Commit 0dc8e021d0be848d8d60d7de1d26f43e6bdf251d

Authored by zhusen
2 parents 7311d332 5298311d

Merge branch 'feat-user-reset' into 'develop'

Feat user reset



See merge request !2
src/api/project/account.ts
... ... @@ -6,6 +6,8 @@ enum Api {
6 6 USER_ADD = '/order/erp/users/add',
7 7 USER_EDIT = '/order/erp/users/edit',
8 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 13 export const getRoleList = async (params: any) => {
... ... @@ -61,3 +63,23 @@ export const userDelete = async (params: any) => {
61 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 10 GetUserInfo = '/getUserInfo',
11 11 GetPermCode = '/getPermCode',
12 12 TestRetry = '/testRetry',
13   - MODIFY_PASSWORD = '/order/erp/users/update_pass',
  13 + MODIFY_PASSWORD = '/order/erp/users/update_pass', // 用户修改自己的密码,不需要验证码
14 14 FORGET_PASSWORD = '/order/erp/auth/password_modify',
15 15 RESET = '/order/erp/users/reset',
16 16 CAPTCHA = '/order/erp/captcha/get_img_captcha_code',
... ... @@ -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 36 return defHttp.post<LoginResultModel>(
37 37 {
38 38 url: Api.MODIFY_PASSWORD,
... ...
src/views/demo/system/password/index.vue
... ... @@ -16,7 +16,7 @@
16 16 import { useUserStoreWithOut } from '/@/store/modules/user';
17 17  
18 18 import { formSchema } from './pwd.data';
19   - import { forgetPassword } from '/@/api/sys/user';
  19 + import { modifyPassword } from '/@/api/sys/user';
20 20  
21 21 export default defineComponent({
22 22 name: 'ChangePassword',
... ... @@ -38,7 +38,7 @@
38 38  
39 39 const userInfo = userStore.getUserInfo;
40 40  
41   - await forgetPassword({ ...values, userId: userInfo.id });
  41 + await modifyPassword({ ...values, userId: userInfo.id });
42 42 } catch (error) {}
43 43 }
44 44  
... ...
src/views/project/account/AccountModal.vue
... ... @@ -62,3 +62,4 @@
62 62 },
63 63 });
64 64 </script>
  65 +./account.data.tsx4
... ...
src/views/project/account/account.data.ts renamed to src/views/project/account/account.data.tsx
1 1 import { getRoleList } from '/@/api/project/account';
  2 +import { Tag } from 'ant-design-vue';
2 3  
3 4 export const columns: BasicColumn[] = [
4 5 {
... ... @@ -27,6 +28,15 @@ export const columns: BasicColumn[] = [
27 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 40 title: '备注',
31 41 dataIndex: 'remark',
32 42 },
... ...
src/views/project/account/index.vue
... ... @@ -19,16 +19,38 @@
19 19 // tooltip: '编辑用户资料',
20 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:
  37 + record.status === 10
  38 + ? '是否确认离职该用户,离职用户无法通过忘记密码进行手机验证码修改密码。请管理员重置其账号密码并修改。'
  39 + : '是否确认启用',
  40 + placement: 'left',
  41 + confirm: handleForbid.bind(null, record),
  42 + },
  43 + },
  44 + {
  45 + // icon: 'ant-design:delete-outlined',
  46 + color: 'error',
  47 + label: '删除',
  48 + popConfirm: {
  49 + title: '是否确认删除',
  50 + placement: 'left',
  51 + confirm: handleDelete.bind(null, record),
  52 + },
  53 + },
32 54 ]"
33 55 />
34 56 </template>
... ... @@ -41,7 +63,13 @@
41 63 import { defineComponent, reactive } from 'vue';
42 64  
43 65 import { BasicTable, useTable, TableAction } from '/@/components/Table';
44   - import { getUserList, userAdd, userEdit } from '/@/api/project/account';
  66 + import {
  67 + getUserList,
  68 + userAdd,
  69 + userEdit,
  70 + userOpt,
  71 + userResetPassword,
  72 + } from '/@/api/project/account';
45 73 import { PageWrapper } from '/@/components/Page';
46 74 import DeptTree from './DeptTree.vue';
47 75  
... ... @@ -58,7 +86,7 @@
58 86 const go = useGo();
59 87 const [registerModal, { openModal }] = useModal();
60 88 const searchInfo = reactive({});
61   - const [registerTable, { reload, updateTableDataRecord }] = useTable({
  89 + const [registerTable, { reload }] = useTable({
62 90 title: '账号列表',
63 91 api: getUserList,
64 92 rowKey: 'id',
... ... @@ -79,7 +107,7 @@
79 107 return info;
80 108 },
81 109 actionColumn: {
82   - width: 120,
  110 + width: 280,
83 111 title: '操作',
84 112 dataIndex: 'action',
85 113 // slots: { customRender: 'action' },
... ... @@ -92,7 +120,7 @@
92 120 });
93 121 }
94 122  
95   - function handleEdit(record: Recordable) {
  123 + function handleEdit(record) {
96 124 console.log(record);
97 125 openModal(true, {
98 126 record,
... ... @@ -100,8 +128,9 @@
100 128 });
101 129 }
102 130  
103   - function handleDelete(record: Recordable) {
104   - console.log(record);
  131 + async function handleDelete(record) {
  132 + await userOpt({ ids: [record.id], optType: 20 });
  133 + reload();
105 134 }
106 135  
107 136 async function handleSuccess({ isUpdate, values }) {
... ... @@ -114,12 +143,22 @@
114 143 reload();
115 144 }
116 145  
  146 + async function handleForbid(record) {
  147 + await userOpt({ ids: [record.id], optType: record.status === 10 ? 30 : 10 });
  148 + reload();
  149 + }
  150 +
  151 + async function handleResetPassword(record) {
  152 + await userResetPassword({ userId: record.id });
  153 + // reload();
  154 + }
  155 +
117 156 function handleSelect(deptId = '') {
118 157 searchInfo.deptId = deptId;
119 158 reload();
120 159 }
121 160  
122   - function handleView(record: Recordable) {
  161 + function handleView(record) {
123 162 go('/system/account_detail/' + record.id);
124 163 }
125 164  
... ... @@ -132,6 +171,8 @@
132 171 handleSuccess,
133 172 handleSelect,
134 173 handleView,
  174 + handleForbid,
  175 + handleResetPassword,
135 176 searchInfo,
136 177 };
137 178 },
... ...
src/views/project/order/tableData.tsx
... ... @@ -1135,6 +1135,7 @@ export const FIELDS_INSPECTION_INFO = [
1135 1135 component: 'Select',
1136 1136 optionField: 'midCheckResult',
1137 1137 label: '中期验货结果PASS / FAIL',
  1138 + labelWidth: 400,
1138 1139 // rules: [{ required: true }],
1139 1140 },
1140 1141 {
... ...
tsconfig.json
... ... @@ -22,7 +22,8 @@
22 22 "build/**/*.ts",
23 23 "build/**/*.d.ts",
24 24 "mock/**/*.ts",
25   - "vite.config.ts"
  25 + "vite.config.ts",
  26 + "src/views/project/account/account.data.tsx4"
26 27 ],
27 28 "exclude": ["node_modules", "tests/server/**/*.ts", "dist", "**/*.js"]
28 29 }
... ...