From b3e4e858be9ed54f2838bc5a98e9d9058f7d6dae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E5=BC=BA?= <1206709430@qq.com> Date: Tue, 26 Apr 2022 21:12:00 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=EF=BC=9A=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web/src/config/button.js | 2 + .../store/modules/d2admin/modules/account.js | 44 ++++++++++--------- web/src/views/system/button/api.js | 2 +- web/src/views/system/user/crud.js | 24 ++++++++-- web/src/views/system/user/index.vue | 1 + 5 files changed, 48 insertions(+), 25 deletions(-) diff --git a/web/src/config/button.js b/web/src/config/button.js index 7687c15..246e91e 100644 --- a/web/src/config/button.js +++ b/web/src/config/button.js @@ -30,3 +30,5 @@ export const BUTTON_STATUS_NUMBER = getButtonSettings([{ label: '启用', value: export const BUTTON_WHETHER_NUMBER = getButtonSettings([{ label: '是', value: 1 }, { label: '否', value: 0 }]) // 是 true/ 否 false export const BUTTON_WHETHER_BOOL = getButtonSettings([{ label: '是', value: true }, { label: '否', value: false }]) +// 用户类型 +export const USER_TYPE = getButtonSettings([{ label: '后台用户', value: 0 }, { label: '前台用户', value: 1 }]) diff --git a/web/src/store/modules/d2admin/modules/account.js b/web/src/store/modules/d2admin/modules/account.js index 2fdc0b1..e3f0d79 100644 --- a/web/src/store/modules/d2admin/modules/account.js +++ b/web/src/store/modules/d2admin/modules/account.js @@ -16,22 +16,24 @@ export default { namespaced: true, actions: { /** - * @description 登录 - * @param {Object} context - * @param {Object} data - * @param {Object} data username {String} 用户账号 - * @param {Object} data password {String} 密码 - * @param {Object} data route {Object} 登录成功后定向的路由对象 任何 vue-router 支持的格式 - * @param {Object} data request function 请求方法 + * @description 登录 + * @param {Object} context + * @param {Object} payload username {String} 用户账号 + * @param {Object} payload password {String} 密码 + * @param {Object} payload route {Object} 登录成功后定向的路由对象 任何 vue-router 支持的格式 */ - async login ({ dispatch }, data) { - let request = data.request - if (request) { - delete data.request - } else { - request = SYS_USER_LOGIN - } - let res = await request(data) + async login ({ dispatch }, { + username = '', + password = '', + captcha = '', + captchaKey = '' + } = {}) { + let res = await SYS_USER_LOGIN({ + username, + password, + captcha, + captchaKey + }) // 设置 cookie 一定要存 uuid 和 token 两个 cookie // 整个系统依赖这两个数据进行校验和存储 // uuid 是用户身份唯一标识 用户注册的时候确定 并且不可改变 不可重复 @@ -47,14 +49,14 @@ export default { await dispatch('load') }, /** - * @description 注销用户并返回登录页面 - * @param {Object} context - * @param {Object} payload confirm {Boolean} 是否需要确认 - */ + * @description 注销用户并返回登录页面 + * @param {Object} context + * @param {Object} payload confirm {Boolean} 是否需要确认 + */ logout ({ commit, dispatch }, { confirm = false } = {}) { /** - * @description 注销 - */ + * @description 注销 + */ async function logout () { await SYS_USER_LOGOUT({ refresh: util.cookies.get('refresh') }).then(() => { // 删除cookie diff --git a/web/src/views/system/button/api.js b/web/src/views/system/button/api.js index c164a9b..aa26c5c 100644 --- a/web/src/views/system/button/api.js +++ b/web/src/views/system/button/api.js @@ -14,7 +14,7 @@ export function GetList (query) { return request({ url: urlPrefix, method: 'get', - data: query + params: query }) } export function createObj (obj) { diff --git a/web/src/views/system/user/crud.js b/web/src/views/system/user/crud.js index 0e9a97b..8efe67d 100644 --- a/web/src/views/system/user/crud.js +++ b/web/src/views/system/user/crud.js @@ -1,5 +1,5 @@ import { request } from '@/api/service' -import { BUTTON_STATUS_BOOL } from '@/config/button' +import { BUTTON_STATUS_BOOL, USER_TYPE } from '@/config/button' import { urlPrefix as deptPrefix } from '../dept/api' export const crudOptions = (vm) => { @@ -234,8 +234,26 @@ export const crudOptions = (vm) => { } }, component: { props: { color: 'auto' } } // 自动染色 - }, - { + }, { + title: '用户类型', + key: 'user_type', + search: { + value: 0, + disabled: false + }, + width: 140, + type: 'select', + dict: { + data: USER_TYPE + }, + form: { + show: false, + value: 0, + component: { + span: 12 + } + } + }, { title: '状态', key: 'is_active', search: { diff --git a/web/src/views/system/user/index.vue b/web/src/views/system/user/index.vue index b8d787f..7d8c3a2 100644 --- a/web/src/views/system/user/index.vue +++ b/web/src/views/system/user/index.vue @@ -94,6 +94,7 @@ export default { }, methods: { getCrudOptions () { + this.crud.searchOptions.form.user_type = 0 return crudOptions(this) }, pageRequest (query) {