@zgfe/modules-event 0.1.5-event.5 → 0.1.5-event.51

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.
@@ -1,39 +1,43 @@
1
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
2
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
3
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
4
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
5
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
6
+ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
1
7
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
2
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."); }
3
9
  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
10
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
5
- function _iterableToArrayLimit(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; } }
11
+ function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
6
12
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
7
- import React, { useState } from 'react';
13
+ import React, { useState, useEffect } from 'react';
8
14
  import { Form, Button } from 'antd';
9
- import { BizUserGroupHeader, BizSelect } from '@zgfe/business-lib';
15
+ import { BizUserGroupHeader, BizSelect, useSubject } from '@zgfe/business-lib';
10
16
  import EventFilter from '../../components/eventFilter';
11
17
  import './styles/index.less';
18
+ import _ from 'lodash';
12
19
  var classPrefix = 'top-panel';
13
20
  var TopPanel = /*#__PURE__*/React.forwardRef(function (props, ref) {
14
21
  var value = props.value,
15
- ajaxFlag = props.ajaxFlag,
16
- finalSearchData = props.finalSearchData,
17
- fetchRequest = props.fetchRequest,
18
22
  setIsCity = props.setIsCity,
19
23
  setEnableSelectChart = props.setEnableSelectChart,
20
- allSubjectList = props.allSubjectList,
21
- subDisplay = props.subDisplay;
24
+ subDisplay = props.subDisplay,
25
+ loading = props.loading;
22
26
  var _useState = useState(false),
23
27
  _useState2 = _slicedToArray(_useState, 2),
24
- searchDisabled = _useState2[0],
25
- setSearchDisabled = _useState2[1];
26
- var _useState3 = useState(false),
28
+ marginStyle = _useState2[0],
29
+ setmarginStyle = _useState2[1];
30
+ var _useState3 = useState('user'),
27
31
  _useState4 = _slicedToArray(_useState3, 2),
28
- marginStyle = _useState4[0],
29
- setmarginStyle = _useState4[1];
30
- var _useState5 = useState({
31
- value: 'user',
32
- label: '用户'
33
- }),
32
+ analysisType = _useState4[0],
33
+ setAnalysisType = _useState4[1];
34
+ var _useState5 = useState(false),
34
35
  _useState6 = _slicedToArray(_useState5, 2),
35
- analysisSubjectType = _useState6[0],
36
- setAnalysisSubjectType = _useState6[1];
36
+ inited = _useState6[0],
37
+ setInited = _useState6[1];
38
+ var _useSubject = useSubject(),
39
+ subjectList = _useSubject.subjectList,
40
+ subjectLoading = _useSubject.loading;
37
41
  var countChange = function countChange(count) {
38
42
  setmarginStyle(count > 0 ? true : false);
39
43
  };
@@ -41,135 +45,171 @@ var TopPanel = /*#__PURE__*/React.forwardRef(function (props, ref) {
41
45
  _Form$useForm2 = _slicedToArray(_Form$useForm, 1),
42
46
  form = _Form$useForm2[0];
43
47
  var userGroup = value.userGroup;
44
- var onValuesChange = function onValuesChange(data, allData) {
45
- var _data = {};
46
- if (allData.filterConditions) {
47
- if (allData.filterConditions.id !== -100) {
48
- _data = allData.filterConditions;
49
- }
50
- _data.eventGroupId = allData.filterConditions.eventGroupId;
51
- }
52
- if (allData.userGroup) {
53
- _data.userGroup = allData.userGroup.filter(function (item) {
54
- return item !== undefined;
55
- });
56
- if (_data.userGroup.length <= 0 || _data.userGroup.length === 1 && _data.userGroup[0].length <= 0) {
57
- _data.userGroup = [0];
58
- }
59
- }
60
- if (data.filterConditions) {
61
- if (finalSearchData && finalSearchData.id && data.filterConditions.id === finalSearchData.id && data.filterConditions.eventGroupId === finalSearchData.eventGroupId) {
62
- ajaxFlag = false;
63
- } else {
64
- ajaxFlag = true;
65
- }
66
- }
67
- if (data.analysisSubject && data.analysisSubject.subjectId) {
68
- _data.analysisSubject = {
69
- subjectId: data.analysisSubject.subjectId,
48
+ function onSearch(data) {
49
+ var _data$filterCondition, _data$filterCondition2, _data$filterCondition3;
50
+ var searchData = _objectSpread(_objectSpread({
51
+ analysisSubject: data.analysisSubject ? {
52
+ subjectId: data.analysisSubject.id || data.analysisSubject.subjectId,
70
53
  subjectName: data.analysisSubject.subjectName,
71
54
  subjectAlias: data.analysisSubject.subjectAlias,
72
55
  unit: data.analysisSubject.unit
73
- };
74
- }
75
- props.onChange(_data, ajaxFlag);
76
- };
56
+ } : undefined
57
+ }, _.isArray(data.filterConditions) ? {} : data.filterConditions), {}, {
58
+ eventIds: _.isArray(data.filterConditions) ? data.filterConditions : undefined,
59
+ eventGroupId: (_data$filterCondition = data.filterConditions) === null || _data$filterCondition === void 0 ? void 0 : _data$filterCondition.eventGroupId,
60
+ userGroup: data.userGroup || [0],
61
+ id: ((_data$filterCondition2 = data.filterConditions) === null || _data$filterCondition2 === void 0 ? void 0 : _data$filterCondition2.id) >= 0 ? (_data$filterCondition3 = data.filterConditions) === null || _data$filterCondition3 === void 0 ? void 0 : _data$filterCondition3.id : undefined
62
+ });
63
+ props.onChange(searchData, true);
64
+ }
77
65
  var resetting = function resetting() {
78
66
  form.resetFields();
79
67
  form.setFieldsValue({
80
68
  userGroup: [0],
81
- filterConditions: null,
82
- analysisSubject: null
69
+ filterConditions: null
83
70
  });
84
71
  props.onChange({
85
72
  userGroup: [0],
86
- analysisSubject: undefined,
87
73
  id: undefined,
88
74
  name: undefined,
89
75
  filters: undefined,
90
- dimension: undefined
76
+ dimension: undefined,
77
+ analysisAttr: undefined,
78
+ chartType: 'line'
91
79
  }, true);
92
80
  };
81
+ useEffect(function () {
82
+ if (!value) {
83
+ setInited(true);
84
+ return;
85
+ }
86
+ setInited(false);
87
+ if (value.analysisSubject) {
88
+ setAnalysisType('eventProp');
89
+ props.onChangeSubjectType('eventProp');
90
+ } else {
91
+ setAnalysisType('user');
92
+ props.onChangeSubjectType('user');
93
+ }
94
+ setInited(true);
95
+ }, []);
96
+ if (!inited) return null;
93
97
  return /*#__PURE__*/React.createElement(Form, {
94
98
  form: form,
95
99
  component: "div",
96
100
  colon: false,
97
101
  layout: "vertical",
102
+ className: "".concat(classPrefix, "-form"),
98
103
  initialValues: {
99
104
  userGroup: userGroup ? userGroup : [0],
100
- filterConditions: {
105
+ filterConditions: (value === null || value === void 0 ? void 0 : value.eventIds) || {
101
106
  id: value === null || value === void 0 ? void 0 : value.id,
102
107
  name: value === null || value === void 0 ? void 0 : value.name,
103
108
  dimension: value === null || value === void 0 ? void 0 : value.dimension,
104
109
  filters: value === null || value === void 0 ? void 0 : value.filters,
105
110
  eventGroupId: value === null || value === void 0 ? void 0 : value.eventGroupId
106
111
  },
107
- analysisSubject: {
108
- subjectId: 0,
109
- subjectName: '',
110
- subjectAlias: '',
111
- unit: ''
112
- }
112
+ analysisSubject: value === null || value === void 0 ? void 0 : value.analysisSubject
113
113
  },
114
114
  scrollToFirstError: true,
115
- onValuesChange: onValuesChange
115
+ onFinish: onSearch
116
116
  }, !subDisplay ? null : /*#__PURE__*/React.createElement(Form.Item, {
117
117
  label: "\u5206\u6790\u4E3B\u4F53",
118
- className: "".concat(classPrefix, "-form-event")
118
+ className: "".concat(classPrefix, "-form-event hoverable-form-item")
119
119
  }, /*#__PURE__*/React.createElement(BizSelect, {
120
120
  className: "".concat(classPrefix, "-form-event-select"),
121
121
  options: [{
122
- value: 'user',
123
- label: '用户'
122
+ label: '用户',
123
+ value: 'user'
124
124
  }, {
125
- value: 'event',
126
- label: '事件属性'
125
+ label: '事件属性',
126
+ value: 'eventProp'
127
127
  }],
128
128
  overlayWidth: 208,
129
- labelField: "label",
130
129
  keyField: "value",
131
- value: analysisSubjectType,
132
- onChange: function onChange(seleted) {
133
- props.onChangeSubjectType(seleted.value);
134
- setAnalysisSubjectType(seleted);
130
+ defaultValue: {
131
+ value: analysisType
132
+ },
133
+ onChange: function onChange(val) {
134
+ props.onChangeSubjectType(val.value);
135
+ setAnalysisType(val.value);
136
+ setEnableSelectChart && setEnableSelectChart(false);
137
+ setIsCity && setIsCity(false);
135
138
  resetting();
136
139
  }
137
- })), analysisSubjectType.value === 'user' ? /*#__PURE__*/React.createElement(Form.Item, {
140
+ })), analysisType === 'user' ? /*#__PURE__*/React.createElement(Form.Item, {
138
141
  label: "",
139
- name: "userGroup"
142
+ name: "userGroup",
143
+ className: "hoverable-form-item"
140
144
  }, /*#__PURE__*/React.createElement(BizUserGroupHeader, {
141
145
  max: 3,
142
146
  enableTags: true
143
147
  })) : /*#__PURE__*/React.createElement(Form.Item, {
144
148
  label: "\u4E3B\u4F53\u540D\u79F0",
145
149
  name: "analysisSubject",
146
- className: "".concat(classPrefix, "-form-event")
150
+ className: "".concat(classPrefix, "-form-event hoverable-form-item"),
151
+ rules: [{
152
+ validator: function validator(_rule, value) {
153
+ if (value && (value.id || value.subjectId)) {
154
+ return Promise.resolve();
155
+ } else {
156
+ return Promise.reject('请选择分析主体');
157
+ }
158
+ }
159
+ }]
147
160
  }, /*#__PURE__*/React.createElement(BizSelect, {
148
161
  className: "".concat(classPrefix, "-form-event-select"),
149
- options: allSubjectList || [],
150
- labelField: "name",
162
+ options: subjectList,
163
+ aliasField: "subjectAlias",
164
+ labelField: "subjectName",
151
165
  keyField: "id"
152
166
  })), /*#__PURE__*/React.createElement("div", {
153
167
  ref: ref
154
168
  }, /*#__PURE__*/React.createElement(Form.Item, {
155
169
  label: "\u4E8B\u4EF6",
156
170
  name: "filterConditions",
157
- className: "".concat(classPrefix, "-form-event")
171
+ className: "".concat(classPrefix, "-form-event event---1"),
172
+ rules: [{
173
+ validator: function validator(_rule, value) {
174
+ var _value$filters, _value$filters$condit;
175
+ if (_.isArray(value)) {
176
+ if (!value.length) {
177
+ return Promise.reject('请选择事件');
178
+ } else {
179
+ return Promise.resolve();
180
+ }
181
+ }
182
+ if (!value || !value.id) {
183
+ return Promise.reject('请选择事件');
184
+ }
185
+ var conditionValIsNull = false;
186
+ value === null || value === void 0 ? void 0 : (_value$filters = value.filters) === null || _value$filters === void 0 ? void 0 : (_value$filters$condit = _value$filters.conditions) === null || _value$filters$condit === void 0 ? void 0 : _value$filters$condit.forEach(function (item) {
187
+ var _item$values;
188
+ if (!/null/.test(item.operator || '') && !((_item$values = item.values) === null || _item$values === void 0 ? void 0 : _item$values.length)) {
189
+ conditionValIsNull = true;
190
+ }
191
+ });
192
+ if (conditionValIsNull) {
193
+ return Promise.reject('请填写完整的条件');
194
+ }
195
+ return Promise.resolve();
196
+ },
197
+ validateTrigger: 'onBlur'
198
+ }]
158
199
  }, /*#__PURE__*/React.createElement(EventFilter, {
159
- setSearchDisabled: setSearchDisabled,
160
200
  countChange: countChange,
161
201
  setIsCity: setIsCity,
162
202
  setEnableSelectChart: setEnableSelectChart,
163
- analysisSubjectType: analysisSubjectType.value
203
+ analysisType: analysisType
164
204
  })), /*#__PURE__*/React.createElement("div", {
165
205
  className: "".concat(classPrefix, "-form-botton-box ").concat(marginStyle ? 'margin-style' : '')
166
206
  }, /*#__PURE__*/React.createElement(Button, {
167
207
  onClick: resetting
168
208
  }, "\u91CD\u7F6E"), /*#__PURE__*/React.createElement(Button, {
169
- disabled: ajaxFlag || searchDisabled,
209
+ loading: subjectLoading || loading,
170
210
  type: "primary",
171
211
  onClick: function onClick() {
172
- fetchRequest(true);
212
+ form.submit();
173
213
  }
174
214
  }, "\u67E5\u8BE2"))));
175
215
  });
@@ -1,23 +1,28 @@
1
1
  .top-panel {
2
2
  &-form-event {
3
3
  margin-bottom: 0;
4
- .ant-form-item-label {
4
+ & .ant-form-item-label {
5
5
  padding-left: 24px;
6
6
  font-weight: 500;
7
7
  }
8
8
  &-select {
9
9
  width: 208px;
10
- margin-bottom: 24px;
11
10
  margin-left: 24px;
12
11
  .biz-select-handle-input {
13
12
  padding-left: 12px;
14
13
  }
15
14
  }
15
+ .ant-form-item-row .ant-form-item-control {
16
+ margin-bottom: 24px;
17
+ padding: 4px 0;
18
+ }
19
+ .ant-form-item-explain-error {
20
+ padding-left: 24px;
21
+ }
16
22
  }
17
23
  &-form-botton-box {
18
24
  display: flex;
19
25
  justify-content: flex-end;
20
- margin-top: 12px;
21
26
  margin-right: 24px;
22
27
  > :nth-child(1) {
23
28
  margin-right: 16px;
@@ -26,8 +31,19 @@
26
31
  border-color: #29bd52;
27
32
  }
28
33
  }
29
-
30
- &-form-botton-box.margin-style {
31
- margin-top: 20px;
34
+ &-form {
35
+ .ant-form-item-has-error .biz-event-select {
36
+ border: 1px solid @error-color !important;
37
+ }
32
38
  }
33
39
  }
40
+ .hoverable-form-item {
41
+ .ant-form-item-control {
42
+ &:hover {
43
+ background: #e8efff !important;
44
+ }
45
+ }
46
+ }
47
+ .event---1 .ant-form-item-label {
48
+ padding-bottom: 4px !important;
49
+ }
@@ -8,14 +8,16 @@ interface filterConditions {
8
8
  dimension?: bizAttributeSelectorValueProp;
9
9
  }
10
10
  interface analysisSubject {
11
+ id?: number;
11
12
  subjectId?: number;
12
13
  name?: string;
13
14
  unit?: string;
14
15
  subjectAlias?: string;
15
16
  subjectName?: string;
17
+ analysisSubjectType?: string;
16
18
  }
17
19
  interface analysisSubjectType {
18
- value?: number;
20
+ value?: string;
19
21
  user?: string;
20
22
  }
21
23
  export interface FormDataProps {
@@ -29,17 +31,18 @@ export interface FormHandelDataProps extends filterConditions {
29
31
  userGroup?: any[];
30
32
  chartType?: EventChartTypes | undefined;
31
33
  analysisSubject?: analysisSubject;
34
+ eventIds?: number[];
32
35
  }
33
36
  export interface TopPanelProps {
34
37
  value?: SearchValue;
35
38
  onChange: (data: SearchValue, flag: boolean) => void;
39
+ loading?: boolean;
36
40
  ajaxFlag: boolean;
37
41
  subDisplay?: boolean;
38
42
  finalSearchData?: SearchValue;
39
43
  fetchRequest: (flag?: boolean) => void;
40
44
  setIsCity?: Function;
41
45
  setEnableSelectChart?: Function;
42
- allSubjectList?: any[];
43
46
  analysisSubjectType?: analysisSubjectType;
44
47
  onChangeSubjectType: (type: string) => void;
45
48
  }
package/es/types.d.ts CHANGED
@@ -15,6 +15,7 @@ export interface AnalysisSubject {
15
15
  unit?: string;
16
16
  subjectAlias?: string;
17
17
  subjectName?: string;
18
+ analysisSubjectType?: string;
18
19
  }
19
20
  export interface eventProps {
20
21
  id?: number;
@@ -25,6 +26,7 @@ export interface eventProps {
25
26
  }
26
27
  export interface SearchValue {
27
28
  id?: number;
29
+ eventIds?: number[];
28
30
  eventGroupId?: number;
29
31
  name?: string;
30
32
  platform?: number;
@@ -36,7 +36,7 @@ export function getColumns(eventGroupList, userPropList, eventEnvList, columnDat
36
36
  }));
37
37
  }
38
38
  }];
39
- if (userGroup.length > 1 || userGroup[0] !== 0) {
39
+ if (!(searchData === null || searchData === void 0 ? void 0 : searchData.analysisSubject) && (userGroup.length > 1 || userGroup[0] !== 0)) {
40
40
  data.push({
41
41
  title: '用户群',
42
42
  width: 150,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zgfe/modules-event",
3
- "version": "0.1.5-event.5",
3
+ "version": "0.1.5-event.51",
4
4
  "scripts": {
5
5
  "start": "dumi dev",
6
6
  "docs:build": "dumi build",
@@ -36,7 +36,7 @@
36
36
  "@types/lodash": "^4.14.191",
37
37
  "@umijs/fabric": "^2.8.1",
38
38
  "@umijs/test": "^3.0.5",
39
- "@zgfe/business-lib": "1.1.89-qirui.3",
39
+ "@zgfe/business-lib": "1.1.89-qirui.19",
40
40
  "antd": "^4.22.6",
41
41
  "dumi": "^1.1.0",
42
42
  "echarts": "^5.3.2",
@@ -49,7 +49,7 @@
49
49
  "react": "^16.12.0 || ^17.0.0",
50
50
  "yorkie": "^2.0.0"
51
51
  },
52
- "gitHead": "ac609e4c3e8d783016cac54006054c6f91521bf8",
52
+ "gitHead": "ac3983bc489976f9307f66288430d73a14f29049",
53
53
  "dependencies": {
54
54
  "react-copy-to-clipboard": "^5.1.0",
55
55
  "react-highlight": "^0.15.0"