Commit ded38d437de254284a8c2e46b83269e19f208981

Authored by fengwotao
1 parent 8962bbd6

feat: 新增用户清除密码功能

... ... @@ -34,6 +34,7 @@ enum Api {
34 34 GetAllRoleList = '/role/find/list',
35 35 BaseUserUrl = '/user',
36 36 BaseOrganization = '/organization',
  37 + RESET_USER_PASSWORD = '/user/reset_password/',
37 38 }
38 39
39 40 export const getAccountInfo = (userId: string) =>
... ... @@ -172,3 +173,12 @@ export const resetPassword = (params: ChangeAccountParams) =>
172 173 url: Api.BaseUserUrl + '/reset',
173 174 params: params,
174 175 });
  176 +
  177 +/**
  178 + * 清除密码
  179 + * @param params
  180 + */
  181 +export const clearUserPassword = (userId: string) =>
  182 + defHttp.post({
  183 + url: Api.RESET_USER_PASSWORD + userId,
  184 + });
... ...
... ... @@ -81,6 +81,17 @@
81 81 confirm: handleDeleteOrBatchDelete.bind(null, record),
82 82 },
83 83 },
  84 + {
  85 + label: '清除密码',
  86 + auth: 'api:yt:user:delete',
  87 + icon: 'ant-design:delete-outlined',
  88 + color: 'error',
  89 + tooltip: '清除密码',
  90 + popConfirm: {
  91 + title: '是否确认清除密码',
  92 + confirm: handleClearPassword.bind(null, record),
  93 + },
  94 + },
84 95 ]"
85 96 />
86 97 </template>
... ... @@ -107,6 +118,8 @@
107 118 import { isAdmin } from '/@/enums/roleEnum';
108 119 import { TenantListItemRecord } from '/@/api/tenant/tenantInfo';
109 120 import { useFastEnter } from '/@/hooks/business/useFastEnter';
  121 + import { clearUserPassword } from '/@/api/system/system';
  122 + import { useMessage } from '/@/hooks/web/useMessage';
110 123
111 124 export default defineComponent({
112 125 name: 'AccountManagement',
... ... @@ -121,6 +134,7 @@
121 134 Popconfirm,
122 135 },
123 136 setup() {
  137 + const { createMessage } = useMessage();
124 138 const userInfo: any = getAuthCache(USER_INFO_KEY);
125 139 const role: string = userInfo?.roles[0];
126 140
... ... @@ -192,6 +206,13 @@
192 206 }
193 207 }
194 208
  209 + const handleClearPassword = async (record: Recordable) => {
  210 + const { id } = record;
  211 + if (!id) return;
  212 + const { message } = await clearUserPassword(id);
  213 + createMessage.success(message);
  214 + };
  215 +
195 216 return {
196 217 handleLoginCustomAdmin,
197 218 registerTable,
... ... @@ -206,6 +227,7 @@
206 227 handleDeleteOrBatchDelete,
207 228 isAdmin,
208 229 role,
  230 + handleClearPassword,
209 231 };
210 232 },
211 233 });
... ...