@deepinnet-components/pc 0.0.26 → 0.0.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -18,12 +18,12 @@ import { createForm, onFieldValueChange } from '@formily/core';
|
|
|
18
18
|
import { createSchemaField } from '@formily/react';
|
|
19
19
|
import { Button, Spin, message } from 'antd';
|
|
20
20
|
import React, { useContext, useEffect, useMemo, useRef, useState } from 'react';
|
|
21
|
-
import
|
|
21
|
+
import MemberSelect from "../../../MemberSelect";
|
|
22
22
|
import OrgSelect from "../../../OrgSelect";
|
|
23
|
+
import OrgTreeSelect from "../../../OrgTreeSelect";
|
|
23
24
|
import RoleSelect from "../../../RoleSelect";
|
|
24
|
-
import MemberSelect from "../../../MemberSelect";
|
|
25
25
|
import ValueContext from "../../../context";
|
|
26
|
-
import { hashWithCryptoJS } from "../../../utils";
|
|
26
|
+
import { hashWithCryptoJS, sm4Encrypt } from "../../../utils";
|
|
27
27
|
var SchemaField = createSchemaField({
|
|
28
28
|
components: {
|
|
29
29
|
FormItem: FormItem,
|
|
@@ -109,16 +109,9 @@ var schema = {
|
|
|
109
109
|
'x-validator': [{
|
|
110
110
|
required: true,
|
|
111
111
|
message: '请输入密码'
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
// const regex = /^(?=.*[a-z])(?=.*[A-Z]).{8,}$/
|
|
116
|
-
// if (val && !regex.test(val)) {
|
|
117
|
-
// return '请输入包含大小写字母且长度不低于8位的密码'
|
|
118
|
-
// }
|
|
119
|
-
// },
|
|
120
|
-
// },
|
|
121
|
-
],
|
|
112
|
+
}, {
|
|
113
|
+
validator: "{{\n (val) => {\n if (!passwordConfig) return;\n const regex = passwordConfig.regex;\n if (val && !regex.test(val)) {\n return passwordConfig.message\n }\n }\n }}"
|
|
114
|
+
}],
|
|
122
115
|
'x-reactions': [{
|
|
123
116
|
when: '{{addOrEdit === "add"}}',
|
|
124
117
|
fulfill: {
|
|
@@ -165,7 +158,9 @@ var CreateAccount = function CreateAccount(props) {
|
|
|
165
158
|
Components = contextValue.Components,
|
|
166
159
|
userType = contextValue.userType,
|
|
167
160
|
isMultiRole = contextValue.isMultiRole,
|
|
168
|
-
|
|
161
|
+
passwordConfig = contextValue.passwordConfig,
|
|
162
|
+
passwordEncryption = contextValue.passwordEncryption,
|
|
163
|
+
passwordEncryptionNeedSalt = contextValue.passwordEncryptionNeedSalt;
|
|
169
164
|
var getAccountDetail = /*#__PURE__*/function () {
|
|
170
165
|
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
171
166
|
var params, _yield$ApiService$get, data, _data$departmentFlatD, _data$userMemberBindD;
|
|
@@ -253,7 +248,7 @@ var CreateAccount = function CreateAccount(props) {
|
|
|
253
248
|
var canSubmit = useRef(true);
|
|
254
249
|
var handleSubmit = /*#__PURE__*/function () {
|
|
255
250
|
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
256
|
-
var values, params, _yield$ApiService$sav, success, _params, _yield$ApiService$sav2, _success;
|
|
251
|
+
var values, params, _sm4Encrypt, key, encryptedData, _yield$ApiService$sav, success, _params, _yield$ApiService$sav2, _success;
|
|
257
252
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
258
253
|
while (1) switch (_context2.prev = _context2.next) {
|
|
259
254
|
case 0:
|
|
@@ -268,7 +263,7 @@ var CreateAccount = function CreateAccount(props) {
|
|
|
268
263
|
case 4:
|
|
269
264
|
values = _context2.sent;
|
|
270
265
|
if (!(addOrEdit === 'add')) {
|
|
271
|
-
_context2.next =
|
|
266
|
+
_context2.next = 19;
|
|
272
267
|
break;
|
|
273
268
|
}
|
|
274
269
|
_context2.prev = 6;
|
|
@@ -281,10 +276,15 @@ var CreateAccount = function CreateAccount(props) {
|
|
|
281
276
|
userType: userType,
|
|
282
277
|
bindMemberId: values.bindMemberId
|
|
283
278
|
};
|
|
279
|
+
if (passwordEncryptionNeedSalt) {
|
|
280
|
+
_sm4Encrypt = sm4Encrypt(params.password), key = _sm4Encrypt.key, encryptedData = _sm4Encrypt.encryptedData;
|
|
281
|
+
params.password = encryptedData;
|
|
282
|
+
params.key = key;
|
|
283
|
+
}
|
|
284
284
|
setLoading(true);
|
|
285
|
-
_context2.next =
|
|
285
|
+
_context2.next = 12;
|
|
286
286
|
return ApiService.saveAccount(params);
|
|
287
|
-
case
|
|
287
|
+
case 12:
|
|
288
288
|
_yield$ApiService$sav = _context2.sent;
|
|
289
289
|
success = _yield$ApiService$sav.success;
|
|
290
290
|
if (success) {
|
|
@@ -292,17 +292,17 @@ var CreateAccount = function CreateAccount(props) {
|
|
|
292
292
|
onClose === null || onClose === void 0 || onClose();
|
|
293
293
|
onSuccess === null || onSuccess === void 0 || onSuccess();
|
|
294
294
|
}
|
|
295
|
-
case
|
|
296
|
-
_context2.prev =
|
|
295
|
+
case 15:
|
|
296
|
+
_context2.prev = 15;
|
|
297
297
|
setLoading(false);
|
|
298
298
|
canSubmit.current = true;
|
|
299
|
-
return _context2.finish(
|
|
300
|
-
case
|
|
299
|
+
return _context2.finish(15);
|
|
300
|
+
case 19:
|
|
301
301
|
if (!(addOrEdit === 'edit')) {
|
|
302
|
-
_context2.next =
|
|
302
|
+
_context2.next = 32;
|
|
303
303
|
break;
|
|
304
304
|
}
|
|
305
|
-
_context2.prev =
|
|
305
|
+
_context2.prev = 20;
|
|
306
306
|
_params = {
|
|
307
307
|
accountNo: actionRow.accountNo,
|
|
308
308
|
roleCodeList: Array.isArray(values.roleCodeList) ? values.roleCodeList : [values.roleCodeList],
|
|
@@ -312,9 +312,9 @@ var CreateAccount = function CreateAccount(props) {
|
|
|
312
312
|
bindMemberId: values.bindMemberId
|
|
313
313
|
};
|
|
314
314
|
setLoading(true);
|
|
315
|
-
_context2.next =
|
|
315
|
+
_context2.next = 25;
|
|
316
316
|
return ApiService.saveAccount(_params);
|
|
317
|
-
case
|
|
317
|
+
case 25:
|
|
318
318
|
_yield$ApiService$sav2 = _context2.sent;
|
|
319
319
|
_success = _yield$ApiService$sav2.success;
|
|
320
320
|
if (_success) {
|
|
@@ -322,16 +322,16 @@ var CreateAccount = function CreateAccount(props) {
|
|
|
322
322
|
onClose === null || onClose === void 0 || onClose();
|
|
323
323
|
onSuccess === null || onSuccess === void 0 || onSuccess();
|
|
324
324
|
}
|
|
325
|
-
case
|
|
326
|
-
_context2.prev =
|
|
325
|
+
case 28:
|
|
326
|
+
_context2.prev = 28;
|
|
327
327
|
setLoading(false);
|
|
328
328
|
canSubmit.current = true;
|
|
329
|
-
return _context2.finish(
|
|
330
|
-
case
|
|
329
|
+
return _context2.finish(28);
|
|
330
|
+
case 32:
|
|
331
331
|
case "end":
|
|
332
332
|
return _context2.stop();
|
|
333
333
|
}
|
|
334
|
-
}, _callee2, null, [[6,,
|
|
334
|
+
}, _callee2, null, [[6,, 15, 19], [20,, 28, 32]]);
|
|
335
335
|
}));
|
|
336
336
|
return function handleSubmit() {
|
|
337
337
|
return _ref2.apply(this, arguments);
|
|
@@ -353,7 +353,8 @@ var CreateAccount = function CreateAccount(props) {
|
|
|
353
353
|
schema: schema,
|
|
354
354
|
scope: {
|
|
355
355
|
addOrEdit: addOrEdit,
|
|
356
|
-
isMultiRole: isMultiRole
|
|
356
|
+
isMultiRole: isMultiRole,
|
|
357
|
+
passwordConfig: passwordConfig
|
|
357
358
|
}
|
|
358
359
|
}), /*#__PURE__*/React.createElement(FormButtonGroup.FormItem, null, /*#__PURE__*/React.createElement(Button, {
|
|
359
360
|
type: "primary",
|
|
@@ -9,7 +9,9 @@ export interface MainProps {
|
|
|
9
9
|
userType?: string;
|
|
10
10
|
showDataAuth?: boolean;
|
|
11
11
|
isMultiRole?: boolean;
|
|
12
|
+
passwordConfig?: any;
|
|
12
13
|
passwordEncryption?: string;
|
|
14
|
+
passwordEncryptionNeedSalt?: boolean;
|
|
13
15
|
hideDeleteAccountBtn?: boolean;
|
|
14
16
|
hideMemberType?: Boolean;
|
|
15
17
|
showMemberPilot?: Boolean;
|
|
@@ -58,8 +58,12 @@ var Index = function Index(props) {
|
|
|
58
58
|
showDataAuth = _props$showDataAuth === void 0 ? false : _props$showDataAuth,
|
|
59
59
|
_props$isMultiRole = props.isMultiRole,
|
|
60
60
|
isMultiRole = _props$isMultiRole === void 0 ? true : _props$isMultiRole,
|
|
61
|
+
_props$passwordConfig = props.passwordConfig,
|
|
62
|
+
passwordConfig = _props$passwordConfig === void 0 ? null : _props$passwordConfig,
|
|
61
63
|
_props$passwordEncryp = props.passwordEncryption,
|
|
62
64
|
passwordEncryption = _props$passwordEncryp === void 0 ? 'md5' : _props$passwordEncryp,
|
|
65
|
+
_props$passwordEncryp2 = props.passwordEncryptionNeedSalt,
|
|
66
|
+
passwordEncryptionNeedSalt = _props$passwordEncryp2 === void 0 ? false : _props$passwordEncryp2,
|
|
63
67
|
_props$hideDeleteAcco = props.hideDeleteAccountBtn,
|
|
64
68
|
hideDeleteAccountBtn = _props$hideDeleteAcco === void 0 ? false : _props$hideDeleteAcco,
|
|
65
69
|
_props$hideMemberType = props.hideMemberType,
|
|
@@ -211,7 +215,9 @@ var Index = function Index(props) {
|
|
|
211
215
|
userType: userType,
|
|
212
216
|
showDataAuth: showDataAuth,
|
|
213
217
|
isMultiRole: isMultiRole,
|
|
218
|
+
passwordConfig: passwordConfig,
|
|
214
219
|
passwordEncryption: passwordEncryption,
|
|
220
|
+
passwordEncryptionNeedSalt: passwordEncryptionNeedSalt,
|
|
215
221
|
hideDeleteAccountBtn: hideDeleteAccountBtn,
|
|
216
222
|
hideMemberType: hideMemberType,
|
|
217
223
|
showMemberPilot: showMemberPilot
|
package/dist/UserCenter/utils.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import CryptoJS from 'crypto-js';
|
|
2
|
+
import { SM4 } from 'gm-crypto';
|
|
2
3
|
|
|
3
4
|
// 获取url参数
|
|
4
5
|
export function getUrlQuery() {
|
|
@@ -29,4 +30,25 @@ export function hashWithCryptoJS(message) {
|
|
|
29
30
|
default:
|
|
30
31
|
throw new Error("Unsupported algorithm: ".concat(algorithm));
|
|
31
32
|
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// 生成32位的16进制数
|
|
36
|
+
function generate32HexDigits() {
|
|
37
|
+
var result = '';
|
|
38
|
+
for (var i = 0; i < 32; i++) {
|
|
39
|
+
result += Math.floor(Math.random() * 16).toString(16);
|
|
40
|
+
}
|
|
41
|
+
return result;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// SM4 国标对称加密
|
|
45
|
+
export function sm4Encrypt(data) {
|
|
46
|
+
var key = generate32HexDigits();
|
|
47
|
+
return {
|
|
48
|
+
key: key,
|
|
49
|
+
encryptedData: SM4.encrypt(data, key, {
|
|
50
|
+
inputEncoding: 'utf8',
|
|
51
|
+
outputEncoding: 'base64'
|
|
52
|
+
})
|
|
53
|
+
};
|
|
32
54
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@deepinnet-components/pc",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.28",
|
|
4
4
|
"description": "A react library developed with dumi",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"module": "dist/index.js",
|
|
@@ -56,6 +56,7 @@
|
|
|
56
56
|
"axios": "^1.5.1",
|
|
57
57
|
"crypto-js": "^4.2.0",
|
|
58
58
|
"dayjs": "^1.11.13",
|
|
59
|
+
"gm-crypto": "^0.1.12",
|
|
59
60
|
"lodash-es": "^4.17.21",
|
|
60
61
|
"md5": "^2.3.0",
|
|
61
62
|
"react-router-dom": "^7.6.2",
|