spring
2025-03-03 f01d916828cf9746a0f438d9472af9271efd9729
src/views/CNAS/resourceDemand/device/component/inspectionOfEquipment.vue
@@ -48,7 +48,11 @@
<script>
import InspectionForm from "./inspectionForm.vue";
import {
  getDeviceInspectionRecordByPage,
  exportDeviceInspectionRecord,
  deleteDeviceInspectionRecord,
} from '@/api/cnas/resourceDemand/device.js'
export default {
  name: "inspection-of-equipment",
  // import 引入的组件需要注入到对象中才能使用
@@ -81,19 +85,10 @@
    // 查询
    getYearTableDetailData(deviceId) {
      this.yearTableDetailDataLoading = true
      this.$axios.post(this.$api.deviceInspectionRecord.getDeviceInspectionRecordByPage, {
        page: {
          current: this.pagination1.current,
          size: this.pagination1.size,
        },
        entity: {
          deviceId: deviceId,
        }
      }, {
        headers: {
          'Content-Type': 'application/json'
        },
        noQs: true
      getDeviceInspectionRecordByPage({
        current: this.pagination1.current,
        size: this.pagination1.size,
        deviceId: deviceId,
      }).then(res => {
        if (res.code == 200) {
          this.yearTableDetailData = res.data.records
@@ -127,37 +122,12 @@
    // 导出
    handleDownOne(id) {
      this.outLoading = true
      this.$axios.get(this.$api.deviceInspectionRecord.exportDeviceInspectionRecord + '?inspectionRecordId=' + id, {
        responseType: "blob"
      exportDeviceInspectionRecord({
        inspectionRecordId: id
      }).then(res => {
        this.outLoading = false
        const blob = new Blob([res], { type: 'application/octet-stream' });
        //将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('导出成功')
          }
        }
        this.$download.saveAs(blob, '设备点检记录表.doc')
      })
    },
    // 删除
@@ -167,7 +137,7 @@
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        this.$axios.get(this.$api.deviceInspectionRecord.deleteDeviceInspectionRecord + '?inspectionRecordId=' + id).then(res => {
        deleteDeviceInspectionRecord({ inspectionRecordId: id }).then(res => {
          this.$message.success('删除成功!');
          this.getYearTableDetailData(this.clickNodeVal.value);
        });