Commit bb4343f164cd6d8c406be3a2fca40210a103cf7d

Authored by sanmu
1 parent 7311d332

feat: user reset

src/api/project/account.ts
@@ -6,6 +6,8 @@ enum Api { @@ -6,6 +6,8 @@ enum Api {
6 USER_ADD = '/order/erp/users/add', 6 USER_ADD = '/order/erp/users/add',
7 USER_EDIT = '/order/erp/users/edit', 7 USER_EDIT = '/order/erp/users/edit',
8 USER_DELETE = '/order/erp/users/delete', 8 USER_DELETE = '/order/erp/users/delete',
  9 + USER_OPT = '/order/erp/users/opt',
  10 + USER_RESET_PASSWORD = '/order/erp/users/reset', // 管理员重置密码
9 } 11 }
10 12
11 export const getRoleList = async (params: any) => { 13 export const getRoleList = async (params: any) => {
@@ -61,3 +63,23 @@ export const userDelete = async (params: any) => { @@ -61,3 +63,23 @@ export const userDelete = async (params: any) => {
61 params, 63 params,
62 }); 64 });
63 }; 65 };
  66 +
  67 +export const userOpt = async (params: any) => {
  68 + return defHttp.post<any>(
  69 + {
  70 + url: Api.USER_OPT,
  71 + params,
  72 + },
  73 + { message: '操作成功' },
  74 + );
  75 +};
  76 +
  77 +export const userResetPassword = async (params: any) => {
  78 + return defHttp.post<any>(
  79 + {
  80 + url: Api.USER_RESET_PASSWORD,
  81 + params,
  82 + },
  83 + { message: '重置密码成功' },
  84 + );
  85 +};
src/api/sys/user.ts
@@ -10,7 +10,7 @@ enum Api { @@ -10,7 +10,7 @@ enum Api {
10 GetUserInfo = '/getUserInfo', 10 GetUserInfo = '/getUserInfo',
11 GetPermCode = '/getPermCode', 11 GetPermCode = '/getPermCode',
12 TestRetry = '/testRetry', 12 TestRetry = '/testRetry',
13 - MODIFY_PASSWORD = '/order/erp/users/update_pass', 13 + MODIFY_PASSWORD = '/order/erp/users/update_pass', // 用户修改自己的密码,不需要验证码
14 FORGET_PASSWORD = '/order/erp/auth/password_modify', 14 FORGET_PASSWORD = '/order/erp/auth/password_modify',
15 RESET = '/order/erp/users/reset', 15 RESET = '/order/erp/users/reset',
16 CAPTCHA = '/order/erp/captcha/get_img_captcha_code', 16 CAPTCHA = '/order/erp/captcha/get_img_captcha_code',
@@ -32,7 +32,7 @@ export function loginApi(params: LoginParams, mode: ErrorMessageMode = &#39;modal&#39;) @@ -32,7 +32,7 @@ export function loginApi(params: LoginParams, mode: ErrorMessageMode = &#39;modal&#39;)
32 ); 32 );
33 } 33 }
34 34
35 -export function MODIFY_PASSWORD(params: LoginParams, mode: ErrorMessageMode = 'modal') { 35 +export function modifyPassword(params: LoginParams, mode: ErrorMessageMode = 'modal') {
36 return defHttp.post<LoginResultModel>( 36 return defHttp.post<LoginResultModel>(
37 { 37 {
38 url: Api.MODIFY_PASSWORD, 38 url: Api.MODIFY_PASSWORD,
src/views/demo/system/password/index.vue
@@ -16,7 +16,7 @@ @@ -16,7 +16,7 @@
16 import { useUserStoreWithOut } from '/@/store/modules/user'; 16 import { useUserStoreWithOut } from '/@/store/modules/user';
17 17
18 import { formSchema } from './pwd.data'; 18 import { formSchema } from './pwd.data';
19 - import { forgetPassword } from '/@/api/sys/user'; 19 + import { modifyPassword } from '/@/api/sys/user';
20 20
21 export default defineComponent({ 21 export default defineComponent({
22 name: 'ChangePassword', 22 name: 'ChangePassword',
@@ -38,7 +38,7 @@ @@ -38,7 +38,7 @@
38 38
39 const userInfo = userStore.getUserInfo; 39 const userInfo = userStore.getUserInfo;
40 40
41 - await forgetPassword({ ...values, userId: userInfo.id }); 41 + await modifyPassword({ ...values, userId: userInfo.id });
42 } catch (error) {} 42 } catch (error) {}
43 } 43 }
44 44
src/views/project/account/AccountModal.vue
@@ -62,3 +62,4 @@ @@ -62,3 +62,4 @@
62 }, 62 },
63 }); 63 });
64 </script> 64 </script>
  65 +./account.data.tsx4
