From 1774693c36de9dbd0788feba8ae4a7c39edbd626 Mon Sep 17 00:00:00 2001 From: pan <1029559041@qq.com> Date: Sat, 7 Nov 2020 19:23:38 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0lopa=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/hazop.js | 13 ++++--- routes/project/lopa.js | 81 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 90 insertions(+), 7 deletions(-) create mode 100644 routes/project/lopa.js diff --git a/app.js b/app.js index e589421..8af580a 100644 --- a/app.js +++ b/app.js @@ -13,6 +13,7 @@ var projectDetailRouter=require('./routes/project/project') var infoRouter=require('./routes/project/info') var prepareRouter=require('./routes/project/prepare') var hazopRouter=require('./routes/project/hazop') +var lopaRouter=require('./routes/project/lopa') const server = require("inspector"); var app = express(); @@ -36,7 +37,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) +app.use('/api/project',projectDetailRouter,infoRouter,prepareRouter,hazopRouter,lopaRouter) // catch 404 and forward to error handler app.use(function(req, res, next) { diff --git a/routes/project/hazop.js b/routes/project/hazop.js index 3c640c5..7a2256c 100644 --- a/routes/project/hazop.js +++ b/routes/project/hazop.js @@ -195,15 +195,16 @@ router.get('/analyse/matrix/:name', function (req, res, next) { res.json(data) }) -route.addContextMenu(router,'analyse/:id','HAZOP分析') - -//HAZOP偏差知识库 +//HAZOP知识库 router.get('/analyse/repository/:know', function (req, res, next) { var data=mock.page(req,`查询${req.params.know}知识库成功`,{ - //选项值 - key: ()=>Mock.Random.word(), + //id + value:/\d{3}/, //描述 - value: ()=>Mock.Random.word() + label: ()=>Mock.Random.word(), + data:function(){ + return this.label + } }) res.json(data) }) diff --git a/routes/project/lopa.js b/routes/project/lopa.js new file mode 100644 index 0000000..ef6edfc --- /dev/null +++ b/routes/project/lopa.js @@ -0,0 +1,81 @@ +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') + +//LOPA知识库 +router.get('/lopa/repository/:know', function (req, res, next) { + var data=mock.page(req,`查询${req.params.know}知识库成功`,{...{ + //id + value:/\d{3}/, + //描述 + label: ()=>Mock.Random.word() + },...(function(col){switch (col){ + case "initialEventDescription": + return { + initialEventDescription:function (){ + return this.label + }, + initialEventProbability:()=>Mock.Random.float(0,1) + } + }})(req.params.know)}) + res.json(data) +}) + + +//lopa +router.get('/lopa/:id/:sif', function (req, res, next) { + var sst=Mock.mock({ + "si|1-100":[{ + t:/\d{3}/ + }] + }) + + var data=Mock.mock({ + ...mock.ok(`LOPA获取节点${req.params.id},${req.params.sif}数据成功`), + ...{ + body:{ + sst, + sheetData:{ + row:function (){ + let rowCount=50 + let colCount=21 + 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:[], + count:0 + } + } + } + }) + res.json(data) +}) + + +module.exports=router \ No newline at end of file