吴羡
11 小时以前 c6e96cdb8b1cfb51e9a45bf86c38d1353e983127
src/views/CNAS/resourceDemand/device/component/borrow.vue
@@ -26,7 +26,7 @@
        <el-step style="cursor:pointer" v-for="(v, i) in steps" :title="v" :key="i"
          @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: 51vh; overflow-y: scroll;">
            <!-- 新增设备事记录卡片 -->
@@ -57,7 +57,7 @@
              </el-col>
              <el-col :span="12">
                <el-form-item label="借用人联系方式:" prop="borrowerContactInformation" label-width="150px">
                  <el-input v-model="form.borrowerContactInformation" size="small"></el-input>
                  <el-input v-model="form.borrowerContactInformation" size="small" :disabled="currentStep > 0"></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="12">
@@ -81,13 +81,13 @@
                <el-form-item label="相关附件:" prop="fileName">
                  <el-input v-model="form.fileName" disabled size="small"
                    :style="`width: ${currentStep == 0 ? '88%' : '100%'};`">
                    <template #append><el-button  v-if="currentStep === 0" :icon="$icon('el-icon-delete-solid')"
                    <template #append><el-button  v-if="currentStep === 0 && canOperate" :icon="$icon('el-icon-delete-solid')"
                      @click="deleteFile"></el-button></template>
                  </el-input>
                  <el-upload ref="upload" style="float: right;" :action="action" :show-file-list="false"
                    :on-success="onSuccess" :disabled="currentStep !== 0" :headers="uploadHeader">
                    :on-success="onSuccess" :disabled="currentStep !== 0 || !canOperate" :headers="uploadHeader">
                    <template #trigger><el-button style="position: relative;top: -4px" class="uploadFile"  size="small"
                      type="primary" v-if="currentStep === 0">附件上传</el-button></template>
                      type="primary" v-if="currentStep === 0 && canOperate">附件上传</el-button></template>
                  </el-upload>
                </el-form-item>
              </el-col>
