Blame view

src/views/oa/newOaWorkflowDetailList.vue 13.5 KB
9d019fa6   wuxw   测试OA相关流程
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
  <template>
    <div class="new-oa-workflow-detail-container">
      <el-row :gutter="20">
        <el-col :span="24">
          <el-card>
            <div slot="header" class="flex justify-between">
              <span>{{ $t('newOaWorkflowDetail.title') }}</span>
              <div class="float-right">
                <el-button type="primary" size="small" @click="_goBack">
                  {{ $t('newOaWorkflowDetail.back') }}
                </el-button>
              </div>
            </div>
  
            <div v-if="newOaWorkflowDetailInfo.pools">
              <el-form>
                <el-row :gutter="20">
                  <el-col :span="8">
                    <el-form-item :label="$t('newOaWorkflowDetail.applicant')">
                      <span>{{ newOaWorkflowDetailInfo.pools.create_user_name }}</span>
                    </el-form-item>
                  </el-col>
                  <el-col :span="8">
                    <el-form-item :label="$t('newOaWorkflowDetail.applyTime')">
                      <span>{{ newOaWorkflowDetailInfo.pools.create_time }}</span>
                    </el-form-item>
                  </el-col>
                  <el-col :span="8">
                    <el-form-item :label="$t('newOaWorkflowDetail.status')">
                      <span>{{ _getNewOaWorkflowDetailState(newOaWorkflowDetailInfo.pools) }}</span>
                    </el-form-item>
                  </el-col>
                </el-row>
  
                <el-row :gutter="20">
                  <template v-for="(item, index) in newOaWorkflowDetailInfo.formJson">
                    <el-col v-if="item.type != 'text' && item.type != 'button'" :key="index" :span="8">
                      <el-form-item :label="item.label">
                        <span>{{ newOaWorkflowDetailInfo.pools[item.key] }}</span>
                      </el-form-item>
                    </el-col>
                  </template>
                </el-row>
  
                <el-row :gutter="20">
                  <el-col v-for="(item, index) in newOaWorkflowDetailInfo.files" :key="index" :span="8">
                    <el-form-item>
                      <el-link :href="item.realFileName" target="_blank">{{ item.fileName }}</el-link>
                    </el-form-item>
                  </el-col>
                </el-row>
              </el-form>
            </div>
          </el-card>
        </el-col>
      </el-row>
  
      <el-row :gutter="20" class="mt-20">
        <el-col :span="24">
          <el-card>
            <div slot="header" class="flex justify-between">
              <span>{{ $t('newOaWorkflowDetail.workflowProcess') }}</span>
            </div>
  
            <el-table :data="newOaWorkflowDetailInfo.comments" border style="width: 100%">
              <el-table-column prop="index" :label="$t('newOaWorkflowDetail.serialNumber')" width="80" align="center">
                <template slot-scope="scope">
                  {{ scope.$index + 1 }}
                </template>
              </el-table-column>
              <el-table-column prop="orgName" :label="$t('newOaWorkflowDetail.department')" align="center">
                <template slot-scope="scope">
                  {{ scope.row.orgName || $t('newOaWorkflowDetail.admin') }}
                </template>
              </el-table-column>
              <el-table-column prop="staffName" :label="$t('newOaWorkflowDetail.handler')" align="center" />
              <el-table-column :label="$t('newOaWorkflowDetail.status')" align="center">
                <template slot-scope="scope">
                  {{ scope.row.endTime ? $t('newOaWorkflowDetail.processed') : $t('newOaWorkflowDetail.processing') }}
                </template>
              </el-table-column>
              <el-table-column prop="duration" :label="$t('newOaWorkflowDetail.timeConsuming')" align="center" />
              <el-table-column prop="context" :label="$t('newOaWorkflowDetail.comment')" align="center" />
            </el-table>
          </el-card>
        </el-col>
      </el-row>
  
      <el-row v-if="newOaWorkflowDetailInfo.action" :gutter="20" class="mt-20">
        <el-col :span="24">
          <el-card>
            <div slot="header" class="flex justify-between">
              <span>{{ $t('newOaWorkflowDetail.workflowHandle') }}</span>
            </div>
  
