From 0e98f08412e60e35a3f07377a6ef561a905080fb Mon Sep 17 00:00:00 2001 From: pan <1029559041@qq.com> Date: Tue, 27 Oct 2020 02:54:01 +0800 Subject: [PATCH] =?UTF-8?q?=E7=9F=A9=E9=98=B5=E8=AF=A6=E6=83=85=E9=9D=A2?= =?UTF-8?q?=E6=9D=BF=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- routes/project/prepare.js | 98 +++++++++++++++++++++++++++++++++++++++ routes/project/project.js | 3 +- 2 files changed, 100 insertions(+), 1 deletion(-) diff --git a/routes/project/prepare.js b/routes/project/prepare.js index 0be294f..51af64c 100644 --- a/routes/project/prepare.js +++ b/routes/project/prepare.js @@ -82,5 +82,103 @@ router.get('/sdivide', function (req, res, next) { route.addContextMenu(router,'sdivide','SIF节点划分') +router.get('/matrix', function (req, res, next) { + var data=Mock.mock({ + ...mock.ok('获取矩阵列表成功'), + ...{ + "body|1-10":[{ + id:()=>Mock.Random.natural(1,1000), + name:function (){ + return `matrix${this.id}` + }, + "useProjectId|0-2":[/\d{3}/] + }] + } + }) + res.json(data) +}) + +router.get('/matrix/:id', function (req, res, next) { + var data=Mock.mock({ + ...mock.ok('获取矩阵详情成功'), + ...{ + body:{ + id:()=>Mock.Random.natural(1,1000), + "useProjectId|0-2":[/\d{3}/], + info:{ + name:`matrix${Mock.Random.natural(5,8)}`, + desc:`matrix${Mock.Random.natural(5,8)}`, + x:()=>Mock.Random.natural(5,8), + y:()=>Mock.Random.natural(5,8), + explain:()=>Mock.Random.sentence(3, 5) + }, + severity:function (){ + const severity=[] + for(let i in Array.from(new Array(this.info.y).keys())){ + severity.push({ + //等级 + level:Mock.Random.natural(1,9), + //严重程度 + severity:Mock.Random.natural(1,9), + //人员 + personnel:Mock.Random.word(), + //财产 + property:Mock.Random.word(), + //环境 + environment:Mock.Random.word(), + //声誉 + prestige:Mock.Random.word() + }) + } + return severity + }, + possibility:function (){ + const possibility=[] + for(let i in Array.from(new Array(this.info.x).keys())){ + possibility.push({ + //等级 + level:Mock.Random.natural(1,this.info.x), + //概率值 + probability:Mock.Random.natural(1,100)/100, + //描述 + desc:Mock.Random.sentence(3, 5) + }) + } + return possibility + }, + 'level|3-5':[{ + //Code + code:/\d{1}/, + //颜色 + color:()=>Mock.Random.color(), + //描述 + desc:()=>Mock.Random.sentence(3, 5), + //风险等级 + level:/\d{1}/, + //应采取措施 + measure:()=>Mock.Random.sentence(3, 5), + //实施期限 + date:()=>Mock.Random.sentence(3, 5), + //备注 + note:()=>Mock.Random.sentence(3, 5) + }], + matrix:function (){ + const matrix=[] + for(let i in Array.from(new Array(this.info.y).keys())){ + const child=[] + for(let j in Array.from(new Array(this.info.x).keys())){ + child.push(this.level[Mock.Random.natural(0,this.level.length-1)]) + } + matrix.push(child) + } + return matrix + } + + + } + } + }) + res.json(data) +}) module.exports=router \ No newline at end of file diff --git a/routes/project/project.js b/routes/project/project.js index 87418f8..7f1cbbe 100644 --- a/routes/project/project.js +++ b/routes/project/project.js @@ -17,7 +17,8 @@ router.get('/menu', function (req, res, next) { {name: '团队成员',path:'/project/info/team_members'}, {name: '会议信息',path:'/project/info/meeting'}]} ,{name: '项目准备', childMenu: [{name: 'HAZOP节点划分',path:'/project/prepare/hdivide'}, {name: 'HAZOP节点复用',path: '/project/prepare/hreuse'}, - {name: 'SIF节点划分',path:'/project/prepare/sdivide'}, {name: '矩阵选择'}]} + {name: 'SIF节点划分',path:'/project/prepare/sdivide'}, + {name: '矩阵选择',path:'/project/prepare/matrix'}]} ,{name: 'HAZOP分析', childMenu: [{name: 'HAZOP分析'}, {name: 'HAZOP所有'}]} ,{name:'LOPA定级', childMenu: [{name:'LOPA'},{name:'LOPA表单'},{name:'LOPA所有节点'}]} ,{name:'SIL验算', childMenu: [{name:'SIL验算'},{name:'SIL验算[Nodes]'},{name:'SIL验算-总'}]}]