<template>
  <!-- 流程图 -->
  <div class="form-single-fragment" style="position: relative;">
    <el-row>
      <ProcessViewer :xml="taskProcessXml" :finishedInfo="finishedInfo" ref="processviewer" style="height: 370px" />
    </el-row>
  </div>
</template>

<script>
import '../../api/flowStaticDict.js';
import { FlowOperationController } from '../../api/FlowOperationController';
import ProcessViewer from './ProcessViewer.vue';
import { request } from '../../utils/request';
export default {
  name: 'formTaskProcessViewer',
  props: {
    processDefinitionId: {
      type: String,
      required: true
    },
    processInstanceId: {
      type: String
    }
  },
  components: {
    ProcessViewer
  },
  data () {
    return {
      finishedInfo: undefined,
      taskProcessXml: undefined
    }
  },
  methods: {
    async getTaskHighlightData () {
      this.finishedInfo = undefined;
      if (this.processInstanceId == null || this.processInstanceId === '') {
        return;
      }
      
      let params = {
        processInstanceId: this.processInstanceId
      }
       const res = await request('/dt_screen/admin/flow/flowOperation/viewHighlightFlowData', 'get', params, false)
       this.finishedInfo = res.data.data;
      // FlowOperationController.viewHighlightFlowData(this, params).then(res => {
      //   // 已完成节点
      //   this.finishedInfo = res.data;
      // }).catch(e => {});
    },
   async getTaskProcessXml () {
    this.taskProcessXml = undefined;
      let params = {
        processDefinitionId: this.processDefinitionId
      }
       const res = await request('/dt_screen/admin/flow/flowOperation/viewProcessBpmn', 'get', params, false)
       
       this.taskProcessXml = res.data.data;
      // this.taskProcessXml = this.taskProcessXml.data;
   
      // FlowOperationController.viewProcessBpmn(this, params).then(res => {
      //   // 当前流程实例xml
      //   this.taskProcessXml = res.data;
      // }).catch(e => {});
    }
  },
  mounted () {
    this.getTaskHighlightData();
    this.getTaskProcessXml();
  }
}
</script>

<style>
</style>
