Commit 643b3873 by YunaiV

REVIEW 用户管理(列表)

parent 1434cdab
......@@ -17,23 +17,8 @@ export interface UserVO {
createTime: Date
}
export interface UserPageReqVO extends PageParam {
deptId?: number
username?: string
mobile?: string
status?: number
createTime?: Date[]
}
export interface UserExportReqVO {
code?: string
name?: string
status?: number
createTime?: Date[]
}
// 查询用户管理列表
export const getUserPageApi = (params: UserPageReqVO) => {
export const getUserPage = (params: PageParam) => {
return request.get({ url: '/system/user/page', params })
}
......@@ -53,12 +38,12 @@ export const updateUserApi = (data: UserVO | Recordable) => {
}
// 删除用户
export const deleteUserApi = (id: number) => {
export const deleteUser = (id: number) => {
return request.delete({ url: '/system/user/delete?id=' + id })
}
// 导出用户
export const exportUserApi = (params: UserExportReqVO) => {
export const exportUser = (params) => {
return request.download({ url: '/system/user/export', params })
}
......
......@@ -112,7 +112,7 @@ const { t } = useI18n() // 国际化
const loading = ref(true) // 列表的加载中
const total = ref(0) // 列表的总页数
const list = ref([]) // 列表的数据
const queryParams: Record<string, any> = ref<Record<string, any>>({
const queryParams = reactive({
pageNo: 1,
pageSize: 10,
name: null,
......
<template>
<div class="head-container">
<el-input v-model="deptName" placeholder="请输入部门名称" clearable style="margin-bottom: 20px">
<el-input v-model="deptName" placeholder="请输入部门名称" clearable class="mb-20px">
<template #prefix>
<Icon icon="ep:search" />
</template>
......@@ -8,15 +8,15 @@
</div>
<div class="head-container">
<el-tree
:data="deptOptions"
:data="deptList"
:props="defaultProps"
node-key="id"
:expand-on-click-node="false"
:filter-node-method="filterNode"
ref="treeRef"
node-key="id"
default-expand-all
highlight-current
@node-click="handleDeptNodeClick"
@node-click="handleNodeClick"
/>
</div>
</template>
......@@ -26,25 +26,30 @@ import { ElTree } from 'element-plus'
import * as DeptApi from '@/api/system/dept'
import { defaultProps, handleTree } from '@/utils/tree'
const emits = defineEmits(['node-click'])
const deptName = ref('')
const deptOptions = ref<Tree[]>([]) // 树形结构
const deptList = ref<Tree[]>([]) // 树形结构
const treeRef = ref<InstanceType<typeof ElTree>>()
/** 获得部门树 */
const getTree = async () => {
const res = await DeptApi.getSimpleDeptList()
deptOptions.value = []
deptOptions.value.push(...handleTree(res))
deptList.value = []
deptList.value.push(...handleTree(res))
}
const filterNode = (value: string, data: Tree) => {
if (!value) return true
return data.name.includes(value)
/** 基于名字过滤 */
const filterNode = (name: string, data: Tree) => {
if (!name) return true
return data.name.includes(name)
}
const handleDeptNodeClick = async (row: { [key: string]: any }) => {
/** 处理部门被点击 */
const handleNodeClick = async (row: { [key: string]: any }) => {
emits('node-click', row)
}
const emits = defineEmits(['node-click'])
/** 初始化 */
onMounted(async () => {
await getTree()
})
......
......@@ -56,7 +56,7 @@
<el-select v-model="formData.sex" placeholder="请选择">
<el-option
v-for="dict in getIntDictOptions(DICT_TYPE.SYSTEM_USER_SEX)"
:key="dict.value as number"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>
......@@ -70,7 +70,7 @@
v-for="item in postOptions"
:key="item.id"
:label="item.name"
:value="item.id as number"
:value="item.id"
/>
</el-select>
</el-form-item>
......@@ -102,7 +102,6 @@ import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
import { defaultProps, handleTree } from '@/utils/tree'
import { ElForm, FormItemRule } from 'element-plus'
import { Arrayable } from 'element-plus/es/utils'
import { UserVO } from '@/api/login/types'
type Form = InstanceType<typeof ElForm>
......@@ -210,7 +209,8 @@ const cancel = () => {
}
/* 打开弹框 */
const openForm = (row: undefined | UserVO) => {
const open = (type: string, id?: number) => {
console.log(type, id)
resetForm()
getTree() // 部门树
if (row && row.id) {
......@@ -232,6 +232,6 @@ onMounted(async () => {
defineExpose({
resetForm,
openForm
open
})
</script>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment