zhaowei
2 天以前 19aff1ac87030b21d2b01cdca5d5604c840ba7c0
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
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
<template>
  <j-modal :width="1200" :visible="visible" :title="title" :okButtonProps="{ class:{'jee-hidden': disableSubmit} }"
           @cancel="handCancel" @ok="submitForm" :mask-closable="false" :confirmLoading="confirmLoading" fullscreen>
    <a-spin :spinning="spinning">
      <a-form-model ref="form" :model="model" :rules="validatorRules" :labelCol="labelColLong"
                    :wrapperCol="wrapperColLong">
        <a-row :gutter="24" id="outer-row">
          <a-col :span="8" class="scroll-col">
            <a-tabs>
              <a-tab-pane tab="基础信息">
                <a-row>
                  <a-col :span="12">
                    <a-form-model-item label="维修开始时间" :labelCol="labelCol" :wrapperCol="wrapperCol">
                      <a-input v-model="model.actualStartTime" readOnly/>
                    </a-form-model-item>
                  </a-col>
                  <a-col :span="12">
                    <a-form-model-item label="维修结束时间" :labelCol="labelCol" :wrapperCol="wrapperCol">
                      <a-input v-model="model.actualEndTime" readOnly/>
                    </a-form-model-item>
                  </a-col>
                  <a-col :span="24">
                    <a-form-model-item label="故障原因">
                      <a-textarea v-model="model.faultReason" readOnly/>
                    </a-form-model-item>
                  </a-col>
                  <a-col :span="24">
                    <a-form-model-item label="故障分析">
                      <a-textarea v-model="model.faultAnalysis" readOnly/>
                    </a-form-model-item>
                  </a-col>
                  <a-col :span="24">
                    <a-form-model-item label="排故过程">
                      <a-textarea v-model="model.faultProcess" readOnly/>
                    </a-form-model-item>
                  </a-col>
                  <a-col :span="24">
                    <a-form-model-item label="预防措施">
                      <a-textarea v-model="model.faultPrevent" readOnly/>
                    </a-form-model-item>
                  </a-col>
                </a-row>
              </a-tab-pane>
            </a-tabs>
          </a-col>
 
          <!--维修人明细-->
          <a-col class="scroll-col" :span="10">
            <a-tabs v-model="activeTabKey">
              <a-tab-pane key="1" tab="维修人明细">
                <j-vxe-table ref="editableDetailTable" rowNumber bordered keep-source :dataSource="detail.dataSource"
                             :columns="detail.columns"/>
              </a-tab-pane>
 
              <template v-if="selectShenpiData.procInstId">
                <a-tab-pane key='2' tab='流程图'>
                  <img :src="imageSrc" alt="Fetched Image"/>
                </a-tab-pane>
              </template>
            </a-tabs>
          </a-col>
 
          <!--右侧审批列-->
          <a-col :span="6" class="scroll-col">
            <a-tabs>
              <a-tab-pane tab="操作工确认">
                <a-row>
                  <a-col :span="24">
                    <a-form-model-item prop="confirmResult" label="确认类型">
                      <j-dict-select-tag type='radio' v-model='model.confirmResult' dictCode='approve_reject'
                                         placeholder="请选择确认类型"
                                         :disabled="disableSubmit || model.repairStatus!='PENDING_CONFIRMATION'"/>
                    </a-form-model-item>
                  </a-col>
                  <a-col :span="24">
                    <a-form-model-item label="确认意见">
                      <a-textarea placeholder="请输入意见" v-model="model.confirmComment"
                                  :disabled="disableSubmit || model.repairStatus!='PENDING_CONFIRMATION'"/>
                    </a-form-model-item>
                  </a-col>
                </a-row>
              </a-tab-pane>
            </a-tabs>
          </a-col>
        </a-row>
      </a-form-model>
    </a-spin>
  </j-modal>
</template>
 
