Crunchy
2025-04-29 e5454b769d44a34af423bf87ac8a740bf8c20341
src/views/CNAS/resourceDemand/device/component/equipmentAccident.vue
@@ -7,6 +7,7 @@
      </div>
      <div>
        <el-table ref="yearTable" v-loading="yearTableDetailDataLoading" :data="yearTableDetailData"
                  :header-cell-style="{ background: '#f8f8f9', color: '#515a6e' }" border
          height="calc(100vh - 18em)" style="width: 100% ;">
          <!-- 表格列 -->
          <el-table-column align="center" header-align="center" label="序号" prop="prop" type="index"
@@ -29,7 +30,7 @@
          </el-table-column>
        </el-table>
        <el-pagination :current-page="1" :page-size="pagination1.size" :page-sizes="[10, 20, 30, 50, 100]"
          :total="pagination1.total" layout="->,total, sizes, prev, pager, next, jumper"
          :total="pagination1.total" layout="->,total, sizes, prev, pager, next, jumper" background
          @size-change="handleSizeChange1" @current-change="handleCurrentChange1">
        </el-pagination>
      </div>
@@ -40,7 +41,11 @@
<script>
import AccidentForm from "./accidentForm.vue";
import {
  pageDeviceAccidentReport,
  exportDeviceAccidentReport,
  delDeviceAccidentReport,
} from '@/api/cnas/resourceDemand/device.js'
export default {
  name: "equipment-accident",
  // import 引入的组件需要注入到对象中才能使用
@@ -73,19 +78,10 @@
    // 查询
    getYearTableDetailData(deviceId) {
      this.yearTableDetailDataLoading = true
      this.$axios.post(this.$api.deviceAccidentReport.pageDeviceAccidentReport, {
        page: {
          current: this.pagination1.current,
          size: this.pagination1.size,
        },
        entity: {
          deviceId: deviceId,
        }
      }, {
        headers: {
          'Content-Type': 'application/json'
        },
        noQs: true
      pageDeviceAccidentReport({
        current: this.pagination1.current,
        size: this.pagination1.size,
        deviceId: deviceId,
      }).then(res => {
        if (res.code == 200) {
          this.yearTableDetailData = res.data.records
@@ -119,37 +115,10 @@
    // 导出
    handleDownOne(id) {
      this.outLoading = true
      this.$axios.get(this.$api.deviceAccidentReport.exportDeviceAccidentReport + '?accidentReportId=' + id, {
        responseType: "blob"
      }).then(res => {
      exportDeviceAccidentReport({ accidentReportId: 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')
      })
    },
    // 删除
@@ -159,7 +128,7 @@
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        this.$axios.get(this.$api.deviceAccidentReport.delDeviceAccidentReport + '?accidentReportId=' + id).then(res => {
        delDeviceAccidentReport({ accidentReportId: id }).then(res => {
          this.$message.success('删除成功!');
          this.getYearTableDetailData(this.clickNodeVal.value);
        });