From 8330d1df8c9de0ca1695071e139d49358791f337 Mon Sep 17 00:00:00 2001 From: JINGYJ <1458671527@qq.com> Date: Thu, 17 Aug 2023 16:16:55 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20bug=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.production | 5 +++- .env.staging | 3 +++ src/views/system/dept/utils/hook.tsx | 16 ++++++------- src/views/system/user/form.vue | 9 +------ src/views/system/user/utils/hook.tsx | 36 +++++++++++++++++++++++++++- 5 files changed, 51 insertions(+), 18 deletions(-) diff --git a/.env.production b/.env.production index 84e6086..730cdae 100644 --- a/.env.production +++ b/.env.production @@ -10,4 +10,7 @@ VITE_CDN = false # 是否启用gzip压缩或brotli压缩(分两种情况,删除原始文件和不删除原始文件) # 压缩时不删除原始文件的配置:gzip、brotli、both(同时开启 gzip 与 brotli 压缩)、none(不开启压缩,默认) # 压缩时删除原始文件的配置:gzip-clear、brotli-clear、both-clear(同时开启 gzip 与 brotli 压缩)、none(不开启压缩,默认) -VITE_COMPRESSION = "none" \ No newline at end of file +VITE_COMPRESSION = "none" + +# 生产环境后端地址 +VITE_APP_BASE_URL = 'http://192.168.10.13:8000' \ No newline at end of file diff --git a/.env.staging b/.env.staging index 65b57e3..18736dc 100644 --- a/.env.staging +++ b/.env.staging @@ -14,3 +14,6 @@ VITE_CDN = true # 压缩时不删除原始文件的配置:gzip、brotli、both(同时开启 gzip 与 brotli 压缩)、none(不开启压缩,默认) # 压缩时删除原始文件的配置:gzip-clear、brotli-clear、both-clear(同时开启 gzip 与 brotli 压缩)、none(不开启压缩,默认) VITE_COMPRESSION = "none" + +# 预发布环境后端地址 +VITE_APP_BASE_URL = 'http://192.168.10.13:8000' diff --git a/src/views/system/dept/utils/hook.tsx b/src/views/system/dept/utils/hook.tsx index c69730d..e776b4e 100644 --- a/src/views/system/dept/utils/hook.tsx +++ b/src/views/system/dept/utils/hook.tsx @@ -45,15 +45,15 @@ export function useDept() { { label: "创建时间", minWidth: 200, - prop: "createTime", - formatter: ({ createTime }) => - dayjs(createTime).format("YYYY-MM-DD HH:mm:ss") - }, - { - label: "备注", - prop: "remark", - minWidth: 320 + prop: "create_time", + formatter: ({ create_time }) => + dayjs(create_time).format("YYYY-MM-DD HH:mm:ss") }, + // { + // label: "备注", + // prop: "remark", + // minWidth: 320 + // }, { label: "操作", fixed: "right", diff --git a/src/views/system/user/form.vue b/src/views/system/user/form.vue index fa2ffff..53813f9 100644 --- a/src/views/system/user/form.vue +++ b/src/views/system/user/form.vue @@ -44,14 +44,7 @@ defineExpose({ getRef }); value: 'id', label: 'name', emitPath: false, - checkStrictly: true, - disabled: function (data) { - if (data.children && data.children.length > 0) { - return true; - } else { - return false; - } - } + checkStrictly: true }" :show-all-levels="false" clearable diff --git a/src/views/system/user/utils/hook.tsx b/src/views/system/user/utils/hook.tsx index c490b9f..387da28 100644 --- a/src/views/system/user/utils/hook.tsx +++ b/src/views/system/user/utils/hook.tsx @@ -394,13 +394,24 @@ export function useUser() { isIndeterminate.value = value.length !== allRole.value.length; } + /** 密码正则(密码格式应为8-18位数字、字母、符号的任意两种组合) */ + const REGEXP_PWD = + /^(?![0-9]+$)(?![a-z]+$)(?![A-Z]+$)(?!([^(0-9a-zA-Z)]|[()])+$)(?!^.*[\u4E00-\u9FA5].*$)([^(0-9a-zA-Z)]|[()]|[a-z]|[A-Z]|[0-9]){8,18}$/; + function resetPassword(row: { username: string; id: any }) { ElMessageBox.prompt( "请输入用户「" + row.username + "」的新密码", "重置密码", { confirmButtonText: "确定", - cancelButtonText: "取消" + cancelButtonText: "取消", + inputValidator: val => { + if (val === null) { + return true; //初始化的值为null,不做处理的话,刚打开MessageBox就会校验出错,影响用户体验 + } + return REGEXP_PWD.test(val); + }, + inputErrorMessage: "密码格式应为8-18位数字、字母、符号的任意两种组合" } ) .then(({ value }) => { @@ -409,6 +420,29 @@ export function useUser() { type: "warning" }); return false; + } else { + const params = { + id: row.id, + password: value + }; + updateUser(params) + .then(res => { + console.log(res); + if (res.success) { + message(`${res.msg}`, { + type: "success" + }); + } else { + message(`${res.msg}`, { + type: "warning" + }); + } + }) + .catch(error => { + message(`${error}`, { + type: "warning" + }); + }); } }) .catch(() => {});