zhaowei
2025-07-12 27d08b2283f88330cc3d282852898ba71c2cbb2b
src/views/flowable/workflow/thirdMaintenance/ThirdMaintenanceApprovalModal.vue
@@ -1,94 +1,72 @@
<template>
  <j-modal
    :title="title"
    :width="1200"
    :visible="visible"
    :confirmLoading="confirmLoading"
    :okButtonProps="{ class:{'jee-hidden': disableSubmit} }"
    switchFullscreen
    @ok="handleOk"
    @cancel="handleCancel"
    centered
    cancelText="关闭">
  <j-modal :title="title" :visible="visible" :confirmLoading="confirmLoading"
           :okButtonProps="{ class:{'jee-hidden': disableSubmit} }" fullscreen @ok="handleOk" @cancel="handleCancel"
           centered cancelText="关闭">
    <a-spin :spinning="spinning">
      <a-form-model ref="form" :model="model" :rules="validatorRules">
        <a-divider orientation="center" style="font-size: large;font-style: italic;color: #66aeed;"> 保养基础信息
        </a-divider>
      <a-form-model ref="form" :model="model" :rules="validatorRules" :labelCol="labelCol" :wrapperCol="wrapperCol">
        <a-row :gutter="24">
          <a-col :span="8">
            <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="orderNum" label="工单号">
              <a-input placeholder="工单号系统自动生成" v-model="model.orderNum" disabled/>
            <a-tabs>
              <a-tab-pane tab="基础信息">
                <a-row>
                  <a-col :span="12">
                    <a-form-model-item label="工单号">
                      <a-input v-model="model.orderNum" readOnly/>
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="equipmentId" label="设备编码">
              <maintenance-equipment-select placeholder="请输入设备编号或名称搜索" v-model="model.equipmentId"
                                            :maintenanceCategory="maintenanceCategory"
                                            @autocompleteForm="autocompleteForm"
                                            disabled></maintenance-equipment-select>
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="standardName" label="标准名称">
              <a-input placeholder="选择设备后自动带出" v-model="model.standardName" disabled/>
                  <a-col :span="12">
                    <a-form-model-item label="统一编码">
                      <maintenance-equipment-select v-model="model.equipmentId" maintenanceCategory="SECOND_MAINTENANCE"
                                                    @autocompleteForm="autocompleteForm" disabled/>
            </a-form-model-item>
          </a-col>
        </a-row>
        <a-row :gutter="24">
          <a-col :span="8">
            <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="maintenanceDate" label="保养日期">
              <a-date-picker placeholder="请选择计划保养日期" v-model="model.maintenanceDate" format="YYYY-MM-DD"
                             disabled
                             style="width: 100%"/>
                <a-row>
                  <a-col :span="12">
                    <a-form-model-item label="规范名称">
                      <a-input v-model="model.standardName" readOnly/>
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="operator" label="保养人">
              <j-search-select-tag v-model="model.operator" placeholder="请选择保养人" disabled
                                   :dictOptions="maintenanceOperatorOptions"/>
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="maintenancePeriod" label="保养周期">
              <a-input placeholder="选择设备后自动带出" v-model="model.maintenancePeriod" disabled/>
                  <a-col :span="12">
                    <a-form-model-item label="保养日期">
                      <a-input v-model="model.maintenanceDate" readOnly/>
            </a-form-model-item>
          </a-col>
        </a-row>
        <a-row :gutter="24">
          <a-form-model-item :labelCol="labelColLong" :wrapperCol="wrapperColLong" prop="remark" label="备注">
            <a-textarea placeholder="请输入备注" v-model="model.remark" disabled/>
                <a-row>
                  <a-col :span="12">
                    <a-form-model-item label="保养人">
                      <a-input v-model="model.operator" readOnly/>
          </a-form-model-item>
        </a-row>
        <a-row :gutter="24">
          <a-form-model-item :labelCol="labelColLong" :wrapperCol="wrapperColLong" label="保养图片">
            <lx-upload :returnUrl="false"
                       :isMultiple="true"
                       file-type="image"
                       :disabled="confirmDisable"
                       :number="3"
                       v-model="model.imageFilesResult"/>
                  </a-col>
                  <a-col :span="12">
                    <a-form-model-item label="保养周期">
                      <a-input v-model="model.maintenancePeriod" readOnly/>
          </a-form-model-item>
                  </a-col>
        </a-row>
        <a-divider orientation="center" style="font-size: large;font-style: italic;color: #66aeed;"> 保养项信息
        </a-divider>
        <a-row :gutter="24">
                <a-row>
                  <a-col :span="24">
                    <a-form-model-item :labelCol="labelColLong" :wrapperCol="wrapperColLong" label="备注">
                      <a-textarea v-model="model.remark" readOnly/>
                    </a-form-model-item>
                  </a-col>
                </a-row>
              </a-tab-pane>
            </a-tabs>
          </a-col>
          <a-col :span="10">
          <a-tabs v-model="activeTabKey">
            <a-tab-pane key="1" tab="保养项明细" v-if="!isPrecisionCheck">
              <j-vxe-table
                ref="editableDetailTable"
                :rowNumber="false"
                :rowSelection="true"
                :bordered="true"
                :alwaysEdit="true"
                :toolbar="false"
                keep-source
                :height="300"
                :loading="detail.loading"
                :dataSource="detail.dataSource"
                :columns="detail.columns"
                @selectRowChange="handleTableSelectRowChange"
              >
                <j-vxe-table ref="editableDetailTable" :rowNumber="false" :rowSelection="true" :bordered="true"
                             :alwaysEdit="true" :toolbar="false" keep-source :height="300" :loading="detail.loading"
                             :dataSource="detail.dataSource" :columns="detail.columns"
                             @selectRowChange="handleTableSelectRowChange">
                <template v-slot:maintenanceResult="props">
                  <j-dict-select-tag v-model="props.row.maintenanceResult" dictCode="eam_inspection_result"
                                     placeholder="请选择保养结果"
