/components/bpmnProcessDesigner/package/penal/task/task-components/

路径新建一个 DeptTree 用于设计面板的部门选择
This commit is contained in:
XaoLi717 2024-07-25 08:10:51 +08:00
parent 4185e78957
commit ce16808cb1

View File

@ -0,0 +1,62 @@
<template>
<div class="head-container">
<el-input v-model="deptName" class="mb-20px" clearable placeholder="请输入部门名称" style="width: 280px">
<template #prefix>
<Icon icon="ep:search" />
</template>
</el-input>
</div>
<div class="head-container">
<el-tree
ref="treeRef"
:data="deptList"
:expand-on-click-node="false"
:filter-node-method="filterNode"
:props="defaultProps"
highlight-current
node-key="id"
@node-click="handleNodeClick"
/>
</div>
</template>
<script lang="ts" setup>
import { ElTree } from 'element-plus'
import * as DeptApi from '@/api/system/dept'
import { defaultProps, handleTree } from '@/utils/tree'
defineOptions({ name: 'SystemUserDeptTree' })
const deptName = ref('')
const deptList = ref<Tree[]>([]) //
const treeRef = ref<InstanceType<typeof ElTree>>()
/** 获得部门树 */
const getTree = async () => {
const res = await DeptApi.getSimpleDeptList()
deptList.value = []
deptList.value.push(...handleTree(res))
}
/** 基于名字过滤 */
const filterNode = (name: string, data: Tree) => {
if (!name) return true
return data.name.includes(name)
}
/** 处理部门被点击 */
const handleNodeClick = async (row: { [key: string]: any }) => {
emits('node-click', row)
}
const emits = defineEmits(['node-click'])
/** 监听deptName */
watch(deptName, (val) => {
treeRef.value!.filter(val)
})
/** 初始化 */
onMounted(async () => {
await getTree()
})
</script>