From 84e8da75fcafa0c1ee65807e30b1b819c4a0cf0a Mon Sep 17 00:00:00 2001 From: xlsea Date: Thu, 15 May 2025 22:26:34 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9E=E9=87=8D=E7=BD=AE?= =?UTF-8?q?=E5=AF=86=E7=A0=81=E5=BC=B9=E7=AA=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/typings/api/system.api.d.ts | 4 +- src/views/system/user/index.vue | 53 +++++--- .../user/modules/user-operate-drawer.vue | 9 +- .../user/modules/user-password-drawer.vue | 114 ++++++++++++++++++ 4 files changed, 156 insertions(+), 24 deletions(-) create mode 100644 src/views/system/user/modules/user-password-drawer.vue diff --git a/src/typings/api/system.api.d.ts b/src/typings/api/system.api.d.ts index d69d0b08..905264c1 100644 --- a/src/typings/api/system.api.d.ts +++ b/src/typings/api/system.api.d.ts @@ -152,7 +152,9 @@ declare namespace Api { type UserProfileOperateParams = CommonType.RecordNullable>; /** user password operate params */ - type UserPasswordOperateParams = CommonType.RecordNullable & { newPassword: string }>; + type UserPasswordOperateParams = CommonType.RecordNullable< + Pick & { newPassword: string } + >; /** user info */ type UserInfo = { diff --git a/src/views/system/user/index.vue b/src/views/system/user/index.vue index b8574a98..83091ce7 100644 --- a/src/views/system/user/index.vue +++ b/src/views/system/user/index.vue @@ -2,6 +2,7 @@ import { computed, ref } from 'vue'; import { NButton, NDivider } from 'naive-ui'; import { useBoolean, useLoading } from '@sa/hooks'; +import { jsonClone } from '@sa/utils'; import { fetchBatchDeleteUser, fetchGetDeptTree, fetchGetUserList, fetchUpdateUserStatus } from '@/service/api/system'; import { useAppStore } from '@/store/modules/app'; import { useTable, useTableOperate } from '@/hooks/common/table'; @@ -13,6 +14,7 @@ import { $t } from '@/locales'; import StatusSwitch from '@/components/custom/status-switch.vue'; import UserOperateDrawer from './modules/user-operate-drawer.vue'; import UserImportModal from './modules/user-import-modal.vue'; +import UserPasswordDrawer from './modules/user-password-drawer.vue'; import UserSearch from './modules/user-search.vue'; defineOptions({ @@ -27,6 +29,7 @@ const appStore = useAppStore(); const { download } = useDownload(); const { bool: importVisible, setTrue: openImportModal } = useBoolean(); +const { bool: passwordVisible, setTrue: openPasswordDrawer } = useBoolean(); const { columns, @@ -118,19 +121,9 @@ const { key: 'operate', title: $t('common.operate'), align: 'center', - width: 130, + width: 150, render: row => { - const divider = () => { - if (!hasAuth('system:user:edit') || !hasAuth('system:user:remove')) { - return null; - } - return ; - }; - const editBtn = () => { - if (!hasAuth('system:user:edit')) { - return null; - } return ( { + return ( + handleResetPwd(row.userId!)} + /> + ); + }; + const deleteBtn = () => { - if (!hasAuth('system:user:remove')) { - return null; - } return ( - {editBtn()} - {divider()} - {deleteBtn()} +
+ {buttons.map((btn, index) => ( + <> + {index !== 0 && } + {btn} + + ))}
); } @@ -191,6 +201,12 @@ async function edit(userId: CommonType.IdType) { handleEdit('userId', userId); } +async function handleResetPwd(userId: CommonType.IdType) { + const findItem = data.value.find(item => item.userId === userId) || null; + editingData.value = jsonClone(findItem); + openPasswordDrawer(); +} + const { loading: treeLoading, startLoading: startTreeLoading, endLoading: endTreeLoading } = useLoading(); const deptPattern = ref(); const deptData = ref([]); @@ -332,6 +348,7 @@ const selectable = computed(() => { :dept-id="searchParams.deptId" @submitted="getDataByPage" /> + diff --git a/src/views/system/user/modules/user-operate-drawer.vue b/src/views/system/user/modules/user-operate-drawer.vue index 1ffa0bf4..d6768341 100644 --- a/src/views/system/user/modules/user-operate-drawer.vue +++ b/src/views/system/user/modules/user-operate-drawer.vue @@ -115,11 +115,11 @@ async function handleSubmit() { const { error } = await fetchCreateUser({ deptId, userName, + password, nickName, email, phonenumber, sex, - password, status, remark }); @@ -135,7 +135,6 @@ async function handleSubmit() { email, phonenumber, sex, - password, status, remark }); @@ -156,7 +155,7 @@ watch(visible, () => {