-
- 维修单ID
- {{ row.repairId ?? '-' }}
-
项目内容
{{ row.subjectContent ?? '-' }}
- 判定标准
- {{ row.subjectStandard ?? '-' }}
-
-
- 故障描述
- {{ row.malfunction ?? '-' }}
-
-
- 维修描述
- {{ row.repairDes ?? '-' }}
+ 维修结果
+
+
+ {{ getResultLabel(row.repairResult ?? row.result) }}
+
+
备注
{{ row.remark ?? '-' }}
- 创建时间
- {{ formatHistoryTime(row.createTime) }}
+ 完成日期
+ {{
+ String(formatHistoryTime(row.finishDate)).split(' ')[0] }}
+v-for="img in row.malfunctionImages" :key="img" :src="img"
+ :preview-src-list="row.malfunctionImages" preview-teleported fit="cover"
+ class="device-ledger-history-item-image">
图片加载失败
@@ -336,73 +364,47 @@ link type="danger" @click="handleDelete(scope.row.id)"
+type="success" plain :loading="criticalExportLoading" @click="handleExportCriticalComponent"
+ v-hasPermi="['mes:device-ledger:export']">
导出
+v-loading="loading" :data="detailData?.componentList" :stripe="true"
+ :show-overflow-tooltip="true">
-
+
+type="success" plain :loading="spareExportLoading" @click="handleExportSpareBased"
+ v-hasPermi="['mes:device-ledger:export']">
导出
-
+
-
+
-
-
-
-
-
-
+
+
+
+
+
+
@@ -419,6 +421,8 @@ import download from '@/utils/download'
import { DeviceLedgerApi, DeviceLedgerVO } from '@/api/mes/deviceledger'
import { DeviceTypeApi, DeviceTypeTreeVO } from '@/api/mes/devicetype'
import { CriticalComponentApi } from '@/api/mes/criticalComponent'
+import { TicketManagementApi } from '@/api/mes/ticketManagement'
+import { DvRepairApi } from '@/api/mes/dvrepair'
import DeviceLedgerForm from './DeviceLedgerForm.vue'
import { getIntDictOptions } from '@/utils/dict'
import { isHexColor } from '@/utils/color'
@@ -445,6 +449,12 @@ const queryFormRef = ref() // 搜索的表单
const exportLoading = ref(false) // 导出的加载中
const criticalExportLoading = ref(false)
const spareExportLoading = ref(false)
+const inspectionExportLoading = ref(false)
+const inspectionDateRange = ref(undefined)
+const maintainExportLoading = ref(false)
+const maintainDateRange = ref(undefined)
+const repairExportLoading = ref(false)
+const repairDateRange = ref(undefined)
const tableRef = ref()
const selectedIds = ref([])
@@ -455,14 +465,8 @@ const handleSelectionChange = (rows: any[]) => {
const dictStore = useDictStoreWithOut()
const dictReady = ref(false)
-const inspectionHistory = computed(() => {
- return (detailData.value as any)?.inspectionList ?? []
-})
-
-const maintainHistory = computed(() => {
- const list = (detailData.value as any)?.maintainList
- return Array.isArray(list) ? list : []
-})
+const inspectionHistory = ref([])
+const maintainHistory = ref([])
const formatHistoryTime = (value: any) => {
const raw = value ?? '-'
@@ -472,21 +476,43 @@ const formatHistoryTime = (value: any) => {
if (hh !== undefined) return `${y}-${pad(m)}-${pad(d)} ${pad(hh)}:${pad(mm)}:${pad(ss)}`
return `${y}-${pad(m)}-${pad(d)}`
}
+ const tryDateFromNumber = (v: any) => {
+ const num = Number(v)
+ if (!Number.isFinite(num)) return undefined
+ const s = String(v).trim()
+ const ms = s.length === 10 ? num * 1000 : num
+ const d = new Date(ms)
+ if (Number.isNaN(d.getTime())) return undefined
+ return d
+ }
+ const tryDateFromString = (v: any) => {
+ const s = String(v).trim()
+ if (!s) return undefined
+ const d = new Date(s)
+ if (Number.isNaN(d.getTime())) return undefined
+ return d
+ }
+ const d = typeof raw === 'number' ? tryDateFromNumber(raw) : tryDateFromNumber(raw) ?? tryDateFromString(raw)
+ if (d) return formatDate(d, 'YYYY-MM-DD HH:mm:ss')
return String(raw)
}
const getResultLabel = (value: any) => {
const v = value === '' || value === null || value === undefined ? undefined : String(value)
+ if (!v) return '-'
+ const upper = v.toUpperCase()
if (v === '0') return '待检测'
- if (v === '1') return 'OK'
- if (v === '2') return 'NG'
- return '-'
+ if (v === '1' || upper === 'OK') return '通过'
+ if (v === '2' || upper === 'NG') return '不通过'
+ return v
}
const getResultTagType = (value: any) => {
const v = value === '' || value === null || value === undefined ? undefined : String(value)
- if (v === '1') return 'success'
- if (v === '2') return 'danger'
+ if (!v) return 'info'
+ const upper = v.toUpperCase()
+ if (v === '1' || upper === 'OK') return 'success'
+ if (v === '2' || upper === 'NG') return 'danger'
if (v === '0') return 'info'
return 'info'
}
@@ -509,7 +535,7 @@ const buildStepGroups = (rows: any[], options: { timeField: string; nameFieldCan
for (const row of rows ?? []) {
const time = formatHistoryTime(row?.[options.timeField] ?? row?.createTime)
- const operator = String(row?.creatorName ?? row?.creator ?? '-')
+ const operator = String(row?.operator ?? row?.creatorName ?? row?.creator ?? '-')
const groupKey = `${row?.managementId ?? ''}__${time}__${operator}`
const name =
@@ -525,7 +551,7 @@ const buildStepGroups = (rows: any[], options: { timeField: string; nameFieldCan
criteria: row?.judgmentCriteria,
images: parseImages(row?.images),
remark: row?.remark,
- inspectionTime: row?.inspectionTime,
+ taskTime: row?.taskTime,
createTime: row?.createTime
}
@@ -558,6 +584,8 @@ const maintainStepGroups = computed(() => {
type RepairHistoryRow = {
id?: any
repairId?: any
+ repairCode?: any
+ repairName?: any
subjectId?: any
subjectCode?: any
subjectName?: any
@@ -568,38 +596,128 @@ type RepairHistoryRow = {
repairDes?: any
remark?: any
createTime?: any
+ finishDate?: any
+ result?: any
+ repairResult?: any
malfunctionImages?: string[]
}
type RepairHistoryGroup = { key: string; name: string; items: RepairHistoryRow[] }
const repairActiveNames = ref([])
+const repairList = ref([])
const repairGroups = computed(() => {
- const raw = (detailData.value as any)?.repairList
- if (!raw || typeof raw !== 'object') return []
- const entries = Object.entries(raw as Record)
- const groups = entries
- .map(([name, rows]) => {
- const list = Array.isArray(rows) ? rows : []
- return {
- key: String(name),
- name: String(name),
- items: list.map((row: any) => ({
- ...row,
- malfunctionImages: parseImages(row?.malfunctionUrl)
- }))
- } as RepairHistoryGroup
+ const groupsMap = new Map()
+ for (const row of repairList.value ?? []) {
+ const key = String(row.repairCode ?? row.repairId ?? row.subjectName ?? '-')
+ if (!groupsMap.has(key)) {
+ groupsMap.set(key, {
+ key,
+ name: String(row.repairName ?? row.repairCode ?? key),
+ items: []
+ })
+ }
+ const group = groupsMap.get(key)!
+ group.items.push({
+ ...row,
+ malfunctionImages: parseImages(row?.malfunctionUrl)
})
- .filter((g) => g.items.length)
+ }
+
+ const groups = Array.from(groupsMap.values()).filter((g) => g.items.length)
return groups.sort((a, b) => {
- const at = formatHistoryTime(a.items?.[0]?.createTime)
- const bt = formatHistoryTime(b.items?.[0]?.createTime)
+ const at = formatHistoryTime(a.items?.[0]?.finishDate ?? a.items?.[0]?.createTime)
+ const bt = formatHistoryTime(b.items?.[0]?.finishDate ?? b.items?.[0]?.createTime)
return String(bt).localeCompare(String(at))
})
})
+const fetchInspectionHistory = async () => {
+ if (!selectedDetailId.value) return
+ const params: any = { deviceId: selectedDetailId.value }
+ if (inspectionDateRange.value && inspectionDateRange.value.length === 2) {
+ params.startTime = inspectionDateRange.value[0]
+ params.endTime = inspectionDateRange.value[1]
+ }
+ const data = await TicketManagementApi.getInspectionByDeviceId(params)
+ inspectionHistory.value = Array.isArray(data) ? data : []
+}
+
+const handleQueryInspection = async () => {
+ if (!selectedDetailId.value) {
+ message.error('请先选择设备')
+ return
+ }
+ await fetchInspectionHistory()
+}
+
+const handleResetInspection = async () => {
+ if (!selectedDetailId.value) {
+ message.error('请先选择设备')
+ return
+ }
+ inspectionDateRange.value = undefined
+ await fetchInspectionHistory()
+}
+
+const fetchMaintainHistory = async () => {
+ if (!selectedDetailId.value) return
+ const params: any = { deviceId: selectedDetailId.value }
+ if (maintainDateRange.value && maintainDateRange.value.length === 2) {
+ params.startTime = maintainDateRange.value[0]
+ params.endTime = maintainDateRange.value[1]
+ }
+ const data = await TicketManagementApi.getMaintenanceByDeviceId(params)
+ maintainHistory.value = Array.isArray(data) ? data : []
+}
+
+const handleQueryMaintain = async () => {
+ if (!selectedDetailId.value) {
+ message.error('请先选择设备')
+ return
+ }
+ await fetchMaintainHistory()
+}
+
+const handleResetMaintain = async () => {
+ if (!selectedDetailId.value) {
+ message.error('请先选择设备')
+ return
+ }
+ maintainDateRange.value = undefined
+ await fetchMaintainHistory()
+}
+
+const fetchRepairHistory = async () => {
+ if (!selectedDetailId.value) return
+ const params: any = { deviceId: selectedDetailId.value }
+ if (repairDateRange.value && repairDateRange.value.length === 2) {
+ params.startTime = repairDateRange.value[0]
+ params.endTime = repairDateRange.value[1]
+ }
+ const data = await DvRepairApi.getRepairListByDeviceId(params)
+ repairList.value = Array.isArray(data) ? data : []
+}
+
+const handleQueryRepair = async () => {
+ if (!selectedDetailId.value) {
+ message.error('请先选择设备')
+ return
+ }
+ await fetchRepairHistory()
+}
+
+const handleResetRepair = async () => {
+ if (!selectedDetailId.value) {
+ message.error('请先选择设备')
+ return
+ }
+ repairDateRange.value = undefined
+ await fetchRepairHistory()
+}
+
const tzStatusOptions = computed(() => {
if (!dictReady.value) return []
const options = getIntDictOptions('mes_tz_status')
@@ -712,7 +830,10 @@ const handleDetail = async (id: number) => {
detailLoading.value = true
try {
detailData.value = await DeviceLedgerApi.getDeviceLedger(id)
- const keys = Object.keys(((detailData.value as any)?.repairList ?? {}) as any)
+ await fetchInspectionHistory()
+ await fetchMaintainHistory()
+ await fetchRepairHistory()
+ const keys = repairGroups.value.map((g) => g.key)
repairActiveNames.value = keys.length ? [keys[0]] : []
} finally {
detailLoading.value = false
@@ -841,6 +962,69 @@ const handleExportSpareBased = async () => {
}
}
+const handleExportInspection = async () => {
+ if (!selectedDetailId.value) {
+ message.error('请先选择设备')
+ return
+ }
+ try {
+ await message.exportConfirm()
+ inspectionExportLoading.value = true
+ const params: any = { deviceId: selectedDetailId.value }
+ if (inspectionDateRange.value && inspectionDateRange.value.length === 2) {
+ params.startTime = inspectionDateRange.value[0]
+ params.endTime = inspectionDateRange.value[1]
+ }
+ const data = await TicketManagementApi.exportInspection(params)
+ download.excel(data, '点检履历.xls')
+ } catch {
+ } finally {
+ inspectionExportLoading.value = false
+ }
+}
+
+const handleExportMaintain = async () => {
+ if (!selectedDetailId.value) {
+ message.error('请先选择设备')
+ return
+ }
+ try {
+ await message.exportConfirm()
+ maintainExportLoading.value = true
+ const params: any = { deviceId: selectedDetailId.value }
+ if (maintainDateRange.value && maintainDateRange.value.length === 2) {
+ params.startTime = maintainDateRange.value[0]
+ params.endTime = maintainDateRange.value[1]
+ }
+ const data = await TicketManagementApi.exportMaintenance(params)
+ download.excel(data, '保养履历.xls')
+ } catch {
+ } finally {
+ maintainExportLoading.value = false
+ }
+}
+
+const handleExportRepair = async () => {
+ if (!selectedDetailId.value) {
+ message.error('请先选择设备')
+ return
+ }
+ try {
+ await message.exportConfirm()
+ repairExportLoading.value = true
+ const params: any = { deviceId: selectedDetailId.value }
+ if (repairDateRange.value && repairDateRange.value.length === 2) {
+ params.startTime = repairDateRange.value[0]
+ params.endTime = repairDateRange.value[1]
+ }
+ const data = await DvRepairApi.exportRepairExcel(params)
+ download.excel(data, '维修履历.xls')
+ } catch {
+ } finally {
+ repairExportLoading.value = false
+ }
+}
+
/** 初始化 **/
onMounted(async () => {
await dictStore.setDictMap()