116 lines
3.3 KiB
TypeScript
116 lines
3.3 KiB
TypeScript
import { MockMethod, Recordable } from 'vite-plugin-mock'
|
|
import { resultPageSuccess, resultSuccess } from './_util'
|
|
|
|
export default [
|
|
// 获取单个设备信息
|
|
{
|
|
url: /\/api\/v1\/parameters\/\d+$/,
|
|
method: 'get',
|
|
timeout: 500,
|
|
response: (opt: { url: Recordable }) => {
|
|
const parameterId = opt.url.split('/')[5]
|
|
return resultSuccess({
|
|
id: Number(parameterId),
|
|
name: '设备@integer(1,10)',
|
|
'categoryId|1': [1, 2, 3, 4, 5],
|
|
'categoryName|1': ['PLC', '车床', '铣床', '机器人', '激光打标机'],
|
|
'manufacturer|1': ['西门子', 'Fanuc'],
|
|
'model|1': '@/word(2,4)',
|
|
'address|1': '@/ip():@integer(1000,9000)',
|
|
status: '正常',
|
|
remark: '6日维护',
|
|
'updatedAt|1684332167-1684432167': 1684432167,
|
|
'createdAt|1684332167-1684432167': 1684432167
|
|
})
|
|
}
|
|
},
|
|
// 获取详细资料
|
|
{
|
|
url: /\/api\/v1\/parameters\/\d+\/detail$/,
|
|
method: 'get',
|
|
timeout: 500,
|
|
response: (opt: { url: Recordable }) => {
|
|
const parameterId = opt.url.split('/')[4]
|
|
if (Number(parameterId)) {
|
|
return resultSuccess({
|
|
id: Number(parameterId),
|
|
name: '设备@integer(1,10)',
|
|
'categoryId|1': [1, 2, 3, 4, 5],
|
|
'categoryName|1': ['PLC', '车床', '铣床', '机器人', '激光打标机'],
|
|
'manufacturer|1': ['西门子', 'Fanuc'],
|
|
'model|1': '@/word(2,4)',
|
|
'address|1': '@/ip():@integer(1000,9000)',
|
|
status: '正常',
|
|
remark: '6日维护',
|
|
'updatedAt|1684332167-1684432167': 1684432167,
|
|
'createdAt|1684332167-1684432167': 1684432167
|
|
})
|
|
}
|
|
return resultSuccess(null)
|
|
}
|
|
},
|
|
// 获取设备列表接口
|
|
{
|
|
url: '/api/v1/parameters',
|
|
method: 'get',
|
|
response: (opt: { url: Recordable; query: Recordable }) => {
|
|
const limit = Number(opt.query['limit'])
|
|
return resultPageSuccess({
|
|
page: Number(opt.query['page']),
|
|
limit: Number(opt.query['limit']),
|
|
total: 12,
|
|
'data|10': [
|
|
{
|
|
'id|+1': 1,
|
|
'no|+1': 1,
|
|
'name|+1': '@/cword(3,7)',
|
|
'valueType|1': ['number', 'string'],
|
|
'categoryId|1': [1, 2, 3, 4, 5],
|
|
'categoryName|1': ['PLC', '车床', '铣床', '机器人', '激光打标机'],
|
|
'manufacturer|1': ['西门子', 'Fanuc'],
|
|
'model|1': '@/word(2,4)',
|
|
'address|1': '@/ip():@integer(1000,9000)',
|
|
status: '正常',
|
|
remark: '6日维护',
|
|
'updatedAt|1684332167-1684432167': 1684432167,
|
|
'createdAt|1684332167-1684432167': 1684432167
|
|
}
|
|
]
|
|
})
|
|
}
|
|
},
|
|
// 新建设备接口
|
|
{
|
|
url: '/api/v1/parameters',
|
|
method: 'post',
|
|
response: () => {
|
|
return resultSuccess(null)
|
|
}
|
|
},
|
|
// 编辑设备接口
|
|
{
|
|
url: '/api/v1/parameters',
|
|
method: 'put',
|
|
response: () => {
|
|
return resultSuccess(null)
|
|
}
|
|
},
|
|
// 删除设备
|
|
{
|
|
url: /\/api\/v1\/parameters\/\d+/,
|
|
method: 'delete',
|
|
response: () => {
|
|
return resultSuccess(null)
|
|
}
|
|
},
|
|
// 批量删除设备
|
|
{
|
|
url: `/api/v1/parameters/batch-delete`,
|
|
method: 'post',
|
|
timeout: 300,
|
|
response: () => {
|
|
return resultSuccess(null)
|
|
}
|
|
}
|
|
] as MockMethod[]
|