<template>
    <div>
      <flow-records :xmlData="xmlData" :taskData="taskList" :flowRecordList="flowRecordList"></flow-records>
    </div>
  </template>
  <script>
  import flowRecords from '@/components/flow/flowRecord.vue'
  import { setStorage } from '@/utils/auth'
  import { getFlowViewer, readXml } from '@/api/flow/todo'
  import req from '@/api/Yjsq/index'
  
  export default {
    name: 'flowRecordForBusiness',
    components: {
      flowRecords
    },
    props: {
      uploadData: {
        type: Object,
        default: {}
      }
    },
    data() {
      return {
        taskList: [],
        xmlData: '',
        flowRecordList: []
      }
    },
    created() {
      const obj = this.uploadData
    //   this.obj = obj
      var token = obj.token
      setStorage(token)
      console.log(obj)
      this.getFlowViewer(obj.procInsId)
      this.getModelDetail(obj.deployId)
      this.getFlowRecordList(obj.procInsId, obj.deployId)
      window.parent.postMessage({
        cmd: 'returnHeight',
        params: {
          // 告诉父级页面，子页面的弹框高度。
          code: 2,
          data: 600 + 'px'
        }
      }, '*')
    },
    methods: {
      /** xml 文件 */
      getModelDetail(deployId) {
        // 发送请求，获取xml
        readXml(deployId).then(res => {
          this.xmlData = res.data
        })
      },
      // 已办环节的节点
      getFlowViewer(procInsId) {
        getFlowViewer(procInsId).then(res => {
          this.taskList = res.data
        })
      },
      /** 流程流转记录 */
      getFlowRecordList(procInsId, deployId) {
        // const params = { procInsId: procInsId, deployId: deployId }
        req.flowRecord(procInsId,deployId).then(res => {
          this.flowRecordList = res.data.flowList
          // 流程过程中不存在初始化表单 直接读取的流程变量中存储的表单值
        //   if (res.data.formData) {
        //     this.formConf = res.data.formData
        //     this.formConfOpen = true
        //   }
        }).catch(res => {
          this.getList()
        })
      }
    }
  }
  </script>
  