<template>
  <a-tree-select
    :allowClear="true"
    :dropdownStyle="{ maxHeight: '220px', overflow: 'auto' }"
    :treeData="deptTreeData"
    v-model="value">
  </a-tree-select>
</template>

<script>
export default {
  name: 'DetpInputTree',
  data () {
    return {
      deptTreeData: [],
      value: undefined
    }
  },
  methods: {
    reset () {
      this.value = ''
    }
  },

  //此处构建部门树
  mounted () {
    this.$get('api/v1/authDepartment/queryAllDepartmentTree').then((r) => {
      //this.deptTreeData = r.data.rows.children
      let children = r.data.data.children

      if('' != children && null != children && children.length > 0){
        this.deptTreeData = r.data.data.children
      }else{
        console.log("没有返回部门")
      }
    })
  },
  watch: {
    value (value) {
      this.$emit('change', value)
    }
  }
}
</script>
