<!--
  @description:采购结果-审核列表组件
  @Modifier:gmy
  @routerPath:
  @date:2020/7/15-9:54
-->
<template>
  <div>
    <el-table ref="multipleTable" :data="flowList">
      <el-table-column header-align="center" prop="processNodeName" label="角色/岗位" />
      <el-table-column header-align="center" prop="processUserRname" label="处理人" />
      <el-table-column
        :formatter="formatTeviewType"
        header-align="center"
        prop="teviewType"
        align="center"
        label="处理意见"
      />
      <el-table-column header-align="center" prop="endDate" align="center" label="处理时间" />
      <el-table-column header-align="center" prop="comment" label="意见说明" />
    </el-table>
  </div>
</template>

<script>
/* api*/
import { findProIdByBizId, historyFlowList } from '@/api/work/work'
import { workCommonGroup } from '@views/work/mixins/workCommonGroup'
/* 公用方法*/
import { filterDictText } from '@/assets/js/utils'// 常用方法
export default {
  name: 'ProcurementResultAuditListVue',
  mixins: [workCommonGroup],
  props: {
    // 业务id
    bizId: {
      type: String,
      default: ''
    },
    //  00为其它列表查看流程追踪 01为待办/办结列表查看（取实例化id方式不同processInstanceId）
    flowType: {
      type: String,
      default: ''
    }
  },
  data() {
    return {
      flowList: []
    }
  },
  watch: {
    'bizId'(val) {
      if (val) {
        this.getFindProIdByBizId()
      }
    }
  },
  created() {
    this.initData()
  },
  methods: {
    filterDictText, // 字典值替换文本通用方法
    // 00为其它列表查看流程追踪 01为待办/办结列表查看（取实例化id方式不同processInstanceId）
    initData() {
      if (this.flowType === '01') {
        const processInstanceId = this.$route.query.processInstanceId || this.$route.params.processInstanceId// 实例化id
        this.getHistoryFlowList(processInstanceId)
      } else {
        this.getFindProIdByBizId()
      }
      this.dialogVisible = true
    },
    // 其它列表查看流程追踪 根据主键id 获取流程实例化id
    getFindProIdByBizId() {
      findProIdByBizId(this.bizId).then(res => {
        const { data: { data }} = res
        this.getHistoryFlowList(data)
      })
    },
    // 历史流程信息
    getHistoryFlowList(processInstanceId) {
      historyFlowList(processInstanceId).then(res => {
        const flowData = res.data.data
        flowData.reverse()
        this.flowList = flowData
      }).catch(() => {
      })
    },
    // 处理字典信息，处理意见
    formatTeviewType(row, column, cellValue) {
      return filterDictText(this.teviewTypeList, cellValue)
    }
  }
}
</script>

<style scoped lang="less">
</style>
