@zgfe/modules-whole 1.0.10-zhongyuan.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 (97) hide show
  1. package/README.md +37 -0
  2. package/es/components/dataUpdateTime/index.d.ts +3 -0
  3. package/es/components/dataUpdateTime/index.js +53 -0
  4. package/es/components/eventFilter/index.d.ts +5 -0
  5. package/es/components/eventFilter/index.js +263 -0
  6. package/es/components/eventFilter/styles/index.less +36 -0
  7. package/es/components/eventFilter/types.d.ts +20 -0
  8. package/es/components/eventFilter/types.js +1 -0
  9. package/es/components/index.d.ts +4 -0
  10. package/es/components/index.js +4 -0
  11. package/es/components/renderContent/index.d.ts +5 -0
  12. package/es/components/renderContent/index.js +44 -0
  13. package/es/components/renderContent/styles/index.less +20 -0
  14. package/es/components/renderContent/types.d.ts +9 -0
  15. package/es/components/renderContent/types.js +1 -0
  16. package/es/components/searchPanel/index.d.ts +5 -0
  17. package/es/components/searchPanel/index.js +164 -0
  18. package/es/components/searchPanel/styles/index.less +22 -0
  19. package/es/components/searchPanel/types.d.ts +23 -0
  20. package/es/components/searchPanel/types.js +1 -0
  21. package/es/components/table/index.d.ts +5 -0
  22. package/es/components/table/index.js +130 -0
  23. package/es/components/table/styles/index.less +193 -0
  24. package/es/components/table/types.d.ts +9 -0
  25. package/es/components/table/types.js +1 -0
  26. package/es/components/topBar/index.d.ts +5 -0
  27. package/es/components/topBar/index.js +163 -0
  28. package/es/components/topBar/styles/index.less +71 -0
  29. package/es/components/topBar/types.d.ts +8 -0
  30. package/es/components/topBar/types.js +1 -0
  31. package/es/constants/apis.d.ts +8 -0
  32. package/es/constants/apis.js +8 -0
  33. package/es/constants/chart.d.ts +2 -0
  34. package/es/constants/chart.js +31 -0
  35. package/es/constants/color.d.ts +1 -0
  36. package/es/constants/color.js +1 -0
  37. package/es/constants/fields.d.ts +271 -0
  38. package/es/constants/fields.js +260 -0
  39. package/es/constants/index.d.ts +6 -0
  40. package/es/constants/index.js +6 -0
  41. package/es/constants/initData.d.ts +2 -0
  42. package/es/constants/initData.js +9 -0
  43. package/es/constants/json/line.d.ts +20 -0
  44. package/es/constants/json/line.js +25 -0
  45. package/es/index.d.ts +5 -0
  46. package/es/index.js +4 -0
  47. package/es/modules/chart/demo/data.d.ts +78 -0
  48. package/es/modules/chart/demo/data.js +489 -0
  49. package/es/modules/chart/demo/index.d.ts +3 -0
  50. package/es/modules/chart/demo/index.js +12 -0
  51. package/es/modules/chart/demo/panel.d.ts +3 -0
  52. package/es/modules/chart/demo/panel.js +11 -0
  53. package/es/modules/chart/index.d.ts +4 -0
  54. package/es/modules/chart/index.js +246 -0
  55. package/es/modules/chart/types.d.ts +15 -0
  56. package/es/modules/chart/types.js +1 -0
  57. package/es/modules/content/index.d.ts +5 -0
  58. package/es/modules/content/index.js +234 -0
  59. package/es/modules/content/styles/index.less +7 -0
  60. package/es/modules/content/types.d.ts +11 -0
  61. package/es/modules/content/types.js +1 -0
  62. package/es/modules/content/utils.d.ts +17 -0
  63. package/es/modules/content/utils.js +107 -0
  64. package/es/modules/home/demo/create.d.ts +3 -0
  65. package/es/modules/home/demo/create.js +58 -0
  66. package/es/modules/home/demo/edit.d.ts +3 -0
  67. package/es/modules/home/demo/edit.js +86 -0
  68. package/es/modules/home/demo/index.d.ts +4 -0
  69. package/es/modules/home/demo/index.js +83 -0
  70. package/es/modules/home/demo/scene.d.ts +3 -0
  71. package/es/modules/home/demo/scene.js +89 -0
  72. package/es/modules/home/demo/styles/index.less +33 -0
  73. package/es/modules/home/index.d.ts +5 -0
  74. package/es/modules/home/index.js +218 -0
  75. package/es/modules/home/styles/index.less +39 -0
  76. package/es/modules/home/types.d.ts +34 -0
  77. package/es/modules/home/types.js +1 -0
  78. package/es/modules/topPanel/index.d.ts +5 -0
  79. package/es/modules/topPanel/index.js +154 -0
  80. package/es/modules/topPanel/styles/index.less +41 -0
  81. package/es/modules/topPanel/types.d.ts +39 -0
  82. package/es/modules/topPanel/types.js +1 -0
  83. package/es/style/image/ring.svg +9 -0
  84. package/es/style/index.less +62 -0
  85. package/es/style/theme.d.ts +15 -0
  86. package/es/style/theme.js +14 -0
  87. package/es/types.d.ts +79 -0
  88. package/es/types.js +6 -0
  89. package/es/utils/ajaxConfig.d.ts +8 -0
  90. package/es/utils/ajaxConfig.js +12 -0
  91. package/es/utils/base64.d.ts +23 -0
  92. package/es/utils/base64.js +125 -0
  93. package/es/utils/formData.d.ts +21 -0
  94. package/es/utils/formData.js +366 -0
  95. package/es/utils/util.d.ts +36 -0
  96. package/es/utils/util.js +167 -0
  97. package/package.json +63 -0
