|
|
@@ -1,5 +1,6 @@
|
|
|
<script setup lang="ts">
|
|
|
import apis from "@a"
|
|
|
+import appStore from "@s"
|
|
|
const props = withDefaults(
|
|
|
defineProps<{
|
|
|
modelValue?: string | number
|
|
|
@@ -34,12 +35,26 @@ function handleNodeClick(data: any) {
|
|
|
function loadTreeData() {
|
|
|
if (data?.value) {
|
|
|
treeData.value = data.value
|
|
|
+ if (treeData.value.length > 0) {
|
|
|
+ initDefaultKey(treeData.value[0].id)
|
|
|
+ }
|
|
|
} else {
|
|
|
apis.system.userApi.deptTreeSelect().then((res) => {
|
|
|
treeData.value = res.data
|
|
|
+ if (treeData.value.length > 0) {
|
|
|
+ initDefaultKey(treeData.value[0].id)
|
|
|
+ }
|
|
|
})
|
|
|
}
|
|
|
}
|
|
|
+/** 初始化默认选中 */
|
|
|
+function initDefaultKey(id: any) {
|
|
|
+ emits("update:modelValue", id)
|
|
|
+ setTimeout(() => {
|
|
|
+ treeRef.value.setCurrentKey(id)
|
|
|
+ }, 50)
|
|
|
+}
|
|
|
+
|
|
|
function init() {
|
|
|
loadTreeData()
|
|
|
}
|
|
|
@@ -55,7 +70,7 @@ watch(
|
|
|
</script>
|
|
|
<template>
|
|
|
<div :class="treeBoxClass" :style="treeBoxStyle">
|
|
|
- <el-input v-model="searchWords" placeholder="请输入部门名称" clearable prefix-icon="Search" />
|
|
|
+ <!-- <el-input v-model="searchWords" placeholder="请输入组织机构名称" clearable prefix-icon="Search" /> -->
|
|
|
<el-tree
|
|
|
class="pt-3"
|
|
|
ref="treeRef"
|