zhangherong
2025-06-02 c4bd5940bcd71de72d05c341a110e8eb7e9346a1
src/views/flowable/workflow/repairOrder/RepairOrderApprovalModal.vue
@@ -1,140 +1,224 @@
<template>
  <a-modal
    :width="1000"
  <j-modal
    :width="1200"
    :visible="visible"
    :title="title"
    :okButtonProps="{ class:{'jee-hidden': disableSubmit} }"
    @cancel="handCancel"
    @ok="submitForm"
    :mask-closable="false"
    :confirmLoading="confirmLoading"
    centered
  >
    <a-card :bordered="false">
      <div>
        <b>{{ selectShenpiData.title }}</b>
        <br/>
        <br/>
        <a-tag color="blue">
          处理人 {{ selectShenpiData.assignee }}
        </a-tag>
        <a-tag color="blue">
          创建时间 {{ selectShenpiData.createTime }}
        </a-tag>
        <br>
        <br>
        <a-button @click="fetchAndShowBmp" :loading="showBmpButtonLoading" class="btn-custom">流程图</a-button>
        <div v-if="imageSrc&&isDisplayBmp">
          <img :src="imageSrc" alt="Fetched Image"/>
        </div>
        <hr class="shallow-hr"/>
      </div>
      <div>
        <b>指派详情</b>
        <br>
        <a-form :form='form'>
          <a-spin :spinning="spinning">
            <a-tabs default-active-key='1'>
              <a-tab-pane key='1' tab='基本信息'>
                <a-form-model ref='form' :model='tableRowRecord' :rules='validatorRules' :labelCol='labelCol'
                              :wrapperCol='wrapperCol'>
                  <a-row>
                    <a-col :span='span'>
                      <a-form-model-item label='工单编号'>
                        <a-input :readOnly='inputReadOnly' v-model='tableRowRecord.repairCode'/>
                      </a-form-model-item>
                    </a-col>
                    <a-col :span='span'>
                      <a-form-model-item label='设备编号'>
                        <a-input :readOnly='inputReadOnly' v-model='tableRowRecord.equipmentId_dictText'/>
                      </a-form-model-item>
                    </a-col>
                    <a-col :span='span'>
                      <a-form-model-item label='单据状态'>
                        <a-input :readOnly='inputReadOnly' v-model='tableRowRecord.repairStatus_dictText'/>
                      </a-form-model-item>
                    </a-col>
                    <a-col :span='span'>
                      <a-form-model-item label='维修负责人'>
                        <a-input :readOnly='inputReadOnly' v-model='tableRowRecord.repairer'/>
                      </a-form-model-item>
                    </a-col>
                  </a-row>
                </a-form-model>
              </a-tab-pane>
    <a-spin :spinning="spinning">
      <a-form-model ref="form" :model='tableRowRecord' :rules='validatorRules' :labelCol='labelCol'
                    :wrapperCol='wrapperCol'>
        <a-divider orientation="center" style="font-size: large;font-style: italic;color: #66aeed;">报修基础信息</a-divider>
              <a-tab-pane key='2' tab='流程节点'>
                <a-card>
                  <a-timeline style="padding:0 1% 0 12%">
                    <a-timeline-item color='white' v-for="(item,index1) in hitaskDataSource" :key="index1">
                      <div class="bottom">
                        <p>开始时间:{{item.startTime}}</p>
                        <p>结束时间:{{item.endTime}}</p>
                        <p>处理人:{{item.assignee}}</p>
                        <p>办理类型:{{item.bllx_dictText}}</p>
                        <p v-if="item.name == '提交申请'">指派原因:{{item.cause}}</p>
                        <p v-else>处理意见:{{item.cause}}</p>
                        <div class="left_qiu"><span>{{item.name}}</span></div>
                      </div>
                    </a-timeline-item>
                  </a-timeline>
                </a-card>
              </a-tab-pane>
            </a-tabs>
          </a-spin>
        </a-form>
      </div>
      <div>
        <hr class="shallow-hr">
        <br>
        <b>审批详情</b>
        <br>
        <br>
        <a-form-model ref="form" :model="approveData" :rules="validatorRules" :labelCol='labelCol'
                      :wrapperCol='wrapperCol'>
        <a-row>
          <a-col :span='threeColSpan'>
            <a-form-model-item label='工单编号'>
              <a-input :readOnly='inputReadOnly' v-model='tableRowRecord.repairCode'/>
            </a-form-model-item>
          </a-col>
          <a-col :span='threeColSpan'>
            <a-form-model-item label='工单状态'>
              <a-input :readOnly='inputReadOnly' v-model='tableRowRecord.repairStatus_dictText'/>
            </a-form-model-item>
          </a-col>
          <a-col :span='threeColSpan'>
            <a-form-model-item label='设备编号'>
              <lx-search-equipment-select disabled v-model='tableRowRecord.equipmentId'/>
            </a-form-model-item>
          </a-col>
        </a-row>
        <a-row>
          <a-col :span='threeColSpan'>
            <a-form-model-item label='安装位置'>
              <a-input :readOnly='inputReadOnly' v-model='tableRowRecord.installationPosition_dictText'/>
            </a-form-model-item>
          </a-col>
          <a-col :span='threeColSpan'>
            <a-form-model-item label='报修人'>
              <a-input :readOnly='inputReadOnly' v-model='tableRowRecord.reporter_dictText'/>
            </a-form-model-item>
          </a-col>
          <a-col :span='threeColSpan'>
            <a-form-model-item label='报修人电话'>
              <a-input :readOnly='inputReadOnly' v-model='tableRowRecord.reporterPhone_dictText'/>
            </a-form-model-item>
          </a-col>
        </a-row>
        <a-row>
          <a-col :span='threeColSpan'>
            <a-form-model-item label='维修人'>
              <a-input :readOnly='inputReadOnly' v-model='tableRowRecord.repairer_dictText'/>
            </a-form-model-item>
          </a-col>
          <a-col :span='threeColSpan'>
            <a-form-model-item label='维修人电话'>
              <a-input :readOnly='inputReadOnly' v-model='tableRowRecord.repairerPhone_dictText'/>
            </a-form-model-item>
          </a-col>
          <a-col :span='threeColSpan'>
            <a-form-model-item label='故障简称'>
              <a-input :readOnly='inputReadOnly' v-model='tableRowRecord.faultName'/>
            </a-form-model-item>
          </a-col>
        </a-row>
        <a-row>
          <a-col :span="threeColSpan">
            <a-form-model-item label="故障开始时间">
              <a-input :readOnly='inputReadOnly' v-model="tableRowRecord.faultStartTime"/>
            </a-form-model-item>
          </a-col>
          <a-col :span="threeColSpan">
            <a-form-model-item label="是否停机">
              <j-dict-select-tag type='radio' v-model='tableRowRecord.breakdownFlag' dictCode='breakdown_flag'
                                 disabled/>
            </a-form-model-item>
          </a-col>
        </a-row>
        <a-row>
          <a-col :span="24">
            <a-form-model-item label='故障描述' :labelCol='labelColLong' :wrapperCol='wrapperColLong'>
              <a-textarea :readOnly='inputReadOnly' v-model='tableRowRecord.faultDescription'/>
            </a-form-model-item>
          </a-col>
        </a-row>
        <a-row>
          <a-col :span='threeColSpan*3'>
            <a-form-model-item label='报修图片' :labelCol='labelColLong' :wrapperCol='wrapperColLong'>
              <lx-upload :returnUrl="false" :isMultiple="true" file-type="image" disabled :number="3"
                         v-model="tableRowRecord.reportImageFiles"/>
            </a-form-model-item>
          </a-col>
        </a-row>
        <a-divider orientation="center" style="font-size: large;font-style: italic;color: #66aeed;">是否需要领用备件</a-divider>
        <a-tabs v-model="activeTabKey">
          <a-tab-pane key="1" tab="领用备件">
            <a-row>
              <a-col :span="twoColSpan*2">
                <a-form-model-item label="是否需要领用备件" prop="isUseSpare">
                  <a-radio-group v-model="tableRowRecord.isUseSpare"
                                 :disabled="isDisableUseSpare">
                    <a-radio :value="1">是</a-radio>
                    <a-radio :value="0">否</a-radio>
                  </a-radio-group>
                </a-form-model-item>
              </a-col>
              <template v-if="tableRowRecord.isUseSpare===0">
                <a-col :span="twoColSpan*2">
                  <a-form-model-item label="故障原因" prop="faultReason">
                    <a-input :readOnly="disableSubmit||tableRowRecord.repairStatus!=='UNDER_REPAIR'"
                             v-model="tableRowRecord.faultReason" rows="4"
                             placeholder="请输入故障原因"/>
                  </a-form-model-item>
                </a-col>
                <a-col :span="twoColSpan*2">
                  <a-form-model-item label="维修结果描述" prop="repairDescription">
                    <a-textarea :readOnly="disableSubmit||tableRowRecord.repairStatus!=='UNDER_REPAIR'"
                                v-model="tableRowRecord.repairDescription"
                                placeholder="请输入维修结果描述"/>
                  </a-form-model-item>
                </a-col>
                <a-col :span="twoColSpan*2">
                  <a-form-model-item label="维修图片">
                    <lx-upload :returnUrl="false" :isMultiple="true" file-type="image" :number="3"
                               :disabled="disableSubmit||tableRowRecord.repairStatus!=='UNDER_REPAIR'"
                               v-model="tableRowRecord.imageFiles"/>
                  </a-form-model-item>
                </a-col>
              </template>
            </a-row>
          </a-tab-pane>
          <template v-if="selectShenpiData.procInstId">
            <a-tab-pane key='2' tab='流程节点'>
              <a-card :bordered="false">
                <a-timeline>
                  <a-timeline-item v-for="(item,index) in hitaskDataSource" :key="index">
                    <div>
                      <h3 style="font-weight: bold;">{{item.taskName}}</h3>
                      <div>处理人:{{item.assignee_dictText}}</div>
                      <div v-if="index !==0">处理时长:{{item.duration}}</div>
                      <div v-if="item.name !== '提交申请'">处理类型:{{item.sequenceFlowName}}</div>
                      <div v-if="item.description">处理意见:{{item.description}}</div>
                    </div>
                  </a-timeline-item>
                </a-timeline>
              </a-card>
            </a-tab-pane>
            <a-tab-pane key='3' tab='流程图'>
              <img :src="imageSrc" alt="Fetched Image"/>-->
            </a-tab-pane>
          </template>
        </a-tabs>
        <template v-if="tableRowRecord.isUseSpare===1&&isDisableUseSpare">
          <a-divider orientation="center" style="font-size: large;font-style: italic;color: #66aeed;">管理员领用备件
          </a-divider>
          <a-row>
            <a-col :span="24">
              <a-form-model-item label="是否需要领用备件" prop="status">
                <a-radio-group v-model="approveData.status">
                  <a-radio :value="1">是</a-radio>
                  <a-radio :value="0">否</a-radio>
                </a-radio-group>
            <a-col :span="twoColSpan*2">
              <a-form-model-item prop="sparePartDescription" label="备件描述">
                <a-textarea placeholder="请输入备件描述" :readOnly="disableSubmit||tableRowRecord.repairStatus!=='WAIT_SPARES'"
                            v-model="tableRowRecord.sparePartDescription"></a-textarea>
              </a-form-model-item>
            </a-col>
            <template v-if="approveData.status===0">
              <a-col :span="24">
                <a-form-model-item label="故障原因" prop="faultReason">
                  <a-input v-model="approveData.faultReason" rows="4" placeholder="请输入故障原因"/>
                </a-form-model-item>
              </a-col>
              <a-col :span="24">
                <a-form-model-item label="维修结果描述" prop="repairResultDescription">
                  <a-textarea v-model="approveData.repairResultDescription" placeholder="请输入维修结果描述"/>
                </a-form-model-item>
              </a-col>
              <a-col :span="24">
                <a-form-model-item label="维修图片">
                  <j-image-upload v-model="approveData.imageFiles" :is-multiple="true" :number="3"/>
                </a-form-model-item>
              </a-col>
            </template>
          </a-row>
        </a-form-model>
      </div>
    </a-card>
        </template>
    <template slot="footer">
      <div>
        <a-button @click="handCancel">取消</a-button>
        <a-button @click="submitForm" type="primary">提 交</a-button>
      </div>
    </template>
  </a-modal>
        <template v-if="Boolean(tableRowRecord.sparePartDescription)&&isDisplayRepairResult">
          <a-divider orientation="center" style="font-size: large;font-style: italic;color: #66aeed;">维修结果上报</a-divider>
          <a-row>
            <a-col :span="twoColSpan*2">
              <a-form-model-item label="故障原因" prop="faultReason">
                <a-input :readOnly="disableSubmit||isDisableSubmitRepairResult" v-model="tableRowRecord.faultReason"
                         rows="4" placeholder="请输入故障原因"/>
              </a-form-model-item>
            </a-col>
          </a-row>
          <a-row>
            <a-col :span="twoColSpan*2">
              <a-form-model-item label="维修结果描述" prop="repairDescription">
                <a-textarea :readOnly="disableSubmit||isDisableSubmitRepairResult"
                            v-model="tableRowRecord.repairDescription"
                            placeholder="请输入维修结果描述"/>
              </a-form-model-item>
            </a-col>
          </a-row>
          <a-row>
            <a-col :span="twoColSpan*2">
              <a-form-model-item label="维修图片">
                <lx-upload :disabled="disableSubmit||isDisableSubmitRepairResult" :returnUrl="false" :isMultiple="true"
                           file-type="image" :number="3"
                           v-model="tableRowRecord.imageFiles"/>
              </a-form-model-item>
            </a-col>
          </a-row>
        </template>
      </a-form-model>
    </a-spin>
  </j-modal>
