src/views/CNAS/resourceDemand/device/component/checkRecord.vue
@@ -11,7 +11,7 @@
          <div class="form-section-title">基本信息</div>
          <el-row :gutter="12">
            <el-col :span="12">
              <el-form-item label="仪器名称:" prop="deviceName">
              <el-form-item label="设备名称:" prop="deviceName">
                <el-select v-if="currentStep === 0" v-model="selectedDeviceId" clearable filterable
                  placeholder="请选择设备" size="small" style="width: 100%" @change="changeMachineName">
                  <el-option v-for="item in equipOptions" :key="item.id" :label="item.label + '-' + item.value"
@@ -141,6 +141,7 @@
  findExaminePlanDetail,
  resolveExaminePlanDetail,
  updateDeviceExaminePlanDetail,
  getDeviceById,
} from '@/api/cnas/resourceDemand/device.js'
import { selectUserCondition } from "@/api/performance/class";
import LimsAttachment from '@/components/Attachment/lims-attachment.vue'
@@ -178,6 +179,7 @@
      selectedDeviceId: '',
      submitFormLoading: false,
      userList: [],
      planDueDate: '',
      rules: {
        checkMethod: [{ required: true, message: '请填写核查方式', trigger: 'blur' }],
      },
@@ -209,6 +211,15 @@
        fileName: row.fileName || '',
        fileUrl: row.fileUrl || '',
        planDetailsId: row.planDetailsId,
      }
      this.planDueDate = ''
      if (row.deviceId && /^\d{4}-\d{2}$/.test(this.form.checkTime)) {
        getDeviceById({ deviceId: row.deviceId }).then(res => {
          const due = res.data && res.data.nextExamineDate
          if (due && String(due).slice(0, 7) === this.form.checkTime) {
            this.planDueDate = String(due).slice(0, 10)
          }
        }).catch(() => {})
      }
    },
    // 新增核查记录:自选设备,提交时自动匹配/创建本轮计划明细
@@ -328,6 +339,41 @@
    },
    // 提交审核
    examine(statue) {
      const checkTime = this.form.checkTime || ''
      const now = new Date()
      const nowMonth = `${now.getFullYear()}-${String(now.getMonth() + 1).padStart(2, '0')}`
      const checkMonth = checkTime.slice(0, 7)
      const isEarlyReview = statue === 1 && /^\d{4}-\d{2}/.test(checkTime) && checkMonth > nowMonth
      if (!isEarlyReview) {
        this.submitReview(statue)
        return
      }
      const isMonthOnly = /^\d{4}-\d{2}$/.test(checkTime)
      const todayStr = `${nowMonth}-${String(now.getDate()).padStart(2, '0')}`
      const plannedText = isMonthOnly
        ? (this.planDueDate ? `${this.planDueDate}(计划月份 ${checkTime})` : `${checkTime}(系统登记只到月份)`)
        : checkTime
      const head = `<div class="er-head">该条记录的计划检查日期为 <b>${plannedText}</b>,当前审核日期是 <b>${todayStr}</b>,属于<b>提前审核</b>。</div>`
      const items = [
        `本轮记录的计划检查日期保留为 <b>${plannedText}</b> 不变;审核通过后,「核查时间」记录为实际审核日期 <b>${todayStr}</b>。`,
        `设备档案的最近核查日期更新为 <b>${todayStr}</b>,下次核查日期按核查周期自动计算。`,
        `系统会按设备的核查周期自动生成下一轮待核查任务(在下次核查日期所属年份的计划中),初始状态“未开始”,这是正常现象,不是审核没生效。`
      ]
      const content = `${head}<div class="er-title">通过后系统会做三件事:</div>` +
        `<ol class="er-list">${items.map(item => `<li>${item}</li>`).join('')}</ol>` +
        `<div class="er-question">是否确认通过?</div>`
      this.$confirm(content, '提前审核提醒', {
        confirmButtonText: '确认通过',
        cancelButtonText: '取消',
        type: 'warning',
        dangerouslyUseHTMLString: true,
        customClass: 'early-review-message',
      }).then(() => {
        this.submitReview(statue)
      }).catch(() => {})
    },
    // 真正提交审核
    submitReview(statue) {
      this.submitFormLoading = true
      const params = {
        planDetailsId: this.form.planDetailsId,
@@ -335,7 +381,7 @@
      }
      reviewExamineRecord(params).then(res => {
        if (res.code == 200) {
          this.$message.success(statue === 1 ? '审核通过' : '已退回')
          this.$message.success(statue === 1 ? '审核通过' : '审核不通过')
          this.resetForm()
        }
        this.submitFormLoading = false
@@ -393,8 +439,7 @@
      if (!this.form.fileUrl) {
        return
      }
      const isImage = /\.(jpg|jpeg|png|gif)$/i.test(this.form.fileUrl)
      window.open(this.javaApi + (isImage ? '/img/' : '/word/') + this.form.fileUrl, '_blank')
      return this.$download.saveAs(this.form.fileUrl, this.form.fileName)
    },
  },
  computed: {
@@ -447,3 +492,51 @@
  margin-bottom: 12px;
}
</style>
<style>
.early-review-message {
  width: 560px !important;
  max-width: calc(100vw - 40px);
}
.early-review-message .el-message-box__message {
  line-height: 1.8;
}
.early-review-message .er-head {
  padding: 10px 14px;
  margin-bottom: 16px;
  line-height: 1.8;
  color: #303133;
  background: #fdf6ec;
  border-left: 4px solid #e6a23c;
  border-radius: 4px;
}
.early-review-message .er-title {
  margin-bottom: 8px;
  font-weight: 600;
  color: #303133;
}
.early-review-message .er-list {
  margin: 0 0 0 4px;
  padding-left: 20px;
  list-style: decimal;
}
.early-review-message .er-list li {
  margin-bottom: 10px;
  line-height: 1.8;
  color: #303133;
}
.early-review-message .er-list li:last-child {
  margin-bottom: 0;
}
.early-review-message .er-question {
  margin-top: 16px;
  color: #606266;
}
</style>