62 lines
1.2 KiB
TypeScript
62 lines
1.2 KiB
TypeScript
import { MockMethod, Recordable } from 'vite-plugin-mock'
|
|
import { resultPageSuccess, resultSuccess } from './_util'
|
|
|
|
export default [
|
|
// 查询商品单位列表
|
|
{
|
|
url: '/api/v1/units',
|
|
method: 'get',
|
|
response: () => {
|
|
return resultPageSuccess({
|
|
'data|10': [
|
|
{
|
|
'id|+1': 1,
|
|
name: '@/cname',
|
|
remark: '@/ctitle'
|
|
}
|
|
]
|
|
})
|
|
}
|
|
},
|
|
// 查询商品单位信息
|
|
{
|
|
url: /\/api\/v1\/unit\/\d+$/,
|
|
method: 'get',
|
|
timeout: 500,
|
|
response: (opt: { url: Recordable }) => {
|
|
const unitId = opt.url.split('/')[5]
|
|
return resultSuccess({
|
|
id: Number(unitId),
|
|
name: '@/cname',
|
|
remark: '@/ctitle'
|
|
})
|
|
}
|
|
},
|
|
|
|
// 新建商品单位
|
|
{
|
|
url: /\/api\/v1\/unit\/\d+$/,
|
|
method: 'post',
|
|
response: () => {
|
|
return resultSuccess(null)
|
|
}
|
|
},
|
|
// 编辑商品单位
|
|
{
|
|
url: /\/api\/v1\/unit\/\d+$/,
|
|
method: 'put',
|
|
response: () => {
|
|
return resultSuccess(null)
|
|
}
|
|
},
|
|
// 删除商品单位
|
|
{
|
|
url: /\/api\/v1\/unit\/\d+$/,
|
|
method: 'delete',
|
|
timeout: 300,
|
|
response: () => {
|
|
return resultSuccess(null)
|
|
}
|
|
}
|
|
] as MockMethod[]
|