commonProcessHistory.vue 4.89 KB
Newer Older
wangdanlei's avatar
wangdanlei committed
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
/**
* @Description: 流程历史记录
* @author wx
* @date 2020/12/28
*/
<template>
  <div class="porcess-history-record-com">
    <dee-up-table
      :options="optionsTree"
      :data="historyRecordData"
      :columns="historyColumns"
    />
    <dee-dialog
      :dialog-visible="dialogVisible"
      title="流程图"
      width="60%"
      @handleClose="handleClose"
    >
      <component :is="comName" v-if="dialogVisible" :ref="comName" :process-instance-id="processInstanceId" />
    </dee-dialog>
  </div>
</template>

<script>
import { getWFInsts, getInstTaskHisTory } from '@/api/workflow/config'
export default {
  name: 'CommonProcessHistory',
  displayName: '流程历史记录',
  modelRelationObjs: ['DxDocument', 'DxPart', 'DxBaseline', 'DxAbstractChangeIssue',
arvin's avatar
arvin committed
30
    'DxChangeItem', 'DxProcessExecutor', 'ExtECM', 'DxCADDocument', 'Contract', 'OutStorageRequest'],
wangdanlei's avatar
wangdanlei committed
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
  props: {
    basicData: {
      type: Object,
      required: true,
      default: () => {}
    },
    modelName: {
      type: String,
      default: () => ''
    }
  },
  data() {
    return {
      dialogVisible: false,
      comName: 'processTracking',
      processInstanceId: '',
      historyRecordData: [],
      historyColumns: [
        { title: '流程名称', key: 'name', minWidth: 150, align: 'center', component: {
          render: (h, params) => {
            return h('div', [
              h('span', {
                class: 'link-style',
                on: {
                  click: () => {
                    this.processInstanceId = params.id
                    this.dialogVisible = true
                  }
                }
              }, params.name || '/')
            ])
          }
        }},
        { title: '任务名称', key: 'taskName', minWidth: 100, align: 'center' },
        { title: '状态', key: 'status', width: 80, align: 'center' },
        { title: '工作责任人', key: 'assigneeName', width: 120, align: 'center' },
        { title: '角色', key: 'participantInfo.pluginShowContent', minWidth: 80, align: 'center', formatter: function(row, column) {
          return row.participantInfo ? row.participantInfo.pluginName === 'authOrg' ? '授权部门' : row.participantInfo.pluginShowContent : '/'
        } },
        { title: '开始时间', key: 'startTime', width: 150, align: 'center' },
        { title: '完成时间', key: 'endTime', width: 150, align: 'center' },
        { title: '处理结果', key: 'result', minWidth: 100, align: 'center' },
        { title: '备注', key: 'comments', align: 'center', minWidth: 100, formatter: function(row, column) {
          return row.comments ? row.comments.join('\n') : ''
        } }

      ],
      optionsTree: {
        fit: true,
        defaultExpandAll: true,
        highlightCurrentRow: true,
        rowKey: 'id'
      },
      pagination: {
        currentPage: 1,
        pageSize: 10,
        total: 0,
        pageSizes: [10, 20, 50]
      }
    }
  },

  computed: {
  },
  watch: {
    basicData: {
      immediate: true,
      deep: true,
      handler: function(val) {
        if (val && val.dxClassname) {
          this.getWFInsts()
        }
      }
    }
  },
  mounted() {
  },
  methods: {
    translateStatus(status) {
      let str = ''
      switch (status) {
        case 'COMPLETE':
          str = '已完成'
          break
        case 'BE_RESOLVED':
          str = '待处理'
          break
        case 'PENDING':
          str = '被委托人待处理'
          break
        case 'RUNNING':
          str = '进行中'
      }
      return str
    },
    getWFInsts() {
      getWFInsts({ pboClass: this.basicData.dxClassname, pboId: this.basicData.versionId || this.basicData.id }).then(res => {
        if (res.items.content && res.items.content.length) {
          this.historyRecordData = []
          res.items.content.forEach((item, index) => {
            getInstTaskHisTory(item.id).then(data => {
              const findItem = this.historyRecordData.find(r => r.id === item.id)
              if (findItem) { return }
              this.historyRecordData.push({
                id: item.id,
                name: item.name,
                status: item.status,
                show: true
              })
              if (data.items && data.items.historyInfo && data.items.historyInfo.length) {
                const historyInfo = data.items.historyInfo.map(x => {
                  const y = JSON.parse(JSON.stringify(x))
                  y.status = this.translateStatus(x.state)
                  y.taskName = x.aliasName || x.name
                  delete y.name
                  return y
                })
                this.$set(this.historyRecordData[index], 'children', historyInfo)
              }
            })
          })
        }
      })
    },
    handleClose() {
      this.processInstanceId = ''
      this.dialogVisible = false
    }
  }
}

</script>
<style lang='scss'>
.link-style{
  color: #2A75CE;
  cursor:pointer;
}
</style>