mirror of
https://github.com/chansee97/nova-admin.git
synced 2025-11-18 22:52:14 +08:00
feat: 角色管理部门搜索
This commit is contained in:
parent
82933cfa22
commit
0f4325fd68
@ -1,11 +1,10 @@
|
|||||||
import { request } from '../../utils/alova'
|
import { request } from '../../utils/alova'
|
||||||
|
|
||||||
// 用户查询参数接口
|
// 用户查询参数接口
|
||||||
interface UserQueryParams {
|
export interface UserQueryParams {
|
||||||
pageNum?: number
|
pageNum?: number
|
||||||
pageSize?: number
|
pageSize?: number
|
||||||
username?: string
|
username?: string
|
||||||
gender?: 'male' | 'female' | 'unknown'
|
|
||||||
status?: number
|
status?: number
|
||||||
deptId?: number
|
deptId?: number
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,12 +1,21 @@
|
|||||||
<script setup lang="tsx">
|
<script setup lang="tsx">
|
||||||
import { createProSearchForm, useNDataTable } from 'pro-naive-ui'
|
import { createProSearchForm, useNDataTable } from 'pro-naive-ui'
|
||||||
import { deleteUser, getUserList, updateUser } from '@/api'
|
import type { TreeOption } from 'naive-ui'
|
||||||
|
import { deleteUser, getDeptOptions, getUserList, updateUser } from '@/api'
|
||||||
import { createUserColumns, searchColumns } from './columns'
|
import { createUserColumns, searchColumns } from './columns'
|
||||||
import UserModal from './components/UserModal.vue'
|
import UserModal from './components/UserModal.vue'
|
||||||
|
|
||||||
|
const modalRef = ref()
|
||||||
|
const treeData = ref<any[]>([])
|
||||||
|
const deptPattern = ref('')
|
||||||
|
const selectedDeptId = ref<number>()
|
||||||
|
|
||||||
const searchForm = createProSearchForm({
|
const searchForm = createProSearchForm({
|
||||||
initialValues: {
|
initialValues: {
|
||||||
},
|
},
|
||||||
|
onReset() {
|
||||||
|
selectedDeptId.value = undefined
|
||||||
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
const {
|
const {
|
||||||
@ -21,8 +30,6 @@ const {
|
|||||||
form: searchForm,
|
form: searchForm,
|
||||||
})
|
})
|
||||||
|
|
||||||
const modalRef = ref()
|
|
||||||
|
|
||||||
async function delteteUser(id: number) {
|
async function delteteUser(id: number) {
|
||||||
try {
|
try {
|
||||||
await deleteUser(id)
|
await deleteUser(id)
|
||||||
@ -40,7 +47,6 @@ async function updateUserStatus(id: number, value: 0 | 1) {
|
|||||||
refresh() // 重新加载列表
|
refresh() // 重新加载列表
|
||||||
}
|
}
|
||||||
catch {
|
catch {
|
||||||
window.$message.error('角色状态更新失败')
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -54,6 +60,7 @@ async function getUserPage({ current, pageSize }: any, formData: Entity.User[])
|
|||||||
try {
|
try {
|
||||||
const { data } = await getUserList({
|
const { data } = await getUserList({
|
||||||
...formData,
|
...formData,
|
||||||
|
deptId: selectedDeptId.value,
|
||||||
pageNum: current,
|
pageNum: current,
|
||||||
pageSize,
|
pageSize,
|
||||||
})
|
})
|
||||||
@ -67,41 +74,53 @@ async function getUserPage({ current, pageSize }: any, formData: Entity.User[])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const treeData = ref([
|
// 加载部门树数据
|
||||||
{
|
async function loadDeptTree() {
|
||||||
id: '1',
|
try {
|
||||||
label: '安徽总公司',
|
const { data } = await getDeptOptions()
|
||||||
children: [
|
treeData.value = data
|
||||||
{
|
}
|
||||||
id: '2',
|
catch (error) {
|
||||||
label: '合肥分公司',
|
console.error('加载部门数据失败:', error)
|
||||||
children: [
|
treeData.value = []
|
||||||
{
|
}
|
||||||
id: '4',
|
}
|
||||||
label: '财务部门',
|
|
||||||
},
|
// 处理树节点点击
|
||||||
{
|
function handleTreeNodeClick(deptId: number) {
|
||||||
id: '5',
|
selectedDeptId.value = deptId
|
||||||
label: '采购部门',
|
// 触发搜索
|
||||||
},
|
refresh()
|
||||||
],
|
}
|
||||||
},
|
|
||||||
{
|
// 组件挂载时加载部门树
|
||||||
id: '3',
|
onMounted(() => {
|
||||||
label: '芜湖分公司',
|
loadDeptTree()
|
||||||
},
|
})
|
||||||
],
|
|
||||||
},
|
|
||||||
])
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<n-flex>
|
<n-flex>
|
||||||
<n-card class="w-70">
|
<n-card class="w-70">
|
||||||
|
<template #header>
|
||||||
|
<n-input v-model:value="deptPattern" placeholder="部门搜索">
|
||||||
|
<template #prefix>
|
||||||
|
<n-icon>
|
||||||
|
<icon-park-outline-search />
|
||||||
|
</n-icon>
|
||||||
|
</template>
|
||||||
|
</n-input>
|
||||||
|
</template>
|
||||||
<n-tree
|
<n-tree
|
||||||
block-line
|
block-line
|
||||||
:data="treeData"
|
:data="treeData"
|
||||||
key-field="id"
|
key-field="value"
|
||||||
|
:pattern="deptPattern"
|
||||||
|
:node-props="({ option }: { option: TreeOption }) => {
|
||||||
|
return {
|
||||||
|
onClick: () => handleTreeNodeClick(option.value as number),
|
||||||
|
}
|
||||||
|
}"
|
||||||
/>
|
/>
|
||||||
</n-card>
|
</n-card>
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user