From c34fe6f588045e527bccfd4c67b9764b2a141ea2 Mon Sep 17 00:00:00 2001
From: chenrui <1187576398@qq.com>
Date: 星期三, 26 二月 2025 15:24:41 +0800
Subject: [PATCH] 设施和环境条件代码迁移

---
 src/views/CNAS/resourceDemand/facilitiesEnvironment/component/facilities-environmental-conditions/temperature-humidity-record.vue |  100 +++++++++++++++++++++-----------------------------
 1 files changed, 42 insertions(+), 58 deletions(-)

diff --git a/src/views/CNAS/resourceDemand/facilitiesEnvironment/component/facilities-environmental-conditions/temperature-humidity-record.vue b/src/views/CNAS/resourceDemand/facilitiesEnvironment/component/facilities-environmental-conditions/temperature-humidity-record.vue
index f848a42..2dbe82a 100644
--- a/src/views/CNAS/resourceDemand/facilitiesEnvironment/component/facilities-environmental-conditions/temperature-humidity-record.vue
+++ b/src/views/CNAS/resourceDemand/facilitiesEnvironment/component/facilities-environmental-conditions/temperature-humidity-record.vue
@@ -236,6 +236,18 @@
 </template>
 
 <script>
+import {
+  getFeTempHumDate,
+  addFeTempHumDate,
+  getFeTempHumRecordPage,
+  addFeTempHumRecord,
+  selectUserCondition,
+  deleteFeTempHumRecord,
+  deleteFeTempHumDate,
+  exportTemperatureAndHumidityRecords,
+  affirmFeTempHumDate
+} from '@/api/cnas/resourceDemand/facilitiesEnvironment/facilitiesAndEnvironment'
+
 export default {
   data() {
     return {
@@ -293,12 +305,7 @@
         dateId: this.approvalRow.dateId,
         subjoin: this.subjoin,
       }
-      this.$axios.post(this.$api.facilitiesAndEnvironment.affirmFeTempHumDate, params, {
-        headers: {
-          'Content-Type': 'application/json'
-        },
-        noQs: true
-      }).then(res => {
+      affirmFeTempHumDate(params).then(res => {
         this.approvalLoading = false
         if (res.code === 200) {
           this.$message.success('纭鎴愬姛锛�')
@@ -310,7 +317,7 @@
       })
     },
     openDialog() {
-      this.$axios.get(this.$api.deviceScope.selectUserList).then(res => {
+      selectUserCondition().then(res => {
         if (res.code == 200) {
           this.responsibleOptions = res.data
         }
@@ -320,11 +327,7 @@
       this.$refs.form.validate((valid) => {
         if (valid) {
           this.submitLoading = true
-          this.$axios.post(this.$api.facilitiesAndEnvironment.addFeTempHumDate, this.form, {
-            headers: {
-              'Content-Type': 'application/json'
-            }
-          }).then(res => {
+          addFeTempHumDate(this.form).then(res => {
             if (res.code === 200) {
               this.$message.success('鏂板鎴愬姛!')
               this.submitLoading = false
@@ -346,11 +349,7 @@
         this.submitLoading = true
         if (valid) {
           this.form1.dateId = this.saveRow.dateId
-          this.$axios.post(this.$api.facilitiesAndEnvironment.addFeTempHumRecord, this.form1, {
-            headers: {
-              'Content-Type': 'application/json'
-            }
-          }).then(res => {
+          addFeTempHumRecord(this.form1).then(res => {
             if (res.code === 200) {
               this.$message.success('鏂板鎴愬姛!')
               this.submitLoading = false
@@ -377,7 +376,7 @@
         cancelButtonText: '鍙栨秷',
         type: 'warning'
       }).then(() => {
-        this.$axios.delete(this.$api.facilitiesAndEnvironment.deleteFeTempHumDate + '?dateId=' + row.dateId).then(res => {
+        deleteFeTempHumDate({dateId:row.dateId}).then(res => {
           this.$message.success('鍒犻櫎鎴愬姛锛�')
           this.initData()
         })
@@ -389,35 +388,11 @@
     },
     // 瀵煎嚭
     downLoadPost(row) {
-      this.$axios.get(this.$api.facilitiesAndEnvironment.exportTemperatureAndHumidityRecords + '?dateId=' + row.dateId,{responseType: "blob"}).then(res => {
+      exportTemperatureAndHumidityRecords({dateId:row.dateId}).then(res => {
         this.outLoading = false
         const blob = new Blob([res],{ type: 'application/msword' });
-        //灏咮lob 瀵硅薄杞崲鎴愬瓧绗︿覆
-        let reader = new FileReader();
-        reader.readAsText(blob, 'utf-8');
-        reader.onload = () => {
-          try {
-            let result = JSON.parse(reader.result);
-            if (result.message) {
-              this.$message.error(result.message);
-            } else {
-              const url = URL.createObjectURL(blob);
-              const link = document.createElement('a');
-              link.href = url;
-              link.download = '娓╂箍搴﹁褰�' + '.docx';
-              link.click();
-              this.$message.success('瀵煎嚭鎴愬姛')
-            }
-          } catch (err) {
-            console.log(err);
-            const url = URL.createObjectURL(blob);
-            const link = document.createElement('a');
-            link.href = url;
-            link.download = '娓╂箍搴﹁褰�' + '.docx';
-            link.click();
-            this.$message.success('瀵煎嚭鎴愬姛')
-          }
-        }
+        this.$download.saveAs(blob, '娓╂箍搴﹁褰�.docx')
+        this.$message.success('瀵煎嚭鎴愬姛')
       })
     },
     deleteRowFun1(row) {
@@ -426,28 +401,37 @@
         cancelButtonText: '鍙栨秷',
         type: 'warning'
       }).then(() => {
-        this.$axios.delete(this.$api.facilitiesAndEnvironment.deleteFeTempHumRecord + '?tempHumId=' + row.tempHumId).then(res => {
+        deleteFeTempHumRecord({tempHumId:row.tempHumId}).then(res => {
           this.$message.success('鍒犻櫎鎴愬姛锛�')
           this.initData1(this.saveRow.dateId)
         })
       })
     },
     initData() {
-      this.$axios.get(this.$api.facilitiesAndEnvironment.getFeTempHumDate + '?size=' + this.search.size + '&current=' + this.search.current + '&testAreaName=' + this.search.testAreaName).then(res => {
-        if (res.code === 201) return;
-        this.tableData = res.data.records;
-        this.search.total = res.data.total;
-        if (res.data.records.length === 0) {
-          this.tableData1 = []
-          this.saveRow.monthDate = ''
+      getFeTempHumDate({
+        ...this.search,
+        ...this.search}).then(res => {
+        if (res.code === 200){
+          this.tableData = res.data.records;
+          this.search.total = res.data.total;
+          if (res.data.records.length === 0) {
+            this.tableData1 = []
+            this.saveRow.monthDate = ''
+          }
         }
-      });
+
+      })
     },
     initData1(dateId) {
-      this.$axios.get(this.$api.facilitiesAndEnvironment.getFeTempHumRecordPage + '?size=' + this.search1.size + '&current=' + this.search1.current + '&dateId=' + dateId).then(res => {
-        if (res.code === 201) return;
-        this.tableData1 = res.data.records;
-        this.search1.total = res.data.total;
+      let form = {dateId: dateId}
+      getFeTempHumRecordPage({
+        ...this.search1,
+        ...form
+      }).then(res => {
+        if (res.code === 200){
+          this.tableData1 = res.data.records;
+          this.search1.total = res.data.total;
+        }
       });
     },
     handleSizeChange(val) {

--
Gitblit v1.9.3