Skip to content

Commit 643b387

Browse files
committed
REVIEW 用户管理(列表)
1 parent 1434cda commit 643b387

File tree

5 files changed

+130
-201
lines changed

5 files changed

+130
-201
lines changed

src/api/system/user/index.ts

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -17,23 +17,8 @@ export interface UserVO {
1717
createTime: Date
1818
}
1919

20-
export interface UserPageReqVO extends PageParam {
21-
deptId?: number
22-
username?: string
23-
mobile?: string
24-
status?: number
25-
createTime?: Date[]
26-
}
27-
28-
export interface UserExportReqVO {
29-
code?: string
30-
name?: string
31-
status?: number
32-
createTime?: Date[]
33-
}
34-
3520
// 查询用户管理列表
36-
export const getUserPageApi = (params: UserPageReqVO) => {
21+
export const getUserPage = (params: PageParam) => {
3722
return request.get({ url: '/system/user/page', params })
3823
}
3924

@@ -53,12 +38,12 @@ export const updateUserApi = (data: UserVO | Recordable) => {
5338
}
5439

5540
// 删除用户
56-
export const deleteUserApi = (id: number) => {
41+
export const deleteUser = (id: number) => {
5742
return request.delete({ url: '/system/user/delete?id=' + id })
5843
}
5944

6045
// 导出用户
61-
export const exportUserApi = (params: UserExportReqVO) => {
46+
export const exportUser = (params) => {
6247
return request.download({ url: '/system/user/export', params })
6348
}
6449

src/views/system/tenantPackage/index.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ const { t } = useI18n() // 国际化
112112
const loading = ref(true) // 列表的加载中
113113
const total = ref(0) // 列表的总页数
114114
const list = ref([]) // 列表的数据
115-
const queryParams: Record<string, any> = ref<Record<string, any>>({
115+
const queryParams = reactive({
116116
pageNo: 1,
117117
pageSize: 10,
118118
name: null,

src/views/system/user/components/UserDeptTree.vue renamed to src/views/system/user/DeptTree.vue

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
<template>
22
<div class="head-container">
3-
<el-input v-model="deptName" placeholder="请输入部门名称" clearable style="margin-bottom: 20px">
3+
<el-input v-model="deptName" placeholder="请输入部门名称" clearable class="mb-20px">
44
<template #prefix>
55
<Icon icon="ep:search" />
66
</template>
77
</el-input>
88
</div>
99
<div class="head-container">
1010
<el-tree
11-
:data="deptOptions"
11+
:data="deptList"
1212
:props="defaultProps"
13+
node-key="id"
1314
:expand-on-click-node="false"
1415
:filter-node-method="filterNode"
1516
ref="treeRef"
16-
node-key="id"
1717
default-expand-all
1818
highlight-current
19-
@node-click="handleDeptNodeClick"
19+
@node-click="handleNodeClick"
2020
/>
2121
</div>
2222
</template>
@@ -26,25 +26,30 @@ import { ElTree } from 'element-plus'
2626
import * as DeptApi from '@/api/system/dept'
2727
import { defaultProps, handleTree } from '@/utils/tree'
2828
29-
const emits = defineEmits(['node-click'])
3029
const deptName = ref('')
31-
const deptOptions = ref<Tree[]>([]) // 树形结构
30+
const deptList = ref<Tree[]>([]) // 树形结构
3231
const treeRef = ref<InstanceType<typeof ElTree>>()
32+
33+
/** 获得部门树 */
3334
const getTree = async () => {
3435
const res = await DeptApi.getSimpleDeptList()
35-
deptOptions.value = []
36-
deptOptions.value.push(...handleTree(res))
36+
deptList.value = []
37+
deptList.value.push(...handleTree(res))
3738
}
3839
39-
const filterNode = (value: string, data: Tree) => {
40-
if (!value) return true
41-
return data.name.includes(value)
40+
/** 基于名字过滤 */
41+
const filterNode = (name: string, data: Tree) => {
42+
if (!name) return true
43+
return data.name.includes(name)
4244
}
4345
44-
const handleDeptNodeClick = async (row: { [key: string]: any }) => {
46+
/** 处理部门被点击 */
47+
const handleNodeClick = async (row: { [key: string]: any }) => {
4548
emits('node-click', row)
4649
}
50+
const emits = defineEmits(['node-click'])
4751
52+
/** 初始化 */
4853
onMounted(async () => {
4954
await getTree()
5055
})

src/views/system/user/components/UserForm.vue

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
<el-select v-model="formData.sex" placeholder="请选择">
5757
<el-option
5858
v-for="dict in getIntDictOptions(DICT_TYPE.SYSTEM_USER_SEX)"
59-
:key="dict.value as number"
59+
:key="dict.value"
6060
:label="dict.label"
6161
:value="dict.value"
6262
/>
@@ -70,7 +70,7 @@
7070
v-for="item in postOptions"
7171
:key="item.id"
7272
:label="item.name"
73-
:value="item.id as number"
73+
:value="item.id"
7474
/>
7575
</el-select>
7676
</el-form-item>
@@ -102,7 +102,6 @@ import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
102102
import { defaultProps, handleTree } from '@/utils/tree'
103103
import { ElForm, FormItemRule } from 'element-plus'
104104
import { Arrayable } from 'element-plus/es/utils'
105-
import { UserVO } from '@/api/login/types'
106105
107106
type Form = InstanceType<typeof ElForm>
108107
@@ -210,7 +209,8 @@ const cancel = () => {
210209
}
211210
212211
/* 打开弹框 */
213-
const openForm = (row: undefined | UserVO) => {
212+
const open = (type: string, id?: number) => {
213+
console.log(type, id)
214214
resetForm()
215215
getTree() // 部门树
216216
if (row && row.id) {
@@ -232,6 +232,6 @@ onMounted(async () => {
232232
233233
defineExpose({
234234
resetForm,
235-
openForm
235+
open
236236
})
237237
</script>

0 commit comments

Comments
 (0)