@tddc/assign-modal 1.2.2 → 1.2.3

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.
@@ -175,18 +175,32 @@ var AssignModal = function AssignModal(props) {
175
175
  onChange = props.onChange,
176
176
  orgTitle = props.orgTitle,
177
177
  appTitle = props.appTitle,
178
+ userTitle = props.userTitle,
178
179
  orgCheckboxTitle = props.orgCheckboxTitle,
179
- appCheckboxTitle = props.appCheckboxTitle;
180
+ appCheckboxTitle = props.appCheckboxTitle,
181
+ userCheckboxTitle = props.userCheckboxTitle,
182
+ _props$userList = props.userList,
183
+ userList = _props$userList === void 0 ? [] : _props$userList,
184
+ showUser = props.showUser;
180
185
  var _dataItem$appCodes = dataItem.appCodes,
181
186
  appCodes = _dataItem$appCodes === void 0 ? [] : _dataItem$appCodes,
182
187
  _dataItem$orgCodes = dataItem.orgCodes,
183
188
  orgCodes = _dataItem$orgCodes === void 0 ? [] : _dataItem$orgCodes,
184
189
  orgCode = dataItem.orgCode,
185
- appCode = dataItem.appCode;
190
+ appCode = dataItem.appCode,
191
+ _dataItem$accounts = dataItem.accounts,
192
+ accounts = _dataItem$accounts === void 0 ? [] : _dataItem$accounts,
193
+ account = dataItem.account;
186
194
  var allOrg = (0, _utils.preorder)(orgList[0]);
187
195
  var allApp = appList.map(function (item) {
188
196
  return item.value;
189
197
  });
198
+ var allUser =
199
+ (userList === null || userList === void 0
200
+ ? void 0
201
+ : userList.map(function (item) {
202
+ return item.account;
203
+ })) || [];
190
204
  var _useState = (0, _react.useState)([]),
191
205
  _useState2 = _slicedToArray(_useState, 2),
192
206
  checkedKeys = _useState2[0],
@@ -195,14 +209,22 @@ var AssignModal = function AssignModal(props) {
195
209
  _useState4 = _slicedToArray(_useState3, 2),
196
210
  appKeys = _useState4[0],
197
211
  setAppKeys = _useState4[1];
198
- var _useState5 = (0, _react.useState)(false),
212
+ var _useState5 = (0, _react.useState)(accounts || []),
199
213
  _useState6 = _slicedToArray(_useState5, 2),
200
- allOrgChecked = _useState6[0],
201
- setAllOrgChecked = _useState6[1];
214
+ userKeys = _useState6[0],
215
+ setUserKeys = _useState6[1];
202
216
  var _useState7 = (0, _react.useState)(false),
203
217
  _useState8 = _slicedToArray(_useState7, 2),
204
- allAppChecked = _useState8[0],
205
- setAllAppChecked = _useState8[1];
218
+ allOrgChecked = _useState8[0],
219
+ setAllOrgChecked = _useState8[1];
220
+ var _useState9 = (0, _react.useState)(false),
221
+ _useState10 = _slicedToArray(_useState9, 2),
222
+ allAppChecked = _useState10[0],
223
+ setAllAppChecked = _useState10[1];
224
+ var _useState11 = (0, _react.useState)(false),
225
+ _useState12 = _slicedToArray(_useState11, 2),
226
+ allUserChecked = _useState12[0],
227
+ setAllUserChecked = _useState12[1];
206
228
  if (!((_orgList$ = orgList[0]) === null || _orgList$ === void 0 ? void 0 : _orgList$.path)) {
207
229
  (0, _utils.addPath)(orgList[0], []); // 添加 上级机构到子机构的路径
208
230
  }
@@ -213,6 +235,7 @@ var AssignModal = function AssignModal(props) {
213
235
  path = (0, _utils.findSameCodePath)(orgList[0], orgCode);
214
236
  var initOrgs = [];
215
237
  var initApps = [];
238
+ var initAccounts = [];
216
239
  if (orgCodes.includes('all')) {
217
240
  setAllOrgChecked(orgCodes.includes('all'));
218
241
  initOrgs = allOrg;
@@ -227,20 +250,31 @@ var AssignModal = function AssignModal(props) {
227
250
  } else {
228
251
  initApps = Array.from(new Set([].concat(_toConsumableArray(appCodes || []), [appCode])));
229
252
  }
253
+ if (showUser) {
254
+ if (accounts.includes('all')) {
255
+ setAllUserChecked(true);
256
+ initAccounts = allUser;
257
+ } else {
258
+ initAccounts = Array.from(
259
+ new Set([].concat(_toConsumableArray(accounts || []), [account])),
260
+ );
261
+ }
262
+ }
230
263
  setCheckedKeys(initOrgs);
231
264
  setAppKeys(initApps || []);
232
- console.log({
233
- initApps: initApps,
234
- });
265
+ setUserKeys(initAccounts || []);
235
266
  onChange &&
236
267
  onChange({
237
268
  appKeys: appCodes.includes('all') ? ['all'] : initApps,
238
269
  checkedKeys: orgCodes.includes('all') ? ['all'] : initOrgs,
270
+ userKeys: accounts.includes('all') ? ['all'] : initAccounts,
239
271
  appCheckAll: appCodes.includes('all'),
240
272
  orgCheckAll: orgCodes.includes('all'),
273
+ userCheckAll: accounts.includes('all'),
241
274
  checkData: {
242
275
  apps: initApps,
243
276
  orgs: initOrgs,
277
+ accounts: initAccounts,
244
278
  },
245
279
  });
246
280
  },
@@ -314,9 +348,12 @@ var AssignModal = function AssignModal(props) {
314
348
  checkedKeys: checked,
315
349
  appCheckAll: allAppChecked,
316
350
  orgCheckAll: allOrgChecked,
351
+ userKeys: allUserChecked ? ['all'] : userKeys,
352
+ userCheckAll: allUserChecked,
317
353
  checkData: {
318
354
  apps: appKeys,
319
355
  orgs: checked,
356
+ accounts: userKeys,
320
357
  },
321
358
  });
322
359
  };
@@ -341,9 +378,42 @@ var AssignModal = function AssignModal(props) {
341
378
  checkedKeys: allOrgChecked ? ['all'] : checkedKeys,
342
379
  appCheckAll: allAppChecked,
343
380
  orgCheckAll: allOrgChecked,
381
+ userKeys: allUserChecked ? ['all'] : userKeys,
382
+ userCheckAll: allUserChecked,
344
383
  checkData: {
345
384
  apps: newAppKeys,
346
385
  orgs: checkedKeys,
386
+ accounts: userKeys,
387
+ },
388
+ });
389
+ };
390
+ var assignUser = function assignUser(e) {
391
+ var value = '';
392
+ var newUserKeys = [];
393
+ if (e.target.checked) {
394
+ value = e.target.value;
395
+ newUserKeys = [].concat(_toConsumableArray(userKeys), [value]);
396
+ } else {
397
+ value = e.target.value;
398
+ newUserKeys = (0, _lodash.cloneDeep)(userKeys);
399
+ newUserKeys.map(function (item, index) {
400
+ if (value === item) {
401
+ newUserKeys.splice(index, 1);
402
+ }
403
+ });
404
+ }
405
+ setUserKeys(newUserKeys);
406
+ onChange({
407
+ appKeys: appKeys,
408
+ checkedKeys: allOrgChecked ? ['all'] : checkedKeys,
409
+ appCheckAll: allAppChecked,
410
+ orgCheckAll: allOrgChecked,
411
+ userKeys: userKeys,
412
+ userCheckAll: allUserChecked,
413
+ checkData: {
414
+ apps: appKeys,
415
+ orgs: checkedKeys,
416
+ accounts: newUserKeys,
347
417
  },
348
418
  });
349
419
  };
