From e5454b769d44a34af423bf87ac8a740bf8c20341 Mon Sep 17 00:00:00 2001
From: Crunchy <3114200645@qq.com>
Date: 星期二, 29 四月 2025 13:25:29 +0800
Subject: [PATCH] Merge branch 'dev' into dev_tides

---
 src/views/CNAS/resourceDemand/device/component/addYearPlanDia.vue |   32 ++++++++++++++++++++++++++++----
 1 files changed, 28 insertions(+), 4 deletions(-)

diff --git a/src/views/CNAS/resourceDemand/device/component/addYearPlanDia.vue b/src/views/CNAS/resourceDemand/device/component/addYearPlanDia.vue
index 3b8db3d..d750d8e 100644
--- a/src/views/CNAS/resourceDemand/device/component/addYearPlanDia.vue
+++ b/src/views/CNAS/resourceDemand/device/component/addYearPlanDia.vue
@@ -12,7 +12,8 @@
         </el-date-picker>
       </div>
       <div style="margin: 10px 0">
-        <el-table id="templateParamTable" ref="yearTable" :data="calibrationPlanDetailList" height="300px"
+        <el-table id="templateParamTable" ref="yearTable" :data="calibrationPlanDetailList" height="560px"
+                  v-loading="yearTableLoading"
                   :header-cell-style="{ background: '#f8f8f9', color: '#515a6e' }" border
           row-key="deviceId" style="width: 100% ;">
           <el-table-column label="璁惧鍚嶇О鍙婂瀷鍙�" min-width="190" prop="deviceName">
@@ -115,7 +116,8 @@
         planId: '',
         calibrationPlanDetailList: [],
       },
-      operationType: ''
+      operationType: '',
+      yearTableLoading: false
     }
   },
   mounted() {
@@ -129,21 +131,26 @@
         this.form = {
           planName: '',
           planYear: '',
-          examinePlanDetailsList: [],
+          calibrationPlanDetailList: [],
         }
+        this.calibrationPlanDetailList = []
       } else {
         this.getRowInfo(row)
       }
       this.applicationForm = true
     },
     getRowInfo(row) {
+      this.yearTableLoading = true
       getDeviceCalibrationPlan({ planId: row.planId }).then(res => {
+        this.yearTableLoading = false
         if (res.code == 200) {
           this.calibrationPlanDetailList = res.data.calibrationPlanDetailList
           this.form.planName = res.data.planName
           this.form.planYear = res.data.planYear
           this.form.planId = res.data.planId
         }
+      }).catch(err => {
+        this.yearTableLoading = false
       })
     },
     // 娣诲姞璁惧
@@ -156,9 +163,19 @@
     },
     changeMachineName() {
       this.selectionRows.map(val => {
+        // 灏� val.nextCalibrationDate 杞崲涓� Date 瀵硅薄骞跺噺鍘� 5 澶�
+        let nextCalibrationDate = val.nextCalibrationDate ? new Date(val.nextCalibrationDate) : null;
+        if (nextCalibrationDate) {
+          nextCalibrationDate.setDate(nextCalibrationDate.getDate() - 5); // 鍑忓幓 5 澶�
+        }
         this.calibrationPlanDetailList.push({
           deviceId: val.id, deviceName: val.label, deviceNumber: val.value,
-          specificationModel: val.specificationModel, verificationCycles: val.calibrationDate, lastDate: val.lastCalibrationDate.substring(0, 10), planDate: val.nextCalibrationDate.substring(0, 10)
+          specificationModel: val.specificationModel,
+          verificationCycles: val.calibrationDate,
+          lastDate: val.lastCalibrationDate && val.lastCalibrationDate.substring(0, 10),
+          planDate: nextCalibrationDate ? formatDate(nextCalibrationDate) : null,
+          verificationUnit: val.calibrationServices,
+          deviceAmount: 1
         })
       })
       this.addEquipDia = false
@@ -238,6 +255,13 @@
     },
   },
 }
+// 鏍煎紡鍖栨棩鏈熶负 YYYY-MM-DD 鏍煎紡
+function formatDate(date) {
+  const year = date.getFullYear();
+  const month = String(date.getMonth() + 1).padStart(2, '0'); // 鏈堜唤浠�0寮�濮嬶紝闇�瑕�+1
+  const day = String(date.getDate()).padStart(2, '0');
+  return `${year}-${month}-${day}`;
+}
 </script>
 
 <style scoped></style>

--
Gitblit v1.9.3