<template>
  <table-dialog
    ref="tableDialog"
    title="流程历史"
    :schema="historySchema"
  />
</template>

<script>
import { WorkflowStateInfo } from '@/constant'
import { getWorkflowHistory } from '../api'

export default {
  name: 'WorkflowHistoryDialog',
  data () {
    return {
      historySchema: {
        nonPagination: true,
        list: this.getWorkflowHistory,
        transform: this.transformHistory,
        cols: [
          { label: '节点', render: ({ status }) => WorkflowStateInfo[status], width: 100, align: 'center' },
          { prop: 'handledBy', label: '处理人', width: 160, align: 'center' },
          { prop: 'createTime', label: '处理时间', align: 'center' },
          { prop: 'reason', label: '备注', align: 'right' }
        ]
      }
    }
  },
  methods: {
    show (workflowId) {
      this.$workflowId = workflowId
      this.$refs.tableDialog.show()
    },
    getWorkflowHistory () {
      return getWorkflowHistory(this.$workflowId)
    }
  }
}
</script>
