src/views/CNAS/resourceDemand/device/component/equipmentVerificationPlan.vue
@@ -52,8 +52,11 @@
        <el-table-column label="设备编号" min-width="170" prop="deviceNumber"></el-table-column>
        <el-table-column label="设备名称" min-width="180" prop="deviceName" show-overflow-tooltip></el-table-column>
        <el-table-column label="设备型号" min-width="120" prop="deviceModel" show-overflow-tooltip></el-table-column>
        <el-table-column label="核查时间" min-width="120" prop="checkTime"
          :formatter="formatCheckMonth"></el-table-column>
        <el-table-column label="核查时间" min-width="120">
          <template #default="scope">
            {{ scope.row.completeDate || formatCheckMonth(null, null, scope.row.checkTime) }}
          </template>
        </el-table-column>
        <el-table-column label="核查指标" min-width="140" prop="checkIndex"> </el-table-column>
        <el-table-column label="核查方法" min-width="140" prop="checkMethod" show-overflow-tooltip></el-table-column>
        <el-table-column label="结果如何判定" min-width="140" prop="howResults" show-overflow-tooltip></el-table-column>
@@ -90,7 +93,7 @@
              @click="handleRecord(scope.row)">审核</el-button>
            <el-button v-if="scope.row.recordStatus === 2 || scope.row.recordStatus === 3"
              size="small" link type="primary" @click="handleDown(scope.row)">导出</el-button>
            <el-button v-if="scope.row.recordStatus === 0 || scope.row.recordStatus === 1"
            <el-button v-if="scope.row.recordStatus !== 2"
              size="small" link type="danger" @click="deleteFun1(scope.row.planDetailsId)">删除</el-button>
          </template>
        </el-table-column>
@@ -239,7 +242,7 @@
            <span class="export-panel-label">设备名称</span>{{ downRow.deviceName || '—' }}
          </div>
          <div class="export-panel-item">
            <span class="export-panel-label">核查时间</span>{{ formatCheckMonth(null, null, downRow.checkTime) || '—' }}
            <span class="export-panel-label">核查时间</span>{{ downRow.completeDate || formatCheckMonth(null, null, downRow.checkTime) || '—' }}
          </div>
        </div>
        <div v-if="!canExport" class="export-panel-tip">
@@ -264,8 +267,8 @@
import CheckRecord from "./checkRecord.vue";
import LimsAttachment from '@/components/Attachment/lims-attachment.vue'
import {
  pageDeviceExaminePlan,
  getExaminePlanByYear,
  getExaminePlanYears,
  exportDeviceExaminePlanDetail,
  delDeviceExaminePlanDetail,
  pageDeviceExaminePlanDetail,
@@ -345,30 +348,24 @@
  },
  // 方法集合
  methods: {
    // 年份下拉只保留有计划明细的年份,空年份自动消失
    // 年份下拉只保留有计划明细的年份,空年份计划自动删除,默认显示本年度(本年度无计划时退回最新年份)
    loadYearOptions() {
      pageDeviceExaminePlan({
        current: 1,
        size: 99,
      }).then(res => {
        let years = []
        if (res.code == 200) {
          years = (res.data.records || []).map(r => r.planYear).filter(Boolean)
        }
        const options = [...new Set(years)].sort((a, b) => b.localeCompare(a))
        this.yearOptions = options
        if (options.length === 0) {
          this.planYear = ''
          this.planInfo = {}
          this.yearTableDetailData = []
          this.pagination1.total = 0
          return
        }
        if (options.indexOf(this.planYear) === -1) {
          const currentYear = String(new Date().getFullYear())
          this.planYear = options.indexOf(currentYear) > -1 ? currentYear : options[0]
      const finish = (years) => {
        let options = [...new Set((years || []).map(y => String(y)).filter(Boolean))]
        options.sort((a, b) => b.localeCompare(a))
        if (options.length === 0) {
          options = [currentYear]
        }
        this.yearOptions = options
        const keep = options.indexOf(String(this.planYear)) > -1
        this.planYear = keep ? String(this.planYear) : (options.includes(currentYear) ? currentYear : options[0])
        this.loadPlan()
      }
      getExaminePlanYears().then(res => {
        finish(res.code == 200 ? (res.data || []) : [])
      }).catch(() => {
        finish([])
      })
    },
    // 切换年份
@@ -504,7 +501,7 @@
    },
    // 明细-删除
    deleteFun1(id) {
      this.$confirm('删除后,该行未审核的核查记录及附件会一并删除;若该设备还有审核通过的核查记录,档案的最近核查日期将回退到最近一次完成记录;若没有,则清空档案的核查日期和核查周期。是否继续?', '提示', {
      this.$confirm('删除后,该行的核查记录(未审核或审核不通过)及附件会一并删除;若该设备还有审核通过的核查记录,档案的最近核查日期将回退到最近一次完成记录;若没有,则清空档案的核查日期和核查周期。是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
@@ -520,10 +517,15 @@
        });
      });
    },
    // 导出年度计划表
    // 导出年度计划表(Excel):有筛选条件导出筛选结果,没有筛选导出该年份全部
    downLoadPost() {
      exportDeviceExaminePlanDetail({ planId: this.planInfo.planId }).then(res => {
        this.saveDocx(res, '仪器设备期间核查计划表.docx')
      exportDeviceExaminePlanDetail({
        planId: this.planInfo.planId,
        deviceName: this.searchForm.deviceName,
        deviceNumber: this.searchForm.deviceNumber,
      }).then(res => {
        const planName = this.planInfo.planName || (this.planYear ? this.planYear + '年度设备核查计划' : '设备核查计划')
        this.saveDocx(res, planName + '.xlsx', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet')
      }).catch(() => { })
    },
    // 本次是否有改动(含打开时恢复的草稿)
@@ -586,7 +588,7 @@
      this.downloadDialog = true
    },
    // 导出结果拦截: 后端返回错误 JSON 时提示错误, 不存成坏文件
    saveDocx(res, filename) {
    saveDocx(res, filename, mime = 'application/msword') {
      const reader = new FileReader();
      reader.readAsText(res, 'utf-8');
      reader.onload = () => {
@@ -596,11 +598,11 @@
          try { msg = JSON.parse(text).msg || msg; } catch (e) { }
          this.$message.error(msg);
        } else {
          this.$download.saveAs(new Blob([res], { type: 'application/msword' }), filename);
          this.$download.saveAs(new Blob([res], { type: mime }), filename);
        }
      };
      reader.onerror = () => {
        this.$download.saveAs(new Blob([res], { type: 'application/msword' }), filename);
        this.$download.saveAs(new Blob([res], { type: mime }), filename);
      };
    },
    // 核查记录导出