<template>
  <div>
<!-- 所有网格 -->
    <el-tree
      :data="data"
      :props="defaultProps"
      @node-click="handleNodeClick"
      :highlight-current="true"
    >
      <span class="span-ellipsis" slot-scope="{ node, data }">
        <i class="el-icon-menu" v-if="data.nodeTag==='top' || data.nodeTag==='street' || data.nodeTag==='community'"> </i>
        <i class="el-icon-s-custom"  v-if=" data.nodeTag==='user'"> </i>
        <span :title="node.label">{{ node.label }}</span> 
      </span> 
    </el-tree>
<!-- 专管单位 -->
    <el-tree
      :data="data2"
      :props="defaultProps"
      @node-click="handleNodeClicks"
      :highlight-current="true"
    >
      <span class="span-ellipsis" slot-scope="{ node, data }">
        <i class="el-icon-menu" v-if="data.nodeTag==='top' || data.nodeTag==='dept' "> </i>
        <i class="el-icon-s-custom"  v-if="data.nodeTag==='user'"> </i>
        <span :title="node.label">{{ node.label }}</span> 
      </span>
    </el-tree>
  </div>
</template>
    
<script>
import {getsuoyouwangge,getzhuanguandanwei}  from '@/api/detailDitu' 
export default {
  data() {
    return {
      // 所有网格 
      data: [],
      // 专管单位 
      data2: [],
      defaultProps: {
        children: "children",
        label: "lable",
      },
    };
  },
  created() {
     this.getsuoyouwangge()
     this.getzhuanguandanwei()
     
     
  },
  methods: {
     async getsuoyouwangge(){
         
          
          const res = await getsuoyouwangge ()
          this.data = res.data
          this.$emit('initOut', res.data[0])
          // console.log(this.data, 'getsuoyouwangge');
         
     },
     async getzhuanguandanwei(){
          const res = await getzhuanguandanwei ()
          this.data2 = res.data
          //  console.log(this.data2);
     },
    //  async getpianqu(){
    //       const res = await getpianqu ()
    //        console.log(res);
    //  },
   
    handleNodeClick(data) {
        // console.log(data,'data');
      this.$emit('handleNodeClick',data)
    },
    handleNodeClicks(data){
      //  console.log(data);
      this.$emit('handleNodeClicks',data)
    }
  },
};
</script>

<style>
.el-icon-menu ,.el-icon-reading,.el-icon-s-custom{
  color:#142380;
}
</style>