From 2fdb25579d465edf01edce7c58696a836f8e5d5e Mon Sep 17 00:00:00 2001 From: pan <1029559041@qq.com> Date: Sat, 7 Nov 2020 00:29:10 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E8=8E=B7=E5=8F=96=E8=8A=82?= =?UTF-8?q?=E7=82=B9=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- routes/project/hazop.js | 14 +------- routes/project/prepare.js | 75 ++++++++++++++++++++++++++++++++++----- 2 files changed, 67 insertions(+), 22 deletions(-) diff --git a/routes/project/hazop.js b/routes/project/hazop.js index 08effef..3c640c5 100644 --- a/routes/project/hazop.js +++ b/routes/project/hazop.js @@ -16,11 +16,6 @@ router.get('/analyse/all', function (req, res, next) { }] }) - Array.from(new Array(20).keys()).forEach(value => { - let t={t:`${JSON.stringify({node:Mock.Random.word(),id:Mock.Random.integer(1,10)})}`} - sst.si.push(t) - }) - var data=Mock.mock({ ...mock.ok(`HAZOP分析获取所有节点数据成功`), @@ -45,14 +40,7 @@ router.get('/analyse/all', function (req, res, next) { r: `${col}${+row + 1}`, s: 1, t: 's', - v: (function (col){ - switch (col){ - case 'A': - return Mock.Random.integer(sst.si.length - 20, sst.si.length - 1) - default: - return Mock.Random.integer(0, sst.si.length - 21) - } - })(col) + v: Mock.Random.integer(0, sst.si.length - 1) } ) } diff --git a/routes/project/prepare.js b/routes/project/prepare.js index 2e48231..dafafdc 100644 --- a/routes/project/prepare.js +++ b/routes/project/prepare.js @@ -24,19 +24,32 @@ router.get('/hdivide', function (req, res, next) { }) router.get('/hdivide/all', function (req, res, next) { - var data=mock.page(req,'获取HAOZP节点划分成功',{ - //节点id - id:/\d{3}/, - //节点 - node:()=>Mock.Random.word(), - //节点编号 - nodeId:/Node\d{3}/, - //节点描述 - nodeDesc:()=>Mock.Random.sentence(3, 5), + var data=Mock.mock({ + ...mock.ok('获取所有HAOZP节点划分成功'), + ...{ + body:function (){ + let obj={} + Array.from(new Array(20).keys()).forEach(value => { + obj[Mock.Random.integer(1,999)]=Mock.mock({ + //节点 + node:()=>Mock.Random.word(), + //节点编号 + nodeId:/Node\d{3}/, + //节点描述 + nodeDesc:()=>Mock.Random.sentence(3, 5), + //节点PID号 + nodePid:/PID\d{3}/ + }) + }) + + return obj + } + } }) res.json(data) }) + router.patch('/hdivide/:nodeId', function (req, res, next) { var data=mock.ok(`节点${req.params.nodeId}更新成功`) res.json(data) @@ -93,6 +106,50 @@ router.get('/sdivide/:nodeId', function (req, res, next) { res.json(data) }) +router.get('/sdivide/:nodeId/all', function (req, res, next) { + var data=Mock.mock({ + ...mock.ok('获取所有HAOZP节点划分成功'), + ...{ + body:function (){ + let obj={} + Array.from(new Array(20).keys()).forEach(value => { + obj[Mock.Random.integer(1,999)]=Mock.mock({ + //sif_id + id:/\d{3}/, + //SIF名称 + name:()=>Mock.Random.name(), + //SIF编号 + sifId:/SIF\d{3}/, + //SIF描述 + desc:()=>Mock.Random.sentence(3, 5), + //SIF连带动作 + action:()=>Mock.Random.word(), + //需求模式 + demandModel:()=>`${Mock.Random.integer(1,3)}`, + //SIL等级要求 + level:()=>Mock.Random.integer(1,10), + //触发机构 + impactMmechanism:()=>Mock.Random.word(), + //后果描述 + consequence:()=>Mock.Random.sentence(3, 5), + //安全状态 + status:()=>Mock.Random.word(), + //安全失效等级 + loseEfficacy:()=>Mock.Random.integer(1,10), + //PID号 + pid:/PID\d{3}/, + //备注 + note:()=>Mock.Random.sentence(3, 5) + }) + }) + + return obj + } + } + }) + res.json(data) +}) + router.patch('/sdivide/:nodeId/:id', function (req, res, next) { var data=mock.ok(`节点:${req.params.nodeId},SIF:${req.params.id}更新成功`) res.json(data)