增加sif接口

master
pan 4 years ago
parent c25a4de634
commit c4babf2d3b
  1. 3
      app.js
  2. 2
      routes/project/project.js
  3. 59
      routes/project/sif.js

@ -14,6 +14,7 @@ var infoRouter=require('./routes/project/info')
var prepareRouter=require('./routes/project/prepare') var prepareRouter=require('./routes/project/prepare')
var hazopRouter=require('./routes/project/hazop') var hazopRouter=require('./routes/project/hazop')
var lopaRouter=require('./routes/project/lopa') var lopaRouter=require('./routes/project/lopa')
var sifRouter=require('./routes/project/sif')
const server = require("inspector"); const server = require("inspector");
var app = express(); var app = express();
@ -37,7 +38,7 @@ app.use(cors({
app.use('/', indexRouter); app.use('/', indexRouter);
app.use('/api/account',accountRouter) app.use('/api/account',accountRouter)
app.use('/api/main',mainRouter,projectRouter,dataRouter) 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 // catch 404 and forward to error handler
app.use(function(req, res, next) { app.use(function(req, res, next) {

@ -21,7 +21,7 @@ router.get('/menu', function (req, res, next) {
{name: '矩阵选择',path:'/project/prepare/matrix'}]} {name: '矩阵选择',path:'/project/prepare/matrix'}]}
,{name: 'HAZOP分析', childMenu: [{name: 'HAZOP分析',path:'/project/hazop/analyse'}, {name: 'HAZOP所有',path:'/project/hazop/all'}]} ,{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:'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) => { config.forEach((item, index) => {
let menu = { let menu = {
menuId: `a${index}`, menuId: `a${index}`,

@ -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
Loading…
Cancel
Save