From c4babf2d3b2dad11640606e23d68bdcdbd39f514 Mon Sep 17 00:00:00 2001 From: pan <1029559041@qq.com> Date: Tue, 10 Nov 2020 04:22:12 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0sif=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app.js | 3 +- routes/project/project.js | 2 +- routes/project/sif.js | 59 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 62 insertions(+), 2 deletions(-) create mode 100644 routes/project/sif.js diff --git a/app.js b/app.js index 8af580a..fb8a4c3 100644 --- a/app.js +++ b/app.js @@ -14,6 +14,7 @@ var infoRouter=require('./routes/project/info') var prepareRouter=require('./routes/project/prepare') var hazopRouter=require('./routes/project/hazop') var lopaRouter=require('./routes/project/lopa') +var sifRouter=require('./routes/project/sif') const server = require("inspector"); var app = express(); @@ -37,7 +38,7 @@ app.use(cors({ app.use('/', indexRouter); app.use('/api/account',accountRouter) app.use('/api/main',mainRouter,projectRouter,dataRouter) -app.use('/api/project',projectDetailRouter,infoRouter,prepareRouter,hazopRouter,lopaRouter) +app.use('/api/project',projectDetailRouter,infoRouter,prepareRouter,hazopRouter,lopaRouter,sifRouter) // catch 404 and forward to error handler app.use(function(req, res, next) { diff --git a/routes/project/project.js b/routes/project/project.js index 1549f85..6f14ea6 100644 --- a/routes/project/project.js +++ b/routes/project/project.js @@ -21,7 +21,7 @@ router.get('/menu', function (req, res, next) { {name: '矩阵选择',path:'/project/prepare/matrix'}]} ,{name: 'HAZOP分析', childMenu: [{name: 'HAZOP分析',path:'/project/hazop/analyse'}, {name: 'HAZOP所有',path:'/project/hazop/all'}]} ,{name:'LOPA定级', childMenu: [{name:'LOPA',path:'/project/lopa/lopa'},{name:'LOPA表单',path:'/project/lopa/form'},{name:'LOPA所有节点',path:'/project/lopa/all'}]} - ,{name:'SIL验算', childMenu: [{name:'SIL验算'},{name:'SIL验算[Nodes]'},{name:'SIL验算-总'}]}] + ,{name:'SIL验算', childMenu: [{name:'SIL验算',path:'/project/sif/sif'},{name:'SIL验算[Nodes]'},{name:'SIL验算-总'}]}] config.forEach((item, index) => { let menu = { menuId: `a${index}`, diff --git a/routes/project/sif.js b/routes/project/sif.js new file mode 100644 index 0000000..355bf2f --- /dev/null +++ b/routes/project/sif.js @@ -0,0 +1,59 @@ +var express = require('express'); +var router = express.Router(); +var mock = require('../../public/javascripts/mock') +var Mock = require("mockjs") +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('/sif/:nodeId/:sifId', function (req, res, next) { + var sst=Mock.mock({ + "si|1-100":[{ + t:/\d{3}/ + }] + }) + + var data=Mock.mock({ + ...mock.ok(`LOPA获取节点${req.params.nodeId},${req.params.sifId}数据成功`), + ...{ + body:{ + sst, + sheetData:{ + row:function (){ + let rowCount=50 + let colCount=39 + let rows=Array.from(new Array(rowCount).keys()) + let cols=Array.from(new Array(colCount).keys()) + for(let row in rows){ + rows[+row]={ + r:+row+1, + spans:`1:${colCount}`, + c:[] + } + for(let col in cols){ + col=String.fromCharCode(+col+"A".charCodeAt()) + rows[row].c.push({ + r: `${col}${+row + 1}`, + s: 1, + t: 's', + v: Mock.Random.integer(0, sst.si.length - 1) + } + ) + } + } + return rows + } + }, + mergeCells:{ + mergeCell:[{ref:'F1:F3'},{ref:'F5:F6'}], + count:1 + } + } + } + }) + res.json(data) +}) + +module.exports=router \ No newline at end of file