zhaowei
5 天以前 48d85187a16a313c5244a830862db5e672e6997d
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
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
<template>
  <j-modal :title="title" :visible="visible" fullscreen
           :okButtonProps="{ class:{'jee-hidden': disableSubmit} }" @ok="submitForm"
           @cancel="handleCancel" :mask-closable="false" :confirmLoading="confirmLoading">
    <a-spin :spinning="spinning">
      <a-form-model ref='form' :model='tableRowRecord' :labelCol="labelCol" :wrapperCol="wrapperCol"
                    :rules="validatorRules">
        <a-row :gutter="24" id="outer-row">
          <a-col :span="8" class="scroll-col">
            <a-tabs>
              <a-tab-pane tab="基础信息" key="1">
                <a-row>
                  <a-col :span="span">
                    <a-form-model-item prop="standardCode" label="规范编码">
                      <a-input v-model="tableRowRecord.standardCode" readOnly/>
                    </a-form-model-item>
                  </a-col>
                  <a-col :span="span">
                    <a-form-model-item prop="standardName" label="规范名称">
                      <a-input v-model="tableRowRecord.standardName" readOnly/>
                    </a-form-model-item>
                  </a-col>
                </a-row>
 
                <a-row>
                  <a-col :span='span'>
                    <a-form-model-item label="统一编码">
                      <a-input v-model="tableRowRecord.equipmentCode" readOnly/>
                    </a-form-model-item>
                  </a-col>
                  <a-col :span='span'>
                    <a-form-model-item label="保养分类">
                      <a-input v-model="tableRowRecord.maintenanceCategory_dictText" readOnly/>
                    </a-form-model-item>
                  </a-col>
 
                </a-row>
 
                <a-row>
                  <a-col :span='span'>
                    <a-form-model-item label="保养周期单位">
                      <a-input v-model="tableRowRecord.periodUnit" readOnly/>
                    </a-form-model-item>
                  </a-col>
                  <a-col :span='span'>
                    <a-form-model-item label="保养周期">
                      <a-input v-model="tableRowRecord.maintenancePeriod" readOnly/>
                    </a-form-model-item>
                  </a-col>
                </a-row>
 
                <a-row>
                  <a-col :span='span'>
                    <a-form-model-item label="初始日期">
                      <a-input v-model="tableRowRecord.initialDate" readOnly/>
                    </a-form-model-item>
                  </a-col>
                  <a-col :span='span'>
                    <a-form-model-item label="规范状态">
                      <a-input v-model="tableRowRecord.standardStatus_dictText" readOnly/>
                    </a-form-model-item>
                  </a-col>
                </a-row>
 
                <a-row>
                  <a-col :span="span">
                    <a-form-model-item label="规范版本">
                      <a-input v-model="tableRowRecord.standardVersion" readOnly/>
                    </a-form-model-item>
                  </a-col>
                </a-row>
              </a-tab-pane>
            </a-tabs>
          </a-col>
 
          <a-col :span="10" class="scroll-col">
            <a-tabs default-active-key="1">
              <a-tab-pane key="1" tab="保养项明细">
                <j-vxe-table ref="editableDetailTable" :rowNumber="false" :bordered="true"
                             :alwaysEdit="true" :toolbar="false" keep-source :loading="detail.loading"
                             :dataSource="detail.dataSource" :columns="detail.columns">
                  <template v-slot:itemCategory="props">
                    <j-dict-select-tag v-model="props.row.itemCategory" :dict-code="encodedDictCode" disabled/>
                  </template>
                </j-vxe-table>
              </a-tab-pane>
 
              <template v-if="selectShenpiData.procInstId">
                <a-tab-pane tab='流程图' forceRender>
                  <img :src="imageSrc" width="100%" v-if="imageSrc"/>
                </a-tab-pane>
              </template>
            </a-tabs>
          </a-col>
 
          <a-col :span="6" class="scroll-col">
            <a-tabs>
              <a-tab-pane tab="维修主任审批">
                <a-row :gutter="24">
                  <a-col :span="24">
                    <a-form-model-item prop="repairManagerApproveResult" label="处理类型">
                      <j-dict-select-tag type='radio' v-model='tableRowRecord.repairManagerApproveResult'
                                         dictCode='approved_rejected'
                                         :disabled="disableSubmit||tableRowRecord.standardStatus!=='WAIT_REPAIR_DIRECTOR'"/>
                    </a-form-model-item>
                  </a-col>
 
                  <a-col :span="24">
                    <a-form-model-item label="处理意见">
                      <a-textarea placeholder="请输入意见"
                                  :disabled="disableSubmit||tableRowRecord.standardStatus!=='WAIT_REPAIR_DIRECTOR'"
                                  v-model="tableRowRecord.repairManagerApproveComment"/>
                    </a-form-model-item>
                  </a-col>
                </a-row>
              </a-tab-pane>
            </a-tabs>
 
            <a-tabs v-if="tableRowRecord.standardStatus&&tableRowRecord.standardStatus!=='WAIT_REPAIR_DIRECTOR'">
              <a-tab-pane tab="技术主管审批">
                <a-row :gutter="24">
                  <a-col :span="24">
                    <a-form-model-item prop="technicalManagerApproveResult" label="处理类型">
                      <j-dict-select-tag type='radio' v-model='tableRowRecord.technicalManagerApproveResult'
                                         dictCode='approved_rejected'/>
                    </a-form-model-item>
                  </a-col>
 
                  <a-col :span="24">
                    <a-form-model-item label="处理意见">
                      <a-textarea placeholder="请输入意见" v-model="tableRowRecord.technicalManagerApproveComment"/>
                    </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, deleteAction, postAction, downFile, httpAction } from '@api/manage'
  import MaintenanceEquipmentSelect from '@views/eam/equipment/modules/MaintenanceEquipmentSelect.vue'
  import { JVXETypes } from '@comp/jeecg/JVxeTable'
  import moment from 'moment'
 
  export default {
    name: 'MaintenanceStandardApprovalModal',
    components: { MaintenanceEquipmentSelect },
    props: {
      selectShenpiData: {
        type: Object
      }
    },
    data() {
      return {
        span: 12,
        confirmLoading: false,
        spinning: false,
        tableRowRecord: {},
        validatorRules: {
          repairManagerApproveResult: [
            { required: true, message: '请选择处理类型' }
          ],
          technicalManagerApproveResult: [
            { required: true, message: '请选择处理类型' }
          ]
        },
        imageSrc: null,
        labelCol: {
          xs: { span: 24 },
          sm: { span: 8 }
        },
        wrapperCol: {
          xs: { span: 30 },
          sm: { span: 16 }
        },
        visible: false,
        // 表头
        url: {
          diagramView: '/assign/flow/diagramView',
          queryHisTaskList: '/assign/flow/queryHisTaskList',
          approve: '/eam/maintenanceStandard/audit',
          queryById: '/eam/maintenanceStandard/list',
          detailList: '/eam/eamMaintenanceStandardDetail/queryList'
        },
        detail: {
          loading: false,
          dataSource: [],
          columns: [],
          defaultColumns: [
            {
              title: 'ID',
              key: 'id',
              type: JVXETypes.hidden
            },
            {
              title: 'standardId',
              key: 'standardId',
              type: JVXETypes.hidden
            },
            {
              title: '项目序号',
              key: 'itemCode',
              type: JVXETypes.inputNumber,
              align: 'center',
              disabled: true
            },
            {
              title: '部位',
              key: 'itemPart',
              type: JVXETypes.textarea,
              align: 'center',
              disabled: true
            },
            {
              title: '保养项分类',
              key: 'itemCategory',
              type: JVXETypes.slot,
              slotName: 'itemCategory',
              align: 'center'
            },
            {
              title: '保养项目',
              key: 'itemName',
              type: JVXETypes.textarea,
              align: 'center',
              disabled: true
            },
            {
              title: '保养规范或要求',
              key: 'itemDemand',
              type: JVXETypes.textarea,
              align: 'center',
              disabled: true
            }
          ]
        },
        disableSubmit: false,
        title: ''
      }
    },
    watch: {
      'tableRowRecord.maintenanceCategory': {
        handler(val) {
          if (val) {
            if (val != 'THIRD_MAINTENANCE') this.detail.columns = [...this.detail.defaultColumns.filter(item => item.key != 'itemPart')]
            else this.detail.columns = [...this.detail.defaultColumns.filter(item => item.key != 'itemCategory')]
          }
          else this.detail.columns = [...this.detail.defaultColumns]
        }
      }
    },
    computed: {
      encodedDictCode() {
        const dictCode = `sys_dict_item,item_text,item_value,dict_id='1940598438685134850'`
        return encodeURIComponent(dictCode)
      }
    },
    methods: {
      /**
       * 获取流程节点和流程图
       * @param record 待办记录信息
       */
      getAllApproveData(record) {
        if (record.procInstId) {
          const { processDefinitionId, processInstanceId, processDefinitionKey, procInstId } = record
          const imageParam = { processDefinitionId, processInstanceId, TaskDefinitionKey: processDefinitionKey }
          const that = this
          this.imageSrc = null
 
          downFile(this.url.diagramView, imageParam, 'get')
            .then((res => {
              const urlObject = window.URL.createObjectURL(new Blob([res]))
              that.imageSrc = urlObject
            }))
            .finally(() => {
              this.spinning = false
            })
        }
      },
 
      /**
       * 获取待办记录的基本信息
       * @param record 待办记录信息
       */
      async getBasicInformation(record) {
        this.detail.dataSource = []
        this.tableRowRecord = {}
        this.spinning = true
        const param = { id: record.dataId }
        let res = await getAction(this.url.queryById, param)
        this.tableRowRecord = Object.assign({}, res.result.records[0])
        await this.loadDetail(record.dataId)
      },
 
      /**
       * 获取保养明细
       * @param dataId 业务ID
       */
      loadDetail(dataId) {
        if (dataId) {
          getAction(this.url.detailList, { standardId: dataId })
            .then(res => {
              if (res.success) {
                this.detail.dataSource = [...res.result]
              }
            })
        }
      },
 
      async submitForm() {
        let errMap = await this.$refs.editableDetailTable.validateTable()
        if (errMap) {
          return
        }
 
        this.$refs.form.validate(valid => {
          if (valid) {
            this.confirmLoading = this.spinning = true
            const flowTaskVo = {}
            flowTaskVo.dataId = this.selectShenpiData.dataId
            flowTaskVo.taskId = this.selectShenpiData.id
            flowTaskVo.userId = this.selectShenpiData.assignee
            flowTaskVo.instanceId = this.selectShenpiData.procInstId
            if (this.tableRowRecord.standardStatus == 'WAIT_REPAIR_DIRECTOR') {
              flowTaskVo.repairManagerApproveResult = this.tableRowRecord.repairManagerApproveResult
              flowTaskVo.repairManagerApproveComment = this.tableRowRecord.repairManagerApproveComment
            } else {
              flowTaskVo.technicalManagerApproveResult = this.tableRowRecord.technicalManagerApproveResult
              flowTaskVo.technicalManagerApproveComment = this.tableRowRecord.technicalManagerApproveComment
            }
            const that = this
            console.log('表单提交数据', flowTaskVo)
            httpAction(this.url.approve, flowTaskVo, 'post')
              .then((res) => {
                if (res.success) {
                  that.$notification.success({
                    message: '消息',
                    description: res.message
                  })
                  //刷新表格
                  that.$emit('modalFormOk')
                  that.handleCancel()
                } else {
                  that.$notification.warning({
                    message: '消息',
                    description: res.message
                  })
                }
              })
              .finally(() => {
                that.confirmLoading = this.spinning = false
              })
          } else {
            return false
          }
        })
      },
 
      handleCancel() {
        this.visible = false
      }
    }
  }
</script>
<style scoped lang="less">
  /deep/ .ant-select-dropdown-menu {
    text-align: left;
  }
 
  /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>