@@ -360,9 +430,12 @@ var AssignModal = function AssignModal(props) {
360
430
  checkedKeys: ['all'],
361
431
  appCheckAll: allAppChecked,
362
432
  orgCheckAll: true,
433
+ userKeys: allUserChecked ? ['all'] : userKeys,
434
+ userCheckAll: allUserChecked,
363
435
  checkData: {
364
436
  apps: appKeys,
365
437
  orgs: checkedKeys,
438
+ accounts: accounts,
366
439
  },
367
440
  });
368
441
  } else {
@@ -377,9 +450,12 @@ var AssignModal = function AssignModal(props) {
377
450
  checkedKeys: orgChecks,
378
451
  appCheckAll: allAppChecked,
379
452
  orgCheckAll: false,
453
+ userKeys: allUserChecked ? ['all'] : userKeys,
454
+ userCheckAll: allUserChecked,
380
455
  checkData: {
381
456
  apps: appKeys,
382
457
  orgs: orgChecks,
458
+ accounts: accounts,
383
459
  },
384
460
  });
385
461
  }
@@ -399,9 +475,12 @@ var AssignModal = function AssignModal(props) {
399
475
  checkedKeys: allOrgChecked ? ['all'] : checkedKeys,
400
476
  appCheckAll: true,
401
477
  orgCheckAll: allOrgChecked,
478
+ userKeys: allUserChecked ? ['all'] : userKeys,
479
+ userCheckAll: allUserChecked,
402
480
  checkData: {
403
481
  apps: appChecks,
404
482
  orgs: checkedKeys,
483
+ accounts: accounts,
405
484
  },
406
485
  });
