From 683c229a837d0c7222334afb849844c7621ec9ba Mon Sep 17 00:00:00 2001 From: jameszow Date: Fri, 15 Sep 2023 17:22:03 +0800 Subject: [PATCH] add user list api --- src/api/sys/model/userModel.ts | 7 ++++ src/api/sys/user.ts | 6 ++-- src/settings/componentSetting.ts | 2 +- src/views/sys/user/UserDrawer.vue | 2 +- src/views/sys/user/index.vue | 9 ++---- src/views/sys/user/user.data.ts | 53 +------------------------------ 6 files changed, 15 insertions(+), 64 deletions(-) diff --git a/src/api/sys/model/userModel.ts b/src/api/sys/model/userModel.ts index 17d35ed..b54d9cd 100644 --- a/src/api/sys/model/userModel.ts +++ b/src/api/sys/model/userModel.ts @@ -1,5 +1,12 @@ import { BaseListResp } from '/@/api/model/baseModel'; +export interface PageUserInfo { + pages: number, + size: number, + total: number, +} +export type UserListResp2 = BaseListResp; + /** * @description: User info response */ diff --git a/src/api/sys/user.ts b/src/api/sys/user.ts index 4215a65..9133ec1 100644 --- a/src/api/sys/user.ts +++ b/src/api/sys/user.ts @@ -5,7 +5,7 @@ import { LoginResp, GetUserInfoModel, RegisterReq, - UserListResp, + UserListResp2, UserInfo, UserProfile, ChangePasswordReq, @@ -21,7 +21,7 @@ import { BaseDataResp, BaseListReq, BaseResp, BaseUUIDReq, BaseUUIDsReq } from ' enum Api { CreateUser = '/sys-api/user/create', UpdateUser = '/sys-api/user/update', - GetUserList = '/sys-api/user/list', + GetUserList = '/user/list', DeleteUser = '/sys-api/user/delete', GetUserById = '/sys-api/user', Login = '/user/login', @@ -44,7 +44,7 @@ enum Api { */ export const getUserList = (params: BaseListReq, mode: ErrorMessageMode = 'notice') => { - return defHttp.post>( + return defHttp.post>( { url: Api.GetUserList, params }, { errorMessageMode: mode }, ); diff --git a/src/settings/componentSetting.ts b/src/settings/componentSetting.ts index 005cc11..e718e1a 100644 --- a/src/settings/componentSetting.ts +++ b/src/settings/componentSetting.ts @@ -13,7 +13,7 @@ export default { // The number field name of each page displayed in the background sizeField: 'pageSize', // Field name of the form data returned by the interface - listField: 'data', + listField: 'records', // Total number of tables returned by the interface field name totalField: 'total', }, diff --git a/src/views/sys/user/UserDrawer.vue b/src/views/sys/user/UserDrawer.vue index 5470007..07ec742 100644 --- a/src/views/sys/user/UserDrawer.vue +++ b/src/views/sys/user/UserDrawer.vue @@ -64,7 +64,7 @@ } values['id'] = unref(isUpdate) ? values['id'] : ''; const result = unref(isUpdate) ? await updateUser(values) : await createUser(values); - if (result.code === 0) { + if (result.code == "00000") { closeDrawer(); emit('success'); } diff --git a/src/views/sys/user/index.vue b/src/views/sys/user/index.vue index 2f29b44..eba4481 100644 --- a/src/views/sys/user/index.vue +++ b/src/views/sys/user/index.vue @@ -69,7 +69,6 @@ import { columns, searchFormSchema } from './user.data'; import { getUserList, deleteUser } from '/@/api/sys/user'; - import { useRoleStore } from '/@/store/modules/role'; import { logout } from '/@/api/sys/token'; import { useMessage } from '/@/hooks/web/useMessage'; import Row from 'ant-design-vue/es/grid/Row'; @@ -97,10 +96,6 @@ const searchInfo = reactive({}); const [registerDrawer, { openDrawer }] = useDrawer(); - const roleStoreData = useRoleStore(); - - // get role data - roleStoreData.getRoleInfoFromServer(); const [registerTable, { reload, getSelectRows }] = useTable({ title: t('sys.user.userList'), @@ -151,7 +146,7 @@ } const result = await deleteUser({ ids: [record.id] }); - if (result.code === 0) { + if (result.code == "00000") { await reload(); } } @@ -169,7 +164,7 @@ } const result = await deleteUser({ ids: ids }); - if (result.code === 0) { + if (result.code == "00000") { await reload(); } }, diff --git a/src/views/sys/user/user.data.ts b/src/views/sys/user/user.data.ts index 31153aa..7f6bd63 100644 --- a/src/views/sys/user/user.data.ts +++ b/src/views/sys/user/user.data.ts @@ -4,9 +4,7 @@ import { formatToDateTime } from '/@/utils/dateUtil'; import { h } from 'vue'; import { Switch } from 'ant-design-vue'; import { useMessage } from '/@/hooks/web/useMessage'; -import { getRoleList } from '/@/api/sys/role'; import { getDepartmentList } from '/@/api/sys/department'; -import { getPositionList } from '/@/api/sys/position'; import { updateUser } from '/@/api/sys/user'; const { t } = useI18n(); @@ -95,22 +93,6 @@ export const searchFormSchema: FormSchema[] = [ colProps: { span: 8 }, rules: [{ max: 40 }], }, - { - field: 'roleIds', - label: t('sys.role.roleTitle'), - component: 'ApiMultipleSelect', - componentProps: { - api: getRoleList, - params: { - page: 1, - pageSize: 100, - }, - resultField: 'data.data', - labelField: 'trans', - valueField: 'id', - }, - colProps: { span: 8 }, - }, { field: 'mobile', label: t('sys.login.mobile'), @@ -188,22 +170,6 @@ export const formSchema: FormSchema[] = [ label: t('sys.login.password'), component: 'Input', }, - { - field: 'roleIds', - label: t('sys.role.roleTitle'), - required: true, - component: 'ApiMultipleSelect', - componentProps: { - api: getRoleList, - params: { - page: 1, - pageSize: 100, - }, - resultField: 'data.data', - labelField: 'trans', - valueField: 'id', - }, - }, { field: 'departmentId', label: t('sys.department.userDepartment'), @@ -217,24 +183,7 @@ export const formSchema: FormSchema[] = [ name: '', leader: '', }, - resultField: 'data.data', - labelField: 'trans', - valueField: 'id', - }, - }, - { - field: 'positionId', - label: t('sys.position.userPosition'), - component: 'ApiMultipleSelect', - required: true, - componentProps: { - api: getPositionList, - params: { - page: 1, - pageSize: 1000, - name: '', - }, - resultField: 'data.data', + resultField: 'data', labelField: 'trans', valueField: 'id', },