@@ -170,9 +170,9 @@
        </div>
      </el-form>
      <template #footer><span  class="dialog-footer">
        <el-button @click="submitForm('3reject')" v-if="currentStep !== 0 && currentStep !== 2">驳回</el-button>
        <el-button @click="submitForm('2save')" v-if="currentStep === 0">保存</el-button>
        <el-button type="primary" v-if="currentStep !== 2" @click="submitForm('1submit')">{{ currentStep === 0 ? '提交' :
        <el-button :loading="submitLoading" @click="submitForm('3reject')" v-if="currentStep !== 0 && currentStep !== 2 && canOperate">驳回</el-button>
        <el-button :loading="submitLoading" @click="submitForm('2save')" v-if="currentStep === 0 && canOperate">保存</el-button>
        <el-button :loading="submitLoading" type="primary" v-if="currentStep !== 2 && canOperate" @click="submitForm('1submit')">{{ currentStep === 0 ? '提交' :
          '通过'
          }}</el-button>
      </span></template>
@@ -183,7 +183,7 @@
        </el-table-column>
        <el-table-column prop="operator" label="操作人" width="180">
        </el-table-column>
        <el-table-column prop="operationTime" label="操作日期" width="180">
        <el-table-column prop="operationTime" label="操作日期" width="180" :formatter="formatDateCell">
        </el-table-column>
        <el-table-column prop="operationType" label="提交类型">
        </el-table-column>
@@ -207,6 +207,8 @@
} from '@/api/cnas/resourceDemand/device.js'
import { selectUserCondition } from "@/api/business/inspectionTask";
import { mapGetters } from "@/utils/store-compat";
import { formatListDate } from './dateFormat'
import { saveBlobOrShowError } from '@/utils/saveBlob'
export default {
  props: {
    clickNodeVal: {
@@ -223,9 +225,10 @@
    return {
      dialogVisible: false,
      dialogVisible0: false,
      canOperate: true,
      currentStep: 0, // 步骤条显示第几步
      currentStepClick: 0, // 点击步骤条变化
      steps: ['借出', '借用'],
      steps: ['借出', '归还'],
      responsibleOptions: [], // 下环节负责人list
      form: {
        processNumber: null,
@@ -251,6 +254,7 @@
      },
      deviceLogs: [],
      outLoading: false,
      submitLoading: false,
      recipientStateList: [{
        value: 0,
        type: 'success',
@@ -279,18 +283,20 @@
        },
        { label: "借用人", prop: "recipientUser" },
        { label: "借用人联系方式", prop: "borrowerContactInformation", width: '140px' },
        { label: "借用日期", prop: "recipientTime" },
        { label: "借用日期", prop: "recipientTime", formatData: (params) => formatListDate(params) },
        {
          label: "借用时状态", prop: "recipientState", dataType: "tag",
          formatData: (params) => {
            return this.recipientStateList.find((m) => m.value == params).label;
            const item = this.recipientStateList.find((m) => m.value == params)
            return item ? item.label : '-'
          },
          formatType: (params) => {
            return this.recipientStateList.find((m) => m.value == params).type;
            const item = this.recipientStateList.find((m) => m.value == params)
            return item ? item.type : 'info'
          },
        },
        { label: "借出人", prop: "submitUser" },
        { label: "借出日期", prop: "createTime" },
        { label: "借出日期", prop: "createTime", formatData: (params) => formatListDate(params) },
        {
          label: "当前状态", prop: "nowState"
        },
@@ -337,7 +343,7 @@
    // 监听点击el-tree的数据,进行数据刷新
    clickNodeVal(newVal) {
      if (newVal.value) {
        thisqueryParams.deviceId = this.clickNodeVal.value
        this.queryParams.deviceId = this.clickNodeVal.value
        this.refreshTable()
      }
    },
@@ -362,6 +368,9 @@
    this.refreshTable()
  },
  methods: {
    formatDateCell(row, column, cellValue) {
      return formatListDate(cellValue)
    },
    getList() {
      this.tableLoading = true;
      let param = { ...this.queryParams, ...this.page };
@@ -384,7 +393,7 @@
      this.getList();
    },
    refresh() {
      this.queryParams = {};
      this.queryParams = { deviceId: this.clickNodeVal.value };
      this.page.current = 1;
      this.getList();
    },
@@ -445,12 +454,16 @@
          this.form.nowState = currentStepAction === 2 ? '关闭' : this.steps[currentStepAction]
          this.form.deviceId = this.clickNodeVal.value
          delete this.form.deviceLogs
          this.submitLoading = true
          saveDeviceBorrow(this.form).then(res => {
            if (res.code == 200) {
              this.$message.success('提交成功')
              this.dialogVisible = false
              this.refreshTable()
            }
            this.submitLoading = false
          }).catch(err => {
            this.submitLoading = false
          })
        } else {
          let step = this.steps[this.currentStep]
@@ -467,6 +480,8 @@
        deleteCNASFile({ fileName: this.form.fileName }).then(res => {
          if (res.code == 200) {
            this.$message.success('删除成功!')
            this.form.fileName = null
            this.form.url = null
          }
        })
      }).catch(() => {
@@ -510,12 +525,31 @@
            this.currentStepClick = i
          }
          console.log(this.currentStepClick)
          this.applyPermission()
          this.dialogVisible = true
        }
      })
    },
    // 非当前环节责任人只允许查看
    applyPermission() {
      if (this.form.nowState === '关闭') {
        this.canOperate = false
        return
      }
      let responsible = null
      if (this.form.nowState === '归还') {
        responsible = this.form.nowUser
      } else if (this.form.nowState === '借出') {
        responsible = this.form.submitOperationUser
      }
      this.canOperate = !responsible || responsible === this.nickName
      if (!this.canOperate) {
        this.$message.warning('当前环节责任人为:' + responsible + ',您只能查看')
      }
    },
    // 新增
    add() {
      this.canOperate = true
      this.dialogVisible = true
      this.form = {
        processNumber: null,
@@ -523,10 +557,11 @@
        unifyNumber: null,
        recipientUser: null,
        recipientTime: null,
        recipientState: 0,
        nextUser: null,
        rebackUser: null,
        rebackTime: null,
        receiveState: null,
        receiveState: 0,
        deviceUser: null,
        fileName: null,
      }
@@ -538,11 +573,10 @@
      this.outLoading = true
      deviceBorrowExport({ deviceId: this.clickNodeVal.value }).then(res => {
        this.outLoading = false
        const blob = new Blob([res], {
          type: 'application/force-download'
        })
        const filename = decodeURI(this.clickNodeVal.label + '设备借出统计' + '.xlsx')
        this.$download.saveAs(blob, filename)
        saveBlobOrShowError(res, filename, 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet')
      }).catch(() => {
        this.outLoading = false
      })
    },
    handleLookList(row) {