<script>
  import { getAction, downFile, httpAction } from '@api/manage'
  import LxSearchEquipmentSelect from '@views/eam/equipment/modules/LxSearchEquipmentSelect'
  import { JVXETypes } from '@comp/jeecg/JVxeTable'
 
  export default {
    name: 'RepairOrderApprovalModal',
    components: { LxSearchEquipmentSelect },
    props: {
      selectShenpiData: {
        type: Object,
        required: true
      }
    },
    data() {
      return {
        title: '',
        disableSubmit: false,
        confirmLoading: false,
        spinning: false,
        model: {},
        imageSrc: null,
        activeTabKey: '1',
        labelCol: {
          xs: { span: 24 },
          sm: { span: 10 }
        },
        wrapperCol: {
          xs: { span: 24 },
          sm: { span: 14 }
        },
        labelColLong: {
          xs: { span: 24 },
          sm: { span: 5 }
        },
        wrapperColLong: {
          xs: { span: 24 },
          sm: { span: 19 }
        },
        validatorRules: { confirmResult: [{ required: true, message: '请选择确认类型' }] },
        detail: {
          dataSource: [],
          columns: [
            {
              title: 'ID',
              key: 'id',
              type: JVXETypes.hidden
            },
            {
              title: '维修人',
              key: 'repairUser',
              align: 'center',
              type: JVXETypes.normal
            },
            {
              title: '是否是主维修人',
              key: 'repairPrimary_dictText',
              align: 'center',
              type: JVXETypes.normal
            },
            {
              title: '维修时长',
              key: 'repairDuration',
              align: 'center',
              type: JVXETypes.normal
            },
            {
              title: '备注',
              key: 'remark',
              align: 'center',
              type: JVXETypes.normal
            }
          ],
          toolbarConfig: {
            // prefix 前缀;suffix 后缀
            slot: ['prefix', 'suffix'],
            // add 新增按钮;remove 删除按钮;clearSelection 清空选择按钮
            btn: ['add', 'remove', 'clearSelection']
          }
        },
        visible: false,
        // 表头
        url: {
          queryById: '/eam/eamRepairOrder/queryByReportId',
          diagramView: '/assign/flow/diagramView',
          approve: '/eam/eamRepairOrder/perform',
          detail: '/eam/eamRepairPerson/list'
        }
      }
    },
    computed: {
      operatorConfirm() {
        return ['WAIT_CONFIRM', 'COMPLETE'].includes(this.model.repairStatus)
      }
    },
    methods: {
      /**
       * 主页面点击执行审批时触发
       * @param record 主页面列表行记录
       */
      async handleDetail(record) {
        this.spinning = true
        this.activeTabKey = '1'
        this.model = {}
        this.getBasicInformationByApi(record)
        this.getFlowChartImageByApi(record)
        this.loadDetail(record.dataId)
      },
 
      /**
       * 主页面点击详情时触发
       * @param record 主页面列表行记录
       */
      recordDetail(record) {
        this.spinning = true
        this.activeTabKey = '1'
        this.model = Object.assign({}, record)
        this.loadDetail(record.id)
      },
 
      /**
       * 获取基础信息
       * @param record 主页面列表行记录
       */
      getBasicInformationByApi(record) {
        const that = this
        getAction(this.url.queryById, { id: record.dataId })
          .then(res => {
            if (res.success) {
              that.model = Object.assign({}, res.result[0])
              that.model.dataId = record.dataId
              that.model.taskId = record.id
              that.model.userId = record.assignee
              that.model.instanceId = record.procInstId
            }
            else {
              that.$notification.warning({
                message: '消息',
                description: res.message
              })
            }
          })
      },
 
      /**
       * 获取流程图
       * @param record 主页面列表行记录
       */
      getFlowChartImageByApi(record) {
        const { processDefinitionId, processInstanceId, processDefinitionKey } = record
 
        downFile(this.url.diagramView, {
          processDefinitionId,
          processInstanceId,
          TaskDefinitionKey: processDefinitionKey
        }, 'get')
          .then((res => {
            this.imageSrc = window.URL.createObjectURL(new Blob([res]))
          }))
          .catch(err => {
            this.$notification.error({
              message: '消息',
              description: err.message
            })
          })
      },
 
      /**
       * 获取维修人明细
       * @param repairId
       */
      loadDetail(repairId) {
        getAction(this.url.detail, { repairId })
          .then(res => {
            if (res.success) this.detail.dataSource = res.result
          })
          .finally(() => {
            this.spinning = false
          })
      },
 
 
      submitForm() {
        const that = this
        // 触发表单验证
        this.$refs.form.validate(valid => {
          if (valid) {
            that.confirmLoading = that.spinning = true
            httpAction(this.url.approve, that.model, 'post')
              .then((res) => {
                if (res.success) {
                  that.$notification.success({
                    message: '消息',
                    description: res.message
                  })
                  that.handCancel()
                  that.$emit('modalFormOk')
                } else {
                  that.$notification.warning({
                    message: '消息',
                    description: res.message
                  })
                }
              })
              .finally(() => {
                that.confirmLoading = that.spinning = false
              })
          } else {
            return false
          }
        })
      },
 
      handCancel() {
        this.visible = false
        if (this.$refs.form) this.$refs.form.clearValidate()
      }
    }
  }
</script>
 
<style scoped lang="less">
  /deep/ .ant-spin-nested-loading {
    height: 100%;
 
    .ant-spin-container {
      height: 100%;
 
      .ant-form {
        height: 100%;
 
        #outer-row {
          height: 100%;
 
          .scroll-col {
            height: 100%;
            overflow: auto;
          }
        }
      }
    }
  }
</style>