@zgfe/business-lib 1.1.49-dev.0 → 1.1.50-tag.0

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 (100) hide show
  1. package/es/addToPanel/demo/edit.d.ts +1 -2
  2. package/es/addToPanel/demo/index.d.ts +1 -2
  3. package/es/addToPanel/index.js +26 -52
  4. package/es/addToPanel/types.d.ts +2 -2
  5. package/es/addToScene/demo/index.d.ts +1 -2
  6. package/es/assets/demo/input.d.ts +1 -2
  7. package/es/attrConditions/demo/group.d.ts +1 -2
  8. package/es/attrConditions/demo/index.d.ts +1 -2
  9. package/es/attributeSelector/demo/disable.d.ts +1 -2
  10. package/es/attributeSelector/demo/index.d.ts +1 -2
  11. package/es/chart/demo/bar.d.ts +1 -2
  12. package/es/chart/demo/index.d.ts +1 -2
  13. package/es/chart/demo/map.d.ts +1 -2
  14. package/es/chart/demo/pie.d.ts +1 -2
  15. package/es/colorIcon/demo/index.d.ts +1 -2
  16. package/es/constants/apis.d.ts +4 -0
  17. package/es/constants/apis.js +8 -4
  18. package/es/cycleTime/demo/disable.d.ts +1 -2
  19. package/es/cycleTime/demo/index.d.ts +1 -2
  20. package/es/cycleTime/demo/multi.d.ts +1 -2
  21. package/es/datePicker/demo/customType.d.ts +1 -2
  22. package/es/datePicker/demo/day.d.ts +1 -2
  23. package/es/datePicker/demo/index.d.ts +1 -2
  24. package/es/demoWrapper/demo/index.d.ts +1 -2
  25. package/es/dialog/demo/index.d.ts +1 -2
  26. package/es/dnd/demo/data.d.ts +1 -2
  27. package/es/dnd/demo/handle.d.ts +1 -2
  28. package/es/dnd/demo/index.d.ts +1 -2
  29. package/es/eventSelector/demo/index.d.ts +1 -2
  30. package/es/icon/demo/index.d.ts +1 -2
  31. package/es/icon/demo/list.d.ts +1 -2
  32. package/es/index.d.ts +3 -1
  33. package/es/index.js +3 -1
  34. package/es/layout/analysisLayout/demo/index.d.ts +1 -2
  35. package/es/layout/detail/demo/index.d.ts +1 -2
  36. package/es/layout/optionTitle/components/btnMenu/api.d.ts +4 -0
  37. package/es/layout/optionTitle/components/btnMenu/api.js +7 -0
  38. package/es/layout/optionTitle/components/btnMenu/demo.d.ts +2 -0
  39. package/es/layout/optionTitle/components/btnMenu/demo.js +80 -0
  40. package/es/layout/optionTitle/components/btnMenu/index.d.ts +5 -0
  41. package/es/layout/optionTitle/components/btnMenu/index.js +48 -0
  42. package/es/layout/optionTitle/components/btnMenu/index.less +18 -0
  43. package/es/layout/optionTitle/components/title/demo.d.ts +2 -0
  44. package/es/layout/optionTitle/components/title/demo.js +50 -0
  45. package/es/layout/optionTitle/components/title/index.d.ts +5 -0
  46. package/es/layout/optionTitle/components/title/index.js +106 -0
  47. package/es/layout/optionTitle/components/title/index.less +42 -0
  48. package/es/layout/optionTitle/data.d.ts +3 -0
  49. package/es/layout/optionTitle/data.js +77 -0
  50. package/es/layout/optionTitle/demo/index.d.ts +2 -0
  51. package/es/layout/optionTitle/demo/index.js +116 -0
  52. package/es/layout/optionTitle/demo/index.less +12 -0
  53. package/es/layout/optionTitle/demo/layout.d.ts +3 -0
  54. package/es/layout/optionTitle/demo/layout.js +41 -0
  55. package/es/layout/optionTitle/demo/panelCreate.d.ts +2 -0
  56. package/es/layout/optionTitle/demo/panelCreate.js +114 -0
  57. package/es/layout/optionTitle/index.d.ts +6 -0
  58. package/es/layout/optionTitle/index.js +155 -0
  59. package/es/layout/optionTitle/layout.d.ts +5 -0
  60. package/es/layout/optionTitle/layout.js +38 -0
  61. package/es/layout/optionTitle/styles/index.less +19 -0
  62. package/es/layout/optionTitle/styles/layout.less +43 -0
  63. package/es/layout/optionTitle/styles/search.less +27 -0
  64. package/es/layout/optionTitle/types.d.ts +85 -0
  65. package/es/layout/optionTitle/types.js +15 -0
  66. package/es/layout/optionTitle/typesValue.d.ts +4 -0
  67. package/es/layout/optionTitle/typesValue.js +7 -0
  68. package/es/loginForm/demo/index.d.ts +1 -2
  69. package/es/searchInput/demo/index.d.ts +1 -2
  70. package/es/select/demo/children.d.ts +1 -2
  71. package/es/select/demo/customLabel.d.ts +1 -2
  72. package/es/select/demo/group.d.ts +1 -2
  73. package/es/select/demo/index.d.ts +1 -2
  74. package/es/select/demo/loading.d.ts +1 -2
  75. package/es/select/demo/multiple.d.ts +1 -2
  76. package/es/socket/demo/demo.d.ts +1 -2
  77. package/es/table/demo/index.d.ts +1 -2
  78. package/es/table/demo/index2.d.ts +1 -2
  79. package/es/table/demo/index3.d.ts +1 -2
  80. package/es/targetConditionGroup/demo/group.d.ts +1 -2
  81. package/es/targetConditionGroup/demo/index.d.ts +1 -2
  82. package/es/targetSelector/demo/index.d.ts +1 -2
  83. package/es/userCondition/conditions/business/paramsCondition.js +1 -5
  84. package/es/userCondition/conditions/tagsCondition.js +4 -8
  85. package/es/userCondition/demo/business.d.ts +1 -2
  86. package/es/userCondition/demo/index.d.ts +1 -2
  87. package/es/userCondition/demo/index.js +19 -8
  88. package/es/userCondition/demo/mockData.d.ts +8 -1
  89. package/es/userCondition/demo/mockData.js +32 -1
  90. package/es/userGroup/demo/group.d.ts +1 -2
  91. package/es/userGroup/demo/index.d.ts +1 -2
  92. package/es/userTagsSelector/cascaderOverlay.js +168 -84
  93. package/es/userTagsSelector/components/tagList/index.d.ts +13 -0
  94. package/es/userTagsSelector/components/tagList/index.js +65 -0
  95. package/es/userTagsSelector/components/tagList/index.less +13 -0
  96. package/es/userTagsSelector/demo/index.d.ts +1 -2
  97. package/es/userTagsSelector/demo/index.js +45 -43
  98. package/es/userTagsSelector/groups/index.js +3 -7
  99. package/es/userTagsSelector/types.d.ts +37 -0
  100. package/package.json +2 -2
