From 1ab5c4f3c69a8e1d882bf5d860d3f84123dfb793 Mon Sep 17 00:00:00 2001 From: TsMask <340112800@qq.com> Date: Tue, 5 Sep 2023 17:11:22 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E7=94=A8=E6=88=B7=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/system/user.ts | 14 +- src/store/modules/user.ts | 18 +-- src/views/system/user/index.vue | 219 ++++++++------------------------ 3 files changed, 71 insertions(+), 180 deletions(-) diff --git a/src/api/system/user.ts b/src/api/system/user.ts index febcce9e..2d052ff6 100644 --- a/src/api/system/user.ts +++ b/src/api/system/user.ts @@ -47,7 +47,7 @@ export function exportUser(query: Record) { */ export function listUser(query: Record) { return request({ - url: '/system/user/list', + url: '/userManage/v1/users', method: 'get', params: query, }); @@ -60,7 +60,7 @@ export function listUser(query: Record) { */ export function getUser(userId: string | number = '0') { return request({ - url: `/system/user/${userId}`, + url: `/userManage/v1/user/${userId}`, method: 'get', }); } @@ -72,7 +72,7 @@ export function getUser(userId: string | number = '0') { */ export function addUser(data: Record) { return request({ - url: '/system/user', + url: '/userManage/v1/user', method: 'post', data: data, }); @@ -85,7 +85,7 @@ export function addUser(data: Record) { */ export function updateUser(data: Record) { return request({ - url: '/system/user', + url: '/userManage/v1/user', method: 'put', data: data, }); @@ -98,7 +98,7 @@ export function updateUser(data: Record) { */ export function delUser(userId: string | number) { return request({ - url: `/system/user/${userId}`, + url: `/userManage/v1/user/${userId}`, method: 'delete', }); } @@ -111,7 +111,7 @@ export function delUser(userId: string | number) { */ export function resetUserPwd(userId: string | number, password: string) { return request({ - url: '/system/user/resetPwd', + url: '/userManage/v1/user/resetPwd', method: 'put', data: { userId, @@ -131,7 +131,7 @@ export function changeUserStatus( status: string | number ) { return request({ - url: '/system/user/changeStatus', + url: '/userManage/v1/user/changeStatus', method: 'put', data: { userId, diff --git a/src/store/modules/user.ts b/src/store/modules/user.ts index 6930cf58..0631aa7a 100644 --- a/src/store/modules/user.ts +++ b/src/store/modules/user.ts @@ -107,7 +107,7 @@ const useUserStore = defineStore('user', { // 登录 async fnLogin(loginBody: Record) { const res = await login(loginBody); - if (res.code === 200 && res.data) { + if (res.code === 1 && res.data) { const token = res.data[TOKEN_RESPONSE_FIELD]; setToken(token); this.token = token; @@ -117,17 +117,17 @@ const useUserStore = defineStore('user', { // 获取用户信息 async fnGetInfo() { const res = await getInfo(); - if (res.code === 200 && res.data) { + if (res.code === 1 && res.data) { const { user, roles, permissions } = res.data; // 登录账号 - this.userName = user.userName; + this.userName = user.accountId; // 用户头像 this.avatar = user.avatar; // 基础信息 - this.nickName = user.nickName; - this.phonenumber = user.phonenumber; + this.nickName = user.name; + this.phonenumber = user.phone; this.email = user.email; - this.sex = user.sex; + this.sex = user.gender; // 验证返回的roles是否是一个非空数组 if (Array.isArray(roles) && roles.length > 0) { @@ -139,14 +139,14 @@ const useUserStore = defineStore('user', { } // 水印文字信息=用户昵称 手机号 - let waterMarkContent = this.nickName; + let waterMarkContent = this.userName; if (this.phonenumber) { - waterMarkContent = `${this.nickName} ${this.phonenumber}`; + waterMarkContent = `${this.userName} ${this.phonenumber}`; } useLayoutStore().changeWaterMark(waterMarkContent); } // 网络错误时退出登录状态 - if (res.code === 500) { + if (res.code === 0) { removeToken(); window.location.reload(); } diff --git a/src/views/system/user/index.vue b/src/views/system/user/index.vue index 9d58f15a..75966fbc 100644 --- a/src/views/system/user/index.vue +++ b/src/views/system/user/index.vue @@ -59,8 +59,6 @@ let queryParams = reactive({ userName: '', /**手机号 */ phonenumber: '', - /**部门ID */ - deptId: '', /**用户状态 */ status: undefined, /**记录开始时间 */ @@ -78,7 +76,6 @@ function fnQueryReset() { queryParams = Object.assign(queryParams, { userName: '', phonenumber: '', - deptId: '', status: undefined, beginTime: '', endTime: '', @@ -121,43 +118,37 @@ let tableState: TabeStateType = reactive({ let tableColumns: ColumnsType = [ { title: '用户编号', - dataIndex: 'userId', + dataIndex: 'id', align: 'center', }, { title: '登录账号', - dataIndex: 'userName', + dataIndex: 'accountId', align: 'center', }, { - title: '用户昵称', - dataIndex: 'nickName', + title: '用户名', + dataIndex: 'name', align: 'center', }, { title: '手机号码', - dataIndex: 'phonenumber', + dataIndex: 'phone', align: 'center', }, { - title: '部门名称', - dataIndex: 'deptId', - key: 'deptId', + title: '用户类型', + dataIndex: 'groupName', + key: 'groupName', align: 'center', - }, + }, { - title: '登录地址', - dataIndex: 'loginIp', - key: 'loginIp', - align: 'center', - }, - { - title: '登录时间', - dataIndex: 'loginDate', + title: '创建时间', + dataIndex: 'createTime', align: 'center', customRender(opt) { - if (+opt.value <= 0) return ''; - return parseDateToStr(+opt.value); + if (!opt.value) return ''; + return parseDateToStr(opt.value); }, }, { @@ -168,7 +159,7 @@ let tableColumns: ColumnsType = [ }, { title: '操作', - key: 'userId', + key: 'id', align: 'center', }, ]; @@ -217,15 +208,12 @@ function fnTableSelectedRowKeys(keys: (string | number)[]) { } type OptionsType = { - /**岗位选择列表 */ - posts: Record[]; /**角色选择列表 */ roles: Record[]; }; /**初始用户选择列表 */ let options: OptionsType = { - posts: [], roles: [], }; @@ -272,7 +260,6 @@ let modalState: ModalStateType = reactive({ }, confirmLoading: false, options: { - posts: [], roles: [], }, }); @@ -334,19 +321,13 @@ function fnModalVisibleByVive(userId: string | number) { getUser(userId).then(res => { modalState.confirmLoading = false; hide(); - if (res.code === 200 && res.data) { + if (res.code === 1 && res.data) { const roles = res.data.roles.map((m: Record) => { const disabled = m.status === '0'; Reflect.set(m, 'disabled', disabled); return m; }); - const posts = res.data.posts.map((m: Record) => { - const disabled = m.status === '0'; - Reflect.set(m, 'disabled', disabled); - return m; - }); modalState.options.roles = roles; - modalState.options.posts = posts; const { user, roleIds, postIds } = res.data; modalState.from = Object.assign(modalState.from, user); modalState.from.roleIds = roleIds; @@ -370,7 +351,6 @@ function fnModalVisibleByEdit(userId?: string | number) { modalStateFrom.resetFields(); if (options.roles.length > 0) { modalState.options.roles = options.roles; - modalState.options.posts = options.posts; modalState.title = '添加用户信息'; modalState.visibleByEdit = true; } else { @@ -381,21 +361,14 @@ function fnModalVisibleByEdit(userId?: string | number) { getUser().then(res => { modalState.confirmLoading = false; hide(); - if (res.code === 200 && res.data) { + if (res.code === 1 && res.data) { const roles = res.data.roles.map((m: Record) => { const disabled = m.status === '0'; Reflect.set(m, 'disabled', disabled); return m; }); - const posts = res.data.posts.map((m: Record) => { - const disabled = m.status === '0'; - Reflect.set(m, 'disabled', disabled); - return m; - }); options.roles = roles; - options.posts = posts; modalState.options.roles = roles; - modalState.options.posts = posts; const { user, roleIds, postIds } = res.data; modalState.from = Object.assign(modalState.from, user); modalState.from.roleIds = roleIds; @@ -414,19 +387,13 @@ function fnModalVisibleByEdit(userId?: string | number) { getUser(userId).then(res => { modalState.confirmLoading = false; hide(); - if (res.code === 200 && res.data) { + if (res.code === 1 && res.data) { const roles = res.data.roles.map((m: Record) => { const disabled = m.status === '0'; Reflect.set(m, 'disabled', disabled); return m; }); - const posts = res.data.posts.map((m: Record) => { - const disabled = m.status === '0'; - Reflect.set(m, 'disabled', disabled); - return m; - }); modalState.options.roles = roles; - modalState.options.posts = posts; const { user, roleIds, postIds } = res.data; modalState.from = Object.assign(modalState.from, user); modalState.from.roleIds = roleIds; @@ -459,7 +426,7 @@ function fnModalOk() { message.loading({ content: '请稍等...', key }); user .then(res => { - if (res.code === 200) { + if (res.code === 1) { message.success({ content: `${modalState.title}成功`, key, @@ -495,7 +462,6 @@ function fnModalCancel() { modalState.visibleByResetPwd = false; modalStateFrom.resetFields(); modalState.options.roles = []; - modalState.options.posts = []; } /** @@ -511,7 +477,7 @@ function fnModalOkResetPwd() { message.loading({ content: '请稍等...', key }); resetUserPwd(modalState.from.userId, modalState.from.password) .then(res => { - if (res.code === 200) { + if (res.code === 1) { message.success({ content: `${modalState.title}成功`, key, @@ -561,7 +527,7 @@ function fnRecordStatus(row: Record) { const key = 'changeUserStatus'; message.loading({ content: '请稍等...', key }); changeUserStatus(row.userId, row.status).then(res => { - if (res.code === 200) { + if (res.code === 1) { message.success({ content: `${row.userName} ${text}成功`, key: key, @@ -598,7 +564,7 @@ function fnRecordDelete(userId: string = '0') { const key = 'delUser'; message.loading({ content: '请稍等...', key }); delUser(userId).then(res => { - if (res.code === 200) { + if (res.code === 1) { message.success({ content: `删除成功`, key, @@ -626,7 +592,7 @@ function fnExportList() { const key = 'exportUser'; message.loading({ content: '请稍等...', key }); exportUser(toRaw(queryParams)).then(res => { - if (res.code === 200) { + if (res.code === 1) { message.success({ content: `已完成导出`, key, @@ -684,7 +650,7 @@ function fnModalUploadXlsxImportExportTemplate() { const hide = message.loading('正在下载...', 0); importTemplate() .then(res => { - if (res.code === 200) { + if (res.code === 1) { message.success({ content: `成功读取并下载导入模板`, duration: 2, @@ -710,7 +676,7 @@ function fnGetList() { queryParams.beginTime = queryRangePicker.value[0]; queryParams.endTime = queryRangePicker.value[1]; listUser(toRaw(queryParams)).then(res => { - if (res.code === 200 && Array.isArray(res.rows)) { + if (res.code === 1 && Array.isArray(res.rows)) { // 取消勾选 if (tableState.selectedRowKeys.length > 0) { tableState.selectedRowKeys = []; @@ -729,7 +695,7 @@ let deptTreeData = ref([]); function fnGetDeptTree() { if (deptTreeData.value.length > 0) return; deptTreeSelect().then(res => { - if (res.code === 200 && Array.isArray(res.data)) { + if (res.code === 1 && Array.isArray(res.data)) { deptTreeData.value = res.data; } }); @@ -768,43 +734,6 @@ onMounted(() => { > - - - - - - - - - - - - - 搜索 - - - - 重置 - - - - - @@ -816,16 +745,6 @@ onMounted(() => { > - - - - - { - - - + + + + + + 搜索 + + + + 重置 + + @@ -875,7 +796,7 @@ onMounted(() => { 删除 - { > 导出 - + --> @@ -945,7 +866,7 @@ onMounted(() => { { }" >