@zgfe/modules-interval 1.0.3-alpha.14 → 1.0.3-alpha.16

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.
@@ -12,7 +12,7 @@ function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefine
12
12
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
13
13
  import { Switch, Tooltip, message } from 'antd';
14
14
  import React, { useEffect, useRef, useState } from 'react';
15
- import { BizEventSelector, IconFont, BizAttrConditionGroup, useChanged } from '@zgfe/business-lib';
15
+ import { BizEventSelector, IconFont, BizAttrConditionGroup } from '@zgfe/business-lib';
16
16
  import "./styles/index.less";
17
17
  import _ from 'lodash';
18
18
  var classPrefix = 'interval-box';
@@ -59,7 +59,7 @@ var EventFilter = function EventFilter(props) {
59
59
  setBizAttributeSelectorValue = _useState14[1];
60
60
 
61
61
  // 初始化
62
- useChanged(function () {
62
+ useEffect(function () {
63
63
  if (props.value) {
64
64
  var _data = props.value;
65
65
  if (_data && _data.id) {
@@ -80,17 +80,8 @@ var EventFilter = function EventFilter(props) {
80
80
  key: _data.dimension.propCategory === 'eventProp' ? _data.dimension.value : _data.dimension.propCategory + '-' + _data.dimension.value
81
81
  }));
82
82
  }
83
- } else {
84
- setEvent({
85
- id: null,
86
- name: ''
87
- });
88
- setEventOverview(false);
89
- setFilter(undefined);
90
- setBizAttributeSelectorValue(undefined);
91
- setRelevancy(false);
92
83
  }
93
- }, props.value);
84
+ }, []);
94
85
 
95
86
  // 添加筛选
