From b1e49bc3325a2f8aa1401b8418e097ecb278310d Mon Sep 17 00:00:00 2001 From: pan <1029559041@qq.com> Date: Wed, 4 Nov 2020 08:06:49 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0HAZOP=E7=9F=A5=E8=AF=86?= =?UTF-8?q?=E5=BA=93=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 | 71 +++++++++++++++++++++++++++++++++++++++ routes/project/prepare.js | 2 +- 3 files changed, 74 insertions(+), 2 deletions(-) create mode 100644 routes/project/hazop.js diff --git a/app.js b/app.js index 1a915ed..e589421 100644 --- a/app.js +++ b/app.js @@ -12,6 +12,7 @@ var dataRouter=require('./routes/main/data') var projectDetailRouter=require('./routes/project/project') var infoRouter=require('./routes/project/info') var prepareRouter=require('./routes/project/prepare') +var hazopRouter=require('./routes/project/hazop') const server = require("inspector"); var app = express(); @@ -35,7 +36,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) +app.use('/api/project',projectDetailRouter,infoRouter,prepareRouter,hazopRouter) // 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 new file mode 100644 index 0000000..6ec64e4 --- /dev/null +++ b/routes/project/hazop.js @@ -0,0 +1,71 @@ +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') + +//HAZOP分析 +router.get('/analyse/:id', function (req, res, next) { + var sst=Mock.mock({ + "si|1-100":[{ + t:/\d{3}/ + }] + }) + + var data=Mock.mock({ + ...mock.ok(`HAZOP分析获取节点${req.params.id}数据成功`), + ...{ + body:{ + sst, + sheetData:{ + row:function (){ + let rowCount=20 + let colCount=18 + 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){ + rows[row].c.push({ + r:`${String.fromCharCode(+col+"A".charCodeAt())}${+row+1}`, + s:1, + t:'s', + v:Mock.Random.integer(0,sst.si.length-1) + }) + } + } + return rows + } + }, + mergeCells:{ + mergeCell:[], + count:0 + } + } + } + }) + res.json(data) +}) + +route.addContextMenu(router,'analyse/:id','HAZOP分析') + +//HAZOP偏差知识库 +router.get('/analyse/repository/:know', function (req, res, next) { + var data=mock.page(req,`查询${req.params.know}知识库成功`,{ + //选项值 + key: ()=>Mock.Random.integer(1,5), + //描述 + value: ()=>Mock.Random.word() + }) + res.json(data) +}) + +module.exports=router \ No newline at end of file diff --git a/routes/project/prepare.js b/routes/project/prepare.js index 07c7095..fc21634 100644 --- a/routes/project/prepare.js +++ b/routes/project/prepare.js @@ -71,7 +71,7 @@ router.get('/sdivide/:id', function (req, res, next) { //SIF连带动作 action:()=>Mock.Random.word(), //需求模式 - demandModel:()=>Mock.Random.integer(1,3), + demandModel:()=>`${Mock.Random.integer(1,3)}`, //SIL等级要求 level:()=>Mock.Random.integer(1,10), //触发机构