</template>
<script>
  import '@assets/less/TableExpand.less'
  import { getAction, deleteAction, postAction, downFile, httpAction } from '@api/manage'
  import LxSearchEquipmentSelect from '../../../eam/equipment/modules/LxSearchEquipmentSelect'
  export default {
    name: 'RepairOrderApprovalModal',
    components: { LxSearchEquipmentSelect },
    props: {
      selectShenpiData: {
        type: Object,
@@ -143,61 +227,97 @@
    },
    data() {
      return {
        form: this.$form.createForm(this),
        span: 12,
        title: '',
        threeColSpan: 8,
        twoColSpan: 12,
        inputReadOnly: true,
        disableSubmit: false,
        confirmLoading: false,
        spinning: false,
        tableRowRecord: {},
        assignFileStream: {},
        hitaskDataSource: [],
        imageSrc: null,
        activeTabKey: '1',
        labelCol: {
          xs: { span: 24 },
          sm: { span: 5 }
          sm: { span: 6 }
        },
        wrapperCol: {
          xs: { span: 24 },
          sm: { span: 16 }
        },
        labelColLong: {
          xs: { span: 24 },
          sm: { span: 2 }
        },
        wrapperColLong: {
          xs: { span: 24 },
          sm: { span: 20 }
        },
        validatorRules: {
          status: [
          isUseSpare: [
            { required: true, message: '请选择是否需要领用备件' }
          ],
          sparePartDescription: [
            { required: true, message: '请输入备件描述' }
          ],
          faultReason: [
            { required: true, message: '请输入故障原因' }
          ],
          repairResultDescription: [
          repairDescription: [
            { required: true, message: '请输入维修结果描述' }
          ]
        },
        approveData: {},
        flowData: {},
        visible: false,
        // 表头
        url: {
          queryBomDataById: '/eam/eamRepairOrder/queryById',
          diagramView: '/assign/flow/diagramView',
          queryHisTaskList: '/assign/flow/queryHisTaskList',
          approve: '/activit/assign/file/approve'
        },
        isDisplayBmp: false,
        showBmpButtonLoading: false
          approve: '/eam/eamRepairOrder/perform'
        }
      }
    },
    created() {
    computed: {
      isDisableUseSpare() {
        return this.disableSubmit || this.tableRowRecord.repairStatus !== 'UNDER_REPAIR' || Boolean(this.tableRowRecord.sparePartDescription)
      },
      isDisplayRepairResult() {
        return ['UNDER_REPAIR', 'WAIT_CONFIRM', 'COMPLETE'].includes(this.tableRowRecord.repairStatus)
      },
      isDisableSubmitRepairResult() {
        return ['WAIT_CONFIRM', 'COMPLETE'].includes(this.tableRowRecord.repairStatus)
      }
    },
    methods: {
      /**
       * 获取待办记录的基本信息
       * 获取流程节点和流程图
       * @param record 待办记录信息
       */
      getAllApproveData(record) {
        console.log('selectShenpiData----->', this.selectShenpiData)
        this.flowData = Object.assign({}, record)
        const param = { 'procInstId': record.dataId }
        if (!record.procInstId) return
        console.log('record----->', record)
        const { procInstId, processDefinitionId, processInstanceId, processDefinitionKey } = record
        const param = { procInstId }
        const imageParam = { processDefinitionId, processInstanceId, TaskDefinitionKey: processDefinitionKey }
        const that = this
        getAction(this.url.queryHisTaskList, param)
          .then(res => {
            this.hitaskDataSource = res.result
            that.hitaskDataSource = res.result
          })
        downFile(this.url.diagramView, imageParam, 'get')
          .then((res => {
            const urlObject = window.URL.createObjectURL(new Blob([res]))
            that.imageSrc = urlObject
          }))
          .catch(err => {
            that.$notification.error({
              message: '消息',
              description: res.message
            })
          })
      },
@@ -209,11 +329,16 @@
        this.spinning = true
        const that = this
        const param = { id: record.dataId }
        this.tableRowRecord = this.approveData = {}
        this.tableRowRecord = {}
        this.activeTabKey = '1'
        getAction(this.url.queryBomDataById, param)
          .then((res => {
            if (res.success) {
              that.tableRowRecord = res.result
              that.tableRowRecord = Object.assign({}, res.result, {
                isUseSpare: res.result.isUseSpare === null ? 0 : res.result.isUseSpare,
                imageFiles: JSON.parse(res.result.imageFiles),
                reportImageFiles: JSON.parse(res.result.reportImageFiles)
              })
              console.log('this.tableRowRecord----->', that.tableRowRecord)
            }
          }))
@@ -222,61 +347,41 @@
          })
      },
      // 获取并展开流程图
      fetchAndShowBmp() {
        this.isDisplayBmp = !this.isDisplayBmp
        if (!this.imageSrc) {
          this.showBmpButtonLoading = true
          const that = this
          let param = {
            processDefinitionId: this.flowData.processDefinitionId,
            processInstanceId: this.flowData.processInstanceId,
            TaskDefinitionKey: this.flowData.processDefinitionKey
          }
          downFile(this.url.diagramView, param, 'get')
            .then((res => {
              const urlObject = window.URL.createObjectURL(new Blob([res]))
              this.imageSrc = urlObject
            }))
            .catch(err => {
              that.$notification.error({
                message: '消息',
                description: res.message
              })
            })
            .finally(() => {
              this.showBmpButtonLoading = false
            })
        }
      },
      submitForm() {
        const that = this
        // 触发表单验证
        this.$refs.form.validate(valid => {
          if (valid) {
            that.confirmLoading = true
            that.confirmLoading = that.spinning = true
            const { isUseSpare, faultReason, repairDescription, sparePartDescription, imageFiles, equipmentId } = that.tableRowRecord
            const { dataId, id, procInstId, taskDefKey, variables } = that.selectShenpiData
            const flowTaskVo = {}
            flowTaskVo.status = that.approveData.status
            flowTaskVo.approveContent = flowTaskVo.comment = that.approveData.approveContent
            flowTaskVo.dataId = this.selectShenpiData.dataId
            flowTaskVo.taskId = this.selectShenpiData.id
            flowTaskVo.userId = flowTaskVo.assignee = this.selectShenpiData.assignee
            flowTaskVo.instanceId = this.selectShenpiData.procInstId
            flowTaskVo.targetKey = this.selectShenpiData.taskDefKey
            flowTaskVo.values = this.selectShenpiData.variables
            flowTaskVo.isUseSpare = isUseSpare
            flowTaskVo.faultReason = faultReason
            flowTaskVo.repairDescription = repairDescription
            flowTaskVo.sparePartDescription = sparePartDescription
            flowTaskVo.imageFilesResult = imageFiles
            flowTaskVo.equipmentId = equipmentId
            flowTaskVo.id = dataId
            flowTaskVo.dataId = dataId
            flowTaskVo.taskId = id
            flowTaskVo.instanceId = procInstId
            flowTaskVo.targetKey = taskDefKey
            flowTaskVo.values = variables
            console.log('表单提交数据', flowTaskVo)
            // httpAction(this.url.approve, flowTaskVo, 'post')
            //   .then((res) => {
            //     if (res.success) {
            //       that.$message.success(res.message)
            //       that.$emit('ok')
            //     } else {
            //       that.$message.warning(res.message)
            //     }
            //   }).finally(() => {
            //   that.confirmLoading = false
            // })
            httpAction(this.url.approve, flowTaskVo, 'post')
              .then((res) => {
                if (res.success) {
                  that.$message.success(res.message)
                  that.handCancel()
                  that.$emit('searchReset')
                } else {
                  that.$message.warning(res.message)
                }
              }).finally(() => {
              that.confirmLoading = that.spinning = false
            })
          } else {
            return false
          }
@@ -285,52 +390,8 @@
      handCancel() {
        this.visible = false
        this.isDisplayBmp = false
        this.imageSrc = null
        if (this.$refs.form) this.$refs.form.clearValidate()
      }
    }
  }
</script>
<style scoped>
  .shallow-hr {
    border: 0;
    height: 1px; /* 分界线的高度 */
    background-color: rgba(0, 0, 0, 0.1); /* 使用 RGBA 颜色,并设置较低的透明度 */
    margin: 20px 0; /* 分界线上下的外边距 */
  }
  .btn-custom {
    background-color: #4CAF50; /* 绿色背景 */
    color: #fff; /* 白色文字 */
  }
  .left_qiu {
    position: absolute;
    left: -74px;
    top: 0;
    width: 54px;
    border-radius: 50%;
    height: 54px;
    font-size: 13px;
    margin: auto;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    background: #0099ff;
    transform: translate(0, 0);
  }
  /deep/ .ant-timeline-item-tail {
    left: -29px !important;
  }
  .left_qiu span {
    width: 3em;
    display: block;
    color: #fff;
    text-align: center;
  }
  @import '~@assets/less/common.less';
</style>
</script>