@zat-design/sisyphus-react 3.6.4-beta.10 → 3.6.4-beta.11
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/ProEditTable/components/RenderField/index.js +97 -91
- package/es/ProForm/components/FormFooter/index.js +1 -1
- package/es/ProForm/components/base/InputNumber/index.js +20 -11
- package/lib/ProEditTable/components/RenderField/index.js +96 -90
- package/lib/ProForm/components/FormFooter/index.js +1 -1
- package/lib/ProForm/components/base/InputNumber/index.js +20 -11
- package/package.json +1 -1
|
@@ -17,7 +17,7 @@ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-run
|
|
|
17
17
|
/* eslint-disable prefer-const */
|
|
18
18
|
import React, { useCallback, useEffect } from 'react';
|
|
19
19
|
import classNames from 'classnames';
|
|
20
|
-
import { cloneDeep, isEqual,
|
|
20
|
+
import { cloneDeep, isEqual, omit, isFunction } from 'lodash';
|
|
21
21
|
import valueTypeMap from '../../../ProForm/utils/valueType';
|
|
22
22
|
import transformMap from '../../utils/transform';
|
|
23
23
|
import { getNamePath, difference, getDisabled } from '../../utils/tools';
|
|
@@ -296,101 +296,107 @@ var RenderField = function RenderField(_ref) {
|
|
|
296
296
|
}, 100);
|
|
297
297
|
};
|
|
298
298
|
// 单元格更新数据时,加个防抖,防止更新频率过快,卡顿
|
|
299
|
-
var _onChange =
|
|
300
|
-
var
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
args
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
299
|
+
var _onChange = /*#__PURE__*/function () {
|
|
300
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
301
|
+
var _len2,
|
|
302
|
+
args,
|
|
303
|
+
_key2,
|
|
304
|
+
_args,
|
|
305
|
+
rowPath,
|
|
306
|
+
row,
|
|
307
|
+
orgRow,
|
|
308
|
+
_TargetComponent,
|
|
309
|
+
_TargetComponent$prop,
|
|
310
|
+
_TargetComponent$prop2,
|
|
311
|
+
_TargetComponent2,
|
|
312
|
+
_TargetComponent2$pro,
|
|
313
|
+
_TargetComponent$prop3,
|
|
314
|
+
_Object$keys,
|
|
315
|
+
_Object$keys$map,
|
|
316
|
+
diff,
|
|
317
|
+
validateFieldKeys,
|
|
318
|
+
_args2 = arguments;
|
|
319
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
320
|
+
while (1) switch (_context.prev = _context.next) {
|
|
321
|
+
case 0:
|
|
322
|
+
for (_len2 = _args2.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
323
|
+
args[_key2] = _args2[_key2];
|
|
324
|
+
}
|
|
325
|
+
_args = [].concat(args);
|
|
326
|
+
rowPath = [].concat(_toConsumableArray(namePath), [index]);
|
|
327
|
+
row = form.getFieldValue(rowPath, true);
|
|
328
|
+
orgRow = cloneDeep(row);
|
|
329
|
+
if (!onFieldChange) {
|
|
330
|
+
_context.next = 18;
|
|
331
|
+
break;
|
|
332
|
+
}
|
|
333
|
+
_args = formatArgs(args);
|
|
334
|
+
_args[1] = row;
|
|
335
|
+
_context.t0 = (_TargetComponent = TargetComponent) === null || _TargetComponent === void 0 ? void 0 : (_TargetComponent$prop = _TargetComponent.props) === null || _TargetComponent$prop === void 0 ? void 0 : _TargetComponent$prop.onFieldChange;
|
|
336
|
+
if (!_context.t0) {
|
|
337
|
+
_context.next = 12;
|
|
338
|
+
break;
|
|
339
|
+
}
|
|
336
340
|
_context.next = 12;
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
341
|
+
return (_TargetComponent$prop2 = TargetComponent.props).onFieldChange.apply(_TargetComponent$prop2, _toConsumableArray(_args));
|
|
342
|
+
case 12:
|
|
343
|
+
_context.t1 = onFieldChange;
|
|
344
|
+
if (!_context.t1) {
|
|
345
|
+
_context.next = 16;
|
|
346
|
+
break;
|
|
347
|
+
}
|
|
344
348
|
_context.next = 16;
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
_context.next = 16;
|
|
348
|
-
return onFieldChange.apply(void 0, _toConsumableArray(_args));
|
|
349
|
-
case 16:
|
|
350
|
-
_context.next = 27;
|
|
351
|
-
break;
|
|
352
|
-
case 18:
|
|
353
|
-
_args = _args.concat([row, index, form]);
|
|
354
|
-
_context.t2 = (_TargetComponent2 = TargetComponent) === null || _TargetComponent2 === void 0 ? void 0 : (_TargetComponent2$pro = _TargetComponent2.props) === null || _TargetComponent2$pro === void 0 ? void 0 : _TargetComponent2$pro.onChange;
|
|
355
|
-
if (!_context.t2) {
|
|
356
|
-
_context.next = 23;
|
|
357
|
-
break;
|
|
358
|
-
}
|
|
359
|
-
_context.next = 23;
|
|
360
|
-
return (_TargetComponent$prop3 = TargetComponent.props).onChange.apply(_TargetComponent$prop3, _toConsumableArray(_args));
|
|
361
|
-
case 23:
|
|
362
|
-
_context.t3 = onChange;
|
|
363
|
-
if (!_context.t3) {
|
|
349
|
+
return onFieldChange.apply(void 0, _toConsumableArray(_args));
|
|
350
|
+
case 16:
|
|
364
351
|
_context.next = 27;
|
|
365
352
|
break;
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
if (!isEqual(orgRow, row)) {
|
|
373
|
-
diff = difference(row, orgRow) || {};
|
|
374
|
-
validateFieldKeys = (_Object$keys = Object.keys(diff)) === null || _Object$keys === void 0 ? void 0 : (_Object$keys$map = _Object$keys.map) === null || _Object$keys$map === void 0 ? void 0 : _Object$keys$map.call(_Object$keys, function (key) {
|
|
375
|
-
return [].concat(_toConsumableArray(rowPath), [key]);
|
|
376
|
-
});
|
|
377
|
-
if (validateFieldKeys === null || validateFieldKeys === void 0 ? void 0 : validateFieldKeys.length) {
|
|
378
|
-
setTimeout(function () {
|
|
379
|
-
form.validateFields(validateFieldKeys);
|
|
380
|
-
}, 100);
|
|
353
|
+
case 18:
|
|
354
|
+
_args = _args.concat([row, index, form]);
|
|
355
|
+
_context.t2 = (_TargetComponent2 = TargetComponent) === null || _TargetComponent2 === void 0 ? void 0 : (_TargetComponent2$pro = _TargetComponent2.props) === null || _TargetComponent2$pro === void 0 ? void 0 : _TargetComponent2$pro.onChange;
|
|
356
|
+
if (!_context.t2) {
|
|
357
|
+
_context.next = 23;
|
|
358
|
+
break;
|
|
381
359
|
}
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
360
|
+
_context.next = 23;
|
|
361
|
+
return (_TargetComponent$prop3 = TargetComponent.props).onChange.apply(_TargetComponent$prop3, _toConsumableArray(_args));
|
|
362
|
+
case 23:
|
|
363
|
+
_context.t3 = onChange;
|
|
364
|
+
if (!_context.t3) {
|
|
365
|
+
_context.next = 27;
|
|
366
|
+
break;
|
|
386
367
|
}
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
368
|
+
_context.next = 27;
|
|
369
|
+
return onChange.apply(void 0, _toConsumableArray(_args));
|
|
370
|
+
case 27:
|
|
371
|
+
// 判断属性是否变动
|
|
372
|
+
form.setFieldValue(rowPath, _objectSpread({}, row));
|
|
373
|
+
if (!isEqual(orgRow, row)) {
|
|
374
|
+
diff = difference(row, orgRow) || {};
|
|
375
|
+
validateFieldKeys = (_Object$keys = Object.keys(diff)) === null || _Object$keys === void 0 ? void 0 : (_Object$keys$map = _Object$keys.map) === null || _Object$keys$map === void 0 ? void 0 : _Object$keys$map.call(_Object$keys, function (key) {
|
|
376
|
+
return [].concat(_toConsumableArray(rowPath), [key]);
|
|
377
|
+
});
|
|
378
|
+
if (validateFieldKeys === null || validateFieldKeys === void 0 ? void 0 : validateFieldKeys.length) {
|
|
379
|
+
setTimeout(function () {
|
|
380
|
+
form.validateFields(validateFieldKeys);
|
|
381
|
+
}, 100);
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
// 单行编辑时需要 强制更新视图
|
|
385
|
+
setState({
|
|
386
|
+
forceUpdate: {
|
|
387
|
+
d: Date.now()
|
|
388
|
+
}
|
|
389
|
+
});
|
|
390
|
+
case 30:
|
|
391
|
+
case "end":
|
|
392
|
+
return _context.stop();
|
|
393
|
+
}
|
|
394
|
+
}, _callee);
|
|
395
|
+
}));
|
|
396
|
+
return function _onChange() {
|
|
397
|
+
return _ref2.apply(this, arguments);
|
|
398
|
+
};
|
|
399
|
+
}();
|
|
394
400
|
var _onblur = /*#__PURE__*/function () {
|
|
395
401
|
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
396
402
|
var _TargetComponent3, _TargetComponent3$pro, _TargetComponent$prop4;
|
|
@@ -434,7 +440,7 @@ var RenderField = function RenderField(_ref) {
|
|
|
434
440
|
return onBlur.apply(void 0, _toConsumableArray(_args));
|
|
435
441
|
case 14:
|
|
436
442
|
// 判断属性是否变动
|
|
437
|
-
form.setFieldValue(rowPath, row);
|
|
443
|
+
form.setFieldValue(rowPath, _objectSpread({}, row));
|
|
438
444
|
if (!isEqual(orgRow, row)) {
|
|
439
445
|
diff = difference(row, orgRow) || {};
|
|
440
446
|
validateFieldKeys = (_Object$keys2 = Object.keys(diff)) === null || _Object$keys2 === void 0 ? void 0 : (_Object$keys2$map = _Object$keys2.map) === null || _Object$keys2$map === void 0 ? void 0 : _Object$keys2$map.call(_Object$keys2, function (key) {
|
|
@@ -35,6 +35,7 @@ var limitNumber = function limitNumber(num, _ref) {
|
|
|
35
35
|
return num;
|
|
36
36
|
};
|
|
37
37
|
var InputNumber = function InputNumber(props) {
|
|
38
|
+
var _props$precision4;
|
|
38
39
|
var placeholder = props.placeholder,
|
|
39
40
|
className = props.className,
|
|
40
41
|
otherProps = props.otherProps,
|
|
@@ -55,28 +56,33 @@ var InputNumber = function InputNumber(props) {
|
|
|
55
56
|
var isView = typeof props.isView === 'boolean' ? props.isView : isViewCon; // 组件可直接接收isView参数, 优先级高
|
|
56
57
|
var valueProps = {};
|
|
57
58
|
var formatter = function formatter(value) {
|
|
59
|
+
var _props$precision;
|
|
58
60
|
if (value === '') return '';
|
|
59
61
|
var num = Number(value);
|
|
60
62
|
if (Number.isNaN(num)) {
|
|
61
63
|
return value;
|
|
62
64
|
}
|
|
63
65
|
var val = num.toLocaleString('en-US', {
|
|
64
|
-
maximumFractionDigits: (props === null || props === void 0 ? void 0 : props.precision)
|
|
66
|
+
maximumFractionDigits: (_props$precision = props === null || props === void 0 ? void 0 : props.precision) !== null && _props$precision !== void 0 ? _props$precision : 2
|
|
65
67
|
});
|
|
66
68
|
if (!activateRef.current) {
|
|
69
|
+
var _props$precision2;
|
|
67
70
|
var _val$split = val.split('.'),
|
|
68
71
|
_val$split2 = _slicedToArray(_val$split, 2),
|
|
69
72
|
int = _val$split2[0],
|
|
70
73
|
_val$split2$ = _val$split2[1],
|
|
71
74
|
float = _val$split2$ === void 0 ? '' : _val$split2$;
|
|
72
|
-
|
|
75
|
+
if ((props === null || props === void 0 ? void 0 : props.precision) === 0) {
|
|
76
|
+
return int;
|
|
77
|
+
}
|
|
78
|
+
return "".concat(int, ".").concat(float.padEnd((_props$precision2 = props === null || props === void 0 ? void 0 : props.precision) !== null && _props$precision2 !== void 0 ? _props$precision2 : 2, '0'));
|
|
73
79
|
}
|
|
74
80
|
return val;
|
|
75
81
|
};
|
|
76
82
|
var _parser = function parser(value, precision) {
|
|
77
|
-
var num = Number(value.replace(/[\s,]+/g, ''));
|
|
78
83
|
if (value === '') return value;
|
|
79
|
-
|
|
84
|
+
var num = Number(value.replace(/[\s,]+/g, ''));
|
|
85
|
+
return Number.isNaN(num) || !precision && precision !== 0 ? Number.isNaN(Number(value)) ? null : value : num.toFixed(precision);
|
|
80
86
|
};
|
|
81
87
|
if (valueType) {
|
|
82
88
|
switch (valueType) {
|
|
@@ -88,8 +94,10 @@ var InputNumber = function InputNumber(props) {
|
|
|
88
94
|
valueProps = {
|
|
89
95
|
formatter: formatter,
|
|
90
96
|
parser: function parser(val) {
|
|
91
|
-
|
|
92
|
-
|
|
97
|
+
var _props$precision3;
|
|
98
|
+
return _parser(val, (_props$precision3 = props === null || props === void 0 ? void 0 : props.precision) !== null && _props$precision3 !== void 0 ? _props$precision3 : 2);
|
|
99
|
+
},
|
|
100
|
+
precision: (_props$precision4 = props === null || props === void 0 ? void 0 : props.precision) !== null && _props$precision4 !== void 0 ? _props$precision4 : 2
|
|
93
101
|
};
|
|
94
102
|
break;
|
|
95
103
|
// 百分比
|
|
@@ -177,7 +185,7 @@ var InputNumber = function InputNumber(props) {
|
|
|
177
185
|
var originValue = calc(Number(value), '/', 100);
|
|
178
186
|
// 获取真实数据的小数位数
|
|
179
187
|
var decimalDigits = getDecimalDigits(originValue);
|
|
180
|
-
if (decimalDigits > (precision
|
|
188
|
+
if (decimalDigits > (precision !== null && precision !== void 0 ? precision : 4)) {
|
|
181
189
|
return _jsx(Container, {
|
|
182
190
|
viewEmpty: viewEmpty,
|
|
183
191
|
children: value
|
|
@@ -195,7 +203,7 @@ var InputNumber = function InputNumber(props) {
|
|
|
195
203
|
var _originValue = calc(Number(value), '/', 1000);
|
|
196
204
|
// 获取真实数据的小数位数
|
|
197
205
|
var _decimalDigits = getDecimalDigits(_originValue);
|
|
198
|
-
if (_decimalDigits > (precision
|
|
206
|
+
if (_decimalDigits > (precision !== null && precision !== void 0 ? precision : 5)) {
|
|
199
207
|
return _jsx(Container, {
|
|
200
208
|
viewEmpty: viewEmpty,
|
|
201
209
|
children: value
|
|
@@ -212,7 +220,7 @@ var InputNumber = function InputNumber(props) {
|
|
|
212
220
|
case 'thousandth':
|
|
213
221
|
return _jsx(Container, {
|
|
214
222
|
viewEmpty: viewEmpty,
|
|
215
|
-
children: tools.formatAmount(value, precision
|
|
223
|
+
children: tools.formatAmount(value, precision !== null && precision !== void 0 ? precision : 2)
|
|
216
224
|
});
|
|
217
225
|
// CNY千分位
|
|
218
226
|
case 'thousandthCNY':
|
|
@@ -232,7 +240,7 @@ var InputNumber = function InputNumber(props) {
|
|
|
232
240
|
}
|
|
233
241
|
// 失去焦点时处理数字,
|
|
234
242
|
var handleBlur = function handleBlur(e) {
|
|
235
|
-
var _e$target, _e$target2;
|
|
243
|
+
var _e$target, _props$precision5, _valueProps3, _e$target2;
|
|
236
244
|
activateRef.current = false;
|
|
237
245
|
var value = e === null || e === void 0 ? void 0 : (_e$target = e.target) === null || _e$target === void 0 ? void 0 : _e$target.value;
|
|
238
246
|
if (_max !== undefined && value > _max) {
|
|
@@ -241,7 +249,8 @@ var InputNumber = function InputNumber(props) {
|
|
|
241
249
|
if (_min !== undefined && value < _min) {
|
|
242
250
|
value = _min;
|
|
243
251
|
}
|
|
244
|
-
value = _parser(String(value), props.precision);
|
|
252
|
+
value = _parser(String(value), (_props$precision5 = props.precision) !== null && _props$precision5 !== void 0 ? _props$precision5 : (_valueProps3 = valueProps) === null || _valueProps3 === void 0 ? void 0 : _valueProps3.precision);
|
|
253
|
+
rest === null || rest === void 0 ? void 0 : rest.onChange(value);
|
|
245
254
|
var limit = {
|
|
246
255
|
min: Number(_min),
|
|
247
256
|
max: Number(_max)
|
|
@@ -299,101 +299,107 @@ var RenderField = function RenderField(_ref) {
|
|
|
299
299
|
}, 100);
|
|
300
300
|
};
|
|
301
301
|
// 单元格更新数据时,加个防抖,防止更新频率过快,卡顿
|
|
302
|
-
var _onChange =
|
|
303
|
-
var
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
args
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
302
|
+
var _onChange = /*#__PURE__*/function () {
|
|
303
|
+
var _ref2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/(0, _regeneratorRuntime2.default)().mark(function _callee() {
|
|
304
|
+
var _len2,
|
|
305
|
+
args,
|
|
306
|
+
_key2,
|
|
307
|
+
_args,
|
|
308
|
+
rowPath,
|
|
309
|
+
row,
|
|
310
|
+
orgRow,
|
|
311
|
+
_TargetComponent,
|
|
312
|
+
_TargetComponent$prop,
|
|
313
|
+
_TargetComponent$prop2,
|
|
314
|
+
_TargetComponent2,
|
|
315
|
+
_TargetComponent2$pro,
|
|
316
|
+
_TargetComponent$prop3,
|
|
317
|
+
_Object$keys,
|
|
318
|
+
_Object$keys$map,
|
|
319
|
+
diff,
|
|
320
|
+
validateFieldKeys,
|
|
321
|
+
_args2 = arguments;
|
|
322
|
+
return (0, _regeneratorRuntime2.default)().wrap(function _callee$(_context) {
|
|
323
|
+
while (1) switch (_context.prev = _context.next) {
|
|
324
|
+
case 0:
|
|
325
|
+
for (_len2 = _args2.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
326
|
+
args[_key2] = _args2[_key2];
|
|
327
|
+
}
|
|
328
|
+
_args = [].concat(args);
|
|
329
|
+
rowPath = [].concat((0, _toConsumableArray2.default)(namePath), [index]);
|
|
330
|
+
row = form.getFieldValue(rowPath, true);
|
|
331
|
+
orgRow = (0, _lodash.cloneDeep)(row);
|
|
332
|
+
if (!onFieldChange) {
|
|
333
|
+
_context.next = 18;
|
|
334
|
+
break;
|
|
335
|
+
}
|
|
336
|
+
_args = formatArgs(args);
|
|
337
|
+
_args[1] = row;
|
|
338
|
+
_context.t0 = (_TargetComponent = TargetComponent) === null || _TargetComponent === void 0 ? void 0 : (_TargetComponent$prop = _TargetComponent.props) === null || _TargetComponent$prop === void 0 ? void 0 : _TargetComponent$prop.onFieldChange;
|
|
339
|
+
if (!_context.t0) {
|
|
340
|
+
_context.next = 12;
|
|
341
|
+
break;
|
|
342
|
+
}
|
|
339
343
|
_context.next = 12;
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
344
|
+
return (_TargetComponent$prop2 = TargetComponent.props).onFieldChange.apply(_TargetComponent$prop2, (0, _toConsumableArray2.default)(_args));
|
|
345
|
+
case 12:
|
|
346
|
+
_context.t1 = onFieldChange;
|
|
347
|
+
if (!_context.t1) {
|
|
348
|
+
_context.next = 16;
|
|
349
|
+
break;
|
|
350
|
+
}
|
|
347
351
|
_context.next = 16;
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
_context.next = 16;
|
|
351
|
-
return onFieldChange.apply(void 0, (0, _toConsumableArray2.default)(_args));
|
|
352
|
-
case 16:
|
|
353
|
-
_context.next = 27;
|
|
354
|
-
break;
|
|
355
|
-
case 18:
|
|
356
|
-
_args = _args.concat([row, index, form]);
|
|
357
|
-
_context.t2 = (_TargetComponent2 = TargetComponent) === null || _TargetComponent2 === void 0 ? void 0 : (_TargetComponent2$pro = _TargetComponent2.props) === null || _TargetComponent2$pro === void 0 ? void 0 : _TargetComponent2$pro.onChange;
|
|
358
|
-
if (!_context.t2) {
|
|
359
|
-
_context.next = 23;
|
|
360
|
-
break;
|
|
361
|
-
}
|
|
362
|
-
_context.next = 23;
|
|
363
|
-
return (_TargetComponent$prop3 = TargetComponent.props).onChange.apply(_TargetComponent$prop3, (0, _toConsumableArray2.default)(_args));
|
|
364
|
-
case 23:
|
|
365
|
-
_context.t3 = onChange;
|
|
366
|
-
if (!_context.t3) {
|
|
352
|
+
return onFieldChange.apply(void 0, (0, _toConsumableArray2.default)(_args));
|
|
353
|
+
case 16:
|
|
367
354
|
_context.next = 27;
|
|
368
355
|
break;
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
if (!(0, _lodash.isEqual)(orgRow, row)) {
|
|
376
|
-
diff = (0, _tools.difference)(row, orgRow) || {};
|
|
377
|
-
validateFieldKeys = (_Object$keys = Object.keys(diff)) === null || _Object$keys === void 0 ? void 0 : (_Object$keys$map = _Object$keys.map) === null || _Object$keys$map === void 0 ? void 0 : _Object$keys$map.call(_Object$keys, function (key) {
|
|
378
|
-
return [].concat((0, _toConsumableArray2.default)(rowPath), [key]);
|
|
379
|
-
});
|
|
380
|
-
if (validateFieldKeys === null || validateFieldKeys === void 0 ? void 0 : validateFieldKeys.length) {
|
|
381
|
-
setTimeout(function () {
|
|
382
|
-
form.validateFields(validateFieldKeys);
|
|
383
|
-
}, 100);
|
|
356
|
+
case 18:
|
|
357
|
+
_args = _args.concat([row, index, form]);
|
|
358
|
+
_context.t2 = (_TargetComponent2 = TargetComponent) === null || _TargetComponent2 === void 0 ? void 0 : (_TargetComponent2$pro = _TargetComponent2.props) === null || _TargetComponent2$pro === void 0 ? void 0 : _TargetComponent2$pro.onChange;
|
|
359
|
+
if (!_context.t2) {
|
|
360
|
+
_context.next = 23;
|
|
361
|
+
break;
|
|
384
362
|
}
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
363
|
+
_context.next = 23;
|
|
364
|
+
return (_TargetComponent$prop3 = TargetComponent.props).onChange.apply(_TargetComponent$prop3, (0, _toConsumableArray2.default)(_args));
|
|
365
|
+
case 23:
|
|
366
|
+
_context.t3 = onChange;
|
|
367
|
+
if (!_context.t3) {
|
|
368
|
+
_context.next = 27;
|
|
369
|
+
break;
|
|
389
370
|
}
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
371
|
+
_context.next = 27;
|
|
372
|
+
return onChange.apply(void 0, (0, _toConsumableArray2.default)(_args));
|
|
373
|
+
case 27:
|
|
374
|
+
// 判断属性是否变动
|
|
375
|
+
form.setFieldValue(rowPath, (0, _objectSpread2.default)({}, row));
|
|
376
|
+
if (!(0, _lodash.isEqual)(orgRow, row)) {
|
|
377
|
+
diff = (0, _tools.difference)(row, orgRow) || {};
|
|
378
|
+
validateFieldKeys = (_Object$keys = Object.keys(diff)) === null || _Object$keys === void 0 ? void 0 : (_Object$keys$map = _Object$keys.map) === null || _Object$keys$map === void 0 ? void 0 : _Object$keys$map.call(_Object$keys, function (key) {
|
|
379
|
+
return [].concat((0, _toConsumableArray2.default)(rowPath), [key]);
|
|
380
|
+
});
|
|
381
|
+
if (validateFieldKeys === null || validateFieldKeys === void 0 ? void 0 : validateFieldKeys.length) {
|
|
382
|
+
setTimeout(function () {
|
|
383
|
+
form.validateFields(validateFieldKeys);
|
|
384
|
+
}, 100);
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
// 单行编辑时需要 强制更新视图
|
|
388
|
+
setState({
|
|
389
|
+
forceUpdate: {
|
|
390
|
+
d: Date.now()
|
|
391
|
+
}
|
|
392
|
+
});
|
|
393
|
+
case 30:
|
|
394
|
+
case "end":
|
|
395
|
+
return _context.stop();
|
|
396
|
+
}
|
|
397
|
+
}, _callee);
|
|
398
|
+
}));
|
|
399
|
+
return function _onChange() {
|
|
400
|
+
return _ref2.apply(this, arguments);
|
|
401
|
+
};
|
|
402
|
+
}();
|
|
397
403
|
var _onblur = /*#__PURE__*/function () {
|
|
398
404
|
var _ref3 = (0, _asyncToGenerator2.default)( /*#__PURE__*/(0, _regeneratorRuntime2.default)().mark(function _callee2() {
|
|
399
405
|
var _TargetComponent3, _TargetComponent3$pro, _TargetComponent$prop4;
|
|
@@ -437,7 +443,7 @@ var RenderField = function RenderField(_ref) {
|
|
|
437
443
|
return onBlur.apply(void 0, (0, _toConsumableArray2.default)(_args));
|
|
438
444
|
case 14:
|
|
439
445
|
// 判断属性是否变动
|
|
440
|
-
form.setFieldValue(rowPath, row);
|
|
446
|
+
form.setFieldValue(rowPath, (0, _objectSpread2.default)({}, row));
|
|
441
447
|
if (!(0, _lodash.isEqual)(orgRow, row)) {
|
|
442
448
|
diff = (0, _tools.difference)(row, orgRow) || {};
|
|
443
449
|
validateFieldKeys = (_Object$keys2 = Object.keys(diff)) === null || _Object$keys2 === void 0 ? void 0 : (_Object$keys2$map = _Object$keys2.map) === null || _Object$keys2$map === void 0 ? void 0 : _Object$keys2$map.call(_Object$keys2, function (key) {
|
|
@@ -39,6 +39,7 @@ var limitNumber = function limitNumber(num, _ref) {
|
|
|
39
39
|
return num;
|
|
40
40
|
};
|
|
41
41
|
var InputNumber = function InputNumber(props) {
|
|
42
|
+
var _props$precision4;
|
|
42
43
|
var placeholder = props.placeholder,
|
|
43
44
|
className = props.className,
|
|
44
45
|
otherProps = props.otherProps,
|
|
@@ -59,28 +60,33 @@ var InputNumber = function InputNumber(props) {
|
|
|
59
60
|
var isView = typeof props.isView === 'boolean' ? props.isView : isViewCon; // 组件可直接接收isView参数, 优先级高
|
|
60
61
|
var valueProps = {};
|
|
61
62
|
var formatter = function formatter(value) {
|
|
63
|
+
var _props$precision;
|
|
62
64
|
if (value === '') return '';
|
|
63
65
|
var num = Number(value);
|
|
64
66
|
if (Number.isNaN(num)) {
|
|
65
67
|
return value;
|
|
66
68
|
}
|
|
67
69
|
var val = num.toLocaleString('en-US', {
|
|
68
|
-
maximumFractionDigits: (props === null || props === void 0 ? void 0 : props.precision)
|
|
70
|
+
maximumFractionDigits: (_props$precision = props === null || props === void 0 ? void 0 : props.precision) !== null && _props$precision !== void 0 ? _props$precision : 2
|
|
69
71
|
});
|
|
70
72
|
if (!activateRef.current) {
|
|
73
|
+
var _props$precision2;
|
|
71
74
|
var _val$split = val.split('.'),
|
|
72
75
|
_val$split2 = (0, _slicedToArray2.default)(_val$split, 2),
|
|
73
76
|
int = _val$split2[0],
|
|
74
77
|
_val$split2$ = _val$split2[1],
|
|
75
78
|
float = _val$split2$ === void 0 ? '' : _val$split2$;
|
|
76
|
-
|
|
79
|
+
if ((props === null || props === void 0 ? void 0 : props.precision) === 0) {
|
|
80
|
+
return int;
|
|
81
|
+
}
|
|
82
|
+
return "".concat(int, ".").concat(float.padEnd((_props$precision2 = props === null || props === void 0 ? void 0 : props.precision) !== null && _props$precision2 !== void 0 ? _props$precision2 : 2, '0'));
|
|
77
83
|
}
|
|
78
84
|
return val;
|
|
79
85
|
};
|
|
80
86
|
var _parser = function parser(value, precision) {
|
|
81
|
-
var num = Number(value.replace(/[\s,]+/g, ''));
|
|
82
87
|
if (value === '') return value;
|
|
83
|
-
|
|
88
|
+
var num = Number(value.replace(/[\s,]+/g, ''));
|
|
89
|
+
return Number.isNaN(num) || !precision && precision !== 0 ? Number.isNaN(Number(value)) ? null : value : num.toFixed(precision);
|
|
84
90
|
};
|
|
85
91
|
if (valueType) {
|
|
86
92
|
switch (valueType) {
|
|
@@ -92,8 +98,10 @@ var InputNumber = function InputNumber(props) {
|
|
|
92
98
|
valueProps = {
|
|
93
99
|
formatter: formatter,
|
|
94
100
|
parser: function parser(val) {
|
|
95
|
-
|
|
96
|
-
|
|
101
|
+
var _props$precision3;
|
|
102
|
+
return _parser(val, (_props$precision3 = props === null || props === void 0 ? void 0 : props.precision) !== null && _props$precision3 !== void 0 ? _props$precision3 : 2);
|
|
103
|
+
},
|
|
104
|
+
precision: (_props$precision4 = props === null || props === void 0 ? void 0 : props.precision) !== null && _props$precision4 !== void 0 ? _props$precision4 : 2
|
|
97
105
|
};
|
|
98
106
|
break;
|
|
99
107
|
// 百分比
|
|
@@ -181,7 +189,7 @@ var InputNumber = function InputNumber(props) {
|
|
|
181
189
|
var originValue = calc(Number(value), '/', 100);
|
|
182
190
|
// 获取真实数据的小数位数
|
|
183
191
|
var decimalDigits = (0, _index.getDecimalDigits)(originValue);
|
|
184
|
-
if (decimalDigits > (precision
|
|
192
|
+
if (decimalDigits > (precision !== null && precision !== void 0 ? precision : 4)) {
|
|
185
193
|
return (0, _jsxRuntime.jsx)(_Container.default, {
|
|
186
194
|
viewEmpty: viewEmpty,
|
|
187
195
|
children: value
|
|
@@ -199,7 +207,7 @@ var InputNumber = function InputNumber(props) {
|
|
|
199
207
|
var _originValue = calc(Number(value), '/', 1000);
|
|
200
208
|
// 获取真实数据的小数位数
|
|
201
209
|
var _decimalDigits = (0, _index.getDecimalDigits)(_originValue);
|
|
202
|
-
if (_decimalDigits > (precision
|
|
210
|
+
if (_decimalDigits > (precision !== null && precision !== void 0 ? precision : 5)) {
|
|
203
211
|
return (0, _jsxRuntime.jsx)(_Container.default, {
|
|
204
212
|
viewEmpty: viewEmpty,
|
|
205
213
|
children: value
|
|
@@ -216,7 +224,7 @@ var InputNumber = function InputNumber(props) {
|
|
|
216
224
|
case 'thousandth':
|
|
217
225
|
return (0, _jsxRuntime.jsx)(_Container.default, {
|
|
218
226
|
viewEmpty: viewEmpty,
|
|
219
|
-
children: _utils.tools.formatAmount(value, precision
|
|
227
|
+
children: _utils.tools.formatAmount(value, precision !== null && precision !== void 0 ? precision : 2)
|
|
220
228
|
});
|
|
221
229
|
// CNY千分位
|
|
222
230
|
case 'thousandthCNY':
|
|
@@ -236,7 +244,7 @@ var InputNumber = function InputNumber(props) {
|
|
|
236
244
|
}
|
|
237
245
|
// 失去焦点时处理数字,
|
|
238
246
|
var handleBlur = function handleBlur(e) {
|
|
239
|
-
var _e$target, _e$target2;
|
|
247
|
+
var _e$target, _props$precision5, _valueProps3, _e$target2;
|
|
240
248
|
activateRef.current = false;
|
|
241
249
|
var value = e === null || e === void 0 ? void 0 : (_e$target = e.target) === null || _e$target === void 0 ? void 0 : _e$target.value;
|
|
242
250
|
if (_max !== undefined && value > _max) {
|
|
@@ -245,7 +253,8 @@ var InputNumber = function InputNumber(props) {
|
|
|
245
253
|
if (_min !== undefined && value < _min) {
|
|
246
254
|
value = _min;
|
|
247
255
|
}
|
|
248
|
-
value = _parser(String(value), props.precision);
|
|
256
|
+
value = _parser(String(value), (_props$precision5 = props.precision) !== null && _props$precision5 !== void 0 ? _props$precision5 : (_valueProps3 = valueProps) === null || _valueProps3 === void 0 ? void 0 : _valueProps3.precision);
|
|
257
|
+
rest === null || rest === void 0 ? void 0 : rest.onChange(value);
|
|
249
258
|
var limit = {
|
|
250
259
|
min: Number(_min),
|
|
251
260
|
max: Number(_max)
|