@tddc/assign-modal 1.2.1 → 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.
@@ -120,9 +120,7 @@ function _unsupportedIterableToArray(o, minLen) {
120
120
  }
121
121
  function _arrayLikeToArray(arr, len) {
122
122
  if (len == null || len > arr.length) len = arr.length;
123
- for (var i = 0, arr2 = new Array(len); i < len; i++) {
124
- arr2[i] = arr[i];
125
- }
123
+ for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
126
124
  return arr2;
127
125
  }
128
126
  function _iterableToArrayLimit(arr, i) {
@@ -147,7 +145,7 @@ function _iterableToArrayLimit(arr, i) {
147
145
  ;
148
146
  !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i);
149
147
  _n = !0
150
- ) {}
148
+ );
151
149
  } catch (err) {
152
150
  (_d = !0), (_e = err);
153
151
  } finally {
@@ -167,6 +165,7 @@ var TreeNode = _tree.default.TreeNode;
167
165
  var path = []; // 上级机构到当前机构的路径
168
166
 
169
167
  var AssignModal = function AssignModal(props) {
168
+ var _orgList$;
170
169
  var _props$orgList = props.orgList,
171
170
  orgList = _props$orgList === void 0 ? [] : _props$orgList,
172
171
  _props$dataItem = props.dataItem,
@@ -176,18 +175,32 @@ var AssignModal = function AssignModal(props) {
176
175
  onChange = props.onChange,
177
176
  orgTitle = props.orgTitle,
178
177
  appTitle = props.appTitle,
178
+ userTitle = props.userTitle,
179
179
  orgCheckboxTitle = props.orgCheckboxTitle,
180
- 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;
181
185
  var _dataItem$appCodes = dataItem.appCodes,
182
186
  appCodes = _dataItem$appCodes === void 0 ? [] : _dataItem$appCodes,
183
187
  _dataItem$orgCodes = dataItem.orgCodes,
184
188
  orgCodes = _dataItem$orgCodes === void 0 ? [] : _dataItem$orgCodes,
185
189
  orgCode = dataItem.orgCode,
186
- appCode = dataItem.appCode;
190
+ appCode = dataItem.appCode,
191
+ _dataItem$accounts = dataItem.accounts,
192
+ accounts = _dataItem$accounts === void 0 ? [] : _dataItem$accounts,
193
+ account = dataItem.account;
187
194
  var allOrg = (0, _utils.preorder)(orgList[0]);
188
195
  var allApp = appList.map(function (item) {
189
196
  return item.value;
190
197
  });
198
+ var allUser =
199
+ (userList === null || userList === void 0
200
+ ? void 0
201
+ : userList.map(function (item) {
202
+ return item.account;
203
+ })) || [];
191
204
  var _useState = (0, _react.useState)([]),
192
205
  _useState2 = _slicedToArray(_useState, 2),
193
206
  checkedKeys = _useState2[0],
@@ -196,15 +209,23 @@ var AssignModal = function AssignModal(props) {
196
209
  _useState4 = _slicedToArray(_useState3, 2),
197
210
  appKeys = _useState4[0],
198
211
  setAppKeys = _useState4[1];
199
- var _useState5 = (0, _react.useState)(false),
212
+ var _useState5 = (0, _react.useState)(accounts || []),
200
213
  _useState6 = _slicedToArray(_useState5, 2),
201
- allOrgChecked = _useState6[0],
202
- setAllOrgChecked = _useState6[1];
214
+ userKeys = _useState6[0],
215
+ setUserKeys = _useState6[1];
203
216
  var _useState7 = (0, _react.useState)(false),
204
217
  _useState8 = _slicedToArray(_useState7, 2),
205
- allAppChecked = _useState8[0],
206
- setAllAppChecked = _useState8[1];
207
- if (!orgList[0].path) {
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];
228
+ if (!((_orgList$ = orgList[0]) === null || _orgList$ === void 0 ? void 0 : _orgList$.path)) {
208
229
  (0, _utils.addPath)(orgList[0], []); // 添加 上级机构到子机构的路径
209
230
  }
210
231
 
@@ -214,6 +235,7 @@ var AssignModal = function AssignModal(props) {
214
235
  path = (0, _utils.findSameCodePath)(orgList[0], orgCode);
215
236
  var initOrgs = [];
216
237
  var initApps = [];
238
+ var initAccounts = [];
217
239
  if (orgCodes.includes('all')) {
218
240
  setAllOrgChecked(orgCodes.includes('all'));
219
241
  initOrgs = allOrg;
@@ -228,20 +250,31 @@ var AssignModal = function AssignModal(props) {
228
250
  } else {
229
251
  initApps = Array.from(new Set([].concat(_toConsumableArray(appCodes || []), [appCode])));
230
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
+ }
231
263
  setCheckedKeys(initOrgs);
232
264
  setAppKeys(initApps || []);
233
- console.log({
234
- initApps: initApps,
235
- });
265
+ setUserKeys(initAccounts || []);
236
266
  onChange &&
237
267
  onChange({
238
268
  appKeys: appCodes.includes('all') ? ['all'] : initApps,
239
269
  checkedKeys: orgCodes.includes('all') ? ['all'] : initOrgs,
270
+ userKeys: accounts.includes('all') ? ['all'] : initAccounts,
240
271
  appCheckAll: appCodes.includes('all'),
241
272
  orgCheckAll: orgCodes.includes('all'),
273
+ userCheckAll: accounts.includes('all'),
242
274
  checkData: {
243
275
  apps: initApps,
244
276
  orgs: initOrgs,
277
+ accounts: initAccounts,
245
278
  },
246
279
  });
247
280
  },
@@ -315,9 +348,12 @@ var AssignModal = function AssignModal(props) {
315
348
  checkedKeys: checked,
316
349
  appCheckAll: allAppChecked,
317
350
  orgCheckAll: allOrgChecked,
351
+ userKeys: allUserChecked ? ['all'] : userKeys,
352
+ userCheckAll: allUserChecked,
318
353
  checkData: {
319
354
  apps: appKeys,
320
355
  orgs: checked,
356
+ accounts: userKeys,
321
357
  },
322
358
  });
323
359
  };
@@ -342,9 +378,42 @@ var AssignModal = function AssignModal(props) {
342
378
  checkedKeys: allOrgChecked ? ['all'] : checkedKeys,
343
379
  appCheckAll: allAppChecked,
344
380
  orgCheckAll: allOrgChecked,
381
+ userKeys: allUserChecked ? ['all'] : userKeys,
382
+ userCheckAll: allUserChecked,
345
383
  checkData: {
346
384
  apps: newAppKeys,
347
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,
348
417
  },
349
418
  });
350
419
  };
@@ -361,9 +430,12 @@ var AssignModal = function AssignModal(props) {
361
430
  checkedKeys: ['all'],
362
431
  appCheckAll: allAppChecked,
363
432
  orgCheckAll: true,
433
+ userKeys: allUserChecked ? ['all'] : userKeys,
434
+ userCheckAll: allUserChecked,
364
435
  checkData: {
365
436
  apps: appKeys,
366
437
  orgs: checkedKeys,
438
+ accounts: accounts,
367
439
  },
368
440
  });
