fix: 适配 7 个 Vue 组件至 ApiResponse<T> 泛型格式 (120处修复)
This commit is contained in:
parent
367d638f58
commit
a5e3011d5a
|
|
@ -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,8 +178,9 @@ 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) {
|
||||
|
|
@ -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