大件运输联网系统前端代码
guoshilong
2023-01-02 dd0838214cd86dcdec93c89687a7e6f457b58dc2
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
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
<template>
  <basic-container>
    <el-form ref="form" :model="form" :rules="rules" label-width="80px">
      <el-row type="flex" class="row-bg" justify="end">
        <el-form-item>
          <!--          <el-button type="primary" @click="handleAgree">同意</el-button>-->
<!--          <el-button type="success" @click="handlePolish">完善</el-button>-->
<!--          <el-button type="danger" @click="handleDisagree">驳回</el-button>-->
          <el-button @click="handleCancel">关闭</el-button>
        </el-form-item>
      </el-row>
      <el-card v-if="!isUserTask" shadow="hover">
        <div slot="header">
          <span>审批信息</span>
        </div>
        <avue-form :option="option" v-model="form"/>
 
        <el-tabs type="border-card">
          <el-tab-pane label="同意">
            <avue-form ref="form" v-model="agreeModel" :option="agreeOption" @submit="handleAgree"/>
          </el-tab-pane>
 
          <el-tab-pane label="完善">
            <avue-form ref="form" v-model="polishModel" :option="polishOption" @submit="handlePolish"/>
          </el-tab-pane>
 
          <el-tab-pane label="驳回">
            <avue-form ref="form" v-model="rejectModel" :option="rejectOption" @submit="handleDisagree"/>
          </el-tab-pane>
        </el-tabs>
      </el-card>
 
      <el-card v-else shadow="hover">
        <div slot="header">
          <span>审批信息</span>
        </div>
        <avue-form :option="option" v-model="form"/>
 
        <el-tabs type="border-card" @tab-click="tabsClick">
          <el-tab-pane label="采纳建议" name="userAgree">
            <avue-form ref="form" v-model="userAgreeModel" :option="userAgreeOption" @submit="userHandleAgree"/>
          </el-tab-pane>
 
          <el-tab-pane label="不采纳建议" name="userPolish">
            <avue-form ref="form" v-model="userPolishModel" :option="userPolishOption" @submit="userHandlePolish"/>
          </el-tab-pane>
 
          <el-tab-pane label="撤销申请" name="userDisagree">
            <avue-form ref="form" v-model="userRejectModel" :option="userRejectOption" @submit="userHandleDisagree"/>
          </el-tab-pane>
        </el-tabs>
      </el-card>
 
      <el-card shadow="hover">
        <div slot="header">
          <span>流程信息</span>
        </div>
        <el-row type="flex" class="row-bg">
          <el-timeline>
            <el-timeline-item :key="flow.id" :timestamp="flow.createTime" v-for="flow in flowList" placement="top">
              <el-card shadow="hover">
                <p>{{ flow.assigneeName }} 在 [{{ flow.createTime }}] 开始处理 [{{ flow.historyActivityName }}] 环节</p>
                <p v-if="flow.historyActivityDurationTime!==''">任务历时 [{{ flow.historyActivityDurationTime }}]</p>
                <p v-if="flow.comment!==''">反馈意见: [{{ flow.comment }}]</p>
                <p v-if="flow.endTime!==''">结束时间: [{{ flow.endTime }}]</p>
              </el-card>
            </el-timeline-item>
          </el-timeline>
        </el-row>
      </el-card>
 
      <el-card shadow="hover">
        <div slot="header">
          <span>流程跟踪</span>
        </div>
        <el-row class="row-bg">
          <flow-design :is-display="true" :process-instance-id="processInstanceId"></flow-design>
        </el-row>
      </el-card>
    </el-form>
  </basic-container>
</template>
 
<script>
import {historyFlowList} from "@/api/work/process";
import option from "@/const/application/application";
import {applicationDetail, completeTask, userCompleteTask} from "@/api/application/application";
import {deepClone} from "@/util/util";
 