369
441
  } else {
@@ -378,9 +450,12 @@ var AssignModal = function AssignModal(props) {
378
450
  checkedKeys: orgChecks,
379
451
  appCheckAll: allAppChecked,
380
452
  orgCheckAll: false,
453
+ userKeys: allUserChecked ? ['all'] : userKeys,
454
+ userCheckAll: allUserChecked,
381
455
  checkData: {
382
456
  apps: appKeys,
383
457
  orgs: orgChecks,
458
+ accounts: accounts,
384
459
  },
385
460
  });
386
461
  }
@@ -400,9 +475,12 @@ var AssignModal = function AssignModal(props) {
400
475
  checkedKeys: allOrgChecked ? ['all'] : checkedKeys,
401
476
  appCheckAll: true,
402
477
  orgCheckAll: allOrgChecked,
478
+ userKeys: allUserChecked ? ['all'] : userKeys,
479
+ userCheckAll: allUserChecked,
403
480
  checkData: {
404
481
  apps: appChecks,
405
482
  orgs: checkedKeys,
483
+ accounts: accounts,
406
484
  },
407
485
  });
408
486
  } else {
@@ -415,9 +493,55 @@ var AssignModal = function AssignModal(props) {
415
493
  checkedKeys: allOrgChecked ? ['all'] : checkedKeys,
416
494
  appCheckAll: false,
417
495
  orgCheckAll: allOrgChecked,
496
+ userKeys: allUserChecked ? ['all'] : userKeys,
497
+ userCheckAll: allUserChecked,
418
498
  checkData: {
419
499
  apps: appChecks,
420
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,
421
545
  },
422
546
  });
