Commit e501bb20 authored by zhang's avatar zhang
parents 78e23eaf a2a6730f
const Mock = require('mockjs')
const List = []
const count = 100
const baseContent = '<p>I am testing data, I am testing data.</p><p><img src="https://wpimg.wallstcn.com/4c69009c-0fd4-4153-b112-6cb53d1cf943"></p>'
const image_uri = 'https://wpimg.wallstcn.com/e4558086-631c-425c-9430-56ffb46e70b3'
for (let i = 0; i < count; i++) {
List.push(Mock.mock({
id: '@increment',
timestamp: +Mock.Random.date('T'),
author: '@first',
reviewer: '@first',
title: '@title(5, 10)',
content_short: 'mock data',
content: baseContent,
forecast: '@float(0, 100, 2, 2)',
importance: '@integer(1, 3)',
'type|1': ['CN', 'US', 'JP', 'EU'],
'status|1': ['published', 'draft'],
display_time: '@datetime',
comment_disabled: true,
pageviews: '@integer(300, 5000)',
image_uri,
platforms: ['a-platform']
}))
}
module.exports = [
{
url: '/article/list',
type: 'get',
response: config => {
const { importance, type, title, page = 1, limit = 20, sort } = config.query
let mockList = List.filter(item => {
if (importance && item.importance !== +importance) return false
if (type && item.type !== type) return false
if (title && item.title.indexOf(title) < 0) return false
return true
})
if (sort === '-id') {
mockList = mockList.reverse()
}
const pageList = mockList.filter((item, index) => index < limit * page && index >= limit * (page - 1))
return {
code: 20000,
data: {
total: mockList.length,
items: pageList
}
}
}
},
{
url: '/article/detail',
type: 'get',
response: config => {
const { id } = config.query
for (const article of List) {
if (article.id === +id) {
return {
code: 20000,
data: article
}
}
}
}
},
{
url: '/article/pv',
type: 'get',
response: _ => {
return {
code: 20000,
data: {
pvData: [
{ key: 'PC', pv: 1024 },
{ key: 'mobile', pv: 1024 },
{ key: 'ios', pv: 1024 },
{ key: 'android', pv: 1024 }
]
}
}
}
},
{
url: '/article/create',
type: 'post',
response: _ => {
return {
code: 20000,
data: 'success'
}
}
},
{
url: '/article/update',
type: 'post',
response: _ => {
return {
code: 20000,
data: 'success'
}
}
}
]
const Mock = require('mockjs')
const { param2Obj } = require('./utils')
const task = require('./task')
const user = require('./user')
const role = require('./role')
const article = require('./article')
const search = require('./remote-search')
const setting = require('./setting')
const review = require('./review')
const mocks = [...task, ...setting, ...review]
// for front mock
// please use it cautiously, it will redefine XMLHttpRequest,
// which will cause many of your third-party libraries to be invalidated(like progress event).
function mockXHR() {
// mock patch
// https://github.com/nuysoft/Mock/issues/300
Mock.XHR.prototype.proxy_send = Mock.XHR.prototype.send
Mock.XHR.prototype.send = function () {
if (this.custom.xhr) {
this.custom.xhr.withCredentials = this.withCredentials || false
if (this.responseType) {
this.custom.xhr.responseType = this.responseType
}
}
this.proxy_send(...arguments)
}
function XHR2ExpressReqWrap(respond) {
return function (options) {
let result = null
if (respond instanceof Function) {
const { body, type, url } = options
// https://expressjs.com/en/4x/api.html#req
result = respond({
method: type,
body: JSON.parse(body),
query: param2Obj(url)
})
} else {
result = respond
}
return Mock.mock(result)
}
}
for (const i of mocks) {
Mock.mock(
new RegExp(i.url),
i.type || 'get',
XHR2ExpressReqWrap(i.response)
)
}
}
module.exports = {
mocks,
mockXHR
}
const chokidar = require('chokidar')
const bodyParser = require('body-parser')
const chalk = require('chalk')
const path = require('path')
const Mock = require('mockjs')
const mockDir = path.join(process.cwd(), 'mock')
function registerRoutes(app) {
let mockLastIndex
const { mocks } = require('./index.js')
const mocksForServer = mocks.map(route => {
return responseFake(route.url, route.type, route.response)
})
for (const mock of mocksForServer) {
app[mock.type](mock.url, mock.response)
mockLastIndex = app._router.stack.length
}
const mockRoutesLength = Object.keys(mocksForServer).length
return {
mockRoutesLength: mockRoutesLength,
mockStartIndex: mockLastIndex - mockRoutesLength
}
}
function unregisterRoutes() {
Object.keys(require.cache).forEach(i => {
if (i.includes(mockDir)) {
delete require.cache[require.resolve(i)]
}
})
}
// for mock server
const responseFake = (url, type, respond) => {
console.log(process.env.VUE_APP_BASE_API);
console.log(url);
return {
url: new RegExp(`${process.env.VUE_APP_BASE_API}${url}`),
type: type || 'get',
response(req, res) {
console.log('request invoke:' + req.path)
res.json(Mock.mock(respond instanceof Function ? respond(req, res) : respond))
}
}
}
module.exports = app => {
// parse app.body
// https://expressjs.com/en/4x/api.html#req.body
app.use(bodyParser.json())
app.use(bodyParser.urlencoded({
extended: true
}))
const mockRoutes = registerRoutes(app)
var mockRoutesLength = mockRoutes.mockRoutesLength
var mockStartIndex = mockRoutes.mockStartIndex
// watch files, hot reload mock server
chokidar.watch(mockDir, {
ignored: /mock-server/,
ignoreInitial: true
}).on('all', (event, path) => {
if (event === 'change' || event === 'add') {
try {
// remove mock routes stack
app._router.stack.splice(mockStartIndex, mockRoutesLength)
// clear routes cache
unregisterRoutes()
const mockRoutes = registerRoutes(app)
mockRoutesLength = mockRoutes.mockRoutesLength
mockStartIndex = mockRoutes.mockStartIndex
console.log(chalk.magentaBright(`\n > Mock Server hot reload success! changed ${path}`))
} catch (error) {
console.log(chalk.redBright(error))
}
}
})
}
const Mock = require('mockjs')
const NameList = []
const count = 100
for (let i = 0; i < count; i++) {
NameList.push(Mock.mock({
name: '@first'
}))
}
NameList.push({ name: 'mock-Pan' })
module.exports = [
// username search
{
url: '/search/user',
type: 'get',
response: config => {
const { name } = config.query
const mockNameList = NameList.filter(item => {
const lowerCaseName = item.name.toLowerCase()
return !(name && lowerCaseName.indexOf(name.toLowerCase()) < 0)
})
return {
code: 20000,
data: { items: mockNameList }
}
}
},
// transaction list
{
url: '/transaction/list',
type: 'get',
response: _ => {
return {
code: 20000,
data: {
total: 20,
'items|20': [{
order_no: '@guid()',
timestamp: +Mock.Random.date('T'),
username: '@name()',
price: '@float(1000, 15000, 0, 2)',
'status|1': ['success', 'pending']
}]
}
}
}
}
]
module.exports = [
{
url: '/wait-list',
type: 'get',
response: config => {
temp = [
{
reviewNo: '20231209001',
reviewType: '新增场景',
type: 1,
sceneCategory: '车型审查',
sceneContent: '制度发布会音频文件',
reviewer: '赵晓东,盖献康,刘佳',
waitingTime: '1天12小时',
createTime: '2023-11-24 10:14:08'
},
{
reviewNo: '20231209002',
reviewType: '修改场景',
type: 2,
sceneCategory: '体系审查',
sceneContent: 'TBOX-蜂窝以太网接口',
reviewer: '赵晓东,尚志伟,闫嘉旭',
waitingTime: '1天13小时',
createTime: '2023-11-22 13:56:34'
},
{
reviewNo: '20231209003',
reviewType: '删除场景',
type: 3,
sceneCategory: '体系审查',
sceneContent: 'TBOX-车辆定位系统',
reviewer: '周朋,李宇涵,李亚涛',
waitingTime: '2天1小时',
createTime: '2023-11-13 17:26:54'
},
{
reviewNo: '20231209004',
reviewType: '修改场景',
type: 2,
sceneCategory: '车型审查',
sceneContent: '发布会车辆制动相关样品',
reviewer: '张鹏伟,李旭,张鑫',
waitingTime: '2天1小时',
createTime: '2023-11-12 14:43:22'
},
{
reviewNo: '20231209005',
reviewType: '删除场景',
type: 3,
sceneCategory: '车型审查',
sceneContent: '保障智能网联汽车时空数据存储文件',
reviewer: '孟同伟,孙钊涵,邵亮',
waitingTime: '3天3小时',
createTime: '2023-11-06 12:45:23'
},
{
reviewNo: '20231209001',
reviewType: '删除场景',
sceneCategory: '车型审查',
sceneContent: '智能网联汽车的访问控制-加密操作硬件',
reviewer: '李旭,孟同伟,张鑫',
waitingTime: '5天5小时',
createTime: '2023-11-02 08:12:56'
}
]
return {
rows: temp,
code: 200,
total: 10
}
}
}
]
const Mock = require('mockjs')
const { deepClone } = require('../utils')
const { asyncRoutes, constantRoutes } = require('./routes.js')
const routes = deepClone([...constantRoutes, ...asyncRoutes])
const roles = [
{
key: 'admin',
name: 'admin',
description: 'Super Administrator. Have access to view all pages.',
routes: routes
},
{
key: 'editor',
name: 'editor',
description: 'Normal Editor. Can see all pages except permission page',
routes: routes.filter(i => i.path !== '/permission')// just a mock
},
{
key: 'visitor',
name: 'visitor',
description: 'Just a visitor. Can only see the home page and the document page',
routes: [{
path: '',
redirect: 'dashboard',
children: [
{
path: 'dashboard',
name: 'Dashboard',
meta: { title: 'dashboard', icon: 'dashboard' }
}
]
}]
}
]
module.exports = [
// mock get all routes form server
{
url: '/routes',
type: 'get',
response: _ => {
return {
code: 20000,
data: routes
}
}
},
// mock get all roles form server
{
url: '/roles',
type: 'get',
response: _ => {
return {
code: 20000,
data: roles
}
}
},
// add role
{
url: '/role',
type: 'post',
response: {
code: 20000,
data: {
key: Mock.mock('@integer(300, 5000)')
}
}
},
// update role
{
url: '/role/[A-Za-z0-9]',
type: 'put',
response: {
code: 20000,
data: {
status: 'success'
}
}
},
// delete role
{
url: '/role/[A-Za-z0-9]',
type: 'delete',
response: {
code: 20000,
data: {
status: 'success'
}
}
}
]
module.exports = [
// get tasklist
{
url: '/standard-list',
type: 'get',
response: config => {
const query = config.query
let temp = []
if (query.type === '1') {
temp = [
{
category: '网络安全',
section: 'GB/T 40857—2021',
request:
'汽车网关信息安全技术要求及试验方法',
resultYes: '汽车网关信息安全技术要求及试验方法.pdf',
resultNO: '现行',
createTime: '@datetime'
},
{
category: '软件升级',
section: 'GB/T 40857—2021',
request:
'车载信息交互系统信息安全技术要求及试验方法',
resultYes: '车载信息交互系统信息安全技术要求及试验方法.pdf',
resultNO: '报批中',
createTime: '@datetime'
}
]
} else {
temp = [
{
category: '车型检验',
section: '7.1.1.1',
request:
'车端具备远程控制功能的系统、授权的第三方应用等外部连接系统不应存在由汽车行业权威漏洞平台6个月前公布且未经处置的高危及以上的安全漏洞。注1:汽车行业权威漏洞平台如车联网产品专用漏洞库NVDB-CAVD等政府主管部门认可的其他漏洞平台。注2:处置包括消除漏洞、制定减缓措施等方式。',
resultYes:
'车端具备远程控制功能的系统、授权的第三方应用等外部连接系统不存在由汽车行业权威漏洞平台6个月前公布且未经处置的高危及以上的安全漏洞。',
resultNO:
'端具备远程控制功能的系统、授权的第三方应用等外部连接系统存在由汽车行业权威漏洞平台6个月前公布且未经处置的高危及以上的安全漏洞。',
way: {
text: '测试人员应使用漏洞扫描工具对车辆外部连接系统进行漏洞扫描,并将测试结果与汽车行业权威漏洞平台6个月前公布的高危及以上的安全漏洞清单和车辆生产企业提供的车辆外部连接系统漏洞处置方案进行比对,测试车辆是否满足7.1.1.1的要求',
object: [
{
text: '①远控系统对应的通信零件 (TBOX、IVI外部连接系统)',
scene: [
{
text: 'TBOX-蜂窝以太网接口'
},
{
text: 'TBOX 固件'
},
{
text: 'WiFi AP接口'
},
{
text: 'WiFi Client接口'
},
{
text: '车载信息交互系统固件'
}
]
},
{
text: '②车载信息交互系统中第三方应用软件包',
scene: [
{
text: 'TBOX-蜂窝以太网接口'
}
]
}
]
}
},
{
category: '车型检验',
section: '7.1.2.4',
request: '应对车端具备远程控制功能的系统进行完整性验证。',
resultYes: 'xxxxxxxxxxxxxxx',
resultNO: 'xxxxxxxxxxxxxxx',
way: {
text: '测试人员根据车辆生产企业提供的车辆远程控制功能系统完整性校验功能的证明文件,检查车辆是否满足7.1.2.4的要求。',
object: []
}
}
]
}
return {
rows: temp,
code: 200,
total: 10
}
}
},
{
url: '/rules-list',
type: 'post',
response: config => {
const query = config.body
console.log('config');
console.log(config);
let temp = []
if (query.type === '1' || query.type === '2') {
temp = [
{
label:
'5.1 车辆制造商应具备车辆全生命周期的汽车信息安全管理体系。注:车辆全生命周期包括车辆的开发阶段、生产阶段及后生产阶段。',
children: [
{
label: '车辆制造商是否建立汽车信息安全管理制度。',
children: [
{
label:
'车辆制造商是否能够提供/展示汽车信息安全管理制度文件,制度文件应定义信息安全政策以及信息安全规则和流程,信息安全政策应致力于管理与车辆制造商活动相关的信息安全风险。'
// children: [{
// label: '--'
// }]
},
{
label:
'车辆制造商是否能够提供/展示汽车信息安全管理制度正式发布的证明材料。',
children: [
{
label: '1.管理制度发布会红头文件'
},
{
label: '2.管理制度正式发布会议纪要'
},
{
label: '3.专用系统正式发布流程或记录'
}
]
}
]
},
{
label:
'车辆制造商汽车信息安全管理制度是否明确汽车信息安全管理制度适用于车辆全生命周期,包括开发阶段、生产阶段及后生产阶段。',
children: [
{
label:
'车辆制造商汽车信息安全管理制度中明确覆盖了车辆全生命周期,包括开发阶段、生产阶段及后生产阶段,且能够提供每个阶段的流程文件。'
// children: [{
// label: '--'
// }]
}
]
},
{
label:
'车辆全生命周期每个阶段的流程文件能够包含相应阶段的信息安全活动及要求。',
children: [
{
label:
'开发阶段流程文件应包含概念设计、设计开发和测试验证阶段的信息安全活动及要求。'
// children: [{
// label: '--'
// }]
},
{
label:
'生产阶段流程文件应包含生产控制计划制定,生产控制计划应包含生产阶段的信息安全需求,确保生产环节的信息安全需求能够顺利落地实施,且不引入新的信息安全漏洞。'
// children: [{
// label: '--'
// }]
},
{
label:
'后生产阶段流程文件应考虑运维阶段、终止支持、退役阶段的信息安全需求,运维阶段包含网络安全事件响应和软件升级。'
// children: [{
// label: '--'
// }]
}
]
}
]
},
{
label:
'5.2 汽车信息安全管理体系应包括以下内容。建立企业内部管理汽车信息安全的过程。',
children: [
{
label:
'车辆制造商汽车信息安全管理制度是否建立并明确汽车信息安全管理制度的组织架构及权责。',
children: [
{
label:
'车辆制造商汽车信息安全管理制度的角色应覆盖车辆/车辆产品在生命周期中的信息安全活动。',
children: [
{
label:
'1.汽车信息安全管理制度或其配套的流程文件中包含流程图,定义了信息安全活动及对应的角色,并有角色的权责定义。'
}
]
},
{
label:
'车辆制造商汽车信息安全管理制度的角色应与车辆制造商的组织架构匹配。',
children: [
{
label:
'1.汽车信息安全管理制度中定义的角色与车辆制造商的组织架构岗位名称一致。'
},
{
label:
'2.汽车信息安全管理制度中定义的角色与车辆制造商的组织架构岗位有映射关系。'
}
]
}
]
},
{
label:
'车辆制造商汽车信息安全管理制度是否明确为保障汽车信息安全需求实现和维持所投入的资源。',
children: [
{
label:
'车辆制造商应提供在信息安全方面提供资源支持的证明材料,包括投入的场地、基础软硬件设备、技术人员和资金等。',
children: [
{
label:
'1.典型的资源要求为人力投入,例如负责网络安全风险管理的人员、研发人员和事件管理响应人员。'
}
]
}
]
},
{
label:
'车辆制造商汽车信息安全管理制度是否明确与其它管理流程(如QMS、ISMS)的适配性。',
children: [
{
label:
'车辆制造商应提供信息安全管理制度在建设实施中与企业其他管理流程相适配的证明材料。',
children: [
{
label:
'1.明确信息安全管理要求融合到现有管理制度流程中,如在现有ISMS制度中增加汽车信息安全管理要求。'
},
{
label:
'2.在信息安全管理制度中明确与其它管理流程的接口。'
}
]
}
]
}
]
}
]
} else if (query.type === '3') {
temp = [
{
section: '7.1.2.1',
require: '应对车端具备远程控制功能的系统进行完整性验证。',
test: '测试人员根据车辆生产企业提供的车辆远程控制功能系统完整性校验功能的证明文件,检查车辆是否满足7.1.2.4的要求。',
check: '.审查远程控制系统对应的通信零件关于安全刷写或安全启动的设计方案与测试验证材料,若提供证明文件满足正确性和充分性要求,则测试通过,否则测试不通过。',
createTime: '@datetime'
}
]
for (let index = 1; index < 8; index++) {
temp.push({
section: '7.1.2.' + index,
require: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
test: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
check: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
createTime: '@datetime'
})
}
}
return {
rows: temp,
code: 200,
total: 10
}
}
},
{
url: '/scene-list',
type: 'get',
response: config => {
let temp = []
temp = [
{
code: '101',
type: '车型检验',
content: 'TBOX-蜂窝以太网接口',
testType: '系统服务漏扫、固件代码漏扫',
user: 'admin',
createTime: '@datetime'
},
{
code: '102',
type: '车型检验',
content: 'TBOX 固件',
testType: '端口扫描、篡改伪造',
user: 'admin',
createTime: '@datetime'
},
{
code: '103',
type: '车型检验',
content: 'WiFi AP接口',
testType: '系统服务漏扫、固件代码漏扫',
user: 'admin',
createTime: '@datetime'
},
{
code: '104',
type: '车型检验',
content: 'WiFi Client接口',
testType: '固件代码漏扫、端口扫描、篡改伪造',
user: 'admin',
createTime: '@datetime'
},
{
code: '105',
type: '车型检验',
content: '车载信息交互系统固件',
testType: '系统服务漏扫、固件代码漏扫、模糊测试、拒绝服务',
user: 'admin',
createTime: '@datetime'
},
{
code: '101',
type: '车型检验',
content: 'TBOX-蜂窝以太网接口',
testType: '系统服务漏扫、固件代码漏扫',
user: 'admin',
createTime: '@datetime'
},
{
code: '106',
type: '车型检验',
content: '第三方应用软件',
testType: '非授权安装',
user: 'admin',
createTime: '@datetime'
}
]
return {
rows: temp,
code: 200,
total: 10
}
}
}
]
/**
* 参考https://github.com/nuysoft/Mock/wiki/Syntax-Specification
* */
module.exports = [
// get tasklist
{
url: '/tasklist',
type: 'get',
response: config => {
const temp = [
{
startTime: '--',
missionNo: 'xxxxxxxxx',
tit: '一汽丰田体系审查',
owener: '@cname',
'costTime': 0,
'progress': 0
},
{
startTime: '2020-12-01 10:30 ',
missionNo: 'xxxxxxxxx',
tit: '一汽丰田体系审查',
owener: '@cname',
'costTime': 3,
'progress': 80
},
{
startTime: '2020-12-01 10:30',
missionNo: 'xxxxxxxxx',
tit: '一汽丰田体系审查',
owener: '@cname',
'costTime': 12,
'progress': 90
}
]
return {
rows: temp,
code: 200,
total: 10
}
}
},
{
url: '/finishTasklist',
type: 'get',
response: config => {
const temp = [
{
startTime: '2020-12-01 10:30 ',
missionNo: 'xxxxxxxxx',
tit: '一汽丰田体系审查',
owener: '@cname',
'costTime': 3,
'progress': 80
},
{
startTime: '2020-12-01 10:30',
missionNo: 'xxxxxxxxx',
tit: '一汽丰田体系审查',
owener: '@cname',
'costTime': 12,
'progress': 90
}
]
return {
rows: temp,
code: 200,
total: 10
}
}
},
// get taskCarType
{
url: '/taskCarType',
type: 'get',
response: config => {
const temp = [
{
startTime: '----',
missionNo: 'xxxx',
tit: '广汽丰田车型测评1210',
owener: '@cname',
'costTimeOne': 0,
'costTimeTwo': 0,
'progressOne': 0,
'progressTwo': 0,
docTypeOne:1,
docTypeTwo:2,
},
{
startTime: ' 2020-12-01 10:30',
missionNo: 'xxxx',
tit: '广汽丰田车型测评1210',
owener: '@cname',
'costTimeOne': 12,
'costTimeTwo': 0,
'progressOne': 80,
'progressTwo': 0,
docTypeOne:3,
docTypeTwo:2,
},
{
startTime: ' 2020-12-01 10:30',
missionNo: 'xxxx',
tit: '广汽丰田车型测评1210',
owener: '@cname',
'costTimeOne': 24,
'costTimeTwo': 3,
'progressOne': 90,
'progressTwo': 30,
docTypeOne:4,
docTypeTwo:2,
},
{
startTime: ' 2020-12-01 10:30',
missionNo: 'xxxx',
tit: '广汽丰田车型测评1210',
owener: '@cname',
'costTimeOne': 25,
'costTimeTwo': 1,
'progressOne': 100,
'progressTwo': 30,
docTypeOne:5,
docTypeTwo:6,
},
{
startTime: ' 2020-12-01 10:30',
missionNo: 'xxxx',
tit: '广汽丰田车型测评1210',
owener: '@cname',
'costTimeOne': 49,
'costTimeTwo': 25,
'progressOne': 100,
'progressTwo': 90,
docTypeOne:5,
docTypeTwo:7,
},
{
startTime: ' 2020-12-01 10:30',
missionNo: 'xxxx',
tit: '广汽丰田车型测评1210',
owener: '@cname',
'costTimeOne': 49,
// 'costTimeTwo': 25,
'progressOne': 100,
// 'progressTwo': 90,
docTypeOne:1,
// docTypeTwo:1,
}
]
return {
rows: temp,
code: 200,
total: 10
}
}
},
{
url: '/company/list',
type: 'get',
response: config => {
const temp = []
for (let i = 0; i < 10; i++) {
temp.push({
companyName: 'xxxxx',
address: 'xxxxx',
mailCode: 'xxxxx',
companyPeople: 'xxxxx',
phoneNum: 'xxxxx',
createTime: '2020-11-25 23:26:08'
})
}
return {
rows: temp,
code: 200,
total: 10
}
}
}
]
const tokens = {
admin: 'admin-token',
editor: 'editor-token'
}
const users = {
'admin-token': {
user: {
avatar:''
},
roles: ['editor'],
},
'editor-token': {
roles: ['editor'],
introduction: 'I am an editor',
avatar: 'https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif',
name: 'Normal Editor'
}
}
module.exports = [
// user login
{
url: '/login',
type: 'post',
response: config => {
const { username } = config.body
const token = tokens[username]
// mock error
if (!token) {
return {
code: 60204,
message: 'Account and password are incorrect.'
}
}
return {
code: 200,
token:tokens[username]
}
}
},
// get user info
{
url: '/getInfo\.*',
type: 'get',
response: config => {
const { token } = config.query
const info = users[token]
// mock error
if (!info) {
return {
code: 50008,
message: 'Login failed, unable to get user details.'
}
}
return {
code: 200,
data: info
}
}
},
// user logout
{
url: '/logout',
type: 'post',
response: _ => {
return {
code: 200,
data: 'success'
}
}
},
{
url: '/captchaImage',
type: 'get',
response: _ => {
return {
code: 200,
message: 'Login failed, unable to get user details.'
}
}
}
]
/**
* @param {string} url
* @returns {Object}
*/
function param2Obj(url) {
const search = decodeURIComponent(url.split('?')[1]).replace(/\+/g, ' ')
if (!search) {
return {}
}
const obj = {}
const searchArr = search.split('&')
searchArr.forEach(v => {
const index = v.indexOf('=')
if (index !== -1) {
const name = v.substring(0, index)
const val = v.substring(index + 1, v.length)
obj[name] = val
}
})
return obj
}
/**
* This is just a simple version of deep copy
* Has a lot of edge cases bug
* If you want to use a perfect deep copy, use lodash's _.cloneDeep
* @param {Object} source
* @returns {Object}
*/
function deepClone(source) {
if (!source && typeof source !== 'object') {
throw new Error('error arguments', 'deepClone')
}
const targetObj = source.constructor === Array ? [] : {}
Object.keys(source).forEach(keys => {
if (source[keys] && typeof source[keys] === 'object') {
targetObj[keys] = deepClone(source[keys])
} else {
targetObj[keys] = source[keys]
}
})
return targetObj
}
module.exports = {
param2Obj,
deepClone
}
...@@ -313,7 +313,7 @@ ...@@ -313,7 +313,7 @@
align-items: center; align-items: center;
justify-content: flex-start; justify-content: flex-start;
height: 8rem; height: 8rem;
// margin-bottom: 2em;
&-img { &-img {
width: 100px; width: 100px;
height: 100px; height: 100px;
......
...@@ -69,7 +69,7 @@ const standard = { ...@@ -69,7 +69,7 @@ const standard = {
} }
commit( commit(
'SET_STANDARD_LIST', 'SET_STANDARD_LIST',
res.rows.filter(i => i.standardStatus === 'INFORCE') res.rows.filter(i => (i.standardStatus === 'INFORCE'||i.standardStatus === 'SOON'))
) )
} }
}) })
......
...@@ -205,7 +205,7 @@ export default { ...@@ -205,7 +205,7 @@ export default {
this.bottom = this.bottom.concat( this.bottom = this.bottom.concat(
{ {
title: '检测方案', title: '检测方案',
link: '/plan/customized', link: '/plan/list',
img: require('@/assets/images/home/bottom5.png') img: require('@/assets/images/home/bottom5.png')
}, },
{ {
...@@ -245,7 +245,7 @@ export default { ...@@ -245,7 +245,7 @@ export default {
}, },
{ {
title: '权限管理', title: '权限管理',
link: '/system/role', link: '/system/dept',
img: require('@/assets/images/home/bottom6.png') img: require('@/assets/images/home/bottom6.png')
} }
) )
......
...@@ -179,7 +179,7 @@ export default { ...@@ -179,7 +179,7 @@ export default {
this.$store this.$store
.dispatch('Login', this.loginForm) .dispatch('Login', this.loginForm)
.then(() => { .then(() => {
this.$router.push({ path: this.redirect || '/' }).catch(() => {}) this.$router.push({ path: '/' }).catch(() => {})
}) })
.catch(() => { .catch(() => {
this.loading = false this.loading = false
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
v-for="item in standardList" v-for="item in standardList"
:key="item.id" :key="item.id"
:label="item.name" :label="item.name"
:value="Number(item.id)" :value="item.id"
> >
</el-option> </el-option>
</el-select> </el-select>
...@@ -60,7 +60,7 @@ ...@@ -60,7 +60,7 @@
v-for="item in componentSelect" v-for="item in componentSelect"
:key="item.id" :key="item.id"
:label="item.enterpriseName" :label="item.enterpriseName"
:value="Number(item.id)" :value="item.id"
> >
</el-option> </el-option>
</el-select> </el-select>
...@@ -162,7 +162,7 @@ export default { ...@@ -162,7 +162,7 @@ export default {
} else { } else {
this.handleLoad() this.handleLoad()
this.form = { this.form = {
inspectionStandardId: 1, inspectionStandardId:"1",
inspectionItem: ['trfis'] inspectionItem: ['trfis']
} }
} }
...@@ -185,13 +185,11 @@ export default { ...@@ -185,13 +185,11 @@ export default {
}) })
}, },
async handleConfirm() { async handleConfirm() {
this.$refs.form.validate(async valid => { this.$refs.form.validate(async valid => {
if (valid) { if (valid) {
let form = JSON.parse(JSON.stringify(this.form)) let form = JSON.parse(JSON.stringify(this.form))
if (form.inspectionItem.indexOf('trfis') !== -1) {
if(form.inspectionItem.indexOf('trfis') !== -1){
const res = await this.$refs.check.getValidateVaule() const res = await this.$refs.check.getValidateVaule()
form.specifyPlan = JSON.stringify(res.record) form.specifyPlan = JSON.stringify(res.record)
form.useCaseNo = res.codes form.useCaseNo = res.codes
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
v-for="item in componentSelect" v-for="item in componentSelect"
:key="item.id" :key="item.id"
:label="item.enterpriseName" :label="item.enterpriseName"
:value="item.id" :value="String(item.id)"
> >
</el-option> </el-option>
</el-select> </el-select>
...@@ -90,7 +90,7 @@ ...@@ -90,7 +90,7 @@
</el-table-column> </el-table-column>
<el-table-column <el-table-column
label="检测机构" label="检测机构"
prop="testOrganizationName" prop="deptName"
min-width="200" min-width="200"
align="left" align="left"
sortable sortable
...@@ -103,7 +103,7 @@ ...@@ -103,7 +103,7 @@
v-if="scope.row.fileUrl" v-if="scope.row.fileUrl"
>{{ scope.row.testResult }}</el-link >{{ scope.row.testResult }}</el-link
> >
<div v-else>___</div> <div v-else>--</div>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column <el-table-column
...@@ -115,15 +115,21 @@ ...@@ -115,15 +115,21 @@
> >
<template slot-scope="scope"> <template slot-scope="scope">
<div class="button-bar"> <div class="button-bar">
<el-button type="text" @click="goDetail(scope.row.id)"> <page-button
查看方案</el-button icon="preview-open"
> title="查看"
<el-button type="text" @click="handleUpdate(scope.row.id)"> @click="goDetail(scope.row.id)"
修改</el-button ></page-button>
> <page-button
<el-button type="text" @click="handleDelete(scope.row.id)"> icon="edit"
删除</el-button title="修改"
> @click="handleUpdate(scope.row.id)"
></page-button>
<page-button
icon="delete"
title="删除"
@click="handleDelete(scope.row.id)"
></page-button>
<el-upload <el-upload
ref="fileUpload" ref="fileUpload"
:action="uploadFileUrl" :action="uploadFileUrl"
...@@ -137,12 +143,13 @@ ...@@ -137,12 +143,13 @@
:headers="headers" :headers="headers"
class="upload-file-uploader" class="upload-file-uploader"
> >
<el-button type="text" v-if="!scope.row.fileUrl" <page-button
>上传结果 icon="upload-logs"
</el-button> title="上传结果"
<el-button type="text" v-else> 重新上传 </el-button> ></page-button>
</el-upload> </el-upload>
</div> </div>
</div>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
......
...@@ -342,8 +342,6 @@ import DeleteUseCase from './deleteUseCase' ...@@ -342,8 +342,6 @@ import DeleteUseCase from './deleteUseCase'
import UpdateUseCase from './updateUseCase' import UpdateUseCase from './updateUseCase'
import { testInitatereview } from '@/api/task/test' import { testInitatereview } from '@/api/task/test'
import { color } from 'echarts'
import UserSelect from 'autoprefixer/lib/hacks/user-select'
export default { export default {
name: 'CreateReview', name: 'CreateReview',
......
...@@ -148,7 +148,7 @@ export default { ...@@ -148,7 +148,7 @@ export default {
} }
</script> </script>
<style lang="scss" scoped> <style lang="scss" >
.view-review { .view-review {
.view-review-header { .view-review-header {
display: flex; display: flex;
......
<template>
<page-standard>
<div class="form-signature-confirmation">
<div class="title-display">
<span class="title-i"></span>
<span class="title-content">车企基本信息</span>
</div>
</div>
<div class="task-box">
<div class="task-header">
<div class="task-item">
<span class="task-label">企业名称:</span>
<span class="task-content">
{{ model.enterpriseName }}
</span>
</div>
<div class="task-item">
<span class="task-label">企业地址:</span>
<span class="task-content">
{{ model.address }}
</span>
</div>
<div class="task-item">
<span class="task-label">企业邮编:</span>
<span class="task-content">
{{ model.postcode }}
</span>
</div>
<div class="task-item">
<span class="task-label">企业联系人:</span>
<span class="task-content"> {{ model.enterpriseContact }} </span>
</div>
</div>
</div>
<div class="form-signature-confirmation">
<div class="title-display">
<span class="title-i"></span>
<span class="title-content">车型检测方案</span>
</div>
</div>
<el-table border :scroll-x="'1500px'" :data="tableData">
<el-table-column type="index" width="55" label="序号" align="center">
</el-table-column>
<el-table-column
label="车辆VIN号"
show-overflow-tooltip
prop="carModel"
min-width="200"
align="left"
>
</el-table-column>
<el-table-column
label="检测机构"
show-overflow-tooltip
prop="deptName"
min-width="200"
align="left"
>
</el-table-column>
<el-table-column
label="检测方案生成时间"
show-overflow-tooltip
prop="createTime"
min-width="200"
align="left"
>
</el-table-column>
<el-table-column
label="操作"
align="center"
min-width="160"
fixed="right"
class-name="small-padding fixed-width"
>
<template slot-scope="scope">
<div class="button-bar">
<el-button type="text" @click="goDetail(scope.row.id)">
查看方案详情</el-button
>
<el-button type="text" @click="goFile(scope.row.fileUrl)">
查看结果</el-button
>
</div>
</template>
</el-table-column>
</el-table>
<pagination
v-show="total > 0"
:total="total"
:background="false"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
@pagination="loadData"
>
</pagination>
<!--返回按钮-->
<div class="bottom-btn">
<footer-button type="default" icon="arrow-left" @click="$router.go(-1)">
返回
</footer-button>
</div>
</page-standard>
</template>
<script>
import page from '@/mixins/page'
export default {
mixins: [page],
data() {
return {
model: this.$modelDataSource({
url: '/system/enterprise',
dataKey: 'model',
attributes: {
address: '',
contactNumber: '',
enterpriseContact: '',
enterpriseName: '',
id: 0,
// params: '',
postcode: ''
// remark: ''
}
}),
listUrl: '/Plan/Record/page',
queryParams: {
inspectCarCompanyId: 1
},
showSearch: true,
tableData: []
}
},
methods: {
goDetail(id) {
this.$router.push({
path: '/plan/detail?id=' + id
})
},
goFile(url) {
if (url) {
location.href = process.env.VUE_APP_IMAGE_API + url
} else {
this.$message.error('暂无检测结果')
}
},
handleReturn() {
this.$router.back()
}
},
created() {
this.queryParams.inspectCarCompanyId = this.$route.query.id
this.model.fetch(this.$route.query.id)
}
}
</script>
<style lang="scss" scoped>
.right-content {
width: 100%;
display: flex;
justify-content: flex-end;
.go-back {
margin-left: 100px;
color: #00afff;
display: inline-block;
text-decoration: underline;
cursor: pointer;
}
}
</style>
...@@ -86,6 +86,14 @@ ...@@ -86,6 +86,14 @@
min-width="200" min-width="200"
align="left" align="left"
> >
<template slot-scope="scope">
<el-link
@click="
$router.push({ path: '/basic/company-view?id=' + scope.row.id })
"
>{{ scope.row.enterpriseName }}</el-link
>
</template>
</el-table-column> </el-table-column>
<el-table-column <el-table-column
label="企业地址" label="企业地址"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment