@zgfe/modules-event 1.0.29-zhongyuanE.17 → 1.0.29-zhongyuanE.23

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 (92) hide show
  1. package/es/components/eventFilter/index.d.ts +5 -0
  2. package/es/components/eventFilter/index.js +315 -0
  3. package/es/components/eventFilter/setCascade.d.ts +3 -0
  4. package/es/components/eventFilter/setCascade.js +286 -0
  5. package/es/components/eventFilter/types.d.ts +21 -0
  6. package/es/components/eventFilter/types.js +1 -0
  7. package/es/components/index.d.ts +4 -0
  8. package/es/components/index.js +4 -0
  9. package/es/components/renderContent/index.d.ts +5 -0
  10. package/es/components/renderContent/index.js +46 -0
  11. package/es/components/renderContent/styles/index.less +19 -0
  12. package/es/components/renderContent/types.d.ts +8 -0
  13. package/es/components/renderContent/types.js +1 -0
  14. package/es/components/searchPanel/index.d.ts +5 -0
  15. package/es/components/searchPanel/index.js +134 -0
  16. package/es/components/searchPanel/styles/index.less +22 -0
  17. package/es/components/searchPanel/types.d.ts +28 -0
  18. package/es/components/searchPanel/types.js +1 -0
  19. package/es/components/table/index.d.ts +6 -0
  20. package/es/components/table/index.js +319 -0
  21. package/es/components/table/styles/index.css +236 -0
  22. package/es/components/table/styles/index.less +249 -0
  23. package/es/components/table/types.d.ts +10 -0
  24. package/es/components/table/types.js +1 -0
  25. package/es/components/topBar/index.d.ts +10 -0
  26. package/es/components/topBar/index.js +174 -0
  27. package/es/components/topBar/styles/index.less +58 -0
  28. package/es/components/topBar/types.d.ts +8 -0
  29. package/es/components/topBar/types.js +1 -0
  30. package/es/constants/apis.d.ts +10 -0
  31. package/es/constants/apis.js +10 -0
  32. package/es/constants/chart.d.ts +2 -0
  33. package/es/constants/chart.js +31 -0
  34. package/es/constants/color.d.ts +1 -0
  35. package/es/constants/color.js +1 -0
  36. package/es/constants/fields.d.ts +251 -0
  37. package/es/constants/fields.js +177 -0
  38. package/es/constants/index.d.ts +6 -0
  39. package/es/constants/index.js +6 -0
  40. package/es/constants/initData.d.ts +2 -0
  41. package/es/constants/initData.js +9 -0
  42. package/es/index.d.ts +6 -0
  43. package/es/index.js +5 -0
  44. package/es/modules/chart/demo/data.d.ts +73 -0
  45. package/es/modules/chart/demo/data.js +484 -0
  46. package/es/modules/chart/demo/index.d.ts +3 -0
  47. package/es/modules/chart/demo/index.js +51 -0
  48. package/es/modules/chart/demo/panel.d.ts +3 -0
  49. package/es/modules/chart/demo/panel.js +16 -0
  50. package/es/modules/chart/index.d.ts +4 -0
  51. package/es/modules/chart/index.js +253 -0
  52. package/es/modules/chart/types.d.ts +19 -0
  53. package/es/modules/chart/types.js +1 -0
  54. package/es/modules/content/index.d.ts +5 -0
  55. package/es/modules/content/index.js +302 -0
  56. package/es/modules/content/styles/index.less +19 -0
  57. package/es/modules/content/types.d.ts +11 -0
  58. package/es/modules/content/types.js +1 -0
  59. package/es/modules/content/utils.d.ts +18 -0
  60. package/es/modules/content/utils.js +134 -0
  61. package/es/modules/home/demo/create.d.ts +3 -0
  62. package/es/modules/home/demo/create.js +58 -0
  63. package/es/modules/home/demo/edit.d.ts +3 -0
  64. package/es/modules/home/demo/edit.js +73 -0
  65. package/es/modules/home/demo/index.d.ts +4 -0
  66. package/es/modules/home/demo/index.js +55 -0
  67. package/es/modules/home/demo/scene.d.ts +3 -0
  68. package/es/modules/home/demo/scene.js +89 -0
  69. package/es/modules/home/demo/styles/index.less +33 -0
  70. package/es/modules/home/index.d.ts +5 -0
  71. package/es/modules/home/index.js +184 -0
  72. package/es/modules/home/styles/index.less +49 -0
  73. package/es/modules/home/types.d.ts +34 -0
  74. package/es/modules/home/types.js +1 -0
  75. package/es/modules/topPanel/index.d.ts +5 -0
  76. package/es/modules/topPanel/index.js +246 -0
  77. package/es/modules/topPanel/styles/index.less +50 -0
  78. package/es/modules/topPanel/types.d.ts +46 -0
  79. package/es/modules/topPanel/types.js +1 -0
  80. package/es/style/theme.d.ts +15 -0
  81. package/es/style/theme.js +14 -0
  82. package/es/types.d.ts +86 -0
  83. package/es/types.js +6 -0
  84. package/es/utils/ajaxConfig.d.ts +8 -0
  85. package/es/utils/ajaxConfig.js +40 -0
  86. package/es/utils/base64.d.ts +23 -0
  87. package/es/utils/base64.js +125 -0
  88. package/es/utils/formData.d.ts +20 -0
  89. package/es/utils/formData.js +406 -0
  90. package/es/utils/util.d.ts +32 -0
  91. package/es/utils/util.js +139 -0
  92. package/package.json +2 -2
@@ -0,0 +1,406 @@
1
+ function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _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(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
4
+ function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
5
+ function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
6
+ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
7
+ import { util, IconFont } from '@zgfe/business-lib';
8
+ import React from 'react';
9
+ import { message } from 'antd';
10
+ import _ from 'lodash';
11
+ import { CopyToClipboard } from 'react-copy-to-clipboard';
12
+ import { chartColors } from '../constants/color';
13
+ import { PropCategory } from '@zgfe/business-lib/es/attributeSelector/types';
14
+ import { Tooltip } from 'antd';
15
+ import '../style/index.less';
16
+ import { getValue } from '../modules/content/utils';
17
+ var classPrefix = 'event-form-data';
18
+ export function sortOriginalData(data, sorter) {
19
+ var columnKey = sorter.columnKey,
20
+ order = sorter.order;
21
+ if (columnKey && order) {
22
+ var sortedData = _toConsumableArray(data).sort(function (a, b) {
23
+ if (order === 'ascend') {
24
+ return a[columnKey] - b[columnKey];
25
+ } else if (order === 'descend') {
26
+ return b[columnKey] - a[columnKey];
27
+ }
28
+ return 0;
29
+ });
30
+ return sortedData;
31
+ } else {
32
+ return data;
33
+ }
34
+ }
35
+ export function getColumns(eventGroupList, userPropList, eventEnvList, columnData, userGroup, searchData, showList, onShowCallback, onClickToDetailCallback, onSelectEvent) {
36
+ var marketEventNameList = marketEventGroupList(eventGroupList);
37
+ var data = [{
38
+ title: '显示',
39
+ width: 80,
40
+ dataIndex: 'nameGroup',
41
+ ellipsis: true,
42
+ key: 'nameGroup',
43
+ align: 'center',
44
+ className: "".concat(classPrefix, "-table-td"),
45
+ fixed: 'left',
46
+ render: function render(_, record) {
47
+ var isActive = showList.includes(record.nameGroup);
48
+ var cannotClick = showList.length >= 10 && !isActive;
49
+ return record.color ? (/*#__PURE__*/React.createElement("div", {
50
+ className: "".concat(classPrefix, "-table-td-show"),
51
+ onClick: function onClick() {
52
+ if (cannotClick) return;
53
+ onShowCallback(record.nameGroup);
54
+ }
55
+ }, /*#__PURE__*/React.createElement("span", {
56
+ style: {
57
+ background: isActive ? record.color : '#D9D9D9'
58
+ }
59
+ }))) : (/*#__PURE__*/React.createElement("div", {
60
+ className: "".concat(classPrefix, "-table-td-show")
61
+ }));
62
+ }
63
+ }];
64
+ if (!(searchData === null || searchData === void 0 ? void 0 : searchData.analysisSubject) && (userGroup.length > 1 || userGroup[0] !== 0)) {
65
+ data.push({
66
+ title: '用户群',
67
+ width: 150,
68
+ dataIndex: 'userGroup',
69
+ key: 'userGroup',
70
+ ellipsis: true,
71
+ fixed: 'left',
72
+ render: function render(text) {
73
+ return /*#__PURE__*/React.createElement("div", {
74
+ className: "tooltip-userGroup-box"
75
+ }, /*#__PURE__*/React.createElement(Tooltip, {
76
+ title: text
77
+ }, /*#__PURE__*/React.createElement("div", null, text)));
78
+ }
79
+ });
80
+ }
81
+ if (searchData.dimension) {
82
+ var _getValue;
83
+ data.push({
84
+ title: (_getValue = getValue(searchData.dimension, eventGroupList, eventEnvList, userPropList)) === null || _getValue === void 0 ? void 0 : _getValue.label,
85
+ width: 180,
86
+ dataIndex: 'dimension',
87
+ key: 'dimension',
88
+ ellipsis: true,
89
+ fixed: 'left',
90
+ render: function render(val) {
91
+ return /*#__PURE__*/React.createElement("div", {
92
+ className: "tooltip-name-box"
93
+ }, /*#__PURE__*/React.createElement(Tooltip, {
94
+ title: val
95
+ }, /*#__PURE__*/React.createElement("div", {
96
+ className: "tooltip-name-box-market"
97
+ }, val)), /*#__PURE__*/React.createElement(Tooltip, {
98
+ title: "\u590D\u5236"
99
+ }, /*#__PURE__*/React.createElement(CopyToClipboard, {
100
+ text: val,
101
+ onCopy: function onCopy() {
102
+ return message.success('复制成功!');
103
+ }
104
+ }, /*#__PURE__*/React.createElement(IconFont, {
105
+ type: "fuzhi1"
106
+ }))));
107
+ }
108
+ });
109
+ }
110
+ if (searchData.id && !searchData.dimension || !searchData.id) {
111
+ data.push({
112
+ title: /*#__PURE__*/React.createElement("div", {
113
+ style: {
114
+ paddingLeft: '16px'
115
+ }
116
+ }, "\u4E8B\u4EF6"),
117
+ width: 180,
118
+ dataIndex: 'eventName',
119
+ key: 'eventName',
120
+ ellipsis: true,
121
+ fixed: 'left',
122
+ render: function render(val, record) {
123
+ var _val = val;
124
+ return /*#__PURE__*/React.createElement("div", {
125
+ className: "tooltip-name-box"
126
+ }, /*#__PURE__*/React.createElement(Tooltip, {
127
+ title: _val
128
+ }, /*#__PURE__*/React.createElement("div", {
129
+ className: "tooltip-name-box-market",
130
+ onClick: function onClick() {
131
+ !record.isAdd && onSelectEvent && onSelectEvent(getEventAliasId(record === null || record === void 0 ? void 0 : record.originalName, eventGroupList), val);
132
+ }
133
+ }, /*#__PURE__*/React.createElement(IconFont, {
134
+ type: "shoucang",
135
+ className: "".concat(marketEventNameList.indexOf(_val) === -1 ? 'notshoucang' : '')
136
+ }), util.strMiddleSplit(_val))), /*#__PURE__*/React.createElement(Tooltip, {
137
+ title: "\u590D\u5236"
138
+ }, /*#__PURE__*/React.createElement(CopyToClipboard, {
139
+ text: _val,
140
+ onCopy: function onCopy() {
141
+ return message.success('复制成功!');
142
+ }
143
+ }, /*#__PURE__*/React.createElement(IconFont, {
144
+ type: "fuzhi1"
145
+ }))));
146
+ }
147
+ });
148
+ }
149
+ data.push({
150
+ title: '合计',
151
+ width: 50,
152
+ dataIndex: 'attrSum',
153
+ ellipsis: true,
154
+ key: 'attrSum',
155
+ align: 'center',
156
+ className: "".concat(classPrefix, "-table-td"),
157
+ fixed: 'left',
158
+ render: function render(text) {
159
+ return /*#__PURE__*/React.createElement("div", {
160
+ className: "tooltip-userGroup-box"
161
+ }, /*#__PURE__*/React.createElement(Tooltip, {
162
+ title: text
163
+ }, /*#__PURE__*/React.createElement("div", null, text)));
164
+ }
165
+ });
166
+ var _loop = function _loop(i) {
167
+ var value = columnData[i];
168
+ if (/^\d{4}-\d{2}-\d{2}$/.test(value)) {
169
+ value = value.replace(/\d{4}-/, '');
170
+ } else if (/^\d{4}-\d{2}-\d{2}\|\d{4}-\d{2}-\d{2}$/.test(value)) {
171
+ var dates = value.match(/\d{4}-\d{2}-\d{2}/g);
172
+ value = dates ? dates[0].replace(/\d{4}-/, '') + '~' + dates[1].replace(/\d{4}-/, '') : value;
173
+ } else {
174
+ value = util.strMiddleSplit(value);
175
+ if (/:/.test(value)) {
176
+ value = value.replace(/\d{4}-\d{2}-\d{2}\s/, '');
177
+ } else if (/,/.test(value)) {
178
+ value = value.replace(/,/g, '-');
179
+ }
180
+ }
181
+ data.push({
182
+ title: value,
183
+ align: 'center',
184
+ ellipsis: true,
185
+ dataIndex: "field".concat(i),
186
+ defaultSortOrder: i === columnData.length - 1 ? 'descend' : null,
187
+ className: "".concat(classPrefix, "-table-event-data"),
188
+ sorter: function sorter(a, b) {
189
+ return a.isAdd || b.isAdd ? 0 : a["field".concat(i)] - b["field".concat(i)];
190
+ },
191
+ render: function render(text, record) {
192
+ var click = text > 0 && (searchData.analysisIndex === 'number' ? true : false);
193
+ return /*#__PURE__*/React.createElement("div", {
194
+ className: "".concat(classPrefix, "-table-td-link ").concat(!record.isAdd && click ? '' : 'not-to-detail'),
195
+ onClick: function onClick() {
196
+ !record.isAdd && click ? onClickToDetailCallback(record, columnData[i], text) : null;
197
+ }
198
+ }, !record.isAdd && click && /*#__PURE__*/React.createElement(IconFont, {
199
+ type: "a-yanjingkai"
200
+ }), text);
201
+ }
202
+ });
203
+ };
204
+ for (var i = 0; i < columnData.length; i++) {
205
+ _loop(i);
206
+ }
207
+ return data;
208
+ }
209
+ export function getChartDataEventAliasName(dataSource, eventGroupList) {
210
+ var data = _.cloneDeep(dataSource);
211
+ var series = [];
212
+ data === null || data === void 0 ? void 0 : data.series.map(function (item) {
213
+ item.originalNames = item.names;
214
+ item.names = item.names.length > 1 ? [item.names[0], getEventAliasName(item.names[1], eventGroupList)] : [getEventAliasName(item.names[0], eventGroupList)];
215
+ series.push(item);
216
+ });
217
+ data.series = series;
218
+ return data;
219
+ }
220
+ export function getEventAliasName(name, eventGroupList) {
221
+ var aliasName = '';
222
+ eventGroupList && eventGroupList.map(function (item) {
223
+ item.eventList.map(function (_item) {
224
+ if (_item.name === name) {
225
+ aliasName = _item.alias ? _item.alias : name;
226
+ }
227
+ });
228
+ });
229
+ return aliasName || name;
230
+ }
231
+ export function getEventAliasId(name, eventGroupList) {
232
+ var eventId = -1;
233
+ eventGroupList && eventGroupList.map(function (item) {
234
+ item.eventList.map(function (_item) {
235
+ if (_item.name === name) {
236
+ eventId = _item.id;
237
+ }
238
+ });
239
+ });
240
+ return eventId;
241
+ }
242
+ export function getSortData(data) {
243
+ var series = data === null || data === void 0 ? void 0 : data.series;
244
+ var sort = function sort(obj1, obj2) {
245
+ var val1 = obj1.values[0];
246
+ var val2 = obj2.values[0];
247
+ if (val1 < val2) {
248
+ return 1;
249
+ } else if (val1 > val2) {
250
+ return -1;
251
+ } else {
252
+ return 0;
253
+ }
254
+ };
255
+ series.sort(sort);
256
+ return data;
257
+ }
258
+ export function getUserGroupsCompareData(data) {
259
+ if ((data === null || data === void 0 ? void 0 : data.series.length) <= 0) {
260
+ return data;
261
+ } else {
262
+ var _data = _.cloneDeep(data);
263
+ var _series = [];
264
+ _data === null || _data === void 0 ? void 0 : _data.series.map(function (item, index) {
265
+ _series.push(item);
266
+ _data === null || _data === void 0 ? void 0 : _data.series.map(function (_item, _index) {
267
+ if (item.names[1] === _item.names[1] && index !== _index) {
268
+ _series.push(_item);
269
+ _data === null || _data === void 0 ? true : delete _data.series[_index];
270
+ }
271
+ });
272
+ _data === null || _data === void 0 ? true : delete _data.series[index];
273
+ });
274
+ _data.series = _series;
275
+ return _data;
276
+ }
277
+ }
278
+ export function marketEventGroupList(eventGroupList) {
279
+ var _marketName = [];
280
+ eventGroupList && eventGroupList.map(function (item) {
281
+ item.eventList.map(function (_item) {
282
+ if (_item.marked) _marketName.push(_item.name);
283
+ });
284
+ });
285
+ return _marketName;
286
+ }
287
+ export function getWarningId(searchData, eventData, eventGroupList) {
288
+ var id = -1;
289
+ if (eventData && eventData.series.length > 0) {
290
+ if (searchData === null || searchData === void 0 ? void 0 : searchData.id) {
291
+ id = searchData === null || searchData === void 0 ? void 0 : searchData.id;
292
+ } else {
293
+ if (eventGroupList && eventGroupList.length > 0 && eventData) {
294
+ eventGroupList.map(function (item) {
295
+ item.eventList.map(function (_item) {
296
+ var _eventData$series$, _searchData$userGroup;
297
+ var _name = eventData === null || eventData === void 0 ? void 0 : (_eventData$series$ = eventData.series[0]) === null || _eventData$series$ === void 0 ? void 0 : _eventData$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];
298
+ if (_item.name === _name || _item.alias === _name) {
299
+ id = _item.id;
300
+ }
301
+ });
302
+ });
303
+ }
304
+ }
305
+ }
306
+ return id;
307
+ }
308
+ export function getAttrLabel(attrData, eventGroupList, userPropList, eventEnvList) {
309
+ if (!attrData) return;
310
+ var type = attrData.propCategory;
311
+ var attrLabel = '';
312
+ if (type === PropCategory.EventProp) {
313
+ eventGroupList === null || eventGroupList === void 0 ? void 0 : eventGroupList.forEach(function (group) {
314
+ group.eventList.forEach(function (event) {
315
+ event.attrList.forEach(function (attr) {
316
+ if (attr.id === attrData.attrId) {
317
+ attrLabel = attr.label;
318
+ return;
319
+ }
320
+ });
321
+ });
322
+ });
323
+ } else {
324
+ var attrList = type === PropCategory.UserProp ? userPropList : eventEnvList;
325
+ attrList === null || attrList === void 0 ? void 0 : attrList.forEach(function (attr) {
326
+ if (attrData.attrName === attr.name) {
327
+ attrLabel = attr.label;
328
+ return;
329
+ }
330
+ });
331
+ }
332
+ return attrLabel;
333
+ }
334
+ export function formTableData(originalData, userGroups, attrNum, showList) {
335
+ var series = originalData.series;
336
+ var result = [];
337
+ series.forEach(function (item, index) {
338
+ var _item$names = item.names,
339
+ names = _item$names === void 0 ? [] : _item$names,
340
+ values = item.values,
341
+ _item$originalNames = item.originalNames,
342
+ originalNames = _item$originalNames === void 0 ? [] : _item$originalNames;
343
+ var nameStr = names.join(',');
344
+ if (showList) {
345
+ if (!showList.includes(nameStr)) {
346
+ return false;
347
+ }
348
+ }
349
+ var len = names.length;
350
+ var haveUserGroup = userGroups.length > 1 || userGroups[0] !== 0;
351
+ var name = names[len - 1];
352
+ var originalName = originalNames[len - 1];
353
+ var userGroup = haveUserGroup ? names[len - 2] : '所有用户';
354
+ var nameGroup = names.join(',');
355
+ var color = chartColors[index % 20];
356
+ var data = {
357
+ id: Math.random(),
358
+ name: name,
359
+ userGroup: userGroup,
360
+ nameGroup: nameGroup,
361
+ color: color,
362
+ attrSum: item.attrSum
363
+ };
364
+ if (attrNum) {
365
+ data["dimension"] = name;
366
+ data['originalName'] = originalName;
367
+ } else {
368
+ data["eventName"] = name;
369
+ data["originalName"] = originalName;
370
+ }
371
+ values.forEach(function (item, index) {
372
+ data["field".concat(index)] = item;
373
+ });
374
+ result.push(data);
375
+ });
376
+ return result;
377
+ }
378
+ export function getDefaultShow(source) {
379
+ if (source.series) {
380
+ var result = [];
381
+ source.series.forEach(function (item, index) {
382
+ if (index < 10) {
383
+ if (item.names) {
384
+ result.push(item.names.join(','));
385
+ }
386
+ }
387
+ });
388
+ return result;
389
+ }
390
+ return [];
391
+ }
392
+ export function getShowColor(source, showList) {
393
+ var colors = [];
394
+ source.series.forEach(function (item, index) {
395
+ if (item.names) {
396
+ var name = item.names.join(',');
397
+ showList.forEach(function (show) {
398
+ if (name === show) {
399
+ colors.push(chartColors[index % 20]);
400
+ return;
401
+ }
402
+ });
403
+ }
404
+ });
405
+ return colors;
406
+ }
@@ -0,0 +1,32 @@
1
+ declare let util: {
2
+ dayTime: number;
3
+ type(obj: any): string;
4
+ isObject(obj: any): boolean;
5
+ isArray(obj: any): boolean;
6
+ isString(obj: any): boolean;
7
+ isNumber(obj: any): boolean;
8
+ isDate(obj: any): boolean;
9
+ isFunction(obj: any): boolean;
10
+ isEqual(a?: {}, b?: {}): boolean;
11
+ equal(a: any, b: any): boolean;
12
+ random(min: number, max: number): number;
13
+ guid(): string;
14
+ mergeObject(defaults: {
15
+ [x: string]: any;
16
+ }, option: {
17
+ [x: string]: any;
18
+ }): {
19
+ [x: string]: any;
20
+ };
21
+ toThousands(num: number): string;
22
+ toDoubleNumber(num: number): string;
23
+ dateFormat(date?: any, formatter?: string): string;
24
+ timeFormat(date: any, formatter: string | undefined, autoShort: any): string | undefined;
25
+ strMiddleSplit(str: string, config?: {
26
+ maxLength: number;
27
+ beginLength: number;
28
+ endLength: number;
29
+ replaceStr: string;
30
+ }): string;
31
+ };
32
+ export default util;
@@ -0,0 +1,139 @@
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 default util;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zgfe/modules-event",
3
- "version": "1.0.29-zhongyuanE.17",
3
+ "version": "1.0.29-zhongyuanE.23",
4
4
  "module": "es/index.js",
5
5
  "typings": "es/index.d.ts",
6
6
  "private": false,
@@ -54,7 +54,7 @@
54
54
  "react": "^16.12.0 || ^17.0.0",
55
55
  "yorkie": "^2.0.0"
56
56
  },
57
- "gitHead": "29048e32c27223583495c1e119aaadf2f49b6708",
57
+ "gitHead": "970c99a20074a839133245ccbf4d340e47e22f21",
58
58
  "gitHooks": {
59
59
  "pre-commit": "lint-staged"
60
60
  }