96
87
  var onAdd = function onAdd() {
@@ -207,7 +198,7 @@ var EventFilter = function EventFilter(props) {
207
198
  ref: conditionRef,
208
199
  value: filter,
209
200
  enableEventProp: true,
210
- enableUserProp: props.subject ? false : true,
201
+ enableUserProp: props.analysisType === 'user',
211
202
  enableDelete: true,
212
203
  eventIdList: [event.id],
213
204
  onChange: onChangeFilters,
@@ -50,5 +50,6 @@ export interface EventFilterProps {
50
50
  relevancyFl?: boolean;
51
51
  relevancy?: boolean;
52
52
  subject?: SubjectTypes.Subject;
53
+ analysisType?: 'user' | 'eventProp';
53
54
  onChange?: (event: eventProps) => {};
54
55
  }
@@ -56,14 +56,10 @@ var EventContent = function EventContent(props) {
56
56
  _useState12 = _slicedToArray(_useState11, 2),
57
57
  isCity = _useState12[0],
58
58
  setIsCity = _useState12[1];
59
- var _useState13 = useState(false),
59
+ var _useState13 = useState(-1),
60
60
  _useState14 = _slicedToArray(_useState13, 2),
61
- ajaxFlag = _useState14[0],
62
- setAjaxFlag = _useState14[1];
63
- var _useState15 = useState(-1),
64
- _useState16 = _slicedToArray(_useState15, 2),
65
- eventId = _useState16[0],
66
- setEventId = _useState16[1];
61
+ eventId = _useState14[0],
62
+ setEventId = _useState14[1];
67
63
  var _useContext2 = useContext(IntervalContext),
68
64
  searchData = _useContext2.searchData,
69
65
  setSearchData = _useContext2.setSearchData,
@@ -72,11 +68,17 @@ var EventContent = function EventContent(props) {
72
68
  userPropList = _useContext2.userPropList;
73
69
  var _useContext3 = useContext(BizTargetFromPanelContext),
74
70
  handleSearch = _useContext3.handleSearch;
71
+ var _useState15 = useState(),
72
+ _useState16 = _slicedToArray(_useState15, 2),
73
+ searchTimer = _useState16[0],
74
+ setSearchTimer = _useState16[1];
75
75
  var collapseRef = useRef();
76
76
  // 初始化
77
77
  useEffect(function () {
78
78
  if (props.defaultValue) {
79
79
  setEventId(props.defaultValue.id);
80
+ } else {
81
+ setLoading(false);
80
82
  }
81
83
  }, [props.defaultValue]);
82
84
  useEffect(function () {
@@ -89,42 +91,27 @@ var EventContent = function EventContent(props) {
89
91
  }
90
92
  }
91
93
  if (!searchData || !searchData.analysisModel) return;
92
- if (timer) clearTimeout(timer);
93
- var flag = true;
94
- timer = setTimeout(function () {
95
- if (flag) {
96
- fetchRequest(false);
97
- }
98
- }, 500);
94
+ if (searchTimer) clearTimeout(searchTimer);
95
+ setSearchTimer(setTimeout(function () {
96
+ fetchRequest();
97
+ }, 300));
99
98
  return function () {
100
- // 清理异步任务
101
- if (timer) clearTimeout(timer);
102
- flag = false;
99
+ clearTimeout(searchTimer);
103
100
  };
104
101
  }, [searchData]);
105
102
  useEffect(function () {
106
103
  handleSearch && handleSearch(loading);
107
104
  }, [loading]);
108
- useEffect(function () {
109
- if (ajaxFlag) {
110
- fetchRequest(true);
111
- }
112
- }, [ajaxFlag]);
105
+
113
106
  // 查询
114
- var fetchRequest = function fetchRequest(flag) {
107
+ var fetchRequest = function fetchRequest() {
115
108
  var _searchData$start, _searchData$end, _searchData$associate, _searchData$associate2, _searchData$associate3;
116
- if (flag !== undefined) setAjaxFlag(flag);
117
- if (!ajaxFlag) return;
118
109
  if ((searchData === null || searchData === void 0 ? void 0 : (_searchData$start = searchData.start) === null || _searchData$start === void 0 ? void 0 : _searchData$start.id) === null || (searchData === null || searchData === void 0 ? void 0 : (_searchData$end = searchData.end) === null || _searchData$end === void 0 ? void 0 : _searchData$end.id) === null) {
119
110
  setLoading(false);
120
111
  return;
121
112
  }
122
113
  setEventData(undefined);
123
114
  setLoading(true);
124
- // 取消上次未完成的请求
125
- // if (typeof cancel === 'function') {
126
- // cancel();
127
- // }
128
115
  if (searchData !== null && searchData !== void 0 && (_searchData$associate = searchData.associatedNextAttr) !== null && _searchData$associate !== void 0 && _searchData$associate.type && (searchData === null || searchData === void 0 ? void 0 : (_searchData$associate2 = searchData.associatedPreAttr) === null || _searchData$associate2 === void 0 ? void 0 : _searchData$associate2.type) !== (searchData === null || searchData === void 0 ? void 0 : (_searchData$associate3 = searchData.associatedNextAttr) === null || _searchData$associate3 === void 0 ? void 0 : _searchData$associate3.type)) {
129
116
  setLoading(false);
130
117
  return message.error('您查询的属性不一致,暂不支持查询');
@@ -160,7 +147,6 @@ var EventContent = function EventContent(props) {
160
147
  setSearchData(function (value) {
161
148
  return _objectSpread(_objectSpread({}, value), data);
162
149
  });
163
- setAjaxFlag(true);
164
150
  };
165
151
 
166
152
  // 改变显示内容
@@ -175,9 +161,6 @@ var EventContent = function EventContent(props) {
175
161
  platform: data
176
162
  });
177
163
  });
178
- setTimeout(function () {
179
- setAjaxFlag(true);
180
- }, 100);
181
164
  };
182
165
 
183
166
  // TopPanel组件数值变更
@@ -189,7 +172,6 @@ var EventContent = function EventContent(props) {
189
172
  analysisSubject: data.analysisSubject ? data.analysisSubject : undefined
190
173
  });
191
174
  });
192
- setAjaxFlag(false);
193
175
  };
