From ce46ecdf35bd9496d7ad86d39c9bd654979213c0 Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期三, 12 三月 2025 16:38:56 +0800
Subject: [PATCH] 设备搬迁-设备故障联调

---
 src/views/CNAS/resourceDemand/device/component/check.vue |  145 +++++++++++++++++++++++++++++-------------------
 1 files changed, 87 insertions(+), 58 deletions(-)

diff --git a/src/views/CNAS/resourceDemand/device/component/check.vue b/src/views/CNAS/resourceDemand/device/component/check.vue
index 5dfe6b9..2097352 100644
--- a/src/views/CNAS/resourceDemand/device/component/check.vue
+++ b/src/views/CNAS/resourceDemand/device/component/check.vue
@@ -4,7 +4,7 @@
     <div class="btns">
       <el-button size="small" type="primary" @click="calibrationMaintenance()">鏍告煡椤圭洰缁存姢</el-button>
       <el-button size="small" type="primary" @click="add('add')">娣诲姞鏍告煡璁板綍</el-button>
-      <el-button size="small" type="primary">瀵煎嚭Excel</el-button>
+      <el-button size="small" type="primary" @click="downLoadPost">瀵煎嚭Excel</el-button>
     </div>
     <div class="tables" style="margin-top: 16px;">
       <el-table :data="tableData" height="calc(100vh - 20em)">
@@ -42,14 +42,15 @@
     </div>
 
     <!-- 鏍″噯椤圭洰缁存姢 -->
-    <el-dialog :close-on-click-modal="false" :close-on-press-escape="false" :visible.sync="dialogVisible0"
-      title="鏍告煡椤圭洰缁存姢" top="5vh" width="70%">
+    <el-dialog :close-on-click-modal="false" :close-on-press-escape="false" :visible.sync="dialogVisible0" title="鏍告煡椤圭洰缁存姢"
+               top="5vh" width="70%">
       <h4>
         <span style="display: flex;align-items: center;"><span class="line"></span><span>璁惧鏍告煡鍙傛暟缁存姢</span></span>
         <el-button :loading="addCalibrateLoading" size="small" type="primary" @click="addCalibrate">娣� 鍔�</el-button>
       </h4>
       <div>
-        <el-form ref="form0" :model="form0" :rules="form0Rules" label-position="right" label-width="120px">
+        <el-form ref="form0" :model="form0" :rules="form0Rules"
+                 label-position="right" label-width="120px">
           <el-row>
             <el-col :span="12">
               <el-form-item label="鏍告煡鍙傛暟:" prop="measurementParameter">
@@ -78,8 +79,9 @@
         <span style="display: flex;align-items: center;"><span class="line"></span><span>璁惧鏍告煡鍙傛暟</span></span>
       </h4>
       <!-- 璁惧鏍″噯鍙傛暟琛ㄦ牸 -->
-      <el-table ref="calibrateTable" v-loading="calibrateParamsLoading" :data="calibrateParams" max-height="450" stripe
-        style="width: 100%">
+      <el-table ref="calibrateTable" v-loading="calibrateParamsLoading" :data="calibrateParams"
+                max-height="450"
+                stripe style="width: 100%">
         <el-table-column label="缂栧彿" type="index" width="80"></el-table-column>
         <el-table-column label="鏍告煡鍙傛暟" prop="measurementParameter"></el-table-column>
         <el-table-column label="鏍告煡鑼冨洿" prop="rangeOfMeasurement"></el-table-column>
@@ -96,68 +98,71 @@
     </el-dialog>
 
     <!-- 娣诲姞鏍告煡璁板綍 -->
-    <el-dialog :close-on-click-modal="false" :close-on-press-escape="false" :visible.sync="dialogVisible1"
-      title="娣诲姞鏍告煡璁板綍" top="5vh" width="80%" @close="resetcalibrationRecord">
+    <el-dialog :close-on-click-modal="false" :close-on-press-escape="false" :visible.sync="dialogVisible1" title="鏍告煡璁板綍" :before-close="handleClose"
+               top="5vh"
+               width="80%" @close="resetcalibrationRecord">
       <div class="dialog-content">
         <h4>
           <span style="display: flex;align-items: center;">
-            <span class="line"></span>
+           <span class="line"></span>
             <span>娣诲姞璁惧鏍告煡璁板綍</span>
           </span>
         </h4>
-        <el-form ref="calibrationRecord" :model="calibrationRecord" :rules="formRules" label-position="right"
-          label-width="120px">
+        <el-form ref="calibrationRecord" :model="calibrationRecord" :rules="formRules"
+                 label-position="right" label-width="120px">
           <el-row>
             <el-col :span="6">
               <el-form-item label="鏍告煡浜�:" prop="unitOfMeasure">
                 <el-input v-model="calibrationRecord.unitOfMeasure" :disabled="operationType === 'view'"
-                  size="small"></el-input>
+                          size="small"></el-input>
               </el-form-item>
             </el-col>
             <el-col :span="8">
               <el-form-item label="鏍告煡鏃ユ湡:" prop="calibrationDate">
-                <el-date-picker v-model="calibrationRecord.calibrationDate" :disabled="operationType === 'view'"
-                  format="yyyy-MM-dd" placeholder="閫夋嫨鏃ユ湡" size="small" style="width: 90%" type="date"
-                  value-format="yyyy-MM-dd">
+                <el-date-picker v-model="calibrationRecord.calibrationDate" :disabled="operationType === 'view'" format="yyyy-MM-dd" placeholder="閫夋嫨鏃ユ湡"
+                                size="small"
+                                style="width: 90%" type="date" value-format="yyyy-MM-dd">
                 </el-date-picker>
               </el-form-item>
             </el-col>
             <el-col :span="10">
               <el-form-item label="涓嬫鏍告煡鏃ユ湡:" label-width="140px" prop="nextCalibrationDate">
-                <el-date-picker v-model="calibrationRecord.nextCalibrationDate" :disabled="operationType === 'view'"
-                  :picker-options="{ disabledDate: this.disabledDate }" format="yyyy-MM-dd" placeholder="閫夋嫨鏃ユ湡"
-                  size="small" style="width: 90%" type="date" value-format="yyyy-MM-dd">
+                <el-date-picker v-model="calibrationRecord.nextCalibrationDate" :disabled="operationType === 'view'" :picker-options="{ disabledDate: this.disabledDate }"
+                                format="yyyy-MM-dd"
+                                placeholder="閫夋嫨鏃ユ湡"
+                                size="small" style="width: 90%" type="date"
+                                value-format="yyyy-MM-dd">
                 </el-date-picker>
               </el-form-item>
             </el-col>
             <el-col :span="6">
               <el-form-item label="鏍告煡鍣ㄥ叿:" prop="calculatingApparatus">
                 <el-input v-model="calibrationRecord.calculatingApparatus" :disabled="operationType === 'view'"
-                  size="small"></el-input>
+                          size="small"></el-input>
               </el-form-item>
             </el-col>
             <el-col :span="8">
               <el-form-item label="鏍告煡鏍囧噯閲忕▼:" prop="standardRange">
                 <el-input v-model="calibrationRecord.standardRange" :disabled="operationType === 'view'" size="small"
-                  style="width: 90%"></el-input>
+                          style="width: 90%"></el-input>
               </el-form-item>
             </el-col>
             <el-col :span="10">
               <el-form-item label="鏍告煡鏍囧噯涓嶇‘瀹氬害:" label-width="140px" prop="calibrationStandardUncertainty">
