吴羡
8 小时以前 a1faa94fbf85553f22da934a1abc745d89dd8667
src/views/CNAS/resourceDemand/device/component/equipmentCalibrationPlan.vue
@@ -11,10 +11,6 @@
        </div>
        <div>
          <el-button size="small" type="primary" @click="loadPlan">刷新</el-button>
          <el-button size="small" type="primary" :disabled="planInfo.ratifyStatus === 1"
            @click="tellApprove">批准通知</el-button>
          <el-button size="small" type="primary"
            :disabled="planInfo.ratifyStatus === 1 || userId != planInfo.ratifyUserId" @click="handleApprove">批准</el-button>
          <el-button size="small" type="primary" @click="downLoadPost">导出</el-button>
        </div>
      </div>
@@ -67,10 +63,10 @@
          <template #default="scope">
            <el-button size="small" link type="primary" :disabled="!scope.row.deviceId"
              @click="handleExecute(scope.row)">执行</el-button>
            <el-button size="small" link type="primary" :disabled="planInfo.ratifyStatus === 1"
            <el-button size="small" link type="primary"
              @click="handleForm('edit', scope.row)">编辑</el-button>
            <el-button size="small" link type="primary" @click="handleForm('view', scope.row)">查看</el-button>
            <el-button size="small" link type="danger" :disabled="planInfo.ratifyStatus === 1"
            <el-button size="small" link type="danger"
              @click="deleteFun1(scope.row.planDetailId)">删除</el-button>
          </template>
        </el-table-column>
@@ -138,29 +134,6 @@
          认</el-button>
      </span></template>
    </el-dialog>
    <el-dialog v-model="approvalDialog" title="批准" width="30%" @close="approvalDialog = false">
      <span>
        批准备注:
        <el-input v-model="ratifyRemark" type="textarea"></el-input>
      </span>
      <template #footer><span class="dialog-footer">
        <el-button :loading="approvalLoading" @click="handleApproval(0)">不批准</el-button>
        <el-button :loading="approvalLoading" type="primary" @click="handleApproval(1)">批 准</el-button>
      </span></template>
    </el-dialog>
    <el-dialog v-model="notificationDia" title="提交批准" width="30%" @close="closeNotificationDia">
      <span style="margin-top: 10px;display: inline-block">
        请选择批准人:
        <el-select v-model="ratifyUserId" clearable filterable size="small" style="width: 90%;">
          <el-option v-for="item in responsibleOptions" :key="item.value" :label="item.label" :value="item.value">
          </el-option>
        </el-select>
      </span>
      <template #footer><span class="dialog-footer">
        <el-button :loading="notificationLoading" @click="closeNotificationDia">取 消</el-button>
        <el-button :loading="notificationLoading" type="primary" @click="notification">提 交</el-button>
      </span></template>
    </el-dialog>
    <!-- 添加/查看校准记录弹窗 -->
    <calibration-record-dia ref="calibrationRecordDia" @success="getYearTableDetailData"></calibration-record-dia>
  </div>
@@ -171,15 +144,11 @@
import {
  pageDeviceCalibrationPlan,
  getCalibrationPlanByYear,
  submiatRatifyDeviceCalibrationPlan,
  exportDeviceCalibrationPlanDetail,
  delDeviceCalibrationPlanDetail,
  pageDeviceCalibrationPlanDetail,
  updateDeviceCalibrationPlanDetail,
  ratifyDeviceCalibrationPlan,
} from '@/api/cnas/resourceDemand/device.js'
import { selectUserCondition } from "@/api/performance/class";
import { mapGetters } from "@/utils/store-compat";
import { formatDateOnly } from './dateFormat'
import { saveBlobOrShowError } from '@/utils/saveBlob'
export default {
@@ -229,15 +198,7 @@
        planDate: [{ required: true, message: '请选择日期', trigger: 'change' }],
      },
      yearTableDetailDataLoading: false,
      approvalDialog: false,
      approvalLoading: false,
      submitFormLoading: false,
      ratifyRemark: '',
      currentRowId: '',
      responsibleOptions: [],
      notificationDia: false,
      notificationLoading: false,
      ratifyUserId: '',
    }
  },
  mounted() {
@@ -383,60 +344,6 @@
        });
      });
    },
    // 打开提交批准弹框
    tellApprove() {
      this.getUserList()
      this.notificationDia = true
    },
    // 关闭提交批准弹框
    closeNotificationDia() {
      this.notificationDia = false
      this.ratifyUserId = ''
    },
    // 提交批准通知
    notification() {
      if (!this.ratifyUserId) {
        this.$message.warning('请选择批准人')
        return
      }
      this.notificationLoading = true
      submiatRatifyDeviceCalibrationPlan({
        ratifyUserId: this.ratifyUserId,
        planId: this.planInfo.planId,
      }).then(res => {
        this.notificationLoading = false
        if (res.code == 200) {
          this.closeNotificationDia()
          this.loadPlan()
        }
      }).catch(err => {
        this.notificationLoading = false
      })
    },
    // 批准
    handleApprove() {
      this.currentRowId = this.planInfo.planId
      this.approvalDialog = true
    },
    // 提交批准结果
    handleApproval(status) {
      const personTrainingUpdateDto = {
        planId: this.currentRowId,
        ratifyRemark: this.ratifyRemark,
        ratifyStatus: status
      }
      this.approvalLoading = true
      ratifyDeviceCalibrationPlan(personTrainingUpdateDto).then(res => {
        if (res.code === 200) {
          this.$message.success('提交成功!');
          this.approvalDialog = false
          this.loadPlan()
        }
        this.approvalLoading = false
      }).catch(() => {
        this.approvalLoading = false
      })
    },
    // 导出
    downLoadPost() {
      exportDeviceCalibrationPlanDetail({ planId: this.planInfo.planId }).then(res => {
@@ -446,25 +353,9 @@
    resetForm() {
      this.$refs.modelForm.resetFields();
      this.dialogVisible = false
    },
    // 获取负责人信息接口
    getUserList() {
      selectUserCondition().then(res => {
        if (res.code == 200) {
          let data = [];
          res.data.forEach((a) => {
            data.push({
              label: a.name,
              value: a.id,
            });
          });
          this.responsibleOptions = data
        }
      });
    }
  },
  computed: {
    ...mapGetters(["userId"]),
    // 是否已完成审批(批准/不批准)
    isRatified() {
      return this.planInfo.ratifyStatus === 0 || this.planInfo.ratifyStatus === 1;