194
176
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(TopBar, {
195
177
  searchData: searchData,
@@ -206,10 +188,8 @@ var EventContent = function EventContent(props) {
206
188
  collapseRef: collapseRef,
207
189
  onChange: onChangeSearch,
208
190
  defaultValue: searchData,
209
- ajaxFlag: ajaxFlag,
210
191
  loading: loading,
211
- finalSearchData: finalSearchData,
212
- fetchRequest: fetchRequest
192
+ finalSearchData: finalSearchData
213
193
  })
214
194
  }, /*#__PURE__*/React.createElement("div", {
215
195
  className: classPrefix
@@ -19,12 +19,11 @@ import { AnalysisMode } from "./types";
19
19
  import { IntervalContext } from "../../types";
20
20
  var classPrefix = 'top-panel-interval';
21
21
  var TopPanel = function TopPanel(props) {
22
- var _props$defaultValue, _props$defaultValue2, _props$defaultValue3, _defaultValue$associa, _defaultValue$associa2, _finalSearchData$asso, _finalSearchData$asso2, _defaultValue$associa3, _finalSearchData$asso3, _defaultValue$associa4, _finalSearchData$asso4, _defaultValue$associa5, _finalSearchData$asso5, _defaultValue$associa6, _finalSearchData$asso6, _defaultValue$associa7, _finalSearchData$asso7, _defaultValue$associa8, _finalSearchData$asso8, _defaultValue$associa9, _finalSearchData$asso9, _defaultValue$associa10, _finalSearchData$asso10, _defaultValue$dimensi, _finalSearchData$dime, _defaultValue$dimensi2, _finalSearchData$dime2, _defaultValue$dimensi3, _finalSearchData$dime3, _defaultValue$dimensi4, _finalSearchData$dime4;
22
+ var _props$defaultValue, _props$defaultValue2, _props$defaultValue3, _defaultValue$associa, _defaultValue$associa2, _finalSearchData$asso, _finalSearchData$asso2, _defaultValue$associa3, _finalSearchData$asso3, _defaultValue$associa4, _finalSearchData$asso4, _defaultValue$associa5, _finalSearchData$asso5, _defaultValue$associa6, _finalSearchData$asso6, _defaultValue$associa7, _finalSearchData$asso7, _defaultValue$associa8, _finalSearchData$asso8, _defaultValue$associa9, _finalSearchData$asso9, _defaultValue$associa10, _finalSearchData$asso10, _defaultValue$dimensi, _finalSearchData$dime, _defaultValue$dimensi2, _finalSearchData$dime2, _defaultValue$dimensi3, _finalSearchData$dime3, _defaultValue$dimensi4, _finalSearchData$dime4, _currentParams$start2, _currentParams$end2, _currentParams$start3, _currentParams$end3;
23
23
  var defaultValue = props.defaultValue,
24
24
  loading = props.loading,
25
25
  collapseRef = props.collapseRef,
26
- finalSearchData = props.finalSearchData,
27
- fetchRequest = props.fetchRequest;
26
+ finalSearchData = props.finalSearchData;
28
27
  var _Form$useForm = Form.useForm(),
29
28
  _Form$useForm2 = _slicedToArray(_Form$useForm, 1),
30
29
  form = _Form$useForm2[0];
@@ -69,6 +68,14 @@ var TopPanel = function TopPanel(props) {
69
68
  _useState16 = _slicedToArray(_useState15, 2),
70
69
  inited = _useState16[0],
71
70
  setInited = _useState16[1];
71
+ var _useState17 = useState(),
72
+ _useState18 = _slicedToArray(_useState17, 2),
73
+ currentParams = _useState18[0],
74
+ setCurrentParams = _useState18[1];
75
+ var _useState19 = useState(true),
76
+ _useState20 = _slicedToArray(_useState19, 2),
77
+ searchDisabled = _useState20[0],
78
+ setSearchDisabled = _useState20[1];
72
79
  // 用户组和事件变更
73
80
  var onValuesChange = function onValuesChange(data, allData) {
74
81
  var _data = {};
@@ -95,15 +102,36 @@ var TopPanel = function TopPanel(props) {
95
102
  _data.userGroup = allData.userGroup;
96
103
  if (_data.userGroup.length <= 0) _data.userGroup = [0];
97
104
  }
98
- props.onChange(_objectSpread(_objectSpread({}, allData), {}, {
105
+ setCurrentParams(_objectSpread(_objectSpread({}, allData), {}, {
99
106
  analysisSubject: allData.analysisSubject ? {
100
107
  subjectId: allData.analysisSubject.id,
101
108
  subjectName: allData.analysisSubject.subjectName,
102
109
  subjectAlias: allData.analysisSubject.subjectAlias,
103
110
  unit: allData.analysisSubject.unit
104
111
  } : undefined
105
- }), (finalSearchData === null || finalSearchData === void 0 ? void 0 : finalSearchData.chartType) === 'boxplot' ? true : false);
112
+ }));
106
113
  };
114
+ useEffect(function () {
115
+ var _currentParams$start, _currentParams$start$, _currentParams$start$2, _currentParams$end, _currentParams$end$fi, _currentParams$end$fi2;
116
+ var conditionValid = true;
117
+ currentParams === null || currentParams === void 0 ? void 0 : (_currentParams$start = currentParams.start) === null || _currentParams$start === void 0 ? void 0 : (_currentParams$start$ = _currentParams$start.filters) === null || _currentParams$start$ === void 0 ? void 0 : (_currentParams$start$2 = _currentParams$start$.conditions) === null || _currentParams$start$2 === void 0 ? void 0 : _currentParams$start$2.forEach(function (item) {
118
+ var _item$values;
119
+ if (!/null/.test(item.operator || '') && !((_item$values = item.values) !== null && _item$values !== void 0 && _item$values.length)) {
120
+ conditionValid = false;
121
+ }
122
+ });
123
+ currentParams === null || currentParams === void 0 ? void 0 : (_currentParams$end = currentParams.end) === null || _currentParams$end === void 0 ? void 0 : (_currentParams$end$fi = _currentParams$end.filters) === null || _currentParams$end$fi === void 0 ? void 0 : (_currentParams$end$fi2 = _currentParams$end$fi.conditions) === null || _currentParams$end$fi2 === void 0 ? void 0 : _currentParams$end$fi2.forEach(function (item) {
124
+ var _item$values2;
125
+ if (!/null/.test(item.operator || '') && !((_item$values2 = item.values) !== null && _item$values2 !== void 0 && _item$values2.length)) {
126
+ conditionValid = false;
127
+ }
128
+ });
129
+ if (loading || !(currentParams !== null && currentParams !== void 0 && currentParams.start) || !(currentParams !== null && currentParams !== void 0 && currentParams.start.id) || !(currentParams !== null && currentParams !== void 0 && currentParams.end) || !(currentParams !== null && currentParams !== void 0 && currentParams.end.id) || !conditionValid || relevancy && !(currentParams !== null && currentParams !== void 0 && currentParams.associatedNextAttr) && !(currentParams !== null && currentParams !== void 0 && currentParams.associatedNextAttr) || analysisType === 'eventProp' && !currentSubject) {
130
+ setSearchDisabled(true);
131
+ } else {
132
+ setSearchDisabled(false);
133
+ }
134
+ }, [currentParams]);
107
135
  var resetting = function resetting() {
108
136
  form.resetFields();
109
137
  form.setFieldsValue({
@@ -249,6 +277,7 @@ var TopPanel = function TopPanel(props) {
249
277
  keyField: "id",
250
278
  onChange: function onChange(val) {
251
279
  setCurrentSubject(val);
280
+ setRelevancy(false);
252
281
  form.setFieldsValue({
253
282
  start: undefined,
254
283
  end: undefined
@@ -274,7 +303,8 @@ var TopPanel = function TopPanel(props) {
274
303
  subject: currentSubject,
275
304
  relevancyFl: relevancyFl,
276
305
  relevancy: true,
277
- key: "begin"
306
+ key: "".concat(currentSubject === null || currentSubject === void 0 ? void 0 : currentSubject.subjectName, "-start"),
307
+ analysisType: analysisType
278
308
  })), relevancy ? /*#__PURE__*/React.createElement(Form.Item, {
279
309
  className: "associated"
280
310
  }, /*#__PURE__*/React.createElement("span", {
@@ -300,6 +330,7 @@ var TopPanel = function TopPanel(props) {
300
330
  value: bizAttributeSelectorValue,
301
331
  enableDelete: true,
302
332
  onChange: onChangeAttr,
333
+ key: "".concat(currentParams === null || currentParams === void 0 ? void 0 : (_currentParams$start2 = currentParams.start) === null || _currentParams$start2 === void 0 ? void 0 : _currentParams$start2.id, "-").concat(currentParams === null || currentParams === void 0 ? void 0 : (_currentParams$end2 = currentParams.end) === null || _currentParams$end2 === void 0 ? void 0 : _currentParams$end2.id, "-pre"),
303
334
  onDelete: function onDelete() {
304
335
  onChangeAttr(undefined, 'associatedPreAttr');
305
336
  }
@@ -318,6 +349,7 @@ var TopPanel = function TopPanel(props) {
318
349
  value: bizAttributeSelectorValue,
319
350
  enableDelete: true,
320
351
  onChange: onChangeAttr,
352
+ key: "".concat(currentParams === null || currentParams === void 0 ? void 0 : (_currentParams$start3 = currentParams.start) === null || _currentParams$start3 === void 0 ? void 0 : _currentParams$start3.id, "-").concat(currentParams === null || currentParams === void 0 ? void 0 : (_currentParams$end3 = currentParams.end) === null || _currentParams$end3 === void 0 ? void 0 : _currentParams$end3.id, "-next"),
321
353
  onDelete: function onDelete() {
322
354
  onChangeAttr(undefined, 'associatedNextAttr');
323
355
  }
@@ -339,7 +371,8 @@ var TopPanel = function TopPanel(props) {
339
371
  name: "end"
340
372
  }, /*#__PURE__*/React.createElement(EventFilter, {
341
373
  subject: currentSubject,
342
- key: "end"
374
+ analysisType: analysisType,
375
+ key: "".concat(currentSubject === null || currentSubject === void 0 ? void 0 : currentSubject.subjectName, "-start")
343
376
  })), /*#__PURE__*/React.createElement(Form.Item, {
344
377
  label: "\u6309\u5C5E\u6027\u7EC6\u5206",
345
378
  name: "dimension",
@@ -348,6 +381,7 @@ var TopPanel = function TopPanel(props) {
348
381
  enableEventProp: true,
349
382
  enableUserProp: analysisType === 'user',
350
383
  enableEnvProp: true,
384
+ key: "".concat(currentSubject === null || currentSubject === void 0 ? void 0 : currentSubject.subjectName, "-dimension"),
351
385
  eventIdList: startId === endId ? [startId] : [startId, endId],
352
386
  value: bizAttributeSelectorValue,
353
387
  enableDelete: true,
@@ -369,10 +403,10 @@ var TopPanel = function TopPanel(props) {
369
403
  onClick: resetting
370
404
  }, "\u91CD\u7F6E"), /*#__PURE__*/React.createElement(Button, {
371
405
  loading: loading || subjectLoading,
372
- disabled: loading || !startId || !endId || relevancy && !(defaultValue !== null && defaultValue !== void 0 && defaultValue.associatedNextAttr) && !(defaultValue !== null && defaultValue !== void 0 && defaultValue.associatedNextAttr),
406
+ disabled: searchDisabled,
373
407
  type: "primary",
374
408
  onClick: function onClick() {
375
- fetchRequest(true);
409
+ props.onChange(currentParams, (finalSearchData === null || finalSearchData === void 0 ? void 0 : finalSearchData.chartType) === 'boxplot' ? true : false);
376
410
  }
377
411
  }, "\u67E5\u8BE2"))));
378
412
  };
@@ -19,13 +19,13 @@
19
19
  .panel-form-interval {
20
20
  &-item {
21
21
  .ant-form-item-label {
22
- padding-left: 24px;
22
+ padding-left: 24px !important;
23
23
  font-weight: 500;
24
24
  }
25
25
  .ant-form-item-control-input-content {
26
26
  height: 40px;
27
- padding: 0 24px;
28
- line-height: 40px;
27
+ padding: 0 24px !important;
28
+ line-height: 40px !important;
29
29
  .biz-select-handle {
30
30
  display: inline-block;
31
31
  width: 208px;
@@ -47,17 +47,9 @@ export interface TopPanelProps {
47
47
  * 数据更新
48
48
  */
49
49
  onChange: (data: SearchValue, flag: boolean) => void;
50
- /**
51
- * 是否请求数据
52
- */
53
- ajaxFlag: boolean;
54
50
  /**
55
51
  * 请求后的最新查询数据
56
52
  */
57
53
  finalSearchData?: SearchValue;
58
- /**
59
- * 请求数据方法
60
- */
61
- fetchRequest: (flag?: boolean) => void;
62
54
  collapseRef?: any;
63
55
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zgfe/modules-interval",
3
- "version": "1.0.3-alpha.14",
3
+ "version": "1.0.3-alpha.16",
4
4
  "scripts": {
5
5
  "start": "dumi dev",
6
6
  "docs:build": "dumi build",
@@ -62,5 +62,5 @@
62
62
  "umi-request": "^1.4.0",
63
63
  "yorkie": "^2.0.0"
64
64
  },
65
- "gitHead": "9d0b2cc2d9ac5ff219a0d7fde2d96acb1dcfc22a"
65
+ "gitHead": "077b080775af77fc27177df447fbf795afd8a021"
66
66
  }