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