@@ -110,75 +88,39 @@
                </template>
              </j-vxe-table>
            </a-tab-pane>
            <a-tab-pane key='4' tab='精度检验' v-if="!isMaintenance">
              <j-vxe-table
                ref="editablePrecisionDetailTable"
                :rowNumber="true"
                :rowSelection="true"
                :bordered="true"
                :alwaysEdit="true"
                :toolbar="false"
                :toolbarConfig="precisionDetail.toolbarConfig"
                keep-source
                :height="300"
                :dataSource="precisionDetail.dataSource"
                :columns="precisionDetail.columns"
                style="margin-top: 8px;" >
                <template v-slot:actualValue="props">
                  <a-input-number v-model="props.row.actualValue" :disabled="disableSubmit || confirmDisable" style="width: 100%" />
                </template>
              </j-vxe-table>
            </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 taskData" :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='流程图'>
                <a-tab-pane key='2' tab='流程图'>
                <img :src="imageSrc" alt="Fetched Image"/>
              </a-tab-pane>
            </template>
            <a-button v-if="!disableSubmit &&!confirmDisable&& selectedRowKeys.length > 0" slot="tabBarExtraContent"
                      type="primary" @click="handleSelectAllInspectionResult">保养正常
              <a-button :disabled="disableSubmit ||confirmDisable||selectedRowKeys.length > 0" slot="tabBarExtraContent"
                        type="primary" @click="handleSelectAllInspectionResult">批量保养正常
            </a-button>
          </a-tabs>
        </a-row>
        <div v-if="confirmDisable">
          <a-divider orientation="center" style="font-size: large;font-style: italic;color: #66aeed;"> 机动办确认信息
          </a-divider>
          <a-row :gutter="24">
            <a-col :span="24">
              <a-form-model-item :labelCol="labelColLong" :wrapperCol="wrapperColLong" prop="confirmComment" label="确认意见">
          </a-col>
          <a-col :span="6">
            <a-tabs v-if="confirmDisable">
              <a-tab-pane tab="确认">
                <a-form-model-item :labelCol="labelColLong" :wrapperCol="wrapperColLong" prop="confirmComment"
                                   label="确认意见">
                <a-textarea placeholder="请输入意见" v-model="model.confirmComment"
                            :disabled="disableSubmit || leaderConfirmDisable"/>
              </a-form-model-item>
            </a-col>
          </a-row>
        </div>
        <div v-if="leaderConfirmDisable">
          <a-divider orientation="center" style="font-size: large;font-style: italic;color: #66aeed;"> 领导确认信息
          </a-divider>
          <a-row :gutter="24">
            <a-col :span="24">
              </a-tab-pane>
            </a-tabs>
            <a-tabs v-if="leaderConfirmDisable">
              <a-tab-pane tab="领导确认">
              <a-form-model-item :labelCol="labelColLong" :wrapperCol="wrapperColLong" prop="leaderConfirmComment"
                                 label="领导意见">
                <a-textarea placeholder="请输入意见" v-model="model.leaderConfirmComment"
                            :disabled="disableSubmit || completionDisable"/>
              </a-form-model-item>
              </a-tab-pane>
            </a-tabs>
            </a-col>
          </a-row>
        </div>
      </a-form-model>
    </a-spin>
  </j-modal>
