From 0073d3581d6bb05f8538dd3b3c2498cb0635258b Mon Sep 17 00:00:00 2001 From: huangjinysf Date: Sun, 21 Dec 2025 15:31:33 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=AE=BE=E5=A4=87=E7=BB=B4?= =?UTF-8?q?=E4=BF=AE=E8=AE=B0=E5=BD=95=E6=9F=A5=E7=9C=8B=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=EF=BC=8C=E6=94=AF=E6=8C=81=E7=82=B9=E5=87=BB=E8=AE=BE=E5=A4=87?= =?UTF-8?q?=E7=BC=96=E5=8F=B7=E6=9F=A5=E7=9C=8B=E8=AF=A6=E7=BB=86=E7=BB=B4?= =?UTF-8?q?=E4=BF=AE=E8=AE=B0=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/eq/RepairSummary.vue | 173 ++++++++++++++++++++++++++++++++- 1 file changed, 172 insertions(+), 1 deletion(-) diff --git a/src/views/eq/RepairSummary.vue b/src/views/eq/RepairSummary.vue index 086aa50..85dc7d2 100644 --- a/src/views/eq/RepairSummary.vue +++ b/src/views/eq/RepairSummary.vue @@ -20,7 +20,13 @@ stripe style="width: 100%" > - + + + @@ -36,6 +42,56 @@ + + + +
+
+ + + + + + + + + + + + + + + +
+
+ 暂无维修记录 +
+
+ +
@@ -61,6 +117,12 @@ const props = defineProps({ const loading = ref(false) const repairSummaryList = ref([]) +// 维修记录对话框相关状态 +const repairRecordsDialogVisible = ref(false) +const repairRecordsLoading = ref(false) +const selectedRepairRecords = ref([]) +const selectedEquipmentCode = ref('') + // 监听设备类型变化 watch(() => props.selectedEquipmentType, (newVal, oldVal) => { console.log('设备类型从', oldVal, '变化为', newVal); @@ -121,6 +183,87 @@ function handleSummary() { loading.value = false }) } + +// 显示设备维修记录 +const showRepairRecords = (equipmentCode) => { + selectedEquipmentCode.value = equipmentCode + repairRecordsDialogVisible.value = true + fetchRepairRecords(equipmentCode) +} + +// 获取设备维修记录 +const fetchRepairRecords = (equipmentCode) => { + repairRecordsLoading.value = true + + // 构建API URL + let apiUrl = `${API_CONFIG.BASE_URL}/api/eq-repair/repair-records/${equipmentCode}`; + + fetch(apiUrl) + .then(response => response.json()) + .then(data => { + if (data.code === 200 && data.data) { + selectedRepairRecords.value = data.data + } else { + selectedRepairRecords.value = [] + } + }) + .catch(error => { + console.error('维修记录API调用失败:', error) + selectedRepairRecords.value = [] + }) + .finally(() => { + repairRecordsLoading.value = false + }) +} + +// 关闭维修记录对话框 +const handleRepairRecordsClose = () => { + repairRecordsDialogVisible.value = false +} + +// 检查维修日期是否是最近的(30天内) +const isRecent = (repairDate) => { + if (!repairDate) return false + + try { + const repairDateObj = new Date(repairDate) + const currentDate = new Date() + const timeDiff = currentDate - repairDateObj + const daysDiff = Math.ceil(timeDiff / (1000 * 3600 * 24)) + + return daysDiff <= 30 + } catch (e) { + return false + } +} + +// 计算维修时长 +const calculateRepairDuration = (applyTime, repairTime) => { + if (!applyTime || !repairTime) return '无' + + try { + const applyDate = new Date(applyTime) + const repairDate = new Date(repairTime) + const timeDiff = repairDate - applyDate + + if (timeDiff < 0) return '无效时间' + + const hours = Math.floor(timeDiff / (1000 * 60 * 60)) + const minutes = Math.floor((timeDiff % (1000 * 60 * 60)) / (1000 * 60)) + + if (hours > 24) { + const days = Math.floor(hours / 24) + const remainingHours = hours % 24 + return `${days}天${remainingHours}小时` + } else if (hours > 0) { + return `${hours}小时${minutes}分钟` + } else { + return `${minutes}分钟` + } + } catch (e) { + return '计算错误' + } +} \ No newline at end of file