Files
hzdyjs/web/src/api/pm/repairCategory.ts
T
2025-06-30 04:25:12 +08:00

514 lines
17 KiB
TypeScript

import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { RepairCategoryVO, RepairCategoryForm, RepairCategoryQuery } from '@/api/pm/types';
/**
* 查询维修类型列表
* @param query 查询参数
*/
export const listRepairCategory = (query?: RepairCategoryQuery): AxiosPromise<RepairCategoryVO[]> => {
return new Promise((resolve) => {
setTimeout(() => {
const mockData = {
code: 200,
msg: '操作成功',
data: [
{
id: '1',
categoryName: '电路维修',
categoryCode: 'ELECTRIC',
categoryDescription: '电路故障、插座开关维修等',
parentId: '0',
ancestorIds: '0',
levelDepth: 1,
childrenCount: 3,
requiredSkills: '电工基础知识、安全操作规范',
skillLevel: '2',
estimatedDuration: 60,
standardCost: 50.00,
iconUrl: '/icons/electric.svg',
colorCode: '#FFB020',
sortOrder: 1,
status: '1',
usageCount: 45,
lastUsedTime: '2025-01-22 15:30:00',
remark: null,
createTime: '2024-12-01 10:00:00',
children: [
{
id: '11',
categoryName: '照明设备',
categoryCode: 'ELECTRIC_LIGHT',
categoryDescription: '灯具、照明线路维修',
parentId: '1',
ancestorIds: '0,1',
levelDepth: 2,
childrenCount: 0,
requiredSkills: '电工基础、照明设备知识',
skillLevel: '1',
estimatedDuration: 30,
standardCost: 30.00,
iconUrl: '/icons/light.svg',
colorCode: '#FFB020',
sortOrder: 1,
status: '1',
usageCount: 18,
lastUsedTime: '2025-01-22 09:15:00',
remark: null,
createTime: '2024-12-01 10:30:00'
},
{
id: '12',
categoryName: '插座开关',
categoryCode: 'ELECTRIC_SOCKET',
categoryDescription: '插座、开关面板维修更换',
parentId: '1',
ancestorIds: '0,1',
levelDepth: 2,
childrenCount: 0,
requiredSkills: '电工基础、安全操作',
skillLevel: '1',
estimatedDuration: 20,
standardCost: 25.00,
iconUrl: '/icons/socket.svg',
colorCode: '#FFB020',
sortOrder: 2,
status: '1',
usageCount: 15,
lastUsedTime: '2025-01-21 14:20:00',
remark: null,
createTime: '2024-12-01 10:45:00'
},
{
id: '13',
categoryName: '配电设备',
categoryCode: 'ELECTRIC_POWER',
categoryDescription: '配电箱、电表等设备维修',
parentId: '1',
ancestorIds: '0,1',
levelDepth: 2,
childrenCount: 0,
requiredSkills: '高级电工、配电知识',
skillLevel: '3',
estimatedDuration: 120,
standardCost: 80.00,
iconUrl: '/icons/power.svg',
colorCode: '#FFB020',
sortOrder: 3,
status: '1',
usageCount: 12,
lastUsedTime: '2025-01-20 16:45:00',
remark: null,
createTime: '2024-12-01 11:00:00'
}
]
},
{
id: '2',
categoryName: '水暖维修',
categoryCode: 'PLUMBING',
categoryDescription: '管道、水龙头、暖气等维修',
parentId: '0',
ancestorIds: '0',
levelDepth: 1,
childrenCount: 3,
requiredSkills: '管工基础知识、焊接技能',
skillLevel: '2',
estimatedDuration: 90,
standardCost: 60.00,
iconUrl: '/icons/plumbing.svg',
colorCode: '#4FC3F7',
sortOrder: 2,
status: '1',
usageCount: 38,
lastUsedTime: '2025-01-23 10:30:00',
remark: null,
createTime: '2024-12-01 10:15:00',
children: [
{
id: '21',
categoryName: '给水设备',
categoryCode: 'PLUMBING_WATER',
categoryDescription: '水龙头、阀门、管道维修',
parentId: '2',
ancestorIds: '0,2',
levelDepth: 2,
childrenCount: 0,
requiredSkills: '管工基础、维修工具使用',
skillLevel: '2',
estimatedDuration: 60,
standardCost: 40.00,
iconUrl: '/icons/water.svg',
colorCode: '#4FC3F7',
sortOrder: 1,
status: '1',
usageCount: 22,
lastUsedTime: '2025-01-23 10:30:00',
remark: null,
createTime: '2024-12-01 10:30:00'
},
{
id: '22',
categoryName: '排水设备',
categoryCode: 'PLUMBING_DRAIN',
categoryDescription: '下水道、地漏疏通维修',
parentId: '2',
ancestorIds: '0,2',
levelDepth: 2,
childrenCount: 0,
requiredSkills: '管道疏通、清洁设备使用',
skillLevel: '1',
estimatedDuration: 45,
standardCost: 35.00,
iconUrl: '/icons/drain.svg',
colorCode: '#4FC3F7',
sortOrder: 2,
status: '1',
usageCount: 10,
lastUsedTime: '2025-01-22 08:45:00',
remark: null,
createTime: '2024-12-01 10:45:00'
},
{
id: '23',
categoryName: '供暖设备',
categoryCode: 'PLUMBING_HEATING',
categoryDescription: '暖气片、供暖管道维修',
parentId: '2',
ancestorIds: '0,2',
levelDepth: 2,
childrenCount: 0,
requiredSkills: '供暖系统知识、焊接技能',
skillLevel: '3',
estimatedDuration: 150,
standardCost: 100.00,
iconUrl: '/icons/heating.svg',
colorCode: '#4FC3F7',
sortOrder: 3,
status: '1',
usageCount: 6,
lastUsedTime: '2025-01-18 13:20:00',
remark: null,
createTime: '2024-12-01 11:00:00'
}
]
},
{
id: '3',
categoryName: '土建维修',
categoryCode: 'CONSTRUCTION',
categoryDescription: '墙面、地面、门窗等土建维修',
parentId: '0',
ancestorIds: '0',
levelDepth: 1,
childrenCount: 2,
requiredSkills: '泥工、油漆工基础技能',
skillLevel: '2',
estimatedDuration: 180,
standardCost: 80.00,
iconUrl: '/icons/construction.svg',
colorCode: '#8BC34A',
sortOrder: 3,
status: '1',
usageCount: 28,
lastUsedTime: '2025-01-21 11:15:00',
remark: null,
createTime: '2024-12-01 10:30:00',
children: [
{
id: '31',
categoryName: '墙面修缮',
categoryCode: 'CONSTRUCTION_WALL',
categoryDescription: '墙面粉刷、裂缝修补',
parentId: '3',
ancestorIds: '0,3',
levelDepth: 2,
childrenCount: 0,
requiredSkills: '油漆工、简单泥工技能',
skillLevel: '2',
estimatedDuration: 120,
standardCost: 60.00,
iconUrl: '/icons/wall.svg',
colorCode: '#8BC34A',
sortOrder: 1,
status: '1',
usageCount: 16,
lastUsedTime: '2025-01-21 11:15:00',
remark: null,
createTime: '2024-12-01 11:15:00'
},
{
id: '32',
categoryName: '门窗维修',
categoryCode: 'CONSTRUCTION_DOOR',
categoryDescription: '门窗锁具、玻璃更换维修',
parentId: '3',
ancestorIds: '0,3',
levelDepth: 2,
childrenCount: 0,
requiredSkills: '木工基础、五金安装',
skillLevel: '2',
estimatedDuration: 90,
standardCost: 45.00,
iconUrl: '/icons/door.svg',
colorCode: '#8BC34A',
sortOrder: 2,
status: '1',
usageCount: 12,
lastUsedTime: '2025-01-19 15:30:00',
remark: null,
createTime: '2024-12-01 11:30:00'
}
]
},
{
id: '4',
categoryName: '设备维修',
categoryCode: 'EQUIPMENT',
categoryDescription: '各类设备故障维修',
parentId: '0',
ancestorIds: '0',
levelDepth: 1,
childrenCount: 2,
requiredSkills: '机电维修、设备操作',
skillLevel: '3',
estimatedDuration: 120,
standardCost: 100.00,
iconUrl: '/icons/equipment.svg',
colorCode: '#FF7043',
sortOrder: 4,
status: '1',
usageCount: 32,
lastUsedTime: '2025-01-23 09:15:00',
remark: null,
createTime: '2024-12-01 10:45:00',
children: [
{
id: '41',
categoryName: '空调设备',
categoryCode: 'EQUIPMENT_AC',
categoryDescription: '空调安装、维修、清洗',
parentId: '4',
ancestorIds: '0,4',
levelDepth: 2,
childrenCount: 0,
requiredSkills: '制冷设备维修、安全操作',
skillLevel: '3',
estimatedDuration: 150,
standardCost: 120.00,
iconUrl: '/icons/ac.svg',
colorCode: '#FF7043',
sortOrder: 1,
status: '1',
usageCount: 20,
lastUsedTime: '2025-01-22 17:30:00',
remark: null,
createTime: '2024-12-01 11:45:00'
},
{
id: '42',
categoryName: '教学设备',
categoryCode: 'EQUIPMENT_TEACHING',
categoryDescription: '投影仪、音响、电脑等设备维修',
parentId: '4',
ancestorIds: '0,4',
levelDepth: 2,
childrenCount: 0,
requiredSkills: '电子设备维修、计算机知识',
skillLevel: '3',
estimatedDuration: 90,
standardCost: 80.00,
iconUrl: '/icons/teaching.svg',
colorCode: '#FF7043',
sortOrder: 2,
status: '1',
usageCount: 12,
lastUsedTime: '2025-01-23 09:15:00',
remark: null,
createTime: '2024-12-01 12:00:00'
}
]
},
{
id: '5',
categoryName: '园林维修',
categoryCode: 'GARDEN',
categoryDescription: '绿化养护、园林设施维修',
parentId: '0',
ancestorIds: '0',
levelDepth: 1,
childrenCount: 0,
requiredSkills: '园艺知识、植物养护',
skillLevel: '1',
estimatedDuration: 240,
standardCost: 40.00,
iconUrl: '/icons/garden.svg',
colorCode: '#66BB6A',
sortOrder: 5,
status: '1',
usageCount: 8,
lastUsedTime: '2025-01-15 14:20:00',
remark: null,
createTime: '2024-12-01 11:00:00'
},
{
id: '6',
categoryName: '清洁维护',
categoryCode: 'CLEANING',
categoryDescription: '清洁卫生、环境维护',
parentId: '0',
ancestorIds: '0',
levelDepth: 1,
childrenCount: 0,
requiredSkills: '清洁知识、环保意识',
skillLevel: '1',
estimatedDuration: 120,
standardCost: 30.00,
iconUrl: '/icons/cleaning.svg',
colorCode: '#42A5F5',
sortOrder: 6,
status: '1',
usageCount: 5,
lastUsedTime: '2025-01-16 10:45:00',
remark: null,
createTime: '2024-12-01 11:15:00'
}
]
};
resolve(mockData as any);
}, 300);
});
};
/**
* 查询维修类型详细信息
* @param id 类型ID
*/
export const getRepairCategory = (id: string | number): AxiosPromise<RepairCategoryVO> => {
return new Promise((resolve) => {
setTimeout(() => {
const mockData = {
code: 200,
msg: '操作成功',
data: {
id: id,
categoryName: '电路维修',
categoryCode: 'ELECTRIC',
categoryDescription: '电路故障、插座开关维修等',
parentId: '0',
ancestorIds: '0',
levelDepth: 1,
childrenCount: 3,
requiredSkills: '电工基础知识、安全操作规范',
skillLevel: '2',
estimatedDuration: 60,
standardCost: 50.00,
iconUrl: '/icons/electric.svg',
colorCode: '#FFB020',
sortOrder: 1,
status: '1',
usageCount: 45,
lastUsedTime: '2025-01-22 15:30:00',
remark: null,
createTime: '2024-12-01 10:00:00'
}
};
resolve(mockData as any);
}, 200);
});
};
/**
* 新增维修类型
* @param data 类型数据
*/
export const addRepairCategory = (data: RepairCategoryForm) => {
return new Promise((resolve) => {
setTimeout(() => {
const mockData = {
code: 200,
msg: '新增成功',
data: {
id: Date.now(),
categoryCode: data.categoryCode
}
};
resolve(mockData);
}, 600);
});
};
/**
* 修改维修类型
* @param data 类型数据
*/
export const updateRepairCategory = (data: RepairCategoryForm) => {
return new Promise((resolve) => {
setTimeout(() => {
const mockData = {
code: 200,
msg: '修改成功',
data: null
};
resolve(mockData);
}, 500);
});
};
/**
* 删除维修类型
* @param id 类型ID
*/
export const delRepairCategory = (id: string | number | Array<string | number>) => {
return new Promise((resolve) => {
setTimeout(() => {
const mockData = {
code: 200,
msg: '删除成功',
data: null
};
resolve(mockData);
}, 400);
});
};
/**
* 获取维修类型树形结构
*/
export const getRepairCategoryTree = (): AxiosPromise<RepairCategoryVO[]> => {
return listRepairCategory();
};
/**
* 获取维修类型下拉选项
*/
export const getRepairCategoryOptions = (): AxiosPromise<Array<{value: string | number, label: string}>> => {
return new Promise((resolve) => {
setTimeout(() => {
const mockData = {
code: 200,
msg: '操作成功',
data: [
{ value: '1', label: '电路维修' },
{ value: '11', label: '- 照明设备' },
{ value: '12', label: '- 插座开关' },
{ value: '13', label: '- 配电设备' },
{ value: '2', label: '水暖维修' },
{ value: '21', label: '- 给水设备' },
{ value: '22', label: '- 排水设备' },
{ value: '23', label: '- 供暖设备' },
{ value: '3', label: '土建维修' },
{ value: '31', label: '- 墙面修缮' },
{ value: '32', label: '- 门窗维修' },
{ value: '4', label: '设备维修' },
{ value: '41', label: '- 空调设备' },
{ value: '42', label: '- 教学设备' },
{ value: '5', label: '园林维修' },
{ value: '6', label: '清洁维护' }
]
};
resolve(mockData as any);
}, 200);
});
};