1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
<template>
  <a-modal
    :width="1000"
    :visible="visible"
    @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>
        <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>
        <a-spin :spinning="spinning">
          <a-tabs default-active-key='1'>
            <a-tab-pane key='1' tab='基本信息'>
              <a-form-model :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='设备编号'>
                      <lx-search-equipment-select disabled v-model='tableRowRecord.equipmentId'/>
                    </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-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-tabs>
        </a-spin>
      </div>
 
      <a-tabs default-active-key='1'>
        <a-tab-pane key="1" tab="审批详情">
          <a-form-model ref="form" :model="approveData" :rules="validatorRules" :labelCol='labelCol'
                        :wrapperCol='wrapperCol'>
            <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-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>
        </a-tab-pane>
      </a-tabs>
    </a-card>
  </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'
 
  export default {
    name: 'RepairOrderApprovalModal',
    components: { LxSearchEquipmentSelect },
    props: {
      selectShenpiData: {
        type: Object,
        required: true
      }
    },
    data() {
      return {
        form: this.$form.createForm(this),
        span: 12,
        inputReadOnly: true,
        spinning: false,
        tableRowRecord: {},
        hitaskDataSource: [],
        imageSrc: null,
        labelCol: {
          xs: { span: 24 },
          sm: { span: 6 }
        },
        wrapperCol: {
          xs: { span: 24 },
          sm: { span: 16 }
        },
        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'
        },
        isDisplayBmp: false,
        showBmpButtonLoading: false
      }
    },
    methods: {
      /**
       * 获取流程节点
       * @param record 待办记录信息
       */
      getAllApproveData(record) {
        console.log('selectShenpiData----->', this.selectShenpiData)
        const param = { 'procInstId': record.dataId }
        getAction(this.url.queryHisTaskList, param)
          .then(res => {
            this.hitaskDataSource = res.result
          })
      },
 
      /**
       * 获取待办记录的基本信息
       * @param record 待办记录信息
       */
      getBasicInformation(record) {
        this.spinning = true
        const that = this
        const param = { id: record.dataId }
        this.tableRowRecord = {}
        this.approveData = { status: 0 }
        getAction(this.url.queryBomDataById, param)
          .then((res => {
            if (res.success) {
              that.tableRowRecord = res.result
              console.log('this.tableRowRecord----->', that.tableRowRecord)
            }
          }))
          .finally(() => {
            that.spinning = false
          })
      },
 
      // 获取并展开流程图
      fetchAndShowBmp() {
        this.isDisplayBmp = !this.isDisplayBmp
        if (!this.imageSrc) {
          const { processDefinitionId, processInstanceId, processDefinitionKey } = this.selectShenpiData
          let param = { processDefinitionId, processInstanceId, TaskDefinitionKey: processDefinitionKey }
          this.showBmpButtonLoading = true
          const that = this
          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
            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
          }
        })
      },
 
      handCancel() {
        this.visible = false
        this.isDisplayBmp = false
        this.imageSrc = null
      }
    }
  }
</script>
<style scoped>
  .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>