src/views/flowable/workflow/repairOrder/RepairOrderApprovalModal.vue
@@ -1,337 +1,341 @@
<template>
  <a-modal
    :title="title"
    :width="width"
    :width="1200"
    :visible="visible"
    :footer="null"
    :title="title"
    @cancel="handCancel"
    @ok="submitForm"
    :mask-closable="false"
    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>
        <button @click="fetchAndShowBmp" class="btn-custom">打开流程图</button>
        <div v-if="imageSrc">
          <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' @change='callback'>
              <a-tab-pane key='1' tab='基本信息'>
                <a-form-model ref='form' :model='tableRowRecord' :rules='validatorRules'>
                  <a-row>
                    <a-col :span='span'>
                      <a-form-model-item label='产品名称' :labelCol='labelCol' :wrapperCol='wrapperCol' prop='productName'>
                        <a-input :disabled='coldisabled' v-model='tableRowRecord.productName'></a-input>
                      </a-form-model-item>
                    </a-col>
                    <a-col :span='span'>
                      <a-form-model-item label='部件名称' :labelCol='labelCol' :wrapperCol='wrapperCol' prop='componentId'>
                        <a-input :disabled='coldisabled' v-model='tableRowRecord.componentName'></a-input>
                      </a-form-model-item>
                    </a-col>
                  </a-row>
                </a-form-model>
              </a-tab-pane>
              <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>
        <a-form-model ref="form" :model="approveData" :rules="validatorRules" slot="detail">
    <a-spin :spinning="spinning">
      <a-form-model :model='tableRowRecord' :rules='validatorRules' :labelCol='labelCol'
                    :wrapperCol='wrapperCol'>
        <a-divider orientation="center" style="font-size: large;font-style: italic;color: #66aeed;">报修基础信息</a-divider>
        <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='设备编号'>
              <lx-search-equipment-select disabled v-model='tableRowRecord.equipmentId'/>
            </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-row>
        <a-row>
          <a-col :span='threeColSpan'>
            <a-form-model-item label='维修负责人'>
              <a-input :readOnly='inputReadOnly' v-model='tableRowRecord.repairer'/>
            </a-form-model-item>
          </a-col>
          <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='threeColSpan*3'>
            <a-form-model-item label='报修图片' :labelCol='labelColLong' :wrapperCol='wrapperColLong'>
              <j-image-upload v-model="tableRowRecord.imageFiles" disabled :is-multiple="true" :number="3"/>
            </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-form-model ref="form" :model="approveData" :rules="validatorRules" :labelCol='labelCol'
                          :wrapperCol='wrapperCol'>
              <a-row>
                <a-col :span="twoColSpan*2">
                  <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-form-model-item>
                </a-col>
                <template v-if="approveData.status===0">
                  <a-col :span="twoColSpan*2">
                    <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="twoColSpan*2">
                    <a-form-model-item label="维修结果描述" prop="repairResultDescription">
                      <a-textarea v-model="approveData.repairResultDescription" placeholder="请输入维修结果描述"/>
                    </a-form-model-item>
                  </a-col>
                  <a-col :span="twoColSpan*2">
                    <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>
          </a-tab-pane>
          <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>
        </a-tabs>
        <template>
          <a-divider orientation="center" style="font-size: large;font-style: italic;color: #66aeed;">管理员领用备件
          </a-divider>
          <a-row>
            <a-col :span="24" class="btxx">
              <a-form-item label="审批状态" :labelCol="labelCol" :wrapperCol="wrapperCol">
                <j-dict-select-tag  type='list' v-model='assignFileStream.status' dictCode='dnc_assign_stream_status' placeholder="请选择审批状态"  />
              </a-form-item>
            <a-col :span="twoColSpan">
              <a-form-model-item prop="confirmDealType" label="处理类型">
                <j-dict-select-tag type='radio' v-model='tableRowRecord.confirmDealType' dictCode='approved_rejected'
                                   :disabled="disableSubmit||tableRowRecord.inspectionStatus!=='WAIT_CONFIRM'"
                                   placeholder="请选择处理类型"/>
              </a-form-model-item>
            </a-col>
            <a-col :span="24" class="btxx">
              <a-form-model-item  label="审批意见" :labelCol="labelCol" :wrapperCol="wrapperCol">
                <a-textarea v-model="assignFileStream.approveContent" rows="4" placeholder="请输入审批意见"/>
              </a-form-model-item >
            <a-col :span="twoColSpan">
              <a-form-model-item prop="confirmComment" label="处理意见">
                <a-textarea placeholder="请输入处理意见"
                            :disabled="disableSubmit||tableRowRecord.inspectionStatus!=='WAIT_CONFIRM'"
                            v-model="tableRowRecord.confirmComment"/>
              </a-form-model-item>
            </a-col>
          </a-row>
          <div class="table-operator" style="text-align: right;">
            <a-button  @click="handleQueXiaoTask" type="primary" icon="close">取消</a-button>
            <a-button @click="submitForm">提 交</a-button>
          </div>
        </a-form-model>
      </div>
    </a-card>
        </template>
      </a-form-model>
    </a-spin>
  </a-modal>
</template>
<script>
  import '@assets/less/TableExpand.less'
  import { getAction, deleteAction, postAction, downFile, httpAction } from '@api/manage'
  import LxSearchEquipmentSelect from '../../../eam/equipment/modules/LxSearchEquipmentSelect'
import '@assets/less/TableExpand.less'
import { mixinDevice } from '@/utils/mixin'
import { getAction, deleteAction, postAction, downFile, httpAction } from '@api/manage'
export default {
  name: 'RepairOrderApprovalModal',
  mixins: [mixinDevice],
  props: {
    selectShenpiData: {
      type: Object,
      required: true
    }
  },
  data() {
    return {
      form: this.$form.createForm(this),
      span: 12,
      span1: 8,
      coldisabled: true,
      spinning: false,
      tableRowRecord: {},
      assignFileStream:{},
      tableDataSource: [],
      usageDataSource: [],
      hitaskDataSource:[],
      bomForm: {},
      approveContent:"",
      imageSrc: null,
      drawerVisible: true,
      labelCol: {
        xs: { span: 24 },
        sm: { span: 5 }
      },
      wrapperCol: {
        xs: { span: 30 },
        sm: { span: 16 }
      },
      validatorRules: {
      },
      approveData: {},
      flowData: {},
      title: '',
      width: 1000,
      visible: false,
      // 表头
      url: {
        queryBomDataById: '/eam/eamRepairOrder/queryById',
        diagramView: '/assign/flow/diagramView',
        queryHisTaskList:'/assign/flow/queryHisTaskList',
        approve:"/activit/assign/file/approve",
      },
      dictOptions: {},
      superFieldList: [],
      workflowSource: []
    }
  },
  created() {
  },
  computed: {},
  methods: {
    callback() {
  export default {
    name: 'RepairOrderApprovalModal',
    components: { LxSearchEquipmentSelect },
    props: {
      selectShenpiData: {
        type: Object,
        required: true
      }
    },
    handCancel() {
      this.visible = false
    },
    clearTableSource() {
      this.tableDataSource = []
      this.usageDataSource = []
    },
    fetchAndShowBmp() {
      console.log('flowData----->', this.flowData)
      try {
        let parm = {
          processDefinitionId: this.flowData.processDefinitionId,
          processInstanceId:this.flowData.processInstanceId,
          TaskDefinitionKey:this.flowData.processDefinitionKey
    data() {
      return {
        title: '',
        form: this.$form.createForm(this),
        threeColSpan: 8,
        twoColSpan: 12,
        inputReadOnly: true,
        disableSubmit: false,
        spinning: false,
        tableRowRecord: {},
        hitaskDataSource: [],
        imageSrc: null,
        activeTabKey: '1',
        labelCol: {
          xs: { span: 24 },
          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: [
            { required: true, message: '请选择是否需要领用备件' }
          ],
          faultReason: [
            { required: true, message: '请输入故障原因' }
          ],
          repairResultDescription: [
            { required: true, message: '请输入维修结果描述' }
          ]
        },
        approveData: {},
        visible: false,
        // 表头
        url: {
          queryBomDataById: '/eam/eamRepairOrder/queryById',
          diagramView: '/assign/flow/diagramView',
          queryHisTaskList: '/assign/flow/queryHisTaskList',
          approve: '/activit/assign/file/approve'
        }
        downFile(this.url.diagramView,parm,'get').then((res=>{
          console.log('Pica------>',res)
          const urlObject = window.URL.createObjectURL(new Blob([res]))
          this.imageSrc = urlObject
        }))
      } catch (error) {
        console.error('Error fetching image blob:', error)
        alert('无法加载图片,请稍后再试。')
      }
    },
    handleQueXiaoTask(){
      this.visible = false
      this.routeReload()
    },
    submitForm () {
      const that = this;
      if (!that.assignFileStream.status==null || that.assignFileStream.status===undefined){
        this.$message.warning('请选择审批状态!')
        return false;
      }
      if (!that.assignFileStream.approveContent==null || that.assignFileStream.approveContent===undefined) {
        this.$message.warning('请输入审批意见!')
        return false;
      }
      // 触发表单验证
      this.form.validateFields((err, values) => {
        if (!err) {
          that.confirmLoading = true;
          let url=this.url.approve
          let method = 'post';
          let flowTaskVo = {}
          flowTaskVo.status=that.assignFileStream.status;
          flowTaskVo.approveContent =that.assignFileStream.approveContent;
          flowTaskVo.comment =that.assignFileStream.approveContent;
          flowTaskVo.secretLevel = that.assignFileStream.secretLevel;
          flowTaskVo.dataId = this.selectShenpiData.dataId
          flowTaskVo.taskId = this.selectShenpiData.id
          flowTaskVo.userId = this.selectShenpiData.assignee
          flowTaskVo.instanceId = this.selectShenpiData.procInstId
          flowTaskVo.targetKey = this.selectShenpiData.taskDefKey
          flowTaskVo.values = this.selectShenpiData.variables
          flowTaskVo.assignee = this.selectShenpiData.assignee
          flowTaskVo.secretLevel = that.assignFileStream.secretLevel;
          console.log("表单提交数据",flowTaskVo)
          httpAction(url,flowTaskVo,method).then((res)=>{
            if(res.success){
              that.$message.success(res.message);
              that.$emit('ok');
            }else{
              that.$message.warning(res.message);
            }
          }).finally(() => {
            that.confirmLoading = false;
    methods: {
      /**
       * 获取流程节点和流程图
       * @param record 待办记录信息
       */
      getAllApproveData(record) {
        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 => {
            that.hitaskDataSource = res.result
          })
        }
      })
    },
    getAllApproveData(item) {
      console.log('selectShenpiData----->', this.selectShenpiData)
      this.flowData = item
      let param = {
        'id': item.dataId
      }
      let parmhis={
        'procInstId': item.dataId
      }
      getAction(this.url.queryHisTaskList,parmhis).then(res=>{
        this.hitaskDataSource=res.result
        getAction(this.url.queryBomDataById, param).then((res => {
          if (res.success) {
            this.tableRowRecord = res.result
            console.log('this.tableRowRecord----->', this.tableRowRecord)
        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
            })
          })
      },
      /**
       * 获取待办记录的基本信息
       * @param record 待办记录信息
       */
      getBasicInformation(record) {
        this.spinning = true
        const that = this
        const param = { id: record.dataId }
        this.tableRowRecord = {}
        this.approveData = { status: 0 }
        this.activeTabKey = '1'
        getAction(this.url.queryBomDataById, param)
          .then((res => {
            if (res.success) {
              that.tableRowRecord = res.result
              console.log('this.tableRowRecord----->', that.tableRowRecord)
            }
          }))
          .finally(() => {
            that.spinning = false
          })
      },
      submitForm() {
        const that = this
        // 触发表单验证
        this.$refs.form.validate(valid => {
          if (valid) {
            that.confirmLoading = true
            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
            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
            // })
          } else {
            return false
          }
        }))
      }).finally(
        this.visible = true,
        console.log('this.approveData---->', this.approveData)
      )
        })
      },
      handCancel() {
        this.visible = false
        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: white; /* 白色文字 */
  border: none; /* 无边框 */
  padding: 5px 15px; /* 内边距 */
  text-align: center; /* 文字居中 */
  text-decoration: none; /* 无下划线 */
  display: inline-block; /* 行内块元素 */
  font-size: 12px; /* 字体大小 */
  margin: 4px 2px; /* 外边距 */
  cursor: pointer; /* 鼠标悬停时显示手型 */
  border-radius: 4px; /* 圆角边框 */
}
  .btn-custom {
    background-color: #4CAF50; /* 绿色背景 */
    color: #fff; /* 白色文字 */
  }
.bold-large-label {
  font-weight: bold;
  font-size: 20px; /* 或你需要的任何大小 */
}
.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;
}
.img{
  width: 75%;
}
  .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);
  }
.wrap{
  clear: both;
  width: 100%;
  display: flex;
  height: 50px;
  border: 1px solid #ccc;
  /* background-color: aqua; */
}
.box{
  width:21%;
  height:50px;
  border-right: 1px solid #ccc;
  line-height: 50px;
  /* background: red; */
  text-align:center;
  margin: auto;
}
  /deep/ .ant-timeline-item-tail {
    left: -29px !important;
  }
@import '~@assets/less/common.less';
  .left_qiu span {
    width: 3em;
    display: block;
    color: #fff;
    text-align: center;
  }
  @import '~@assets/less/common.less';
</style>