src/views/project/account/account.data.ts renamed to src/views/project/account/account.data.tsx
1 import { getRoleList } from '/@/api/project/account'; 1 import { getRoleList } from '/@/api/project/account';
  2 +import { Tag } from 'ant-design-vue';
2 3
3 export const columns: BasicColumn[] = [ 4 export const columns: BasicColumn[] = [
4 { 5 {
@@ -27,6 +28,15 @@ export const columns: BasicColumn[] = [ @@ -27,6 +28,15 @@ export const columns: BasicColumn[] = [
27 width: 200, 28 width: 200,
28 }, 29 },
29 { 30 {
  31 + title: '状态',
  32 + dataIndex: 'status',
  33 + width: 200,
  34 + customRender: (column) => {
  35 + const { record } = column || {};
  36 + return record.status === 10 ? <Tag color="green">启用</Tag> : <Tag color="red">禁用</Tag>;
  37 + },
  38 + },
  39 + {
30 title: '备注', 40 title: '备注',
31 dataIndex: 'remark', 41 dataIndex: 'remark',
32 }, 42 },
src/views/project/account/index.vue
@@ -19,16 +19,35 @@ @@ -19,16 +19,35 @@
19 // tooltip: '编辑用户资料', 19 // tooltip: '编辑用户资料',
20 onClick: handleEdit.bind(null, record), 20 onClick: handleEdit.bind(null, record),
21 }, 21 },
22 - // {  
23 - // icon: 'ant-design:delete-outlined',  
24 - // color: 'error',  
25 - // tooltip: '删除此账号',  
26 - // popConfirm: {  
27 - // title: '是否确认删除',  
28 - // placement: 'left',  
29 - // confirm: handleDelete.bind(null, record),  
30 - // },  
31 - // }, 22 + {
  23 + label: '重置密码',
  24 + // tooltip: '编辑用户资料',
  25 + popConfirm: {
  26 + title: '是否确认重置密码',
  27 + placement: 'left',
  28 + confirm: handleResetPassword.bind(null, record),
  29 + },
  30 + },
  31 + {
  32 + // icon: 'ant-design:delete-outlined',
  33 + color: 'error',
  34 + label: record.status === 10 ? '禁用' : '启用',
  35 + popConfirm: {
  36 + title: record.status === 10 ? '是否确认禁用' : '是否确认启用',
  37 + placement: 'left',
  38 + confirm: handleForbid.bind(null, record),
  39 + },
  40 + },
  41 + {
  42 + // icon: 'ant-design:delete-outlined',
  43 + color: 'error',
  44 + label: '删除',
  45 + popConfirm: {
  46 + title: '是否确认删除',
  47 + placement: 'left',
  48 + confirm: handleDelete.bind(null, record),
  49 + },
  50 + },
32 ]" 51 ]"
33 /> 52 />
34 </template> 53 </template>
@@ -41,7 +60,13 @@ @@ -41,7 +60,13 @@
41 import { defineComponent, reactive } from 'vue'; 60 import { defineComponent, reactive } from 'vue';
42 61
43 import { BasicTable, useTable, TableAction } from '/@/components/Table'; 62 import { BasicTable, useTable, TableAction } from '/@/components/Table';
44 - import { getUserList, userAdd, userEdit } from '/@/api/project/account'; 63 + import {
  64 + getUserList,
  65 + userAdd,
  66 + userEdit,
  67 + userOpt,
  68 + userResetPassword,
  69 + } from '/@/api/project/account';