407
486
  } else {
@@ -414,9 +493,55 @@ var AssignModal = function AssignModal(props) {
414
493
  checkedKeys: allOrgChecked ? ['all'] : checkedKeys,
415
494
  appCheckAll: false,
416
495
  orgCheckAll: allOrgChecked,
496
+ userKeys: allUserChecked ? ['all'] : userKeys,
497
+ userCheckAll: allUserChecked,
417
498
  checkData: {
418
499
  apps: appChecks,
419
500
  orgs: checkedKeys,
501
+ accounts: accounts,
502
+ },
503
+ });
504
+ }
505
+ };
506
+
507
+ // account全局授权
508
+ var checkedAllUser = function checkedAllUser(e) {
509
+ var userChecks = [];
510
+ if (e.target.checked) {
511
+ setAllUserChecked(true);
512
+ userChecks = userList.map(function (item) {
513
+ return item.account;
514
+ });
515
+ setUserKeys(userChecks);
516
+ onChange({
517
+ appKeys: allAppChecked ? ['all'] : appKeys,
518
+ appCheckAll: allAppChecked,
519
+ checkedKeys: allOrgChecked ? ['all'] : checkedKeys,
520
+ orgCheckAll: allOrgChecked,
521
+ userKeys: ['all'],
522
+ userCheckAll: true,
523
+ checkData: {
524
+ apps: appKeys,
525
+ orgs: checkedKeys,
526
+ accounts: userChecks,
527
+ },
528
+ });
529
+ } else {
530
+ setAllUserChecked(false);
531
+ var arr = accounts.includes('all') ? allUser : accounts;
532
+ userChecks = Array.from(new Set([].concat(_toConsumableArray(arr || []), [account])));
533
+ setUserKeys(userChecks);
534
+ onChange({
535
+ appKeys: allAppChecked ? ['all'] : appKeys,
536
+ appCheckAll: allAppChecked,
537
+ checkedKeys: allOrgChecked ? ['all'] : checkedKeys,
538
+ orgCheckAll: allOrgChecked,
539
+ userKeys: userChecks,
540
+ userCheckAll: false,
541
+ checkData: {
542
+ apps: appKeys,
543
+ orgs: checkedKeys,
544
+ accounts: userChecks,
420
545
  },
421
546
  });
422
547
  }
@@ -545,6 +670,76 @@ var AssignModal = function AssignModal(props) {
545
670
  }),
546
671
  ),
547
672
  ),
673
+ !!showUser &&
674
+ /*#__PURE__*/ _react.default.createElement(
675
+ 'div',
676
+ {
677
+ className: 'user',
678
+ },
679
+ /*#__PURE__*/ _react.default.createElement(
680
+ 'div',
681
+ {
682
+ className: 'menu-header',
683
+ },
684
+ userTitle ||
685
+ (0, _locale.getText)(
686
+ 'authorizesUserList',
687
+ props === null || props === void 0 ? void 0 : props.lang,
688
+ ),
689
+ /*#__PURE__*/ _react.default.createElement(
690
+ 'div',
691
+ {
692
+ className: 'menu-all-checked',
693
+ },
694
+ /*#__PURE__*/ _react.default.createElement(
695
+ _checkbox.default,
696
+ {
697
+ onChange: checkedAllUser,
698
+ checked: allUserChecked,
699
+ disabled: disabled,
700
+ },
701
+ userCheckboxTitle ||
702
+ (0, _locale.getText)(
703
+ 'allUserAvailable',
704
+ props === null || props === void 0 ? void 0 : props.lang,
705
+ ),
706
+ ),
707
+ ),
708
+ ),
709
+ /*#__PURE__*/ _react.default.createElement(
710
+ 'div',
711
+ {
712
+ className: 'menu-body',
713
+ },
714
+ userList.map(function (item, index) {
715
+ var isCheck =
716
+ userKeys === null || userKeys === void 0 ? void 0 : userKeys.includes(item.account);
717
+ var isOwnAccount = account === item.account;
718
+ return /*#__PURE__*/ _react.default.createElement(
719
+ _checkbox.default,
720
+ {
721
+ checked: isCheck,
722
+ disabled: disabled || isOwnAccount || allUserChecked,
723
+ onChange: assignUser,
724
+ value: item.account,
725
+ key: index,
726
+ },
727
+ /*#__PURE__*/ _react.default.createElement(
728
+ 'span',
729
+ {
730
+ style: {
731
+ display: 'inline-block',
732
+ },
733
+ },
734
+ /*#__PURE__*/ _react.default.createElement(_tntd.Ellipsis, {
735
+ widthLimit: 100,
736
+ title: item.userName,
737
+ }),
738
+ ),
739
+ );
740
+ }),
741
+ ),
742
+ ),
548
743
  );
