<template>
  <el-tree :data="customerOrg.customerOrgTree" :props="customerOrg.treeprops" @node-click="treeclick"></el-tree>
</template>
<script>

import { mapState,mapMutations } from 'vuex'
import { getapi, postapi, putapi, deletapi } from "@/api/api";
import { tcdate } from '../../utlis/proFunc'
export default {
  components: {},
  data() {
    return {};
  },
  //<el-tree :data="$store.state.customerOrg.customerOrgTree" :props="$store.state.customerOrg.treeprops" @node-click="treeclick"></el-tree>
  computed:{
    ...mapState(['customerOrg']),
  },
  //创建组件后
  created() {},

  //挂载组件完成
  mounted() {
    //获取体检单位列表树信息
    this.getCustomerOrgTree();
  },

  methods: {
    ...mapMutations(['setData']),
    //获取体检单位列表树信息
    getCustomerOrgTree(){
      //let customerOrgTree = []
      // [
      //   {
      //     displayName: "个人体检", //
      //     id: "00000000-0000-0000-0000-000000000000", //
      //     //treeChildren: [],
      //   },
      //   {
      //     displayName: "组件式", //
      //     id: "10000000-0000-0000-0000-000000000000", //
      //     //treeChildren: [],
      //   },
      // ];
      //console.log('getCustomerOrgTree start')
      // api/app/organization-units/organization-unit-by-is-peis    // api/app/customer-org/by-code-all
      getapi("/api/app/customer-org/by-code-all").then(
        (res) => {
          //customerOrgTree = res.data;
          console.log('res.data',res.data)
          this.setData({ key: 'customerOrg.customerOrgTree', value: res.data})
          tcdate(this.customerOrg.customerOrgTree)
        }        
      );
      
    },

    //获取体检次数列表
    getCustomerOrgRegisterList(){      
      getapi("/api/app/customer-org-register/in_filter").then(
        (res) => {          
          //console.log('res.data',res.data)
          this.setData({ key: 'customerOrg.customerOrgRegisterList', value: res.data})
        }        
      );
    },

    //获取体检次数列表
    getCustomerOrgRegisterList(){      
      getapi("/api/app/customer-org-register/in_filter").then(
        (res) => {          
          //console.log('res.data',res.data)
          this.setData({ key: 'customerOrg.customerOrgRegisterList', value: res.data})
        }        
      );
    },

    //点击树节点
    treeclick(data) {
      //this.$message.success(data.id + " 查询单位详情、体检次数、联系人等信息 " + data.displayName);//   api/app/customer-org/3a0c0439-a5ca-8a63-b2b9-e0eb24cb58b1   
      //getapi(`/api/app/customer-org/3a0c0439-a5ca-8a63-b2b9-e0eb24cb58b1`).then((res) => {        
      getapi(`/api/app/customer-org/${data.id}`).then((res) => {      
        //console.log("res.data", res.data);
        this.setData({ key: 'customerOrg.customerOrgRd', value: res.data})
      });
    },
  },
};
</script>
<style>
</style>