You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
120 lines
5.3 KiB
TypeScript
120 lines
5.3 KiB
TypeScript
import type { MockMethod } from './types'
|
|
|
|
const machines = [
|
|
{ id: 1, name: '西-1.8', deviceCode: 'fanake_1.8', workshopId: 1, workshopName: 'A栋', brandId: 1, brandName: 'FANUC', collectAddressId: 1, ipAddress: '10.1.1.8', isOnline: 1, workerId: 1, workerName: '张三', isEnabled: 1 },
|
|
{ id: 2, name: '西-1.10', deviceCode: 'fanake_1.10', workshopId: 1, workshopName: 'A栋', brandId: 1, brandName: 'FANUC', collectAddressId: 1, ipAddress: '10.1.1.10', isOnline: 1, workerId: 2, workerName: '李四', isEnabled: 1 },
|
|
{ id: 3, name: '东-2.0', deviceCode: 'fanake_2.0', workshopId: 2, workshopName: 'B栋', brandId: 1, brandName: 'FANUC', collectAddressId: 2, ipAddress: '10.1.2.0', isOnline: 0, workerId: 3, workerName: '王五', isEnabled: 1 },
|
|
{ id: 4, name: '东-2.5', deviceCode: 'siemens_2.5', workshopId: 2, workshopName: 'B栋', brandId: 2, brandName: 'SIEMENS', collectAddressId: 2, ipAddress: '10.1.2.5', isOnline: 0, workerId: null, workerName: null, isEnabled: 0 },
|
|
{ id: 5, name: '南-3.1', deviceCode: 'fanake_3.1', workshopId: 3, workshopName: 'C栋', brandId: 1, brandName: 'FANUC', collectAddressId: 1, ipAddress: '10.1.3.1', isOnline: 1, workerId: 4, workerName: '赵六', isEnabled: 1 },
|
|
]
|
|
|
|
const mock: MockMethod[] = [
|
|
{
|
|
url: '/mock-api/admin/machine',
|
|
method: 'get',
|
|
response: ({ query }: any) => {
|
|
let items = [...machines]
|
|
if (query.workshopId) items = items.filter((m: any) => m.workshopId === Number(query.workshopId))
|
|
if (query.isOnline !== undefined && query.isOnline !== '') items = items.filter((m: any) => m.isOnline === Number(query.isOnline))
|
|
if (query.brandId) items = items.filter((m: any) => m.brandId === Number(query.brandId))
|
|
if (query.keyword) items = items.filter((m: any) => m.name.includes(query.keyword) || m.deviceCode.includes(query.keyword))
|
|
return { code: 0, data: { items, total: items.length, page: Number(query.page || 1), pageSize: Number(query.pageSize || 20) } }
|
|
},
|
|
},
|
|
{
|
|
url: '/mock-api/admin/machine/detail',
|
|
method: 'get',
|
|
response: ({ query }: any) => {
|
|
const id = Number(query.id)
|
|
const m = machines.find((m: any) => m.id === id)
|
|
return { code: 0, data: m || null }
|
|
},
|
|
},
|
|
{
|
|
url: '/mock-api/admin/machine/status',
|
|
method: 'get',
|
|
response: () => ({
|
|
code: 0,
|
|
data: { programName: '1566.NC', partCount: 580, runStatus: '运行中', operateMode: '自动', spindleSpeedSet: 3000, feedSpeedSet: 500, spindleSpeedActual: 2980, feedSpeedActual: 480, spindleLoad: 65, machiningStatus: 'G01', lastCollectTime: '2026-04-25T17:36:38' },
|
|
}),
|
|
},
|
|
{
|
|
url: '/mock-api/admin/machine',
|
|
method: 'post',
|
|
response: () => ({ code: 0, message: 'success', data: { id: 161, name: '新机床' } }),
|
|
},
|
|
{
|
|
url: '/mock-api/admin/machine/update',
|
|
method: 'post',
|
|
response: () => ({ code: 0, message: 'success', data: null }),
|
|
},
|
|
{
|
|
url: '/mock-api/admin/machine/delete',
|
|
method: 'post',
|
|
response: () => ({ code: 0, message: 'success', data: null }),
|
|
},
|
|
{
|
|
url: '/mock-api/admin/machine/batch-status',
|
|
method: 'post',
|
|
response: () => ({ code: 0, message: 'success', data: null }),
|
|
},
|
|
{
|
|
url: '/mock-api/admin/machine/production/today',
|
|
method: 'get',
|
|
response: () => ({
|
|
code: 0,
|
|
data: { items: [
|
|
{ programName: '1566.NC', quantity: 580, runTime: '4h20m', cuttingTime: '3h50m' },
|
|
{ programName: 'O123.NC', quantity: 120, runTime: '2h10m', cuttingTime: '1h45m' },
|
|
] },
|
|
}),
|
|
},
|
|
{
|
|
url: '/mock-api/admin/machine/production/trend',
|
|
method: 'get',
|
|
response: () => ({
|
|
code: 0,
|
|
data: { items: [
|
|
{ date: '2026-04-19', quantity: 820 }, { date: '2026-04-20', quantity: 760 },
|
|
{ date: '2026-04-21', quantity: 910 }, { date: '2026-04-22', quantity: 850 },
|
|
{ date: '2026-04-23', quantity: 780 }, { date: '2026-04-24', quantity: 900 },
|
|
{ date: '2026-04-25', quantity: 700 },
|
|
] },
|
|
}),
|
|
},
|
|
{
|
|
url: '/mock-api/admin/machine/collect-records',
|
|
method: 'get',
|
|
response: () => ({
|
|
code: 0,
|
|
data: { items: [
|
|
{ collectTime: '2026-04-25T17:36:35', programName: '1566.NC', partCount: 580, runStatus: '运行中' },
|
|
{ collectTime: '2026-04-25T17:36:05', programName: '1566.NC', partCount: 579, runStatus: '运行中' },
|
|
{ collectTime: '2026-04-25T17:35:35', programName: '1566.NC', partCount: 578, runStatus: '运行中' },
|
|
] },
|
|
}),
|
|
},
|
|
{
|
|
url: '/mock-api/admin/workshop/list',
|
|
method: 'get',
|
|
response: () => ({ code: 0, data: { items: [{ id: 1, name: 'A栋' }, { id: 2, name: 'B栋' }, { id: 3, name: 'C栋' }] } }),
|
|
},
|
|
{
|
|
url: '/mock-api/admin/brand/list',
|
|
method: 'get',
|
|
response: () => ({ code: 0, data: { items: [{ id: 1, brandName: 'FANUC' }, { id: 2, brandName: 'SIEMENS' }, { id: 3, brandName: 'MITSUBISHI' }] } }),
|
|
},
|
|
{
|
|
url: '/mock-api/admin/collect-address/list',
|
|
method: 'get',
|
|
response: () => ({ code: 0, data: { items: [{ id: 1, name: 'FANUC-A栋', brandId: 1 }, { id: 2, name: 'FANUC-B栋', brandId: 1 }] } }),
|
|
},
|
|
{
|
|
url: '/mock-api/admin/worker/list',
|
|
method: 'get',
|
|
response: () => ({ code: 0, data: { items: [{ id: 1, name: '张三', code: 'W001' }, { id: 2, name: '李四', code: 'W002' }, { id: 3, name: '王五', code: 'W003' }] } }),
|
|
},
|
|
]
|
|
|
|
export default mock
|