import { MockMethod, Recordable } from 'vite-plugin-mock' import { resultPageSuccess, resultSuccess } from './_util' export default [ // 获取单个数控程序信息 { url: /\/api\/v1\/programs\/\d+$/, method: 'get', timeout: 500, response: (opt: { url: Recordable }) => { const programsId = opt.url.split('/')[4] return resultSuccess({ id: Number(programsId), 'name|1': '@/cword(4)', 'categoryId|1': '@/integer(1,5)', params: [ { key: 'width', type: 'number' }, { key: 'height', type: 'number' } ], 'content|1': `% O3000(main program) #997=1 #999=1 #996=2 G65P#996 M30 %`, remark: '6日维护', 'updatedAt|1684332167-1684432167': 1684432167, 'createdAt|1684332167-1684432167': 1684432167 }) } }, // 获取数控程序详细资料 { url: /\/api\/v1\/programs\/\d+\/detail$/, method: 'get', timeout: 500, response: (opt: { url: Recordable }) => { const programsId = opt.url.split('/')[4] if (Number(programsId)) { return resultSuccess({ id: Number(programsId), 'name|1': '@/cword(4)', 'categoryId|1': '@/integer(1,5)', 'categoryName|1': '@/cword(2,6)', params: [ { key: 'width', type: 'number' }, { key: 'height', type: 'number' } ], 'content|1': `% O3000(main program) #997=1 #999=1 #996=2 G65P#996 M30 %`, remark: '6日维护', 'updatedAt|1684332167-1684432167': 1684432167, 'createdAt|1684332167-1684432167': 1684432167 }) } return resultSuccess(null) } }, // 获取数控程序列表接口 { url: '/api/v1/programs', method: 'get', response: (opt: { url: Recordable; query: Recordable }) => { return resultPageSuccess({ page: Number(opt.query['page']), limit: Number(opt.query['limit']), total: 14, 'data|10': [ { 'id|+1': 1, 'name|1': '@/cword(4)', 'categoryId|1': '@/integer(1,5)', params: [ { key: 'width', type: 'number' }, { key: 'height', type: 'number' } ], 'content|1': `% O3000(main program) #997=1 #999=1 #996=2 G65P#996 M30 %`, remark: '6日维护', 'updatedAt|1684332167-1684432167': 1684432167, 'createdAt|1684332167-1684432167': 1684432167 } ] }) } }, // 新建数控程序接口 { url: '/api/v1/programs', method: 'post', response: () => { return resultSuccess(null) } }, // 编辑数控程序接口 { url: /\/api\/v1\/programs\/\d+$/, method: 'put', response: () => { return resultSuccess(null) } }, // 删除数控程序 { url: /\/api\/v1\/programs\/\d+/, method: 'delete', response: () => { return resultSuccess(null) } }, // 批量删除数控程序 { url: /\/api\/v1\/programs\/batch-delete$/, method: 'post', timeout: 300, response: () => { return resultSuccess(null) } } ] as MockMethod[]