-                <el-input v-model="calibrationRecord.calibrationStandardUncertainty"
-                  :disabled="operationType === 'view'" size="small" style="width: 90%"></el-input>
+                <el-input v-model="calibrationRecord.calibrationStandardUncertainty" :disabled="operationType === 'view'" size="small"
+                          style="width: 90%"></el-input>
               </el-form-item>
             </el-col>
             <el-col :span="6">
               <el-form-item label="鏍告煡鎸囧涔�:" prop="byDocument">
                 <el-input v-model="calibrationRecord.byDocument" :disabled="operationType === 'view'"
-                  size="small"></el-input>
+                          size="small"></el-input>
               </el-form-item>
             </el-col>
             <el-col :span="8">
               <el-form-item label="妫�鏌ユ姤鍛婄紪鍙�:" prop="certificateSerialNumber">
-                <el-input v-model="calibrationRecord.certificateSerialNumber" :disabled="operationType === 'view'"
-                  size="small" style="width: 90%"></el-input>
+                <el-input v-model="calibrationRecord.certificateSerialNumber" :disabled="operationType === 'view'" size="small"
+                          style="width: 90%"></el-input>
               </el-form-item>
             </el-col>
             <el-col :span="8">
@@ -171,16 +176,17 @@
             </el-col>
             <el-col :span="23">
               <el-form-item label="闄勪欢锛�" prop="fileName">
-                <el-input v-model="calibrationRecord.fileName"
-                  :style="`width: ${operationType === 'add' ? '90%' : '100%'};}`" disabled size="small">
+                <el-input v-model="calibrationRecord.fileName" :style="`width: ${operationType === 'add' ? '90%' : '100%'};}`" disabled
+                          size="small">
                   <el-button v-if="operationType === 'add'" slot="append" icon="el-icon-delete-solid"
-                    @click="deleteFile"></el-button>
+                             @click="deleteFile"></el-button>
                 </el-input>
-                <el-upload v-if="operationType === 'add'" ref="upload" :action="action" :before-upload="beforeUpload"
-                  :headers="uploadHeader" :limit="1" :on-error="onError" :on-success="handleSuccessUp"
-                  :show-file-list="false" style="float: right;">
+                <el-upload v-if="operationType === 'add'" ref="upload" :action="action" :before-upload="beforeUpload" :headers="uploadHeader"
+                           :limit="1" :on-error="onError" :on-success="handleSuccessUp"
+                           :show-file-list="false"
+                           style="float: right;">
                   <el-button :loading="upLoading" size="small" style="position: relative; top: -4px;"
-                    type="primary">闄勪欢涓婁紶
+                             type="primary">闄勪欢涓婁紶
                   </el-button>
                 </el-upload>
               </el-form-item>
@@ -188,7 +194,7 @@
             <el-col :span="24">
               <el-form-item label="澶囨敞:">
                 <el-input v-model="calibrationRecord.remark" :disabled="operationType === 'view'" :rows="3" size="small"
-                  style="width: 96%" type="textarea"></el-input>
+                          style="width: 96%" type="textarea"></el-input>
               </el-form-item>
             </el-col>
           </el-row>
@@ -229,13 +235,12 @@
           </el-table-column>
           <el-table-column label="鍗曢」缁撴灉璇存槑" prop="singleResultStatement">
             <template slot-scope="scope">
-              <el-input v-model="scope.row.singleResultStatement" :disabled="operationType === 'view'"
-                size="small"></el-input>
+              <el-input v-model="scope.row.singleResultStatement" :disabled="operationType === 'view'" size="small"></el-input>
             </template>
           </el-table-column>
         </el-table>
         <span slot="footer" class="dialog-footer" style="float: right;margin-top: 10px">
-          <el-button v-if="operationType === 'add'" @click="dialogVisible1 = false">鍙� 娑�</el-button>
+          <el-button v-if="operationType === 'add'" @click="handleClose">鍙� 娑�</el-button>
           <el-button v-if="operationType === 'add'" type="primary" @click="addRecord">纭� 瀹�</el-button>
         </span>
       </div>
