吴羡
10 小时以前 c6e96cdb8b1cfb51e9a45bf86c38d1353e983127
src/views/CNAS/resourceDemand/device/component/state.vue
@@ -13,7 +13,7 @@
        </el-form-item>
      </el-form>
      <div>
        <el-button size="small" type="primary" @click="dialogVisible = true">新建</el-button>
        <el-button size="small" type="primary" @click="handleAddClick">新建</el-button>
        <el-button :loading="outLoading" size="small" type="primary" @click="handleDown">导出Excel</el-button>
      </div>
    </div>
@@ -33,7 +33,8 @@
        </el-table-column>
        <el-table-column label="停用/启用理由" min-width="180" prop="reason"></el-table-column>
        <el-table-column label="提交人" min-width="130" prop="createUser"></el-table-column>
        <el-table-column label="提交日期" min-width="150" prop="createTime"></el-table-column>
        <el-table-column label="提交日期" min-width="150" prop="createTime"
          :formatter="formatDateCell"></el-table-column>
        <el-table-column label="当前状态" min-width="130" prop="currentState"></el-table-column>
        <el-table-column label="当前责任人" min-width="180" prop="currentResponsible"></el-table-column>
        <!-- 操作按钮 -->
@@ -45,7 +46,7 @@
          </template>
        </el-table-column>
      </el-table>
      <el-pagination :current-page="1" :page-size="search.size" :page-sizes="[10, 20, 30, 50, 100]"
      <el-pagination :current-page="search.current" :page-size="search.size" :page-sizes="[10, 20, 30, 50, 100]"
        :total="search.total" layout="->,total, sizes, prev, pager, next, jumper" @size-change="handleSizeChange"
        @current-change="handleCurrentChange" background>
      </el-pagination>
@@ -56,7 +57,7 @@
        <el-step v-for="(v, i) in steps" :key="i" :title="v" style="cursor:pointer"
          @click="choiceStep(i)"></el-step>
      </el-steps>
      <el-form ref="form" :model="form" :rules="rules" label-width="130px">
      <el-form ref="form" :model="form" :rules="rules" label-width="130px" :disabled="!canOperate">
        <div v-show="currentStepClick === 0">
          <el-card style="margin-top: 1em; height: 42vh; overflow-y: scroll;">
            <!-- 卡片 -->
@@ -220,10 +221,10 @@
        </div>
      </el-form>
      <template #footer><span  class="dialog-footer">
        <el-button v-if="currentStep !== 0 && currentStep !== 4" :loading="sumbitLoading1"
        <el-button v-if="currentStep !== 0 && currentStep !== 4 && canOperate" :loading="sumbitLoading1"
          @click="submitForm('3reject')">驳回</el-button>
        <el-button v-if="currentStep === 0" :loading="sumbitLoading2" @click="submitForm('2save')">保存</el-button>
        <el-button v-if="currentStep !== 4" :loading="sumbitLoading3" type="primary" @click="submitForm('1submit')">
        <el-button v-if="currentStep === 0 && canOperate" :loading="sumbitLoading2" @click="submitForm('2save')">保存</el-button>
        <el-button v-if="currentStep !== 4 && canOperate" :loading="sumbitLoading3" type="primary" @click="submitForm('1submit')">
          {{ currentStep === 0 ? '提交' : '通过' }}
        </el-button>
      </span></template>