423
547
  }
@@ -546,6 +670,76 @@ var AssignModal = function AssignModal(props) {
546
670
  }),
547
671
  ),
548
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
+ ),
549
743
  );
550
744
  };
551
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
  }
@@ -38,9 +38,7 @@ function _arrayWithoutHoles(arr) {
38
38
  }
39
39
  function _arrayLikeToArray(arr, len) {
40
40
  if (len == null || len > arr.length) len = arr.length;
41
- for (var i = 0, arr2 = new Array(len); i < len; i++) {
42
- arr2[i] = arr[i];
43
- }
41
+ for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
44
42
  return arr2;
45
43
  }
46
44
  // 遍历机构树 添加 path属性 (上级机构到子机构的路径)
@@ -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;
@@ -125,9 +127,7 @@ function _unsupportedIterableToArray(o, minLen) {
125
127
  }
126
128
  function _arrayLikeToArray(arr, len) {
127
129
  if (len == null || len > arr.length) len = arr.length;
128
- for (var i = 0, arr2 = new Array(len); i < len; i++) {
129
- arr2[i] = arr[i];
130
- }
130
+ for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
131
131
  return arr2;
132
132
  }
133
133
  function _iterableToArrayLimit(arr, i) {
@@ -152,7 +152,7 @@ function _iterableToArrayLimit(arr, i) {
152
152
  ;
153
153
  !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i);
154
154
  _n = !0
155
- ) {}
155
+ );
156
156
  } catch (err) {
157
157
  (_d = !0), (_e = err);
158
158
  } finally {
@@ -207,6 +207,8 @@ var AssignModal = function AssignModal(props) {
207
207
  title = _props$title === void 0 ? '' : _props$title,
208
208
  onSubmit = props.onSubmit,
209
209
  appList = props.appList,
210
+ userList = props.userList,
211
+ showUser = props.showUser,
210
212
  restProps = _objectWithoutProperties(props, _excluded);
211
213
  var _useState = (0, _react.useState)({}),
212
214
  _useState2 = _slicedToArray(_useState, 2),
@@ -224,7 +226,7 @@ var AssignModal = function AssignModal(props) {
224
226
  className: 'modelTool-assign',
225
227
  title: title,
226
228
  visible: visible,
227
- width: '65%',
229
+ width: showUser ? '80%' : '65%',
228
230
  onCancel: close,
229
231
  onOk: submit,
230
232
  maskClosable: false,
@@ -240,6 +242,7 @@ var AssignModal = function AssignModal(props) {
240
242
  dataItem: dataItem,
241
243
  orgList: orgList,
242
244
  appList: appList,
245
+ userList: userList,
243
246
  onChange: function onChange(data) {
244
247
  setAssignData(data);
245
248
  },
@@ -248,6 +251,7 @@ var AssignModal = function AssignModal(props) {
248
251
  (props === null || props === void 0 ? void 0 : props.lang) ||
249
252
  cookies.get('lang') ||
250
253
  'cn',
254
+ showUser: showUser,
251
255
  },
252
256
  restProps,
253
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.1",
3
+ "version": "1.2.3",
4
4
  "description": "Layout",
5
5
  "author": "zj <jun.zhang002383@tongdun.net>",
6
6
  "license": "ISC",