@tddc/assign-modal 3.1.5 → 3.1.6

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.
Files changed (38) hide show
  1. package/es/index.js +67791 -3
  2. package/es/index.js.LICENSE.txt +45 -0
  3. package/lib/index.js +70897 -0
  4. package/lib/index.js.LICENSE.txt +45 -0
  5. package/package.json +44 -2
  6. package/src/.octopus/ar-EG/index.js +17 -3
  7. package/src/.octopus/en-US/index.js +6 -6
  8. package/src/.octopus/es-ES/index.js +17 -3
  9. package/src/.octopus/ko-KR/index.js +17 -3
  10. package/src/.octopus/th-TH/index.js +17 -3
  11. package/src/.octopus/zh-TW/index.js +19 -0
  12. package/src/I18N.js +3 -0
  13. package/src/locale/en-US.js +5 -0
  14. package/src/locale/es-ES.js +5 -0
  15. package/src/locale/ko-KR.js +5 -0
  16. package/src/locale/th-TH.js +5 -0
  17. package/src/locale/zh-CN.js +5 -0
  18. package/src/locale/zh-TW.js +5 -0
  19. package/es/AssignModal/AssignApp/Edit.js +0 -1504
  20. package/es/AssignModal/AssignApp/Edit_without_TntdVirtualTree.js +0 -1359
  21. package/es/AssignModal/AssignApp/View.js +0 -641
  22. package/es/AssignModal/AssignApp/index.js +0 -9
  23. package/es/AssignModal/AssignApp/index.less +0 -329
  24. package/es/AssignModal/AssignApp/utils.js +0 -241
  25. package/es/AssignModal/index.js +0 -202
  26. package/es/AssignModal/index.less +0 -12
  27. package/es/I18N.js +0 -102
  28. package/es/locale/ar-EG.js +0 -4
  29. package/es/locale/en-US.js +0 -0
  30. package/es/locale/es-ES.js +0 -0
  31. package/es/locale/ko-KR.js +0 -0
  32. package/es/locale/th-TH.js +0 -0
  33. package/es/locale/zh-CN.js +0 -0
  34. package/src/.octopus/ar-EG/test.js +0 -3
  35. package/src/.octopus/en-US/test.js +0 -3
  36. package/src/.octopus/es-ES/test.js +0 -3
  37. package/src/.octopus/ko-KR/test.js +0 -3
  38. package/src/.octopus/th-TH/test.js +0 -3