@@ -242,6 +243,8 @@
import { selectUserCondition } from "@/api/business/inspectionTask";
import { dateFormat } from '@/utils/date'
import { mapGetters } from "@/utils/store-compat";
import { formatListDate } from './dateFormat'
import { saveBlobOrShowError } from '@/utils/saveBlob'
export default {
  props: {
    clickNodeVal: {
@@ -258,6 +261,7 @@
    return {
      outLoading: false, // 导出loading
      dialogVisible: false,
      canOperate: true,
      form: {},
      currentStep: 0, // 步骤条显示第几步
      currentStepClick: 0, // 点击步骤条变化
@@ -282,6 +286,9 @@
    this.getDeviceStatePage(this.clickNodeVal.value)
  },
  methods: {
    formatDateCell(row, column, cellValue) {
      return formatListDate(cellValue)
    },
    // 分页
    handleSizeChange(val) {
      this.search.size = val
@@ -341,22 +348,40 @@
            default:
              break
          }
          // 获取当前环节负责人
          switch (saveState === '3reject' ? this.currentStep - 1 : this.currentStep) {
            case 0:
              this.form.currentResponsible = this.form.submitOperatingPersonnel
              break
            case 1:
              this.form.currentResponsible = this.form.departmentOperatingPersonnel
              break
            case 2:
              this.form.currentResponsible = this.form.measuringRoomOperatingPersonnel
              break
            case 3:
              this.form.currentResponsible = this.form.approvalOperatingPersonnel
              break
            default:
              break
          // 获取当前环节负责人:驳回回到上一环节操作人,保存留给自己,提交/通过进入下一环节责任人
          if (saveState === '3reject') {
            switch (this.currentStep - 1) {
              case 0:
                this.form.currentResponsible = this.form.submitOperatingPersonnel
                break
              case 1:
                this.form.currentResponsible = this.form.departmentOperatingPersonnel
                break
              case 2:
                this.form.currentResponsible = this.form.measuringRoomOperatingPersonnel
                break
              default:
                break
            }
          } else if (saveState === '2save') {
            this.form.currentResponsible = this.form.submitOperatingPersonnel
          } else {
            switch (this.currentStep) {
              case 0:
                this.form.currentResponsible = this.form.submitNextPesponsible
                break
              case 1:
                this.form.currentResponsible = this.form.departmentNextPesponsible
                break
              case 2:
                this.form.currentResponsible = this.form.measuringRoomNextPesponsible
                break
              case 3:
                this.form.currentResponsible = this.form.approvalNextPesponsible
                break
              default:
                break
            }
          }
          // 获取当前状态
          this.form.currentState = currentStepAction === 4 ? '关闭' : this.steps[currentStepAction]
@@ -406,24 +431,43 @@
        }
      })
    },
    // 新建
    handleAddClick() {
      this.canOperate = true
      this.dialogVisible = true
    },
    // 查看
    handleViewClick(row) {
      this.form = { ...row }
      // 如果索引为6表示全部通过
      this.currentStep = this.steps.indexOf(this.form.currentState) === -1 ? 4 : this.steps.indexOf(this.form.currentState)
      this.currentStepClick = this.currentStep === 4 ? 0 : this.currentStep
      this.$nextTick(() => {
        this.$refs['form'].clearValidate()
      })
      this.applyPermission()
      this.dialogVisible = true
      this.$nextTick(() => {
        this.$refs['form'] && this.$refs['form'].clearValidate()
      })
    },
    // 非当前环节责任人只允许查看
    applyPermission() {
      if (this.currentStep === 4) {
        this.canOperate = false
        return
      }
      const responsible = this.form.currentResponsible
      this.canOperate = !responsible || responsible === this.nickName
      if (!this.canOperate) {
        this.$message.warning('当前环节责任人为:' + responsible + ',您只能查看')
      }
    },
    // 导出
    handleDownOne(row) {
      this.outLoading = true
      exportDeviceStatus({ deviceId: row.deviceId, processNumber: row.processNumber }).then(res => {
        this.outLoading = false
        const blob = new Blob([res], { type: 'application/octet-stream' });
        this.$download.saveAs(blob, '设备停/启用.doc')
        saveBlobOrShowError(res, '设备停/启用.doc', 'application/msword')
      }).catch(() => {
        this.outLoading = false
      })
    },
    // 删除
@@ -454,9 +498,8 @@
        processNumber: this.search.processNumber
      }).then(res => {
        this.outLoading = false
        const blob = new Blob([res], { type: 'application/octet-stream' });
        this.$download.saveAs(blob, '设备停用/启用.xlsx')
      }).finally(() => {
        saveBlobOrShowError(res, '设备停用/启用.xlsx', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet')
      }).catch(() => {
        this.outLoading = false
      })
    },
@@ -482,8 +525,6 @@
    // 监听点击el-tree的数据,进行数据刷新
    clickNodeVal(newVal) {
      if (newVal.value) {
        this.componentData.entity.deviceId = this.clickNodeVal.value
        this.entityCopy = this.HaveJson(this.componentData.entity)
        this.getDeviceStatePage(newVal.value)
      }
    },
@@ -494,7 +535,7 @@
        this.closeLoading()
        this.currentStep = 0 // 步骤条显示第几步
        this.currentStepClick = 0 // 点击步骤条变化
        this.$refs['form'].clearValidate()
        this.$refs['form'] && this.$refs['form'].clearValidate()
      }
    }
  },