caba9d96   wuxw   oa 中除了 工作办理没有测试其他...
96
            <el-form label-width="120px" class="text-left">
9d019fa6   wuxw   测试OA相关流程
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
              <el-form-item :label="$t('newOaWorkflowDetail.action')">
                <el-select v-model="newOaWorkflowDetailInfo.audit.auditCode" style="width:100%"
                  :placeholder="$t('newOaWorkflowDetail.selectAction')">
                  <el-option v-if="newOaWorkflowDetailInfo.nextAudit.next" value="1100"
                    :label="$t('newOaWorkflowDetail.handle')" />
                  <el-option v-if="newOaWorkflowDetailInfo.nextAudit.back" value="1200"
                    :label="$t('newOaWorkflowDetail.return')" />
                  <el-option v-if="newOaWorkflowDetailInfo.nextAudit.backIndex" value="1400"
                    :label="$t('newOaWorkflowDetail.returnToSubmitter')" />
                  <el-option v-if="newOaWorkflowDetailInfo.nextAudit.exit" value="1500"
                    :label="$t('newOaWorkflowDetail.end')" />
                  <el-option value="1300" :label="$t('newOaWorkflowDetail.transfer')" />
                </el-select>
              </el-form-item>
  
caba9d96   wuxw   oa 中除了 工作办理没有测试其他...
112
              <el-form-item :label="$t('newOaWorkflowDetail.workflowDescription')" class="margin-top">
9d019fa6   wuxw   测试OA相关流程
113
114
115
116
117
118
119
                <el-input type="textarea" :rows="3" :placeholder="$t('newOaWorkflowDetail.descriptionRequired')"
                  v-model="newOaWorkflowDetailInfo.audit.auditMessage" />
              </el-form-item>
  
              <!-- 办理时 判断是否指定 委托人 如果指定了 则不显示 -->
              <el-form-item
                v-if="newOaWorkflowDetailInfo.audit.auditCode == '1100' && newOaWorkflowDetailInfo.nextAudit.assignee == '-2'"
caba9d96   wuxw   oa 中除了 工作办理没有测试其他...
120
                :label="$t('newOaWorkflowDetail.nextHandler')" class="margin-top">
9d019fa6   wuxw   测试OA相关流程
121
122
123
124
125
126
127
128
129
                <el-input v-model="newOaWorkflowDetailInfo.audit.staffName"
                  :placeholder="$t('newOaWorkflowDetail.selectNextHandler')" disabled style="width:80%" />
                <el-button type="primary" @click="chooseStaff" style="margin-left:10px">
                  {{ $t('newOaWorkflowDetail.select') }}
                </el-button>
              </el-form-item>
  
              <!-- 转单时 必须指定 委托人 -->
              <el-form-item v-if="newOaWorkflowDetailInfo.audit.auditCode == '1300'"
caba9d96   wuxw   oa 中除了 工作办理没有测试其他...
130
                :label="$t('newOaWorkflowDetail.nextHandler')" class="margin-top">
9d019fa6   wuxw   测试OA相关流程
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
                <el-input v-model="newOaWorkflowDetailInfo.audit.staffName"
                  :placeholder="$t('newOaWorkflowDetail.selectNextHandler')" disabled style="width:80%" />
                <el-button type="primary" @click="chooseStaff" style="margin-left:10px">
                  {{ $t('newOaWorkflowDetail.select') }}
                </el-button>
              </el-form-item>
  
              <el-form-item>
                <el-button type="primary" class="float-right" @click="_auditSubmit">
                  {{ $t('newOaWorkflowDetail.submit') }}
                </el-button>
              </el-form-item>
            </el-form>
          </el-card>
        </el-col>
      </el-row>
  
      <el-row :gutter="20" class="mt-20">
        <el-col :span="24">
          <el-card>
            <div slot="header" class="flex justify-between">
              <span>{{ $t('newOaWorkflowDetail.flowChart') }}</span>
            </div>
            <div class="text-center">
              <el-image :src="newOaWorkflowDetailInfo.imgData" style="height:300px" fit="contain" />
            </div>
          </el-card>
        </el-col>
      </el-row>
  
