From 049aa1e89441c932814237137b22e81488cb16df Mon Sep 17 00:00:00 2001 From: pan <1029559041@qq.com> Date: Tue, 20 Oct 2020 23:29:13 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E9=80=9A=E7=94=A8=E5=8F=B3?= =?UTF-8?q?=E9=94=AE=E8=8F=9C=E5=8D=95=E8=B7=AF=E7=94=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/javascripts/route.js | 31 +++++++++++++++++++++++++++++++ routes/main/data.js | 24 +++--------------------- routes/project/info.js | 4 ++++ routes/project/project.js | 3 +++ 4 files changed, 41 insertions(+), 21 deletions(-) create mode 100644 public/javascripts/route.js diff --git a/public/javascripts/route.js b/public/javascripts/route.js new file mode 100644 index 0000000..81fc6c3 --- /dev/null +++ b/public/javascripts/route.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}行交换位置`)) + }) +} +} + diff --git a/routes/main/data.js b/routes/main/data.js index baab413..6753545 100644 --- a/routes/main/data.js +++ b/routes/main/data.js @@ -8,6 +8,7 @@ var mock=require('../../public/javascripts/mock') var util=require('../../public/javascripts/util') const multipart = require("connect-multiparty"); var multipartMiddleware = multipart(); +var route=require('../../public/javascripts/route') function base(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){ - let data - 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) + return res.json(mock.ok(`基础数据导入成功`)) }) -router.delete('/data',multipartMiddleware,function(req, res, next){ - return res.json(mock.ok('基础数据删除成功')) -}) -router.patch('/data',multipartMiddleware,function(req, res, next){ - return res.json(mock.ok('基础数据位置更新成功')) -}) +route.addContextMenu(router,'data','基础数据') module.exports=router \ No newline at end of file diff --git a/routes/project/info.js b/routes/project/info.js index 1c5d1db..68b5f88 100644 --- a/routes/project/info.js +++ b/routes/project/info.js @@ -6,6 +6,7 @@ var multipart = require('connect-multiparty'); var multipartMiddleware = multipart(); var moment = require("moment") var util=require("../../public/javascripts/util") +var route=require('../../public/javascripts/route') //获取一般信息 router.get('/info', function (req, res, next) { var data={ @@ -46,4 +47,7 @@ router.get('/member', function (req, res, next) { res.json(data) }) + +route.addContextMenu(router,'member','团队成员') + module.exports = router \ No newline at end of file diff --git a/routes/project/project.js b/routes/project/project.js index f5998ec..fc2ec43 100644 --- a/routes/project/project.js +++ b/routes/project/project.js @@ -2,6 +2,8 @@ var express = require('express'); var router = express.Router(); var mock = require('../../public/javascripts/mock') var Mock = require("mockjs") +const multipart = require("connect-multiparty"); +var multipartMiddleware = multipart(); router.get('/menu', function (req, res, next) { res.json({ @@ -41,4 +43,5 @@ router.get('/menu', function (req, res, next) { }) }) + module.exports = router \ No newline at end of file