From 8d1d92a4baad8df0814a712224112f4b8eefc9d6 Mon Sep 17 00:00:00 2001
From: wupengfei <834520024@qq.com>
Date: 星期三, 12 十一月 2025 13:32:39 +0800
Subject: [PATCH] feat: 1.3.0.2
---
src/views/UserManage/UserManageList.vue | 153 +++++++++++++++++++++++++++++++++++++++++++++-----
1 files changed, 136 insertions(+), 17 deletions(-)
diff --git a/src/views/UserManage/UserManageList.vue b/src/views/UserManage/UserManageList.vue
index 3ea919e..ccb367c 100644
--- a/src/views/UserManage/UserManageList.vue
+++ b/src/views/UserManage/UserManageList.vue
@@ -14,17 +14,33 @@
</QueryFilterItem>
</template>
<template #btn>
- <el-button @click="openDialog()" icon="Plus" type="primary">鏂板</el-button>
+ <el-button
+ v-if="checkSubModuleItemShow('pageButton', 'addBtn')"
+ @click="openDialog()"
+ icon="Plus"
+ type="primary"
+ >鏂板</el-button
+ >
</template>
</ProTableQueryFilterBar>
- <ProTableV2
- v-bind="proTableProps"
- :columns="UserManageColumns"
- :operationBtns="operationBtns"
- >
+ <ProTableV2 v-bind="proTableProps" :columns="column" :operationBtns="operationBtns">
+ <template #status="{ row }">
+ <FieldSwitch
+ v-model="row.status"
+ active-text="鍚敤"
+ :active-value="EnumUserStatus.Normal"
+ inactive-text="绂佺敤"
+ :inactive-value="EnumUserStatus.Disabled"
+ :before-change="() => setUserInfoStatus(row)"
+ />
+ </template>
</ProTableV2>
</AppContainer>
<AddOrEditUserDialog v-bind="dialogProps" />
+ <ResetPasswordDialog v-bind="resetPasswordDialogProps"></ResetPasswordDialog>
+ <ResetOperatorPasswordDialog
+ v-bind="resetOperatorPasswordDialogProps"
+ ></ResetOperatorPasswordDialog>
</LoadingLayout>
</template>
@@ -39,29 +55,41 @@
useTable,
useFormDialog,
defineOperationBtns,
+ FieldSwitch,
} from '@bole-core/components';
import * as userServices from '@/services/api/user';
-import { UserManageColumns } from './constants';
-import { EnumUserStatusText } from '@/constants';
+import { EnumUserStatus, EnumUserStatusText } from '@/constants';
import { ModelValueType } from 'element-plus';
import { Message } from '@bole-core/core';
import AddOrEditUserDialog from './components/AddOrEditUserDialog.vue';
+import ResetPasswordDialog from './components/ResetPasswordDialog.vue';
+import ResetOperatorPasswordDialog from './components/ResetOperatorPasswordDialog.vue';
defineOptions({
name: 'UserManageList',
});
-const operationBtns = defineOperationBtns([
- {
- data: {
- enCode: 'editBtn',
- name: '缂栬緫',
- },
+const operationBtnMap: Record<string, OperationBtnType> = {
+ editBtn: {
emits: {
onClick: (role) => openDialog(role),
},
},
-]);
+ resetPasswordBtn: {
+ emits: {
+ onClick: (role) => openResetPasswordDialog(role),
+ },
+ },
+ resetOperatorPasswordBtn: {
+ emits: {
+ onClick: (role) => openResetOperatorPasswordDialog(role),
+ },
+ },
+};
+
+const { column, operationBtns, checkSubModuleItemShow } = useAccess({
+ operationBtnMap,
+});
const router = useRouter();
const BaseState = {
@@ -111,7 +139,7 @@
formatter: (role: API.GetOperationUserInfosQueryResultItem) =>
role.roles?.length > 0 ? role.roles.map((x) => x.name).join(',') : '',
},
- status: { type: 'enum', valueEnum: EnumUserStatusText },
+ // status: { type: 'enum', valueEnum: EnumUserStatusText },
},
}
);
@@ -124,8 +152,10 @@
userName: '',
phoneNumber: '',
remark: '',
+ status: '' as any as EnumUserStatus,
roleIds: [] as string[],
password: '',
+ operatorPassword: '',
},
});
@@ -138,7 +168,9 @@
phoneNumber: row.phoneNumber,
remark: row.remark,
roleIds: row.roles?.map((x) => x.id) ?? [],
+ status: row.status,
password: '',
+ operatorPassword: '',
});
} else {
handleAdd();
@@ -152,10 +184,14 @@
name: editForm.name,
userName: editForm.userName,
phoneNumber: editForm.phoneNumber,
- password: editForm.password,
roleIds: editForm.roleIds,
remark: editForm.remark,
+ status: editForm.status ? editForm.status : EnumUserStatus.Normal,
};
+ if (!editForm.id) {
+ params.password = editForm.password;
+ params.operatorPassword = editForm.operatorPassword;
+ }
if (editForm.id) {
params.id = editForm.id;
}
@@ -167,4 +203,87 @@
}
} catch (error) {}
}
+
+const {
+ dialogProps: resetOperatorPasswordDialogProps,
+ handleAdd: handleResetOperatorPasswordAdd,
+ editForm: resetOperatorPasswordEditForm,
+} = useFormDialog({
+ onConfirm: resetOperatorPassword,
+ defaultFormParams: {
+ ids: '',
+ operatorPassword: '',
+ },
+});
+
+function openResetOperatorPasswordDialog(row: API.GetOperationUserInfosQueryResultItem) {
+ handleResetOperatorPasswordAdd({
+ ids: row.id,
+ operatorPassword: '',
+ });
+}
+
+async function resetOperatorPassword() {
+ try {
+ let params: API.ResetUserOperatorPasswordsCommand = {
+ ids: [resetOperatorPasswordEditForm.ids],
+ operatorPassword: resetOperatorPasswordEditForm.operatorPassword,
+ };
+ let res = await userServices.resetUserOperatorPasswords(params);
+ if (res) {
+ Message.successMessage('鎿嶄綔鎴愬姛');
+ getList(paginationState.pageIndex);
+ }
+ } catch (error) {}
+}
+const {
+ dialogProps: resetPasswordDialogProps,
+ handleAdd: handleResetPasswordAdd,
+ editForm: resetPasswordEditForm,
+} = useFormDialog({
+ onConfirm: resetPassword,
+ defaultFormParams: {
+ ids: '',
+ password: '',
+ },
+});
+
+function openResetPasswordDialog(row: API.GetOperationUserInfosQueryResultItem) {
+ handleResetPasswordAdd({
+ ids: row.id,
+ password: '',
+ });
+}
+
+async function setUserInfoStatus(row: API.GetOperationUserInfosQueryResultItem) {
+ try {
+ await Message.tipMessage(
+ `纭瑕�${row.status === EnumUserStatus.Normal ? '绂佺敤' : '鍚敤'}璇ョ敤鎴峰悧锛焋
+ );
+ const res = await userServices.setUserInfoStatus({
+ ids: [row.id],
+ status:
+ row.status === EnumUserStatus.Normal ? EnumUserStatus.Disabled : EnumUserStatus.Normal,
+ });
+ if (res) {
+ getList(paginationState.pageIndex);
+ Message.successMessage(`鎿嶄綔鎴愬姛`);
+ return !!res;
+ }
+ } catch (error) {}
+}
+
+async function resetPassword() {
+ try {
+ let params: API.ResetUserPasswordsCommand = {
+ ids: [resetPasswordEditForm.ids],
+ password: resetPasswordEditForm.password,
+ };
+ let res = await userServices.resetUserPasswords(params);
+ if (res) {
+ Message.successMessage('鎿嶄綔鎴愬姛');
+ getList(paginationState.pageIndex);
+ }
+ } catch (error) {}
+}
</script>
--
Gitblit v1.9.1