吴羡
12 小时以前 a1faa94fbf85553f22da934a1abc745d89dd8667
src/views/CNAS/resourceDemand/device/component/scrapApplicationForm.vue
@@ -8,7 +8,7 @@
        <el-step title="计量室意见" @click="setStep(2)"></el-step>
        <el-step title="批准人" @click="setStep(3)"></el-step>
      </el-steps>
      <el-form ref="modelForm" :model="form" :rules="rules" label-width="160px">
      <el-form ref="modelForm" :model="form" :rules="rules" label-width="160px" :disabled="!canOperate">
        <el-col v-if="showStep === 0" :span="24">
          <el-form-item label="配件:" prop="parts">
            <el-input v-model="form.parts" :disabled="currentStep !== 0" clearable size="small"></el-input>
@@ -65,7 +65,7 @@
      </el-form>
      <template #footer><span  class="dialog-footer">
        <el-button @click="resetForm">取 消</el-button>
        <el-button v-if="currentStep !== 4" :loading="submitFormLoading" type="primary" @click="submitForm">确
        <el-button v-if="currentStep !== 4 && canOperate" :loading="submitFormLoading" type="primary" @click="submitForm">确
          认</el-button>
      </span></template>
    </el-dialog>
@@ -78,17 +78,17 @@
  addDeviceScrapped,
} from '@/api/cnas/resourceDemand/device.js'
import { selectUserCondition } from "@/api/business/inspectionTask";
import draftSave from '@/mixins/draftSave'
import { mapGetters } from "@/utils/store-compat";
export default {
  name: "scrapApplicationForm",
  // import 引入的组件需要注入到对象中才能使用
  components: {},
  mixins: [draftSave],
  data() {
    // 这里存放数据
    return {
      dialogVisible: false,
      submitFormLoading: false,
      canOperate: true,
      form: {
        parts: '',
        reasonsForScrap: '',
@@ -120,13 +120,12 @@
    // 打开弹框
    openDialog(id, deviceId) {
      this.dialogVisible = true
      this.canOperate = true
      this.form.scrappedId = id
      this.form.deviceId = deviceId
      this.getUserList()
      if (this.form.scrappedId) {
        this.searchInfo()
      } else {
        this.draftRestore('scrapApplicationForm', 'form', this.form.deviceId, 'dialogVisible')
      }
    },
    // 查询详情
@@ -135,9 +134,7 @@
        scrappedId: this.form.scrappedId
      }).then(res => {
        if (res.code === 200) {
          const id = this.form.scrappedId
          this.form = { ...res.data }
          this.draftRestore('scrapApplicationForm', 'form', id, 'dialogVisible')
          if (this.form.isFinish === 0) {
            if (this.form.departmentHeadUserId) {
              this.currentStep = 1
@@ -155,10 +152,29 @@
            this.currentStep = 4
            this.showStep = 3
          }
          this.applyPermission()
        }
      }).catch(error => {
        console.error(error)
      })
    },
    // 非当前环节责任人只允许查看
    applyPermission() {
      if (this.form.isFinish === 1 || this.currentStep >= 4) {
        this.canOperate = false
        return
      }
      const responsibleList = [
        this.form.applicantUser,
        this.form.departmentHeadUser,
        this.form.meteringRoomUser,
        this.form.approverUser,
      ]
      const responsible = responsibleList[this.currentStep]
      this.canOperate = !responsible || responsible === this.nickName
      if (!this.canOperate) {
        this.$message.warning('当前环节责任人为:' + responsible + ',您只能查看')
      }
    },
    setStep(step) {
      this.showStep = step
@@ -168,10 +184,10 @@
      this.form.flowType = this.currentStep
      this.$refs.modelForm.validate((valid) => {
        if (valid) {
          this.submitFormLoading = true
          addDeviceScrapped(this.form).then(res => {
            if (res.code == 200) {
              this.$message.success('新增成功')
              this.draftClear('scrapApplicationForm')
              this.resetForm()
            }
            this.submitFormLoading = false
@@ -183,7 +199,6 @@
    },
    // 关闭弹框
    resetForm() {
      this.draftStop('scrapApplicationForm')
      this.dialogVisible = false
      this.$emit('closeDialog')
    },
@@ -193,6 +208,9 @@
      })
    },
  },
  computed: {
    ...mapGetters(["nickName"]),
  },
}
</script>