@@ -1,4 +1,4 @@
1
- export var tagList = [{
1
+ export var tagList2 = [{
2
2
  dataStatus: 1,
3
3
  endProcessTime: '2022-09-08T10:00:28',
4
4
  id: 176,
@@ -534,6 +534,37 @@ export var tagList = [{
534
534
  }],
535
535
  startProcessTime: '2022-09-06T21:08:28'
536
536
  }];
537
+ export var tagList = [{
538
+ id: 1000,
539
+ labelGroup: '基本标签',
540
+ sequence: 1,
541
+ labelNum: 30,
542
+ children: []
543
+ }, {
544
+ id: 1001,
545
+ labelGroup: '活跃标签',
546
+ sequence: 2,
547
+ labelNum: 70,
548
+ children: []
549
+ }, {
550
+ id: 1002,
551
+ labelGroup: '行为标签',
552
+ sequence: 3,
553
+ labelNum: 1230,
554
+ children: []
555
+ }, {
556
+ id: 1003,
557
+ labelGroup: '预测标签',
558
+ sequence: 4,
559
+ labelNum: 3,
560
+ children: []
561
+ }, {
562
+ id: 1004,
563
+ labelGroup: '其他标签',
564
+ sequence: 5,
565
+ labelNum: 0,
566
+ children: []
567
+ }];
537
568
  export var conditions = [[{
538
569
  dataset: [{
539
570
  datasetId: 174,
@@ -1,3 +1,2 @@
1
- import React from 'react';
2
- declare const _default: () => React.JSX.Element;
1
+ declare const _default: () => JSX.Element;
3
2
  export default _default;
@@ -1,3 +1,2 @@
1
- import React from 'react';
2
- declare const _default: () => React.JSX.Element;
1
+ declare const _default: () => JSX.Element;
3
2
  export default _default;
@@ -1,10 +1,10 @@
1
1
  function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
2
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
3
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
4
2
  function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
5
3
  function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
6
4
  function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
7
5
  function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
6
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
7
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
8
8
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
9
9
  function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
10
10
  function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
@@ -14,15 +14,21 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
14
14
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
15
15
  function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
16
16
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
17
- import React, { useRef } from 'react';
17
+ import React, { useContext, useEffect, useMemo, useRef } from 'react';
18
18
  import { useState } from 'react';
19
19
  import { classPrefix } from '.';
20
20
  import './styles/cascaderOverlay.less';
21
21
  import Groups from './groups/index';
22
22
  import MultipleCheckPanel from './multipleCheckPanel';
23
- import { filterFactory, getFieldFactory } from './util';
24
23
  import _ from 'lodash';
25
24
  import Search from './components/search';
25
+ import TagListScroll from './components/tagList';
26
+ import { BizGlobalDataContext, ajax } from '..';
27
+ import apis from '../constants/apis';
28
+ import { Spin } from 'antd';
29
+ import Request from 'umi-request';
30
+ var CancelToken = Request.CancelToken;
31
+ var cancel;
26
32
  var CascaderOverlay = function CascaderOverlay(props) {
27
33
  var currentValue = props.currentValue,
28
34
  labelFields = props.labelFields,
@@ -30,92 +36,168 @@ var CascaderOverlay = function CascaderOverlay(props) {
30
36
  valueFields = props.valueFields,
31
37
  childFields = props.childFields;
32
38
  var timer = useRef(null);
33
- var _useState = useState(props.data || []),
39
+ var _useState = useState(''),
34
40
  _useState2 = _slicedToArray(_useState, 2),
35
- data = _useState2[0],
36
- setData = _useState2[1];
37
- var _useState3 = useState(initPath(data)),
41
+ highlightText = _useState2[0],
42
+ setHighlightText = _useState2[1];
43
+ var _useState3 = useState([]),
38
44
  _useState4 = _slicedToArray(_useState3, 2),
39
- currentPath = _useState4[0],
40
- setCurrentPath = _useState4[1];
41
- var _useState5 = useState(''),
45
+ groupList = _useState4[0],
46
+ setGroupList = _useState4[1];
47
+ var _useState5 = useState(),
42
48
  _useState6 = _slicedToArray(_useState5, 2),
43
- highlightText = _useState6[0],
44
- setHighlightText = _useState6[1];
45
- function initPath(data) {
46
- return function () {
47
- var path = [];
48
- var curr = data[0];
49
- var getChildField = getFieldFactory(childFields);
50
- while (curr) {
51
- path.push(curr);
52
- var childField = getChildField();
53
- if (_.isArray(curr[childField])) {
54
- curr = curr[childField].length ? curr[childField][0] : null;
55
- } else {
56
- curr = curr[childField];
57
- }
49
+ currentSelect = _useState6[0],
50
+ setCurrentSelect = _useState6[1];
51
+ var _useState7 = useState(),
52
+ _useState8 = _slicedToArray(_useState7, 2),
53
+ currentTag = _useState8[0],
54
+ setCurrentTag = _useState8[1];
55
+ var _useState9 = useState(false),
56
+ _useState10 = _slicedToArray(_useState9, 2),
57
+ loading = _useState10[0],
58
+ setLoading = _useState10[1];
59
+ var _useState11 = useState(true),
60
+ _useState12 = _slicedToArray(_useState11, 2),
61
+ isInit = _useState12[0],
62
+ setIsInit = _useState12[1];
63
+ var _useContext = useContext(BizGlobalDataContext),
64
+ currentApp = _useContext.currentApp;
65
+ var groupMap = useMemo(function () {
66
+ var data = {};
67
+ groupList.forEach(function (item) {
68
+ data[item.labelGroup] = _objectSpread({}, item);
69
+ });
70
+ return data;
71
+ }, [groupList]);
72
+ useEffect(function () {
73
+ if (props.data && props.data.length) {
74
+ setCurrentSelect(props.data[0].labelGroup);
75
+ setGroupList(props.data.map(function (item) {
76
+ return _objectSpread(_objectSpread({}, item), {}, {
77
+ children: []
78
+ });
79
+ }) || []);
80
+ } else {
81
+ getTagGroup();
82
+ }
83
+ }, []);
84
+ useEffect(function () {
85
+ if (!currentSelect) return;
86
+ setCurrentTag(undefined);
87
+ var currentGroup = groupList.filter(function (item) {
88
+ return item.labelGroup === currentSelect;
89
+ });
90
+ if (!currentGroup.length || currentGroup[0].labelNum === 0) return;
91
+ if (currentGroup[0].children.length > 0) {
92
+ setCurrentTag(currentGroup[0].children[0]);
93
+ return;
94
+ }
95
+ getTagsByGroup();
96
+ }, [currentSelect]);
97
+ useEffect(function () {
98
+ if (isInit) {
99
+ setIsInit(false);
100
+ return;
101
+ }
102
+ timer.current && clearTimeout(timer.current);
103
+ timer.current = setTimeout(function () {
104
+ getTagGroup();
105
+ }, 300);
106
+ }, [highlightText]);
107
+ function getTagGroup() {
108
+ setLoading(true);
109
+ if (typeof cancel === 'function') {
110
+ cancel();
111
+ }
112
+ ajax(apis.queryTagGroups, {
113
+ method: 'post',
114
+ data: {
115
+ appId: currentApp === null || currentApp === void 0 ? void 0 : currentApp.appId,
116
+ platform: (currentApp === null || currentApp === void 0 ? void 0 : currentApp.platform) || 0,
117
+ labelName: highlightText
118
+ },
119
+ cancelToken: new CancelToken(function executor(c) {
120
+ cancel = c;
121
+ })
122
+ }).then(function (res) {
123
+ setLoading(false);
124
+ var list = (res === null || res === void 0 ? void 0 : res.data) || [];
125
+ if (list.length) {
126
+ setGroupList(function () {
127
+ return list.map(function (item) {
128
+ return _objectSpread(_objectSpread({}, item), {}, {
129
+ labelNum: item.labelNum || 0,
130
+ children: []
131
+ });
132
+ });
133
+ });
134
+ getTagsByGroup();
58
135
  }
59
- path.pop();
60
- return path;
61
- };
136
+ }).catch(function (e) {
137
+ setLoading(false);
138
+ console.error(e);
139
+ });
62
140
  }
63
- function onActive(data, level) {
64
- var currIndex = level;
65
- var getChildField = getFieldFactory(childFields.slice(currIndex).length ? childFields.slice(currIndex) : childFields.slice(-1));
66
- var curr = data;
67
- var newPath = currentPath.slice(0, level + 1);
68
- while (curr) {
69
- newPath[currIndex] = curr;
70
- var childField = getChildField();
71
- if (_.isArray(curr[childField])) {
72
- curr = curr[childField].length ? curr[childField][0] : null;
73
- } else {
74
- curr = curr[childField];
141
+ function getTagsByGroup() {
142
+ var pageNo = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;
143
+ if (!currentSelect) return;
144
+ setCurrentTag(undefined);
145
+ ajax(apis.queryTagsByGroup, {
146
+ method: 'post',
147
+ data: {
148
+ appId: currentApp === null || currentApp === void 0 ? void 0 : currentApp.appId,
149
+ platform: (currentApp === null || currentApp === void 0 ? void 0 : currentApp.platform) || 0,
150
+ labelGroup: currentSelect,
151
+ pageNo: pageNo,
152
+ pageSize: 10,
153
+ labelName: highlightText
75
154
  }
76
- currIndex++;
77
- }
78
- newPath.pop();
79
- setCurrentPath(newPath);
155
+ }).then(function (res) {
156
+ if ((res === null || res === void 0 ? void 0 : res.data) && res.data.results) {
157
+ var result = res.data.results;
158
+ setGroupList(function (group) {
159
+ return group.map(function (item) {
160
+ if (item.labelGroup === currentSelect) {
161
+ item.children = pageNo === 1 ? _toConsumableArray(result) : item.children.concat(result);
162
+ }
163
+ return _objectSpread({}, item);
164
+ });
165
+ });
166
+ if (pageNo === 1) {
167
+ setCurrentTag(result[0]);
168
+ }
169
+ }
170
+ });
80
171
  }
81
172
  function onCheck(data) {
82
- var getVabelField = getFieldFactory(valueFields);
83
- var getLabelField = getFieldFactory(labelFields);
84
- var newValue = currentPath.map(function (item) {
85
- var _ref;
86
- var labelField = getLabelField();
87
- var valueField = getVabelField();
88
- return _ref = {}, _defineProperty(_ref, labelField, item[labelField]), _defineProperty(_ref, valueField, item[valueField]), _ref;
89
- }).concat(data);
173
+ var newValue = [{
174
+ id: groupMap[currentSelect].id,
175
+ labelGroup: currentSelect
176
+ }, {
177
+ id: currentTag === null || currentTag === void 0 ? void 0 : currentTag.id,
178
+ labelName: currentTag === null || currentTag === void 0 ? void 0 : currentTag.labelName
179
+ }, _objectSpread({}, data)];
90
180
  props.onChange([].concat(_toConsumableArray(currentValue), [newValue]));
91
181
  }
92
182
  function onUncheck(data) {
93
183
  var index = currentValue.findIndex(function (item) {
94
- return _.isEqual(item.slice().pop(), data);
184
+ return _.isEqual(item[2].layerLabelId, data.layerLabelId);
95
185
  });
96
186
  var newValues = currentValue.slice();
97
187
  newValues.splice(index, 1);
98
188
  props.onChange(newValues);
99
189
  }
100
190
  function onSearch(val) {
101
- timer.current && clearTimeout(timer.current);
102
- timer.current = setTimeout(function () {
103
- var _labelFields$, _props$data;
104
- var res = [];
105
- var filter = filterFactory((_labelFields$ = labelFields[1]) !== null && _labelFields$ !== void 0 ? _labelFields$ : labelFields[0], val);
106
- (_props$data = props.data) === null || _props$data === void 0 ? void 0 : _props$data.forEach(function (item) {
107
- var searchList = item[childFields[0]].filter(filter);
108
- if (searchList.length) {
109
- res.push(_objectSpread(_objectSpread({}, item), {}, _defineProperty({}, childFields[0], item[childFields[0]].filter(filter))));
110
- }
111
- });
112
- setData(res);
113
- setCurrentPath(initPath(res));
114
- setHighlightText(val);
115
- }, 300);
191
+ setHighlightText(val);
192
+ }
193
+ function onClickGroup(data) {
194
+ setCurrentSelect(data.labelGroup);
195
+ }
196
+ function onClickTag(data) {
197
+ setCurrentTag(data);
116
198
  }
117
199
  function render() {
118
- if (!data.length) return /*#__PURE__*/React.createElement("div", {
200
+ if (!groupList.length) return /*#__PURE__*/React.createElement("div", {
119
201
  style: {
120
202
  padding: 8,
121
203
  width: 596
@@ -130,21 +212,21 @@ var CascaderOverlay = function CascaderOverlay(props) {
130
212
  keyField: keyFields[0],
131
213
  childField: childFields[0],
132
214
  labelField: labelFields[0],
133
- data: data,
134
- onActive: onActive,
215
+ data: groupList,
216
+ onActive: onClickGroup,
135
217
  level: 0
136
218
  })), /*#__PURE__*/React.createElement("div", {
137
219
  className: "".concat(classPrefix, "-overlay-groups")
138
- }, /*#__PURE__*/React.createElement(Groups, {
220
+ }, /*#__PURE__*/React.createElement(TagListScroll, {
221
+ parentId: groupMap[currentSelect].id,
222
+ value: currentSelect ? groupMap[currentSelect].children : [],
223
+ total: currentSelect ? groupMap[currentSelect].labelNum || 0 : 0,
139
224
  currentValue: currentValue,
140
- valueField: valueFields[1],
141
- keyField: keyFields[1],
142
- childField: childFields[1],
143
- labelField: labelFields[1],
144
- data: currentPath[0] ? currentPath[0][childFields[0]] : [],
145
- onActive: onActive,
146
- highlightText: highlightText,
147
- level: 1
225
+ searchValue: highlightText,
226
+ onLoadMore: function onLoadMore() {
227
+ return getTagsByGroup(Math.floor(groupMap[currentSelect].children.length / 10) + 1);
228
+ },
229
+ onClick: onClickTag
148
230
  })), /*#__PURE__*/React.createElement("div", {
149
231
  className: "".concat(classPrefix, "-overlay-selections")
150
232
  }, /*#__PURE__*/React.createElement(MultipleCheckPanel, {
@@ -154,7 +236,7 @@ var CascaderOverlay = function CascaderOverlay(props) {
154
236
  currentValue: currentValue,
155
237
  level: 2,
156
238
  labelField: labelFields[2],
157
- data: currentPath[1] ? currentPath[1][childFields[1]] : []
239
+ data: (currentTag === null || currentTag === void 0 ? void 0 : currentTag.layers) || []
158
240
  })));
159
241
  }
160
242
  return /*#__PURE__*/React.createElement("div", {
@@ -165,8 +247,10 @@ var CascaderOverlay = function CascaderOverlay(props) {
165
247
  show: true,
166
248
  onChange: onSearch,
167
249
  placeholder: "\u641C\u7D22\u6807\u7B7E\u540D\u79F0"
168
- })), /*#__PURE__*/React.createElement("div", {
250
+ })), /*#__PURE__*/React.createElement(Spin, {
251
+ spinning: loading
252
+ }, /*#__PURE__*/React.createElement("div", {
169
253
  className: "".concat(classPrefix, "-overlay-panel")
170
- }, render()));
254
+ }, render())));
171
255
  };
172
256
  export default CascaderOverlay;
@@ -0,0 +1,13 @@
1
+ import React from 'react';
2
+ import { UserTagsSelectorTypes } from '../../types';
3
+ import './index.less';
4
+ declare const TagListScroll: React.FC<{
5
+ value: UserTagsSelectorTypes.TagValue[];
6
+ total: number;
7
+ parentId?: number;
8
+ searchValue?: string;
9
+ currentValue: UserTagsSelectorTypes.GroupValue[];
10
+ onClick?: (tag: any) => void;
11
+ onLoadMore: () => void;
12
+ }>;
13
+ export default TagListScroll;
@@ -0,0 +1,65 @@
1
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
2
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
3
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
4
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
5
+ function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
6
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
7
+ import { Spin } from 'antd';
8
+ import React, { useEffect, useMemo, useState } from 'react';
9
+ import InfiniteScroll from 'react-infinite-scroll-component';
10
+ import { classPrefix } from '../..';
11
+ import GroupOption from '../../groups/groupOption';
12
+ import { isCheckedFactory } from '../../util';
13
+ import './index.less';
14
+ var TagListScroll = function TagListScroll(props) {
15
+ var value = props.value,
16
+ currentValue = props.currentValue,
17
+ onLoadMore = props.onLoadMore;
18
+ var _useState = useState(null),
19
+ _useState2 = _slicedToArray(_useState, 2),
20
+ active = _useState2[0],
21
+ setActive = _useState2[1];
22
+ useEffect(function () {
23
+ setActive(null);
24
+ }, [props.parentId]);
25
+ var isChecked = useMemo(function () {
26
+ return isCheckedFactory(currentValue, 1);
27
+ }, [currentValue]);
28
+ function _onClick(data) {
29
+ setActive(data.id);
30
+ props.onClick && props.onClick(data);
31
+ }
32
+ if (!props.total) {
33
+ return /*#__PURE__*/React.createElement("span", null, "\u6682\u65E0\u6570\u636E");
34
+ }
35
+ return /*#__PURE__*/React.createElement("div", {
36
+ id: "tagListContainer",
37
+ className: "".concat(classPrefix, "-list-container")
38
+ }, /*#__PURE__*/React.createElement(InfiniteScroll, {
39
+ dataLength: props.total,
40
+ hasMore: value.length < props.total,
41
+ loader: /*#__PURE__*/React.createElement("div", {
42
+ className: "".concat(classPrefix, "-list-container-loading")
43
+ }, /*#__PURE__*/React.createElement(Spin, null)),
44
+ next: onLoadMore,
45
+ scrollableTarget: "tagListContainer",
46
+ key: Math.random()
47
+ }, value.map(function (item, index) {
48
+ return /*#__PURE__*/React.createElement(GroupOption, {
49
+ key: item.id,
50
+ onClick: function onClick() {
51
+ return _onClick(item);
52
+ },
53
+ actived: active ? item.id === active : index === 0,
54
+ checked: isChecked(item, 'id'),
55
+ count: item.layers.length,
56
+ label: item.labelName,
57
+ value: item.id,
58
+ highlightText: props.searchValue || ''
59
+ });
60
+ })));
61
+ };
62
+ TagListScroll.defaultProps = {
63
+ value: []
64
+ };
65
+ export default TagListScroll;
@@ -0,0 +1,13 @@
1
+ @import '../../../assets/styles/variable.less';
2
+ .biz-user-tags-selector {
3
+ &-list-container {
4
+ max-height: 360px;
5
+ overflow: auto;
6
+ }
7
+ &-list-container-loading {
8
+ display: flex;
9
+ align-items: center;
10
+ justify-content: center;
11
+ height: 40px;
12
+ }
13
+ }
@@ -1,3 +1,2 @@
1
- import React from 'react';
2
- declare const _default: () => React.JSX.Element;
1
+ declare const _default: () => JSX.Element;
3
2
  export default _default;
@@ -1,52 +1,54 @@
1
- import React from 'react';
1
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
2
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
3
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
4
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
5
+ function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
6
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
7
+ import React, { useEffect, useState } from 'react';
2
8
  import { BizUserTagsSelect } from '@zgfe/business-lib';
3
- var data = [{
4
- labelGroup: '基本标签',
5
- children: []
6
- }, {
7
- labelGroup: '行为标签',
8
- children: []
9
- }, {
10
- labelGroup: '活跃标签',
11
- children: []
12
- }, {
13
- labelGroup: '预测标签',
14
- children: []
15
- }, {
16
- labelGroup: '其它标签',
17
- children: []
18
- }];
19
- var defaultValue = [];
20
- data.forEach(function (item) {
21
- item.children = Array(100 * Math.random() >> 0).fill(1).map(function (_child, _index) {
22
- var id = Math.random();
23
- var tag = {
24
- id: id,
25
- labelName: '标签' + id + id + id + id,
26
- layers: Array(5 * Math.random() >> 0).fill(1).map(function (_item, i) {
27
- var layer = {
28
- layerLabelId: Math.random(),
29
- layerLabelName: '分层' + i
30
- };
31
- return layer;
32
- })
33
- };
34
- if (id < 0.6 && defaultValue.length < 20) {
35
- defaultValue.push([item.labelGroup, tag]);
36
- }
37
- return tag;
38
- });
39
- });
9
+ import { DemoWrapper } from '@zgfe/business-lib';
10
+ import { ajax } from '../../utils';
11
+ import apis from '../../constants/apis';
40
12
  export default (function () {
13
+ var appId = 9;
14
+ var _useState = useState([]),
15
+ _useState2 = _slicedToArray(_useState, 2),
16
+ groupList = _useState2[0],
17
+ setGroupList = _useState2[1];
41
18
  function onChange(data) {
42
19
  console.log(data);
43
20
  }
44
- return /*#__PURE__*/React.createElement(BizUserTagsSelect, {
21
+ useEffect(function () {
22
+ getTagGroup();
23
+ }, []);
24
+ function getTagGroup() {
25
+ ajax(apis.queryTagGroups, {
26
+ method: 'post',
27
+ data: {
28
+ appId: appId,
29
+ platform: 0
30
+ }
31
+ }).then(function (res) {
32
+ var list = (res === null || res === void 0 ? void 0 : res.data) || [];
33
+ setGroupList(list);
34
+ }).catch(function (e) {
35
+ console.error(e);
36
+ });
37
+ }
38
+ return /*#__PURE__*/React.createElement(DemoWrapper, {
39
+ needMeta: true,
40
+ defaultApp: appId
41
+ }, /*#__PURE__*/React.createElement("div", {
42
+ style: {
43
+ background: '#fff',
44
+ padding: 40
45
+ }
46
+ }, /*#__PURE__*/React.createElement(BizUserTagsSelect, {
47
+ data: groupList,
45
48
  childFields: ['children', 'layers'],
46
- data: data,
47
- keyFields: ['labelGroup', 'id', 'id'],
49
+ keyFields: ['labelGroup', 'id', 'layerLabelId'],
48
50
  labelFields: ['labelGroup', 'labelName', 'layerLabelName'],
49
- valueFields: ['labelGroup', 'labelName', 'layerLabelId'],
51
+ valueFields: ['labelGroup', 'id', 'layerLabelId'],
50
52
  onChange: onChange
51
- });
53
+ })));
52
54
  });
@@ -4,7 +4,7 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
4
4
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
5
5
  function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
6
6
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
7
- import React, { useEffect, useMemo } from 'react';
7
+ import React, { useMemo } from 'react';
8
8
  import VirtualList from 'rc-virtual-list';
9
9
  import { classPrefix } from '../';
10
10
  import GroupOption from './groupOption';
@@ -14,7 +14,6 @@ import { filterFactory, isCheckedFactory } from '../util';
14
14
  var Groups = function Groups(props) {
15
15
  var data = props.data,
16
16
  labelField = props.labelField,
17
- childField = props.childField,
18
17
  keyField = props.keyField,
19
18
  valueField = props.valueField,
20
19
  searchable = props.searchable,
@@ -34,9 +33,6 @@ var Groups = function Groups(props) {
34
33
  var isChecked = useMemo(function () {
35
34
  return isCheckedFactory(currentValue, level);
36
35
  }, [currentValue, level]);
37
- useEffect(function () {
38
- if (data.length) setActive(data[0][valueField]);
39
- }, [data]);
40
36
  function _onClick(i) {
41
37
  setActive(data[i][valueField]);
42
38
  props.onActive(data[i], level);
@@ -61,9 +57,9 @@ var Groups = function Groups(props) {
61
57
  onClick: function onClick() {
62
58
  return _onClick(index);
63
59
  },
64
- actived: item[valueField] === active,
60
+ actived: active ? item[valueField] === active : index === 0,
65
61
  checked: isChecked(item, valueField),
66
- count: item[childField].length,
62
+ count: item.labelNum,
67
63
  label: item[labelField],
68
64
  value: item[valueField],
69
65
  highlightText: (_props$highlightText = props.highlightText) !== null && _props$highlightText !== void 0 ? _props$highlightText : searchValue