549
744
  };
550
745
  var _default = AssignModal;
@@ -15,7 +15,7 @@
15
15
 
16
16
  .left {
17
17
  position: relative;
18
- z-index: 1;
18
+ z-index: 3;
19
19
  width: 430px;
20
20
  background: #ffffff;
21
21
  box-shadow: 0px 0px 6px 0px rgba(58, 48, 48, 0.12);
@@ -66,6 +66,7 @@
66
66
  }
67
67
 
68
68
  .right {
69
+ z-index: 2;
69
70
  flex: 1;
70
71
  overflow: scroll;
71
72
  background: #fcfcfc;
@@ -77,4 +78,19 @@
77
78
  }
78
79
  }
79
80
  }
81
+
82
+ .user {
83
+ position: relative;
84
+ z-index: 1;
85
+ width: 320px;
86
+ overflow: auto;
87
+ background: #ffffff;
88
+ box-shadow: 0px 0px 6px 0px rgba(58, 48, 48, 0.12);
89
+ .menu-body {
90
+ margin: 20px;
91
+ .ant-checkbox-wrapper {
92
+ margin: 0 4px !important;
93
+ }
94
+ }
95
+ }
80
96
  }
@@ -44,6 +44,8 @@ var _excluded = [
44
44
  'title',
45
45
  'onSubmit',
46
46
  'appList',
47
+ 'userList',
48
+ 'showUser',
47
49
  ];
48
50
  function _getRequireWildcardCache(nodeInterop) {
49
51
  if (typeof WeakMap !== 'function') return null;
@@ -205,6 +207,8 @@ var AssignModal = function AssignModal(props) {
205
207
  title = _props$title === void 0 ? '' : _props$title,
206
208
  onSubmit = props.onSubmit,
207
209
  appList = props.appList,
210
+ userList = props.userList,
211
+ showUser = props.showUser,
208
212
  restProps = _objectWithoutProperties(props, _excluded);
209
213
  var _useState = (0, _react.useState)({}),
210
214
  _useState2 = _slicedToArray(_useState, 2),
@@ -222,7 +226,7 @@ var AssignModal = function AssignModal(props) {
222
226
  className: 'modelTool-assign',
223
227
  title: title,
224
228
  visible: visible,
225
- width: '65%',
229
+ width: showUser ? '80%' : '65%',
226
230
  onCancel: close,
227
231
  onOk: submit,
228
232
  maskClosable: false,
@@ -238,6 +242,7 @@ var AssignModal = function AssignModal(props) {
238
242
  dataItem: dataItem,
239
243
  orgList: orgList,
240
244
  appList: appList,
245
+ userList: userList,
241
246
  onChange: function onChange(data) {
242
247
  setAssignData(data);
243
248
  },
@@ -246,6 +251,7 @@ var AssignModal = function AssignModal(props) {
246
251
  (props === null || props === void 0 ? void 0 : props.lang) ||
247
252
  cookies.get('lang') ||
248
253
  'cn',
254
+ showUser: showUser,
249
255
  },
250
256
  restProps,
251
257
  ),
package/lib/locale.js CHANGED
@@ -14,13 +14,17 @@ var zh_CN = {
14
14
  allOrgAvailable: '全部机构可用',
15
15
  authorizesAppList: '授权可用渠道列表',
16
16
  allAppAvailable: '全部渠道可用',
17
+ authorizesUserList: '全部可用用户列表',
18
+ allUserAvailable: '全部用户可用',
17
19
  };
18
20
  exports.zh_CN = zh_CN;
19
21
  var en_US = {
20
22
  authorizesOrgList: 'Authorizes the list of organization available',
21
- allOrgAvailable: 'All organization are available',
23
+ allOrgAvailable: 'All organizations are available',
22
24
  authorizesAppList: 'Authorizes the list of application available',
23
- allAppAvailable: 'All application are available',
25
+ allAppAvailable: 'All applications are available',
26
+ authorizesUserList: 'Authorizes the list of account available',
27
+ allUserAvailable: 'All accounts are available',
24
28
  };
25
29
  exports.en_US = en_US;
26
30
  var getText = function getText(key, language) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tddc/assign-modal",
3
- "version": "1.2.2",
3
+ "version": "1.2.3",
4
4
  "description": "Layout",
5
5
  "author": "zj <jun.zhang002383@tongdun.net>",
6
6
  "license": "ISC",