@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
package/README.md
CHANGED
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
# modules-event
|
|
2
|
-
|
|
3
|
-
事件分析
|
|
4
|
-
|
|
5
|
-
## Getting Started
|
|
6
|
-
|
|
7
|
-
Install dependencies,
|
|
8
|
-
|
|
9
|
-
```bash
|
|
10
|
-
$ npm i
|
|
11
|
-
```
|
|
12
|
-
|
|
13
|
-
Start the dev server,
|
|
14
|
-
|
|
15
|
-
```bash
|
|
16
|
-
$ npm start
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
Build documentation,
|
|
20
|
-
|
|
21
|
-
```bash
|
|
22
|
-
$ npm run docs:build
|
|
23
|
-
```
|
|
24
|
-
|
|
25
|
-
Run test,
|
|
26
|
-
|
|
27
|
-
```bash
|
|
28
|
-
$ npm test
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
Build library via `father-build`,
|
|
32
|
-
|
|
33
|
-
```bash
|
|
34
|
-
$ npm run build
|
|
35
|
-
```
|
|
1
|
+
# modules-event
|
|
2
|
+
|
|
3
|
+
事件分析
|
|
4
|
+
|
|
5
|
+
## Getting Started
|
|
6
|
+
|
|
7
|
+
Install dependencies,
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
$ npm i
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Start the dev server,
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
$ npm start
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Build documentation,
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
$ npm run docs:build
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Run test,
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
$ npm test
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Build library via `father-build`,
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
$ npm run build
|
|
35
|
+
```
|
|
@@ -1,22 +1,24 @@
|
|
|
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 { Tooltip } from 'antd';
|
|
14
14
|
import React, { useEffect, useRef, useState, useContext } from 'react';
|
|
15
|
-
import { BizEventSelector, BizAttributeSelector, IconFont, BizAttrConditionGroup, BizGlobalDataContext } from '@zgfe/business-lib';
|
|
15
|
+
import { BizEventSelector, BizAttributeSelector, IconFont, BizAttrConditionGroup, BizGlobalDataContext, ajax } from '@zgfe/business-lib';
|
|
16
16
|
import { EventContext } from '../../types';
|
|
17
17
|
import './styles/index.less';
|
|
18
18
|
import { judgeIsCity, judgeIsArea } from '../../modules/content/utils';
|
|
19
19
|
import _ from 'lodash';
|
|
20
|
+
import SetCascade from './setCascade';
|
|
21
|
+
import { Apis } from '../../constants';
|
|
20
22
|
var classPrefix = 'eventfilter-box';
|
|
21
23
|
var EventFilter = function EventFilter(props) {
|
|
22
24
|
var _props$value, _props$value2;
|
|
@@ -25,12 +27,13 @@ var EventFilter = function EventFilter(props) {
|
|
|
25
27
|
setEnableSelectChart = props.setEnableSelectChart,
|
|
26
28
|
analysisType = props.analysisType;
|
|
27
29
|
var _useContext = useContext(EventContext),
|
|
28
|
-
selectEventData = _useContext.selectEventData,
|
|
29
30
|
searchData = _useContext.searchData,
|
|
30
|
-
setSearchData = _useContext.setSearchData
|
|
31
|
+
setSearchData = _useContext.setSearchData,
|
|
32
|
+
currentApp = _useContext.currentApp;
|
|
31
33
|
var _useContext2 = useContext(BizGlobalDataContext),
|
|
32
34
|
_useContext2$eventIdM = _useContext2.eventIdMap,
|
|
33
|
-
eventIdMap = _useContext2$eventIdM === void 0 ? {} : _useContext2$eventIdM
|
|
35
|
+
eventIdMap = _useContext2$eventIdM === void 0 ? {} : _useContext2$eventIdM,
|
|
36
|
+
envs = _useContext2.envs;
|
|
34
37
|
var _useState = useState(props.value && props.value.filters && props.value.filters.conditions ? props.value.filters.conditions.length : 0),
|
|
35
38
|
_useState2 = _slicedToArray(_useState, 2),
|
|
36
39
|
count = _useState2[0],
|
|
@@ -59,58 +62,87 @@ var EventFilter = function EventFilter(props) {
|
|
|
59
62
|
event = _useState8[0],
|
|
60
63
|
setEvent = _useState8[1];
|
|
61
64
|
var _useState9 = useState(false),
|
|
62
|
-
|
|
63
|
-
showDimension =
|
|
64
|
-
setShowDimension =
|
|
65
|
+
_useState0 = _slicedToArray(_useState9, 2),
|
|
66
|
+
showDimension = _useState0[0],
|
|
67
|
+
setShowDimension = _useState0[1];
|
|
68
|
+
var _useState1 = useState(),
|
|
69
|
+
_useState10 = _slicedToArray(_useState1, 2),
|
|
70
|
+
filter = _useState10[0],
|
|
71
|
+
setFilter = _useState10[1];
|
|
65
72
|
var _useState11 = useState(),
|
|
66
73
|
_useState12 = _slicedToArray(_useState11, 2),
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
var _useState13 = useState()
|
|
70
|
-
_useState14 = _slicedToArray(_useState13, 2),
|
|
71
|
-
bizAttributeSelectorValue = _useState14[0],
|
|
72
|
-
setBizAttributeSelectorValue = _useState14[1];
|
|
73
|
-
var _useState15 = useState(_.isArray(props.value) ? props.value.map(function (id) {
|
|
74
|
+
bizAttributeSelectorValue = _useState12[0],
|
|
75
|
+
setBizAttributeSelectorValue = _useState12[1];
|
|
76
|
+
var _useState13 = useState(_.isArray(props.value) ? props.value.map(function (id) {
|
|
74
77
|
return eventIdMap[id];
|
|
75
78
|
}) : props.analysisType === 'eventProp' && ((_props$value = props.value) === null || _props$value === void 0 ? void 0 : _props$value.id) ? [eventIdMap[(_props$value2 = props.value) === null || _props$value2 === void 0 ? void 0 : _props$value2.id]] : []),
|
|
79
|
+
_useState14 = _slicedToArray(_useState13, 2),
|
|
80
|
+
eventList = _useState14[0],
|
|
81
|
+
setEventList = _useState14[1];
|
|
82
|
+
var _useState15 = useState(true),
|
|
76
83
|
_useState16 = _slicedToArray(_useState15, 2),
|
|
77
|
-
|
|
78
|
-
|
|
84
|
+
isCascadeOpen = _useState16[0],
|
|
85
|
+
setIsCascadeOpen = _useState16[1];
|
|
86
|
+
var _useState17 = useState(false),
|
|
87
|
+
_useState18 = _slicedToArray(_useState17, 2),
|
|
88
|
+
isCascadeShow = _useState18[0],
|
|
89
|
+
setIsCascadeShow = _useState18[1];
|
|
90
|
+
var _useState19 = useState(),
|
|
91
|
+
_useState20 = _slicedToArray(_useState19, 2),
|
|
92
|
+
relationConfig = _useState20[0],
|
|
93
|
+
setRelationConfig = _useState20[1];
|
|
79
94
|
useEffect(function () {
|
|
80
95
|
var _data = props.value;
|
|
81
|
-
if (selectEventData) {
|
|
82
|
-
_data = selectEventData;
|
|
83
|
-
setEvent({
|
|
84
|
-
id: selectEventData.id,
|
|
85
|
-
name: selectEventData.name
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
96
|
if (_data) {
|
|
89
97
|
if (_data && _data.id) {
|
|
90
98
|
setShowDimension(true);
|
|
91
99
|
}
|
|
92
|
-
if (_data.filters) {
|
|
93
|
-
setFilter(_data.filters);
|
|
94
|
-
setCount(_data.filters.conditions.length);
|
|
100
|
+
if (_data === null || _data === void 0 ? void 0 : _data.filters) {
|
|
101
|
+
setFilter(_data === null || _data === void 0 ? void 0 : _data.filters);
|
|
102
|
+
setCount(_data === null || _data === void 0 ? void 0 : _data.filters.conditions.length);
|
|
95
103
|
}
|
|
96
104
|
if (_data.dimension) {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
}));
|
|
105
|
+
setBizAttributeSelectorValue(function () {
|
|
106
|
+
return _objectSpread({}, _data.dimension);
|
|
107
|
+
});
|
|
101
108
|
}
|
|
102
109
|
}
|
|
103
|
-
|
|
110
|
+
ajax(Apis.getEventSwitch, {
|
|
111
|
+
method: 'post',
|
|
112
|
+
data: {
|
|
113
|
+
appId: currentApp === null || currentApp === void 0 ? void 0 : currentApp.appId
|
|
114
|
+
}
|
|
115
|
+
}).then(function (res) {
|
|
116
|
+
if (res === null || res === void 0 ? void 0 : res.data) {
|
|
117
|
+
setIsCascadeOpen(res === null || res === void 0 ? void 0 : res.data);
|
|
118
|
+
queryRelationConfig();
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
}, []);
|
|
122
|
+
var queryRelationConfig = function queryRelationConfig() {
|
|
123
|
+
ajax(Apis.queryRelationConfig, {
|
|
124
|
+
method: 'post',
|
|
125
|
+
data: {
|
|
126
|
+
appId: currentApp === null || currentApp === void 0 ? void 0 : currentApp.appId
|
|
127
|
+
}
|
|
128
|
+
}).then(function (res) {
|
|
129
|
+
if (res === null || res === void 0 ? void 0 : res.data) {
|
|
130
|
+
setRelationConfig(res === null || res === void 0 ? void 0 : res.data);
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
};
|
|
104
134
|
var onAdd = function onAdd() {
|
|
105
|
-
var _conditionRef$current;
|
|
106
135
|
if ((event === null || event === void 0 ? void 0 : event.id) === -1) {
|
|
107
136
|
return;
|
|
108
137
|
}
|
|
109
|
-
if (count >=
|
|
138
|
+
if (count >= 20) {
|
|
110
139
|
return;
|
|
111
140
|
}
|
|
112
141
|
setIsAdd(true);
|
|
113
|
-
|
|
142
|
+
setTimeout(function () {
|
|
143
|
+
var _conditionRef$current;
|
|
144
|
+
conditionRef === null || conditionRef === void 0 ? void 0 : (_conditionRef$current = conditionRef.current) === null || _conditionRef$current === void 0 ? void 0 : _conditionRef$current.add();
|
|
145
|
+
}, 0);
|
|
114
146
|
};
|
|
115
147
|
var onChangeFilters = function onChangeFilters(data) {
|
|
116
148
|
setFilter(data);
|
|
@@ -168,12 +200,14 @@ var EventFilter = function EventFilter(props) {
|
|
|
168
200
|
setBizAttributeSelectorValue(undefined);
|
|
169
201
|
} else {
|
|
170
202
|
var _value = attr.propCategory === 'eventProp' ? attr.id : attr.name;
|
|
171
|
-
setBizAttributeSelectorValue({
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
203
|
+
setBizAttributeSelectorValue(function () {
|
|
204
|
+
return _objectSpread(_objectSpread({}, attr), {}, {
|
|
205
|
+
propCategory: attr.propCategory,
|
|
206
|
+
category: attr.category,
|
|
207
|
+
value: _value,
|
|
208
|
+
id: attr.id,
|
|
209
|
+
encryptionType: attr.encryptionType
|
|
210
|
+
});
|
|
177
211
|
});
|
|
178
212
|
}
|
|
179
213
|
};
|
|
@@ -221,7 +255,7 @@ var EventFilter = function EventFilter(props) {
|
|
|
221
255
|
},
|
|
222
256
|
onChange: onChangeEvent,
|
|
223
257
|
placeholder: "\u8BF7\u9009\u62E9\u4E8B\u4EF6"
|
|
224
|
-
}), showDimension && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(BizAttributeSelector, {
|
|
258
|
+
}), showDimension && (/*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(BizAttributeSelector, {
|
|
225
259
|
enableEventProp: true,
|
|
226
260
|
enableUserProp: analysisType === 'eventProp' ? false : true,
|
|
227
261
|
enableEnvProp: true,
|
|
@@ -237,12 +271,24 @@ var EventFilter = function EventFilter(props) {
|
|
|
237
271
|
placement: "top",
|
|
238
272
|
title: '添加属性筛选'
|
|
239
273
|
}, /*#__PURE__*/React.createElement(IconFont, {
|
|
240
|
-
className: "".concat(count >= 5 || (event === null || event === void 0 ? void 0 : event.id) === -1 ? 'disable' : ''),
|
|
274
|
+
className: "".concat(count >= ((envs === null || envs === void 0 ? void 0 : envs.propertyNum) || 5) || (event === null || event === void 0 ? void 0 : event.id) === -1 ? 'disable' : ''),
|
|
241
275
|
type: "shaixuan",
|
|
242
276
|
onClick: function onClick() {
|
|
243
277
|
return onAdd();
|
|
244
278
|
}
|
|
245
|
-
}))
|
|
279
|
+
})), isCascadeOpen ? (/*#__PURE__*/React.createElement(Tooltip, {
|
|
280
|
+
placement: "top",
|
|
281
|
+
title: '事件属性级联设置'
|
|
282
|
+
}, /*#__PURE__*/React.createElement(IconFont, {
|
|
283
|
+
style: {
|
|
284
|
+
marginLeft: 16
|
|
285
|
+
},
|
|
286
|
+
className: "".concat((event === null || event === void 0 ? void 0 : event.id) === -1 ? 'disable' : ''),
|
|
287
|
+
type: "guanli",
|
|
288
|
+
onClick: function onClick() {
|
|
289
|
+
setIsCascadeShow(true);
|
|
290
|
+
}
|
|
291
|
+
}))) : null))), event && eventIdMap && eventIdMap[event.id] && (filter || isAdd) && (/*#__PURE__*/React.createElement("div", {
|
|
246
292
|
className: "".concat(count > 0 ? 'attr-box-show' : '', " top")
|
|
247
293
|
}, /*#__PURE__*/React.createElement(BizAttrConditionGroup, {
|
|
248
294
|
ref: conditionRef,
|
|
@@ -253,7 +299,17 @@ var EventFilter = function EventFilter(props) {
|
|
|
253
299
|
enableUserProp: analysisType === 'eventProp' ? false : true,
|
|
254
300
|
eventIdList: event ? [event.id] : [],
|
|
255
301
|
onChange: onChangeFilters,
|
|
256
|
-
onConditionsCount: setCount
|
|
302
|
+
onConditionsCount: setCount,
|
|
303
|
+
relationConfig: relationConfig
|
|
304
|
+
}))), isCascadeOpen && isCascadeShow && (/*#__PURE__*/React.createElement(SetCascade, {
|
|
305
|
+
relationConfig: relationConfig,
|
|
306
|
+
onCancel: function onCancel() {
|
|
307
|
+
setIsCascadeShow(false);
|
|
308
|
+
},
|
|
309
|
+
submit: function submit() {
|
|
310
|
+
queryRelationConfig();
|
|
311
|
+
setIsCascadeShow(false);
|
|
312
|
+
}
|
|
257
313
|
})));
|
|
258
314
|
};
|
|
259
315
|
export default EventFilter;
|
|
@@ -0,0 +1,286 @@
|
|
|
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 _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
|
|
4
|
+
function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
|
|
5
|
+
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
6
|
+
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."); }
|
|
7
|
+
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; } }
|
|
8
|
+
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; }
|
|
9
|
+
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; } }
|
|
10
|
+
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
11
|
+
import { IconFont, ajax, BizDialog, BizEventSelector, BizAttributeSelector, BizGlobalDataContext } from '@zgfe/business-lib';
|
|
12
|
+
import { message, Button, Empty } from 'antd';
|
|
13
|
+
import { useContext, useEffect, useRef } from 'react';
|
|
14
|
+
import React, { useState } from 'react';
|
|
15
|
+
import _ from 'lodash';
|
|
16
|
+
import { Apis } from '../../constants';
|
|
17
|
+
var SelectAttributes = function SelectAttributes(props) {
|
|
18
|
+
var classPrefix = 'set-cascade';
|
|
19
|
+
var _useState = useState([{}]),
|
|
20
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
21
|
+
eventAttrList = _useState2[0],
|
|
22
|
+
setEventAttrList = _useState2[1];
|
|
23
|
+
var _useContext = useContext(BizGlobalDataContext),
|
|
24
|
+
currentApp = _useContext.currentApp;
|
|
25
|
+
var _useState3 = useState([]),
|
|
26
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
27
|
+
deleteIds = _useState4[0],
|
|
28
|
+
setDeleteIds = _useState4[1];
|
|
29
|
+
var scrollContainerRef = useRef();
|
|
30
|
+
var scrollToBottom = function scrollToBottom() {
|
|
31
|
+
var _scrollContainerRef$c = scrollContainerRef.current,
|
|
32
|
+
scrollHeight = _scrollContainerRef$c.scrollHeight,
|
|
33
|
+
clientHeight = _scrollContainerRef$c.clientHeight;
|
|
34
|
+
scrollContainerRef.current.scrollTo({
|
|
35
|
+
top: scrollHeight - clientHeight,
|
|
36
|
+
behavior: 'smooth'
|
|
37
|
+
});
|
|
38
|
+
};
|
|
39
|
+
useEffect(function () {
|
|
40
|
+
if (props.relationConfig && props.relationConfig.length) {
|
|
41
|
+
setEventAttrList(props.relationConfig.map(function (item) {
|
|
42
|
+
return {
|
|
43
|
+
id: item.id,
|
|
44
|
+
event: {
|
|
45
|
+
id: item.eventId,
|
|
46
|
+
name: item.eventName
|
|
47
|
+
},
|
|
48
|
+
attrSup: {
|
|
49
|
+
id: item.eventAttrIdSup,
|
|
50
|
+
label: item.eventAttrNameSup,
|
|
51
|
+
propCategory: 'eventProp'
|
|
52
|
+
},
|
|
53
|
+
attrSub: {
|
|
54
|
+
id: item.eventAttrIdSub,
|
|
55
|
+
label: item.eventAttrNameSub,
|
|
56
|
+
propCategory: 'eventProp'
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
}));
|
|
60
|
+
}
|
|
61
|
+
}, []);
|
|
62
|
+
var changeItemInfo = function changeItemInfo(i, key, v) {
|
|
63
|
+
var dealData = _.clone(eventAttrList);
|
|
64
|
+
dealData[i]['isEdit'] = true;
|
|
65
|
+
dealData[i][key] = v;
|
|
66
|
+
if (key == 'event') {
|
|
67
|
+
dealData[i]['attrSup'] = void 0;
|
|
68
|
+
dealData[i]['attrSub'] = void 0;
|
|
69
|
+
}
|
|
70
|
+
setEventAttrList(dealData);
|
|
71
|
+
if (key === 'attrSup' && dealData[i]['attrSub'] && v && v.id === dealData[i]['attrSub'].id || key === 'attrSub' && dealData[i]['attrSup'] && v && v.id === dealData[i]['attrSup'].id) {
|
|
72
|
+
message.warn('事件属性不可相同');
|
|
73
|
+
setTimeout(function () {
|
|
74
|
+
return changeItemInfo(i, key, undefined);
|
|
75
|
+
}, 200);
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
var dealEventAttr = function dealEventAttr(index) {
|
|
80
|
+
var dealData = _.clone(eventAttrList);
|
|
81
|
+
if (dealData[index].id) {
|
|
82
|
+
setDeleteIds([].concat(_toConsumableArray(deleteIds), [dealData[index].id]));
|
|
83
|
+
}
|
|
84
|
+
dealData.splice(index, 1);
|
|
85
|
+
setEventAttrList(dealData);
|
|
86
|
+
};
|
|
87
|
+
var submit = function submit() {
|
|
88
|
+
if (eventAttrList.filter(function (item) {
|
|
89
|
+
return !item.event || !item.event.id;
|
|
90
|
+
}).length) {
|
|
91
|
+
message.warn('设置事件不可为空');
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
if (eventAttrList.filter(function (item) {
|
|
95
|
+
return !item.attrSup || !item.attrSup.id || !item.attrSub || !item.attrSub.id;
|
|
96
|
+
}).length) {
|
|
97
|
+
message.warn('事件属性不可为空');
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
var addEventRelation = eventAttrList.filter(function (item) {
|
|
101
|
+
return !item.id;
|
|
102
|
+
}).map(function (item) {
|
|
103
|
+
return {
|
|
104
|
+
eventId: item.event.id,
|
|
105
|
+
eventName: item.event.name,
|
|
106
|
+
eventAttrIdSup: item.attrSup.id,
|
|
107
|
+
eventAttrNameSup: item.attrSup.label,
|
|
108
|
+
eventAttrIdSub: item.attrSub.id,
|
|
109
|
+
eventAttrNameSub: item.attrSub.label
|
|
110
|
+
};
|
|
111
|
+
});
|
|
112
|
+
var updateEventRelation = eventAttrList.filter(function (item) {
|
|
113
|
+
return item.id && item.isEdit;
|
|
114
|
+
}).map(function (item) {
|
|
115
|
+
return {
|
|
116
|
+
id: item.id,
|
|
117
|
+
eventId: item.event.id,
|
|
118
|
+
eventName: item.event.name,
|
|
119
|
+
eventAttrIdSup: item.attrSup.id,
|
|
120
|
+
eventAttrNameSup: item.attrSup.label,
|
|
121
|
+
eventAttrIdSub: item.attrSub.id,
|
|
122
|
+
eventAttrNameSub: item.attrSub.label
|
|
123
|
+
};
|
|
124
|
+
});
|
|
125
|
+
if ([].concat(_toConsumableArray(addEventRelation), _toConsumableArray(updateEventRelation), _toConsumableArray(deleteIds)).length) {
|
|
126
|
+
ajax(Apis.relationSaveConfig, {
|
|
127
|
+
method: 'post',
|
|
128
|
+
data: {
|
|
129
|
+
appId: currentApp === null || currentApp === void 0 ? void 0 : currentApp.appId,
|
|
130
|
+
addEventRelation: addEventRelation,
|
|
131
|
+
updateEventRelation: updateEventRelation,
|
|
132
|
+
deleteIds: deleteIds
|
|
133
|
+
}
|
|
134
|
+
}).then(function (res) {
|
|
135
|
+
if ((res === null || res === void 0 ? void 0 : res.code) == '100000') {
|
|
136
|
+
props.submit && props.submit();
|
|
137
|
+
message.success('保存成功');
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
} else {
|
|
141
|
+
props.onCancel && props.onCancel();
|
|
142
|
+
message.success('保存成功');
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
return /*#__PURE__*/React.createElement(BizDialog, {
|
|
146
|
+
wrapClassName: "".concat(classPrefix, "-modal-box"),
|
|
147
|
+
width: 520,
|
|
148
|
+
open: true,
|
|
149
|
+
title: "\u4E8B\u4EF6\u5C5E\u6027\u7EA7\u8054\u8BBE\u7F6E",
|
|
150
|
+
closable: true,
|
|
151
|
+
onCancel: props.onCancel,
|
|
152
|
+
footer: null
|
|
153
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
154
|
+
className: "".concat(classPrefix, "-modal-box-tips")
|
|
155
|
+
}, "\u7EA7\u8054\u5173\u7CFB\u8BBE\u7F6E\u540E\uFF0CT+1\u65E5\u5B8C\u6210\u66F4\u65B0\uFF0C\u8BF7\u4E8E\u6B21\u65E5\u524D\u6765\u67E5\u8BE2"), /*#__PURE__*/React.createElement("div", {
|
|
156
|
+
className: "".concat(classPrefix, "-modal-box-set"),
|
|
157
|
+
ref: scrollContainerRef
|
|
158
|
+
}, !eventAttrList.length && (/*#__PURE__*/React.createElement("div", {
|
|
159
|
+
className: "".concat(classPrefix, "-modal-box-set-empty")
|
|
160
|
+
}, /*#__PURE__*/React.createElement(Empty, {
|
|
161
|
+
image: Empty.PRESENTED_IMAGE_SIMPLE,
|
|
162
|
+
description: "\u6682\u65E0\u6570\u636E"
|
|
163
|
+
}))), eventAttrList.map(function (item, index) {
|
|
164
|
+
var _item$event, _item$event2;
|
|
165
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
166
|
+
key: index,
|
|
167
|
+
className: "".concat(classPrefix, "-modal-box-set-item")
|
|
168
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
169
|
+
className: "".concat(classPrefix, "-modal-box-set-item-info")
|
|
170
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
171
|
+
className: "".concat(classPrefix, "-modal-box-set-item-info-item")
|
|
172
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
173
|
+
style: {
|
|
174
|
+
marginRight: 12
|
|
175
|
+
}
|
|
176
|
+
}, "\u8BBE\u7F6E\u4E8B\u4EF6"), /*#__PURE__*/React.createElement(BizEventSelector, {
|
|
177
|
+
showAllEvent: false,
|
|
178
|
+
showBuiltInTarget: false,
|
|
179
|
+
popupContainer: false,
|
|
180
|
+
defaultSelectAble: false,
|
|
181
|
+
value: {
|
|
182
|
+
event: item.event
|
|
183
|
+
},
|
|
184
|
+
onChange: function onChange(e) {
|
|
185
|
+
changeItemInfo(index, 'event', e.event);
|
|
186
|
+
},
|
|
187
|
+
placeholder: "\u8BF7\u9009\u62E9\u4E8B\u4EF6"
|
|
188
|
+
})), /*#__PURE__*/React.createElement("div", {
|
|
189
|
+
style: {
|
|
190
|
+
paddingLeft: 8
|
|
191
|
+
}
|
|
192
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
193
|
+
className: "".concat(classPrefix, "-modal-box-set-item-info-item"),
|
|
194
|
+
style: {
|
|
195
|
+
marginBottom: 16
|
|
196
|
+
}
|
|
197
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
198
|
+
className: "".concat(classPrefix, "-modal-box-set-item-info-item-shu")
|
|
199
|
+
}), /*#__PURE__*/React.createElement("div", {
|
|
200
|
+
className: "".concat(classPrefix, "-modal-box-set-item-info-item-heng")
|
|
201
|
+
}), /*#__PURE__*/React.createElement("div", {
|
|
202
|
+
style: {
|
|
203
|
+
marginRight: 12
|
|
204
|
+
}
|
|
205
|
+
}, "\u4E0A\u7EA7\u4E8B\u4EF6\u5C5E\u6027"), /*#__PURE__*/React.createElement(BizAttributeSelector, {
|
|
206
|
+
isString: true,
|
|
207
|
+
isHideYeWu: true,
|
|
208
|
+
enableEventProp: true,
|
|
209
|
+
enableUserProp: false,
|
|
210
|
+
enableEnvProp: false,
|
|
211
|
+
eventIdList: [item === null || item === void 0 ? void 0 : (_item$event = item.event) === null || _item$event === void 0 ? void 0 : _item$event.id],
|
|
212
|
+
value: item.attrSup,
|
|
213
|
+
enableDelete: true,
|
|
214
|
+
onChange: function onChange(e) {
|
|
215
|
+
changeItemInfo(index, 'attrSup', e);
|
|
216
|
+
},
|
|
217
|
+
onDelete: function onDelete() {
|
|
218
|
+
changeItemInfo(index, 'attrSup', undefined);
|
|
219
|
+
},
|
|
220
|
+
placeholder: "\u8BF7\u9009\u62E9\u7EC6\u5206\u5C5E\u6027"
|
|
221
|
+
})), /*#__PURE__*/React.createElement("div", {
|
|
222
|
+
className: "".concat(classPrefix, "-modal-box-set-item-info-item")
|
|
223
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
224
|
+
className: "".concat(classPrefix, "-modal-box-set-item-info-item-shu"),
|
|
225
|
+
style: {
|
|
226
|
+
marginTop: -32
|
|
227
|
+
}
|
|
228
|
+
}), /*#__PURE__*/React.createElement("div", {
|
|
229
|
+
className: "".concat(classPrefix, "-modal-box-set-item-info-item-heng")
|
|
230
|
+
}), /*#__PURE__*/React.createElement("div", {
|
|
231
|
+
style: {
|
|
232
|
+
marginRight: 12
|
|
233
|
+
}
|
|
234
|
+
}, "\u4E0B\u7EA7\u4E8B\u4EF6\u5C5E\u6027"), /*#__PURE__*/React.createElement(BizAttributeSelector, {
|
|
235
|
+
isString: true,
|
|
236
|
+
isHideYeWu: true,
|
|
237
|
+
enableEventProp: true,
|
|
238
|
+
enableUserProp: false,
|
|
239
|
+
enableEnvProp: false,
|
|
240
|
+
eventIdList: [item === null || item === void 0 ? void 0 : (_item$event2 = item.event) === null || _item$event2 === void 0 ? void 0 : _item$event2.id],
|
|
241
|
+
value: item.attrSub,
|
|
242
|
+
enableDelete: true,
|
|
243
|
+
onChange: function onChange(e) {
|
|
244
|
+
changeItemInfo(index, 'attrSub', e);
|
|
245
|
+
},
|
|
246
|
+
onDelete: function onDelete() {
|
|
247
|
+
changeItemInfo(index, 'attrSub', undefined);
|
|
248
|
+
},
|
|
249
|
+
placeholder: "\u8BF7\u9009\u62E9\u7EC6\u5206\u5C5E\u6027"
|
|
250
|
+
})))), /*#__PURE__*/React.createElement("div", {
|
|
251
|
+
className: "".concat(classPrefix, "-modal-box-set-item-info-item")
|
|
252
|
+
}, /*#__PURE__*/React.createElement(IconFont, {
|
|
253
|
+
size: 16,
|
|
254
|
+
type: "qingchu",
|
|
255
|
+
onClick: function onClick() {
|
|
256
|
+
dealEventAttr(index);
|
|
257
|
+
}
|
|
258
|
+
})));
|
|
259
|
+
})), /*#__PURE__*/React.createElement("div", {
|
|
260
|
+
className: "".concat(classPrefix, "-modal-box-footer")
|
|
261
|
+
}, /*#__PURE__*/React.createElement(Button, {
|
|
262
|
+
disabled: eventAttrList.length > 4,
|
|
263
|
+
shape: "round",
|
|
264
|
+
className: "button addEvent ".concat(eventAttrList.length > 4 ? 'disabled' : ''),
|
|
265
|
+
onClick: function onClick() {
|
|
266
|
+
setEventAttrList([].concat(_toConsumableArray(eventAttrList), [{}]));
|
|
267
|
+
setTimeout(function () {
|
|
268
|
+
return scrollToBottom();
|
|
269
|
+
});
|
|
270
|
+
}
|
|
271
|
+
}, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(IconFont, {
|
|
272
|
+
type: "tianjia3",
|
|
273
|
+
style: {
|
|
274
|
+
marginRight: 8
|
|
275
|
+
}
|
|
276
|
+
}), "\u6DFB\u52A0\u7EA7\u8054\u5173\u7CFB")), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(Button, {
|
|
277
|
+
onClick: props.onCancel,
|
|
278
|
+
style: {
|
|
279
|
+
marginRight: 16
|
|
280
|
+
}
|
|
281
|
+
}, "\u53D6\u6D88"), /*#__PURE__*/React.createElement(Button, {
|
|
282
|
+
type: 'primary',
|
|
283
|
+
onClick: submit
|
|
284
|
+
}, "\u4FDD\u5B58"))));
|
|
285
|
+
};
|
|
286
|
+
export default SelectAttributes;
|