@zgfe/business-lib 1.1.67-beta.3 → 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,28 +84,23 @@ 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();
109
- if (!props.enableDelete) return;
103
+ if (!props.enableDelete && !contentChange) return;
110
104
  props.onDelete && props.onDelete();
111
105
  };
112
106
  var onCancel = function onCancel(e) {
@@ -115,26 +109,20 @@ var BizFormulaTarget = function BizFormulaTarget(props) {
115
109
  if (!props.enableDelete) return;
116
110
  props.onDelete && props.onDelete();
117
111
  } else {
118
- var _props$value3;
119
112
  setCondition(props.value || defaultValue);
120
- setName(((_props$value3 = props.value) === null || _props$value3 === void 0 ? void 0 : _props$value3.eventName) || defaultValue.eventName);
121
113
  setTimeout(function () {
122
114
  formulaRef.current.reset();
123
115
  }, 0);
124
116
  }
125
- setIsNormal(true);
126
117
  };
127
118
  var onChange = function onChange(customCondition, formula, resultFormat) {
128
119
  setCondition(function (value) {
129
- return _objectSpread(_objectSpread({}, value || {
130
- eventName: name
131
- }), {}, {
120
+ return _objectSpread(_objectSpread({}, value), {}, {
132
121
  customCondition: customCondition,
133
122
  formula: formula,
134
123
  resultFormat: resultFormat
135
124
  });
136
125
  });
137
- setIsNormal(false);
138
126
  };
139
127
  var onClose = function onClose() {
140
128
  setOpen(false);
@@ -149,14 +137,14 @@ var BizFormulaTarget = function BizFormulaTarget(props) {
149
137
  className: "".concat(classPrefix, "-title-content")
150
138
  }, isEdit ? /*#__PURE__*/React.createElement(Input, {
151
139
  className: "".concat(classPrefix, "-title-input").concat(isEdit ? ' focused' : ''),
152
- defaultValue: name,
140
+ defaultValue: condition.eventName,
153
141
  autoFocus: true,
154
142
  maxLength: 20,
155
143
  status: nameError ? 'error' : '',
156
144
  placeholder: "\u8BF7\u8F93\u5165",
157
145
  onChange: onChangeTemporaryName
158
- }) : /*#__PURE__*/React.createElement("span", null, name)), /*#__PURE__*/React.createElement("div", {
159
- 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' : '')
160
148
  }, isEdit ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
161
149
  className: "primary",
162
150
  onClick: onChangeName
@@ -168,7 +156,7 @@ var BizFormulaTarget = function BizFormulaTarget(props) {
168
156
  onClick: function onClick() {
169
157
  return setIsEdit(true);
170
158
  }
171
- }), /*#__PURE__*/React.createElement(Popconfirm, {
159
+ }), contentChange ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Popconfirm, {
172
160
  title: errorMsg,
173
161
  open: open,
174
162
  onCancel: onClose,
@@ -180,8 +168,8 @@ var BizFormulaTarget = function BizFormulaTarget(props) {
180
168
  onClick: function onClick(e) {
181
169
  return onCancel(e);
182
170
  }
183
- }, "\u53D6\u6D88"), /*#__PURE__*/React.createElement("div", {
184
- className: "delete".concat(!props.enableDelete ? ' disable' : ''),
171
+ }, "\u53D6\u6D88")) : null, /*#__PURE__*/React.createElement("div", {
172
+ className: "delete".concat(!props.enableDelete && !contentChange ? ' disable' : ''),
185
173
  onClick: function onClick(e) {
186
174
  return onDelete(e);
187
175
  }
@@ -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,13 +49,12 @@
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
60
  .disable {
@@ -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];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zgfe/business-lib",
3
- "version": "1.1.67-beta.3",
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": "60b424a819cbf1465a05510288a93b9cda0b67d0"
63
+ "gitHead": "69f43c91e600c8c965e1f83da23b9e3d96e4b490"
64
64
  }