@@ -1,641 +0,0 @@
1
- import _Input from 'tntd/es/input';
2
- import _Icon from 'tntd/es/icon';
3
- import _Tooltip from 'tntd/es/tooltip';
4
- import _Empty from 'tntd/es/empty';
5
- import _Ellipsis from 'tntd/es/ellipsis';
6
- function _toConsumableArray(r) {
7
- return (
8
- _arrayWithoutHoles(r) ||
9
- _iterableToArray(r) ||
10
- _unsupportedIterableToArray(r) ||
11
- _nonIterableSpread()
12
- );
13
- }
14
- function _nonIterableSpread() {
15
- throw new TypeError(
16
- 'Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.',
17
- );
18
- }
19
- function _iterableToArray(r) {
20
- if (('undefined' != typeof Symbol && null != r[Symbol.iterator]) || null != r['@@iterator'])
21
- return Array.from(r);
22
- }
23
- function _arrayWithoutHoles(r) {
24
- if (Array.isArray(r)) return _arrayLikeToArray(r);
25
- }
26
- function _slicedToArray(r, e) {
27
- return (
28
- _arrayWithHoles(r) ||
29
- _iterableToArrayLimit(r, e) ||
30
- _unsupportedIterableToArray(r, e) ||
31
- _nonIterableRest()
32
- );
33
- }
34
- function _nonIterableRest() {
35
- throw new TypeError(
36
- 'Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.',
37
- );
38
- }
39
- function _unsupportedIterableToArray(r, a) {
40
- if (r) {
41
- if ('string' == typeof r) return _arrayLikeToArray(r, a);
42
- var t = {}.toString.call(r).slice(8, -1);
43
- return (
44
- 'Object' === t && r.constructor && (t = r.constructor.name),
45
- 'Map' === t || 'Set' === t
46
- ? Array.from(r)
47
- : 'Arguments' === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)
48
- ? _arrayLikeToArray(r, a)
49
- : void 0
50
- );
51
- }
52
- }
53
- function _arrayLikeToArray(r, a) {
54
- (null == a || a > r.length) && (a = r.length);
55
- for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
56
- return n;
57
- }
58
- function _iterableToArrayLimit(r, l) {
59
- var t =
60
- null == r ? null : ('undefined' != typeof Symbol && r[Symbol.iterator]) || r['@@iterator'];
61
- if (null != t) {
62
- var e,
63
- n,
64
- i,
65
- u,
66
- a = [],
67
- f = !0,
68
- o = !1;
69
- try {
70
- if (((i = (t = t.call(r)).next), 0 === l)) {
71
- if (Object(t) !== t) return;
72
- f = !1;
73
- } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
74
- } catch (r) {
75
- (o = !0), (n = r);
76
- } finally {
77
- try {
78
- if (!f && null != t.return && ((u = t.return()), Object(u) !== u)) return;
79
- } finally {
80
- if (o) throw n;
81
- }
82
- }
83
- return a;
84
- }
85
- }
86
- function _arrayWithHoles(r) {
87
- if (Array.isArray(r)) return r;
88
- }
89
- import React from 'react';
90
- import { useEffect, useState, useCallback, useRef, useMemo } from 'react';
91
- import { debounce } from 'lodash';
92
- import './index.less';
93
- import { findSameCodePath, preorder } from './utils';
94
- import { getText } from '../../I18N';
95
- var path = []; // 上级机构到当前机构的路径
96
-
97
- var AssignModal = function AssignModal(props) {
98
- var _props$orgList = props.orgList,
99
- orgList = _props$orgList === void 0 ? [] : _props$orgList,
100
- _props$dataItem = props.dataItem,
101
- dataItem = _props$dataItem === void 0 ? {} : _props$dataItem,
102
- appList = props.appList,
103
- orgTitle = props.orgTitle,
104
- appTitle = props.appTitle,
105
- userTitle = props.userTitle,
106
- _props$userList = props.userList,
107
- userList = _props$userList === void 0 ? [] : _props$userList,
108
- showUser = props.showUser,
109
- locale = props.locale;
110
-
111
- // 封装 getText,自动传入 locale
112
- var t = function t(key) {
113
- for (
114
- var _len = arguments.length, params = new Array(_len > 1 ? _len - 1 : 0), _key = 1;
115
- _key < _len;
116
- _key++
117
- ) {
118
- params[_key - 1] = arguments[_key];
119
- }
120
- return getText.apply(
121
- void 0,
122
- [key, props === null || props === void 0 ? void 0 : props.lang, locale].concat(params),
123
- );
124
- };
125
- var _dataItem$appCodes = dataItem.appCodes,
126
- appCodes = _dataItem$appCodes === void 0 ? [] : _dataItem$appCodes,
127
- _dataItem$orgCodes = dataItem.orgCodes,
128
- orgCodes = _dataItem$orgCodes === void 0 ? [] : _dataItem$orgCodes,
129
- orgCode = dataItem.orgCode,
130
- appCode = dataItem.appCode,
131
- accounts = dataItem.accounts,
132
- account = dataItem.account;
133
- var orgMapRef = useRef({});
134
- var appMapRef = useRef({});
135
- var userMapRef = useRef({});
136
- var rootNode = orgList[0];
137
- var _useMemo = useMemo(
138
- function () {
139
- var org = preorder(
140
- rootNode,
141
- function (key, obj) {
142
- orgMapRef.current[key] = obj;
143
- },
144
- true,
145
- );
146
- var app = appList.map(function (item) {
147
- appMapRef.current[item.value] = item;
148
- return item.value;
149
- });
150
- var user =
151
- (userList === null || userList === void 0
152
- ? void 0
153
- : userList.map(function (item) {
154
- userMapRef.current[item.account] = item;
155
- return item.account;
156
- })) || [];
157
- return [org, app, user];
158
- },
159
- [rootNode, appList, userList],
160
- ),
161
- _useMemo2 = _slicedToArray(_useMemo, 3),
162
- allOrg = _useMemo2[0],
163
- allApp = _useMemo2[1],
164
- allUser = _useMemo2[2];
165
- var _useState = useState([]),
166
- _useState2 = _slicedToArray(_useState, 2),
167
- checkedKeys = _useState2[0],
168
- setCheckedKeys = _useState2[1];
169
- var _useState3 = useState(appCodes || []),
170
- _useState4 = _slicedToArray(_useState3, 2),
171
- appKeys = _useState4[0],
172
- setAppKeys = _useState4[1];
173
- var _useState5 = useState(accounts || []),
174
- _useState6 = _slicedToArray(_useState5, 2),
175
- userKeys = _useState6[0],
176
- setUserKeys = _useState6[1];
177
- var _useState7 = useState(),
178
- _useState8 = _slicedToArray(_useState7, 2),
179
- filterOrg = _useState8[0],
180
- setFilterOrg = _useState8[1];
181
- var _useState9 = useState(),
182
- _useState0 = _slicedToArray(_useState9, 2),
183
- filterUser = _useState0[0],
184
- setFilterUser = _useState0[1];
185
- var _useState1 = useState(),
186
- _useState10 = _slicedToArray(_useState1, 2),
187
- filterApp = _useState10[0],
188
- setFilterApp = _useState10[1];
189
- useEffect(
190
- function () {
191
- // path 和 allOrgList 赋值
192
- path = findSameCodePath(rootNode, orgCode);
193
- var initOrgs = [];
194
- var initApps = [];
195
- var initAccounts = [];
196
- if (orgCodes.includes('all')) {
197
- initOrgs = allOrg;
198
- } else {
199
- initOrgs = Array.from(
200
- new Set([].concat(_toConsumableArray(orgCodes || []), _toConsumableArray(path))),
201
- );
202
- }
203
- if (appCodes.includes('all')) {
204
- initApps = allApp;
205
- } else {
206
- initApps = Array.from(new Set([].concat(_toConsumableArray(appCodes || []), [appCode])));
207
- }
208
- if (showUser) {
209
- if (accounts.includes('all')) {
210
- initAccounts = allUser;
211
- } else {
212
- initAccounts = Array.from(
213
- new Set([].concat(_toConsumableArray(accounts || []), [account])),
214
- );
215
- }
216
- }
217
- setCheckedKeys(initOrgs);
218
- setAppKeys(initApps || []);
219
- setUserKeys(initAccounts || []);
220
- },
221
- [dataItem],
222
- );
223
- var debouncedOrgSearch = useCallback(
224
- debounce(function (nextValue) {
225
- setFilterOrg(nextValue);
226
- }, 200),
227
- [],
228
- );
229
- var debouncedUserSearch = useCallback(
230
- debounce(function (nextValue) {
231
- setFilterUser(nextValue);
232
- }, 200),
233
- [],
234
- );
235
- var debouncedAppSearch = useCallback(
236
- debounce(function (nextValue) {
237
- setFilterApp(nextValue);
238
- }, 200),
239
- [],
240
- );
241
- // 获取机构路径的中文显示名并拼接
242
- var getOrgPathDisplayName = function getOrgPathDisplayName() {
243
- var path = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
244
- var displayName = '';
245
- if (path.length > 0) {
246
- displayName = path
247
- .map(function (item) {
248
- return orgMapRef.current[item].name;
249
- })
250
- .join(' / ');
251
- }
252
- return displayName;
253
- };
254
-
255
- // 渲染Org列表
256
- var orgListDomRender = useMemo(
257
- function () {
258
- var renderOrgItem = function renderOrgItem(item, lang) {
259
- console.log(item, 'item');
260
- var mapResult = {
261
- 1: {
262
- cn: '职能部门',
263
- en: 'Func. Dept.',
264
- icon: 'crowd',
265
- },
266
- 2: {
267
- icon: 'corporation',
268
- },
269
- };
270
- var result = mapResult[item === null || item === void 0 ? void 0 : item.orgAttribute] || {};
271
- return /*#__PURE__*/ React.createElement(
272
- 'div',
273
- {
274
- className: 'org-item-wrapper',
275
- style: {
276
- width: '100%',
277
- },
278
- },
279
- /*#__PURE__*/ React.createElement(_Ellipsis, {
280
- title: item.name,
281
- widthLimit: String(item.orgAttribute) === '1' ? 'calc(100% - 90px}' : '100%',
282
- }),
283
- String(item.orgAttribute) === '1' &&
284
- /*#__PURE__*/ React.createElement(
285
- 'span',
286
- {
287
- className: 'org-functional-departemt-marker',
288
- },
289
- result[lang] || '职能部门',
290
- ),
291
- );
292
- };
293
- return (
294
- checkedKeys
295
- .filter(function (i) {
296
- var node = orgMapRef.current[i] || {};
297
- var path = node.path,
298
- name = node.name;
299
- if (!path && !name) return false;
300
- var pathDisplayName = getOrgPathDisplayName(path);
301
- if (filterOrg) {
302
- return (
303
- (pathDisplayName === null || pathDisplayName === void 0
304
- ? void 0
305
- : pathDisplayName
306
- .toLocaleLowerCase()
307
- .includes(
308
- filterOrg === null || filterOrg === void 0
309
- ? void 0
310
- : filterOrg.toLocaleLowerCase(),
311
- )) ||
312
- (name === null || name === void 0
313
- ? void 0
314
- : name
315
- .toLocaleLowerCase()
316
- .includes(
317
- filterOrg === null || filterOrg === void 0
318
- ? void 0
319
- : filterOrg.toLocaleLowerCase(),
320
- ))
321
- );
322
- }
323
- return i;
324
- })
325
- .map(function (item, index) {
326
- var node = orgMapRef.current[item] || {};
327
- var path = node.path,
328
- name = node.name;
329
- var pathDisplayName = getOrgPathDisplayName(path);
330
- if (!path && !name) return null;
331
- return /*#__PURE__*/ React.createElement(
332
- 'li',
333
- {
334
- key: item.value + index,
335
- className: 'select-menu-list-item',
336
- },
337
- /*#__PURE__*/ React.createElement(
338
- 'span',
339
- {
340
- className: 'org-name',
341
- },
342
- /*#__PURE__*/ React.createElement(_Ellipsis, {
343
- title: renderOrgItem(
344
- node,
345
- props === null || props === void 0 ? void 0 : props.lang,
346
- ),
347
- }),
348
- ),
349
- /*#__PURE__*/ React.createElement(
350
- 'span',
351
- {
352
- className: 'path-name',
353
- },
354
- /*#__PURE__*/ React.createElement(_Ellipsis, {
355
- title: pathDisplayName,
356
- }),
357
- ),
358
- );
359
- }) || /*#__PURE__*/ React.createElement(_Empty, null)
360
- );
361
- },
362
- [userList, checkedKeys, filterOrg],
363
- );
364
- // 渲染App列表
365
- var appListDomRender = useMemo(
366
- function () {
367
- return (
368
- appKeys
369
- .filter(function (i) {
370
- var node = appMapRef.current[i] || {};
371
- var label = node.label,
372
- value = node.value;
373
- if (!value && !label) return false;
374
- if (filterApp) {
375
- return (
376
- (label === null || label === void 0
377
- ? void 0
378
- : label
379
- .toLocaleLowerCase()
380
- .includes(
381
- filterApp === null || filterApp === void 0
382
- ? void 0
383
- : filterApp.toLocaleLowerCase(),
384
- )) ||
385
- (value === null || value === void 0
386
- ? void 0
387
- : value
388
- .toLocaleLowerCase()
389
- .includes(
390
- filterApp === null || filterApp === void 0
391
- ? void 0
392
- : filterApp.toLocaleLowerCase(),
393
- ))
394
- );
395
- }
396
- return i;
397
- })
398
- .map(function (item, index) {
399
- var node = appMapRef.current[item] || {};
400
- var value = node.value,
401
- label = node.label;
402
- return /*#__PURE__*/ React.createElement(
403
- 'li',
404
- {
405
- key: value + index,
406
- className: 'select-menu-list-item',
407
- },
408
- /*#__PURE__*/ React.createElement(
409
- _Tooltip,
410
- {
411
- title: label,
412
- key: label + index,
413
- },
414
- /*#__PURE__*/ React.createElement(
415
- 'span',
416
- {
417
- className: 'app-name',
418
- },
419
- label,
420
- ),
421
- ),
422
- );
423
- }) || /*#__PURE__*/ React.createElement(_Empty, null)
424
- );
425
- },
426
- [appList, appKeys, filterApp],
427
- );
428
-
429
- // 渲染User列表
430
- var userListDomRender = useMemo(
431
- function () {
432
- return (
433
- (userKeys === null || userKeys === void 0
434
- ? void 0
435
- : userKeys
436
- .filter(function (item) {
437
- var node = userMapRef.current[item] || {};
438
- var account = node.account,
439
- userName = node.userName;
440
- if (!userName && !node.account) return false;
441
- if (filterUser) {
442
- return (
443
- (account === null || account === void 0
444
- ? void 0
445
- : account
446
- .toLocaleLowerCase()
447
- .includes(
448
- filterUser === null || filterUser === void 0
449
- ? void 0
450
- : filterUser.toLocaleLowerCase(),
451
- )) ||
452
- (userName === null || userName === void 0
453
- ? void 0
454
- : userName
455
- .toLocaleLowerCase()
456
- .includes(
457
- filterUser === null || filterUser === void 0
458
- ? void 0
459
- : filterUser.toLocaleLowerCase(),
460
- ))
461
- );
462
- }
463
- return item;
464
- })
465
- .map(function (item, index) {
466
- var node = userMapRef.current[item] || {};
467
- var userName = node.userName;
468
- return /*#__PURE__*/ React.createElement(
469
- 'li',
470
- {
471
- key: userName + index,
472
- className: 'select-menu-list-item',
473
- },
474
- /*#__PURE__*/ React.createElement(
475
- _Tooltip,
476
- {
477
- title: userName,
478
- key: userName + index,
479
- },
480
- /*#__PURE__*/ React.createElement(
481
- 'span',
482
- {
483
- className: 'user-name',
484
- },
485
- userName,
486
- ),
487
- ),
488
- );
489
- })) || /*#__PURE__*/ React.createElement(_Empty, null)
490
- );
491
- },
492
- [userList, userKeys, filterUser],
493
- );
494
- return /*#__PURE__*/ React.createElement(
495
- React.Fragment,
496
- null,
497
- /*#__PURE__*/ React.createElement(
498
- 'div',
499
- {
500
- className: 'assign-box-container view-mode',
501
- },
502
- /*#__PURE__*/ React.createElement(
503
- 'div',
504
- {
505
- className: 'org-panel panel',
506
- },
507
- /*#__PURE__*/ React.createElement(
508
- 'div',
509
- {
510
- className: 'menu-header',
511
- },
512
- /*#__PURE__*/ React.createElement(
513
- 'span',
514
- {
515
- className: 'title',
516
- },
517
- orgTitle || t('authorizesOrgList'),
518
- ),
519
- ),
520
- /*#__PURE__*/ React.createElement(
521
- 'div',
522
- {
523
- className: 'panel-menu-body',
524
- },
525
- /*#__PURE__*/ React.createElement(
526
- 'ul',
527
- {
528
- className: 'select-menu-list',
529
- },
530
- /*#__PURE__*/ React.createElement(_Input, {
531
- size: 'small',
532
- placeholder: t('search'),
533
- onChange: function onChange(e) {
534
- debouncedOrgSearch(e.target.value);
535
- },
536
- suffix: /*#__PURE__*/ React.createElement(_Icon, {
537
- type: 'zoom',
538
- }),
539
- style: {
540
- marginBottom: 16,
541
- },
542
- }),
543
- orgListDomRender,
544
- ),
545
- ),
546
- ),
547
- /*#__PURE__*/ React.createElement(
548
- 'div',
549
- {
550
- className: 'app-panel panel',
551
- },
552
- /*#__PURE__*/ React.createElement(
553
- 'div',
554
- {
555
- className: 'menu-header',
556
- },
557
- /*#__PURE__*/ React.createElement(
558
- 'span',
559
- {
560
- className: 'title',
561
- },
562
- appTitle || t('authorizesAppList'),
563
- ),
564
- ),
565
- /*#__PURE__*/ React.createElement(
566
- 'div',
567
- {
568
- className: 'panel-menu-body',
569
- },
570
- /*#__PURE__*/ React.createElement(_Input, {
571
- onChange: function onChange(e) {
572
- debouncedAppSearch(e.target.value);
573
- },
574
- placeholder: t('enterAppName'),
575
- size: 'small',
576
- suffix: /*#__PURE__*/ React.createElement(_Icon, {
577
- type: 'zoom',
578
- }),
579
- style: {
580
- marginBottom: 16,
581
- },
582
- }),
583
- /*#__PURE__*/ React.createElement(
584
- 'ul',
585
- {
586
- className: 'select-menu-list',
587
- },
588
- appListDomRender,
589
- ),
590
- ),
591
- ),
592
- !!showUser &&
593
- /*#__PURE__*/ React.createElement(
594
- 'div',
595
- {
596
- className: 'user-panel panel',
597
- },
598
- /*#__PURE__*/ React.createElement(
599
- 'div',
600
- {
601
- className: 'menu-header',
602
- },
603
- /*#__PURE__*/ React.createElement(
604
- 'span',
605
- {
606
- className: 'title',
607
- },
608
- userTitle || t('authorizesUserList'),
609
- ),
610
- ),
611
- /*#__PURE__*/ React.createElement(
612
- 'div',
613
- {
614
- className: 'panel-menu-body',
615
- },
616
- /*#__PURE__*/ React.createElement(_Input, {
617
- size: 'small',
618
- placeholder: t('enterUserName'),
619
- onChange: function onChange(e) {
620
- debouncedUserSearch(e.target.value);
621
- },
622
- suffix: /*#__PURE__*/ React.createElement(_Icon, {
623
- type: 'zoom',
624
- }),
625
- style: {
626
- marginBottom: 16,
627
- },
628
- }),
629
- /*#__PURE__*/ React.createElement(
630
- 'ul',
631
- {
632
- className: 'select-menu-list',
633
- },
634
- userListDomRender,
635
- ),
636
- ),
637
- ),
638
- ),
639
- );
640
- };
641
- export default AssignModal;
@@ -1,9 +0,0 @@
1
- import React from 'react';
2
- import View from './View';
3
- import Edit from './Edit';
4
- var AssignModal = function AssignModal(props) {
5
- return props.disabled
6
- ? /*#__PURE__*/ React.createElement(View, props)
7
- : /*#__PURE__*/ React.createElement(Edit, props);
8
- };
9
- export default AssignModal;