export default {
  name: "handle",
  data() {
    return {
      taskId: '',
      businessId: '',
      processInstanceId: '',
      src: '',
      flowList: [],
      form: {},
      option: option,
      //审批人员相关字段
      agreeModel: {},
      agreeOption: {
        emptyBtn: false,
        submitText: "提交",
        gutter: 30,
        column: [
          {
            label: "反馈意见",
            prop: "comment",
            span:24,
            type:'textarea',
            hide: true,
            rules: [{
              required: true,
              message: "请输入反馈意见",
              trigger: "blur"
            }]
          },
        ]
      },
      polishModel: {},
      polishOption: {
        emptyBtn: false,
        submitText: "提交",
        gutter: 30,
        column: [
          {
            label: "完善意见",
            prop: "suggestion",
            type:'textarea',
            span:24,
            hide: true,
            rules: [{
              required: true,
              message: "请输入完善意见",
              trigger: "blur"
            }]
          },
          {
            label: "反馈意见",
            prop: "comment",
            type:'textarea',
            span:24,
            hide: true,
            rules: [{
              required: true,
              message: "请输入反馈意见",
              trigger: "blur"
            }]
          },
        ]
      },
      rejectModel: {},
      rejectOption: {
        emptyBtn: false,
        submitText: "提交",
        gutter: 30,
        column: [
          {
            label: "理由",
            prop: "rejectReason",
            type: "select",
            dicUrl: "/api/blade-system/dict-biz/dictionary?code=reject_reason",
            props: {
              label: "dictValue",
              value: "dictKey"
            },
            hide: true,
            rules: [{
              required: true,
              message: "请选择理由",
              trigger: "blur"
            }]
          },
          {
            label: "备注",
            prop: "remark",
            type: "textarea",
            span: 24
          },
          {
            label: "反馈意见",
            prop: "comment",
            type:'textarea',
            span:24,
            hide: true,
            rules: [{
              required: true,
              message: "请输入反馈意见",
              trigger: "blur"
            }]
          },
        ]
      },
 
      //申请人员相关字段
      isUserTask:false,
      userAgreeModel:{
        comment:'同意',
      },
      userAgreeOption:{
        emptyBtn: false,
        submitText: "提交",
        gutter: 30,
        column: [
          {
            label: "反馈意见",
            prop: "comment",
            span:24,
            type:'textarea',
            hide: true,
            rules: [{
              required: true,
              message: "请输入反馈意见",
              trigger: "blur"
            }]
          },
        ]
      },
      userPolishModel:{},
      userPolishOption:{
        emptyBtn: false,
        submitText: "提交",
        gutter: 30,
        column: [
          {
            label: "反馈意见",
            prop: "comment",
            span:24,
            type:'textarea',
            hide: true,
            rules: [{
              required: true,
              message: "请输入反馈意见",
              trigger: "blur"
            }]
          },
        ]
      },
      userRejectModel:{
        comment:'撤销申请'
      },
      userRejectOption:{
        emptyBtn: false,
        submitText: "提交",
        gutter: 30,
        column: [
          {
            label: "反馈意见",
            prop: "comment",
            type:'textarea',
            span:24,
            hide: true,
            rules: [{
              required: true,
              message: "请输入反馈意见",
              trigger: "blur"
            }]
          },
        ]
      },
      cloneForm:{},
    }
  },
  watch:{
    'form.passTime':{
      handler(newVal){
        this.form.startPassTime = newVal[0]
        this.form.endPassTime = newVal[1]
      }
    }
  },
  created() {
    this.init();
  },
  beforeDestroy() {
    this.controlOption("close")
  },
  beforeRouteUpdate(to, from, next) {
    // 在当前路由改变,但是该组件被复用时调用
    // 举例来说,对于一个带有动态参数的路径 /foo/:id,在 /foo/1 和 /foo/2 之间跳转的时候
    // 由于会渲染同样的 Foo 组件,因此组件实例会被复用。而这个钩子就会在这个情况下被调用
    // 可以访问组件实例 `this`
    if (to.fullPath !== from.fullPath) {
      next();
      this.init();
    }
  },
  methods: {
    init() {
      this.taskId = this.$route.params.taskId;
      this.processInstanceId = this.$route.params.processInstanceId;
      this.businessId = this.$route.params.businessId;
 
      this.controlOption('open')
      historyFlowList(this.processInstanceId).then(res => {
        const data = res.data;
        if (data.success) {
          this.flowList = data.data;
          if (this.flowList[this.flowList.length-1].historyActivityId == 'userTask'){
            this.controlOption('userTask')
            this.isUserTask = true
          }
        }
      })
      applicationDetail(this.businessId).then(res => {
        const data = res.data;
        if (data.success) {
          this.form = data.data;
          this.cloneForm = deepClone(this.form)
          this.initForm()
        }
      })
    },
    //==============审批人员审核方法=======================
    //同意
    handleAgree() {
      if (!this.agreeModel.comment) {
        this.$message.warning('请先填写反馈意见');
        return;
      }
      const params = {
        taskId: this.taskId,
        processInstanceId: this.processInstanceId,
        flag: 'ok',
        comment: this.agreeModel.comment,
        isSuggestion:false,
      };
      completeTask(params).then(res => {
        const data = res.data;
        if (data.success) {
          this.$message.success(data.msg);
          this.$router.$avueRouter.closeTag();
          this.$router.push({path: `/work/start`});
        } else {
          this.$message.error(data.msg || '提交失败');
        }
      })
    },
    //驳回
    handleDisagree() {
      if (!this.rejectModel.comment) {
        this.$message.warning('请先填写反馈意见');
        return;
      }
      const params = {
        taskId: this.taskId,
        processInstanceId: this.processInstanceId,
        comment: this.rejectModel.comment,
        isSuggestion:false
      };
      completeTask(params).then(res => {
        const data = res.data;
        if (data.success) {
          this.$message.success(data.msg);
          this.$router.$avueRouter.closeTag();
          this.$router.push({path: `/work/start`});
        } else {
          this.$message.error(data.msg || '提交失败');
        }
      })
    },
    //完善
    handlePolish() {
      if (!this.polishModel.comment) {
        this.$message.warning('请先填写反馈意见');
        return;
      }
      const params = {
        taskId: this.taskId,
        processInstanceId: this.processInstanceId,
        comment: this.polishModel.comment,
        suggestion:this.polishModel.suggestion,
        isSuggestion:true,
      };
      completeTask(params).then(res => {
        const data = res.data;
        if (data.success) {
          this.$message.success(data.msg);
          this.$router.$avueRouter.closeTag();
          this.$router.push({path: `/work/start`});
        } else {
          this.$message.error(data.msg || '提交失败');
        }
      })
    },
 
    //===============申请人员审核方法================
    //采纳意见
    userHandleAgree(){
      const params = {
        ...this.form,
        taskId: this.taskId,
        processInstanceId: this.processInstanceId,
        flag: 'ok',
        comment: this.userAgreeModel.comment,
        isSuggestion:true,
      };
      userCompleteTask(params).then(res => {
        const data = res.data;
        if (data.success) {
          this.$message.success(data.msg);
          this.$router.$avueRouter.closeTag();
          this.$router.push({path: `/work/start`});
        } else {
          this.$message.error(data.msg || '提交失败');
        }
      })
    },
    //撤销申请
    userHandleDisagree(){
      if (!this.rejectModel.comment) {
        this.$message.warning('请先填写反馈意见');
        return;
      }
      const params = {
        taskId: this.taskId,
        processInstanceId: this.processInstanceId,
        comment: this.userRejectModel.comment,
      };
      userCompleteTask(params).then(res => {
        const data = res.data;
        if (data.success) {
          this.$message.success(data.msg);
          this.$router.$avueRouter.closeTag();
          this.$router.push({path: `/work/start`});
        } else {
          this.$message.error(data.msg || '提交失败');
        }
      })
    },
    //不采纳意见
    userHandlePolish(){
      const params = {
        taskId: this.taskId,
        processInstanceId: this.processInstanceId,
        flag: 'ok',
        isSuggestion:false,
        comment: this.polishModel.comment,
      };
      userCompleteTask(params).then(res => {
        const data = res.data;
        if (data.success) {
          this.$message.success(data.msg);
          this.$router.$avueRouter.closeTag();
          this.$router.push({path: `/work/start`});
        } else {
          this.$message.error(data.msg || '提交失败');
        }
      })
    },
 
 
    handleCancel() {
      this.$router.$avueRouter.closeTag();
      this.$router.push({path: `/work/start`});
    },
    //给form表单中的字段赋值
    initForm() {
      let basic = this.form.basicInfoEntity
      let basicId = basic.id
      let plan = this.form.planEntity
      let planId = plan.id
      let scheme = this.form.schemeEntity
      let schemeId = scheme.id
      let car = this.form.carEntity
      let catId = car.id
      let goods = this.form.goodsEntity
      let goodsId = goods.id
      this.form.passTime = [basic.startPassTime,basic.endPassTime]
      let form = this.form
      //保留原form中的字段
      let common = Object.assign({}, form)
 
      form = Object.assign(form, basic)
      form = Object.assign(form, plan)
      form = Object.assign(form, scheme)
      form = Object.assign(form, car)
      form = Object.assign(form, goods)
 
      //覆盖回原form
      form = Object.assign(form, common)
 
      this.form.basicInfoEntity.id = basicId
      this.form.planEntity.id = planId
      this.form.schemeEntity.id = schemeId
      this.form.carEntity.id = catId
      this.form.goodsEntity.id = goodsId
    },
 
    //对option进行操作
    controlOption(arg) {
      if (arg == 'open') {
        //设置group内全为禁用状态
        this.option.group.forEach(group => {
          group.column.forEach(item => {
            item.disabled = true
          })
        })
 
        //隐藏提交 清空按钮
        this.option.submitBtn = false
        this.option.emptyBtn = false
 
      } else if (arg == 'close') {
        //解除禁用状态
        this.option.group.forEach(group => {
          group.column.forEach(item => {
            item.disabled = false
          })
        })
 
        //显示提交 清空按钮
        this.option.submitBtn = true
        this.option.emptyBtn = true
 
      }else if (arg == 'userTask'){
        //解除禁用状态
        this.option.group.forEach(group => {
          group.column.forEach(item => {
            item.disabled = false
          })
        })
 
      }else if (arg == 'noPolish'){
        //设置group内全为禁用状态
        this.option.group.forEach(group => {
          group.column.forEach(item => {
            item.disabled = true
          })
        })
      }
    },
    tabsClick(tab){
      if (tab.name == 'userAgree'){
        this.controlOption('userTask')
      }else {
        this.controlOption('noPolish')
      }
    }
  }
}
</script>
 
<style scoped>
 
</style>