45 import { PageWrapper } from '/@/components/Page'; 70 import { PageWrapper } from '/@/components/Page';
46 import DeptTree from './DeptTree.vue'; 71 import DeptTree from './DeptTree.vue';
47 72
@@ -58,7 +83,7 @@ @@ -58,7 +83,7 @@
58 const go = useGo(); 83 const go = useGo();
59 const [registerModal, { openModal }] = useModal(); 84 const [registerModal, { openModal }] = useModal();
60 const searchInfo = reactive({}); 85 const searchInfo = reactive({});
61 - const [registerTable, { reload, updateTableDataRecord }] = useTable({ 86 + const [registerTable, { reload }] = useTable({
62 title: '账号列表', 87 title: '账号列表',
63 api: getUserList, 88 api: getUserList,
64 rowKey: 'id', 89 rowKey: 'id',
@@ -79,7 +104,7 @@ @@ -79,7 +104,7 @@
79 return info; 104 return info;
80 }, 105 },
81 actionColumn: { 106 actionColumn: {
82 - width: 120, 107 + width: 280,
83 title: '操作', 108 title: '操作',
84 dataIndex: 'action', 109 dataIndex: 'action',
85 // slots: { customRender: 'action' }, 110 // slots: { customRender: 'action' },
@@ -92,7 +117,7 @@ @@ -92,7 +117,7 @@
92 }); 117 });
93 } 118 }
94 119
95 - function handleEdit(record: Recordable) { 120 + function handleEdit(record) {
96 console.log(record); 121 console.log(record);
97 openModal(true, { 122 openModal(true, {
98 record, 123 record,
@@ -100,8 +125,9 @@ @@ -100,8 +125,9 @@
100 }); 125 });
101 } 126 }
102 127
103 - function handleDelete(record: Recordable) {  
104 - console.log(record); 128 + async function handleDelete(record) {
  129 + await userOpt({ ids: [record.id], optType: 20 });
  130 + reload();
105 } 131 }
106 132
107 async function handleSuccess({ isUpdate, values }) { 133 async function handleSuccess({ isUpdate, values }) {
@@ -114,12 +140,22 @@ @@ -114,12 +140,22 @@
114 reload(); 140 reload();
115 } 141 }
116 142
  143 + async function handleForbid(record) {
  144 + await userOpt({ ids: [record.id], optType: record.status === 10 ? 30 : 10 });
  145 + reload();
  146 + }
  147 +
  148 + async function handleResetPassword(record) {
  149 + await userResetPassword({ userId: record.id });
  150 + // reload();
  151 + }
  152 +
117 function handleSelect(deptId = '') { 153 function handleSelect(deptId = '') {
118 searchInfo.deptId = deptId; 154 searchInfo.deptId = deptId;
119 reload(); 155 reload();
120 } 156 }
121 157
122 - function handleView(record: Recordable) { 158 + function handleView(record) {
123 go('/system/account_detail/' + record.id); 159 go('/system/account_detail/' + record.id);
124 } 160 }
125 161
@@ -132,6 +168,8 @@ @@ -132,6 +168,8 @@
132 handleSuccess, 168 handleSuccess,
133 handleSelect, 169 handleSelect,
134 handleView, 170 handleView,
  171 + handleForbid,
  172 + handleResetPassword,
135 searchInfo, 173 searchInfo,
136 }; 174 };
137 }, 175 },
tsconfig.json
@@ -22,7 +22,8 @@ @@ -22,7 +22,8 @@
22 "build/**/*.ts", 22 "build/**/*.ts",
23 "build/**/*.d.ts", 23 "build/**/*.d.ts",
24 "mock/**/*.ts", 24 "mock/**/*.ts",
25 - "vite.config.ts" 25 + "vite.config.ts",
  26 + "src/views/project/account/account.data.tsx4"
26 ], 27 ],
27 "exclude": ["node_modules", "tests/server/**/*.ts", "dist", "**/*.js"] 28 "exclude": ["node_modules", "tests/server/**/*.ts", "dist", "**/*.js"]
28 } 29 }