@zgfe/business-lib 1.1.66 → 1.1.67-beta.3
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/es/assets/iconfont/demo_index.html +118 -3
- package/es/assets/iconfont/iconfont.css +23 -3
- package/es/assets/iconfont/iconfont.js +1 -1
- package/es/assets/iconfont/iconfont.json +35 -0
- package/es/assets/iconfont/iconfont.ttf +0 -0
- package/es/assets/iconfont/iconfont.woff +0 -0
- package/es/assets/iconfont/iconfont.woff2 +0 -0
- package/es/assets/styles/chunks.less +18 -0
- package/es/assets/styles/variable.less +1 -0
- package/es/attrCondition/group.d.ts +2 -2
- package/es/attrCondition/group.js +10 -6
- package/es/attrCondition/index.js +43 -7
- package/es/attrCondition/styles/index.less +23 -7
- package/es/attrCondition/useAttrCondition.d.ts +3 -1
- package/es/attrCondition/useAttrCondition.js +2 -1
- package/es/attrCondition/useConditionGroup.js +14 -3
- package/es/attrConditions/components/stringList.d.ts +1 -0
- package/es/attrConditions/components/stringList.js +1 -0
- package/es/attrConditions/components/valuesList.d.ts +1 -0
- package/es/attrConditions/components/valuesList.js +6 -1
- package/es/attrConditions/index.js +4 -2
- package/es/attrConditions/types.d.ts +1 -0
- package/es/attributeSelector/demo/disable.js +6 -1
- package/es/attributeSelector/index.js +8 -13
- package/es/attributeSelector/styles/index.less +8 -19
- package/es/attributeSelector/types.d.ts +2 -1
- package/es/context/index.d.ts +4 -0
- package/es/context/index.js +2 -1
- package/es/eventSelector/index.js +0 -1
- package/es/eventSelector/listPanel.d.ts +10 -0
- package/es/eventSelector/listPanel.js +9 -9
- package/es/eventSelector/option.js +5 -2
- package/es/formulaTarget/components/formula/data.d.ts +16 -0
- package/es/formulaTarget/components/formula/data.js +40 -0
- package/es/formulaTarget/components/formula/demo.d.ts +2 -0
- package/es/formulaTarget/components/formula/demo.js +76 -0
- package/es/formulaTarget/components/formula/index.d.ts +6 -0
- package/es/formulaTarget/components/formula/index.js +132 -0
- package/es/formulaTarget/components/formula/index.less +68 -0
- package/es/formulaTarget/components/formula/types.d.ts +24 -0
- package/es/formulaTarget/components/formula/types.js +1 -0
- package/es/formulaTarget/components/formula/util.d.ts +28 -0
- package/es/formulaTarget/components/formula/util.js +245 -0
- package/es/formulaTarget/components/formulaItem/data.d.ts +2 -0
- package/es/formulaTarget/components/formulaItem/data.js +4 -0
- package/es/formulaTarget/components/formulaItem/index.d.ts +4 -0
- package/es/formulaTarget/components/formulaItem/index.js +190 -0
- package/es/formulaTarget/components/formulaItem/types.d.ts +10 -0
- package/es/formulaTarget/components/formulaItem/types.js +1 -0
- package/es/formulaTarget/components/panel/data.d.ts +8 -0
- package/es/formulaTarget/components/panel/data.js +32 -0
- package/es/formulaTarget/components/panel/demo.d.ts +2 -0
- package/es/formulaTarget/components/panel/demo.js +59 -0
- package/es/formulaTarget/components/panel/index.d.ts +6 -0
- package/es/formulaTarget/components/panel/index.js +162 -0
- package/es/formulaTarget/components/panel/index.less +131 -0
- package/es/formulaTarget/components/panel/item.d.ts +5 -0
- package/es/formulaTarget/components/panel/item.js +76 -0
- package/es/formulaTarget/components/panel/types.d.ts +13 -0
- package/es/formulaTarget/components/panel/types.js +1 -0
- package/es/formulaTarget/components/symbol/index.d.ts +7 -0
- package/es/formulaTarget/components/symbol/index.js +48 -0
- package/es/formulaTarget/components/symbol/index.less +48 -0
- package/es/formulaTarget/demo/group.d.ts +2 -0
- package/es/formulaTarget/demo/group.js +92 -0
- package/es/formulaTarget/demo/index.d.ts +2 -0
- package/es/formulaTarget/demo/index.js +21 -0
- package/es/formulaTarget/index.d.ts +5 -0
- package/es/formulaTarget/index.js +201 -0
- package/es/formulaTarget/styles/index.less +69 -0
- package/es/formulaTarget/types.d.ts +18 -0
- package/es/formulaTarget/types.js +1 -0
- package/es/index.d.ts +2 -1
- package/es/index.js +2 -1
- package/es/select/handle.js +9 -2
- package/es/select/styles/handle.less +1 -0
- package/es/select/types.d.ts +1 -0
- package/es/targetConditionGroup/components/targetDimension.js +0 -2
- package/es/targetConditionGroup/demo/group.js +8 -7
- package/es/targetConditionGroup/demo/index.js +1 -0
- package/es/targetConditionGroup/index.js +19 -9
- package/es/targetConditionGroup/styles/index.less +31 -6
- package/es/targetConditionGroup/types.d.ts +1 -0
- package/es/targetSelector/index.js +11 -69
- package/es/targetSelector/optionIcon.js +3 -0
- package/es/targetSelector/styles/index.less +27 -13
- package/es/userGroup/index.js +5 -9
- package/es/userGroup/styles/index.less +9 -10
- package/package.json +2 -2
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
2
|
+
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
|
+
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
|
+
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(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
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
7
|
+
import React, { useContext, useEffect, useRef, useState } from 'react';
|
|
8
|
+
import { classPrefix } from '../formula';
|
|
9
|
+
import { getDimension, getFilters, isDisable, judgeHaveFilter, validator } from '../formula/util';
|
|
10
|
+
import { BizGlobalDataContext, IconFont } from '../../..';
|
|
11
|
+
import SelectHandle from '../../../select/handle';
|
|
12
|
+
import { Dropdown } from 'antd';
|
|
13
|
+
import FormulaPanel from '../panel';
|
|
14
|
+
import _ from 'lodash';
|
|
15
|
+
import { itemDefaultData } from './data';
|
|
16
|
+
import { BizValidatorContext } from '../../../context';
|
|
17
|
+
var FormulaItem = function FormulaItem(props) {
|
|
18
|
+
var _useState = useState(props.value),
|
|
19
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
20
|
+
formulaValue = _useState2[0],
|
|
21
|
+
setFormulaValue = _useState2[1];
|
|
22
|
+
var _useState3 = useState(false),
|
|
23
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
24
|
+
disableLeft = _useState4[0],
|
|
25
|
+
setDisableLeft = _useState4[1];
|
|
26
|
+
var _useState5 = useState(false),
|
|
27
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
28
|
+
disableRight = _useState6[0],
|
|
29
|
+
setDisableRight = _useState6[1];
|
|
30
|
+
var _useState7 = useState(''),
|
|
31
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
32
|
+
label = _useState8[0],
|
|
33
|
+
setLabel = _useState8[1];
|
|
34
|
+
var _useState9 = useState(false),
|
|
35
|
+
_useState10 = _slicedToArray(_useState9, 2),
|
|
36
|
+
haveFilter = _useState10[0],
|
|
37
|
+
setHaveFilter = _useState10[1];
|
|
38
|
+
var _useState11 = useState(''),
|
|
39
|
+
_useState12 = _slicedToArray(_useState11, 2),
|
|
40
|
+
dimension = _useState12[0],
|
|
41
|
+
setDimension = _useState12[1];
|
|
42
|
+
var _useState13 = useState(false),
|
|
43
|
+
_useState14 = _slicedToArray(_useState13, 2),
|
|
44
|
+
isValidate = _useState14[0],
|
|
45
|
+
setIsValidate = _useState14[1];
|
|
46
|
+
var _useContext = useContext(BizGlobalDataContext),
|
|
47
|
+
eventGroupList = _useContext.eventGroupList;
|
|
48
|
+
var _useState15 = useState(false),
|
|
49
|
+
_useState16 = _slicedToArray(_useState15, 2),
|
|
50
|
+
open = _useState16[0],
|
|
51
|
+
setOpen = _useState16[1];
|
|
52
|
+
var panelRef = useRef(null);
|
|
53
|
+
var handleRef = useRef(null);
|
|
54
|
+
useEffect(function () {
|
|
55
|
+
setDisableLeft(isDisable(props.id, props.index, props.brackets, 'left'));
|
|
56
|
+
setDisableRight(isDisable(props.id, props.index, props.brackets, 'right'));
|
|
57
|
+
}, [props.brackets]);
|
|
58
|
+
useEffect(function () {
|
|
59
|
+
window.addEventListener('click', handleClick);
|
|
60
|
+
return function () {
|
|
61
|
+
window.removeEventListener('click', handleClick);
|
|
62
|
+
};
|
|
63
|
+
}, [open, formulaValue]);
|
|
64
|
+
useEffect(function () {
|
|
65
|
+
var condition = formulaValue === null || formulaValue === void 0 ? void 0 : formulaValue.condition;
|
|
66
|
+
setLabel((condition === null || condition === void 0 ? void 0 : condition.eventName) || (formulaValue === null || formulaValue === void 0 ? void 0 : formulaValue.condition));
|
|
67
|
+
if ((condition === null || condition === void 0 ? void 0 : condition.type) === 'event') {
|
|
68
|
+
setDimension(getDimension(condition.analysisDimension, condition.eventId, eventGroupList));
|
|
69
|
+
setHaveFilter(judgeHaveFilter(condition.filters));
|
|
70
|
+
} else if ((condition === null || condition === void 0 ? void 0 : condition.type) === 'whole') {
|
|
71
|
+
setHaveFilter(judgeHaveFilter(condition.filters));
|
|
72
|
+
setDimension('');
|
|
73
|
+
} else {
|
|
74
|
+
setDimension('');
|
|
75
|
+
setHaveFilter(false);
|
|
76
|
+
}
|
|
77
|
+
props.onChange && props.onChange(formulaValue);
|
|
78
|
+
}, [formulaValue]);
|
|
79
|
+
var handleClick = function handleClick(e) {
|
|
80
|
+
var _handleRef$current, _panelRef$current;
|
|
81
|
+
var handleClicked = (_handleRef$current = handleRef.current) === null || _handleRef$current === void 0 ? void 0 : _handleRef$current.contains(e.target);
|
|
82
|
+
var clicked = (_panelRef$current = panelRef.current) === null || _panelRef$current === void 0 ? void 0 : _panelRef$current.contains(e.target);
|
|
83
|
+
if (!open || clicked || handleClicked) return;
|
|
84
|
+
var isDropdown = false;
|
|
85
|
+
var dropdownList = document.getElementsByClassName('ant-dropdown');
|
|
86
|
+
var len = dropdownList.length;
|
|
87
|
+
for (var i = 0; i < len; i++) {
|
|
88
|
+
if (dropdownList[i].contains(e.target)) {
|
|
89
|
+
isDropdown = true;
|
|
90
|
+
break;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
if (!isDropdown) {
|
|
94
|
+
var _formulaValue$conditi;
|
|
95
|
+
if (!(formulaValue === null || formulaValue === void 0 ? void 0 : formulaValue.condition)) {
|
|
96
|
+
setOpen(false);
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
var type = ((_formulaValue$conditi = formulaValue.condition) === null || _formulaValue$conditi === void 0 ? void 0 : _formulaValue$conditi.type) || 'constant';
|
|
100
|
+
var validateData = validator(type, formulaValue.condition);
|
|
101
|
+
if (!validateData.isOk) {
|
|
102
|
+
setIsValidate(true);
|
|
103
|
+
} else {
|
|
104
|
+
setOpen(false);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
var onClickBracket = function onClickBracket(position) {
|
|
109
|
+
var flag = position === 'left' ? disableLeft : disableRight;
|
|
110
|
+
if (flag) return;
|
|
111
|
+
setFormulaValue(function (value) {
|
|
112
|
+
var newValue = _.cloneDeep(value) || itemDefaultData;
|
|
113
|
+
newValue[position] = !newValue[position];
|
|
114
|
+
return newValue;
|
|
115
|
+
});
|
|
116
|
+
};
|
|
117
|
+
var onChange = function onChange(data) {
|
|
118
|
+
setFormulaValue(function (value) {
|
|
119
|
+
var newValue = _.cloneDeep(value) || itemDefaultData;
|
|
120
|
+
newValue.condition = _.cloneDeep(data);
|
|
121
|
+
return newValue;
|
|
122
|
+
});
|
|
123
|
+
setIsValidate(false);
|
|
124
|
+
};
|
|
125
|
+
var onClickHandle = function onClickHandle() {
|
|
126
|
+
if (open) {
|
|
127
|
+
setFormulaValue(function (value) {
|
|
128
|
+
var _newValue$condition;
|
|
129
|
+
var newValue = _.cloneDeep(value) || itemDefaultData;
|
|
130
|
+
if (newValue.condition && ((_newValue$condition = newValue.condition) === null || _newValue$condition === void 0 ? void 0 : _newValue$condition.filters)) {
|
|
131
|
+
newValue.condition.filters = getFilters(newValue.condition.filters);
|
|
132
|
+
}
|
|
133
|
+
return newValue;
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
setTimeout(function () {
|
|
137
|
+
setOpen(function (open) {
|
|
138
|
+
return !open;
|
|
139
|
+
});
|
|
140
|
+
}, 0);
|
|
141
|
+
};
|
|
142
|
+
return /*#__PURE__*/React.createElement(BizValidatorContext.Provider, {
|
|
143
|
+
value: {
|
|
144
|
+
isValidate: isValidate,
|
|
145
|
+
setValidate: function setValidate(data) {
|
|
146
|
+
return setIsValidate(!!data);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
150
|
+
className: "".concat(classPrefix, "-target")
|
|
151
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
152
|
+
className: "".concat(classPrefix, "-option ").concat((formulaValue === null || formulaValue === void 0 ? void 0 : formulaValue.left) ? 'active' : '').concat(disableLeft ? ' disabled' : ''),
|
|
153
|
+
onClick: function onClick() {
|
|
154
|
+
return onClickBracket('left');
|
|
155
|
+
}
|
|
156
|
+
}, "("), /*#__PURE__*/React.createElement(Dropdown, {
|
|
157
|
+
dropdownRender: function dropdownRender() {
|
|
158
|
+
return /*#__PURE__*/React.createElement(FormulaPanel, {
|
|
159
|
+
ref: panelRef,
|
|
160
|
+
value: formulaValue === null || formulaValue === void 0 ? void 0 : formulaValue.condition,
|
|
161
|
+
onChange: onChange,
|
|
162
|
+
onDelete: props.onDelete,
|
|
163
|
+
onSubmit: function onSubmit() {
|
|
164
|
+
return setOpen(false);
|
|
165
|
+
}
|
|
166
|
+
});
|
|
167
|
+
},
|
|
168
|
+
trigger: ['click'],
|
|
169
|
+
open: open,
|
|
170
|
+
destroyPopupOnHide: true
|
|
171
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
172
|
+
ref: handleRef,
|
|
173
|
+
className: "".concat(classPrefix, "-target-handle"),
|
|
174
|
+
onClick: onClickHandle
|
|
175
|
+
}, /*#__PURE__*/React.createElement(SelectHandle, {
|
|
176
|
+
border: false,
|
|
177
|
+
label: label
|
|
178
|
+
}, /*#__PURE__*/React.createElement("span", null, label), haveFilter ? /*#__PURE__*/React.createElement(IconFont, {
|
|
179
|
+
className: "".concat(classPrefix, "-target-handle-icon"),
|
|
180
|
+
type: "a-shaixuan2"
|
|
181
|
+
}) : null, /*#__PURE__*/React.createElement("span", {
|
|
182
|
+
className: "".concat(classPrefix, "-target-handle-name")
|
|
183
|
+
}, dimension)))), /*#__PURE__*/React.createElement("div", {
|
|
184
|
+
className: "".concat(classPrefix, "-option ").concat((formulaValue === null || formulaValue === void 0 ? void 0 : formulaValue.right) ? 'active' : '').concat(disableRight ? ' disabled' : ''),
|
|
185
|
+
onClick: function onClick() {
|
|
186
|
+
return onClickBracket('right');
|
|
187
|
+
}
|
|
188
|
+
}, ")")));
|
|
189
|
+
};
|
|
190
|
+
export default FormulaItem;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { FormulaContainerTypes } from '../formula/types';
|
|
2
|
+
export interface FormulaItemProps {
|
|
3
|
+
value: FormulaContainerTypes.Item;
|
|
4
|
+
id: string;
|
|
5
|
+
index: number;
|
|
6
|
+
brackets: (null | FormulaContainerTypes.Bracket)[];
|
|
7
|
+
onChange?: (data: FormulaContainerTypes.Item) => void;
|
|
8
|
+
onDelete?: () => void;
|
|
9
|
+
onSubmit?: () => void;
|
|
10
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { AttrConditionTypes } from '../../..';
|
|
2
|
+
import { AnalysisEvent, EventGroup } from '../../../attributeSelector/types';
|
|
3
|
+
export declare const leftMenu: {
|
|
4
|
+
name: string;
|
|
5
|
+
value: string;
|
|
6
|
+
}[];
|
|
7
|
+
export declare const filterData: AttrConditionTypes.GroupValue;
|
|
8
|
+
export declare const getEventList: (eventGroupList?: EventGroup[]) => AnalysisEvent[];
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export var leftMenu = [{
|
|
2
|
+
name: '事件',
|
|
3
|
+
value: 'event'
|
|
4
|
+
}, {
|
|
5
|
+
name: '整体',
|
|
6
|
+
value: 'whole'
|
|
7
|
+
}, {
|
|
8
|
+
name: '常数',
|
|
9
|
+
value: 'constant'
|
|
10
|
+
}];
|
|
11
|
+
export var filterData = {
|
|
12
|
+
relation: 'and',
|
|
13
|
+
conditions: []
|
|
14
|
+
};
|
|
15
|
+
export var getEventList = function getEventList(eventGroupList) {
|
|
16
|
+
var list = [];
|
|
17
|
+
var listObj = {};
|
|
18
|
+
var markList = [];
|
|
19
|
+
eventGroupList === null || eventGroupList === void 0 ? void 0 : eventGroupList.forEach(function (group) {
|
|
20
|
+
group.eventList.forEach(function (item) {
|
|
21
|
+
if (!listObj[item.id]) {
|
|
22
|
+
if (item.marked) {
|
|
23
|
+
markList.push(item);
|
|
24
|
+
} else {
|
|
25
|
+
list.push(item);
|
|
26
|
+
}
|
|
27
|
+
listObj[item.id] = 1;
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
return [].concat(markList, list);
|
|
32
|
+
};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import FormulaPanel from '.';
|
|
3
|
+
import BizGlobalDataContext from '../../../context';
|
|
4
|
+
import { convertAttributeData } from '../../..';
|
|
5
|
+
import eventData from '../../../mock/event';
|
|
6
|
+
import envData from '../../../mock/env';
|
|
7
|
+
import userData from '../../../mock/user';
|
|
8
|
+
import { OperateTypes } from '../../../attrConditions/types';
|
|
9
|
+
export default (function () {
|
|
10
|
+
var store = convertAttributeData({
|
|
11
|
+
eventList: eventData,
|
|
12
|
+
userPropList: userData,
|
|
13
|
+
envPropList: envData
|
|
14
|
+
});
|
|
15
|
+
var defaultValue = {
|
|
16
|
+
type: 'event',
|
|
17
|
+
eventId: 24143013,
|
|
18
|
+
eventName: '小程序-付款成功',
|
|
19
|
+
alias: '小程序-付款成功',
|
|
20
|
+
isBuiltIn: false,
|
|
21
|
+
analysisDimension: {
|
|
22
|
+
analysisIndex: 'number'
|
|
23
|
+
},
|
|
24
|
+
filters: {
|
|
25
|
+
relation: 'and',
|
|
26
|
+
conditions: [{
|
|
27
|
+
attrId: 30183422,
|
|
28
|
+
propCategory: 'eventProp',
|
|
29
|
+
type: 1,
|
|
30
|
+
operator: OperateTypes.Equal,
|
|
31
|
+
values: ['111'],
|
|
32
|
+
dimensionSub: 'event_attr',
|
|
33
|
+
label: '_编号',
|
|
34
|
+
attrName: '_编号'
|
|
35
|
+
}]
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
var onChange = function onChange(data) {
|
|
39
|
+
console.log('onChange:', data);
|
|
40
|
+
};
|
|
41
|
+
var onDelete = function onDelete() {
|
|
42
|
+
console.log('onDelete------');
|
|
43
|
+
};
|
|
44
|
+
var onSubmit = function onSubmit() {
|
|
45
|
+
console.log('onSubmit------');
|
|
46
|
+
};
|
|
47
|
+
return /*#__PURE__*/React.createElement(BizGlobalDataContext.Provider, {
|
|
48
|
+
value: {
|
|
49
|
+
eventGroupList: store.eventGroupList,
|
|
50
|
+
userPropList: store.userPropList,
|
|
51
|
+
eventEnvList: store.envPropList
|
|
52
|
+
}
|
|
53
|
+
}, /*#__PURE__*/React.createElement(FormulaPanel, {
|
|
54
|
+
value: defaultValue,
|
|
55
|
+
onChange: onChange,
|
|
56
|
+
onDelete: onDelete,
|
|
57
|
+
onSubmit: onSubmit
|
|
58
|
+
}));
|
|
59
|
+
});
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import './index.less';
|
|
3
|
+
import { FormulaPanelProps } from './types';
|
|
4
|
+
export declare const classPrefix = "formula-panel";
|
|
5
|
+
declare const FormulaPanel: React.ForwardRefExoticComponent<FormulaPanelProps & React.RefAttributes<any>>;
|
|
6
|
+
export default FormulaPanel;
|
|
@@ -0,0 +1,162 @@
|
|
|
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); }
|
|
7
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
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(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); }
|
|
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; }
|
|
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; } }
|
|
12
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
13
|
+
import React, { useContext, useEffect, useState } from 'react';
|
|
14
|
+
import './index.less';
|
|
15
|
+
import { Button, InputNumber, Spin } from 'antd';
|
|
16
|
+
import { getEventList, leftMenu } from './data';
|
|
17
|
+
import { BizGlobalDataContext, BizSearchInput } from '../../..';
|
|
18
|
+
import { BuiltinIndicators } from '../../../constants/common';
|
|
19
|
+
import { InfiniteScrollList } from '../../../eventSelector/listPanel';
|
|
20
|
+
import PanelItem from './item';
|
|
21
|
+
import { validator } from '../formula/util';
|
|
22
|
+
import { BizValidatorContext } from '../../../context';
|
|
23
|
+
export var classPrefix = 'formula-panel';
|
|
24
|
+
var FormulaPanel = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
25
|
+
var _useContext = useContext(BizGlobalDataContext),
|
|
26
|
+
eventGroupList = _useContext.eventGroupList;
|
|
27
|
+
var _useState = useState('event'),
|
|
28
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
29
|
+
type = _useState2[0],
|
|
30
|
+
setType = _useState2[1];
|
|
31
|
+
var _useState3 = useState(''),
|
|
32
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
33
|
+
searchValue = _useState4[0],
|
|
34
|
+
setSearchValue = _useState4[1];
|
|
35
|
+
var _useState5 = useState({}),
|
|
36
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
37
|
+
allList = _useState6[0],
|
|
38
|
+
setAllList = _useState6[1];
|
|
39
|
+
var _useState7 = useState(true),
|
|
40
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
41
|
+
loading = _useState8[0],
|
|
42
|
+
setLoading = _useState8[1];
|
|
43
|
+
var _useState9 = useState(),
|
|
44
|
+
_useState10 = _slicedToArray(_useState9, 2),
|
|
45
|
+
currentValue = _useState10[0],
|
|
46
|
+
setCurrentValue = _useState10[1];
|
|
47
|
+
var scrollableId = 'scrollableFormula' + Math.random();
|
|
48
|
+
var _useState11 = useState(''),
|
|
49
|
+
_useState12 = _slicedToArray(_useState11, 2),
|
|
50
|
+
validateData = _useState12[0],
|
|
51
|
+
setValidateData = _useState12[1];
|
|
52
|
+
var _useContext2 = useContext(BizValidatorContext),
|
|
53
|
+
setValidate = _useContext2.setValidate;
|
|
54
|
+
useEffect(function () {
|
|
55
|
+
setAllList({
|
|
56
|
+
event: getEventList(eventGroupList),
|
|
57
|
+
whole: BuiltinIndicators.eventList
|
|
58
|
+
});
|
|
59
|
+
setCurrentValue(props.value);
|
|
60
|
+
setType(props.value ? props.value.type ? props.value.type : 'constant' : 'event');
|
|
61
|
+
setTimeout(function () {
|
|
62
|
+
setLoading(false);
|
|
63
|
+
}, 0);
|
|
64
|
+
}, []);
|
|
65
|
+
useEffect(function () {
|
|
66
|
+
props.onChange && props.onChange(currentValue);
|
|
67
|
+
}, [currentValue]);
|
|
68
|
+
var onClickMenu = function onClickMenu(data) {
|
|
69
|
+
setType(data);
|
|
70
|
+
};
|
|
71
|
+
var onClick = function onClick(data) {
|
|
72
|
+
setValidateData('');
|
|
73
|
+
setCurrentValue({
|
|
74
|
+
type: type,
|
|
75
|
+
eventId: data.id,
|
|
76
|
+
eventName: data.alias || data.name,
|
|
77
|
+
alias: data.alias || data.name,
|
|
78
|
+
isBuiltIn: data.isBuiltIn,
|
|
79
|
+
analysisDimension: {
|
|
80
|
+
analysisIndex: 'number'
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
};
|
|
84
|
+
var onChangeFilter = function onChangeFilter(dimension, filters) {
|
|
85
|
+
setCurrentValue(function (value) {
|
|
86
|
+
return _objectSpread(_objectSpread({}, value), {}, {
|
|
87
|
+
analysisDimension: _objectSpread({}, dimension),
|
|
88
|
+
filters: filters
|
|
89
|
+
});
|
|
90
|
+
});
|
|
91
|
+
};
|
|
92
|
+
var onChangeConstant = function onChangeConstant(data) {
|
|
93
|
+
setCurrentValue(String(data));
|
|
94
|
+
if (data) setValidateData('');
|
|
95
|
+
};
|
|
96
|
+
var onSubmit = function onSubmit() {
|
|
97
|
+
var conditionType = currentValue && currentValue.type ? currentValue.type : type;
|
|
98
|
+
var data = validator(conditionType, currentValue);
|
|
99
|
+
console.log('submit:', data, conditionType, currentValue);
|
|
100
|
+
if (!data.isOk) {
|
|
101
|
+
setValidateData(data.msg);
|
|
102
|
+
setValidate && setValidate(true);
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
props.onSubmit && props.onSubmit();
|
|
106
|
+
};
|
|
107
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
108
|
+
className: classPrefix,
|
|
109
|
+
ref: ref
|
|
110
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
111
|
+
className: "".concat(classPrefix, "-content")
|
|
112
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
113
|
+
className: "".concat(classPrefix, "-left")
|
|
114
|
+
}, leftMenu.map(function (item) {
|
|
115
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
116
|
+
className: "".concat(classPrefix, "-left-item").concat(item.value === type ? ' active' : ''),
|
|
117
|
+
key: item.value,
|
|
118
|
+
onClick: function onClick() {
|
|
119
|
+
return onClickMenu(item.value);
|
|
120
|
+
}
|
|
121
|
+
}, item.name);
|
|
122
|
+
})), currentValue && currentValue.eventId && currentValue.type === type ? /*#__PURE__*/React.createElement(PanelItem, {
|
|
123
|
+
value: currentValue,
|
|
124
|
+
onBack: function onBack() {
|
|
125
|
+
return setCurrentValue(null);
|
|
126
|
+
},
|
|
127
|
+
onChange: onChangeFilter
|
|
128
|
+
}) : /*#__PURE__*/React.createElement("div", {
|
|
129
|
+
className: "".concat(classPrefix, "-right")
|
|
130
|
+
}, type === 'event' && allList[type] && allList[type].length ? /*#__PURE__*/React.createElement(BizSearchInput, {
|
|
131
|
+
className: "".concat(classPrefix, "-right-search"),
|
|
132
|
+
onChange: setSearchValue
|
|
133
|
+
}) : null, type === 'constant' ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(InputNumber, {
|
|
134
|
+
className: "".concat(classPrefix, "-right-number"),
|
|
135
|
+
value: typeof currentValue === 'string' || typeof currentValue === 'number' ? Number(currentValue) : undefined,
|
|
136
|
+
min: 0,
|
|
137
|
+
max: 99999,
|
|
138
|
+
status: validateData ? 'error' : '',
|
|
139
|
+
onChange: onChangeConstant
|
|
140
|
+
}), /*#__PURE__*/React.createElement("div", {
|
|
141
|
+
className: "".concat(classPrefix, "-error")
|
|
142
|
+
}, validateData)) : /*#__PURE__*/React.createElement("div", {
|
|
143
|
+
className: "".concat(classPrefix, "-right-list"),
|
|
144
|
+
id: scrollableId
|
|
145
|
+
}, loading ? /*#__PURE__*/React.createElement(Spin, null) : allList[type].length ? /*#__PURE__*/React.createElement(InfiniteScrollList, {
|
|
146
|
+
scrollableTarget: scrollableId,
|
|
147
|
+
searchEventList: allList[type],
|
|
148
|
+
searchValue: searchValue,
|
|
149
|
+
groupId: type,
|
|
150
|
+
currentId: currentValue === null || currentValue === void 0 ? void 0 : currentValue.eventId,
|
|
151
|
+
onClick: onClick
|
|
152
|
+
}) : '暂无数据'))), /*#__PURE__*/React.createElement("div", {
|
|
153
|
+
className: "".concat(classPrefix, "-footer")
|
|
154
|
+
}, /*#__PURE__*/React.createElement(Button, {
|
|
155
|
+
type: "text",
|
|
156
|
+
onClick: props.onDelete
|
|
157
|
+
}, "\u5220\u9664"), /*#__PURE__*/React.createElement(Button, {
|
|
158
|
+
type: "primary",
|
|
159
|
+
onClick: onSubmit
|
|
160
|
+
}, "\u786E\u5B9A")));
|
|
161
|
+
});
|
|
162
|
+
export default FormulaPanel;
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
@import '../../../assets/styles/inner.less';
|
|
2
|
+
|
|
3
|
+
.formula-panel {
|
|
4
|
+
.__select-panel();
|
|
5
|
+
display: flex;
|
|
6
|
+
flex-direction: column;
|
|
7
|
+
width: fit-content;
|
|
8
|
+
min-width: 328px;
|
|
9
|
+
height: 368px;
|
|
10
|
+
padding: 0;
|
|
11
|
+
background: #fff;
|
|
12
|
+
|
|
13
|
+
&-content {
|
|
14
|
+
display: flex;
|
|
15
|
+
height: 320px;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
&-left {
|
|
19
|
+
width: 76px;
|
|
20
|
+
height: 100%;
|
|
21
|
+
padding: 8px;
|
|
22
|
+
border-right: 1px solid #ecedf0;
|
|
23
|
+
&-item {
|
|
24
|
+
.__select-option();
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
&-right {
|
|
29
|
+
display: flex;
|
|
30
|
+
flex-direction: column;
|
|
31
|
+
width: 100%;
|
|
32
|
+
height: 100%;
|
|
33
|
+
padding: 12px 8px;
|
|
34
|
+
|
|
35
|
+
&-search {
|
|
36
|
+
width: 100%;
|
|
37
|
+
margin-bottom: 12px;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
&-list {
|
|
41
|
+
max-height: calc(100% - 44px);
|
|
42
|
+
// flex: 1;
|
|
43
|
+
|
|
44
|
+
overflow: auto;
|
|
45
|
+
}
|
|
46
|
+
&-item {
|
|
47
|
+
.__select-option();
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
&-number {
|
|
51
|
+
min-width: 184px;
|
|
52
|
+
background-color: @background-color-base;
|
|
53
|
+
border: 1px solid @background-color-base;
|
|
54
|
+
border-radius: @border-radius-small;
|
|
55
|
+
&:hover,
|
|
56
|
+
&.ant-input-number-focused {
|
|
57
|
+
background-color: #fff;
|
|
58
|
+
border-color: @primary-color;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
&-detail {
|
|
64
|
+
width: 100%;
|
|
65
|
+
height: 100%;
|
|
66
|
+
|
|
67
|
+
&-title {
|
|
68
|
+
display: flex;
|
|
69
|
+
align-items: center;
|
|
70
|
+
justify-content: space-between;
|
|
71
|
+
height: 48px;
|
|
72
|
+
padding: 0 12px;
|
|
73
|
+
border-bottom: 1px solid #f2f3f4;
|
|
74
|
+
&-left {
|
|
75
|
+
display: flex;
|
|
76
|
+
align-items: center;
|
|
77
|
+
&-icon {
|
|
78
|
+
margin-right: 10px;
|
|
79
|
+
color: @text-color-secondary;
|
|
80
|
+
font-size: 16px !important;
|
|
81
|
+
line-height: 16px;
|
|
82
|
+
cursor: pointer;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
&-right {
|
|
87
|
+
display: flex;
|
|
88
|
+
align-items: center;
|
|
89
|
+
margin-left: 16px;
|
|
90
|
+
color: #9aa1a9;
|
|
91
|
+
cursor: pointer;
|
|
92
|
+
.bsicon {
|
|
93
|
+
margin-right: 8px;
|
|
94
|
+
font-size: 16px !important;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
&:hover {
|
|
98
|
+
color: @primary-color;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
&-content {
|
|
104
|
+
display: flex;
|
|
105
|
+
flex-direction: column;
|
|
106
|
+
max-height: calc(100% - 48px);
|
|
107
|
+
padding: 12px;
|
|
108
|
+
overflow: auto;
|
|
109
|
+
|
|
110
|
+
.biz-attr-condition:not(:last-child) {
|
|
111
|
+
margin-bottom: 12px;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
&-footer {
|
|
117
|
+
display: flex;
|
|
118
|
+
align-items: center;
|
|
119
|
+
justify-content: end;
|
|
120
|
+
padding: 8px 16px;
|
|
121
|
+
border-top: 1px solid #ecedf0;
|
|
122
|
+
|
|
123
|
+
.ant-btn:not(:last-child) {
|
|
124
|
+
margin-right: 16px;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
&-error {
|
|
129
|
+
color: @error-color;
|
|
130
|
+
}
|
|
131
|
+
}
|