增加通用右键菜单路由

master
pan 4 years ago
parent 84dbf885ee
commit 049aa1e894
  1. 31
      public/javascripts/route.js
  2. 24
      routes/main/data.js
  3. 4
      routes/project/info.js
  4. 3
      routes/project/project.js

@ -0,0 +1,31 @@
var mock=require('../../public/javascripts/mock')
module.exports= {
//**通用右键菜单接口
addContextMenu:function (router,prefix, label)
{
router.post(`/${prefix}/:y/addEmpty`, function (req, res, next) {
return res.json(mock.ok(`${label}插入第${+req.params.y + 1}空白行成功`))
})
router.post(`/${prefix}/:y/copy`, function (req, res, next) {
return res.json(mock.ok(`拷贝${+req.params.y + 1}${label}并插入到下一行成功`))
})
router.delete(`/${prefix}/:y/del`, function (req, res, next) {
return res.json(mock.ok(`删除第${+req.params.y + 1}${label}成功`))
})
router.delete(`/${prefix}/:y/clean`, function (req, res, next) {
return res.json(mock.ok(`清空第${+req.params.y + 1}${label}成功`))
})
router.patch(`/${prefix}/:y/up`, function (req, res, next) {
return res.json(mock.ok(`${label}${+req.params.y + 1}行跟第${+req.params.y}行交换位置`))
})
router.patch(`/${prefix}/:y/down`, function (req, res, next) {
return res.json(mock.ok(`${label}${+req.params.y + 1}行跟第${+req.params.y + 2}行交换位置`))
})
}
}

@ -8,6 +8,7 @@ var mock=require('../../public/javascripts/mock')
var util=require('../../public/javascripts/util') var util=require('../../public/javascripts/util')
const multipart = require("connect-multiparty"); const multipart = require("connect-multiparty");
var multipartMiddleware = multipart(); var multipartMiddleware = multipart();
var route=require('../../public/javascripts/route')
function base(req,message){ function base(req,message){
return mock.page(req,message,{ return mock.page(req,message,{
@ -53,29 +54,10 @@ router.get('/data',function(req, res, next) {
}) })
router.post('/data',multipartMiddleware,function(req, res, next){ router.post('/data',multipartMiddleware,function(req, res, next){
let data return res.json(mock.ok(`基础数据导入成功`))
const type=req.body.type
console.info(`type=${type}`)
switch (req.body.type){
case 'import':
data = mock.ok(`基础数据导入成功`)
break
case 'addEmpty':
data=mock.ok('基础数据插入空白行成功')
break
case 'copy':
data=mock.ok('基础数据复制行数据成功')
break
}
return res.json(data)
}) })
router.delete('/data',multipartMiddleware,function(req, res, next){
return res.json(mock.ok('基础数据删除成功'))
})
router.patch('/data',multipartMiddleware,function(req, res, next){ route.addContextMenu(router,'data','基础数据')
return res.json(mock.ok('基础数据位置更新成功'))
})
module.exports=router module.exports=router

@ -6,6 +6,7 @@ var multipart = require('connect-multiparty');
var multipartMiddleware = multipart(); var multipartMiddleware = multipart();
var moment = require("moment") var moment = require("moment")
var util=require("../../public/javascripts/util") var util=require("../../public/javascripts/util")
var route=require('../../public/javascripts/route')
//获取一般信息 //获取一般信息
router.get('/info', function (req, res, next) { router.get('/info', function (req, res, next) {
var data={ var data={
@ -46,4 +47,7 @@ router.get('/member', function (req, res, next) {
res.json(data) res.json(data)
}) })
route.addContextMenu(router,'member','团队成员')
module.exports = router module.exports = router

@ -2,6 +2,8 @@ var express = require('express');
var router = express.Router(); var router = express.Router();
var mock = require('../../public/javascripts/mock') var mock = require('../../public/javascripts/mock')
var Mock = require("mockjs") var Mock = require("mockjs")
const multipart = require("connect-multiparty");
var multipartMiddleware = multipart();
router.get('/menu', function (req, res, next) { router.get('/menu', function (req, res, next) {
res.json({ res.json({
@ -41,4 +43,5 @@ router.get('/menu', function (req, res, next) {
}) })
}) })
module.exports = router module.exports = router
Loading…
Cancel
Save