@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.
@@ -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: @border-color-base;
150
- box-shadow: none;
149
+ border-color: @primary-color;
151
150
  }
152
151
  }
153
152
  }
@@ -74,6 +74,7 @@
74
74
  }
75
75
 
76
76
  .ant-select {
77
+ background: #fafafb;
77
78
  border: 1px solid #fafafb;
78
79
  border-radius: 2px;
79
80
  &:hover {
@@ -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", {
@@ -123,6 +123,12 @@
123
123
  .ant-btn:not(:last-child) {
124
124
  margin-right: 16px;
125
125
  }
126
+ .ant-btn-text {
127
+ &:hover {
128
+ color: @error-color !important;
129
+ background: #f2f3f4 !important;
130
+ }
131
+ }
126
132
  }
127
133
 
128
134
  &-error {
@@ -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);
@@ -15,6 +15,10 @@ export default (function () {
15
15
  padding: 20
16
16
  }
17
17
  }, /*#__PURE__*/React.createElement(BizFormulaTarget, {
18
+ value: {
19
+ type: 'custom',
20
+ eventName: '自定义指标'
21
+ },
18
22
  onChange: onChange,
19
23
  onDelete: onDelete
20
24
  })));
@@ -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(true),
30
+ var _useState3 = useState(),
31
31
  _useState4 = _slicedToArray(_useState3, 2),
32
- isNormal = _useState4[0],
33
- setIsNormal = _useState4[1];
34
- var _useState5 = useState(((_props$value = props.value) === null || _props$value === void 0 ? void 0 : _props$value.eventName) || defaultValue.eventName),
32
+ temporaryName = _useState4[0],
33
+ setTemporaryName = _useState4[1];
34
+ var _useState5 = useState(''),
35
35
  _useState6 = _slicedToArray(_useState5, 2),
36
- name = _useState6[0],
37
- setName = _useState6[1];
38
- var _useState7 = useState(((_props$value2 = props.value) === null || _props$value2 === void 0 ? void 0 : _props$value2.eventName) || defaultValue.eventName),
36
+ nameError = _useState6[0],
37
+ setNameError = _useState6[1];
38
+ var _useState7 = useState(props.value || defaultValue),
39
39
  _useState8 = _slicedToArray(_useState7, 2),
40
- temporaryName = _useState8[0],
41
- setTemporaryName = _useState8[1];
42
- var _useState9 = useState(''),
40
+ condition = _useState8[0],
41
+ setCondition = _useState8[1];
42
+ var _useState9 = useState(false),
43
43
  _useState10 = _slicedToArray(_useState9, 2),
44
- nameError = _useState10[0],
45
- setNameError = _useState10[1];
46
- var _useState11 = useState(props.value || defaultValue),
44
+ open = _useState10[0],
45
+ setOpen = _useState10[1];
46
+ var _useState11 = useState(''),
47
47
  _useState12 = _slicedToArray(_useState11, 2),
48
- condition = _useState12[0],
49
- setCondition = _useState12[1];
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
- setName(temporaryName);
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(name);
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(name)) return;
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
- setIsNormal(true);
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: name,
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, name)), /*#__PURE__*/React.createElement("div", {
157
- className: "".concat(classPrefix, "-title-option").concat(isEdit || !isNormal ? ' show' : '')
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-left: 8px;
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
- .delete:hover {
60
+ .disable {
61
+ cursor: not-allowed;
62
+ }
63
+ .delete:not(.disable):hover {
58
64
  color: @error-color;
59
65
  }
60
66
  }
@@ -3,6 +3,7 @@ export declare namespace BizFormulaTargetTypes {
3
3
  interface Props {
4
4
  value?: Value;
5
5
  disableNames?: string[];
6
+ enableDelete?: boolean;
6
7
  onChange?: (data: Value) => void;
7
8
  onDelete?: () => void;
8
9
  }
@@ -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
- if (fields.length > 1) {
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(true),
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(true),
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
- setEnableDelete(canDelete);
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, {
@@ -28,6 +28,7 @@ export declare namespace TargetConditionTypes {
28
28
  max?: number;
29
29
  children: ReactNode;
30
30
  onlyAnd?: boolean;
31
+ enableDelete?: boolean;
31
32
  onChange?: (value: Value) => void;
32
33
  onDelete?: (value?: Value) => void;
33
34
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zgfe/business-lib",
3
- "version": "1.1.67-beta.2",
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": "4544eca127a8c4b92ac78e3911a53ae6b33e8473"
63
+ "gitHead": "69f43c91e600c8c965e1f83da23b9e3d96e4b490"
64
64
  }