|
|
|
|
|
|
|
|
|
|
|
var express = require('express');
|
|
|
|
var router = express.Router();
|
|
|
|
var Mock = require("mockjs")
|
|
|
|
var moment = require("moment")
|
|
|
|
var mock=require('../../public/javascripts/mock')
|
|
|
|
var util=require('../../public/javascripts/util')
|
|
|
|
const multipart = require("connect-multiparty");
|
|
|
|
var multipartMiddleware = multipart();
|
|
|
|
var route=require('../../public/javascripts/route')
|
|
|
|
|
|
|
|
function base(req,message){
|
|
|
|
return mock.page(req,message,{
|
|
|
|
number:/\d{2}[A-Z]{2}\d{4}/,
|
|
|
|
type:/阀门(Valve)/,
|
|
|
|
name:/[A-Z]{4}-Series/,
|
|
|
|
model:/[A-Z]{2}\d{3}[A-Z]{2}\d{2}/,
|
|
|
|
manufacturer:/[A-Z]/,
|
|
|
|
'sd|100-999':0,
|
|
|
|
'su|100-999':0,
|
|
|
|
'dd|100-999':0,
|
|
|
|
'du|100-999':0,
|
|
|
|
sff:function () {
|
|
|
|
return `${Mock.Random.natural(0,100)}%`
|
|
|
|
},
|
|
|
|
dataSources:'Exida Certification',
|
|
|
|
framework:/[A-Z]/,
|
|
|
|
'tsd|0-10':0,
|
|
|
|
'mttr|1-10':0,
|
|
|
|
'ti':'',
|
|
|
|
'ctr|0-10':0,
|
|
|
|
'lt|0-10':0,
|
|
|
|
htf:'',
|
|
|
|
silLevel:function (){
|
|
|
|
return `${Mock.Random.natural(1,10)}%`
|
|
|
|
},
|
|
|
|
route:function () {
|
|
|
|
return `Route H${Mock.Random.natural(1,10)}`
|
|
|
|
},
|
|
|
|
createUser:function () {
|
|
|
|
return Mock.Random.first()
|
|
|
|
},
|
|
|
|
note:'',
|
|
|
|
createTime:function (){
|
|
|
|
return moment(Date.now()-Mock.Random.natural(3600,36000)*1000).format(util.dateFormat)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
router.get('/data',function(req, res, next) {
|
|
|
|
var data=base(req,'基础数据获取成功')
|
|
|
|
res.json(data)
|
|
|
|
})
|
|
|
|
|
|
|
|
router.post('/data',multipartMiddleware,function(req, res, next){
|
|
|
|
return res.json(mock.ok(`基础数据导入成功`))
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
route.addContextMenu(router,'data','基础数据')
|
|
|
|
|
|
|
|
module.exports=router
|