@@ -247,6 +252,13 @@
 <script>
 import file from '@/utils/file';
 import { mapGetters } from "vuex";
+import {
+  addOrUpdateDeviceMetricRecord, deleteCNASFile, deleteDeviceMetricRecord, deleteDeviceMetrics,
+  deviceMetricRecordExport,
+  deviceMetricRecordPage,
+  saveOrUpdateDeviceMetric,
+  selectDeviceMetric, showDeviceMetricsCopy
+} from "@/api/cnas/resourceDemand/device";
 export default {
   components: {},
   props: {
@@ -330,7 +342,7 @@
   computed: {
     ...mapGetters(["nickName"]),
     action() {
-      return this.javaApi + this.$api.personnel.saveCNASFile
+      return this.javaApi + '/personBasicInfo/saveCNASFile'
     }
   },
   mounted() {
@@ -369,7 +381,7 @@
     async getXmsg() {
       this.calibrateParamsLoading = true
       try {
-        await this.$axios.get(this.$api.deviceCheck.selectDeviceMetric + "?deviceId=" + this.clickNodeVal.value + "&type=examine").then(res => {
+        await selectDeviceMetric({deviceId: this.clickNodeVal.value, type: 'examine'}).then(res => {
           if (res.code == 200) {
             this.calibrateParams = res.data
           }
@@ -393,11 +405,7 @@
           this.form0.deviceId = this.clickNodeVal.value;
           this.form0.createdBy = this.nickName;
           this.form0.type = 'examine'
-          this.$axios.post(this.$api.deviceCheck.saveOrUpdateDeviceMetric, this.form0, {
-            headers: {
-              'Content-Type': 'application/json'
-            }
-          }).then(res => {
+          saveOrUpdateDeviceMetric(this.form0).then(res => {
             if (res.code == 200) {
               this.$message.success('淇濆瓨鎴愬姛')
               this.$refs['form0'].resetFields()
@@ -414,7 +422,7 @@
     },
     // 鏌ヨ璁惧鏍告煡鍒楄〃
     getTableList(deviceId) {
-      this.$axios.get(this.$api.deviceCheck.deviceMetricRecordPage + '?deviceId=' + deviceId + "&size=" + this.search.size + "&current=" + this.search.current + "&type=examine").then(res => {
+      deviceMetricRecordPage({deviceId: deviceId, size: this.search.size, current: this.search.current, type: 'examine'}).then(res => {
         this.tableData = res.data.records
         this.search.total = res.data.total
       })
@@ -436,12 +444,11 @@
             this.calibrationRecord.deviceId = this.clickNodeVal.value;
             this.calibrationRecord.createUser = this.nickName
             this.calibrationRecord.deviceMetricsCopyList = this.calibrateParams
+            this.calibrationRecord.deviceMetricsCopyList.forEach(ele => {
+              delete ele.creationTime
+            })
             this.calibrationRecord.type = 'examine'
-            this.$axios.post(this.$api.deviceCheck.addOrUpdateDeviceMetricRecord, this.calibrationRecord, {
-              headers: {
-                'Content-Type': 'application/json'
-              }
-            }).then(res => {
+            addOrUpdateDeviceMetricRecord(this.calibrationRecord).then(res => {
               if (res.code == 200) {
                 this.$message.success('娣诲姞鎴愬姛')
                 this.dialogVisible1 = false
@@ -457,6 +464,22 @@
           this.$message.warning('鏈夊繀濉」鏈~');
         }
       })
+    },
+    handleClose(done) {
+      this. calibrationRecord = {
+        unitOfMeasure: '', // 鏍告煡浜�
+        calibrationDate: '', // 鏍告煡鏃ユ湡
+        nextCalibrationDate: '', // 涓嬫鏍告煡鏃ユ湡
+        calculatingApparatus: '', // 鏍告煡鍣ㄥ叿
+        standardRange: '', // 鏍告煡鏍囧噯閲忕▼
+        calibrationStandardUncertainty: '', // 鏍告煡鏍囧噯涓嶇‘瀹氬害
+        byDocument: '', // 鏍告煡鎸囧涔�
+        certificateSerialNumber: '', // 妫�鏌ユ姤鍛婃寚瀵间功
+        fileName: '', // 闄勪欢
+        status: '', // 鏍告煡鎬荤粨璁�
+        remark: '', // 澶囨敞
+      }
+      this.dialogVisible1 = false
     },
     resetcalibrationRecord() {
       this.$refs.calibrationRecord.resetFields()
@@ -492,7 +515,7 @@
         cancelButtonText: '鍙栨秷',
         type: 'warning'
       }).then(() => {
-        this.$axios.delete(this.$api.personnel.deleteCNASFile + "?fileName=" + this.form.systemFileName).then(res => {
+        deleteCNASFile({fileName: this.form.systemFileName}).then(res => {
           if (res.code == 200) {
             this.$message.success('鍒犻櫎鎴愬姛锛�')
           }
@@ -506,10 +529,7 @@
     },
     // end
     handleAttachmentClick(row) {
-      // 妯℃嫙涓嬭浇闄勪欢
-      const imageUrl = this.javaApi + '/img/' + row.systemFileName; // 鍥剧墖 URL
-      file.downloadIamge(imageUrl, row.fileName)
-      // downloadImage(imageUrl, row.fileName);
+      this.$download.saveAs(row.systemFileName, row.fileName)
     },
     // 娣诲姞鏍告煡璁板綍
     add(type) {
@@ -519,7 +539,7 @@
     },
     // 鏌ョ湅璇︽儏
     handleViewClick(type, row) {
-      this.$axios.get(this.$api.deviceCheck.showDeviceMetricsCopy + "?id=" + row.id + "&type=examine").then(res => {
+      showDeviceMetricsCopy({id: row.id, type: 'examine'}).then(res => {
         this.calibrateParams = res.data
       })
       this.calibrationRecord = { ...row }
@@ -534,7 +554,7 @@
         cancelButtonText: '鍙栨秷',
         type: 'warning'
       }).then(() => {
-        this.$axios.delete(this.$api.deviceCheck.deleteDeviceMetricRecord + "?id=" + row.id).then(res => {
+        deleteDeviceMetricRecord({id: row.id}).then(res => {
           this.getTableList(this.clickNodeVal.value) // 鑾峰彇璁惧鏍″噯鍒楄〃鏁版嵁
           this.$message.success('鍒犻櫎鎴愬姛锛�')
         })
@@ -551,7 +571,7 @@
         cancelButtonText: '鍙栨秷',
         type: 'warning'
       }).then(() => {
-        this.$axios.delete(this.$api.deviceCheck.deleteDeviceMetrics + "?id=" + row.id).then(res => {
+        deleteDeviceMetrics({id: row.id}).then(res => {
           this.getXmsg();
           this.$message.success('鍒犻櫎鎴愬姛锛�')
         })
@@ -561,7 +581,15 @@
           message: '宸插彇娑堝垹闄�'
         });
       })
-    }
+    },
+    downLoadPost() {
+      this.outLoading = true
+      deviceMetricRecordExport({deviceId: this.clickNodeVal.value}).then(res => {
+        this.outLoading = false
+        const blob = new Blob([res],{ type: 'application/msword' });
+        this.$download.saveAs(blob, '璁惧鏍告煡.xlsx')
+      })
+    },
   },
   watch: {
     // 鐩戝惉鐐瑰嚮el-tree鐨勬暟鎹紝杩涜鏁版嵁鍒锋柊
@@ -622,6 +650,7 @@
 
 .btns {
   text-align: right;
+  margin-top: 10px;
 }
 
 h4 {

--
Gitblit v1.9.3