|
|
@@ -1,9 +1,8 @@
|
|
|
<script lang="ts" setup name="GroupSelector">
|
|
|
-import { getGroupByList } from '@/api/system/groupApi'
|
|
|
-import { packageTreeData } from '@/utils/tool'
|
|
|
-
|
|
|
+import { getGroupView } from '@/api/system/groupApi'
|
|
|
const emit = defineEmits(['update:modelValue'])
|
|
|
interface TreeNode {
|
|
|
+ id: number
|
|
|
label: string
|
|
|
groupId: number
|
|
|
children?: TreeNode[]
|
|
|
@@ -15,32 +14,37 @@ const state = reactive({
|
|
|
dataList: [] as TreeNode[],
|
|
|
})
|
|
|
|
|
|
+const treeRef = ref()
|
|
|
+
|
|
|
const getData = async () => {
|
|
|
state.loading = true
|
|
|
- const { data } = await getGroupByList()
|
|
|
-
|
|
|
- state.dataList = packageTreeData({
|
|
|
- data,
|
|
|
- id: 'groupId',
|
|
|
- })
|
|
|
+ const { data } = await getGroupView()
|
|
|
+ state.dataList = data
|
|
|
}
|
|
|
|
|
|
watch(() => state.groupId, (newValue) => {
|
|
|
emit('update:modelValue', newValue)
|
|
|
})
|
|
|
|
|
|
+watch(() => 'modelValue', (newValue) => {
|
|
|
+ // emit('update:modelValue', newValue)
|
|
|
+ window.console.log(newValue)
|
|
|
+})
|
|
|
+
|
|
|
onMounted(() => {
|
|
|
getData ()
|
|
|
+ treeRef.value.currentNodeKey = state.groupId
|
|
|
})
|
|
|
</script>
|
|
|
|
|
|
<template>
|
|
|
<el-tree-select
|
|
|
+ ref="treeRef"
|
|
|
v-model="state.groupId"
|
|
|
:data="state.dataList"
|
|
|
style="width: 100%"
|
|
|
filterable
|
|
|
placeholder="请选择部门"
|
|
|
- :render-after-expand="false"
|
|
|
+ default-expand-all
|
|
|
/>
|
|
|
</template>
|