115115 <el-button
116116 type =" primary"
117117 :loading =" table.approvalLoading"
118- @click =" handleApproval (scope.row)"
118+ @click =" handleLogTrack (scope.row)"
119119 >
120120 审批日志
121121 </el-button >
273273import { Component , Vue } from ' vue-property-decorator'
274274import Pagination from ' @/components/Pagination/index.vue'
275275import { Form } from ' element-ui'
276- import {
277- batchDeleteLeave ,
278- cancelLeave ,
279- createLeave ,
280- findLeaveApprovingTrack ,
281- findLeave ,
282- updateLeave , confirmLeave , resubmitLeave
283- } from ' @/api/test/leaves'
276+ import { batchDeleteLeave , createLeave , findLeave , updateLeave } from ' @/api/test/leaves'
284277import { diffObjUpdate } from ' @/utils/diff'
285278import { IdempotenceModule } from ' @/store/modules/idempotence'
279+ import { approveFsm , cancelFsm , findFsmLogTrack } from ' @/api/system/fsm'
286280
287281@Component ({
288282 // 组件名称首字母需大写, 否则会报警告
@@ -295,6 +289,8 @@ export default class extends Vue {
295289 private readonly defaultConfig: any = {
296290 pageNum: 1 ,
297291 pageSize: 5 ,
292+ // 默认状态机分类, 需要和后端保持一致, 也可以动态从数据字典查询
293+ category: 1 ,
298294 status: [{
299295 name: 0 ,
300296 label: ' 已提交' ,
@@ -502,11 +498,17 @@ export default class extends Vue {
502498 this .updateDialog .visible = true
503499 }
504500
505- private async handleApproval (row : any ) {
501+ private async handleLogTrack (row : any ) {
506502 this .table .approvalLoading = true
507- this .approvalDialog .title = ' '
508503 try {
509- const { data } = await findLeaveApprovingTrack (row .id )
504+ console .log ({
505+ category: this .defaultConfig .category ,
506+ uuid: row .fsmUuid
507+ })
508+ const { data } = await findFsmLogTrack ({
509+ category: this .defaultConfig .category ,
510+ uuid: row .fsmUuid
511+ })
510512 this .approvalDialog .stepsActive = data .length - 1
511513 const logs: any [] = []
512514 for (let i = 0 , len = data .length ; i < len ; i ++ ) {
@@ -520,6 +522,14 @@ export default class extends Vue {
520522 } else if (i < len - 1 || item .status > 0 ) {
521523 let status = ' success'
522524 let description = item .updatedAt
525+ let opinion = item .opinion
526+ if (item .opinion === ' ' && item .status !== 3 && item .end === 0 && item .confirm === 0 ) {
527+ opinion = ' 通过'
528+ }
529+ let title = item .name
530+ if (opinion !== ' ' ) {
531+ title = item .name + ' [审批意见: ' + opinion + ' ]'
532+ }
523533 if (item .status === 2 ) {
524534 status = ' error'
525535 if (item .opinion !== ' ' ) {
@@ -531,18 +541,18 @@ export default class extends Vue {
531541 status = ' finish'
532542 }
533543 logs .push ({
534- title: item . name ,
544+ title ,
535545 description ,
536546 status
537547 })
538548 } else {
539- if (item .resubmit ) {
549+ if (item .resubmit === 1 ) {
540550 logs .push ({
541551 title: ' 待重新提交' ,
542552 description: ' 请编辑后重新提交~' ,
543553 status: ' wait'
544554 })
545- } else if (item .confirm ) {
555+ } else if (item .confirm === 1 ) {
546556 logs .push ({
547557 title: ' 待确认' ,
548558 description: ' 请点击确认~' ,
@@ -599,13 +609,23 @@ export default class extends Vue {
599609 type: ' warning'
600610 })
601611 .then (async () => {
602- await confirmLeave (row .id )
612+ await approveFsm ({
613+ category: this .defaultConfig .category ,
614+ uuid: row .fsmUuid ,
615+ // 确认相当于一次审批通过
616+ approved: 1
617+ })
603618 this .getData ()
604619 })
605620 }
606621
607622 private async handleResubmit(row : any ) {
608- await resubmitLeave (row .id )
623+ await approveFsm ({
624+ category: this .defaultConfig .category ,
625+ uuid: row .fsmUuid ,
626+ // 重新提交相当于一次审批通过
627+ approved: 1
628+ })
609629 this .getData ()
610630 }
611631
@@ -617,7 +637,10 @@ export default class extends Vue {
617637 type: ' warning'
618638 })
619639 .then (async () => {
620- await cancelLeave (row .id )
640+ await cancelFsm ({
641+ category: this .defaultConfig .category ,
642+ uuids: [row .fsmUuid ]
643+ })
621644 this .getData ()
622645 })
623646 }
@@ -721,7 +744,7 @@ export default class extends Vue {
721744 margin-bottom : 15px ;
722745 }
723746 .el-steps {
724- width : 50 % ;
747+ width : 70 % ;
725748 margin : 0 auto ;
726749 }
727750 }
0 commit comments