spring
2025-03-03 f01d916828cf9746a0f438d9472af9271efd9729
src/views/CNAS/resourceDemand/device/component/maintenance.vue
@@ -118,8 +118,10 @@
<script>
import {
  exportMaintenanceRecord,
  deviceMaintainDelete,
  deleteDeviceMaintenance,
  selectDeviceByCode,
  addDeviceMaintenance,
  getDeviceMaintenancePage,
} from '@/api/cnas/resourceDemand/device.js'
export default {
  props: {
@@ -180,33 +182,8 @@
      exportMaintenanceRecord({ deviceId: this.clickNodeVal.value }).then(res => {
        this.outLoading = false
        const blob = new Blob([res], { type: 'application/octet-stream' });
        this.$download.saveAs(blob, '设备维护保养记录.doc')
        this.$message.success('导出成功')
        //将Blob 对象转换成字符串
        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 = '设备维护保养记录.doc';
              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 = '设备维护保养记录.doc';
            link.click();
            this.$message.success('导出成功')
          }
        }
      })
    },
    //操作详情删除
@@ -216,9 +193,10 @@
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        deviceMaintainDelete(row.id).then(res => {
        deleteDeviceMaintenance({ id: row.id }).then(res => {
        })
        this.MaintainParam.splice(index, 1);
        // this.MaintainParam.splice(index, 1);
        this.getAllMessage(this.clickNodeVal.value)
        this.$message({
          type: 'success',
          message: '删除成功!'
@@ -246,15 +224,15 @@
      this.$refs['form'].validate((valid) => {
        if (valid) {
          this.formData.deviceId = this.clickNodeVal.value;
          this.$axios.post(this.$api.deviceCheck.deviceMaintainAdd, this.formData).then(res => {
          addDeviceMaintenance(this.formData).then(res => {
            if (res.code == 200) {
              this.$message.success('添加成功');
              this.getAllMessage(this.clickNodeVal.value)
            }
          })
          this.MaintainParam.push(this.formData)
          this.dialogVisible = false;
          this.formData = {}; //清空表单
            }
          })
          // this.MaintainParam.push(this.formData)
        }
      })
    },
@@ -269,7 +247,10 @@
    },
    //获取表单设备维护信息
    getAllMessage(deviceId) {
      this.$axios.get(this.$api.deviceCheck.getDeviceMaintenancePage + "?deviceId=" + deviceId + "&size=" + this.search.size + "&current=" + this.search.current + "&deviceNumber=" + this.search.deviceNumber).then(res => {
      getDeviceMaintenancePage({
        deviceId,
        ...this.search
      }).then(res => {
        if (res.code == 200) {
          this.MaintainParam = res.data.records
          this.search.total = res.data.total