@zgfe/modules-event 1.0.6 → 1.0.29-zhongyuan-event.1
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.
- package/README.md +35 -35
- package/es/components/eventFilter/index.js +111 -55
- package/es/components/eventFilter/setCascade.d.ts +3 -0
- package/es/components/eventFilter/setCascade.js +286 -0
- package/es/components/eventFilter/styles/index.less +148 -36
- package/es/components/eventFilter/types.d.ts +1 -0
- package/es/components/renderContent/index.js +16 -27
- package/es/components/renderContent/styles/index.less +19 -19
- package/es/components/renderContent/types.d.ts +0 -1
- package/es/components/searchPanel/index.js +35 -17
- package/es/components/searchPanel/styles/index.less +22 -18
- package/es/components/searchPanel/types.d.ts +2 -2
- package/es/components/table/index.js +106 -35
- package/es/components/table/styles/index.css +236 -0
- package/es/components/table/styles/index.less +249 -193
- package/es/components/table/types.d.ts +0 -1
- package/es/components/topBar/index.d.ts +6 -1
- package/es/components/topBar/index.js +62 -45
- package/es/components/topBar/styles/index.less +58 -63
- package/es/components/topBar/types.d.ts +0 -1
- package/es/constants/apis.d.ts +3 -1
- package/es/constants/apis.js +4 -2
- package/es/constants/fields.d.ts +0 -14
- package/es/constants/fields.js +1 -45
- package/es/index.d.ts +2 -1
- package/es/index.js +2 -1
- package/es/modules/chart/demo/index.js +5 -5
- package/es/modules/chart/demo/panel.js +7 -2
- package/es/modules/chart/index.js +120 -45
- package/es/modules/chart/types.d.ts +3 -0
- package/es/modules/content/index.d.ts +1 -1
- package/es/modules/content/index.js +116 -75
- package/es/modules/content/styles/index.less +19 -7
- package/es/modules/content/utils.d.ts +3 -2
- package/es/modules/content/utils.js +63 -34
- package/es/modules/home/demo/create.js +8 -8
- package/es/modules/home/demo/edit.js +14 -15
- package/es/modules/home/demo/index.js +13 -10
- package/es/modules/home/demo/scene.js +8 -8
- package/es/modules/home/demo/styles/index.less +33 -33
- package/es/modules/home/index.js +59 -41
- package/es/modules/home/styles/index.less +49 -49
- package/es/modules/topPanel/index.js +51 -23
- package/es/modules/topPanel/styles/index.less +50 -49
- package/es/style/image/ring.svg +8 -8
- package/es/style/index.less +62 -62
- package/es/types.d.ts +8 -0
- package/es/utils/formData.d.ts +2 -1
- package/es/utils/formData.js +67 -18
- package/package.json +24 -20
|
@@ -1,51 +1,55 @@
|
|
|
1
|
-
function _typeof(
|
|
2
|
-
function ownKeys(
|
|
3
|
-
function _objectSpread(
|
|
4
|
-
function _defineProperty(
|
|
5
|
-
function _toPropertyKey(
|
|
6
|
-
function _toPrimitive(
|
|
7
|
-
function _slicedToArray(
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
5
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
6
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
7
|
+
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
8
8
|
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."); }
|
|
9
|
-
function _unsupportedIterableToArray(
|
|
10
|
-
function _arrayLikeToArray(
|
|
11
|
-
function _iterableToArrayLimit(
|
|
12
|
-
function _arrayWithHoles(
|
|
9
|
+
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; } }
|
|
10
|
+
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; }
|
|
11
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
12
|
+
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
13
13
|
import React, { useContext, useEffect, useMemo, useState } from 'react';
|
|
14
14
|
import { Tooltip, Empty } from 'antd';
|
|
15
|
-
import { BizChart, BizGlobalDataContext, ajax, BizLoading } from '@zgfe/business-lib';
|
|
15
|
+
import { BizChart, BizGlobalDataContext, ajax, BizLoading, BizEmpty } from '@zgfe/business-lib';
|
|
16
16
|
import { EventTable } from '../../components';
|
|
17
17
|
import { judgeIsCity } from '../content/utils';
|
|
18
18
|
import { getValue, getMapChartData } from '../../modules/content/utils';
|
|
19
|
-
import {
|
|
19
|
+
import { getShowColor, getUserGroupsCompareData, getSortData, getChartDataEventAliasName, formTableData, sortOriginalData } from '../../utils/formData';
|
|
20
20
|
import _ from 'lodash';
|
|
21
21
|
import moment from 'moment';
|
|
22
22
|
import { Apis, chartColors } from '../../constants';
|
|
23
23
|
var classPrefix = 'event-mi-table';
|
|
24
24
|
var EventChart = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
25
25
|
var params = props.params;
|
|
26
|
-
var _useState = useState(
|
|
26
|
+
var _useState = useState(props === null || props === void 0 ? void 0 : props.completedSearchData),
|
|
27
27
|
_useState2 = _slicedToArray(_useState, 2),
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
var _useState3 = useState(
|
|
28
|
+
completedSearchData = _useState2[0],
|
|
29
|
+
setCompletedSearchData = _useState2[1];
|
|
30
|
+
var _useState3 = useState(false),
|
|
31
31
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
var _useState5 = useState(props.
|
|
32
|
+
isCity = _useState4[0],
|
|
33
|
+
setIsCity = _useState4[1];
|
|
34
|
+
var _useState5 = useState(props.type || 'line'),
|
|
35
35
|
_useState6 = _slicedToArray(_useState5, 2),
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
var _useState7 = useState(props.
|
|
36
|
+
chartType = _useState6[0],
|
|
37
|
+
setChartType = _useState6[1];
|
|
38
|
+
var _useState7 = useState(props.showList || []),
|
|
39
39
|
_useState8 = _slicedToArray(_useState7, 2),
|
|
40
|
-
|
|
41
|
-
|
|
40
|
+
showList = _useState8[0],
|
|
41
|
+
setShowList = _useState8[1];
|
|
42
|
+
var _useState9 = useState(props.dataSource),
|
|
43
|
+
_useState0 = _slicedToArray(_useState9, 2),
|
|
44
|
+
dataSource = _useState0[0],
|
|
45
|
+
setDataSource = _useState0[1];
|
|
42
46
|
var _useContext = useContext(BizGlobalDataContext),
|
|
43
|
-
currentApp = _useContext.currentApp,
|
|
44
47
|
eventGroupList = _useContext.eventGroupList,
|
|
45
48
|
eventEnvList = _useContext.eventEnvList,
|
|
46
|
-
userPropList = _useContext.userPropList
|
|
47
|
-
|
|
48
|
-
|
|
49
|
+
userPropList = _useContext.userPropList,
|
|
50
|
+
currentApp = _useContext.currentApp;
|
|
51
|
+
var _useState1 = useState(false),
|
|
52
|
+
_useState10 = _slicedToArray(_useState1, 2),
|
|
49
53
|
loading = _useState10[0],
|
|
50
54
|
setLoading = _useState10[1];
|
|
51
55
|
var showColors = useMemo(function () {
|
|
@@ -58,31 +62,46 @@ var EventChart = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
58
62
|
}
|
|
59
63
|
}, [params]);
|
|
60
64
|
useEffect(function () {
|
|
65
|
+
if (!dataSource || !dataSource.series.length) return;
|
|
61
66
|
if (!props.showList || !props.showList.length) {
|
|
62
|
-
|
|
67
|
+
var _dataSource$series$;
|
|
68
|
+
var gLen = (params === null || params === void 0 ? void 0 : params.dimension) ? 1 : 0;
|
|
69
|
+
var _data = formTableData(dataSource, (params === null || params === void 0 ? void 0 : params.userGroup) || [0], gLen);
|
|
70
|
+
var _sortData = sortOriginalData(_data, {
|
|
71
|
+
columnKey: "field".concat(((_dataSource$series$ = dataSource.series[0]) === null || _dataSource$series$ === void 0 ? void 0 : _dataSource$series$.values.length) - 1),
|
|
72
|
+
order: 'descend'
|
|
73
|
+
});
|
|
74
|
+
var _showlist = [];
|
|
75
|
+
_sortData.forEach(function (item, index) {
|
|
76
|
+
if (index < 10) {
|
|
77
|
+
_showlist.push(item.nameGroup);
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
setShowList(_showlist);
|
|
81
|
+
props.onChangeShow && props.onChangeShow(_showlist);
|
|
63
82
|
} else {
|
|
64
83
|
setShowList(props.showList);
|
|
65
84
|
}
|
|
66
|
-
}, [
|
|
85
|
+
}, [dataSource, props.showList]);
|
|
67
86
|
useEffect(function () {
|
|
68
|
-
var
|
|
69
|
-
if (!
|
|
70
|
-
var chartData = ((
|
|
87
|
+
var _completedSearchData$;
|
|
88
|
+
if (!completedSearchData) return;
|
|
89
|
+
var chartData = ((_completedSearchData$ = completedSearchData.chartType) === null || _completedSearchData$ === void 0 ? void 0 : _completedSearchData$.split(',')) || ['line'];
|
|
71
90
|
var type = chartData[0];
|
|
72
91
|
if (!props.dataSource) {
|
|
73
92
|
type = (chartData === null || chartData === void 0 ? void 0 : chartData.length) > 1 ? chartData[chartData.length - 1] : chartData[0];
|
|
74
93
|
}
|
|
75
94
|
setChartType(props.type || type);
|
|
76
|
-
if (
|
|
77
|
-
var dimensions =
|
|
95
|
+
if (completedSearchData.id) {
|
|
96
|
+
var dimensions = completedSearchData.dimension;
|
|
78
97
|
if (type === 'map' && dimensions) {
|
|
79
98
|
var _getValue;
|
|
80
99
|
setIsCity(judgeIsCity((_getValue = getValue(dimensions, eventGroupList, eventEnvList, userPropList)) === null || _getValue === void 0 ? void 0 : _getValue.name));
|
|
81
100
|
}
|
|
82
101
|
}
|
|
83
|
-
}, [
|
|
102
|
+
}, [completedSearchData, props.type]);
|
|
84
103
|
var fetchResult = function fetchResult() {
|
|
85
|
-
var _params$chartType2;
|
|
104
|
+
var _params$chartType, _params$chartType2;
|
|
86
105
|
setLoading(true);
|
|
87
106
|
ajax(Apis.dataList, {
|
|
88
107
|
method: 'post',
|
|
@@ -90,9 +109,11 @@ var EventChart = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
90
109
|
appId: currentApp === null || currentApp === void 0 ? void 0 : currentApp.appId,
|
|
91
110
|
platform: (params === null || params === void 0 ? void 0 : params.platform) || 0
|
|
92
111
|
}, params), {}, {
|
|
93
|
-
chartType: (params === null || params === void 0 ? void 0 : (_params$
|
|
112
|
+
chartType: (params === null || params === void 0 ? void 0 : (_params$chartType = params.chartType) === null || _params$chartType === void 0 ? void 0 : _params$chartType.indexOf(',')) === -1 ? params === null || params === void 0 ? void 0 : params.chartType : params === null || params === void 0 ? void 0 : (_params$chartType2 = params.chartType) === null || _params$chartType2 === void 0 ? void 0 : _params$chartType2.split(',')[0]
|
|
94
113
|
})
|
|
95
114
|
}).then(function (res) {
|
|
115
|
+
var _params$userGroup;
|
|
116
|
+
setCompletedSearchData(params);
|
|
96
117
|
if (!res) {
|
|
97
118
|
setLoading(false);
|
|
98
119
|
return;
|
|
@@ -101,7 +122,7 @@ var EventChart = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
101
122
|
if (['bar', 'pie', 'map'].indexOf(params.chartType) !== -1) {
|
|
102
123
|
_data = getSortData(_data);
|
|
103
124
|
}
|
|
104
|
-
if (params.userGroup.length > 1) {
|
|
125
|
+
if ((params === null || params === void 0 ? void 0 : params.userGroup) && (params === null || params === void 0 ? void 0 : (_params$userGroup = params.userGroup) === null || _params$userGroup === void 0 ? void 0 : _params$userGroup.length) > 1) {
|
|
105
126
|
setDataSource(getUserGroupsCompareData(_data));
|
|
106
127
|
} else {
|
|
107
128
|
setDataSource(_data);
|
|
@@ -117,16 +138,37 @@ var EventChart = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
117
138
|
} else {
|
|
118
139
|
list.splice(index, 1);
|
|
119
140
|
}
|
|
141
|
+
setShowList(list);
|
|
120
142
|
if (props.onChangeShow) props.onChangeShow(list);
|
|
121
143
|
};
|
|
122
|
-
var onChangeShow = function onChangeShow(names) {
|
|
123
|
-
if (props.onChangeShow) props.onChangeShow(names);
|
|
124
|
-
};
|
|
125
144
|
if (loading) {
|
|
126
145
|
return /*#__PURE__*/React.createElement(BizLoading, {
|
|
127
146
|
className: "".concat(classPrefix, "-loading")
|
|
128
147
|
});
|
|
129
148
|
}
|
|
149
|
+
if (dataSource && dataSource.delEvent) {
|
|
150
|
+
if (!props.isHideDel) {
|
|
151
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
152
|
+
style: {
|
|
153
|
+
display: 'flex',
|
|
154
|
+
minHeight: 345,
|
|
155
|
+
justifyContent: 'center',
|
|
156
|
+
alignItems: 'center'
|
|
157
|
+
}
|
|
158
|
+
}, /*#__PURE__*/React.createElement(BizEmpty, {
|
|
159
|
+
imageStyle: {
|
|
160
|
+
height: 58
|
|
161
|
+
},
|
|
162
|
+
description: /*#__PURE__*/React.createElement("span", {
|
|
163
|
+
style: {
|
|
164
|
+
color: '#9AA1A9'
|
|
165
|
+
}
|
|
166
|
+
}, "\u4E8B\u4EF6\u5DF2\u88AB\u5220\u9664\u65E0\u6CD5\u67E5\u770B\uFF0C\u8BF7\u91CD\u65B0\u8BBE\u7F6E")
|
|
167
|
+
}));
|
|
168
|
+
} else {
|
|
169
|
+
return null;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
130
172
|
if (!dataSource || !dataSource.xAxis.length || !dataSource.series.length) {
|
|
131
173
|
return /*#__PURE__*/React.createElement(Empty, {
|
|
132
174
|
image: Empty.PRESENTED_IMAGE_SIMPLE,
|
|
@@ -139,6 +181,39 @@ var EventChart = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
139
181
|
title: '当前图表数据实时更新,约每分钟更新一次'
|
|
140
182
|
}, /*#__PURE__*/React.createElement("div", null, "\u6570\u636E\u66F4\u65B0\u65F6\u95F4\uFF1A", moment().format('YYYY-MM-DD HH:mm')));
|
|
141
183
|
};
|
|
184
|
+
var tooltipFormatter = function tooltipFormatter(data) {
|
|
185
|
+
var xLabel = '';
|
|
186
|
+
var params = data[0] ? data : [data];
|
|
187
|
+
var array = params[0].name.split('|');
|
|
188
|
+
if (array.length > 1) {
|
|
189
|
+
xLabel = moment(array[0]).format('MM-DD') + '~' + moment(array[1]).format('MM-DD');
|
|
190
|
+
} else {
|
|
191
|
+
var _props$params, _props$params$time, _props$params2, _props$params2$time;
|
|
192
|
+
if ((props === null || props === void 0 ? void 0 : (_props$params = props.params) === null || _props$params === void 0 ? void 0 : (_props$params$time = _props$params.time) === null || _props$params$time === void 0 ? void 0 : _props$params$time.unit) == 'hour') {
|
|
193
|
+
xLabel = moment(array[0]).isValid() ? moment(array[0]).format('MM-DD HH') : array[0];
|
|
194
|
+
} else if ((props === null || props === void 0 ? void 0 : (_props$params2 = props.params) === null || _props$params2 === void 0 ? void 0 : (_props$params2$time = _props$params2.time) === null || _props$params2$time === void 0 ? void 0 : _props$params2$time.unit) == 'minute') {
|
|
195
|
+
xLabel = moment(array[0]).isValid() ? moment(array[0]).format('MM-DD HH:mm') : array[0];
|
|
196
|
+
} else xLabel = moment(array[0]).isValid() ? moment(array[0]).format('MM-DD') : array[0];
|
|
197
|
+
}
|
|
198
|
+
var series = [];
|
|
199
|
+
var seriesMap = {};
|
|
200
|
+
params.forEach(function (item) {
|
|
201
|
+
if (item.value === null || item.value === undefined || seriesMap[item.seriesName] !== null && seriesMap[item.seriesName] !== undefined) return;
|
|
202
|
+
seriesMap[item.seriesName] = item.value;
|
|
203
|
+
var value = item.value;
|
|
204
|
+
var seriesName = item.seriesName || item.axisValueLabel;
|
|
205
|
+
seriesName = [seriesName].join('<br/>');
|
|
206
|
+
series.push({
|
|
207
|
+
text: "<div class='biz-chart-tooltip-item'>\n <div class='biz-chart-tooltip-content'>\n <span class=\"biz-tooltip-marker\" style=\"background:".concat(item.color, "\"></span>\n <div class=\"biz-tooltip-name\">").concat(seriesName, "</div>\n </div> \n <div class='biz-chart-tooltip-value'>\n ").concat(value, "\n </div>\n </div>"),
|
|
208
|
+
value: value
|
|
209
|
+
});
|
|
210
|
+
});
|
|
211
|
+
return "<div class='biz-chart-tooltip-title'>".concat(xLabel, "</div>").concat(series.sort(function (a, b) {
|
|
212
|
+
return parseInt(b.value) - parseInt(a.value);
|
|
213
|
+
}).map(function (item) {
|
|
214
|
+
return item.text;
|
|
215
|
+
}).join(''));
|
|
216
|
+
};
|
|
142
217
|
switch (chartType) {
|
|
143
218
|
case 'line':
|
|
144
219
|
case 'bar':
|
|
@@ -156,7 +231,8 @@ var EventChart = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
156
231
|
colors: showColors,
|
|
157
232
|
xRotate: chartType === 'bar' && dataSource.series.length > 5 ? 40 : 0,
|
|
158
233
|
reverseXAxis: chartType === 'bar',
|
|
159
|
-
isCity: isCity
|
|
234
|
+
isCity: isCity,
|
|
235
|
+
tooltipFormatter: tooltipFormatter
|
|
160
236
|
}));
|
|
161
237
|
case 'grid':
|
|
162
238
|
return /*#__PURE__*/React.createElement(EventTable, {
|
|
@@ -164,7 +240,6 @@ var EventChart = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
164
240
|
sourcePanel: !props.dataSource,
|
|
165
241
|
searchData: params,
|
|
166
242
|
showList: showList,
|
|
167
|
-
changeShow: onChangeShow,
|
|
168
243
|
changeShowByName: onChangeShowByName,
|
|
169
244
|
onSelectEvent: props === null || props === void 0 ? void 0 : props.onSelectEvent
|
|
170
245
|
});
|
|
@@ -3,14 +3,17 @@ import { SearchValue } from '../../types';
|
|
|
3
3
|
export declare namespace eventChartProps {
|
|
4
4
|
interface ChartTypesProps extends ChartTypes.Value {
|
|
5
5
|
xAxis: [];
|
|
6
|
+
delEvent?: number;
|
|
6
7
|
}
|
|
7
8
|
interface Props {
|
|
8
9
|
dataSource?: ChartTypesProps;
|
|
9
10
|
params?: SearchValue;
|
|
11
|
+
completedSearchData?: SearchValue;
|
|
10
12
|
type?: string;
|
|
11
13
|
showList?: string[];
|
|
12
14
|
showColors?: string[];
|
|
13
15
|
onChangeShow?: (data: string[]) => void;
|
|
14
16
|
onSelectEvent?: (id: number, name: string) => void;
|
|
17
|
+
isHideDel?: boolean;
|
|
15
18
|
}
|
|
16
19
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { EventContentProps } from './types';
|
|
3
3
|
import './styles/index.less';
|
|
4
|
-
declare const EventContent: React.
|
|
4
|
+
declare const EventContent: React.ForwardRefExoticComponent<EventContentProps.Props & React.RefAttributes<any>>;
|
|
5
5
|
export default EventContent;
|
|
@@ -1,87 +1,97 @@
|
|
|
1
|
-
function _typeof(
|
|
2
|
-
function ownKeys(
|
|
3
|
-
function _objectSpread(
|
|
4
|
-
function _defineProperty(
|
|
5
|
-
function _toPropertyKey(
|
|
6
|
-
function _toPrimitive(
|
|
7
|
-
function _slicedToArray(
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
5
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
6
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
7
|
+
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
8
8
|
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."); }
|
|
9
|
-
function _unsupportedIterableToArray(
|
|
10
|
-
function _arrayLikeToArray(
|
|
11
|
-
function _iterableToArrayLimit(
|
|
12
|
-
function _arrayWithHoles(
|
|
9
|
+
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; } }
|
|
10
|
+
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; }
|
|
11
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
12
|
+
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
13
13
|
import { ajax, BizGlobalDataContext, BizLayout, BizTargetFromPanelContext } from '@zgfe/business-lib';
|
|
14
14
|
import { message } from 'antd';
|
|
15
|
-
import React, { useContext, useEffect, useRef, useState } from 'react';
|
|
15
|
+
import React, { useContext, useEffect, useRef, useState, useImperativeHandle } from 'react';
|
|
16
16
|
import Request from 'umi-request';
|
|
17
17
|
import TopBar from '../../components/topBar';
|
|
18
18
|
import { EventContext } from '../../types';
|
|
19
19
|
import './styles/index.less';
|
|
20
20
|
import { Apis } from '../../constants';
|
|
21
21
|
import { ContentPanel, SearchPanel } from '../../components';
|
|
22
|
-
import {
|
|
22
|
+
import { getUserGroupsCompareData, getSortData, getChartDataEventAliasName, sortOriginalData, formTableData } from '../../utils/formData';
|
|
23
23
|
import TopPanel from '../topPanel';
|
|
24
24
|
var timer = 0;
|
|
25
25
|
var ajaxFlag = true;
|
|
26
|
+
var refresh = false;
|
|
26
27
|
var CancelToken = Request.CancelToken;
|
|
27
28
|
var cancel;
|
|
28
29
|
var classPrefix = 'event-content';
|
|
29
|
-
var EventContent = function
|
|
30
|
-
var _props$value, _props$value2;
|
|
30
|
+
var EventContent = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
31
|
+
var _props$value, _props$value2, _topPanelRef$current4;
|
|
31
32
|
var _useContext = useContext(BizGlobalDataContext),
|
|
32
|
-
currentApp = _useContext.currentApp,
|
|
33
33
|
authority = _useContext.authority;
|
|
34
34
|
var _useContext2 = useContext(EventContext),
|
|
35
|
+
currentApp = _useContext2.currentApp,
|
|
35
36
|
searchData = _useContext2.searchData,
|
|
36
37
|
setSearchData = _useContext2.setSearchData,
|
|
37
38
|
eventGroupList = _useContext2.eventGroupList,
|
|
38
39
|
loading = _useContext2.loading,
|
|
39
40
|
setLoading = _useContext2.setLoading,
|
|
40
41
|
afterEditTarget = _useContext2.afterEditTarget,
|
|
41
|
-
onChangeUrlParam = _useContext2.onChangeUrlParam
|
|
42
|
+
onChangeUrlParam = _useContext2.onChangeUrlParam,
|
|
43
|
+
panelId = _useContext2.panelId,
|
|
44
|
+
setShowListHome = _useContext2.setShowListHome,
|
|
45
|
+
setRefreshLoading = _useContext2.setRefreshLoading,
|
|
46
|
+
setCompletedSearchData = _useContext2.setCompletedSearchData;
|
|
42
47
|
var _useState = useState(),
|
|
43
48
|
_useState2 = _slicedToArray(_useState, 2),
|
|
44
49
|
eventData = _useState2[0],
|
|
45
50
|
setEventData = _useState2[1];
|
|
46
|
-
var _useState3 = useState(
|
|
51
|
+
var _useState3 = useState(false),
|
|
47
52
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
48
|
-
|
|
49
|
-
|
|
53
|
+
enableSelectChart = _useState4[0],
|
|
54
|
+
setEnableSelectChart = _useState4[1];
|
|
50
55
|
var _useState5 = useState(false),
|
|
51
56
|
_useState6 = _slicedToArray(_useState5, 2),
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
var _useState7 = useState(
|
|
57
|
+
isCity = _useState6[0],
|
|
58
|
+
setIsCity = _useState6[1];
|
|
59
|
+
var _useState7 = useState(props.value.id),
|
|
55
60
|
_useState8 = _slicedToArray(_useState7, 2),
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
var _useState9 = useState(
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
61
|
+
eventId = _useState8[0],
|
|
62
|
+
setEventId = _useState8[1];
|
|
63
|
+
var _useState9 = useState(true),
|
|
64
|
+
_useState0 = _slicedToArray(_useState9, 2),
|
|
65
|
+
first = _useState0[0],
|
|
66
|
+
setFirst = _useState0[1];
|
|
62
67
|
var _useContext3 = useContext(BizTargetFromPanelContext),
|
|
63
|
-
handleSearch = _useContext3.handleSearch
|
|
64
|
-
|
|
68
|
+
handleSearch = _useContext3.handleSearch,
|
|
69
|
+
disabled = _useContext3.disabled;
|
|
70
|
+
var topPanelRef = useRef();
|
|
71
|
+
useImperativeHandle(ref, function () {
|
|
72
|
+
return {
|
|
73
|
+
onFormSetFieldsValue: function onFormSetFieldsValue(data) {
|
|
74
|
+
var _topPanelRef$current;
|
|
75
|
+
topPanelRef === null || topPanelRef === void 0 ? void 0 : (_topPanelRef$current = topPanelRef.current) === null || _topPanelRef$current === void 0 ? void 0 : _topPanelRef$current.onFormSetFieldsValue(data);
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
});
|
|
65
79
|
var chartRef = useRef();
|
|
66
|
-
var
|
|
80
|
+
var _useState1 = useState('user'),
|
|
81
|
+
_useState10 = _slicedToArray(_useState1, 2),
|
|
82
|
+
analysisSubjectType = _useState10[0],
|
|
83
|
+
setAnalysisSubjectType = _useState10[1];
|
|
84
|
+
var _useState11 = useState(false),
|
|
67
85
|
_useState12 = _slicedToArray(_useState11, 2),
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
var _useState13 = useState(
|
|
71
|
-
_useState14 = _slicedToArray(_useState13, 2),
|
|
72
|
-
subDisplay = _useState14[0],
|
|
73
|
-
setSubDisplay = _useState14[1];
|
|
74
|
-
var _useState15 = useState(true),
|
|
75
|
-
_useState16 = _slicedToArray(_useState15, 2),
|
|
76
|
-
isFirst = _useState16[0],
|
|
77
|
-
setIsFirst = _useState16[1];
|
|
78
|
-
var _useState17 = useState({
|
|
86
|
+
subDisplay = _useState12[0],
|
|
87
|
+
setSubDisplay = _useState12[1];
|
|
88
|
+
var _useState13 = useState({
|
|
79
89
|
analysisIndex: ((_props$value = props.value) === null || _props$value === void 0 ? void 0 : _props$value.analysisIndex) || 'number',
|
|
80
90
|
analysisAttr: (_props$value2 = props.value) === null || _props$value2 === void 0 ? void 0 : _props$value2.analysisAttr
|
|
81
91
|
}),
|
|
82
|
-
|
|
83
|
-
dimension =
|
|
84
|
-
setDimension =
|
|
92
|
+
_useState14 = _slicedToArray(_useState13, 2),
|
|
93
|
+
dimension = _useState14[0],
|
|
94
|
+
setDimension = _useState14[1];
|
|
85
95
|
useEffect(function () {
|
|
86
96
|
if (timer) clearTimeout(timer);
|
|
87
97
|
var flag = true;
|
|
@@ -96,6 +106,7 @@ var EventContent = function EventContent(props) {
|
|
|
96
106
|
};
|
|
97
107
|
}, [searchData]);
|
|
98
108
|
useEffect(function () {
|
|
109
|
+
if (disabled) return;
|
|
99
110
|
handleSearch && handleSearch(loading);
|
|
100
111
|
}, [loading]);
|
|
101
112
|
useEffect(function () {
|
|
@@ -120,48 +131,81 @@ var EventContent = function EventContent(props) {
|
|
|
120
131
|
if (flag !== undefined) ajaxFlag = flag;
|
|
121
132
|
if (analysisSubjectType === 'eventProp' && !searchData.analysisSubject) return;
|
|
122
133
|
if (!ajaxFlag) return;
|
|
123
|
-
setLoading(true);
|
|
134
|
+
if (!refresh) setLoading(true);
|
|
124
135
|
setEventData(undefined);
|
|
125
136
|
if (typeof cancel === 'function') {
|
|
126
137
|
cancel();
|
|
127
138
|
}
|
|
128
139
|
ajax(Apis.dataList, {
|
|
129
140
|
method: 'post',
|
|
130
|
-
data: _objectSpread({
|
|
141
|
+
data: _objectSpread(_objectSpread({
|
|
131
142
|
appId: currentApp === null || currentApp === void 0 ? void 0 : currentApp.appId,
|
|
132
143
|
platform: (searchData === null || searchData === void 0 ? void 0 : searchData.platform) || 0
|
|
133
|
-
}, searchData),
|
|
144
|
+
}, searchData), {}, {
|
|
145
|
+
refresh: refresh
|
|
146
|
+
}),
|
|
134
147
|
cancelToken: new CancelToken(function executor(c) {
|
|
135
148
|
cancel = c;
|
|
136
149
|
})
|
|
137
150
|
}).then(function (res) {
|
|
138
|
-
var _searchData$userGroup
|
|
151
|
+
var _searchData$userGroup;
|
|
152
|
+
setCompletedSearchData && setCompletedSearchData(searchData);
|
|
153
|
+
setRefreshLoading(false);
|
|
139
154
|
if (!res) {
|
|
140
155
|
setLoading(false);
|
|
141
156
|
return;
|
|
142
157
|
}
|
|
143
158
|
var result = res.data;
|
|
159
|
+
if (!(result === null || result === void 0 ? void 0 : result.series.length)) {
|
|
160
|
+
setLoading(false);
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
144
163
|
var _data = searchData.dimension ? result : getChartDataEventAliasName(result, eventGroupList);
|
|
164
|
+
var gLen = (searchData === null || searchData === void 0 ? void 0 : searchData.dimension) ? 1 : 0;
|
|
165
|
+
var dataTemp = formTableData(_data, (searchData === null || searchData === void 0 ? void 0 : searchData.userGroup) || [0], gLen);
|
|
166
|
+
var _sortData = [];
|
|
145
167
|
if (['bar', 'pie', 'map'].indexOf(searchData.chartType) !== -1) {
|
|
146
168
|
_data = getSortData(_data);
|
|
169
|
+
} else {
|
|
170
|
+
var _data2, _data2$series$;
|
|
171
|
+
_sortData = sortOriginalData(dataTemp, {
|
|
172
|
+
columnKey: "field".concat(((_data2 = _data) === null || _data2 === void 0 ? void 0 : (_data2$series$ = _data2.series[0]) === null || _data2$series$ === void 0 ? void 0 : _data2$series$.values.length) - 1),
|
|
173
|
+
order: 'descend'
|
|
174
|
+
});
|
|
147
175
|
}
|
|
148
176
|
if (searchData && (searchData === null || searchData === void 0 ? void 0 : searchData.userGroup) && (searchData === null || searchData === void 0 ? void 0 : (_searchData$userGroup = searchData.userGroup) === null || _searchData$userGroup === void 0 ? void 0 : _searchData$userGroup.length) > 1) {
|
|
149
177
|
_data = getUserGroupsCompareData(_data);
|
|
150
178
|
}
|
|
151
|
-
if (
|
|
152
|
-
|
|
179
|
+
if (first) {
|
|
180
|
+
setFirst(false);
|
|
153
181
|
} else {
|
|
154
|
-
var
|
|
155
|
-
|
|
156
|
-
|
|
182
|
+
var _showlist = [];
|
|
183
|
+
_sortData.forEach(function (item, index) {
|
|
184
|
+
if (index < 10) {
|
|
185
|
+
_showlist.push(item.nameGroup);
|
|
186
|
+
}
|
|
187
|
+
});
|
|
188
|
+
setShowListHome(_showlist);
|
|
157
189
|
}
|
|
158
190
|
setEventData(_data);
|
|
159
191
|
onChangeUrlParam(searchData);
|
|
160
192
|
setLoading(false);
|
|
161
193
|
});
|
|
162
194
|
};
|
|
195
|
+
var refreshHandle = function refreshHandle() {
|
|
196
|
+
refresh = true;
|
|
197
|
+
setRefreshLoading(true);
|
|
198
|
+
if (timer) clearTimeout(timer);
|
|
199
|
+
timer = setTimeout(function () {
|
|
200
|
+
fetchRequest();
|
|
201
|
+
refresh = false;
|
|
202
|
+
clearTimeout(timer);
|
|
203
|
+
}, 500);
|
|
204
|
+
};
|
|
163
205
|
var onChangeContent = function onChangeContent(data) {
|
|
206
|
+
var _topPanelRef$current2;
|
|
164
207
|
ajaxFlag = true;
|
|
208
|
+
(_topPanelRef$current2 = topPanelRef.current) === null || _topPanelRef$current2 === void 0 ? void 0 : _topPanelRef$current2.submit();
|
|
165
209
|
setSearchData(function (value) {
|
|
166
210
|
return _objectSpread(_objectSpread(_objectSpread({}, value), data), {}, {
|
|
167
211
|
analysisAttr: data.analysisAttr,
|
|
@@ -169,12 +213,10 @@ var EventContent = function EventContent(props) {
|
|
|
169
213
|
});
|
|
170
214
|
});
|
|
171
215
|
};
|
|
172
|
-
var onChangeShow = function onChangeShow(data) {
|
|
173
|
-
setShowList(data);
|
|
174
|
-
props.onChangeShow && props.onChangeShow(data);
|
|
175
|
-
};
|
|
176
216
|
var platformChange = function platformChange(data) {
|
|
217
|
+
var _topPanelRef$current3;
|
|
177
218
|
ajaxFlag = true;
|
|
219
|
+
(_topPanelRef$current3 = topPanelRef.current) === null || _topPanelRef$current3 === void 0 ? void 0 : _topPanelRef$current3.submit();
|
|
178
220
|
setSearchData(function (_searchData) {
|
|
179
221
|
return _objectSpread(_objectSpread({}, _searchData), {}, {
|
|
180
222
|
platform: data
|
|
@@ -215,19 +257,12 @@ var EventContent = function EventContent(props) {
|
|
|
215
257
|
};
|
|
216
258
|
if (afterEditTarget) afterEditTarget('report', params);
|
|
217
259
|
};
|
|
218
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(
|
|
219
|
-
|
|
220
|
-
searchData: searchData,
|
|
221
|
-
platformChange: platformChange,
|
|
222
|
-
enableSelectChart: enableSelectChart,
|
|
223
|
-
showList: showList,
|
|
224
|
-
onClickGenerateReport: onClickGenerateReport
|
|
225
|
-
}), /*#__PURE__*/React.createElement(BizLayout, {
|
|
226
|
-
showTitle: false,
|
|
260
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(BizLayout, {
|
|
261
|
+
showTitle: !panelId,
|
|
227
262
|
hasCollapse: true,
|
|
228
|
-
collapseRef:
|
|
263
|
+
collapseRef: topPanelRef === null || topPanelRef === void 0 ? void 0 : (_topPanelRef$current4 = topPanelRef.current) === null || _topPanelRef$current4 === void 0 ? void 0 : _topPanelRef$current4.getCollapseRef(),
|
|
229
264
|
topPanel: /*#__PURE__*/React.createElement(TopPanel, {
|
|
230
|
-
ref:
|
|
265
|
+
ref: topPanelRef,
|
|
231
266
|
onChange: onChangeSearch,
|
|
232
267
|
loading: loading,
|
|
233
268
|
value: searchData,
|
|
@@ -235,6 +270,13 @@ var EventContent = function EventContent(props) {
|
|
|
235
270
|
setIsCity: setIsCity,
|
|
236
271
|
setEnableSelectChart: setEnableSelectChart,
|
|
237
272
|
onChangeSubjectType: onChangeSubjectType
|
|
273
|
+
}),
|
|
274
|
+
toolbar: /*#__PURE__*/React.createElement(TopBar, {
|
|
275
|
+
eventData: eventData,
|
|
276
|
+
searchData: searchData,
|
|
277
|
+
platformChange: platformChange,
|
|
278
|
+
enableSelectChart: enableSelectChart,
|
|
279
|
+
onClickGenerateReport: onClickGenerateReport
|
|
238
280
|
})
|
|
239
281
|
}, /*#__PURE__*/React.createElement("div", {
|
|
240
282
|
className: classPrefix
|
|
@@ -248,14 +290,13 @@ var EventContent = function EventContent(props) {
|
|
|
248
290
|
onChange: onChangeContent,
|
|
249
291
|
dimension: dimension,
|
|
250
292
|
setDimension: setDimension,
|
|
251
|
-
analysisSubjectType: analysisSubjectType
|
|
293
|
+
analysisSubjectType: analysisSubjectType,
|
|
294
|
+
refreshHandle: refreshHandle
|
|
252
295
|
}), /*#__PURE__*/React.createElement(ContentPanel, {
|
|
253
296
|
ref: chartRef,
|
|
254
297
|
isCity: isCity,
|
|
255
298
|
eventData: eventData,
|
|
256
|
-
searchData: searchData
|
|
257
|
-
showList: showList,
|
|
258
|
-
onChangeShow: onChangeShow
|
|
299
|
+
searchData: searchData
|
|
259
300
|
}))));
|
|
260
|
-
};
|
|
301
|
+
});
|
|
261
302
|
export default EventContent;
|