<template>
  <div class="w100">
    <el-tree-select
      v-model="value"
      :data="treeData"
      placeholder="请选择组织机构"
      :default-expand-all="true"
      class="w100"
      check-strictly
      node-key="id"
      :render-after-expand="false"
      @change="handleCheckChange"
      :default-checked-keys="[uid]"
      :props="props"
    >
    </el-tree-select>
  </div>
</template>

<script setup lang="ts">
import { defineExpose, reactive, onMounted, ref, watch, watchEffect } from "vue";
import { type } from "os";
import { userApi } from "/@/api/sys/role";
// import { setBackEndControlRefreshRoutes } from "/@/router/backEnd";
// 定义变量内容
const treeData = ref();
const value = ref();

const props = {
  label: "name",
  children: "children",
};
const uid = ref("");

const emit = defineEmits(["getvalue"]);

function handleCheckChange(node: any) {
  emit("getvalue", node);
}
async function loadData(type: String, row?: any) {
  value.value = "";
  // 组织机构
  let treeitem = await userApi().selectTree();
  treeData.value = treeitem.data;
  if (type == "edit") {

    uid.value = row;
  }
}
defineExpose({
  loadData,
});
</script>
