src/views/CNAS/resourceDemand/device/component/equipmentVerificationPlan.vue
@@ -51,6 +51,7 @@
          width="70"></el-table-column>
        <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="140" prop="checkIndex"> </el-table-column>
@@ -107,7 +108,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-input v-model="form.deviceName" disabled size="small"></el-input>
              </el-form-item>
            </el-col>
@@ -212,7 +213,7 @@
        </div>
      </el-form>
      <template #footer><span class="dialog-footer">
        <el-button @click="resetForm">取 消</el-button>
        <el-button @click="handleCancel">取 消</el-button>
        <el-button :loading="submitFormLoading" type="primary" @click="submitForm"
          v-if="operationType !== 'view'">确 认</el-button>
      </span></template>
@@ -471,7 +472,10 @@
      this.$nextTick(() => {
        this.form = this.HaveJson(row)
        if (this.operationType !== 'view') {
          this.draftRestore('equipmentVerificationPlan', 'form', this.form.planDetailsId, 'dialogVisible')
          const rowDeviceName = this.form.deviceName
          this.draftRestore('equipmentVerificationPlan', 'form', this.form.planDetailsId, 'dialogVisible',
            // 设备名称是禁用字段,草稿里为空说明是被表单重置清空的废草稿,直接丢弃
            draft => !!draft.deviceName || !rowDeviceName)
        }
      })
    },
@@ -518,7 +522,28 @@
        this.saveDocx(res, '仪器设备期间核查计划表.docx')
      }).catch(() => { })
    },
    // 本次是否有改动(含打开时恢复的草稿)
    hasUnsavedEdit() {
      const state = this.draftStates && this.draftStates['equipmentVerificationPlan']
      return !!state && this.draftSnapshot(state) !== state.baseline
    },
    // 取消:无编辑直接退出;有编辑先确认,确认后丢弃草稿退出
    handleCancel() {
      if (this.operationType === 'view' || !this.hasUnsavedEdit()) {
        this.dialogVisible = false
        return
      }
      this.$confirm('是否确认取消编辑?本次编辑记录不保存!', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '继续编辑',
        type: 'warning'
      }).then(() => {
        this.draftClear('equipmentVerificationPlan')
        this.dialogVisible = false
      }).catch(() => { })
    },
    resetForm() {
      // 右上角关闭时 close 事件先于显隐监听触发,先把草稿存下再重置表单,避免重置后的空内容被存成草稿
      this.draftStop('equipmentVerificationPlan')
      this.$refs.modelForm.resetFields();
      this.dialogVisible = false