@zgfe/business-lib 1.1.67-beta.2 → 1.1.67-beta.4
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/styles/chunks.less +2 -3
- package/es/assets/styles/resetAntd.less +1 -0
- package/es/formulaTarget/components/formulaItem/index.js +0 -1
- package/es/formulaTarget/components/panel/index.js +3 -0
- package/es/formulaTarget/components/panel/index.less +6 -0
- package/es/formulaTarget/demo/group.js +1 -0
- package/es/formulaTarget/demo/index.js +4 -0
- package/es/formulaTarget/index.js +42 -49
- package/es/formulaTarget/styles/index.less +9 -3
- package/es/formulaTarget/types.d.ts +1 -0
- package/es/targetConditionGroup/demo/group.js +8 -7
- package/es/targetConditionGroup/index.js +7 -5
- package/es/targetConditionGroup/types.d.ts +1 -0
- package/package.json +2 -2
|
@@ -140,14 +140,13 @@
|
|
|
140
140
|
|
|
141
141
|
// 下拉框常用样式
|
|
142
142
|
.__select-normal-secondary {
|
|
143
|
+
background: @white;
|
|
143
144
|
border: 1px solid @border-color-base;
|
|
144
145
|
border-radius: @border-radius-small;
|
|
145
|
-
|
|
146
146
|
&:not(.disable) {
|
|
147
147
|
&:hover,
|
|
148
148
|
&.active {
|
|
149
|
-
border-color: @
|
|
150
|
-
box-shadow: none;
|
|
149
|
+
border-color: @primary-color;
|
|
151
150
|
}
|
|
152
151
|
}
|
|
153
152
|
}
|
|
@@ -173,7 +173,6 @@ var FormulaItem = function FormulaItem(props) {
|
|
|
173
173
|
className: "".concat(classPrefix, "-target-handle"),
|
|
174
174
|
onClick: onClickHandle
|
|
175
175
|
}, /*#__PURE__*/React.createElement(SelectHandle, {
|
|
176
|
-
border: false,
|
|
177
176
|
label: label
|
|
178
177
|
}, /*#__PURE__*/React.createElement("span", null, label), haveFilter ? /*#__PURE__*/React.createElement(IconFont, {
|
|
179
178
|
className: "".concat(classPrefix, "-target-handle-icon"),
|
|
@@ -135,6 +135,9 @@ var FormulaPanel = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
135
135
|
value: typeof currentValue === 'string' || typeof currentValue === 'number' ? Number(currentValue) : undefined,
|
|
136
136
|
min: 0,
|
|
137
137
|
max: 99999,
|
|
138
|
+
parser: function parser(value) {
|
|
139
|
+
return Number(value ? value.replace(/^(\d+)\.(\d\d).*/, '$1.$2') : '');
|
|
140
|
+
},
|
|
138
141
|
status: validateData ? 'error' : '',
|
|
139
142
|
onChange: onChangeConstant
|
|
140
143
|
}), /*#__PURE__*/React.createElement("div", {
|
|
@@ -69,6 +69,7 @@ export default (function () {
|
|
|
69
69
|
return /*#__PURE__*/React.createElement(Form.Item, _objectSpread(_objectSpread({}, field), {}, {
|
|
70
70
|
key: field.key
|
|
71
71
|
}), /*#__PURE__*/React.createElement(BizFormulaTarget, {
|
|
72
|
+
enableDelete: fields.length > 1,
|
|
72
73
|
onDelete: function onDelete() {
|
|
73
74
|
if (fields.length > 1) {
|
|
74
75
|
remove(field.name);
|
|
@@ -10,52 +10,47 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
|
|
|
10
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
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
12
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
13
|
-
import React, { useRef, useState } from 'react';
|
|
13
|
+
import React, { useMemo, useRef, useState } from 'react';
|
|
14
14
|
import './styles/index.less';
|
|
15
15
|
import { Input, Popconfirm } from 'antd';
|
|
16
16
|
import IconFont from '../icon/iconFont';
|
|
17
17
|
import FormulaContainer from './components/formula';
|
|
18
18
|
import { validatorFormula } from './components/formula/util';
|
|
19
|
+
import _ from 'lodash';
|
|
19
20
|
var classPrefix = 'biz-formula-target';
|
|
20
21
|
var defaultValue = {
|
|
21
22
|
type: 'custom',
|
|
22
23
|
eventName: '自定义指标'
|
|
23
24
|
};
|
|
24
25
|
var BizFormulaTarget = function BizFormulaTarget(props) {
|
|
25
|
-
var _props$value, _props$value2;
|
|
26
26
|
var _useState = useState(false),
|
|
27
27
|
_useState2 = _slicedToArray(_useState, 2),
|
|
28
28
|
isEdit = _useState2[0],
|
|
29
29
|
setIsEdit = _useState2[1];
|
|
30
|
-
var _useState3 = useState(
|
|
30
|
+
var _useState3 = useState(),
|
|
31
31
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
var _useState5 = useState(
|
|
32
|
+
temporaryName = _useState4[0],
|
|
33
|
+
setTemporaryName = _useState4[1];
|
|
34
|
+
var _useState5 = useState(''),
|
|
35
35
|
_useState6 = _slicedToArray(_useState5, 2),
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
var _useState7 = useState(
|
|
36
|
+
nameError = _useState6[0],
|
|
37
|
+
setNameError = _useState6[1];
|
|
38
|
+
var _useState7 = useState(props.value || defaultValue),
|
|
39
39
|
_useState8 = _slicedToArray(_useState7, 2),
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
var _useState9 = useState(
|
|
40
|
+
condition = _useState8[0],
|
|
41
|
+
setCondition = _useState8[1];
|
|
42
|
+
var _useState9 = useState(false),
|
|
43
43
|
_useState10 = _slicedToArray(_useState9, 2),
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
var _useState11 = useState(
|
|
44
|
+
open = _useState10[0],
|
|
45
|
+
setOpen = _useState10[1];
|
|
46
|
+
var _useState11 = useState(''),
|
|
47
47
|
_useState12 = _slicedToArray(_useState11, 2),
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
var _useState13 = useState(false),
|
|
51
|
-
_useState14 = _slicedToArray(_useState13, 2),
|
|
52
|
-
open = _useState14[0],
|
|
53
|
-
setOpen = _useState14[1];
|
|
54
|
-
var _useState15 = useState(''),
|
|
55
|
-
_useState16 = _slicedToArray(_useState15, 2),
|
|
56
|
-
errorMsg = _useState16[0],
|
|
57
|
-
setErrorMsg = _useState16[1];
|
|
48
|
+
errorMsg = _useState12[0],
|
|
49
|
+
setErrorMsg = _useState12[1];
|
|
58
50
|
var formulaRef = useRef(null);
|
|
51
|
+
var contentChange = useMemo(function () {
|
|
52
|
+
return !_.isEqual(props.value, condition);
|
|
53
|
+
}, [props.value, condition]);
|
|
59
54
|
var onChangeTemporaryName = function onChangeTemporaryName(e) {
|
|
60
55
|
var name = e.target.value;
|
|
61
56
|
setTemporaryName(name);
|
|
@@ -67,7 +62,12 @@ var BizFormulaTarget = function BizFormulaTarget(props) {
|
|
|
67
62
|
};
|
|
68
63
|
var onChangeName = function onChangeName() {
|
|
69
64
|
if (!validatorName(temporaryName)) return;
|
|
70
|
-
|
|
65
|
+
setCondition(function (data) {
|
|
66
|
+
return _objectSpread(_objectSpread({}, data), {}, {
|
|
67
|
+
eventName: temporaryName,
|
|
68
|
+
alias: temporaryName
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
71
|
setIsEdit(false);
|
|
72
72
|
};
|
|
73
73
|
var validatorName = function validatorName(name) {
|
|
@@ -76,8 +76,7 @@ var BizFormulaTarget = function BizFormulaTarget(props) {
|
|
|
76
76
|
if (!name) {
|
|
77
77
|
msg = '指标名称不能为空';
|
|
78
78
|
flag = false;
|
|
79
|
-
}
|
|
80
|
-
if (props.disableNames && props.disableNames.includes(name)) {
|
|
79
|
+
} else if (props.disableNames && props.disableNames.includes(name)) {
|
|
81
80
|
msg = '指标名称不能重复';
|
|
82
81
|
flag = false;
|
|
83
82
|
}
|
|
@@ -85,54 +84,45 @@ var BizFormulaTarget = function BizFormulaTarget(props) {
|
|
|
85
84
|
return flag;
|
|
86
85
|
};
|
|
87
86
|
var onCancelChangeName = function onCancelChangeName() {
|
|
88
|
-
setTemporaryName(
|
|
87
|
+
setTemporaryName(condition === null || condition === void 0 ? void 0 : condition.eventName);
|
|
89
88
|
setIsEdit(false);
|
|
90
89
|
setNameError('');
|
|
91
90
|
};
|
|
92
91
|
var onSave = function onSave() {
|
|
93
|
-
if (!validatorName(
|
|
92
|
+
if (!validatorName(condition.eventName)) return;
|
|
94
93
|
var validateData = validatorFormula(condition);
|
|
95
94
|
if (!validateData.isOk) {
|
|
96
95
|
setErrorMsg(validateData.msg);
|
|
97
96
|
setOpen(true);
|
|
98
97
|
return;
|
|
99
98
|
}
|
|
100
|
-
|
|
101
|
-
props.onChange && props.onChange(_objectSpread(_objectSpread({}, condition), {}, {
|
|
102
|
-
type: 'custom',
|
|
103
|
-
alias: name,
|
|
104
|
-
eventName: name
|
|
105
|
-
}));
|
|
99
|
+
props.onChange && props.onChange(condition);
|
|
106
100
|
};
|
|
107
101
|
var onDelete = function onDelete(e) {
|
|
108
102
|
e.stopPropagation();
|
|
103
|
+
if (!props.enableDelete && !contentChange) return;
|
|
109
104
|
props.onDelete && props.onDelete();
|
|
110
105
|
};
|
|
111
106
|
var onCancel = function onCancel(e) {
|
|
112
107
|
e.stopPropagation();
|
|
113
108
|
if (!props.value || !props.value.customCondition || !props.value.customCondition.length) {
|
|
109
|
+
if (!props.enableDelete) return;
|
|
114
110
|
props.onDelete && props.onDelete();
|
|
115
111
|
} else {
|
|
116
|
-
var _props$value3;
|
|
117
112
|
setCondition(props.value || defaultValue);
|
|
118
|
-
setName(((_props$value3 = props.value) === null || _props$value3 === void 0 ? void 0 : _props$value3.eventName) || defaultValue.eventName);
|
|
119
113
|
setTimeout(function () {
|
|
120
114
|
formulaRef.current.reset();
|
|
121
115
|
}, 0);
|
|
122
116
|
}
|
|
123
|
-
setIsNormal(true);
|
|
124
117
|
};
|
|
125
118
|
var onChange = function onChange(customCondition, formula, resultFormat) {
|
|
126
119
|
setCondition(function (value) {
|
|
127
|
-
return _objectSpread(_objectSpread({}, value
|
|
128
|
-
eventName: name
|
|
129
|
-
}), {}, {
|
|
120
|
+
return _objectSpread(_objectSpread({}, value), {}, {
|
|
130
121
|
customCondition: customCondition,
|
|
131
122
|
formula: formula,
|
|
132
123
|
resultFormat: resultFormat
|
|
133
124
|
});
|
|
134
125
|
});
|
|
135
|
-
setIsNormal(false);
|
|
136
126
|
};
|
|
137
127
|
var onClose = function onClose() {
|
|
138
128
|
setOpen(false);
|
|
@@ -147,14 +137,14 @@ var BizFormulaTarget = function BizFormulaTarget(props) {
|
|
|
147
137
|
className: "".concat(classPrefix, "-title-content")
|
|
148
138
|
}, isEdit ? /*#__PURE__*/React.createElement(Input, {
|
|
149
139
|
className: "".concat(classPrefix, "-title-input").concat(isEdit ? ' focused' : ''),
|
|
150
|
-
defaultValue:
|
|
140
|
+
defaultValue: condition.eventName,
|
|
151
141
|
autoFocus: true,
|
|
152
142
|
maxLength: 20,
|
|
153
143
|
status: nameError ? 'error' : '',
|
|
154
144
|
placeholder: "\u8BF7\u8F93\u5165",
|
|
155
145
|
onChange: onChangeTemporaryName
|
|
156
|
-
}) : /*#__PURE__*/React.createElement("span", null,
|
|
157
|
-
className: "".concat(classPrefix, "-title-option").concat(isEdit ||
|
|
146
|
+
}) : /*#__PURE__*/React.createElement("span", null, condition.eventName)), /*#__PURE__*/React.createElement("div", {
|
|
147
|
+
className: "".concat(classPrefix, "-title-option").concat(isEdit || contentChange ? ' show' : '')
|
|
158
148
|
}, isEdit ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
159
149
|
className: "primary",
|
|
160
150
|
onClick: onChangeName
|
|
@@ -166,7 +156,7 @@ var BizFormulaTarget = function BizFormulaTarget(props) {
|
|
|
166
156
|
onClick: function onClick() {
|
|
167
157
|
return setIsEdit(true);
|
|
168
158
|
}
|
|
169
|
-
}), /*#__PURE__*/React.createElement(Popconfirm, {
|
|
159
|
+
}), contentChange ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Popconfirm, {
|
|
170
160
|
title: errorMsg,
|
|
171
161
|
open: open,
|
|
172
162
|
onCancel: onClose,
|
|
@@ -178,8 +168,8 @@ var BizFormulaTarget = function BizFormulaTarget(props) {
|
|
|
178
168
|
onClick: function onClick(e) {
|
|
179
169
|
return onCancel(e);
|
|
180
170
|
}
|
|
181
|
-
}, "\u53D6\u6D88"), /*#__PURE__*/React.createElement("div", {
|
|
182
|
-
className: "delete",
|
|
171
|
+
}, "\u53D6\u6D88")) : null, /*#__PURE__*/React.createElement("div", {
|
|
172
|
+
className: "delete".concat(!props.enableDelete && !contentChange ? ' disable' : ''),
|
|
183
173
|
onClick: function onClick(e) {
|
|
184
174
|
return onDelete(e);
|
|
185
175
|
}
|
|
@@ -193,4 +183,7 @@ var BizFormulaTarget = function BizFormulaTarget(props) {
|
|
|
193
183
|
onChange: onChange
|
|
194
184
|
}));
|
|
195
185
|
};
|
|
186
|
+
BizFormulaTarget.defaultProps = {
|
|
187
|
+
enableDelete: true
|
|
188
|
+
};
|
|
196
189
|
export default BizFormulaTarget;
|
|
@@ -6,6 +6,10 @@
|
|
|
6
6
|
.biz-formula-target-title-option {
|
|
7
7
|
display: flex;
|
|
8
8
|
}
|
|
9
|
+
.formula-container-option:not(.active) {
|
|
10
|
+
display: flex;
|
|
11
|
+
color: #b9ceff;
|
|
12
|
+
}
|
|
9
13
|
}
|
|
10
14
|
|
|
11
15
|
&-title {
|
|
@@ -45,16 +49,18 @@
|
|
|
45
49
|
}
|
|
46
50
|
|
|
47
51
|
&-icon {
|
|
48
|
-
margin
|
|
52
|
+
margin: 0 8px;
|
|
49
53
|
font-size: 16px !important;
|
|
50
54
|
cursor: pointer;
|
|
51
55
|
}
|
|
52
56
|
|
|
53
57
|
.primary {
|
|
54
|
-
margin-left: 8px;
|
|
55
58
|
color: @primary-color;
|
|
56
59
|
}
|
|
57
|
-
.
|
|
60
|
+
.disable {
|
|
61
|
+
cursor: not-allowed;
|
|
62
|
+
}
|
|
63
|
+
.delete:not(.disable):hover {
|
|
58
64
|
color: @error-color;
|
|
59
65
|
}
|
|
60
66
|
}
|
|
@@ -41,6 +41,10 @@ export default (function () {
|
|
|
41
41
|
_useState6 = _slicedToArray(_useState5, 2),
|
|
42
42
|
enableAdd = _useState6[0],
|
|
43
43
|
setEnableAdd = _useState6[1];
|
|
44
|
+
var _useState7 = useState(false),
|
|
45
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
46
|
+
enableDelete = _useState8[0],
|
|
47
|
+
setEnableDelete = _useState8[1];
|
|
44
48
|
var _Form$useForm = Form.useForm(),
|
|
45
49
|
_Form$useForm2 = _slicedToArray(_Form$useForm, 1),
|
|
46
50
|
form = _Form$useForm2[0];
|
|
@@ -55,6 +59,7 @@ export default (function () {
|
|
|
55
59
|
useEffect(function () {
|
|
56
60
|
var flag = true,
|
|
57
61
|
show = true;
|
|
62
|
+
console.log(target.targets, target.targets.length > 1);
|
|
58
63
|
if ((target === null || target === void 0 ? void 0 : target.targets) && target.targets.length > 0) {
|
|
59
64
|
if (target.targets[0] && target.targets[0].eventId === -100) {
|
|
60
65
|
flag = false;
|
|
@@ -63,6 +68,7 @@ export default (function () {
|
|
|
63
68
|
show = false;
|
|
64
69
|
}
|
|
65
70
|
}
|
|
71
|
+
setEnableDelete(target.targets.length > 1);
|
|
66
72
|
setShowOverview(show);
|
|
67
73
|
setEnableAdd(flag);
|
|
68
74
|
}, [target === null || target === void 0 ? void 0 : target.targets]);
|
|
@@ -87,14 +93,9 @@ export default (function () {
|
|
|
87
93
|
return /*#__PURE__*/React.createElement(Form.Item, _objectSpread(_objectSpread({}, field), {}, {
|
|
88
94
|
key: field.key
|
|
89
95
|
}), /*#__PURE__*/React.createElement(BizTargetCondition, {
|
|
96
|
+
enableDelete: enableDelete,
|
|
90
97
|
onDelete: function onDelete() {
|
|
91
|
-
|
|
92
|
-
remove(field.name);
|
|
93
|
-
} else {
|
|
94
|
-
form.setFieldsValue({
|
|
95
|
-
targets: [initValue]
|
|
96
|
-
});
|
|
97
|
-
}
|
|
98
|
+
remove(field.name);
|
|
98
99
|
}
|
|
99
100
|
}, /*#__PURE__*/React.createElement(BizEventSelector, {
|
|
100
101
|
showAllEvent: showOverview,
|
|
@@ -44,7 +44,7 @@ var BizTargetCondition = function BizTargetCondition(props) {
|
|
|
44
44
|
_useState8 = _slicedToArray(_useState7, 2),
|
|
45
45
|
enableAdd = _useState8[0],
|
|
46
46
|
setEnableAdd = _useState8[1];
|
|
47
|
-
var _useState9 = useState(
|
|
47
|
+
var _useState9 = useState(props.enableDelete),
|
|
48
48
|
_useState10 = _slicedToArray(_useState9, 2),
|
|
49
49
|
enableDelete = _useState10[0],
|
|
50
50
|
setEnableDelete = _useState10[1];
|
|
@@ -52,7 +52,7 @@ var BizTargetCondition = function BizTargetCondition(props) {
|
|
|
52
52
|
_useState12 = _slicedToArray(_useState11, 2),
|
|
53
53
|
count = _useState12[0],
|
|
54
54
|
setCount = _useState12[1];
|
|
55
|
-
var _useState13 = useState(
|
|
55
|
+
var _useState13 = useState(false),
|
|
56
56
|
_useState14 = _slicedToArray(_useState13, 2),
|
|
57
57
|
isAdd = _useState14[0],
|
|
58
58
|
setIsAdd = _useState14[1];
|
|
@@ -90,7 +90,9 @@ var BizTargetCondition = function BizTargetCondition(props) {
|
|
|
90
90
|
canAdd = count < max;
|
|
91
91
|
}
|
|
92
92
|
setEnableAdd(canAdd);
|
|
93
|
-
|
|
93
|
+
if (props.enableDelete !== undefined) {
|
|
94
|
+
setEnableDelete(canDelete);
|
|
95
|
+
}
|
|
94
96
|
} else {
|
|
95
97
|
setEnableAdd(false);
|
|
96
98
|
}
|
|
@@ -219,7 +221,7 @@ var BizTargetCondition = function BizTargetCondition(props) {
|
|
|
219
221
|
}, 0);
|
|
220
222
|
};
|
|
221
223
|
var onDelete = function onDelete() {
|
|
222
|
-
if (!enableDelete) return;
|
|
224
|
+
if (!(props.enableDelete !== undefined ? props.enableDelete : enableDelete)) return;
|
|
223
225
|
if (props.onDelete) props.onDelete();
|
|
224
226
|
};
|
|
225
227
|
return /*#__PURE__*/React.createElement("div", {
|
|
@@ -246,7 +248,7 @@ var BizTargetCondition = function BizTargetCondition(props) {
|
|
|
246
248
|
type: "shaixuan",
|
|
247
249
|
onClick: onAdd
|
|
248
250
|
})), /*#__PURE__*/React.createElement(IconFont, {
|
|
249
|
-
className: "".concat(classPrefix, "-icon delete ").concat(!enableDelete ? 'disabled' : ''),
|
|
251
|
+
className: "".concat(classPrefix, "-icon delete ").concat(!(props.enableDelete !== undefined ? props.enableDelete : enableDelete) ? 'disabled' : ''),
|
|
250
252
|
type: "qingchu",
|
|
251
253
|
onClick: onDelete
|
|
252
254
|
})), (filters || isAdd) && /*#__PURE__*/React.createElement(BizAttrConditionGroup, {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zgfe/business-lib",
|
|
3
|
-
"version": "1.1.67-beta.
|
|
3
|
+
"version": "1.1.67-beta.4",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"start": "dumi dev",
|
|
6
6
|
"docs:build": "dumi build",
|
|
@@ -60,5 +60,5 @@
|
|
|
60
60
|
"react": "^16.12.0 || ^17.0.0",
|
|
61
61
|
"yorkie": "^2.0.0"
|
|
62
62
|
},
|
|
63
|
-
"gitHead": "
|
|
63
|
+
"gitHead": "69f43c91e600c8c965e1f83da23b9e3d96e4b490"
|
|
64
64
|
}
|