diff --git a/config/vite.config.dev.ts b/config/vite.config.dev.ts index 7ed0243..c462ff3 100644 --- a/config/vite.config.dev.ts +++ b/config/vite.config.dev.ts @@ -14,7 +14,8 @@ export default mergeConfig( proxy: { '/api': { // target: 'http://8.134.75.234:8081', - target: 'http://192.168.3.238:8081', + // target: 'http://192.168.3.238:8081', + target: 'http://localhost:8081', changeOrigin: true, }, }, diff --git a/src/api/dept.ts b/src/api/dept.ts index 70a1ac0..6aa0d42 100644 --- a/src/api/dept.ts +++ b/src/api/dept.ts @@ -11,6 +11,12 @@ export interface DeptRecord extends DeptCreateRecord { id: string; } +export interface DeptTreeData { + id: number; + label: string; + children?: DeptTreeData[]; +} + // 获取部门树 export function getAllDeptTree(id?: number | string) { return axios({ diff --git a/src/views/system/user/components/dept-tree.vue b/src/views/system/user/components/dept-tree.vue new file mode 100644 index 0000000..229c371 --- /dev/null +++ b/src/views/system/user/components/dept-tree.vue @@ -0,0 +1,110 @@ + + + + + {{ nodeData?.label }} + + {{ nodeData?.title?.slice(0, index) }} + + {{ nodeData?.title?.slice(index, index + searchKey.length) }} + + {{ nodeData?.title?.slice(index + searchKey.length) }} + + + + + + + + + + \ No newline at end of file diff --git a/src/views/system/user/components/user-edit.vue b/src/views/system/user/components/user-edit.vue index a805d27..c0b8702 100644 --- a/src/views/system/user/components/user-edit.vue +++ b/src/views/system/user/components/user-edit.vue @@ -145,7 +145,7 @@ import { computed, PropType, ref } from 'vue'; import { CreateRecord } from '@/api/user'; import { FormInstance } from '@arco-design/web-vue/es/form'; import { queryRoleList } from '@/api/role'; -import { deptList } from '@/api/dept'; +import { deptList, getAllDeptTree } from '@/api/dept'; import { Message } from '@arco-design/web-vue'; import { useUserStore } from '@/store'; @@ -184,8 +184,8 @@ const userStore = useUserStore(); // 部门数据 const deptOptions = ref(); const getDeptData = async () => { - const res = await deptList(); - deptOptions.value = res.data.records; + const res = await getAllDeptTree(0); + deptOptions.value = res.data; }; // 角色数据 const roleOptions = ref(); diff --git a/src/views/system/user/index.vue b/src/views/system/user/index.vue index ff00272..e94efdd 100644 --- a/src/views/system/user/index.vue +++ b/src/views/system/user/index.vue @@ -1,224 +1,245 @@ - - - - - - - - - - + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - {{ $t('searchTable.form.search') }} - - - - - - {{ $t('searchTable.form.reset') }} - - - - + + + + + + + + + + + + + - - - - - - - - - - - {{ $t('searchTable.operation.download') }} - - - + + + + + + + + + + + + + + + + + + + + + + + + + {{ $t('searchTable.form.search') }} + + + + + + {{ $t('searchTable.form.reset') }} + + + + + + + + + + + + + + + + {{ $t('searchTable.operation.download') }} + + + - - - - - - - - - - - - - {{ item.name }} - - - - - - - - - - + + + + + + + + + + + - - - - - {{ item.name }} + + + + + + + + + + + + + + + - + > + + + + {{ item.title === '#' ? '序列号' : item.title }} + + - - {{ item.title === '#' ? '序列号' : item.title }} - - - - - - - - + + + + + - - - {{ rowIndex + 1 + (pagination.current - 1) * pagination.size }} - - - - - - - - - - - - - - - - - + + {{ rowIndex + 1 + (pagination.current - 1) * pagination.size }} + + + + + + + + + + + + + + + + + + + + @@ -227,6 +248,7 @@ import { useI18n } from 'vue-i18n'; import useLoading from '@/hooks/loading'; import { UserRecord, UserParams } from '@/api/user'; +import { getAllDeptTree } from '@/api/dept'; import { Pagination } from '@/types/global'; import type { SelectOptionData } from '@arco-design/web-vue/es/select/interface'; import type { TableColumnData } from '@arco-design/web-vue/es/table/interface'; @@ -235,6 +257,7 @@ import { Message } from '@arco-design/web-vue'; import { downloadExcel, DownloadExcelPrams } from '@/utils/excel'; import useTableOption from '@/hooks/table-option'; import UserEdit from './components/user-edit.vue'; +import DeptTree from './components/dept-tree.vue'; const generateFormModel = () => { return { @@ -243,7 +266,8 @@ const generateFormModel = () => { phone: '', email: '', createdTime: [], - enable: '', + enableState: '', + deptId: '', }; }; @@ -314,8 +338,8 @@ const columns = computed(() => [ }, { title: t('userTable.columns.enabled'), - dataIndex: 'enabled', - slotName: 'enabled', + dataIndex: 'enableState', + slotName: 'enableState', }, { title: t('searchTable.columns.operations'), @@ -333,6 +357,7 @@ const statusOptions = computed(() => [ value: 'false', }, ]); +const deptTreeData = ref([]); // 获取用户列表 const fetchData = async ( @@ -353,6 +378,14 @@ const fetchData = async ( } }; +// 获取部门树 + const getDeptTree = async () => { + const res = await getAllDeptTree(0); + if (res.status === 200) { + deptTreeData.value = res.data; + } + } + // 下载表格 const generateExcel = () => { const param: DownloadExcelPrams = { @@ -363,7 +396,7 @@ const generateExcel = () => { { title: '部门Id', key: 'deptId' }, { title: '角色Id', key: 'roleId' }, { title: 'email', key: 'email' }, - { title: '启用状态', key: 'enabled' }, + { title: '启用状态', key: 'enableState' }, ], rows: renderData.value, name: '用户表格', @@ -374,7 +407,7 @@ const generateExcel = () => { // 查询 const search = () => { fetchData({ - ...pagination, + // ...pagination, ...formModel.value, } as unknown as UserParams); }; @@ -394,6 +427,7 @@ const onSizeChange = (size: number) => { onMounted(() => { search(); + // getDeptTree() }) // 重置 @@ -407,7 +441,7 @@ const handleSortChange = (data: any, extra: any, currentDataSource: any) => {}; // 是否启用 const enabledStatus = async (record: any) => { - record.enabled = !record.enabled; + record.enableState = !record.enableState; const res = await userStore.enabledUser(record.id); if (res.status === 200) { Message.success({ @@ -421,6 +455,22 @@ const enabledStatus = async (record: any) => { }); } }; + const generateQueryParams = () => { + return { + pageNum: 1, + pageSize: 10, + userName: undefined, + phonenumber: undefined, + status: undefined, + deptId: undefined, + params: undefined, + }; + }; + const handleSelectDept = (id: any[]) => { + const [deptId] = id; + formModel.value.deptId = deptId; + search(); + } // 删除 // const handleDelete = async (record: UserRecord) => { @@ -442,7 +492,6 @@ export default { name: 'User', }; -