|  |  |  | 
|---|
|  |  |  | :columns="UserManageColumns" | 
|---|
|  |  |  | :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> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | 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', | 
|---|
|  |  |  | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | emits: { | 
|---|
|  |  |  | onClick: (role) => openResetPasswordDialog(role), | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | { | 
|---|
|  |  |  | data: { | 
|---|
|  |  |  | enCode: 'resetOperatorPasswordBtn', | 
|---|
|  |  |  | name: '重置操作密码', | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | props: { | 
|---|
|  |  |  | type: 'danger', | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | emits: { | 
|---|
|  |  |  | onClick: (role) => openResetOperatorPasswordDialog(role), | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | ]); | 
|---|
|  |  |  | 
|---|
|  |  |  | 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 }, | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | } | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | 
|---|
|  |  |  | status: '' as any as EnumUserStatus, | 
|---|
|  |  |  | roleIds: [] as string[], | 
|---|
|  |  |  | password: '', | 
|---|
|  |  |  | operatorPassword: '', | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | }); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | roleIds: row.roles?.map((x) => x.id) ?? [], | 
|---|
|  |  |  | status: row.status, | 
|---|
|  |  |  | password: '', | 
|---|
|  |  |  | operatorPassword: '', | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | handleAdd(); | 
|---|
|  |  |  | 
|---|
|  |  |  | }; | 
|---|
|  |  |  | if (!editForm.id) { | 
|---|
|  |  |  | params.password = editForm.password; | 
|---|
|  |  |  | params.operatorPassword = editForm.operatorPassword; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (editForm.id) { | 
|---|
|  |  |  | params.id = editForm.id; | 
|---|
|  |  |  | 
|---|
|  |  |  | } 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, | 
|---|
|  |  |  | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 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 = { | 
|---|