Skip to content
This repository has been archived by the owner on Oct 31, 2023. It is now read-only.

Commit

Permalink
add user list api
Browse files Browse the repository at this point in the history
  • Loading branch information
Jzow committed Sep 15, 2023
1 parent b6ba365 commit 683c229
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 64 deletions.
7 changes: 7 additions & 0 deletions src/api/sys/model/userModel.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
import { BaseListResp } from '/@/api/model/baseModel';

export interface PageUserInfo {
pages: number,
size: number,
total: number,
}
export type UserListResp2 = BaseListResp<PageUserInfo>;

/**
* @description: User info response
*/
Expand Down
6 changes: 3 additions & 3 deletions src/api/sys/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
LoginResp,
GetUserInfoModel,
RegisterReq,
UserListResp,
UserListResp2,
UserInfo,
UserProfile,
ChangePasswordReq,
Expand All @@ -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',
Expand All @@ -44,7 +44,7 @@ enum Api {
*/

export const getUserList = (params: BaseListReq, mode: ErrorMessageMode = 'notice') => {
return defHttp.post<BaseDataResp<UserListResp>>(
return defHttp.post<BaseDataResp<UserListResp2>>(
{ url: Api.GetUserList, params },
{ errorMessageMode: mode },
);
Expand Down
2 changes: 1 addition & 1 deletion src/settings/componentSetting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
},
Expand Down
2 changes: 1 addition & 1 deletion src/views/sys/user/UserDrawer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
Expand Down
9 changes: 2 additions & 7 deletions src/views/sys/user/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -97,10 +96,6 @@
const searchInfo = reactive<Recordable>({});
const [registerDrawer, { openDrawer }] = useDrawer();
const roleStoreData = useRoleStore();
// get role data
roleStoreData.getRoleInfoFromServer();
const [registerTable, { reload, getSelectRows }] = useTable({
title: t('sys.user.userList'),
Expand Down Expand Up @@ -151,7 +146,7 @@
}
const result = await deleteUser({ ids: [record.id] });
if (result.code === 0) {
if (result.code == "00000") {
await reload();
}
}
Expand All @@ -169,7 +164,7 @@
}
const result = await deleteUser({ ids: ids });
if (result.code === 0) {
if (result.code == "00000") {
await reload();
}
},
Expand Down
53 changes: 1 addition & 52 deletions src/views/sys/user/user.data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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'),
Expand Down Expand Up @@ -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'),
Expand All @@ -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',
},
Expand Down

0 comments on commit 683c229

Please sign in to comment.