@@ -205,15 +147,7 @@
      return {
        title: '操作',
        visible: false,
        //状态控制
        //保养中 不可编辑
        // confirmDisable: false,
        // initialAcceptanceDisable: false,
        // finalAcceptanceDisable: false,
        editable: false,
        model: {},
        maintenanceCategory: 'SECOND_MAINTENANCE',
        maintenanceOperatorOptions: [],
        labelCol: {
          xs: { span: 24 },
          sm: { span: 6 }
@@ -224,11 +158,11 @@
        },
        labelColLong: {
          xs: { span: 24 },
          sm: { span: 2 }
          sm: { span: 3 }
        },
        wrapperColLong: {
          xs: { span: 24 },
          sm: { span: 21 }
          sm: { span: 20 }
        },
        confirmLoading: false,
        spinning: false,
@@ -240,24 +174,18 @@
          ],
          leaderConfirmComment: [
            { required: true, message: '请输入初验收意见!' }
          ],
          ]
        },
        url: {
          queryById: '/eam/thirdMaintenanceOrder/queryById',
          detail: '/eam/thirdMaintenanceOrderDetail/queryList',
          approval: '/eam/thirdMaintenanceOrder/approval',
          userSelect: '/eam/user_select/list',
          queryHisTaskList: '/assign/flow/queryHisTaskList',
          diagramView: '/assign/flow/diagramView',
          precisionCheckDetail: '/eam/precisionCheckDetail/queryList',
          diagramView: '/assign/flow/diagramView'
        },
        disableSubmit: false,
        taskData: [],
        isDisplayBmp: false,
        showBmpButtonLoading: false,
        selectedRowKeys: [],
        detail: {
          loading: false,
          dataSource: [],
          columns: [
            {
@@ -274,28 +202,31 @@
              title: '序号',
              key: 'itemCode',
              type: JVXETypes.normal,
              width: '5%',
              width: 60,
              align: 'center'
            },
            {
              title: '保养项',
              title: '保养部位',
              key: 'itemPart',
              type: JVXETypes.normal,
              align: 'center'
            },
            {
              title: '保养内容',
              key: 'itemName',
              type: JVXETypes.normal,
              width: '10%',
              align: 'center'
            },
            {
              title: '保养要求',
              title: '验收标准',
              key: 'itemDemand',
              type: JVXETypes.normal,
              width: '20%',
              align: 'center'
            },
            {
              title: '保养结果',
              key: 'maintenanceResult',
              type: JVXETypes.slot,
              width: '10%',
              align: 'center',
              slotName: 'maintenanceResult',
              validateRules: [
@@ -306,7 +237,6 @@
              title: '异常描述',
              key: 'exceptionDescription',
              type: JVXETypes.slot,
              width: '20%',
              align: 'center',
              slotName: 'exceptionDescription',
              validateRules: [
@@ -317,88 +247,15 @@
              title: '是否报修',
              key: 'reportFlag',
              type: JVXETypes.slot,
              width: '10%',
              align: 'center',
              slotName: 'reportFlag',
              validateRules: [
                { handler: this.customValidator }
              ]
            }
          ],
          toolbarConfig: {
            // prefix 前缀;suffix 后缀
            slot: ['prefix', 'suffix'],
            // add 新增按钮;remove 删除按钮;clearSelection 清空选择按钮
            btn: ['clearSelection']
          }
        },
        precisionDetail: {
          loading: false,
          dataSource: [],
          columns: [
            {
              title: 'ID',
              key: 'id',
              type: JVXETypes.hidden
            },
            {
              title: 'orderId',
              key: 'orderId',
              type: JVXETypes.hidden
            },
            {
              title: 'equipmentId',
              key: 'equipmentId',
              type: JVXETypes.hidden
            },
            {
              title: 'parameterId',
              key: 'parameterId',
              type: JVXETypes.hidden
            },
            {
              title: '检测项目',
              key: 'parameterId_dictText',
              type: JVXETypes.normal,
              width: '25%',
              align: 'center'
            },
            {
              title: '参数编码',
              key: 'parameterCode_dictText',
              type: JVXETypes.normal,
              width: '20%',
              align: 'center',
            },
            {
              title: '允差值',
              key: 'parameterValue',
              type: JVXETypes.normal,
              width: '15%',
              align: 'center',
            },
            {
              title: '实测值',
              key: 'actualValue',
              type: JVXETypes.slot,
              width: '15%',
              align: 'center',
              slotName: 'actualValue',
              validateRules: [
                { required: true, message: '请输入实测值!' }
              ]
            }
          ],
          toolbarConfig: {
            // prefix 前缀;suffix 后缀
            slot: ['prefix', 'suffix'],
            // add 新增按钮;remove 删除按钮;clearSelection 清空选择按钮
            btn: ['add', 'remove', 'clearSelection']
          }
        }
      }
    },
    created() {
    },
    computed: {
      confirmDisable: function() {
@@ -411,25 +268,18 @@
        return ['COMPLETE', 'ABOLISH'].includes(this.model.maintenanceStatus)
      },
      isMaintenance: function() {
        return this.selectShenpiData && this.selectShenpiData.taskDefKey === 'maintenance_execution';
        return this.selectShenpiData && this.selectShenpiData.taskDefKey === 'maintenance_execution'
      },
      isPrecisionCheck: function() {
        return this.selectShenpiData && this.selectShenpiData.taskDefKey === 'precision_check';
      },
        return this.selectShenpiData && this.selectShenpiData.taskDefKey === 'precision_check'
      }
    },
    methods: {
      async handleDetail(item) {
        this.initParams()
        //重新计算defaultKey
        if(item && item.taskDefKey === 'precision_check') {
          this.activeTabKey = '4';
        }
        this.model = {}
        if (item.procInstId) {
          const { processDefinitionId, processInstanceId, processDefinitionKey, procInstId } = item
          let taskDataList = await getAction(this.url.queryHisTaskList, { procInstId })
          this.taskData = [...taskDataList.result]
          const { processDefinitionId, processInstanceId, processDefinitionKey } = item
          downFile(this.url.diagramView, {
            processDefinitionId,
@@ -449,66 +299,40 @@
        }
        let res = await getAction(this.url.queryById, { id: item.dataId })
        this.model = Object.assign({}, res.result)
        if (this.model.imageFiles) {
          let obj = JSON.parse(this.model.imageFiles)
          this.model.imageFilesResult = [...obj]
        }
        this.model.dataId = item.dataId
        this.model.taskId = item.id
        this.model.userId = item.assignee
        this.model.instanceId = item.procInstId
        this.model.values = item.variables
        await this.loadDetail(item.dataId)
        await this.loadPrecisionDetail(item.dataId);
      },
      recordDetail(record) {
        console.log('record', record)
        this.initParams()
        this.model = Object.assign({}, record)
        if (this.model.imageFiles) {
          let obj = JSON.parse(this.model.imageFiles)
          this.model.imageFilesResult = [...obj]
        }
        this.loadDetail(record.id)
        this.loadPrecisionDetail(record.id);
      },
      initParams() {
        this.detail.dataSource = []
        this.visible = true
        this.activeTabKey = '1';
        if(this.selectShenpiData &&  this.selectShenpiData.taskDefKey === 'precision_check') {
          this.activeTabKey = '4';
        }
        this.activeTabKey = '1'
        this.spinning = true
      },
      async handleOk() {
        const that = this
        if(that.$refs.editableDetailTable) {
          let errMap = await that.$refs.editableDetailTable.validateTable()
          if (errMap) {
            this.$message.warning('数据校验失败!')
            return
          }
        }
        // 触发表单验证
        this.$refs.form.validate(valid => {
          if (valid) {
            that.confirmLoading = that.spinning = true
            let tableData = [];
            let precisionTableData = [];
            if(that.$refs.editableDetailTable) {
              tableData = that.$refs.editableDetailTable.getTableData()
            }
            if(that.$refs.editablePrecisionDetailTable) {
              precisionTableData = that.$refs.editablePrecisionDetailTable.getTableData()
            }
            that.model.tableDetailList = [...tableData]
            that.model.precisionDetailList = [...precisionTableData]
            let httpurl = this.url.approval
            let method = 'put'
            that.model.tableDetailList = that.$refs.editableDetailTable.getTableData()
            httpAction(httpurl, this.model, method).then((res) => {
            httpAction(this.url.approval, this.model, 'put').then((res) => {
              if (res.success) {
                that.$message.success(res.message)
                that.$emit('searchReset')
@@ -524,21 +348,20 @@
          }
        })
      },
      autocompleteForm(selectObj) {
        this.$set(this.model, 'standardName', selectObj.standardName)
        this.$set(this.model, 'maintenancePeriod', selectObj.maintenancePeriod)
        this.$set(this.model, 'standardId', selectObj.id)
        this.$set(this.model, 'equipmentId', selectObj.equipmentId)
        // console.log('model', this.model)
        if (!this.model.id) {
          this.loadStandardDetail(selectObj.id)
        }
        this.loadMaintenanceOperatorList(this.model.equipmentId)
      },
      //标准选择变化
      //规范选择变化
      loadDetail(orderId) {
        if (orderId) {
          getAction(this.url.detail, { orderId: orderId })
          getAction(this.url.detail, { orderId })
            .then(res => {
              if (res.success) {
                this.detail.dataSource = [...res.result]
@@ -549,35 +372,11 @@
            })
        }
      },
      loadPrecisionDetail(orderId) {
        if (orderId) {
          getAction(this.url.precisionCheckDetail, { orderId: orderId }).then(res => {
            if (res.success) {
              this.precisionDetail.dataSource = [...res.result]
            }
          })
        }
      },
      loadMaintenanceOperatorList(equipmentId) {
        this.maintenanceOperatorOptions = []
        let params = { positionCode: 'PCR0001' }
        if (equipmentId) {
          params.equipmentId = equipmentId
        }
        getAction(this.url.userSelect, params).then(res => {
          if (res.success) {
            this.maintenanceOperatorOptions = res.result.map(item => ({
              key: item.id,
              value: item.username,
              text: item.realname
            }))
          }
        })
      },
      handleInspectionResultSelectChange(value, record) {
        if (record.exceptionDescription) delete record.exceptionDescription
        if (record.reportFlag) delete record.reportFlag
      },
      // 批量选择所有点检结果
      handleSelectAllInspectionResult() {
        this.selectedRowKeys.forEach(key => {
@@ -625,7 +424,3 @@
    }
  }
</script>
<style lang="less" scoped>
</style>