caba9d96   wuxw   oa 中除了 工作办理没有测试其他...
161
      <select-staff ref="selectStaff" @selectStaff="handleSelectStaff"/>
9d019fa6   wuxw   测试OA相关流程
162
163
164
165
166
    </div>
  </template>
  
  <script>
  import { getCommunityId } from '@/api/community/communityApi'
caba9d96   wuxw   oa 中除了 工作办理没有测试其他...
167
168
  import { queryOaWorkflowForm, queryOaWorkflowFormData, queryOaWorkflowUser, 
    getNextTask, auditOaWorkflow, listRunWorkflowImage } from '@/api/oa/newOaWorkflowDetailApi'
9d019fa6   wuxw   测试OA相关流程
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
  import SelectStaff from '@/components/staff/SelectStaff'
  
  export default {
    name: 'NewOaWorkflowDetailList',
    components: {
      SelectStaff
    },
    data() {
      return {
        newOaWorkflowDetailInfo: {
          id: '',
          flowId: '',
          pools: {},
          formJson: [],
          comments: [],
          action: '',
          audit: {
            auditCode: '1100',
            auditMessage: '',
            staffId: '',
            staffName: '',
            taskId: ''
          },
          imgData: '',
          nextAudit: {},
          files: []
        },
        communityId: ''
      }
    },
    created() {
      this.communityId = getCommunityId()
      const id = this.$route.query.id
      if (!id) {
        this.$message.error(this.$t('newOaWorkflowDetail.illegalOperation'))
        return
      }
      this.newOaWorkflowDetailInfo.id = id
      this.newOaWorkflowDetailInfo.flowId = this.$route.query.flowId
      this.newOaWorkflowDetailInfo.action = this.$route.query.action
      this.newOaWorkflowDetailInfo.audit.taskId = this.$route.query.taskId
      this._listOaWorkflowDetails()
      this._loadComments()
      if (this.newOaWorkflowDetailInfo.action) {
        this._loadNextAuditPerson()
      }
      this._openNewOaWorkflowDetailImg()
    },
    methods: {
      async _listOaWorkFlowDetailForm() {
        try {
          const params = {
            page: 1,
            row: 1,
            flowId: this.newOaWorkflowDetailInfo.flowId
          }
          const response = await queryOaWorkflowForm(params)
          this.newOaWorkflowDetailInfo.formJson = JSON.parse(response.data[0].formJson).components
        } catch (error) {
          console.error('请求失败:', error)
        }
      },
      async _listOaWorkflowDetails() {
        try {
          const params = {
            page: 1,
            row: 1,
            id: this.newOaWorkflowDetailInfo.id,
            flowId: this.newOaWorkflowDetailInfo.flowId
          }
          const response = await queryOaWorkflowFormData(params)
          this.newOaWorkflowDetailInfo.pools = response.data[0]
          this.newOaWorkflowDetailInfo.files = response.data[0].files
          this._listOaWorkFlowDetailForm()
        } catch (error) {
          console.error('请求失败:', error)
        }
      },
      async _loadComments() {
        try {
          const params = {
            communityId: this.communityId,
            id: this.newOaWorkflowDetailInfo.id,
            flowId: this.newOaWorkflowDetailInfo.flowId,
            page: 1,
            row: 10
          }
          const response = await queryOaWorkflowUser(params)
caba9d96   wuxw   oa 中除了 工作办理没有测试其他...
257
          if (response.code !== 0) return
9d019fa6   wuxw   测试OA相关流程
258
259
260
261
262
263
264
265
266
267
268
          this.newOaWorkflowDetailInfo.comments = response.data
        } catch (error) {
          console.error('请求失败:', error)
        }
      },
      _goBack() {
        this.$router.go(-1)
      },
      chooseStaff() {
        this.$refs.selectStaff.open(this.newOaWorkflowDetailInfo.audit)
      },
caba9d96   wuxw   oa 中除了 工作办理没有测试其他...
269
270
271
272
      handleSelectStaff(staff) {
        this.newOaWorkflowDetailInfo.audit.staffId = staff.userId
        this.newOaWorkflowDetailInfo.audit.staffName = staff.userName
      },
9d019fa6   wuxw   测试OA相关流程
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
      async _auditSubmit() {
        const audit = this.newOaWorkflowDetailInfo.audit
        audit.flowId = this.newOaWorkflowDetailInfo.flowId
        audit.id = this.newOaWorkflowDetailInfo.id
  
        if (!audit.auditCode) {
          this.$message.error(this.$t('newOaWorkflowDetail.selectStatus'))
          return
        }
        if (!audit.auditMessage) {
          this.$message.error(this.$t('newOaWorkflowDetail.fillDescription'))
          return
        }
        if (audit.auditCode !== '1200' && audit.auditCode !== '1400' && !audit.staffId) {
          this.$message.error(this.$t('newOaWorkflowDetail.selectNextHandler'))
          return
        }
  
        try {
          const response = await auditOaWorkflow(audit)
          if (response.code === 0) {
            this.$message.success(this.$t('newOaWorkflowDetail.submitSuccess'))
            this._goBack()
          } else {
            this.$message.error(response.msg)
          }
        } catch (error) {
          this.$message.error(error)
        }
      },
      async _loadNextAuditPerson() {
        try {
          const params = {
            communityId: this.communityId,
            taskId: this.newOaWorkflowDetailInfo.audit.taskId,
            flowId: this.newOaWorkflowDetailInfo.flowId,
            id: this.newOaWorkflowDetailInfo.id
          }
          const response = await getNextTask(params)
          if (response.code !== '0') return
          this.newOaWorkflowDetailInfo.nextAudit = response.data[0]
        } catch (error) {
          console.error('请求失败:', error)
        }
      },
      _getNewOaWorkflowDetailState(pool) {
        if (!Object.prototype.hasOwnProperty.call(pool, 'state')) {
          return this.$t('newOaWorkflowDetail.unknown')
        }
        switch (pool.state) {
          case '1001':
            return this.$t('newOaWorkflowDetail.apply')
          case '1002':
            return this.$t('newOaWorkflowDetail.pendingReview')
          case '1003':
            return this.$t('newOaWorkflowDetail.returned')
          case '1004':
            return this.$t('newOaWorkflowDetail.transferred')
          case '1005':
            return this.$t('newOaWorkflowDetail.completed')
          default:
            return this.$t('newOaWorkflowDetail.unknown')
        }
      },
      async _openNewOaWorkflowDetailImg() {
        try {
          const params = {
            communityId: this.communityId,
            businessKey: this.newOaWorkflowDetailInfo.id
          }
          const response = await listRunWorkflowImage(params)
caba9d96   wuxw   oa 中除了 工作办理没有测试其他...
344
          if (response.code !== 0) return
9d019fa6   wuxw   测试OA相关流程
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
          this.newOaWorkflowDetailInfo.imgData = 'data:image/png;base64,' + response.data
        } catch (error) {
          console.error('请求失败:', error)
        }
      }
    }
  }
  </script>
  
  <style lang="scss" scoped>
  .new-oa-workflow-detail-container {
    padding: 20px;
  
    .mt-20 {
      margin-top: 20px;
    }
  
    .float-right {
      float: right;
    }
  
    .text-center {
      text-align: center;
    }
  
    .el-form-item {
      margin-bottom: 0;
    }
  }
  </style>