@@ -0,0 +1,366 @@
1
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
2
+ 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."); }
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 _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
5
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
6
+ 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; }
7
+ import { util, IconFont } from '@zgfe/business-lib';
8
+ import React from 'react';
9
+ import _ from 'lodash';
10
+ import { chartColors } from '../constants/color';
11
+ import { PropCategory } from '@zgfe/business-lib/es/attributeSelector/types';
12
+ import { Tooltip } from 'antd';
13
+ import '../style/index.less';
14
+ import { getValue } from '../modules/content/utils';
15
+ import moment from 'moment';
16
+ var classPrefix = 'event-form-data';
17
+ export function getColumns(eventGroupList, userPropList, eventEnvList, columnData, userGroup, searchData, showList, onShowCallback, onClickToDetailCallback) {
18
+ var data = [{
19
+ title: '显示',
20
+ width: 80,
21
+ dataIndex: 'nameGroup',
22
+ ellipsis: true,
23
+ key: 'nameGroup',
24
+ align: 'center',
25
+ className: "".concat(classPrefix, "-table-td"),
26
+ fixed: 'left',
27
+ render: function render(_, record) {
28
+ var isActive = showList.includes(record.nameGroup);
29
+ var cannotClick = showList.length >= 10 && !isActive;
30
+ return /*#__PURE__*/React.createElement("div", {
31
+ className: "".concat(classPrefix, "-table-td-show"),
32
+ onClick: function onClick() {
33
+ if (cannotClick) return;
34
+ onShowCallback(record.nameGroup);
35
+ }
36
+ }, /*#__PURE__*/React.createElement("span", {
37
+ style: {
38
+ background: isActive ? record.color : '#D9D9D9'
39
+ }
40
+ }));
41
+ }
42
+ }];
43
+ if (userGroup.length > 1 || userGroup[0] !== 0) {
44
+ data.push({
45
+ title: '用户群',
46
+ width: 150,
47
+ dataIndex: 'userGroup',
48
+ key: 'userGroup',
49
+ ellipsis: true,
50
+ fixed: 'left',
51
+ render: function render(text) {
52
+ return text;
53
+ }
54
+ });
55
+ }
56
+ if (searchData.dimension) {
57
+ var _getValue;
58
+ data.push({
59
+ title: (_getValue = getValue(searchData.dimension, eventGroupList, eventEnvList, userPropList)) === null || _getValue === void 0 ? void 0 : _getValue.label,
60
+ width: 150,
61
+ dataIndex: 'dimension',
62
+ key: 'dimension',
63
+ ellipsis: true,
64
+ fixed: 'left',
65
+ render: function render(val) {
66
+ return /*#__PURE__*/React.createElement("div", {
67
+ className: "tooltip-name-box"
68
+ }, /*#__PURE__*/React.createElement(Tooltip, {
69
+ title: val
70
+ }, /*#__PURE__*/React.createElement("div", {
71
+ className: "tooltip-name-box-market"
72
+ }, val)));
73
+ }
74
+ });
75
+ }
76
+ if (searchData.id && !searchData.dimension || !searchData.id) {
77
+ data.push({
78
+ title: '指标',
79
+ width: 180,
80
+ dataIndex: 'eventName',
81
+ key: 'eventName',
82
+ ellipsis: true,
83
+ fixed: 'left',
84
+ render: function render(val) {
85
+ return /*#__PURE__*/React.createElement("div", {
86
+ className: "tooltip-name-box"
87
+ }, util.strMiddleSplit(val));
88
+ }
89
+ });
90
+ }
91
+ var _loop = function _loop(i) {
92
+ var value = columnData[i];
93
+ if (/^\d{4}-\d{2}-\d{2}$/.test(value)) {
94
+ value = value.replace(/\d{4}-/, '');
95
+ } else if (/^\d{4}-\d{2}-\d{2}\|\d{4}-\d{2}-\d{2}$/.test(value)) {
96
+ var dates = value.match(/\d{4}-\d{2}-\d{2}/g);
97
+ value = dates ? dates[0].replace(/\d{4}-/, '') + '~' + dates[1].replace(/\d{4}-/, '') : value;
98
+ } else {
99
+ value = util.strMiddleSplit(value);
100
+ if (/:/.test(value)) {
101
+ value = value.replace(/\d{4}-\d{2}-\d{2}\s/, '');
102
+ } else if (/,/.test(value)) {
103
+ value = value.replace(/,/g, '-');
104
+ }
105
+ }
106
+ data.push({
107
+ title: value,
108
+ align: 'center',
109
+ ellipsis: true,
110
+ defaultSortOrder: i === columnData.length - 1 ? 'descend' : null,
111
+ dataIndex: "field".concat(i),
112
+ className: "".concat(classPrefix, "-table-whole-data"),
113
+ sorter: function sorter(a, b) {
114
+ return a["field".concat(i)] - b["field".concat(i)];
115
+ },
116
+ render: function render(text, record) {
117
+ var _text = text;
118
+ var click = _text > 0;
119
+ if (searchData.module == 'duration' && record.eventName !== '活跃用户') {
120
+ click = false;
121
+ }
122
+ if (searchData.module == 'duration_avg' || searchData.id == -203) {
123
+ click = false;
124
+ }
125
+ if (searchData.module == 'duration_avg') {
126
+ _text = convertMilliseconds(_text);
127
+ }
128
+ return /*#__PURE__*/React.createElement("div", {
129
+ className: "".concat(classPrefix, "-table-td-link ").concat(click ? '' : 'not-to-detail'),
130
+ onClick: function onClick() {
131
+ click ? onClickToDetailCallback(record, columnData[i], _text) : null;
132
+ }
133
+ }, click && /*#__PURE__*/React.createElement(IconFont, {
134
+ type: "a-yanjingkai"
135
+ }), _text);
136
+ }
137
+ });
138
+ };
139
+ for (var i = 0; i < columnData.length; i++) {
140
+ _loop(i);
141
+ }
142
+ return data;
143
+ }
144
+ export function getChartDataWholeAliasName(dataSource, eventGroupList) {
145
+ var data = _.cloneDeep(dataSource);
146
+ var series = [];
147
+ data.series.map(function (item) {
148
+ item.originalNames = item.names;
149
+ item.names = item.names.length > 1 ? [item.names[0], getWholeAliasName(item.names[1], eventGroupList)] : [getWholeAliasName(item.names[0], eventGroupList)];
150
+ series.push(item);
151
+ });
152
+ data.series = series;
153
+ return data;
154
+ }
155
+ export function getWholeAliasName(name, eventGroupList) {
156
+ var aliasName = '';
157
+ eventGroupList && eventGroupList.map(function (item) {
158
+ item.eventList.map(function (_item) {
159
+ if (_item.name === name) {
160
+ aliasName = _item.alias ? _item.alias : name;
161
+ }
162
+ });
163
+ });
164
+ return aliasName || name;
165
+ }
166
+ export function getWholeAliasId(name, eventGroupList) {
167
+ var eventId = -1;
168
+ eventGroupList && eventGroupList.map(function (item) {
169
+ item.eventList.map(function (_item) {
170
+ if (_item.name === name) {
171
+ eventId = _item.id;
172
+ }
173
+ });
174
+ });
175
+ return eventId;
176
+ }
177
+ export function getSortData(data) {
178
+ var series = data.series;
179
+ var sort = function sort(obj1, obj2) {
180
+ var val1 = obj1.values[0];
181
+ var val2 = obj2.values[0];
182
+ if (val1 < val2) {
183
+ return 1;
184
+ } else if (val1 > val2) {
185
+ return -1;
186
+ } else {
187
+ return 0;
188
+ }
189
+ };
190
+ series.sort(sort);
191
+ return data;
192
+ }
193
+ export function getUserGroupsCompareData(data) {
194
+ if (data.series.length <= 0) {
195
+ return data;
196
+ } else {
197
+ var _data = _.cloneDeep(data);
198
+ var _series = [];
199
+ _data.series.map(function (item, index) {
200
+ _series.push(item);
201
+ _data.series.map(function (_item, _index) {
202
+ if (item.names[1] === _item.names[1] && index !== _index) {
203
+ _series.push(_item);
204
+ delete _data.series[_index];
205
+ }
206
+ });
207
+ delete _data.series[index];
208
+ });
209
+ _data.series = _series;
210
+ return _data;
211
+ }
212
+ }
213
+ export function marketWholeGroupList(eventGroupList) {
214
+ var _marketName = [];
215
+ eventGroupList && eventGroupList.map(function (item) {
216
+ item.eventList.map(function (_item) {
217
+ if (_item.marked) _marketName.push(_item.name);
218
+ });
219
+ });
220
+ return _marketName;
221
+ }
222
+ export function getWarningId(searchData, wholeData, eventGroupList) {
223
+ var id = -1;
224
+ if (wholeData && wholeData.series.length > 0) {
225
+ if (searchData === null || searchData === void 0 ? void 0 : searchData.id) {
226
+ id = searchData === null || searchData === void 0 ? void 0 : searchData.id;
227
+ } else {
228
+ if (eventGroupList && eventGroupList.length > 0 && wholeData) {
229
+ eventGroupList.map(function (item) {
230
+ item.eventList.map(function (_item) {
231
+ var _wholeData$series$, _searchData$userGroup;
232
+ var _name = wholeData === null || wholeData === void 0 ? void 0 : (_wholeData$series$ = wholeData.series[0]) === null || _wholeData$series$ === void 0 ? void 0 : _wholeData$series$.names[(searchData === null || searchData === void 0 ? void 0 : (_searchData$userGroup = searchData.userGroup) === null || _searchData$userGroup === void 0 ? void 0 : _searchData$userGroup.length) > 1 ? 1 : 0];
233
+ if (_item.name === _name || _item.alias === _name) {
234
+ id = _item.id;
235
+ }
236
+ });
237
+ });
238
+ }
239
+ }
240
+ }
241
+ return id;
242
+ }
243
+ export function getAttrLabel(attrData, eventGroupList, userPropList, eventEnvList) {
244
+ if (!attrData) return;
245
+ var type = attrData.propCategory;
246
+ var attrLabel = '';
247
+ if (type === PropCategory.EventProp) {
248
+ eventGroupList === null || eventGroupList === void 0 ? void 0 : eventGroupList.forEach(function (group) {
249
+ group.eventList.forEach(function (event) {
250
+ event.attrList.forEach(function (attr) {
251
+ if (attr.id === attrData.attrId) {
252
+ attrLabel = attr.label;
253
+ return;
254
+ }
255
+ });
256
+ });
257
+ });
258
+ } else {
259
+ var attrList = type === PropCategory.UserProp ? userPropList : eventEnvList;
260
+ attrList === null || attrList === void 0 ? void 0 : attrList.forEach(function (attr) {
261
+ if (attrData.attrName === attr.name) {
262
+ attrLabel = attr.label;
263
+ return;
264
+ }
265
+ });
266
+ }
267
+ return attrLabel;
268
+ }
269
+ export function formTableData(originalData, userGroups, attrNum, showList) {
270
+ var series = originalData.series;
271
+ var result = [];
272
+ series.forEach(function (item, index) {
273
+ var _item$names = item.names,
274
+ names = _item$names === void 0 ? [] : _item$names,
275
+ values = item.values,
276
+ _item$originalNames = item.originalNames,
277
+ originalNames = _item$originalNames === void 0 ? [] : _item$originalNames;
278
+ var nameStr = names.join(',');
279
+ if (showList) {
280
+ if (!showList.includes(nameStr)) {
281
+ return false;
282
+ }
283
+ }
284
+ var len = names.length;
285
+ var haveUserGroup = userGroups.length > 1 || userGroups[0] !== 0;
286
+ var name = names[len - 1];
287
+ var originalName = originalNames[len - 1];
288
+ var userGroup = haveUserGroup ? names[len - 2] : '所有用户';
289
+ var nameGroup = names.join(',');
290
+ var color = chartColors[index % 20];
291
+ var data = {
292
+ id: Math.random(),
293
+ name: name,
294
+ userGroup: userGroup,
295
+ nameGroup: nameGroup,
296
+ color: color
297
+ };
298
+ if (attrNum) {
299
+ data["dimension"] = name;
300
+ } else {
301
+ data["eventName"] = name;
302
+ data["originalName"] = originalName;
303
+ }
304
+ values.forEach(function (item, index) {
305
+ data["field".concat(index)] = item;
306
+ });
307
+ result.push(data);
308
+ });
309
+ return result;
310
+ }
311
+ export function getDefaultShow(source) {
312
+ if (source.series) {
313
+ var result = [];
314
+ source.series.forEach(function (item, index) {
315
+ if (index < 10) {
316
+ if (item.names) {
317
+ result.push(item.names.join(','));
318
+ }
319
+ }
320
+ });
321
+ return result;
322
+ }
323
+ return [];
324
+ }
325
+ export function getShowColor(source, showList) {
326
+ var colors = [];
327
+ source.series.forEach(function (item, index) {
328
+ if (item.names) {
329
+ var name = item.names.join(',');
330
+ showList.forEach(function (show) {
331
+ if (name === show) {
332
+ colors.push(chartColors[index % 20]);
333
+ return;
334
+ }
335
+ });
336
+ }
337
+ });
338
+ return colors;
339
+ }
340
+ export function convertMilliseconds(milliseconds) {
341
+ var duration = moment.duration(milliseconds);
342
+ if (duration.asSeconds() < 60) {
343
+ return "".concat(duration.asSeconds(), "s");
344
+ } else if (duration.asMinutes() < 60) {
345
+ return duration.minutes() + 'm' + duration.seconds() + 's';
346
+ } else {
347
+ return duration.hours() + 'h' + duration.minutes() + 'm' + duration.seconds() + 's';
348
+ }
349
+ }
350
+ export function sortOriginalData(data, sorter) {
351
+ var columnKey = sorter.columnKey,
352
+ order = sorter.order;
353
+ if (columnKey && order) {
354
+ var sortedData = _toConsumableArray(data).sort(function (a, b) {
355
+ if (order === 'ascend') {
356
+ return a[columnKey] - b[columnKey];
357
+ } else if (order === 'descend') {
358
+ return b[columnKey] - a[columnKey];
359
+ }
360
+ return 0;
361
+ });
362
+ return sortedData;
363
+ } else {
364
+ return data;
365
+ }
366
+ }
@@ -0,0 +1,36 @@
1
+ import { AttributeSelect, EnvProp, EventGroup, UserProp } from '@zgfe/business-lib/es/attributeSelector/types';
2
+ import { bizAttributeSelectorValueProp } from '../types';
3
+ declare let util: {
4
+ dayTime: number;
5
+ type(obj: any): string;
6
+ isObject(obj: any): boolean;
7
+ isArray(obj: any): boolean;
8
+ isString(obj: any): boolean;
9
+ isNumber(obj: any): boolean;
10
+ isDate(obj: any): boolean;
11
+ isFunction(obj: any): boolean;
12
+ isEqual(a?: {}, b?: {}): boolean;
13
+ equal(a: any, b: any): boolean;
14
+ random(min: number, max: number): number;
15
+ guid(): string;
16
+ mergeObject(defaults: {
17
+ [x: string]: any;
18
+ }, option: {
19
+ [x: string]: any;
20
+ }): {
21
+ [x: string]: any;
22
+ };
23
+ toThousands(num: number): string;
24
+ toDoubleNumber(num: number): string;
25
+ dateFormat(date?: any, formatter?: string): string;
26
+ timeFormat(date: any, formatter: string | undefined, autoShort: any): string | undefined;
27
+ strMiddleSplit(str: string, config?: {
28
+ maxLength: number;
29
+ beginLength: number;
30
+ endLength: number;
31
+ replaceStr: string;
32
+ }): string;
33
+ };
34
+ export declare const getValue: (param: bizAttributeSelectorValueProp, eventGroupList: EventGroup[] | undefined, eventEnvList: EnvProp[] | undefined, userPropList: UserProp[] | undefined) => AttributeSelect.Value | undefined;
35
+ export declare function tipContent(isRealTime: boolean): "当前图标数据每天更新一次" | "当前图表数据实时更新,约每分钟更新一次";
36
+ export default util;
@@ -0,0 +1,167 @@
1
+ var util = {
2
+ dayTime: 24 * 60 * 60 * 1000,
3
+ type: function type(obj) {
4
+ return Object.prototype.toString.call(obj);
5
+ },
6
+ isObject: function isObject(obj) {
7
+ return this.type(obj) === '[object Object]';
8
+ },
9
+ isArray: function isArray(obj) {
10
+ return this.type(obj) === '[object Array]';
11
+ },
12
+ isString: function isString(obj) {
13
+ return this.type(obj) === '[object String]';
14
+ },
15
+ isNumber: function isNumber(obj) {
16
+ return this.type(obj) === '[object Number]';
17
+ },
18
+ isDate: function isDate(obj) {
19
+ return this.type(obj) === '[object Date]';
20
+ },
21
+ isFunction: function isFunction(obj) {
22
+ return this.type(obj) === '[object Function]';
23
+ },
24
+ isEqual: function isEqual() {
25
+ var a = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
26
+ var b = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
27
+ return JSON.stringify(a) === JSON.stringify(b);
28
+ },
29
+ equal: function equal(a, b) {
30
+ return JSON.stringify(a) === JSON.stringify(b);
31
+ },
32
+ random: function random(min, max) {
33
+ return Math.round(Math.random() * (max - min)) + min;
34
+ },
35
+ guid: function guid() {
36
+ function s4() {
37
+ return Math.floor((1 + Math.random()) * 0x10000).toString(16).substring(1);
38
+ }
39
+ return s4() + s4() + '-' + s4() + '-' + s4() + '-' + s4() + '-' + s4() + s4() + s4();
40
+ },
41
+ mergeObject: function mergeObject(defaults, option) {
42
+ defaults = defaults || {};
43
+ option = option || {};
44
+ for (var prop in defaults) {
45
+ if (this.isObject(defaults[prop])) {
46
+ option[prop] = option[prop] ? option[prop] : {};
47
+ this.mergeObject(defaults[prop], option[prop]);
48
+ } else if (this.isArray(defaults[prop])) {
49
+ if (!option[prop] || !option[prop].length) {
50
+ option[prop] = defaults[prop];
51
+ } else {
52
+ var i = 0;
53
+ var optLenght = option[prop].length;
54
+ var defaultLength = defaults[prop].length;
55
+ for (i; i < optLenght && i < defaultLength; i++) {
56
+ option[prop][i] = this.mergeObject(defaults[prop][i], option[prop][i]);
57
+ }
58
+ }
59
+ } else {
60
+ option[prop] = option[prop] === null || option[prop] === undefined ? defaults[prop] : option[prop];
61
+ }
62
+ }
63
+ return option;
64
+ },
65
+ toThousands: function toThousands(num) {
66
+ var source = String(num).split('.');
67
+ source[0] = source[0].replace(new RegExp('(\\d)(?=(\\d{3})+$)', 'ig'), '$1,');
68
+ return source.join('.');
69
+ },
70
+ toDoubleNumber: function toDoubleNumber(num) {
71
+ var num2 = num.toString();
72
+ return num > 9 ? num2 : '0' + num2;
73
+ },
74
+ dateFormat: function dateFormat() {
75
+ var date = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : new Date();
76
+ var formatter = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'yyyy-mm-dd';
77
+ return formatter.replace('yyyy', date.getFullYear()).replace('mm', this.toDoubleNumber(date.getMonth() + 1)).replace('dd', this.toDoubleNumber(date.getDate()));
78
+ },
79
+ timeFormat: function timeFormat() {
80
+ var date = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : new Date();
81
+ var formatter = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'hh:mm:ss';
82
+ var autoShort = arguments.length > 2 ? arguments[2] : undefined;
83
+ if (this.isDate(date)) {
84
+ return formatter.replace('hh', this.toDoubleNumber(date.getHours())).replace('mm', this.toDoubleNumber(date.getMinutes())).replace('ss', this.toDoubleNumber(date.getSeconds()));
85
+ } else if (this.isNumber(date)) {
86
+ var s = parseInt(date / 1000 + '');
87
+ var m = parseInt(s / 60 + '');
88
+ var h = parseInt(m / 60 + '');
89
+ s = s - m * 60;
90
+ m = m - h * 60;
91
+ if (!h && autoShort) {
92
+ formatter = formatter.replace(/hh\S*?mm/, 'mm');
93
+ if (!m) {
94
+ formatter = formatter.replace(/mm\S*?ss/, 'ss');
95
+ return formatter.replace('ss', s + '');
96
+ }
97
+ }
98
+ return formatter.replace('hh', this.toDoubleNumber(h)).replace('mm', this.toDoubleNumber(m)).replace('ss', this.toDoubleNumber(s));
99
+ }
100
+ },
101
+ strMiddleSplit: function strMiddleSplit(str) {
102
+ var config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
103
+ maxLength: 20,
104
+ beginLength: 8,
105
+ endLength: 8,
106
+ replaceStr: '...'
107
+ };
108
+ str += '';
109
+ var reg = {
110
+ fullCharReg: /[^\x00-\xff]/,
111
+ fullCharsReg: /[^\x00-\xff]/g,
112
+ anyChars: /[\S\s]{1}/g
113
+ };
114
+ var fullCharLength = (str.match(reg.fullCharsReg) || []).length;
115
+ var fullLength = str.length + fullCharLength;
116
+ var beginArr = [];
117
+ var beginLength = 0;
118
+ var endArr = [];
119
+ var endLength = 0;
120
+ if (fullLength > config.maxLength) {
121
+ var strArr = str.match(reg.anyChars) || [];
122
+ strArr.forEach(function (char) {
123
+ if (beginLength >= config.beginLength) return;
124
+ var len = reg.fullCharReg.test(char) ? 2 : 1;
125
+ beginLength += len;
126
+ beginArr.push(char);
127
+ });
128
+ strArr.reverse().forEach(function (char) {
129
+ if (endLength >= config.endLength) return;
130
+ var len = reg.fullCharReg.test(char) ? 2 : 1;
131
+ endLength += len;
132
+ endArr.push(char);
133
+ });
134
+ return beginArr.join('') + config.replaceStr + endArr.reverse().join('');
135
+ }
136
+ return str;
137
+ }
138
+ };
139
+ export var getValue = function getValue(param, eventGroupList, eventEnvList, userPropList) {
140
+ var res = undefined;
141
+ var key = "".concat(param.propCategory, "-").concat(param.value);
142
+ if ((param === null || param === void 0 ? void 0 : param.propCategory) === 'envProp') {
143
+ eventEnvList === null || eventEnvList === void 0 ? void 0 : eventEnvList.forEach(function (attr) {
144
+ if (attr.key === key) res = attr;
145
+ });
146
+ } else if ((param === null || param === void 0 ? void 0 : param.propCategory) === 'eventProp') {
147
+ eventGroupList === null || eventGroupList === void 0 ? void 0 : eventGroupList.forEach(function (group) {
148
+ group.eventList.forEach(function (event) {
149
+ event.attrList.forEach(function (attr) {
150
+ if (attr.key === key) res = attr;
151
+ });
152
+ });
153
+ });
154
+ } else if ((param === null || param === void 0 ? void 0 : param.propCategory) === 'userProp') {
155
+ userPropList === null || userPropList === void 0 ? void 0 : userPropList.forEach(function (attr) {
156
+ if (attr.key === key) res = attr;
157
+ });
158
+ }
159
+ return res;
160
+ };
161
+ export function tipContent(isRealTime) {
162
+ if (!isRealTime) {
163
+ return '当前图标数据每天更新一次';
164
+ }
165
+ return '当前图表数据实时更新,约每分钟更新一次';
166
+ }
167
+ export default util;
package/package.json ADDED
@@ -0,0 +1,63 @@
1
+ {
2
+ "name": "@zgfe/modules-whole",
3
+ "version": "1.0.10-zhongyuan.0",
4
+ "module": "es/index.js",
5
+ "typings": "es/index.d.ts",
6
+ "private": false,
7
+ "publishConfig": {
8
+ "access": "public"
9
+ },
10
+ "files": [
11
+ "es"
12
+ ],
13
+ "scripts": {
14
+ "build": "father-build",
15
+ "deploy": "npm run docs:build && npm run docs:deploy",
16
+ "docs:build": "dumi build",
17
+ "docs:deploy": "gh-pages -d docs-dist",
18
+ "prepublishOnly": "npm run build",
19
+ "prettier": "prettier --write \"**/*.{js,jsx,tsx,ts,less,md,json}\"",
20
+ "pub": "lerna publish",
21
+ "start": "dumi dev",
22
+ "test": "umi-test",
23
+ "test:coverage": "umi-test --coverage"
24
+ },
25
+ "lint-staged": {
26
+ "*.{js,jsx,less,md,json}": [
27
+ "prettier --write"
28
+ ],
29
+ "*.ts?(x)": [
30
+ "prettier --parser=typescript --write"
31
+ ]
32
+ },
33
+ "dependencies": {
34
+ "add": "^2.0.6",
35
+ "react-copy-to-clipboard": "^5.1.0",
36
+ "react-highlight": "^0.15.0",
37
+ "yarn": "^1.22.22"
38
+ },
39
+ "devDependencies": {
40
+ "@testing-library/jest-dom": "^5.15.1",
41
+ "@testing-library/react": "^12.1.2",
42
+ "@types/jest": "^27.0.3",
43
+ "@types/lodash": "^4.14.191",
44
+ "@umijs/fabric": "^2.8.1",
45
+ "@umijs/test": "^3.0.5",
46
+ "@zgfe/business-lib": "1.2.70-hxd.1",
47
+ "antd": "^4.22.6",
48
+ "dumi": "^1.1.0",
49
+ "echarts": "^5.3.2",
50
+ "echarts-for-react": "^3.0.2",
51
+ "father-build": "^1.17.2",
52
+ "gh-pages": "^3.0.0",
53
+ "lerna": "^4.0.0",
54
+ "lint-staged": "^10.0.7",
55
+ "prettier": "^2.2.1",
56
+ "react": "^16.12.0 || ^17.0.0",
57
+ "yorkie": "^2.0.0"
58
+ },
59
+ "gitHead": "ed71978c89b950986c5757c94b5e83754ee7cabd",
60
+ "gitHooks": {
61
+ "pre-commit": "lint-staged"
62
+ }
63
+ }