<template>
    <a-card :bordered="false">
        <itdm-xm-shuru :tableData1="tableData1" @save="runFlowPathSaveData"></itdm-xm-shuru>
        <itdm-xq-pingshen :tableData2="tableData2"></itdm-xq-pingshen>
        <itdm-gc-shishi :tableData3="tableData3" @save="runFlowPathSaveData"></itdm-gc-shishi>
        <itdm-bg-jiaofu :tableData4="tableData4"></itdm-bg-jiaofu>
        <itdm-xn-jiesuan :tableData5="tableData5" @save="runFlowPathSaveData"></itdm-xn-jiesuan>
    </a-card>
</template>

<script>
import ItdmXmShuru from './itdmXmShuru.vue'
import ItdmXqPingshen from './itdmXqPingshen.vue'
import ItdmGcShishi from './itdmGcShishi.vue'
import ItdmBgJiaofu from './itdmBgJiaofu.vue'
import ItdmXnJiesuan from './itdmXnJiesuan.vue'
import { getYeWU, runFlowPathSaveData } from '@/api/api'
export default {
  components: { ItdmXmShuru, ItdmXqPingshen, ItdmGcShishi, ItdmBgJiaofu, ItdmXnJiesuan },
    data() {
      return {
        querys:{
          id: this.$route.query.id,
        },
        // 接收后端传的json
        tableData1:[],
        tableData2:[],
        tableData3:[],
        tableData4:[],
        tableData5:[],
      }
    },
    created(){
      // this.querys.id = this.$route.query.id
      console.log(this.querys.id)
      this.getList()
    },
    methods: {
      getList(){
        getYeWU(this.querys).then((res) => {
          console.log(11111,res)
          // this.tableData = res.result.stepList
          console.log(JSON.parse(res.result.stepList[0].saveData))
          var arr1 = [], arr2 = [], arr3=[], arr4 = [], arr5 = []
          arr1.push(res.result.stepList[0])
          arr1.push(res.result.stepList[1])
          arr2.push(res.result.stepList[2])
          arr2.push(res.result.stepList[3])
          arr3.push(res.result.stepList[0])
          arr3.push(res.result.stepList[4])
          arr4.push(res.result.stepList[5])
          arr4.push(res.result.stepList[6])
          arr5.push(res.result.stepList[0])
          arr5.push(res.result.stepList[7])
          arr5.push(res.result.stepList[8])
          arr5.push(res.result.stepList[9])
          arr5.push(res.result.stepList[10])
          arr5.push(res.result.stepList[11])
          this.tableData1 = arr1
          this.tableData2 = arr2
          this.tableData3 = arr3
          this.tableData4 = arr4
          this.tableData5 = arr5
          // console.log(this.tableData1)
        })
      },
      runFlowPathSaveData(saveData){
        console.log(JSON.parse(saveData.saveData))
        runFlowPathSaveData(saveData).then(response => {
          console.log('ddd', response)
          if (response.success) {
            this.$message.success(response.message)
            this.getList()
          }
        })
      }
    }
}
</script>

<style>

</style>