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/equipmentMaintenance.vue |  297 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 297 insertions(+), 0 deletions(-)

diff --git a/src/views/CNAS/resourceDemand/device/component/equipmentMaintenance.vue b/src/views/CNAS/resourceDemand/device/component/equipmentMaintenance.vue
new file mode 100644
index 0000000..add36e0
--- /dev/null
+++ b/src/views/CNAS/resourceDemand/device/component/equipmentMaintenance.vue
@@ -0,0 +1,297 @@
+<template>
+  <div>
+    <div class="search">
+      <el-button size="small" type="primary" @click="refreshTableList">鍒锋柊</el-button>
+      <el-button size="small" type="primary" @click="openDia('add')">鏂� 寤�</el-button>
+      <el-button :loading="outLoading" size="small" type="primary" @click="openHandleOut">瀵� 鍑�</el-button>
+    </div>
+    <div>
+      <lims-table :tableData="tableData" :column="column"
+                  height="calc(100vh - 20em)" @pagination="pagination"
+                  :page="page" :tableLoading="tableLoading"></lims-table>
+    </div>
+    <el-dialog :visible.sync="dialogVisible" title="浠櫒璁惧浣跨敤缁存姢淇濆吇琛�" width="55%">
+      <el-form ref="form" :model="form" label-width="130px" :rules="rules">
+        <el-row>
+          <el-col :span="12">
+            <el-form-item label="缁存姢鏃ユ湡:" prop="maintenanceDate">
+              <el-date-picker v-model="form.maintenanceDate" :disabled="operationType === 'view'"
+                              format="yyyy-MM-dd" size="small" placeholder="閫夋嫨鏃ユ湡" style="width:100%"
+                              type="date" value-format="yyyy-MM-dd">
+              </el-date-picker>
+            </el-form-item>
+          </el-col>
+        </el-row>
+        <el-row>
+          <el-col :span="24">
+            <el-form-item label="缁存姢鍐呭:" prop="maintenanceContentArr">
+              <el-checkbox-group v-model="form.maintenanceContentArr" :disabled="operationType === 'view'">
+                <el-checkbox v-for="city in qualificationList" :key="city.label" :label="city.label"
+                             :value="city.label"></el-checkbox>
+              </el-checkbox-group>
+            </el-form-item>
+          </el-col>
+        </el-row>
+        <el-row>
+          <el-col :span="12">
+            <el-form-item label="缁存姢浜�:" prop="maintenanceUserId">
+              <el-select v-model="form.maintenanceUserId"
+                         clearable filterable
+                         placeholder="璇烽�夋嫨" size="small" style="width: 100%;">
+                <el-option v-for="item in responsibleOptions" :key="item.id" :label="item.name" :value="item.id">
+                </el-option>
+              </el-select>
+            </el-form-item>
+          </el-col>
+          <el-col :span="12">
+            <el-form-item label="澶囨敞:" prop="remark">
+              <el-input v-model="form.remark" :disabled="operationType === 'view'" size="small"
+                        style="width: 100%;"></el-input>
+            </el-form-item>
+          </el-col>
+        </el-row>
+      </el-form>
+      <span slot="footer" class="dialog-footer">
+        <el-button @click="closeDia">鍙� 娑�</el-button>
+        <el-button v-if="operationType !== 'view'" type="primary" @click="saveRecord" :loading="buttonLoading">纭� 瀹�</el-button>
+      </span>
+    </el-dialog>
+  </div>
+</template>
+
+<script>
+import {
+  addDeviceMaintenance,
+  deleteDeviceMaintenance, exportDeviceMaintenance,
+  selectDeviceMaintenancePage
+} from "@/api/cnas/resourceDemand/device";
+import limsTable from "@/components/Table/lims-table.vue";
+import {selectUserCondition} from "@/api/system/user";
+
+export default {
+  name: '',
+  // import 寮曞叆鐨勭粍浠堕渶瑕佹敞鍏ュ埌瀵硅薄涓墠鑳戒娇鐢�
+  components: {limsTable},
+  props: {
+    clickNodeVal: {
+      type: Object,
+      default: () => {
+        return {};
+      }
+    },
+  },
+  data() {
+    // 杩欓噷瀛樻斁鏁版嵁
+    return {
+      search: {
+        maintenanceDate: '',
+      },
+      outLoading: false,
+      tableData: [],
+      tableLoading: false,
+      page: {
+        total: 0,
+        size: 20,
+        current: 1
+      },
+      column: [
+        { label: '缁存姢鏃ユ湡', prop: 'maintenanceDate' },
+        { label: '缁存姢鍐呭', prop: 'maintenanceContent' },
+        { label: '缁存姢浜�', prop: 'maintenanceUserName' },
+        { label: '澶囨敞', prop: 'remark' },
+        {
+          dataType: 'action',
+          label: '鎿嶄綔',
+          operation: [
+            {
+              name: '缂栬緫',
+              type: 'text',
+              clickFun: (row) => {
+                this.openDia('edit', row);
+              },
+            },
+            {
+              name: '鍒犻櫎',
+              type: 'text',
+              clickFun: (row) => {
+                this.handleDeleteClick(row);
+              },
+            },
+          ]
+        }
+      ],
+      dialogVisible: false,
+      form: {
+        id: '',
+        deviceId: '',
+        maintenanceDate: '',
+        maintenanceContentArr: [],
+        maintenanceContent: '',
+        maintenanceUserId: '',
+        remark: '',
+      },
+      operationType: '',
+      buttonLoading: false,
+      qualificationList: [],
+      rules: {
+        maintenanceDate: [{ required: true, message: '璇烽�夋嫨缁存姢鏃ユ湡', trigger: 'change' }],
+        maintenanceContentArr: [{ required: true, message: '璇烽�夋嫨缁存姢鍐呭', trigger: 'change' }],
+        maintenanceUserId: [{ required: true, message: '璇烽�夋嫨缁存姢浜�', trigger: 'change' }],
+      },
+      responsibleOptions: [],
+    };
+  },
+  mounted() {
+    this.refreshTableList()
+  },
+  // 鏂规硶闆嗗悎
+  methods: {
+    // 鐐瑰嚮鍒锋柊
+    refreshTableList () {
+      this.page.current = 1;
+      this.getTableList()
+    },
+    // 鍒嗛〉鍒囨崲
+    pagination(page) {
+      this.page.size = page.limit
+      this.getTableList()
+    },
+    getTableList () {
+      this.tableLoading = true
+      selectDeviceMaintenancePage({
+        deviceId: this.clickNodeVal.value,
+        ...this.page
+      }).then(res => {
+        this.tableLoading = false
+        this.tableData = res.data.records
+        this.page.total = res.data.total
+      }).catch(err => {
+        this.tableLoading = false
+      })
+    },
+    // 鎵撳紑鎿嶄綔寮规
+    openDia (type, row) {
+      this.operationType = type
+      this.dialogVisible = true
+      this.$nextTick(() => {
+        this.$refs['form'].resetFields()
+        this.form.id = ''
+        if (this.operationType === 'edit') {
+          this.form = {...row}
+          this.$set(this.form, 'maintenanceContentArr', this.form.maintenanceContent.split(','))
+        }
+      })
+      this.getDictS()
+      this.getUserList()
+    },
+    // 鏌ヨ缁存姢鍐呭閫夋嫨妗嗗唴瀹�
+    getDictS () {
+      // 瀹氫箟瀹為獙瀹ゅ悕绉颁笌缁存姢鍐呭绫诲瀷鐨勬槧灏勫叧绯�
+      const labTypeMapping = {
+        '鑰佸寲瀹�': 'aging_maintenance_content',
+        '鑰佸寲瀹為獙瀹�': 'aging_maintenance_content',
+        '鐢垫�ц兘瀹為獙瀹�': 'electrical_maintenance_content',
+        '鐜瀹為獙瀹�': 'environmental_maintenance_content',
+        '鐕冪儳瀹為獙瀹�': 'burn_maintenance_content',
+        '娣风偧瀹為獙瀹�': 'mixing_maintenance_content',
+        '妫�娴嬩腑蹇冪數鎬ц兘瀹為獙瀹�': 'center_electrical_maintenance_content',
+        '鎭掓俯浜�': 'temperature2_maintenance_content',
+        '鎭掓俯涓�': 'temperature1_maintenance_content',
+        '鍖栧瀹為獙瀹�': 'chemistry_maintenance_content',
+        '鍒舵牱瀹�': 'sample_maintenance_content',
+        '浣庢俯瀹為獙瀹�': 'hypothermia_maintenance_content',
+      };
+      // 鑾峰彇褰撳墠鑺傜偣鐨勫疄楠屽鍚嶇О
+      const name = this.clickNodeVal.parent.label;
+      // 鏍规嵁鏄犲皠鍏崇郴鑾峰彇瀵瑰簲鐨勭被鍨�
+      const type = labTypeMapping[name];
+      this.getDicts(type).then((response) => {
+        this.qualificationList = response.data.map((m) => {
+          return {
+            label: m.dictLabel,
+            value: m.dictValue,
+          };
+        });
+      });
+    },
+    openHandleOut () {
+      this.outLoading = true
+      exportDeviceMaintenance({
+        deviceId: this.clickNodeVal.value
+      }).then(res => {
+        this.outLoading = false
+        const blob = new Blob([res], { type: 'application/octet-stream' });
+        this.$download.saveAs(blob, '璁惧缁存姢淇濆吇.doc')
+      })
+
+    },
+    handleDeleteClick(row) {
+      this.$confirm('姝ゆ搷浣滃皢姘镐箙鍒犻櫎璇ユ枃浠�, 鏄惁缁х画?', '鎻愮ず', {
+        confirmButtonText: '纭畾',
+        cancelButtonText: '鍙栨秷',
+        type: 'warning'
+      }).then(() => {
+        deleteDeviceMaintenance({ id: row.id }).then(res => {
+          this.$message({
+            type: 'success',
+            message: '鍒犻櫎鎴愬姛!'
+          });
+          this.refreshTableList()
+        })
+      }).catch(() => {
+        this.$message({
+          type: 'info',
+          message: '宸插彇娑堝垹闄�'
+        });
+      });
+    },
+    // 鎻愪氦鏂板鍜屼繚瀛�
+    saveRecord () {
+      this.$refs.form.validate((valid) => {
+        if (valid) {
+          this.buttonLoading = true;
+          this.form.maintenanceContent = this.form.maintenanceContentArr.join(',')
+          this.form.deviceId = this.clickNodeVal.value
+          addDeviceMaintenance(this.form).then(res => {
+            this.buttonLoading = false;
+            this.$message.success('鏂板鎴愬姛')
+            this.closeDia()
+            this.getTableList()
+          }).catch(err => {
+            this.buttonLoading = false;
+          })
+        }
+      })
+    },
+    closeDia () {
+      this.$refs['form'].resetFields();
+      this.dialogVisible = false
+      this.refreshTableList()
+    },
+    // 鑾峰彇璐熻矗浜轰俊鎭帴鍙�
+    getUserList() {
+      selectUserCondition({type: 2}).then(res => {
+        if (res.code == 200) {
+          this.responsibleOptions = res.data
+        }
+      })
+    },
+  },
+  watch: {
+    // 鐩戝惉鐐瑰嚮el-tree鐨勬暟鎹紝杩涜鏁版嵁鍒锋柊
+    clickNodeVal(newVal) {
+      if (newVal.value) {
+        this.refreshTableList();
+      }
+    },
+  }
+};
+</script>
+
+<style scoped>
+.search {
+  height: 46px;
+  text-align: right;
+  margin-top: 10px;
+}
+</style>

--
Gitblit v1.9.3