为部门管理添加搜索功能
1. 添加部门搜索框,支持搜索部门名称、编码和负责人 2. 部门负责人下拉选择已有搜索功能(show-search和filterUserOption) 3. 实时显示搜索结果数量
This commit is contained in:
parent
3b9fb61312
commit
302def1e7c
@ -396,9 +396,28 @@
|
||||
style="margin-bottom: 16px;"
|
||||
/>
|
||||
|
||||
<!-- 部门搜索框 -->
|
||||
<div style="margin-bottom: 16px;">
|
||||
<a-input-search
|
||||
v-model:value="departmentSearchText"
|
||||
placeholder="搜索部门名称、编码或负责人"
|
||||
allow-clear
|
||||
@search="onDepartmentSearch"
|
||||
@change="onDepartmentSearch"
|
||||
style="max-width: 400px;"
|
||||
>
|
||||
<template #prefix>
|
||||
<Icon name="search" size="sm" />
|
||||
</template>
|
||||
</a-input-search>
|
||||
<span v-if="departmentSearchText" style="margin-left: 12px; color: #888; font-size: 13px;">
|
||||
找到 {{ filteredDepartments.length }} 个部门
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<a-table
|
||||
:columns="departmentColumns"
|
||||
:data-source="departments"
|
||||
:data-source="filteredDepartments"
|
||||
:loading="loading.departments"
|
||||
row-key="id"
|
||||
:pagination="{ pageSize: 10 }"
|
||||
@ -1452,6 +1471,7 @@ const brands = ref<Brand[]>([])
|
||||
const platforms = ref<Platform[]>([])
|
||||
const categories = ref<Category[]>([])
|
||||
const departments = ref<DepartmentOverview[]>([])
|
||||
const departmentSearchText = ref<string>('')
|
||||
const currentScorePool = ref<TeamScorePool | null>(null)
|
||||
const currentDept = ref<DepartmentOverview | null>(null)
|
||||
const scoreAdjustForm = reactive<ScoreAdjustPayload>({
|
||||
@ -1554,6 +1574,30 @@ const departmentUsers = computed(() => {
|
||||
})
|
||||
})
|
||||
|
||||
// 过滤后的部门列表(用于搜索)
|
||||
const filteredDepartments = computed(() => {
|
||||
if (!departmentSearchText.value || !departmentSearchText.value.trim()) {
|
||||
return departments.value
|
||||
}
|
||||
|
||||
const searchText = departmentSearchText.value.trim().toLowerCase()
|
||||
return departments.value.filter(dept => {
|
||||
// 搜索部门名称
|
||||
if (dept.deptName && dept.deptName.toLowerCase().includes(searchText)) {
|
||||
return true
|
||||
}
|
||||
// 搜索部门编码
|
||||
if (dept.deptCode && dept.deptCode.toLowerCase().includes(searchText)) {
|
||||
return true
|
||||
}
|
||||
// 搜索负责人名称
|
||||
if (dept.leaderName && dept.leaderName.toLowerCase().includes(searchText)) {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
})
|
||||
})
|
||||
|
||||
const hasUserData = computed(() => {
|
||||
return unassignedUsers.value.length > 0 || departmentUserCards.value.some((dept) => dept.users.length > 0)
|
||||
})
|
||||
@ -1832,6 +1876,12 @@ const filterUserOption = (input: string, option: any) => {
|
||||
return realName.includes(searchText) || username.includes(searchText)
|
||||
}
|
||||
|
||||
// 部门搜索处理
|
||||
const onDepartmentSearch = () => {
|
||||
// 搜索逻辑通过 computed 属性 filteredDepartments 自动处理
|
||||
// 此方法仅用于响应搜索事件,实际过滤在 computed 中完成
|
||||
}
|
||||
|
||||
// 显示积分池管理弹窗
|
||||
const showScorePoolModal = async (dept: DepartmentOverview) => {
|
||||
if (!dept.id) return
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user