Compare commits
3 Commits
2a14167861
...
a5e3011d5a
| Author | SHA1 | Date |
|---|---|---|
|
|
a5e3011d5a | |
|
|
367d638f58 | |
|
|
c2429614fe |
|
|
@ -1,8 +1,9 @@
|
|||
import request from '@/utils/request'
|
||||
import type { LoginRequest, LoginResponse } from '@/types'
|
||||
import type { AxiosResponse } from 'axios'
|
||||
import type { LoginRequest, LoginResponse, ApiResponse } from '@/types'
|
||||
|
||||
export const login = (data: LoginRequest) => {
|
||||
return request.post<LoginResponse>('/api/auth/login', data)
|
||||
export const login = (data: LoginRequest): Promise<AxiosResponse<ApiResponse<LoginResponse>>> => {
|
||||
return request.post<ApiResponse<LoginResponse>>('/api/auth/login', data)
|
||||
}
|
||||
|
||||
export const logout = () => {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import request from '@/utils/request'
|
||||
import type { ApiResponse } from '@/types'
|
||||
|
||||
// ==================== 设备健康度类型 ====================
|
||||
|
||||
|
|
@ -66,24 +67,24 @@ const BASE_URL = '/api/asset/equipment-health'
|
|||
|
||||
// 获取设备健康度
|
||||
export function getEquipmentHealth(equipmentId: string) {
|
||||
return request.get<EquipmentHealth>(`${BASE_URL}/${equipmentId}`)
|
||||
return request.get<ApiResponse<EquipmentHealth>>(`${BASE_URL}/${equipmentId}`)
|
||||
}
|
||||
|
||||
// 获取健康度历史
|
||||
export function getHealthHistory(equipmentId: string, days: number = 30) {
|
||||
return request.get<HealthHistory[]>(`${BASE_URL}/${equipmentId}/history`, {
|
||||
return request.get<ApiResponse<HealthHistory[]>>(`${BASE_URL}/${equipmentId}/history`, {
|
||||
params: { days }
|
||||
})
|
||||
}
|
||||
|
||||
// 计算设备健康度
|
||||
export function calculateHealth(equipmentId: string) {
|
||||
return request.post<EquipmentHealth>(`${BASE_URL}/calculate`, { equipmentId })
|
||||
return request.post<ApiResponse<EquipmentHealth>>(`${BASE_URL}/calculate`, { equipmentId })
|
||||
}
|
||||
|
||||
// 获取故障历史列表
|
||||
export function getFailureHistory(equipmentId: string) {
|
||||
return request.get<EquipmentFailure[]>(`${BASE_URL}/failure-history/${equipmentId}`)
|
||||
return request.get<ApiResponse<EquipmentFailure[]>>(`${BASE_URL}/failure-history/${equipmentId}`)
|
||||
}
|
||||
|
||||
// 记录故障
|
||||
|
|
@ -99,10 +100,10 @@ export function recordFailure(data: {
|
|||
|
||||
// 获取 MTBF
|
||||
export function getEquipmentMTBF(equipmentId: string) {
|
||||
return request.get<MTBFData>(`${BASE_URL}/mtbf/${equipmentId}`)
|
||||
return request.get<ApiResponse<MTBFData>>(`${BASE_URL}/mtbf/${equipmentId}`)
|
||||
}
|
||||
|
||||
// 获取 MTTR
|
||||
export function getEquipmentMTTR(equipmentId: string) {
|
||||
return request.get<MTTRData>(`${BASE_URL}/mttr/${equipmentId}`)
|
||||
return request.get<ApiResponse<MTTRData>>(`${BASE_URL}/mttr/${equipmentId}`)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import request from '@/utils/request'
|
||||
import type { ApiResponse } from '@/types'
|
||||
|
||||
// ==================== 系统类型枚举(8大系统分类)===================
|
||||
export type SystemType =
|
||||
|
|
@ -243,22 +244,22 @@ export interface FireInfo {
|
|||
|
||||
// 获取设备列表(按项目)
|
||||
export function getEquipmentList(projectId: string) {
|
||||
return request.get<Equipment[]>(`/api/asset/equipment/by-project/${projectId}`)
|
||||
return request.get<ApiResponse<Equipment[]>>(`/api/asset/equipment/by-project/${projectId}`)
|
||||
}
|
||||
|
||||
// 获取设备详情
|
||||
export function getEquipmentDetail(id: string) {
|
||||
return request.get<Equipment>(`/api/asset/equipment/${id}`)
|
||||
return request.get<ApiResponse<Equipment>>(`/api/asset/equipment/${id}`)
|
||||
}
|
||||
|
||||
// 获取设备(按位置)
|
||||
export function getEquipmentBySpace(spaceNodeId: string) {
|
||||
return request.get<Equipment[]>(`/api/asset/equipment/by-space/${spaceNodeId}`)
|
||||
return request.get<ApiResponse<Equipment[]>>(`/api/asset/equipment/by-space/${spaceNodeId}`)
|
||||
}
|
||||
|
||||
// 获取设备(按类型)
|
||||
export function getEquipmentByType(projectId: string, type: EquipmentType) {
|
||||
return request.get<Equipment[]>('/api/asset/equipment/by-type', {
|
||||
return request.get<ApiResponse<Equipment[]>>('/api/asset/equipment/by-type', {
|
||||
params: { projectId, type }
|
||||
})
|
||||
}
|
||||
|
|
@ -272,7 +273,7 @@ export function getEquipmentByOwnership(projectId: string, ownership: OwnershipT
|
|||
|
||||
// 创建设备
|
||||
export function createEquipment(data: EquipmentForm) {
|
||||
return request.post<Equipment>('/api/asset/equipment', data)
|
||||
return request.post<ApiResponse<Equipment>>('/api/asset/equipment', data)
|
||||
}
|
||||
|
||||
// 更新设备
|
||||
|
|
@ -282,19 +283,20 @@ export function updateEquipment(id: string, data: EquipmentForm) {
|
|||
|
||||
// 删除设备
|
||||
export function deleteEquipment(id: string) {
|
||||
return request.delete<void>(`/api/asset/equipment/${id}`)
|
||||
return request.delete<ApiResponse<void>>(`/api/asset/equipment/${id}`)
|
||||
}
|
||||
|
||||
// 批量删除设备
|
||||
export function deleteEquipmentBatch(ids: string[]) {
|
||||
return request.post<void>(`/api/asset/equipment/batch-delete`, ids)
|
||||
return request.post<ApiResponse<void>>(`/api/asset/equipment/batch-delete`, ids)
|
||||
}
|
||||
|
||||
// 导入设备
|
||||
export function importEquipment(file: File, projectId: string) {
|
||||
const formData = new FormData()
|
||||
formData.append('file', file)
|
||||
return request.post<{ successCount: number; failCount: number; failDetails: string[] }>(`/api/asset/equipment/import`, formData, {
|
||||
formData.append('projectId', projectId)
|
||||
return request.post<ApiResponse<{ successCount: number; failCount: number; failDetails: string[] }>>(`/api/asset/equipment/import`, formData, {
|
||||
headers: { 'Content-Type': 'multipart/form-data' }
|
||||
})
|
||||
}
|
||||
|
|
@ -311,12 +313,12 @@ export function exportEquipment(projectId: string) {
|
|||
|
||||
// 按类型统计设备
|
||||
export function getEquipmentStatsByType(projectId: string) {
|
||||
return request.get<EquipmentStatsByType[]>(`/api/asset/equipment/stats/by-type/${projectId}`)
|
||||
return request.get<ApiResponse<EquipmentStatsByType[]>>(`/api/asset/equipment/stats/by-type/${projectId}`)
|
||||
}
|
||||
|
||||
// 按归属统计设备
|
||||
export function getEquipmentStatsByOwnership(projectId: string) {
|
||||
return request.get<EquipmentStatsByOwnership[]>(`/api/asset/equipment/stats/by-ownership/${projectId}`)
|
||||
return request.get<ApiResponse<EquipmentStatsByOwnership[]>>(`/api/asset/equipment/stats/by-ownership/${projectId}`)
|
||||
}
|
||||
|
||||
// 设备总数统计
|
||||
|
|
@ -328,12 +330,12 @@ export function getEquipmentCountStats(projectId: string) {
|
|||
|
||||
// 获取所有归属主体
|
||||
export function getOwnershipEntityList() {
|
||||
return request.get<OwnershipEntity[]>('/api/asset/ownership-entity')
|
||||
return request.get<ApiResponse<OwnershipEntity[]>>('/api/asset/ownership-entity')
|
||||
}
|
||||
|
||||
// 按类型获取归属主体
|
||||
export function getOwnershipEntityByType(type: OwnershipEntityType) {
|
||||
return request.get<OwnershipEntity[]>('/api/asset/ownership-entity/by-type', {
|
||||
return request.get<ApiResponse<OwnershipEntity[]>>('/api/asset/ownership-entity/by-type', {
|
||||
params: { type }
|
||||
})
|
||||
}
|
||||
|
|
@ -342,42 +344,42 @@ export function getOwnershipEntityByType(type: OwnershipEntityType) {
|
|||
|
||||
// 获取电梯扩展信息
|
||||
export function getElevatorInfo(equipmentId: string) {
|
||||
return request.get<ElevatorInfo>(`/api/asset/equipment/${equipmentId}/elevator`)
|
||||
return request.get<ApiResponse<ElevatorInfo>>(`/api/asset/equipment/${equipmentId}/elevator`)
|
||||
}
|
||||
|
||||
// 更新电梯扩展信息
|
||||
export function updateElevatorInfo(equipmentId: string, data: ElevatorInfo) {
|
||||
return request.put<ElevatorInfo>(`/api/asset/equipment/${equipmentId}/elevator`, data)
|
||||
return request.put<ApiResponse<ElevatorInfo>>(`/api/asset/equipment/${equipmentId}/elevator`, data)
|
||||
}
|
||||
|
||||
// 获取暖通扩展信息
|
||||
export function getHvacInfo(equipmentId: string) {
|
||||
return request.get<HvacInfo>(`/api/asset/equipment/${equipmentId}/hvac`)
|
||||
return request.get<ApiResponse<HvacInfo>>(`/api/asset/equipment/${equipmentId}/hvac`)
|
||||
}
|
||||
|
||||
// 更新暖通扩展信息
|
||||
export function updateHvacInfo(equipmentId: string, data: HvacInfo) {
|
||||
return request.put<HvacInfo>(`/api/asset/equipment/${equipmentId}/hvac`, data)
|
||||
return request.put<ApiResponse<HvacInfo>>(`/api/asset/equipment/${equipmentId}/hvac`, data)
|
||||
}
|
||||
|
||||
// 获取能源计量扩展信息
|
||||
export function getEnergyInfo(equipmentId: string) {
|
||||
return request.get<EnergyInfo>(`/api/asset/equipment/${equipmentId}/energy`)
|
||||
return request.get<ApiResponse<EnergyInfo>>(`/api/asset/equipment/${equipmentId}/energy`)
|
||||
}
|
||||
|
||||
// 更新能源计量扩展信息
|
||||
export function updateEnergyInfo(equipmentId: string, data: EnergyInfo) {
|
||||
return request.put<EnergyInfo>(`/api/asset/equipment/${equipmentId}/energy`, data)
|
||||
return request.put<ApiResponse<EnergyInfo>>(`/api/asset/equipment/${equipmentId}/energy`, data)
|
||||
}
|
||||
|
||||
// 获取消防扩展信息
|
||||
export function getFireInfo(equipmentId: string) {
|
||||
return request.get<FireInfo>(`/api/asset/equipment/${equipmentId}/fire`)
|
||||
return request.get<ApiResponse<FireInfo>>(`/api/asset/equipment/${equipmentId}/fire`)
|
||||
}
|
||||
|
||||
// 更新消防扩展信息
|
||||
export function updateFireInfo(equipmentId: string, data: FireInfo) {
|
||||
return request.put<FireInfo>(`/api/asset/equipment/${equipmentId}/fire`, data)
|
||||
return request.put<ApiResponse<FireInfo>>(`/api/asset/equipment/${equipmentId}/fire`, data)
|
||||
}
|
||||
|
||||
// ==================== 设备类型映射 ====================
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import request from '@/utils/request'
|
||||
import type { ApiResponse } from '@/types'
|
||||
|
||||
// ==================== 巡检标准项类型 ====================
|
||||
export interface InspectionItem {
|
||||
|
|
@ -29,22 +30,22 @@ export interface InspectionItemForm {
|
|||
|
||||
// 获取巡检标准项列表
|
||||
export function getInspectionItems() {
|
||||
return request.get<InspectionItem[]>('/api/mdm/inspection-items')
|
||||
return request.get<ApiResponse<InspectionItem[]>>('/api/mdm/inspection-items')
|
||||
}
|
||||
|
||||
// 创建巡检标准项
|
||||
export function createInspectionItem(data: InspectionItemForm) {
|
||||
return request.post<InspectionItem>('/api/mdm/inspection-items', data)
|
||||
return request.post<ApiResponse<InspectionItem>>('/api/mdm/inspection-items', data)
|
||||
}
|
||||
|
||||
// 更新巡检标准项
|
||||
export function updateInspectionItem(id: string, data: InspectionItemForm) {
|
||||
return request.put<InspectionItem>(`/api/mdm/inspection-items/${id}`, data)
|
||||
return request.put<ApiResponse<InspectionItem>>(`/api/mdm/inspection-items/${id}`, data)
|
||||
}
|
||||
|
||||
// 删除巡检标准项
|
||||
export function deleteInspectionItem(id: string) {
|
||||
return request.delete<void>(`/api/mdm/inspection-items/${id}`)
|
||||
return request.delete<ApiResponse<void>>(`/api/mdm/inspection-items/${id}`)
|
||||
}
|
||||
|
||||
// ==================== 设备类型和系统类型选项 ====================
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import request from '@/utils/request'
|
||||
import type { ApiResponse } from '@/types'
|
||||
|
||||
// ==================== 巡检记录类型 ====================
|
||||
export type InspectionStatus = 'NORMAL' | 'WARNING' | 'ABNORMAL'
|
||||
|
|
@ -47,24 +48,24 @@ export interface InspectionRecordForm {
|
|||
|
||||
// 获取巡检记录列表
|
||||
export function getInspectionRecords(projectId: string, equipmentId?: string) {
|
||||
return request.get<InspectionRecord[]>('/api/mdm/inspection-records', {
|
||||
return request.get<ApiResponse<InspectionRecord[]>>('/api/mdm/inspection-records', {
|
||||
params: { projectId, equipmentId }
|
||||
})
|
||||
}
|
||||
|
||||
// 获取巡检记录详情
|
||||
export function getInspectionRecord(id: string) {
|
||||
return request.get<InspectionRecord>(`/api/mdm/inspection-records/${id}`)
|
||||
return request.get<ApiResponse<InspectionRecord>>(`/api/mdm/inspection-records/${id}`)
|
||||
}
|
||||
|
||||
// 创建巡检记录
|
||||
export function createInspectionRecord(data: InspectionRecordForm) {
|
||||
return request.post<InspectionRecord>('/api/mdm/inspection-records', data)
|
||||
return request.post<ApiResponse<InspectionRecord>>('/api/mdm/inspection-records', data)
|
||||
}
|
||||
|
||||
// 更新巡检记录
|
||||
export function updateInspectionRecord(id: string, data: InspectionRecordForm) {
|
||||
return request.put<InspectionRecord>(`/api/mdm/inspection-records/${id}`, data)
|
||||
return request.put<ApiResponse<InspectionRecord>>(`/api/mdm/inspection-records/${id}`, data)
|
||||
}
|
||||
|
||||
// 完成巡检
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import request from '@/utils/request'
|
||||
import type { ApiResponse } from '@/types'
|
||||
|
||||
// ==================== 维保计划类型 ====================
|
||||
export type PlanType = 'PREVENTIVE' | 'CORRECTIVE'
|
||||
|
|
@ -37,29 +38,29 @@ export interface MaintenancePlanForm {
|
|||
|
||||
// 获取维保计划列表
|
||||
export function getMaintenancePlans(projectId: string) {
|
||||
return request.get<MaintenancePlan[]>(`/api/mdm/maintenance-plans`, {
|
||||
return request.get<ApiResponse<MaintenancePlan[]>>(`/api/mdm/maintenance-plans`, {
|
||||
params: { projectId }
|
||||
})
|
||||
}
|
||||
|
||||
// 获取维保计划详情
|
||||
export function getMaintenancePlan(id: string) {
|
||||
return request.get<MaintenancePlan>(`/api/mdm/maintenance-plans/${id}`)
|
||||
return request.get<ApiResponse<MaintenancePlan>>(`/api/mdm/maintenance-plans/${id}`)
|
||||
}
|
||||
|
||||
// 创建维保计划
|
||||
export function createMaintenancePlan(data: MaintenancePlanForm) {
|
||||
return request.post<MaintenancePlan>('/api/mdm/maintenance-plans', data)
|
||||
return request.post<ApiResponse<MaintenancePlan>>('/api/mdm/maintenance-plans', data)
|
||||
}
|
||||
|
||||
// 更新维保计划
|
||||
export function updateMaintenancePlan(id: string, data: MaintenancePlanForm) {
|
||||
return request.put<MaintenancePlan>(`/api/mdm/maintenance-plans/${id}`, data)
|
||||
return request.put<ApiResponse<MaintenancePlan>>(`/api/mdm/maintenance-plans/${id}`, data)
|
||||
}
|
||||
|
||||
// 删除维保计划
|
||||
export function deleteMaintenancePlan(id: string) {
|
||||
return request.delete<void>(`/api/mdm/maintenance-plans/${id}`)
|
||||
return request.delete<ApiResponse<void>>(`/api/mdm/maintenance-plans/${id}`)
|
||||
}
|
||||
|
||||
// ==================== 常量选项 ====================
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import request from '@/utils/request'
|
||||
import type { ApiResponse } from '@/types'
|
||||
|
||||
// ==================== 维保工单类型 ====================
|
||||
export type TaskType = 'PREVENTIVE' | 'CORRECTIVE' | 'EMERGENCY'
|
||||
|
|
@ -90,36 +91,36 @@ export interface VerifyTaskData {
|
|||
|
||||
// 获取维保工单列表
|
||||
export function getMaintenanceTasks(projectId?: string) {
|
||||
return request.get<MaintenanceTask[]>(`/api/ops/maintenance-tasks`, {
|
||||
return request.get<ApiResponse<MaintenanceTask[]>>(`/api/ops/maintenance-tasks`, {
|
||||
params: { projectId }
|
||||
})
|
||||
}
|
||||
|
||||
// 根据状态获取维保工单列表
|
||||
export function getMaintenanceTasksByStatus(status: TaskStatus) {
|
||||
return request.get<MaintenanceTask[]>(`/api/ops/maintenance-tasks`, {
|
||||
return request.get<ApiResponse<MaintenanceTask[]>>(`/api/ops/maintenance-tasks`, {
|
||||
params: { status }
|
||||
})
|
||||
}
|
||||
|
||||
// 获取维保工单详情
|
||||
export function getMaintenanceTask(id: string) {
|
||||
return request.get<MaintenanceTask>(`/api/ops/maintenance-tasks/${id}`)
|
||||
return request.get<ApiResponse<MaintenanceTask>>(`/api/ops/maintenance-tasks/${id}`)
|
||||
}
|
||||
|
||||
// 创建维保工单
|
||||
export function createMaintenanceTask(data: MaintenanceTaskForm) {
|
||||
return request.post<MaintenanceTask>('/api/ops/maintenance-tasks', data)
|
||||
return request.post<ApiResponse<MaintenanceTask>>('/api/ops/maintenance-tasks', data)
|
||||
}
|
||||
|
||||
// 更新维保工单
|
||||
export function updateMaintenanceTask(id: string, data: Partial<MaintenanceTaskForm>) {
|
||||
return request.put<MaintenanceTask>(`/api/ops/maintenance-tasks/${id}`, data)
|
||||
return request.put<ApiResponse<MaintenanceTask>>(`/api/ops/maintenance-tasks/${id}`, data)
|
||||
}
|
||||
|
||||
// 删除维保工单
|
||||
export function deleteMaintenanceTask(id: string) {
|
||||
return request.delete<void>(`/api/ops/maintenance-tasks/${id}`)
|
||||
return request.delete<ApiResponse<void>>(`/api/ops/maintenance-tasks/${id}`)
|
||||
}
|
||||
|
||||
// 状态流转 API
|
||||
|
|
|
|||
|
|
@ -1,19 +1,19 @@
|
|||
import request from '@/utils/request'
|
||||
import type { User } from '@/types'
|
||||
import type { User, ApiResponse, PageResponse } from '@/types'
|
||||
|
||||
// 获取企业员工列表(用于项目管理添加成员)
|
||||
export const getEnterpriseUsers = (params?: { keyword?: string }) => {
|
||||
return request.get<{ code: number; message: string; data: User[] }>('/api/auth/users/enterprise', { params })
|
||||
return request.get<ApiResponse<User[]>>('/api/auth/users/enterprise', { params })
|
||||
}
|
||||
|
||||
// 获取项目成员列表
|
||||
export const getProjectMembers = (projectId: string, params?: { page?: number; size?: number }) => {
|
||||
return request.get<{ code: number; message: string; data: { content: User[]; total: number } }>(`/api/auth/projects/${projectId}/members`, { params })
|
||||
return request.get<ApiResponse<PageResponse<User>>>(`/api/auth/projects/${projectId}/members`, { params })
|
||||
}
|
||||
|
||||
// 获取可添加的成员列表(排除已添加的)
|
||||
export const getAvailableMembers = (projectId: string) => {
|
||||
return request.get<{ code: number; message: string; data: User[] }>(`/api/auth/projects/${projectId}/available-members`)
|
||||
return request.get<ApiResponse<User[]>>(`/api/auth/projects/${projectId}/available-members`)
|
||||
}
|
||||
|
||||
// 添加项目成员
|
||||
|
|
@ -28,7 +28,7 @@ export const removeProjectMember = (projectId: string, userId: string) => {
|
|||
|
||||
// 获取部门树
|
||||
export const getDeptTree = () => {
|
||||
return request.get<{ code: number; message: string; data: DeptTreeNode[] }>('/api/auth/depts/tree')
|
||||
return request.get<ApiResponse<DeptTreeNode[]>>('/api/auth/depts/tree')
|
||||
}
|
||||
|
||||
// 创建部门
|
||||
|
|
@ -38,7 +38,7 @@ export const createDept = (data: { deptName: string; deptCode?: string; parentId
|
|||
|
||||
// 获取部门成员
|
||||
export const getDeptMembers = (deptId: string) => {
|
||||
return request.get<{ code: number; message: string; data: User[] }>(`/api/auth/depts/${deptId}/members`)
|
||||
return request.get<ApiResponse<User[]>>(`/api/auth/depts/${deptId}/members`)
|
||||
}
|
||||
|
||||
export interface DeptTreeNode {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import request from '@/utils/request'
|
||||
import type { ApiResponse } from '@/types'
|
||||
|
||||
// ==================== 工单类型 ====================
|
||||
export type WorkOrderSource = 'OWNER' | 'MAINTENANCE' | 'INSPECTION' | 'FAULT' | 'REGULATORY' | 'MANUAL'
|
||||
|
|
@ -88,23 +89,23 @@ export function getWorkOrders(params?: {
|
|||
status?: WorkOrderStatus
|
||||
assignedTo?: string
|
||||
}) {
|
||||
return request.get<WorkOrder[]>('/api/wo/work-orders', { params })
|
||||
return request.get<ApiResponse<WorkOrder[]>>('/api/wo/work-orders', { params })
|
||||
}
|
||||
|
||||
export function getWorkOrder(id: string) {
|
||||
return request.get<WorkOrder>(`/api/wo/work-orders/${id}`)
|
||||
return request.get<ApiResponse<WorkOrder>>(`/api/wo/work-orders/${id}`)
|
||||
}
|
||||
|
||||
export function createWorkOrder(data: Partial<WorkOrder>) {
|
||||
return request.post<WorkOrder>('/api/wo/work-orders', data)
|
||||
return request.post<ApiResponse<WorkOrder>>('/api/wo/work-orders', data)
|
||||
}
|
||||
|
||||
export function updateWorkOrder(id: string, data: Partial<WorkOrder>) {
|
||||
return request.put<WorkOrder>(`/api/wo/work-orders/${id}`, data)
|
||||
return request.put<ApiResponse<WorkOrder>>(`/api/wo/work-orders/${id}`, data)
|
||||
}
|
||||
|
||||
export function deleteWorkOrder(id: string) {
|
||||
return request.delete<void>(`/api/wo/work-orders/${id}`)
|
||||
return request.delete<ApiResponse<void>>(`/api/wo/work-orders/${id}`)
|
||||
}
|
||||
|
||||
export function assignWorkOrder(id: string, data: { assignedTo: string; assignedVendor?: string; assignedDate?: string }) {
|
||||
|
|
@ -128,11 +129,11 @@ export function cancelWorkOrder(id: string) {
|
|||
}
|
||||
|
||||
export function getWorkOrderStats() {
|
||||
return request.get<WorkOrderStats>('/api/wo/work-orders/stats')
|
||||
return request.get<ApiResponse<WorkOrderStats>>('/api/wo/work-orders/stats')
|
||||
}
|
||||
|
||||
export function getWorkOrderItems(workOrderId: string) {
|
||||
return request.get<WorkOrderItem[]>(`/api/wo/work-orders/${workOrderId}/items`)
|
||||
return request.get<ApiResponse<WorkOrderItem[]>>(`/api/wo/work-orders/${workOrderId}/items`)
|
||||
}
|
||||
|
||||
export function addWorkOrderItems(workOrderId: string, items: WorkOrderItem[]) {
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
<script setup lang="ts">
|
||||
import { ref, onMounted } from 'vue'
|
||||
import { useRoute, useRouter } from 'vue-router'
|
||||
import { Descriptions, DescriptionsItem, Tag, message, Spin, Button, Modal, Card } from 'ant-design-vue'
|
||||
import { ArrowLeftOutlined, UploadOutlined, FilePdfOutlined, FileImageOutlined, FileOutlined, EyeOutlined } from '@ant-design/icons-vue'
|
||||
import { Descriptions, DescriptionsItem, Tag, message, Spin, Button, Modal } from 'ant-design-vue'
|
||||
import { ArrowLeftOutlined, UploadOutlined, FilePdfOutlined, FileImageOutlined, FileOutlined } from '@ant-design/icons-vue'
|
||||
import { getEquipmentDetail, type Equipment, EQUIPMENT_TYPE_OPTIONS, OWNERSHIP_TYPE_OPTIONS, uploadFile, type EquipmentPhoto, type EquipmentDocument } from '@/api/equipment'
|
||||
|
||||
const route = useRoute()
|
||||
|
|
@ -29,8 +29,8 @@ const fetchEquipmentDetail = async () => {
|
|||
|
||||
loading.value = true
|
||||
try {
|
||||
const res = await getEquipmentDetail(id)
|
||||
equipment.value = res.data
|
||||
const response = await getEquipmentDetail(id)
|
||||
equipment.value = response.data.data
|
||||
} catch {
|
||||
message.error('获取设备详情失败')
|
||||
} finally {
|
||||
|
|
|
|||
|
|
@ -106,9 +106,9 @@ const renderHealthChart = () => {
|
|||
const fetchEquipmentList = async (pId: string) => {
|
||||
if (!pId) return
|
||||
try {
|
||||
const res = await getEquipmentList(pId)
|
||||
const data = res.data
|
||||
equipmentOptions.value = (data || []).map((item: Equipment) => ({
|
||||
const response = await getEquipmentList(pId)
|
||||
const equipmentList = response.data.data || []
|
||||
equipmentOptions.value = equipmentList.map((item: Equipment) => ({
|
||||
value: item.id,
|
||||
label: `${item.equipmentName} (${item.equipmentCode})`
|
||||
}))
|
||||
|
|
@ -133,11 +133,11 @@ const fetchHealthData = async () => {
|
|||
getEquipmentMTTR(selectedEquipmentId.value)
|
||||
])
|
||||
|
||||
healthData.value = healthRes.data
|
||||
healthHistory.value = historyRes.data || []
|
||||
failureHistory.value = failureRes.data || []
|
||||
mtbfData.value = mtbfRes.data
|
||||
mttrData.value = mttrRes.data
|
||||
healthData.value = healthRes.data.data
|
||||
healthHistory.value = historyRes.data.data || []
|
||||
failureHistory.value = failureRes.data.data || []
|
||||
mtbfData.value = mtbfRes.data.data
|
||||
mttrData.value = mttrRes.data.data
|
||||
|
||||
// 渲染图表
|
||||
setTimeout(() => {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
<script setup lang="ts">
|
||||
import { ref, reactive, onMounted } from 'vue'
|
||||
import type { PaginationInfo } from '@/types'
|
||||
import { getErrorMessage, isValidationError } from '@/utils/error-handler'
|
||||
import { Button, Select, Space, message, Drawer, InputNumber, DatePicker, TreeSelect, Popconfirm, Statistic, Row, Col, Card, Modal, Upload } from 'ant-design-vue'
|
||||
import type { ColumnsType } from 'ant-design-vue/es/table'
|
||||
import type { UploadProps } from 'ant-design-vue'
|
||||
|
|
@ -43,11 +45,8 @@ import {
|
|||
type EquipmentType,
|
||||
type OwnershipType,
|
||||
type SystemType,
|
||||
type OwnershipEntity,
|
||||
type EquipmentStatsByType,
|
||||
type EquipmentStatsByOwnership,
|
||||
type EquipmentPhoto,
|
||||
type EquipmentDocument
|
||||
type EquipmentStatsByOwnership
|
||||
} from '@/api/equipment'
|
||||
import PhotoManager from './components/PhotoManager.vue'
|
||||
import DocumentManager from './components/DocumentManager.vue'
|
||||
|
|
@ -141,30 +140,30 @@ const rowSelection = {
|
|||
// 获取项目列表
|
||||
const fetchProjects = async () => {
|
||||
try {
|
||||
const res = await getProjectSelectorList()
|
||||
const list = (res as any)?.data?.data || []
|
||||
const response = await getProjectSelectorList()
|
||||
const res = response.data
|
||||
const list = res.data || []
|
||||
projectOptions.value = list.map((item: any) => ({
|
||||
value: item.id,
|
||||
label: item.name
|
||||
}))
|
||||
} catch (error: any) {
|
||||
console.error('获取项目列表失败:', error)
|
||||
message.error('获取项目列表失败')
|
||||
} catch (error: unknown) {
|
||||
message.error(getErrorMessage(error))
|
||||
}
|
||||
}
|
||||
|
||||
// 获取归属主体列表
|
||||
const fetchOwnershipEntityList = async () => {
|
||||
try {
|
||||
const res = await getOwnershipEntityList()
|
||||
const list = (res as any)?.data?.data || []
|
||||
const response = await getOwnershipEntityList()
|
||||
const res = response.data
|
||||
const list = res.data || []
|
||||
ownershipEntityOptions.value = list.map((item: any) => ({
|
||||
value: item.id,
|
||||
label: item.entityName || item.name
|
||||
}))
|
||||
} catch (error: any) {
|
||||
console.error('获取归属主体列表失败:', error)
|
||||
message.error('获取归属主体列表失败')
|
||||
} catch (error: unknown) {
|
||||
message.error(getErrorMessage(error))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -176,15 +175,17 @@ const fetchEquipmentList = async () => {
|
|||
}
|
||||
loading.value = true
|
||||
try {
|
||||
let res
|
||||
let response
|
||||
if (queryParams.equipmentType) {
|
||||
res = await getEquipmentByType(queryParams.projectId, queryParams.equipmentType)
|
||||
response = await getEquipmentByType(queryParams.projectId, queryParams.equipmentType)
|
||||
} else if (queryParams.ownershipType) {
|
||||
res = await getEquipmentByOwnership(queryParams.projectId, queryParams.ownershipType)
|
||||
response = await getEquipmentByOwnership(queryParams.projectId, queryParams.ownershipType)
|
||||
} else {
|
||||
res = await getEquipmentList(queryParams.projectId)
|
||||
response = await getEquipmentList(queryParams.projectId)
|
||||
}
|
||||
let data = res.data || []
|
||||
const res = response.data
|
||||
// 处理不同的返回格式:可能是 ApiResponse<Equipment[]> 或直接的 Equipment[]
|
||||
let data: Equipment[] = Array.isArray(res) ? res : (res as any)?.data || (res as any)?.content || []
|
||||
// 按系统类型筛选
|
||||
if (queryParams.systemType) {
|
||||
data = data.filter((item: Equipment) => item.systemType === queryParams.systemType)
|
||||
|
|
@ -203,14 +204,15 @@ const fetchEquipmentStats = async () => {
|
|||
if (!queryParams.projectId) return
|
||||
statsLoading.value = true
|
||||
try {
|
||||
const [countRes, typeRes, ownershipRes] = await Promise.all([
|
||||
const [countResponse, typeResponse, ownershipResponse] = await Promise.all([
|
||||
getEquipmentCountStats(queryParams.projectId),
|
||||
getEquipmentStatsByType(queryParams.projectId),
|
||||
getEquipmentStatsByOwnership(queryParams.projectId)
|
||||
])
|
||||
countStats.value = countRes.data || { total: 0, normal: 0, warning: 0, abnormal: 0 }
|
||||
statsByType.value = typeRes.data || []
|
||||
statsByOwnership.value = ownershipRes.data || []
|
||||
// getEquipmentCountStats 返回的是 EquipmentCountStats 对象,不是 ApiResponse 包装
|
||||
countStats.value = countResponse.data || { total: 0, normal: 0, warning: 0, abnormal: 0 }
|
||||
statsByType.value = typeResponse.data.data || []
|
||||
statsByOwnership.value = ownershipResponse.data.data || []
|
||||
} catch {
|
||||
message.error('获取设备统计失败')
|
||||
} finally {
|
||||
|
|
@ -326,7 +328,8 @@ const openAddModal = () => {
|
|||
const fetchSpaceTree = async () => {
|
||||
if (!queryParams.projectId) return
|
||||
try {
|
||||
const res = await getSpaceTree(queryParams.projectId)
|
||||
const response = await getSpaceTree(queryParams.projectId)
|
||||
const res = response.data
|
||||
spaceTreeData.value = transformToTreeData(res.data || [])
|
||||
} catch {
|
||||
message.error('获取空间节点树失败')
|
||||
|
|
@ -350,11 +353,11 @@ const handleAddSubmit = async () => {
|
|||
addDrawerVisible.value = false
|
||||
fetchEquipmentList()
|
||||
fetchEquipmentStats()
|
||||
} catch (error: any) {
|
||||
if (error?.errorFields) {
|
||||
} catch (error: unknown) {
|
||||
if (isValidationError(error)) {
|
||||
return
|
||||
}
|
||||
message.error(error?.message || '添加失败')
|
||||
message.error(getErrorMessage(error))
|
||||
} finally {
|
||||
addDrawerLoading.value = false
|
||||
}
|
||||
|
|
@ -366,8 +369,9 @@ const viewEquipment = ref<Equipment | null>(null)
|
|||
|
||||
const openViewDrawer = async (record: Equipment) => {
|
||||
try {
|
||||
const res = await getEquipmentDetail(record.id)
|
||||
viewEquipment.value = res.data
|
||||
const response = await getEquipmentDetail(record.id)
|
||||
const res = response.data
|
||||
viewEquipment.value = res.data || res
|
||||
viewDrawerVisible.value = true
|
||||
} catch {
|
||||
message.error('获取设备详情失败')
|
||||
|
|
@ -418,8 +422,9 @@ const editFormState = reactive<EquipmentForm>({
|
|||
|
||||
const openEditDrawer = async (record: Equipment) => {
|
||||
try {
|
||||
const res = await getEquipmentDetail(record.id)
|
||||
const data = res.data
|
||||
const response = await getEquipmentDetail(record.id)
|
||||
const res = response.data
|
||||
const data = res.data || res
|
||||
editFormState.id = data.id
|
||||
editFormState.equipmentCode = data.equipmentCode || ''
|
||||
editFormState.equipmentName = data.equipmentName
|
||||
|
|
@ -474,11 +479,11 @@ const handleEditSubmit = async () => {
|
|||
editDrawerVisible.value = false
|
||||
fetchEquipmentList()
|
||||
fetchEquipmentStats()
|
||||
} catch (error: any) {
|
||||
if (error?.errorFields) {
|
||||
} catch (error: unknown) {
|
||||
if (isValidationError(error)) {
|
||||
return
|
||||
}
|
||||
message.error(error?.message || '修改失败')
|
||||
message.error(getErrorMessage(error))
|
||||
} finally {
|
||||
editDrawerLoading.value = false
|
||||
}
|
||||
|
|
@ -491,8 +496,8 @@ const handleDelete = async (record: Equipment) => {
|
|||
message.success('删除成功')
|
||||
fetchEquipmentList()
|
||||
fetchEquipmentStats()
|
||||
} catch (error: any) {
|
||||
message.error(error?.message || '删除失败')
|
||||
} catch (error: unknown) {
|
||||
message.error(getErrorMessage(error))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -504,7 +509,7 @@ const handleBatchDelete = async () => {
|
|||
}
|
||||
Modal.confirm({
|
||||
title: '确认删除',
|
||||
icon: ExclamationCircleOutlined,
|
||||
icon: ExclamationCircleOutlined as any,
|
||||
content: `确定删除选中的 ${selectedRowKeys.value.length} 台设备吗?`,
|
||||
async onOk() {
|
||||
try {
|
||||
|
|
@ -514,8 +519,8 @@ const handleBatchDelete = async () => {
|
|||
selectedRows.value = []
|
||||
fetchEquipmentList()
|
||||
fetchEquipmentStats()
|
||||
} catch (error: any) {
|
||||
message.error(error?.message || '批量删除失败')
|
||||
} catch (error: unknown) {
|
||||
message.error(getErrorMessage(error))
|
||||
}
|
||||
}
|
||||
})
|
||||
|
|
@ -530,7 +535,7 @@ const importUploadProps: UploadProps = {
|
|||
name: 'file',
|
||||
multiple: false,
|
||||
accept: '.xlsx,.xls',
|
||||
fileList: importFileList,
|
||||
fileList: importFileList as any,
|
||||
beforeUpload: (file: any) => {
|
||||
importFileList.value = [file]
|
||||
return false
|
||||
|
|
@ -552,11 +557,11 @@ const handleImport = async () => {
|
|||
importing.value = true
|
||||
try {
|
||||
const file = importFileList.value[0].originFileObj || importFileList.value[0]
|
||||
const res = await importEquipment(file, queryParams.projectId)
|
||||
const data = res.data
|
||||
const response = await importEquipment(file, queryParams.projectId)
|
||||
const res = response.data
|
||||
const data = res.data || res
|
||||
if (data.failCount > 0) {
|
||||
message.warning(`导入完成:成功 ${data.successCount} 条,失败 ${data.failCount} 条`)
|
||||
console.warn('导入失败详情:', data.failDetails)
|
||||
} else {
|
||||
message.success(`导入成功:${data.successCount} 条`)
|
||||
}
|
||||
|
|
@ -564,8 +569,8 @@ const handleImport = async () => {
|
|||
importFileList.value = []
|
||||
fetchEquipmentList()
|
||||
fetchEquipmentStats()
|
||||
} catch (error: any) {
|
||||
message.error(error?.message || '导入失败')
|
||||
} catch (error: unknown) {
|
||||
message.error(getErrorMessage(error))
|
||||
} finally {
|
||||
importing.value = false
|
||||
}
|
||||
|
|
@ -581,8 +586,8 @@ const handleExport = async () => {
|
|||
}
|
||||
exporting.value = true
|
||||
try {
|
||||
const res = await exportEquipment(queryParams.projectId)
|
||||
const blob = new Blob([res.data as unknown as BlobPart], { type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' })
|
||||
const response = await exportEquipment(queryParams.projectId)
|
||||
const blob = new Blob([response.data as unknown as BlobPart], { type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' })
|
||||
const url = window.URL.createObjectURL(blob)
|
||||
const link = document.createElement('a')
|
||||
link.href = url
|
||||
|
|
@ -590,8 +595,8 @@ const handleExport = async () => {
|
|||
link.click()
|
||||
window.URL.revokeObjectURL(url)
|
||||
message.success('导出成功')
|
||||
} catch (error: any) {
|
||||
message.error(error?.message || '导出失败')
|
||||
} catch (error: unknown) {
|
||||
message.error(getErrorMessage(error))
|
||||
} finally {
|
||||
exporting.value = false
|
||||
}
|
||||
|
|
@ -743,7 +748,7 @@ onMounted(() => {
|
|||
showQuickJumper: true,
|
||||
showTotal: (total: number) => `共 ${total} 条`
|
||||
}"
|
||||
@change="(pag: any) => handlePageChange(pag.current, pag.pageSize)"
|
||||
@change="(pag: PaginationInfo) => handlePageChange(pag.current, pag.pageSize)"
|
||||
>
|
||||
<template #bodyCell="{ column, record }">
|
||||
<template v-if="column.key === 'systemType'">
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
<script setup lang="ts">
|
||||
import { ref, reactive, onMounted } from 'vue'
|
||||
import { Button, Select, Space, message, Drawer, Tabs, TabPane, Table, Popconfirm, Tag, Form, DatePicker } from 'ant-design-vue'
|
||||
import { getErrorMessage, isValidationError } from '@/utils/error-handler'
|
||||
import { Button, Select, Space, message, Drawer, Popconfirm, Tag, DatePicker } from 'ant-design-vue'
|
||||
import type { ColumnsType } from 'ant-design-vue/es/table'
|
||||
import {
|
||||
SearchOutlined,
|
||||
|
|
@ -73,9 +74,11 @@ const itemPagination = reactive({
|
|||
const fetchInspectionItems = async () => {
|
||||
itemLoading.value = true
|
||||
try {
|
||||
const res = await getInspectionItems()
|
||||
itemData.value = res.data || []
|
||||
itemPagination.total = res.data?.length || 0
|
||||
const response = await getInspectionItems()
|
||||
const apiRes = response.data
|
||||
const data = apiRes.data || []
|
||||
itemData.value = data
|
||||
itemPagination.total = data.length || 0
|
||||
} catch {
|
||||
message.error('获取巡检标准项列表失败')
|
||||
} finally {
|
||||
|
|
@ -134,7 +137,7 @@ const recordPagination = reactive({
|
|||
const fetchProjects = async () => {
|
||||
try {
|
||||
const res = await getProjectSelectorList()
|
||||
projectOptions.value = (res.data || []).map((item: any) => ({
|
||||
projectOptions.value = (res.data.data || []).map((item: any) => ({
|
||||
value: item.id,
|
||||
label: item.name
|
||||
}))
|
||||
|
|
@ -146,8 +149,10 @@ const fetchProjects = async () => {
|
|||
// 获取设备列表
|
||||
const fetchEquipments = async (projectId: string) => {
|
||||
try {
|
||||
const res = await getEquipmentList(projectId)
|
||||
equipmentOptions.value = (res.data || []).map((item: any) => ({
|
||||
const response = await getEquipmentList(projectId)
|
||||
const apiRes = response.data
|
||||
const data = apiRes.data || []
|
||||
equipmentOptions.value = data.map((item: any) => ({
|
||||
value: item.id,
|
||||
label: item.equipmentName
|
||||
}))
|
||||
|
|
@ -164,9 +169,11 @@ const fetchInspectionRecords = async () => {
|
|||
}
|
||||
recordLoading.value = true
|
||||
try {
|
||||
const res = await getInspectionRecords(queryParams.projectId, queryParams.equipmentId)
|
||||
recordData.value = res.data || []
|
||||
recordPagination.total = res.data?.length || 0
|
||||
const response = await getInspectionRecords(queryParams.projectId, queryParams.equipmentId)
|
||||
const apiRes = response.data
|
||||
const data = apiRes.data || []
|
||||
recordData.value = data
|
||||
recordPagination.total = data.length || 0
|
||||
} catch {
|
||||
message.error('获取巡检记录列表失败')
|
||||
} finally {
|
||||
|
|
@ -240,11 +247,11 @@ const handleAddItemSubmit = async () => {
|
|||
message.success('添加成功')
|
||||
addItemDrawerVisible.value = false
|
||||
fetchInspectionItems()
|
||||
} catch (error: any) {
|
||||
if (error?.errorFields) {
|
||||
} catch (error: unknown) {
|
||||
if (isValidationError(error)) {
|
||||
return
|
||||
}
|
||||
message.error(error?.message || '添加失败')
|
||||
message.error(getErrorMessage(error))
|
||||
} finally {
|
||||
addItemDrawerLoading.value = false
|
||||
}
|
||||
|
|
@ -291,11 +298,11 @@ const handleEditItemSubmit = async () => {
|
|||
message.success('修改成功')
|
||||
editItemDrawerVisible.value = false
|
||||
fetchInspectionItems()
|
||||
} catch (error: any) {
|
||||
if (error?.errorFields) {
|
||||
} catch (error: unknown) {
|
||||
if (isValidationError(error)) {
|
||||
return
|
||||
}
|
||||
message.error(error?.message || '修改失败')
|
||||
message.error(getErrorMessage(error))
|
||||
} finally {
|
||||
editItemDrawerLoading.value = false
|
||||
}
|
||||
|
|
@ -307,8 +314,8 @@ const handleDeleteItem = async (record: InspectionItem) => {
|
|||
await deleteInspectionItem(record.id!)
|
||||
message.success('删除成功')
|
||||
fetchInspectionItems()
|
||||
} catch (error: any) {
|
||||
message.error(error?.message || '删除失败')
|
||||
} catch (error: unknown) {
|
||||
message.error(getErrorMessage(error))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -350,11 +357,11 @@ const handleAddRecordSubmit = async () => {
|
|||
message.success('添加成功')
|
||||
addRecordDrawerVisible.value = false
|
||||
fetchInspectionRecords()
|
||||
} catch (error: any) {
|
||||
if (error?.errorFields) {
|
||||
} catch (error: unknown) {
|
||||
if (isValidationError(error)) {
|
||||
return
|
||||
}
|
||||
message.error(error?.message || '添加失败')
|
||||
message.error(getErrorMessage(error))
|
||||
} finally {
|
||||
addRecordDrawerLoading.value = false
|
||||
}
|
||||
|
|
@ -375,8 +382,9 @@ const editRecordFormState = reactive<InspectionRecordForm>({
|
|||
|
||||
const openEditRecordDrawer = async (record: InspectionRecord) => {
|
||||
try {
|
||||
const res = await getInspectionRecord(record.id!)
|
||||
const data = res.data
|
||||
const response = await getInspectionRecord(record.id!)
|
||||
const apiRes = response.data
|
||||
const data = apiRes.data || apiRes
|
||||
editRecordFormState.id = data.id
|
||||
editRecordFormState.equipmentId = data.equipmentId
|
||||
editRecordFormState.inspectionDate = data.inspectionDate
|
||||
|
|
@ -397,11 +405,11 @@ const handleEditRecordSubmit = async () => {
|
|||
message.success('修改成功')
|
||||
editRecordDrawerVisible.value = false
|
||||
fetchInspectionRecords()
|
||||
} catch (error: any) {
|
||||
if (error?.errorFields) {
|
||||
} catch (error: unknown) {
|
||||
if (isValidationError(error)) {
|
||||
return
|
||||
}
|
||||
message.error(error?.message || '修改失败')
|
||||
message.error(getErrorMessage(error))
|
||||
} finally {
|
||||
editRecordDrawerLoading.value = false
|
||||
}
|
||||
|
|
@ -413,8 +421,8 @@ const handleCompleteRecord = async (record: InspectionRecord) => {
|
|||
await completeInspectionRecord(record.id!)
|
||||
message.success('巡检已完成')
|
||||
fetchInspectionRecords()
|
||||
} catch (error: any) {
|
||||
message.error(error?.message || '操作失败')
|
||||
} catch (error: unknown) {
|
||||
message.error(getErrorMessage(error))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
<script setup lang="ts">
|
||||
import { ref, reactive, onMounted } from 'vue'
|
||||
import type { PaginationInfo } from '@/types'
|
||||
import { getErrorMessage, isValidationError } from '@/utils/error-handler'
|
||||
import { Button, Select, Space, message, Drawer, InputNumber, DatePicker, Popconfirm, Tag } from 'ant-design-vue'
|
||||
import type { ColumnsType } from 'ant-design-vue/es/table'
|
||||
import {
|
||||
|
|
@ -90,7 +92,7 @@ const pagination = reactive({
|
|||
const fetchProjects = async () => {
|
||||
try {
|
||||
const res = await getProjectSelectorList()
|
||||
projectOptions.value = (res.data || []).map((item: any) => ({
|
||||
projectOptions.value = (res.data.data || []).map((item: any) => ({
|
||||
value: item.id,
|
||||
label: item.name
|
||||
}))
|
||||
|
|
@ -102,8 +104,10 @@ const fetchProjects = async () => {
|
|||
// 获取设备列表
|
||||
const fetchEquipments = async (projectId: string) => {
|
||||
try {
|
||||
const res = await getEquipmentList(projectId)
|
||||
equipmentOptions.value = (res.data || []).map((item: any) => ({
|
||||
const response = await getEquipmentList(projectId)
|
||||
const apiRes = response.data
|
||||
const data = apiRes.data || []
|
||||
equipmentOptions.value = data.map((item: any) => ({
|
||||
value: item.id,
|
||||
label: item.equipmentName
|
||||
}))
|
||||
|
|
@ -120,9 +124,11 @@ const fetchMaintenancePlans = async () => {
|
|||
}
|
||||
loading.value = true
|
||||
try {
|
||||
const res = await getMaintenancePlans(queryParams.projectId)
|
||||
tableData.value = res.data || []
|
||||
pagination.total = res.data?.length || 0
|
||||
const response = await getMaintenancePlans(queryParams.projectId)
|
||||
const apiRes = response.data
|
||||
const data = apiRes.data || []
|
||||
tableData.value = data
|
||||
pagination.total = data.length || 0
|
||||
} catch {
|
||||
message.error('获取维保计划列表失败')
|
||||
} finally {
|
||||
|
|
@ -207,11 +213,11 @@ const handleAddSubmit = async () => {
|
|||
message.success('添加成功')
|
||||
addDrawerVisible.value = false
|
||||
fetchMaintenancePlans()
|
||||
} catch (error: any) {
|
||||
if (error?.errorFields) {
|
||||
} catch (error: unknown) {
|
||||
if (isValidationError(error)) {
|
||||
return
|
||||
}
|
||||
message.error(error?.message || '添加失败')
|
||||
message.error(getErrorMessage(error))
|
||||
} finally {
|
||||
addDrawerLoading.value = false
|
||||
}
|
||||
|
|
@ -236,8 +242,9 @@ const editFormState = reactive<MaintenancePlanForm>({
|
|||
|
||||
const openEditDrawer = async (record: MaintenancePlan) => {
|
||||
try {
|
||||
const res = await getMaintenancePlan(record.id!)
|
||||
const data = res.data
|
||||
const response = await getMaintenancePlan(record.id!)
|
||||
const apiRes = response.data
|
||||
const data = apiRes.data || apiRes
|
||||
editFormState.id = data.id
|
||||
editFormState.equipmentId = data.equipmentId
|
||||
editFormState.planName = data.planName
|
||||
|
|
@ -262,11 +269,11 @@ const handleEditSubmit = async () => {
|
|||
message.success('修改成功')
|
||||
editDrawerVisible.value = false
|
||||
fetchMaintenancePlans()
|
||||
} catch (error: any) {
|
||||
if (error?.errorFields) {
|
||||
} catch (error: unknown) {
|
||||
if (isValidationError(error)) {
|
||||
return
|
||||
}
|
||||
message.error(error?.message || '修改失败')
|
||||
message.error(getErrorMessage(error))
|
||||
} finally {
|
||||
editDrawerLoading.value = false
|
||||
}
|
||||
|
|
@ -278,8 +285,8 @@ const handleDelete = async (record: MaintenancePlan) => {
|
|||
await deleteMaintenancePlan(record.id!)
|
||||
message.success('删除成功')
|
||||
fetchMaintenancePlans()
|
||||
} catch (error: any) {
|
||||
message.error(error?.message || '删除失败')
|
||||
} catch (error: unknown) {
|
||||
message.error(getErrorMessage(error))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -334,7 +341,7 @@ onMounted(() => {
|
|||
showQuickJumper: true,
|
||||
showTotal: (total: number) => `共 ${total} 条`
|
||||
}"
|
||||
@change="(pag: any) => handlePageChange(pag.current, pag.pageSize)"
|
||||
@change="(pag: PaginationInfo) => handlePageChange(pag.current, pag.pageSize)"
|
||||
>
|
||||
<template #bodyCell="{ column, record }">
|
||||
<template v-if="column.key === 'planType'">
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
<script setup lang="ts">
|
||||
import { ref, reactive, onMounted, computed } from 'vue'
|
||||
import { Button, Select, Space, message, Drawer, InputNumber, DatePicker, Popconfirm, Tag, Modal, Card, Statistic, Row, Col, Form, Input, Table } from 'ant-design-vue'
|
||||
import { ref, reactive, onMounted } from 'vue'
|
||||
import { Button, Select, Space, message, Drawer, InputNumber, DatePicker, Popconfirm, Tag, Modal, Card, Statistic, Row, Col, Input } from 'ant-design-vue'
|
||||
import type { ColumnsType } from 'ant-design-vue/es/table'
|
||||
import {
|
||||
SearchOutlined,
|
||||
|
|
@ -13,9 +13,7 @@ import {
|
|||
PlayCircleOutlined,
|
||||
SendOutlined,
|
||||
EyeOutlined,
|
||||
SafetyCertificateOutlined,
|
||||
ClockCircleOutlined,
|
||||
ToolOutlined
|
||||
SafetyCertificateOutlined
|
||||
} from '@ant-design/icons-vue'
|
||||
import {
|
||||
getMaintenanceTasks,
|
||||
|
|
@ -40,11 +38,12 @@ import {
|
|||
type TaskType,
|
||||
type TaskPriority,
|
||||
type TaskStatus,
|
||||
type TriggerType,
|
||||
type PartsUsed
|
||||
} from '@/api/maintenance-task'
|
||||
import { getProjectSelectorList } from '@/api/project'
|
||||
import { getEquipmentList } from '@/api/equipment'
|
||||
import type { PaginationInfo } from '@/types'
|
||||
import { getErrorMessage, isValidationError } from '@/utils/error-handler'
|
||||
|
||||
// 格式化日期
|
||||
const formatDate = (date: string | Date | undefined) => {
|
||||
|
|
@ -152,7 +151,7 @@ const fetchStats = async () => {
|
|||
const fetchProjects = async () => {
|
||||
try {
|
||||
const res = await getProjectSelectorList()
|
||||
projectOptions.value = (res.data || []).map((item: any) => ({
|
||||
projectOptions.value = (res.data.data || []).map((item: any) => ({
|
||||
value: item.id,
|
||||
label: item.name
|
||||
}))
|
||||
|
|
@ -164,8 +163,9 @@ const fetchProjects = async () => {
|
|||
// 获取设备列表
|
||||
const fetchEquipments = async (projectId: string) => {
|
||||
try {
|
||||
const res = await getEquipmentList(projectId)
|
||||
equipmentOptions.value = (res.data || []).map((item: any) => ({
|
||||
const response = await getEquipmentList(projectId)
|
||||
const apiRes = response.data
|
||||
equipmentOptions.value = (apiRes.data || []).map((item: any) => ({
|
||||
value: item.id,
|
||||
label: item.equipmentName
|
||||
}))
|
||||
|
|
@ -178,9 +178,10 @@ const fetchEquipments = async (projectId: string) => {
|
|||
const fetchMaintenanceTasks = async () => {
|
||||
loading.value = true
|
||||
try {
|
||||
const res = await getMaintenanceTasks(queryParams.projectId)
|
||||
let data = res.data || []
|
||||
|
||||
const response = await getMaintenanceTasks(queryParams.projectId)
|
||||
const apiRes = response.data
|
||||
let data: MaintenanceTask[] = apiRes.data || []
|
||||
|
||||
// 前端筛选
|
||||
if (queryParams.status) {
|
||||
data = data.filter(t => t.status === queryParams.status)
|
||||
|
|
@ -193,13 +194,13 @@ const fetchMaintenanceTasks = async () => {
|
|||
}
|
||||
if (queryParams.keyword) {
|
||||
const kw = queryParams.keyword.toLowerCase()
|
||||
data = data.filter(t =>
|
||||
t.taskNo?.toLowerCase().includes(kw) ||
|
||||
data = data.filter(t =>
|
||||
t.taskNo?.toLowerCase().includes(kw) ||
|
||||
t.title?.toLowerCase().includes(kw) ||
|
||||
t.equipmentName?.toLowerCase().includes(kw)
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
tableData.value = data
|
||||
pagination.total = data.length
|
||||
} catch {
|
||||
|
|
@ -233,7 +234,7 @@ const handlePageChange = (page: number, pageSize: number) => {
|
|||
}
|
||||
|
||||
// 项目变化时重新加载设备列表
|
||||
const handleProjectChange = (val: string) => {
|
||||
const handleProjectChange = (val: any) => {
|
||||
if (val) {
|
||||
fetchEquipments(val)
|
||||
}
|
||||
|
|
@ -246,8 +247,9 @@ const detailData = ref<MaintenanceTask | null>(null)
|
|||
|
||||
const openDetailDrawer = async (record: MaintenanceTask) => {
|
||||
try {
|
||||
const res = await getMaintenanceTask(record.id!)
|
||||
detailData.value = res.data
|
||||
const response = await getMaintenanceTask(record.id!)
|
||||
const apiRes = response.data
|
||||
detailData.value = apiRes.data || apiRes
|
||||
detailDrawerVisible.value = true
|
||||
} catch {
|
||||
message.error('获取工单详情失败')
|
||||
|
|
@ -304,9 +306,9 @@ const handleAddSubmit = async () => {
|
|||
message.success('创建成功')
|
||||
addDrawerVisible.value = false
|
||||
fetchMaintenanceTasks()
|
||||
} catch (error: any) {
|
||||
if (error?.errorFields) return
|
||||
message.error(error?.message || '创建失败')
|
||||
} catch (error: unknown) {
|
||||
if (isValidationError(error)) return
|
||||
message.error(getErrorMessage(error))
|
||||
} finally {
|
||||
addDrawerLoading.value = false
|
||||
}
|
||||
|
|
@ -330,8 +332,9 @@ const editFormState = reactive<MaintenanceTaskForm & { id?: string }>({
|
|||
|
||||
const openEditDrawer = async (record: MaintenanceTask) => {
|
||||
try {
|
||||
const res = await getMaintenanceTask(record.id!)
|
||||
const data = res.data
|
||||
const response = await getMaintenanceTask(record.id!)
|
||||
const apiRes = response.data
|
||||
const data = apiRes.data || apiRes
|
||||
editFormState.id = data.id
|
||||
editFormState.equipmentId = data.equipmentId
|
||||
editFormState.taskType = data.taskType
|
||||
|
|
@ -355,9 +358,9 @@ const handleEditSubmit = async () => {
|
|||
message.success('修改成功')
|
||||
editDrawerVisible.value = false
|
||||
fetchMaintenanceTasks()
|
||||
} catch (error: any) {
|
||||
if (error?.errorFields) return
|
||||
message.error(error?.message || '修改失败')
|
||||
} catch (error: unknown) {
|
||||
if (isValidationError(error)) return
|
||||
message.error(getErrorMessage(error))
|
||||
} finally {
|
||||
editDrawerLoading.value = false
|
||||
}
|
||||
|
|
@ -369,8 +372,8 @@ const handleDelete = async (record: MaintenanceTask) => {
|
|||
await deleteMaintenanceTask(record.id!)
|
||||
message.success('删除成功')
|
||||
fetchMaintenanceTasks()
|
||||
} catch (error: any) {
|
||||
message.error(error?.message || '删除失败')
|
||||
} catch (error: unknown) {
|
||||
message.error(getErrorMessage(error))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -401,9 +404,9 @@ const handleAssignSubmit = async () => {
|
|||
message.success('派单成功')
|
||||
assignDrawerVisible.value = false
|
||||
fetchMaintenanceTasks()
|
||||
} catch (error: any) {
|
||||
if (error?.errorFields) return
|
||||
message.error(error?.message || '派单失败')
|
||||
} catch (error: unknown) {
|
||||
if (isValidationError(error)) return
|
||||
message.error(getErrorMessage(error))
|
||||
} finally {
|
||||
assignLoading.value = false
|
||||
}
|
||||
|
|
@ -419,8 +422,8 @@ const handleStart = async (record: MaintenanceTask) => {
|
|||
await startTask(record.id!)
|
||||
message.success('已开始执行')
|
||||
fetchMaintenanceTasks()
|
||||
} catch (error: any) {
|
||||
message.error(error?.message || '操作失败')
|
||||
} catch (error: unknown) {
|
||||
message.error(getErrorMessage(error))
|
||||
}
|
||||
}
|
||||
})
|
||||
|
|
@ -498,9 +501,9 @@ const handleCompleteSubmit = async () => {
|
|||
message.success('工单已完成')
|
||||
completeDrawerVisible.value = false
|
||||
fetchMaintenanceTasks()
|
||||
} catch (error: any) {
|
||||
if (error?.errorFields) return
|
||||
message.error(error?.message || '操作失败')
|
||||
} catch (error: unknown) {
|
||||
if (isValidationError(error)) return
|
||||
message.error(getErrorMessage(error))
|
||||
} finally {
|
||||
completeLoading.value = false
|
||||
}
|
||||
|
|
@ -537,9 +540,9 @@ const handleVerifySubmit = async () => {
|
|||
message.success('验收成功')
|
||||
verifyDrawerVisible.value = false
|
||||
fetchMaintenanceTasks()
|
||||
} catch (error: any) {
|
||||
if (error?.errorFields) return
|
||||
message.error(error?.message || '验收失败')
|
||||
} catch (error: unknown) {
|
||||
if (isValidationError(error)) return
|
||||
message.error(getErrorMessage(error))
|
||||
} finally {
|
||||
verifyLoading.value = false
|
||||
}
|
||||
|
|
@ -557,8 +560,8 @@ const handleCancel = (record: MaintenanceTask) => {
|
|||
await cancelTask(record.id!)
|
||||
message.success('工单已取消')
|
||||
fetchMaintenanceTasks()
|
||||
} catch (error: any) {
|
||||
message.error(error?.message || '操作失败')
|
||||
} catch (error: unknown) {
|
||||
message.error(getErrorMessage(error))
|
||||
}
|
||||
}
|
||||
})
|
||||
|
|
@ -592,22 +595,22 @@ onMounted(() => {
|
|||
</Col>
|
||||
<Col :span="4">
|
||||
<Card class="stat-card stat-pending">
|
||||
<Statistic title="待分配" :value="stats.pending" value-style="color: #8c8c8c" />
|
||||
<Statistic title="待分配" :value="stats.pending" :value-style="{ color: '#8c8c8c' }" />
|
||||
</Card>
|
||||
</Col>
|
||||
<Col :span="4">
|
||||
<Card class="stat-card stat-progress">
|
||||
<Statistic title="执行中" :value="stats.inProgress" value-style="color: #fa8c16" />
|
||||
<Statistic title="执行中" :value="stats.inProgress" :value-style="{ color: '#fa8c16' }" />
|
||||
</Card>
|
||||
</Col>
|
||||
<Col :span="4">
|
||||
<Card class="stat-card stat-completed">
|
||||
<Statistic title="今日完成" :value="stats.completedToday" value-style="color: #52c41a" />
|
||||
<Statistic title="今日完成" :value="stats.completedToday" :value-style="{ color: '#52c41a' }" />
|
||||
</Card>
|
||||
</Col>
|
||||
<Col :span="4">
|
||||
<Card class="stat-card stat-verified">
|
||||
<Statistic title="逾期工单" :value="stats.overdue" value-style="color: #ff4d4f" />
|
||||
<Statistic title="逾期工单" :value="stats.overdue" :value-style="{ color: '#ff4d4f' }" />
|
||||
</Card>
|
||||
</Col>
|
||||
<Col :span="4">
|
||||
|
|
@ -683,7 +686,7 @@ onMounted(() => {
|
|||
showQuickJumper: true,
|
||||
showTotal: (total: number) => `共 ${total} 条`
|
||||
}"
|
||||
@change="(pag: any) => handlePageChange(pag.current, pag.pageSize)"
|
||||
@change="(pag: PaginationInfo) => handlePageChange(pag.current, pag.pageSize)"
|
||||
>
|
||||
<template #bodyCell="{ column, record }">
|
||||
<template v-if="column.key === 'taskType'">
|
||||
|
|
@ -693,12 +696,12 @@ onMounted(() => {
|
|||
{{ getLabel(TRIGGER_TYPE_OPTIONS, record.triggerType) }}
|
||||
</template>
|
||||
<template v-else-if="column.key === 'priority'">
|
||||
<Tag :color="PRIORITY_COLOR_MAP[record.priority]">
|
||||
<Tag :color="PRIORITY_COLOR_MAP[record.priority as TaskPriority]">
|
||||
{{ getLabel(TASK_PRIORITY_OPTIONS, record.priority) }}
|
||||
</Tag>
|
||||
</template>
|
||||
<template v-else-if="column.key === 'status'">
|
||||
<Tag :color="STATUS_COLOR_MAP[record.status]">
|
||||
<Tag :color="STATUS_COLOR_MAP[record.status as TaskStatus]">
|
||||
{{ getLabel(TASK_STATUS_OPTIONS, record.status) }}
|
||||
</Tag>
|
||||
</template>
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
<script setup lang="ts">
|
||||
import { ref, reactive, onMounted, computed } from 'vue'
|
||||
import { Button, Select, Space, message, Drawer, InputNumber, DatePicker, Popconfirm, Tag, Modal, Card, Statistic, Row, Col, Form, Input, Table } from 'ant-design-vue'
|
||||
import { ref, reactive, onMounted } from 'vue'
|
||||
import type { PaginationInfo } from '@/types'
|
||||
import { Button, Select, Space, message, Drawer, InputNumber, DatePicker, Popconfirm, Tag, Modal, Card, Statistic, Row, Col, Input } from 'ant-design-vue'
|
||||
import type { ColumnsType } from 'ant-design-vue/es/table'
|
||||
import {
|
||||
SearchOutlined,
|
||||
|
|
@ -13,9 +14,7 @@ import {
|
|||
PlayCircleOutlined,
|
||||
SendOutlined,
|
||||
EyeOutlined,
|
||||
SafetyCertificateOutlined,
|
||||
ClockCircleOutlined,
|
||||
ToolOutlined
|
||||
SafetyCertificateOutlined
|
||||
} from '@ant-design/icons-vue'
|
||||
import {
|
||||
getWorkOrders,
|
||||
|
|
@ -47,6 +46,7 @@ import {
|
|||
} from '@/api/work-order'
|
||||
import { getProjectSelectorList } from '@/api/project'
|
||||
import { getEquipmentList } from '@/api/equipment'
|
||||
import { getErrorMessage, isValidationError } from '@/utils/error-handler'
|
||||
|
||||
// 格式化日期
|
||||
const formatDate = (date: string | Date | undefined) => {
|
||||
|
|
@ -130,8 +130,9 @@ const stats = reactive({
|
|||
// 获取统计数据
|
||||
const fetchStats = async () => {
|
||||
try {
|
||||
const res = await getWorkOrderStats()
|
||||
const data = res.data
|
||||
const response = await getWorkOrderStats()
|
||||
const apiRes = response.data
|
||||
const data = apiRes.data || apiRes
|
||||
if (data) {
|
||||
stats.total = data.total || 0
|
||||
stats.pending = data.pending || 0
|
||||
|
|
@ -154,8 +155,10 @@ const fetchStats = async () => {
|
|||
// 获取项目列表
|
||||
const fetchProjects = async () => {
|
||||
try {
|
||||
const res = await getProjectSelectorList()
|
||||
projectOptions.value = (res.data || []).map((item: any) => ({
|
||||
const response = await getProjectSelectorList()
|
||||
const apiRes = response.data
|
||||
const projectList = apiRes.data || apiRes || []
|
||||
projectOptions.value = projectList.map((item: { id: string; name: string }) => ({
|
||||
value: item.id,
|
||||
label: item.name
|
||||
}))
|
||||
|
|
@ -167,8 +170,10 @@ const fetchProjects = async () => {
|
|||
// 获取设备列表
|
||||
const fetchEquipments = async (projectId: string) => {
|
||||
try {
|
||||
const res = await getEquipmentList(projectId)
|
||||
equipmentOptions.value = (res.data || []).map((item: any) => ({
|
||||
const response = await getEquipmentList(projectId)
|
||||
const apiRes = response.data
|
||||
const equipmentList = apiRes.data || apiRes || []
|
||||
equipmentOptions.value = equipmentList.map((item: { id: string; equipmentName: string }) => ({
|
||||
value: item.id,
|
||||
label: item.equipmentName
|
||||
}))
|
||||
|
|
@ -181,25 +186,31 @@ const fetchEquipments = async (projectId: string) => {
|
|||
const fetchWorkOrders = async () => {
|
||||
loading.value = true
|
||||
try {
|
||||
const res = await getWorkOrders(queryParams.projectId)
|
||||
let data = res.data || []
|
||||
const response = await getWorkOrders({
|
||||
projectId: queryParams.projectId,
|
||||
source: queryParams.source,
|
||||
type: queryParams.type,
|
||||
status: queryParams.status
|
||||
})
|
||||
const apiRes = response.data
|
||||
let data: WorkOrder[] = apiRes.data || apiRes || []
|
||||
|
||||
// 前端筛选
|
||||
if (queryParams.source) {
|
||||
data = data.filter(t => t.source === queryParams.source)
|
||||
data = data.filter((t: WorkOrder) => t.source === queryParams.source)
|
||||
}
|
||||
if (queryParams.type) {
|
||||
data = data.filter(t => t.type === queryParams.type)
|
||||
data = data.filter((t: WorkOrder) => t.type === queryParams.type)
|
||||
}
|
||||
if (queryParams.status) {
|
||||
data = data.filter(t => t.status === queryParams.status)
|
||||
data = data.filter((t: WorkOrder) => t.status === queryParams.status)
|
||||
}
|
||||
if (queryParams.priority) {
|
||||
data = data.filter(t => t.priority === queryParams.priority)
|
||||
data = data.filter((t: WorkOrder) => t.priority === queryParams.priority)
|
||||
}
|
||||
if (queryParams.keyword) {
|
||||
const kw = queryParams.keyword.toLowerCase()
|
||||
data = data.filter(t =>
|
||||
data = data.filter((t: WorkOrder) =>
|
||||
t.workNo?.toLowerCase().includes(kw) ||
|
||||
t.title?.toLowerCase().includes(kw)
|
||||
)
|
||||
|
|
@ -253,13 +264,15 @@ const detailItems = ref<WorkOrderItem[]>([])
|
|||
|
||||
const openDetailDrawer = async (record: WorkOrder) => {
|
||||
try {
|
||||
const res = await getWorkOrder(record.id!)
|
||||
detailData.value = res.data
|
||||
const response = await getWorkOrder(record.id!)
|
||||
const apiRes = response.data
|
||||
detailData.value = apiRes.data || apiRes
|
||||
detailDrawerVisible.value = true
|
||||
// 获取工单项
|
||||
try {
|
||||
const itemsRes = await getWorkOrderItems(record.id!)
|
||||
detailItems.value = itemsRes.data || []
|
||||
const itemsResponse = await getWorkOrderItems(record.id!)
|
||||
const itemsApiRes = itemsResponse.data
|
||||
detailItems.value = itemsApiRes.data || itemsApiRes || []
|
||||
} catch {
|
||||
detailItems.value = []
|
||||
}
|
||||
|
|
@ -321,9 +334,9 @@ const handleAddSubmit = async () => {
|
|||
message.success('创建成功')
|
||||
addDrawerVisible.value = false
|
||||
fetchWorkOrders()
|
||||
} catch (error: any) {
|
||||
if (error?.errorFields) return
|
||||
message.error(error?.message || '创建失败')
|
||||
} catch (error: unknown) {
|
||||
if (isValidationError(error)) return
|
||||
message.error(getErrorMessage(error))
|
||||
} finally {
|
||||
addDrawerLoading.value = false
|
||||
}
|
||||
|
|
@ -349,8 +362,9 @@ const editFormState = reactive<Partial<WorkOrder>>({
|
|||
|
||||
const openEditDrawer = async (record: WorkOrder) => {
|
||||
try {
|
||||
const res = await getWorkOrder(record.id!)
|
||||
const data = res.data
|
||||
const response = await getWorkOrder(record.id!)
|
||||
const apiRes = response.data
|
||||
const data = apiRes.data || apiRes
|
||||
editFormState.id = data.id
|
||||
editFormState.source = data.source
|
||||
editFormState.type = data.type
|
||||
|
|
@ -375,9 +389,9 @@ const handleEditSubmit = async () => {
|
|||
message.success('修改成功')
|
||||
editDrawerVisible.value = false
|
||||
fetchWorkOrders()
|
||||
} catch (error: any) {
|
||||
if (error?.errorFields) return
|
||||
message.error(error?.message || '修改失败')
|
||||
} catch (error: unknown) {
|
||||
if (isValidationError(error)) return
|
||||
message.error(getErrorMessage(error))
|
||||
} finally {
|
||||
editDrawerLoading.value = false
|
||||
}
|
||||
|
|
@ -389,8 +403,8 @@ const handleDelete = async (record: WorkOrder) => {
|
|||
await deleteWorkOrder(record.id!)
|
||||
message.success('删除成功')
|
||||
fetchWorkOrders()
|
||||
} catch (error: any) {
|
||||
message.error(error?.message || '删除失败')
|
||||
} catch (error: unknown) {
|
||||
message.error(getErrorMessage(error))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -425,9 +439,9 @@ const handleAssignSubmit = async () => {
|
|||
message.success('派单成功')
|
||||
assignDrawerVisible.value = false
|
||||
fetchWorkOrders()
|
||||
} catch (error: any) {
|
||||
if (error?.errorFields) return
|
||||
message.error(error?.message || '派单失败')
|
||||
} catch (error: unknown) {
|
||||
if (isValidationError(error)) return
|
||||
message.error(getErrorMessage(error))
|
||||
} finally {
|
||||
assignLoading.value = false
|
||||
}
|
||||
|
|
@ -443,8 +457,8 @@ const handleStart = async (record: WorkOrder) => {
|
|||
await startWorkOrder(record.id!)
|
||||
message.success('已开始执行')
|
||||
fetchWorkOrders()
|
||||
} catch (error: any) {
|
||||
message.error(error?.message || '操作失败')
|
||||
} catch (error: unknown) {
|
||||
message.error(getErrorMessage(error))
|
||||
}
|
||||
}
|
||||
})
|
||||
|
|
@ -534,9 +548,9 @@ const handleCompleteSubmit = async () => {
|
|||
message.success('工单已完成')
|
||||
completeDrawerVisible.value = false
|
||||
fetchWorkOrders()
|
||||
} catch (error: any) {
|
||||
if (error?.errorFields) return
|
||||
message.error(error?.message || '操作失败')
|
||||
} catch (error: unknown) {
|
||||
if (isValidationError(error)) return
|
||||
message.error(getErrorMessage(error))
|
||||
} finally {
|
||||
completeLoading.value = false
|
||||
}
|
||||
|
|
@ -573,9 +587,9 @@ const handleVerifySubmit = async () => {
|
|||
message.success('验收成功')
|
||||
verifyDrawerVisible.value = false
|
||||
fetchWorkOrders()
|
||||
} catch (error: any) {
|
||||
if (error?.errorFields) return
|
||||
message.error(error?.message || '验收失败')
|
||||
} catch (error: unknown) {
|
||||
if (isValidationError(error)) return
|
||||
message.error(getErrorMessage(error))
|
||||
} finally {
|
||||
verifyLoading.value = false
|
||||
}
|
||||
|
|
@ -593,8 +607,8 @@ const handleCancel = (record: WorkOrder) => {
|
|||
await cancelWorkOrder(record.id!)
|
||||
message.success('工单已取消')
|
||||
fetchWorkOrders()
|
||||
} catch (error: any) {
|
||||
message.error(error?.message || '操作失败')
|
||||
} catch (error: unknown) {
|
||||
message.error(getErrorMessage(error))
|
||||
}
|
||||
}
|
||||
})
|
||||
|
|
@ -628,22 +642,22 @@ onMounted(() => {
|
|||
</Col>
|
||||
<Col :span="4">
|
||||
<Card class="stat-card stat-pending">
|
||||
<Statistic title="待分配" :value="stats.pending" value-style="color: #8c8c8c" />
|
||||
<Statistic title="待分配" :value="stats.pending" :value-style="{ color: '#8c8c8c' }" />
|
||||
</Card>
|
||||
</Col>
|
||||
<Col :span="4">
|
||||
<Card class="stat-card stat-progress">
|
||||
<Statistic title="执行中" :value="stats.inProgress" value-style="color: #fa8c16" />
|
||||
<Statistic title="执行中" :value="stats.inProgress" :value-style="{ color: '#fa8c16' }" />
|
||||
</Card>
|
||||
</Col>
|
||||
<Col :span="4">
|
||||
<Card class="stat-card stat-completed">
|
||||
<Statistic title="今日完成" :value="stats.completedToday" value-style="color: #52c41a" />
|
||||
<Statistic title="今日完成" :value="stats.completedToday" :value-style="{ color: '#52c41a' }" />
|
||||
</Card>
|
||||
</Col>
|
||||
<Col :span="4">
|
||||
<Card class="stat-card stat-verified">
|
||||
<Statistic title="逾期工单" :value="stats.overdue" value-style="color: #ff4d4f" />
|
||||
<Statistic title="逾期工单" :value="stats.overdue" :value-style="{ color: '#ff4d4f' }" />
|
||||
</Card>
|
||||
</Col>
|
||||
<Col :span="4">
|
||||
|
|
@ -662,7 +676,7 @@ onMounted(() => {
|
|||
style="width: 200px"
|
||||
:options="projectOptions"
|
||||
allow-clear
|
||||
@change="handleProjectChange"
|
||||
@change="(val) => handleProjectChange(val as string)"
|
||||
/>
|
||||
<Select
|
||||
v-model:value="queryParams.source"
|
||||
|
|
@ -670,7 +684,7 @@ onMounted(() => {
|
|||
style="width: 140px"
|
||||
:options="SOURCE_OPTIONS"
|
||||
allow-clear
|
||||
@change="handleSearch"
|
||||
@change="() => handleSearch()"
|
||||
/>
|
||||
<Select
|
||||
v-model:value="queryParams.type"
|
||||
|
|
@ -678,7 +692,7 @@ onMounted(() => {
|
|||
style="width: 120px"
|
||||
:options="TYPE_OPTIONS"
|
||||
allow-clear
|
||||
@change="handleSearch"
|
||||
@change="() => handleSearch()"
|
||||
/>
|
||||
<Select
|
||||
v-model:value="queryParams.status"
|
||||
|
|
@ -686,7 +700,7 @@ onMounted(() => {
|
|||
style="width: 140px"
|
||||
:options="STATUS_OPTIONS"
|
||||
allow-clear
|
||||
@change="handleSearch"
|
||||
@change="() => handleSearch()"
|
||||
/>
|
||||
<Select
|
||||
v-model:value="queryParams.priority"
|
||||
|
|
@ -694,7 +708,7 @@ onMounted(() => {
|
|||
style="width: 120px"
|
||||
:options="PRIORITY_OPTIONS"
|
||||
allow-clear
|
||||
@change="handleSearch"
|
||||
@change="() => handleSearch()"
|
||||
/>
|
||||
<Input
|
||||
v-model:value="queryParams.keyword"
|
||||
|
|
@ -727,11 +741,11 @@ onMounted(() => {
|
|||
showQuickJumper: true,
|
||||
showTotal: (total: number) => `共 ${total} 条`
|
||||
}"
|
||||
@change="(pag: any) => handlePageChange(pag.current, pag.pageSize)"
|
||||
@change="(pag: PaginationInfo) => handlePageChange(pag.current, pag.pageSize)"
|
||||
>
|
||||
<template #bodyCell="{ column, record }">
|
||||
<template v-if="column.key === 'source'">
|
||||
<Tag :color="SOURCE_COLOR_MAP[record.source]">
|
||||
<Tag :color="SOURCE_COLOR_MAP[record.source as WorkOrderSource]">
|
||||
{{ getLabel(SOURCE_OPTIONS, record.source) }}
|
||||
</Tag>
|
||||
</template>
|
||||
|
|
@ -739,12 +753,12 @@ onMounted(() => {
|
|||
{{ getLabel(TYPE_OPTIONS, record.type) }}
|
||||
</template>
|
||||
<template v-else-if="column.key === 'priority'">
|
||||
<Tag :color="PRIORITY_COLOR_MAP[record.priority]">
|
||||
<Tag :color="PRIORITY_COLOR_MAP[record.priority as WorkOrderPriority]">
|
||||
{{ getLabel(PRIORITY_OPTIONS, record.priority) }}
|
||||
</Tag>
|
||||
</template>
|
||||
<template v-else-if="column.key === 'status'">
|
||||
<Tag :color="STATUS_COLOR_MAP[record.status]">
|
||||
<Tag :color="STATUS_COLOR_MAP[record.status as WorkOrderStatus]">
|
||||
{{ getLabel(STATUS_OPTIONS, record.status) }}
|
||||
</Tag>
|
||||
</template>
|
||||
|
|
|
|||
Loading…
Reference in New Issue