@signalplus/params-about 0.1.0 → 0.1.3
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/README-CN.md +19 -14
- package/README.md +19 -14
- package/index.d.ts +172 -96
- package/lib/css/Bool.scss +19 -0
- package/lib/css/Expiries.scss +110 -0
- package/lib/css/ExpiriesLimit.scss +80 -0
- package/lib/css/Num.scss +42 -0
- package/lib/css/NumRange.scss +38 -0
- package/lib/css/ParamForm/ParentSelector.scss +20 -0
- package/lib/css/ParamForm/index.scss +56 -0
- package/lib/css/TextArray.scss +52 -0
- package/lib/css/index.css +1 -1
- package/lib/css/index.scss +11 -277
- package/lib/css/var.scss +8 -0
- package/lib/es/index.js +704 -94
- package/lib/umd/index.js +4861 -0
- package/package.json +7 -43
- package/pnpm-lock.yaml +0 -11087
package/lib/es/index.js
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Bundle of @signalplus/params-about
|
|
3
|
-
* Generated: 2022-04-
|
|
4
|
-
* Version: 0.1.
|
|
3
|
+
* Generated: 2022-04-07
|
|
4
|
+
* Version: 0.1.3
|
|
5
5
|
* License: MIT
|
|
6
6
|
* Author: 2631541504@qq.com
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import React, { PureComponent } from 'react';
|
|
9
|
+
import React, { PureComponent, useMemo } from 'react';
|
|
10
10
|
import classNames from 'classnames';
|
|
11
11
|
import dayjs from 'dayjs';
|
|
12
12
|
import Big from 'big.js';
|
|
13
|
-
import { PlusOutlined, DeleteOutlined, CheckOutlined, DownOutlined } from '@ant-design/icons';
|
|
14
|
-
import { Popover } from 'antd';
|
|
13
|
+
import { PlusOutlined, DeleteOutlined, CloseOutlined, CheckOutlined, DownOutlined } from '@ant-design/icons';
|
|
14
|
+
import { Popover, Cascader, Input, Select, Form, Button, Modal } from 'antd';
|
|
15
|
+
import ReactGlobalComp from 'react-global-comp';
|
|
15
16
|
|
|
16
17
|
function _defineProperty(obj, key, value) {
|
|
17
18
|
if (key in obj) {
|
|
@@ -190,6 +191,64 @@ var ParamType;
|
|
|
190
191
|
ParamType[ParamType["Phone"] = 8] = "Phone";
|
|
191
192
|
})(ParamType || (ParamType = {}));
|
|
192
193
|
|
|
194
|
+
function _arrayWithHoles(arr) {
|
|
195
|
+
if (Array.isArray(arr)) return arr;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
function _iterableToArrayLimit(arr, i) {
|
|
199
|
+
if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return;
|
|
200
|
+
var _arr = [];
|
|
201
|
+
var _n = true;
|
|
202
|
+
var _d = false;
|
|
203
|
+
var _e = undefined;
|
|
204
|
+
|
|
205
|
+
try {
|
|
206
|
+
for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
|
|
207
|
+
_arr.push(_s.value);
|
|
208
|
+
|
|
209
|
+
if (i && _arr.length === i) break;
|
|
210
|
+
}
|
|
211
|
+
} catch (err) {
|
|
212
|
+
_d = true;
|
|
213
|
+
_e = err;
|
|
214
|
+
} finally {
|
|
215
|
+
try {
|
|
216
|
+
if (!_n && _i["return"] != null) _i["return"]();
|
|
217
|
+
} finally {
|
|
218
|
+
if (_d) throw _e;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
return _arr;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
function _arrayLikeToArray(arr, len) {
|
|
226
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
227
|
+
|
|
228
|
+
for (var i = 0, arr2 = new Array(len); i < len; i++) {
|
|
229
|
+
arr2[i] = arr[i];
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
return arr2;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
function _unsupportedIterableToArray(o, minLen) {
|
|
236
|
+
if (!o) return;
|
|
237
|
+
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
238
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
239
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
240
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
|
241
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
function _nonIterableRest() {
|
|
245
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
function _slicedToArray(arr, i) {
|
|
249
|
+
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
|
|
250
|
+
}
|
|
251
|
+
|
|
193
252
|
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
194
253
|
|
|
195
254
|
function createCommonjsModule(fn, module) {
|
|
@@ -307,42 +366,75 @@ function isNullLike(val) {
|
|
|
307
366
|
return val === undefined || val === null;
|
|
308
367
|
}
|
|
309
368
|
function emptyValidator(val, enableEmpty) {
|
|
310
|
-
return !enableEmpty && (isNullLike(val) || val instanceof Array && !val.length || typeof val === 'string' && !val) ? '
|
|
369
|
+
return !enableEmpty && (isNullLike(val) || val instanceof Array && !val.length || typeof val === 'string' && !val) ? 'Should not be empty' : '';
|
|
311
370
|
}
|
|
312
371
|
function numRangeValidator(val, enableEmpty) {
|
|
313
372
|
var error = emptyValidator(val === null || val === void 0 ? void 0 : val.min, enableEmpty);
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
373
|
+
|
|
374
|
+
if (error) {
|
|
375
|
+
// return { min: error }
|
|
376
|
+
return "Min: ".concat(error);
|
|
377
|
+
}
|
|
378
|
+
|
|
317
379
|
error = emptyValidator(val === null || val === void 0 ? void 0 : val.max, enableEmpty);
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
380
|
+
|
|
381
|
+
if (error) {
|
|
382
|
+
// return { max: error }
|
|
383
|
+
return "Max: ".concat(error);
|
|
384
|
+
}
|
|
385
|
+
|
|
321
386
|
return val.min > val.max ? 'Max should bigger than Min' : '';
|
|
322
387
|
}
|
|
323
388
|
function expiryValidator(val, enableEmpty) {
|
|
324
389
|
var error = emptyValidator(val, enableEmpty);
|
|
325
390
|
if (error) return error;
|
|
326
391
|
var $val = dayjs(val, 'DDMMMYY').format('DDMMMYY').toUpperCase();
|
|
327
|
-
if ($val !== val) return '
|
|
392
|
+
if ($val !== val) return 'Out of format';
|
|
328
393
|
return '';
|
|
329
394
|
}
|
|
330
|
-
function expiriesValidator(val
|
|
331
|
-
var error = emptyValidator(val, enableEmpty);
|
|
332
|
-
if (error) return error;
|
|
333
|
-
|
|
395
|
+
function expiriesValidator(val) {
|
|
334
396
|
for (var i = 0; i < val.length; i++) {
|
|
335
|
-
error = expiryValidator(val[i]);
|
|
336
|
-
|
|
397
|
+
var error = expiryValidator(val[i]);
|
|
398
|
+
|
|
399
|
+
if (error) {
|
|
400
|
+
// return { [i]: error }
|
|
401
|
+
return "The ".concat(i + 1, "th item: ").concat(error);
|
|
402
|
+
}
|
|
337
403
|
}
|
|
338
404
|
|
|
339
405
|
return '';
|
|
340
406
|
}
|
|
407
|
+
function keyValidator(val) {
|
|
408
|
+
var error = emptyValidator(val);
|
|
409
|
+
if (error) return error;
|
|
410
|
+
return /^[_.a-zA-Z0-9]+$/.test(val) ? '' : 'Out of format: should be a combination of the following chars `_.0-9a-zA-Z`';
|
|
411
|
+
}
|
|
341
412
|
function isExpired(val) {
|
|
413
|
+
if (!val) return false;
|
|
342
414
|
var now = dayjs();
|
|
343
415
|
var expireTime = dayjs.utc("".concat(val, " 8:00"), 'DDMMMYY 8:00');
|
|
344
416
|
return now >= expireTime;
|
|
345
417
|
}
|
|
418
|
+
function validatorCvt(validator, form) {
|
|
419
|
+
return function (_, val) {
|
|
420
|
+
var $form = form === null || form === void 0 ? void 0 : form();
|
|
421
|
+
var error = validator(val, $form === null || $form === void 0 ? void 0 : $form.getFieldsValue());
|
|
422
|
+
if (!error) return Promise.resolve();
|
|
423
|
+
|
|
424
|
+
var traverse = function traverse(obj) {
|
|
425
|
+
if (typeof obj === 'string' && obj) return Promise.reject(new Error(obj));
|
|
426
|
+
|
|
427
|
+
if (obj && _typeof(obj) === 'object') {
|
|
428
|
+
for (var key in obj) {
|
|
429
|
+
var res = traverse(obj[key]);
|
|
430
|
+
if (res) return res;
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
};
|
|
434
|
+
|
|
435
|
+
return traverse(error) || Promise.resolve();
|
|
436
|
+
};
|
|
437
|
+
}
|
|
346
438
|
|
|
347
439
|
var Bool = /*#__PURE__*/function (_PureComponent) {
|
|
348
440
|
_inherits(Bool, _PureComponent);
|
|
@@ -410,6 +502,13 @@ var Bool = /*#__PURE__*/function (_PureComponent) {
|
|
|
410
502
|
stroke: "currentColor"
|
|
411
503
|
})));
|
|
412
504
|
|
|
505
|
+
_defineProperty(_assertThisInitialized(_this), "onChange", function (val) {
|
|
506
|
+
var _this$props$onChange, _this$props, _this$props$onBlur, _this$props2;
|
|
507
|
+
|
|
508
|
+
(_this$props$onChange = (_this$props = _this.props).onChange) === null || _this$props$onChange === void 0 ? void 0 : _this$props$onChange.call(_this$props, val);
|
|
509
|
+
(_this$props$onBlur = (_this$props2 = _this.props).onBlur) === null || _this$props$onBlur === void 0 ? void 0 : _this$props$onBlur.call(_this$props2);
|
|
510
|
+
});
|
|
511
|
+
|
|
413
512
|
return _this;
|
|
414
513
|
}
|
|
415
514
|
|
|
@@ -426,15 +525,13 @@ var Bool = /*#__PURE__*/function (_PureComponent) {
|
|
|
426
525
|
}, this.props.readonly ? /*#__PURE__*/React.createElement("span", {
|
|
427
526
|
className: "param-bool-val"
|
|
428
527
|
}, !isNullLike(this.props.value) ? String(this.props.value).toUpperCase() : '-') : this.options.map(function (it) {
|
|
429
|
-
var _this2$props$onChange;
|
|
430
|
-
|
|
431
528
|
var active = it.value === _this2.props.value;
|
|
432
529
|
return /*#__PURE__*/React.createElement("div", {
|
|
433
530
|
key: String(it.value),
|
|
434
531
|
className: classNames('param-bool-option', {
|
|
435
532
|
active: active
|
|
436
533
|
}),
|
|
437
|
-
onClick:
|
|
534
|
+
onClick: _this2.onChange.bind(null, it.value)
|
|
438
535
|
}, active ? _this2.RadioChecked : _this2.RadioUnchecked, it.label);
|
|
439
536
|
}));
|
|
440
537
|
}
|
|
@@ -452,12 +549,13 @@ var NumCvt = /*#__PURE__*/function () {
|
|
|
452
549
|
key: "show",
|
|
453
550
|
value: function show(val, isPercentage) {
|
|
454
551
|
if (val && isPercentage) return Big(val).times(100).valueOf();
|
|
455
|
-
return val;
|
|
552
|
+
return String(val !== null && val !== void 0 ? val : '');
|
|
456
553
|
}
|
|
457
554
|
}, {
|
|
458
555
|
key: "emit",
|
|
459
556
|
value: function emit(val, isPercentage) {
|
|
460
|
-
if (!val
|
|
557
|
+
if (!val) return undefined;
|
|
558
|
+
if (!isPercentage) return +val;
|
|
461
559
|
return +Big(val).div(100);
|
|
462
560
|
}
|
|
463
561
|
}]);
|
|
@@ -491,16 +589,19 @@ var Num = /*#__PURE__*/function (_PureComponent) {
|
|
|
491
589
|
_defineProperty(_assertThisInitialized(_this), "state", initState(_this.props));
|
|
492
590
|
|
|
493
591
|
_defineProperty(_assertThisInitialized(_this), "onChange", function (e) {
|
|
494
|
-
var _this$props$onChange, _this$props;
|
|
495
|
-
|
|
496
592
|
var $value = e.target.value;
|
|
497
593
|
var $val = $value.replace(/^(-?\d+(\.\d*)?|-?\d*).*$/, '$1');
|
|
498
594
|
if ($val !== $value) e.target.value = $val;
|
|
499
595
|
var value = NumCvt.emit($val, _this.props.isPercentage);
|
|
500
|
-
|
|
596
|
+
|
|
597
|
+
_this.setState(function (pre) {
|
|
501
598
|
return _objectSpread2(_objectSpread2({}, pre), {}, {
|
|
502
599
|
tempValue: e.target.value
|
|
503
600
|
});
|
|
601
|
+
}, function () {
|
|
602
|
+
var _this$props$onChange, _this$props;
|
|
603
|
+
|
|
604
|
+
if (value !== _this.props.value) (_this$props$onChange = (_this$props = _this.props).onChange) === null || _this$props$onChange === void 0 ? void 0 : _this$props$onChange.call(_this$props, value);
|
|
504
605
|
});
|
|
505
606
|
});
|
|
506
607
|
|
|
@@ -524,7 +625,8 @@ var Num = /*#__PURE__*/function (_PureComponent) {
|
|
|
524
625
|
type: "text",
|
|
525
626
|
placeholder: this.props.placeholder || 'Value',
|
|
526
627
|
value: this.state.tempValue || '',
|
|
527
|
-
onChange: this.onChange
|
|
628
|
+
onChange: this.onChange,
|
|
629
|
+
onBlur: this.props.onBlur
|
|
528
630
|
}), this.props.isPercentage && /*#__PURE__*/React.createElement("span", {
|
|
529
631
|
className: "param-number-suffix"
|
|
530
632
|
}, "%"));
|
|
@@ -532,7 +634,7 @@ var Num = /*#__PURE__*/function (_PureComponent) {
|
|
|
532
634
|
}], [{
|
|
533
635
|
key: "getDerivedStateFromProps",
|
|
534
636
|
value: function getDerivedStateFromProps(props, state) {
|
|
535
|
-
if (props.value !== state.preProps.value) {
|
|
637
|
+
if (props.value !== state.preProps.value && parseFloat(state.tempValue) !== props.value) {
|
|
536
638
|
state.tempValue = NumCvt.show(props.value, props.isPercentage);
|
|
537
639
|
}
|
|
538
640
|
|
|
@@ -590,7 +692,8 @@ var NumRange = /*#__PURE__*/function (_PureComponent) {
|
|
|
590
692
|
value: (_this$props$value = this.props.value) === null || _this$props$value === void 0 ? void 0 : _this$props$value.min,
|
|
591
693
|
onChange: this.onChange.bind(null, 'min'),
|
|
592
694
|
isPercentage: this.props.isPercentage,
|
|
593
|
-
readonly: this.props.readonly
|
|
695
|
+
readonly: this.props.readonly,
|
|
696
|
+
onBlur: this.props.onBlur
|
|
594
697
|
}), /*#__PURE__*/React.createElement("span", {
|
|
595
698
|
className: "param-number-range-sep"
|
|
596
699
|
}, this.props.readonly ? ',' : '-'), /*#__PURE__*/React.createElement("span", {
|
|
@@ -600,7 +703,8 @@ var NumRange = /*#__PURE__*/function (_PureComponent) {
|
|
|
600
703
|
value: (_this$props$value2 = this.props.value) === null || _this$props$value2 === void 0 ? void 0 : _this$props$value2.max,
|
|
601
704
|
onChange: this.onChange.bind(null, 'max'),
|
|
602
705
|
isPercentage: this.props.isPercentage,
|
|
603
|
-
readonly: this.props.readonly
|
|
706
|
+
readonly: this.props.readonly,
|
|
707
|
+
onBlur: this.props.onBlur
|
|
604
708
|
}));
|
|
605
709
|
}
|
|
606
710
|
}]);
|
|
@@ -608,16 +712,6 @@ var NumRange = /*#__PURE__*/function (_PureComponent) {
|
|
|
608
712
|
return NumRange;
|
|
609
713
|
}(PureComponent);
|
|
610
714
|
|
|
611
|
-
function _arrayLikeToArray(arr, len) {
|
|
612
|
-
if (len == null || len > arr.length) len = arr.length;
|
|
613
|
-
|
|
614
|
-
for (var i = 0, arr2 = new Array(len); i < len; i++) {
|
|
615
|
-
arr2[i] = arr[i];
|
|
616
|
-
}
|
|
617
|
-
|
|
618
|
-
return arr2;
|
|
619
|
-
}
|
|
620
|
-
|
|
621
715
|
function _arrayWithoutHoles(arr) {
|
|
622
716
|
if (Array.isArray(arr)) return _arrayLikeToArray(arr);
|
|
623
717
|
}
|
|
@@ -626,15 +720,6 @@ function _iterableToArray(iter) {
|
|
|
626
720
|
if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter);
|
|
627
721
|
}
|
|
628
722
|
|
|
629
|
-
function _unsupportedIterableToArray(o, minLen) {
|
|
630
|
-
if (!o) return;
|
|
631
|
-
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
632
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
633
|
-
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
634
|
-
if (n === "Map" || n === "Set") return Array.from(n);
|
|
635
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
636
|
-
}
|
|
637
|
-
|
|
638
723
|
function _nonIterableSpread() {
|
|
639
724
|
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
640
725
|
}
|
|
@@ -715,7 +800,8 @@ var TextArray = /*#__PURE__*/function (_PureComponent) {
|
|
|
715
800
|
type: "text",
|
|
716
801
|
placeholder: "Phone",
|
|
717
802
|
value: it,
|
|
718
|
-
onChange: _this2.onChange.bind(null, i)
|
|
803
|
+
onChange: _this2.onChange.bind(null, i),
|
|
804
|
+
onBlur: _this2.props.onBlur
|
|
719
805
|
}), /*#__PURE__*/React.createElement("div", {
|
|
720
806
|
className: "param-arr-ops"
|
|
721
807
|
}, /*#__PURE__*/React.createElement(PlusOutlined, {
|
|
@@ -759,15 +845,21 @@ var Expiries = /*#__PURE__*/function (_PureComponent) {
|
|
|
759
845
|
});
|
|
760
846
|
|
|
761
847
|
_defineProperty(_assertThisInitialized(_this), "onChange", function (val) {
|
|
762
|
-
var _this$props$onChange, _this$props;
|
|
848
|
+
var _this$props$onChange, _this$props, _this$props$onBlur, _this$props2;
|
|
763
849
|
|
|
764
850
|
var value = _toConsumableArray(_this.props.value || []);
|
|
765
851
|
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
852
|
+
if (_this.props.multiple !== false) {
|
|
853
|
+
var index = value.findIndex(function (it) {
|
|
854
|
+
return it === val;
|
|
855
|
+
});
|
|
856
|
+
if (index > -1) value.splice(index, 1);else value.push(val);
|
|
857
|
+
} else {
|
|
858
|
+
value = [val];
|
|
859
|
+
}
|
|
860
|
+
|
|
770
861
|
(_this$props$onChange = (_this$props = _this.props).onChange) === null || _this$props$onChange === void 0 ? void 0 : _this$props$onChange.call(_this$props, value);
|
|
862
|
+
(_this$props$onBlur = (_this$props2 = _this.props).onBlur) === null || _this$props$onBlur === void 0 ? void 0 : _this$props$onBlur.call(_this$props2);
|
|
771
863
|
if (_this.props.multiple === false) _this.handleVisibleChange(false);
|
|
772
864
|
});
|
|
773
865
|
|
|
@@ -777,7 +869,8 @@ var Expiries = /*#__PURE__*/function (_PureComponent) {
|
|
|
777
869
|
_createClass(Expiries, [{
|
|
778
870
|
key: "renderValue",
|
|
779
871
|
value: function renderValue() {
|
|
780
|
-
var _this$props$value
|
|
872
|
+
var _this$props$value,
|
|
873
|
+
_this2 = this;
|
|
781
874
|
|
|
782
875
|
var value = (_this$props$value = this.props.value) === null || _this$props$value === void 0 ? void 0 : _this$props$value.filter(function (it) {
|
|
783
876
|
return it && !isExpired(it);
|
|
@@ -807,15 +900,20 @@ var Expiries = /*#__PURE__*/function (_PureComponent) {
|
|
|
807
900
|
return value.map(function (it) {
|
|
808
901
|
return /*#__PURE__*/React.createElement("span", {
|
|
809
902
|
className: "param-expiries-multi-val",
|
|
810
|
-
key: it
|
|
811
|
-
|
|
903
|
+
key: it,
|
|
904
|
+
onClick: function onClick(e) {
|
|
905
|
+
return e.stopPropagation();
|
|
906
|
+
}
|
|
907
|
+
}, it, /*#__PURE__*/React.createElement(CloseOutlined, {
|
|
908
|
+
onClick: _this2.onChange.bind(null, it)
|
|
909
|
+
}));
|
|
812
910
|
});
|
|
813
911
|
}
|
|
814
912
|
}, {
|
|
815
913
|
key: "render",
|
|
816
914
|
value: function render() {
|
|
817
915
|
var _this$props$options,
|
|
818
|
-
|
|
916
|
+
_this3 = this;
|
|
819
917
|
|
|
820
918
|
return /*#__PURE__*/React.createElement(Popover, {
|
|
821
919
|
overlayClassName: "param-expiries-popover",
|
|
@@ -824,20 +922,23 @@ var Expiries = /*#__PURE__*/function (_PureComponent) {
|
|
|
824
922
|
visible: !this.props.readonly && this.state.visible,
|
|
825
923
|
onVisibleChange: this.handleVisibleChange,
|
|
826
924
|
content: (_this$props$options = this.props.options) === null || _this$props$options === void 0 ? void 0 : _this$props$options.map(function (it) {
|
|
827
|
-
var
|
|
925
|
+
var _this3$props$value, _this3$props$calcDisa, _this3$props, _this3$onChange;
|
|
828
926
|
|
|
829
|
-
var checked = (
|
|
927
|
+
var checked = (_this3$props$value = _this3.props.value) === null || _this3$props$value === void 0 ? void 0 : _this3$props$value.includes(it);
|
|
928
|
+
var disabled = (_this3$props$calcDisa = (_this3$props = _this3.props).calcDisabled) === null || _this3$props$calcDisa === void 0 ? void 0 : _this3$props$calcDisa.call(_this3$props, it);
|
|
830
929
|
return /*#__PURE__*/React.createElement("div", {
|
|
831
930
|
className: classNames('param-expiries-option', {
|
|
832
|
-
'param-expiries-option-checked': checked
|
|
931
|
+
'param-expiries-option-checked': checked,
|
|
932
|
+
'param-expiries-option-disabled': disabled
|
|
833
933
|
}),
|
|
834
934
|
key: it,
|
|
835
|
-
onClick: (
|
|
935
|
+
onClick: disabled ? undefined : (_this3$onChange = _this3.onChange) === null || _this3$onChange === void 0 ? void 0 : _this3$onChange.bind(null, it)
|
|
836
936
|
}, it, checked && /*#__PURE__*/React.createElement(CheckOutlined, null));
|
|
837
937
|
})
|
|
838
938
|
}, /*#__PURE__*/React.createElement("div", {
|
|
839
939
|
className: classNames('param-expiries', {
|
|
840
|
-
readonly: this.props.readonly
|
|
940
|
+
readonly: this.props.readonly,
|
|
941
|
+
multiple: this.props.multiple !== false
|
|
841
942
|
}, this.props.className),
|
|
842
943
|
style: this.props.style
|
|
843
944
|
}, this.renderValue(), !this.props.readonly && this.props.options && /*#__PURE__*/React.createElement(DownOutlined, {
|
|
@@ -880,7 +981,7 @@ var ExpiriesLimit = /*#__PURE__*/function (_PureComponent) {
|
|
|
880
981
|
});
|
|
881
982
|
|
|
882
983
|
_defineProperty(_assertThisInitialized(_this), "onAdd", function (i) {
|
|
883
|
-
var _this$props$onChange2, _this$props2;
|
|
984
|
+
var _this$props$onChange2, _this$props2, _this$props$onBlur, _this$props3;
|
|
884
985
|
|
|
885
986
|
var value = _toConsumableArray(_this.value);
|
|
886
987
|
|
|
@@ -888,15 +989,17 @@ var ExpiriesLimit = /*#__PURE__*/function (_PureComponent) {
|
|
|
888
989
|
expiry: ''
|
|
889
990
|
});
|
|
890
991
|
(_this$props$onChange2 = (_this$props2 = _this.props).onChange) === null || _this$props$onChange2 === void 0 ? void 0 : _this$props$onChange2.call(_this$props2, value);
|
|
992
|
+
(_this$props$onBlur = (_this$props3 = _this.props).onBlur) === null || _this$props$onBlur === void 0 ? void 0 : _this$props$onBlur.call(_this$props3);
|
|
891
993
|
});
|
|
892
994
|
|
|
893
995
|
_defineProperty(_assertThisInitialized(_this), "onDel", function (i) {
|
|
894
|
-
var _this$props$onChange3, _this$
|
|
996
|
+
var _this$props$onChange3, _this$props4, _this$props$onBlur2, _this$props5;
|
|
895
997
|
|
|
896
998
|
var value = _toConsumableArray(_this.value);
|
|
897
999
|
|
|
898
1000
|
value.splice(i, 1);
|
|
899
|
-
(_this$props$onChange3 = (_this$
|
|
1001
|
+
(_this$props$onChange3 = (_this$props4 = _this.props).onChange) === null || _this$props$onChange3 === void 0 ? void 0 : _this$props$onChange3.call(_this$props4, value);
|
|
1002
|
+
(_this$props$onBlur2 = (_this$props5 = _this.props).onBlur) === null || _this$props$onBlur2 === void 0 ? void 0 : _this$props$onBlur2.call(_this$props5);
|
|
900
1003
|
});
|
|
901
1004
|
|
|
902
1005
|
return _this;
|
|
@@ -906,10 +1009,11 @@ var ExpiriesLimit = /*#__PURE__*/function (_PureComponent) {
|
|
|
906
1009
|
key: "render",
|
|
907
1010
|
value: function render() {
|
|
908
1011
|
var _this$props$value,
|
|
1012
|
+
_this$props$value2,
|
|
909
1013
|
_this2 = this;
|
|
910
1014
|
|
|
911
1015
|
this.value = ((_this$props$value = this.props.value) === null || _this$props$value === void 0 ? void 0 : _this$props$value.filter(function (it) {
|
|
912
|
-
return
|
|
1016
|
+
return !isExpired(it.expiry);
|
|
913
1017
|
})) || [];
|
|
914
1018
|
if (!this.value.length) this.value.push({
|
|
915
1019
|
expiry: ''
|
|
@@ -919,14 +1023,18 @@ var ExpiriesLimit = /*#__PURE__*/function (_PureComponent) {
|
|
|
919
1023
|
readonly: this.props.readonly
|
|
920
1024
|
}, this.props.className),
|
|
921
1025
|
style: this.props.style
|
|
922
|
-
}, this.props.readonly ? this.value.filter(function (it) {
|
|
1026
|
+
}, this.props.readonly ? ((_this$props$value2 = this.props.value) === null || _this$props$value2 === void 0 ? void 0 : _this$props$value2.length) ? this.value.filter(function (it) {
|
|
923
1027
|
return it.expiry;
|
|
924
1028
|
}).map(function (it, i) {
|
|
925
1029
|
return /*#__PURE__*/React.createElement("span", {
|
|
926
1030
|
className: "param-expiries-limit-val",
|
|
927
1031
|
key: i
|
|
928
|
-
}, it.expiry,
|
|
929
|
-
|
|
1032
|
+
}, it.expiry, /*#__PURE__*/React.createElement("span", {
|
|
1033
|
+
className: "param-expiries-limit-val-sep"
|
|
1034
|
+
}, "/"), it.minAumPercentage && it.maxAumPercentage ? "(".concat(NumCvt.show(it.minAumPercentage, true), "%, ").concat(NumCvt.show(it.maxAumPercentage, true), "%)") : '-', /*#__PURE__*/React.createElement("span", {
|
|
1035
|
+
className: "param-expiries-limit-val-sep"
|
|
1036
|
+
}, "/"), it.minAbs && it.maxAbs ? "(".concat(it.minAbs, ", ").concat(it.maxAbs, ")") : '-');
|
|
1037
|
+
}) : '-' : /*#__PURE__*/React.createElement("div", {
|
|
930
1038
|
className: "param-expiries-limit-inputs"
|
|
931
1039
|
}, /*#__PURE__*/React.createElement("div", {
|
|
932
1040
|
className: "param-expiries readonly"
|
|
@@ -947,7 +1055,13 @@ var ExpiriesLimit = /*#__PURE__*/function (_PureComponent) {
|
|
|
947
1055
|
value: [it.expiry],
|
|
948
1056
|
onChange: function onChange(val) {
|
|
949
1057
|
return _this2.onChange(i, val[0], 'expiry');
|
|
950
|
-
}
|
|
1058
|
+
},
|
|
1059
|
+
calcDisabled: function calcDisabled(expiry) {
|
|
1060
|
+
return _this2.value.some(function (item) {
|
|
1061
|
+
return item !== it && item.expiry === expiry;
|
|
1062
|
+
});
|
|
1063
|
+
},
|
|
1064
|
+
onBlur: _this2.props.onBlur
|
|
951
1065
|
}), /*#__PURE__*/React.createElement(NumRange, {
|
|
952
1066
|
value: {
|
|
953
1067
|
min: it.minAumPercentage,
|
|
@@ -959,7 +1073,8 @@ var ExpiriesLimit = /*#__PURE__*/function (_PureComponent) {
|
|
|
959
1073
|
maxAumPercentage: val === null || val === void 0 ? void 0 : val.max
|
|
960
1074
|
});
|
|
961
1075
|
},
|
|
962
|
-
isPercentage: true
|
|
1076
|
+
isPercentage: true,
|
|
1077
|
+
onBlur: _this2.props.onBlur
|
|
963
1078
|
}), /*#__PURE__*/React.createElement(NumRange, {
|
|
964
1079
|
value: {
|
|
965
1080
|
min: it.minAbs,
|
|
@@ -970,7 +1085,8 @@ var ExpiriesLimit = /*#__PURE__*/function (_PureComponent) {
|
|
|
970
1085
|
minAbs: val === null || val === void 0 ? void 0 : val.min,
|
|
971
1086
|
maxAbs: val === null || val === void 0 ? void 0 : val.max
|
|
972
1087
|
});
|
|
973
|
-
}
|
|
1088
|
+
},
|
|
1089
|
+
onBlur: _this2.props.onBlur
|
|
974
1090
|
}), /*#__PURE__*/React.createElement("div", {
|
|
975
1091
|
className: "param-arr-ops"
|
|
976
1092
|
}, /*#__PURE__*/React.createElement(PlusOutlined, {
|
|
@@ -1030,28 +1146,31 @@ var ParamTypeConfig = (_ParamTypeConfig = {}, _defineProperty(_ParamTypeConfig,
|
|
|
1030
1146
|
name: '到期日 Limit',
|
|
1031
1147
|
key: 'expiryLimitList',
|
|
1032
1148
|
Comp: ExpiriesLimit,
|
|
1033
|
-
validator: function validator(val
|
|
1034
|
-
var
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
}
|
|
1149
|
+
validator: function validator($val) {
|
|
1150
|
+
for (var i = 0; i < $val.length; i++) {
|
|
1151
|
+
var val = $val[i];
|
|
1152
|
+
var error = expiryValidator(val === null || val === void 0 ? void 0 : val.expiry);
|
|
1153
|
+
|
|
1154
|
+
if (error) {
|
|
1155
|
+
// return { [i]: { expire: error } }
|
|
1156
|
+
return "Expiry field of the ".concat(i + 1, "th item: ").concat(error);
|
|
1157
|
+
}
|
|
1042
1158
|
|
|
1043
1159
|
if (isNullLike(val === null || val === void 0 ? void 0 : val.minAumPercentage) && isNullLike(val === null || val === void 0 ? void 0 : val.maxAumPercentage) && isNullLike(val === null || val === void 0 ? void 0 : val.minAbs) && isNullLike(val === null || val === void 0 ? void 0 : val.maxAbs)) {
|
|
1044
|
-
return
|
|
1160
|
+
// return {
|
|
1161
|
+
// [i]: 'at least one parameter must be specified between AUM and ABS',
|
|
1162
|
+
// }
|
|
1163
|
+
return "The ".concat(i + 1, "th item: at least one parameter must be specified between AUM and ABS");
|
|
1045
1164
|
}
|
|
1046
1165
|
|
|
1047
|
-
if (val.minAbs > val.maxAbs) return
|
|
1048
|
-
|
|
1049
|
-
});
|
|
1166
|
+
if (val.minAbs > val.maxAbs) // return { [i]: { minAbs: 'Min ABS should smaller than Max ABS' } }
|
|
1167
|
+
return "The ".concat(i + 1, "th item: Min ABS should smaller than Max ABS");
|
|
1050
1168
|
|
|
1051
1169
|
if (val.minAumPercentage > val.maxAumPercentage) {
|
|
1052
|
-
return
|
|
1053
|
-
|
|
1054
|
-
}
|
|
1170
|
+
// return {
|
|
1171
|
+
// [i]: { minAumPercentage: 'Min AUM should smaller than Max AUM' },
|
|
1172
|
+
// }
|
|
1173
|
+
return "The ".concat(i + 1, "th item: Min AUM should smaller than Max AUM");
|
|
1055
1174
|
}
|
|
1056
1175
|
}
|
|
1057
1176
|
|
|
@@ -1065,9 +1184,27 @@ var ParamTypeConfig = (_ParamTypeConfig = {}, _defineProperty(_ParamTypeConfig,
|
|
|
1065
1184
|
}), _defineProperty(_ParamTypeConfig, ParamType.Phone, {
|
|
1066
1185
|
name: '联系人电话',
|
|
1067
1186
|
key: 'list',
|
|
1068
|
-
Comp: TextArray
|
|
1069
|
-
validator: emptyValidator
|
|
1187
|
+
Comp: TextArray
|
|
1070
1188
|
}), _ParamTypeConfig);
|
|
1189
|
+
function paramValidator(val, values) {
|
|
1190
|
+
var _config$validator;
|
|
1191
|
+
|
|
1192
|
+
var config = ParamTypeConfig[values.valueType];
|
|
1193
|
+
console.log();
|
|
1194
|
+
if (!config) return '';
|
|
1195
|
+
var value = config.key ? val === null || val === void 0 ? void 0 : val[config.key] : val;
|
|
1196
|
+
return ((_config$validator = config.validator) === null || _config$validator === void 0 ? void 0 : _config$validator.call(config, value)) || '';
|
|
1197
|
+
}
|
|
1198
|
+
var ParamTypeOptions = Object.entries(ParamTypeConfig).map(function (_ref) {
|
|
1199
|
+
var _ref2 = _slicedToArray(_ref, 2),
|
|
1200
|
+
value = _ref2[0],
|
|
1201
|
+
config = _ref2[1];
|
|
1202
|
+
|
|
1203
|
+
return _objectSpread2(_objectSpread2({}, config), {}, {
|
|
1204
|
+
value: value,
|
|
1205
|
+
label: config.name
|
|
1206
|
+
});
|
|
1207
|
+
});
|
|
1071
1208
|
|
|
1072
1209
|
var ParamRenderer = /*#__PURE__*/function (_PureComponent) {
|
|
1073
1210
|
_inherits(ParamRenderer, _PureComponent);
|
|
@@ -1122,4 +1259,477 @@ var ParamRenderer = /*#__PURE__*/function (_PureComponent) {
|
|
|
1122
1259
|
return ParamRenderer;
|
|
1123
1260
|
}(PureComponent);
|
|
1124
1261
|
|
|
1125
|
-
|
|
1262
|
+
function ParentSelector(props) {
|
|
1263
|
+
var value = useMemo(function () {
|
|
1264
|
+
var _props$parentOptions;
|
|
1265
|
+
|
|
1266
|
+
var $value = [];
|
|
1267
|
+
|
|
1268
|
+
var find = function find(item) {
|
|
1269
|
+
var _item$children;
|
|
1270
|
+
|
|
1271
|
+
var index = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
1272
|
+
$value[index] = item.value;
|
|
1273
|
+
$value.length = index + 1;
|
|
1274
|
+
if (String(item.value) === String(props.value)) return true;
|
|
1275
|
+
return Boolean((_item$children = item.children) === null || _item$children === void 0 ? void 0 : _item$children.some(function (it) {
|
|
1276
|
+
return find(it, index + 1);
|
|
1277
|
+
}));
|
|
1278
|
+
};
|
|
1279
|
+
|
|
1280
|
+
var matched = props.value && ((_props$parentOptions = props.parentOptions) === null || _props$parentOptions === void 0 ? void 0 : _props$parentOptions.some(function (it) {
|
|
1281
|
+
return find(it);
|
|
1282
|
+
}));
|
|
1283
|
+
if (!matched) return [];
|
|
1284
|
+
return $value;
|
|
1285
|
+
}, [props.parentOptions, props.value]);
|
|
1286
|
+
return /*#__PURE__*/React.createElement(Cascader, Object.assign({}, props, {
|
|
1287
|
+
disabled: props.readonly,
|
|
1288
|
+
placeholder: '请选择',
|
|
1289
|
+
options: props.parentOptions,
|
|
1290
|
+
className: classNames('param-parent-selector', {
|
|
1291
|
+
readonly: props.readonly
|
|
1292
|
+
}, props.className),
|
|
1293
|
+
value: value,
|
|
1294
|
+
onChange: function onChange(val) {
|
|
1295
|
+
var _props$onChange;
|
|
1296
|
+
|
|
1297
|
+
return (_props$onChange = props.onChange) === null || _props$onChange === void 0 ? void 0 : _props$onChange.call(props, val.pop());
|
|
1298
|
+
}
|
|
1299
|
+
}));
|
|
1300
|
+
}
|
|
1301
|
+
|
|
1302
|
+
var ParamForm = /*#__PURE__*/function (_PureComponent) {
|
|
1303
|
+
_inherits(ParamForm, _PureComponent);
|
|
1304
|
+
|
|
1305
|
+
var _super = _createSuper(ParamForm);
|
|
1306
|
+
|
|
1307
|
+
function ParamForm() {
|
|
1308
|
+
var _this;
|
|
1309
|
+
|
|
1310
|
+
_classCallCheck(this, ParamForm);
|
|
1311
|
+
|
|
1312
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
1313
|
+
args[_key] = arguments[_key];
|
|
1314
|
+
}
|
|
1315
|
+
|
|
1316
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
1317
|
+
|
|
1318
|
+
_defineProperty(_assertThisInitialized(_this), "ref", React.createRef());
|
|
1319
|
+
|
|
1320
|
+
_defineProperty(_assertThisInitialized(_this), "formItems", [{
|
|
1321
|
+
label: '所属分组',
|
|
1322
|
+
name: 'parentId',
|
|
1323
|
+
Comp: ParentSelector,
|
|
1324
|
+
required: true,
|
|
1325
|
+
validator: validatorCvt(function (val) {
|
|
1326
|
+
return emptyValidator(val);
|
|
1327
|
+
})
|
|
1328
|
+
}, {
|
|
1329
|
+
label: '参数 Key',
|
|
1330
|
+
name: 'key',
|
|
1331
|
+
Comp: function Comp(props) {
|
|
1332
|
+
return /*#__PURE__*/React.createElement(Input, Object.assign({
|
|
1333
|
+
placeholder: '请输入'
|
|
1334
|
+
}, props));
|
|
1335
|
+
},
|
|
1336
|
+
required: true,
|
|
1337
|
+
validator: validatorCvt(keyValidator)
|
|
1338
|
+
}, {
|
|
1339
|
+
label: '参数名称',
|
|
1340
|
+
name: 'name',
|
|
1341
|
+
Comp: function Comp(props) {
|
|
1342
|
+
return /*#__PURE__*/React.createElement(Input, Object.assign({
|
|
1343
|
+
placeholder: '请输入'
|
|
1344
|
+
}, props));
|
|
1345
|
+
}
|
|
1346
|
+
}, {
|
|
1347
|
+
label: '参数类型',
|
|
1348
|
+
name: 'valueType',
|
|
1349
|
+
Comp: function Comp(props) {
|
|
1350
|
+
return /*#__PURE__*/React.createElement(Select, Object.assign({
|
|
1351
|
+
placeholder: '请选择'
|
|
1352
|
+
}, props, {
|
|
1353
|
+
options: undefined
|
|
1354
|
+
}), ParamTypeOptions.map(function (it) {
|
|
1355
|
+
return /*#__PURE__*/React.createElement(Select.Option, {
|
|
1356
|
+
key: it.value,
|
|
1357
|
+
value: it.value
|
|
1358
|
+
}, it.label);
|
|
1359
|
+
}));
|
|
1360
|
+
},
|
|
1361
|
+
required: true,
|
|
1362
|
+
validator: validatorCvt(function (val) {
|
|
1363
|
+
return emptyValidator(val);
|
|
1364
|
+
})
|
|
1365
|
+
}, {
|
|
1366
|
+
label: '默认值',
|
|
1367
|
+
name: 'defaultValue',
|
|
1368
|
+
Comp: ParamRenderer,
|
|
1369
|
+
validator: validatorCvt(paramValidator, function () {
|
|
1370
|
+
return _this.ref.current;
|
|
1371
|
+
})
|
|
1372
|
+
}, {
|
|
1373
|
+
label: '参数说明',
|
|
1374
|
+
name: 'description',
|
|
1375
|
+
Comp: function Comp(props) {
|
|
1376
|
+
return /*#__PURE__*/React.createElement(Input.TextArea, Object.assign({
|
|
1377
|
+
placeholder: '请输入'
|
|
1378
|
+
}, props));
|
|
1379
|
+
}
|
|
1380
|
+
}]);
|
|
1381
|
+
|
|
1382
|
+
_defineProperty(_assertThisInitialized(_this), "onChange", function (changed, data) {
|
|
1383
|
+
var _this$props$onChange, _this$props;
|
|
1384
|
+
|
|
1385
|
+
(_this$props$onChange = (_this$props = _this.props).onChange) === null || _this$props$onChange === void 0 ? void 0 : _this$props$onChange.call(_this$props, data);
|
|
1386
|
+
if ('valueType' in changed) _this.forceUpdate();
|
|
1387
|
+
});
|
|
1388
|
+
|
|
1389
|
+
return _this;
|
|
1390
|
+
}
|
|
1391
|
+
|
|
1392
|
+
_createClass(ParamForm, [{
|
|
1393
|
+
key: "render",
|
|
1394
|
+
value: function render() {
|
|
1395
|
+
var _this2 = this;
|
|
1396
|
+
|
|
1397
|
+
return /*#__PURE__*/React.createElement(Form, {
|
|
1398
|
+
className: "param-form",
|
|
1399
|
+
ref: this.ref,
|
|
1400
|
+
key: JSON.stringify(this.props.initialValues),
|
|
1401
|
+
initialValues: this.props.initialValues,
|
|
1402
|
+
onFinish: this.props.onSubmit,
|
|
1403
|
+
onValuesChange: this.onChange
|
|
1404
|
+
}, this.formItems.map(function (it) {
|
|
1405
|
+
var _this2$ref$current;
|
|
1406
|
+
|
|
1407
|
+
return /*#__PURE__*/React.createElement(Form.Item, {
|
|
1408
|
+
key: it.name,
|
|
1409
|
+
label: it.label,
|
|
1410
|
+
name: it.name,
|
|
1411
|
+
required: it.required,
|
|
1412
|
+
requiredMark: true,
|
|
1413
|
+
rules: [{
|
|
1414
|
+
validator: it.validator || function () {
|
|
1415
|
+
return Promise.resolve();
|
|
1416
|
+
}
|
|
1417
|
+
}],
|
|
1418
|
+
validateTrigger: 'onBlur'
|
|
1419
|
+
}, /*#__PURE__*/React.createElement(it.Comp, {
|
|
1420
|
+
parentOptions: _this2.props.parentOptions,
|
|
1421
|
+
options: _this2.props.expiriesOptions,
|
|
1422
|
+
valueType: (_this2$ref$current = _this2.ref.current) === null || _this2$ref$current === void 0 ? void 0 : _this2$ref$current.getFieldValue('valueType')
|
|
1423
|
+
}));
|
|
1424
|
+
}), this.props.onSubmit && /*#__PURE__*/React.createElement(Button, {
|
|
1425
|
+
type: "primary",
|
|
1426
|
+
htmlType: "submit"
|
|
1427
|
+
}, "\u63D0\u4EA4"));
|
|
1428
|
+
}
|
|
1429
|
+
}]);
|
|
1430
|
+
|
|
1431
|
+
return ParamForm;
|
|
1432
|
+
}(PureComponent);
|
|
1433
|
+
|
|
1434
|
+
var ParamFormModalEl = /*#__PURE__*/function (_PureComponent2) {
|
|
1435
|
+
_inherits(ParamFormModalEl, _PureComponent2);
|
|
1436
|
+
|
|
1437
|
+
var _super2 = _createSuper(ParamFormModalEl);
|
|
1438
|
+
|
|
1439
|
+
function ParamFormModalEl() {
|
|
1440
|
+
var _this3;
|
|
1441
|
+
|
|
1442
|
+
_classCallCheck(this, ParamFormModalEl);
|
|
1443
|
+
|
|
1444
|
+
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
1445
|
+
args[_key2] = arguments[_key2];
|
|
1446
|
+
}
|
|
1447
|
+
|
|
1448
|
+
_this3 = _super2.call.apply(_super2, [this].concat(args));
|
|
1449
|
+
|
|
1450
|
+
_defineProperty(_assertThisInitialized(_this3), "ref", React.createRef());
|
|
1451
|
+
|
|
1452
|
+
_defineProperty(_assertThisInitialized(_this3), "state", {
|
|
1453
|
+
visible: false
|
|
1454
|
+
});
|
|
1455
|
+
|
|
1456
|
+
_defineProperty(_assertThisInitialized(_this3), "onShow", function () {
|
|
1457
|
+
return _this3.setState({
|
|
1458
|
+
visible: true
|
|
1459
|
+
});
|
|
1460
|
+
});
|
|
1461
|
+
|
|
1462
|
+
_defineProperty(_assertThisInitialized(_this3), "onHide", function () {
|
|
1463
|
+
return _this3.setState({
|
|
1464
|
+
visible: false
|
|
1465
|
+
});
|
|
1466
|
+
});
|
|
1467
|
+
|
|
1468
|
+
_defineProperty(_assertThisInitialized(_this3), "onSubmit", function () {
|
|
1469
|
+
var form = _this3.ref.current.ref.current;
|
|
1470
|
+
return form.validateFields().then(function () {
|
|
1471
|
+
return _this3.props.onSubmit(form.getFieldsValue());
|
|
1472
|
+
}).then(_this3.onHide);
|
|
1473
|
+
});
|
|
1474
|
+
|
|
1475
|
+
return _this3;
|
|
1476
|
+
}
|
|
1477
|
+
|
|
1478
|
+
_createClass(ParamFormModalEl, [{
|
|
1479
|
+
key: "render",
|
|
1480
|
+
value: function render() {
|
|
1481
|
+
var _this$props$initialVa;
|
|
1482
|
+
|
|
1483
|
+
return /*#__PURE__*/React.createElement(Modal, {
|
|
1484
|
+
key: String(this.state.visible),
|
|
1485
|
+
width: 640,
|
|
1486
|
+
closable: false,
|
|
1487
|
+
title: !((_this$props$initialVa = this.props.initialValues) === null || _this$props$initialVa === void 0 ? void 0 : _this$props$initialVa.paramId) ? '新增参数' : '修改参数',
|
|
1488
|
+
visible: this.state.visible,
|
|
1489
|
+
footer: /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Button, {
|
|
1490
|
+
onClick: this.onHide
|
|
1491
|
+
}, "\u53D6\u6D88"), /*#__PURE__*/React.createElement(Button, {
|
|
1492
|
+
type: "primary",
|
|
1493
|
+
onClick: this.onSubmit
|
|
1494
|
+
}, "\u786E\u8BA4"))
|
|
1495
|
+
}, /*#__PURE__*/React.createElement(ParamForm, Object.assign({}, this.props, {
|
|
1496
|
+
ref: this.ref,
|
|
1497
|
+
onSubmit: undefined
|
|
1498
|
+
})));
|
|
1499
|
+
}
|
|
1500
|
+
}]);
|
|
1501
|
+
|
|
1502
|
+
return ParamFormModalEl;
|
|
1503
|
+
}(PureComponent);
|
|
1504
|
+
|
|
1505
|
+
var ParamFormModal = /*#__PURE__*/function () {
|
|
1506
|
+
function ParamFormModal() {
|
|
1507
|
+
_classCallCheck(this, ParamFormModal);
|
|
1508
|
+
}
|
|
1509
|
+
|
|
1510
|
+
_createClass(ParamFormModal, null, [{
|
|
1511
|
+
key: "show",
|
|
1512
|
+
value: function show(props) {
|
|
1513
|
+
return ParamFormModal.el.render(props).then(function () {
|
|
1514
|
+
ParamFormModal.el.ref.onShow();
|
|
1515
|
+
});
|
|
1516
|
+
}
|
|
1517
|
+
}, {
|
|
1518
|
+
key: "hide",
|
|
1519
|
+
value: function hide() {
|
|
1520
|
+
return ParamFormModal.el.render().then(function () {
|
|
1521
|
+
ParamFormModal.el.ref.onHide();
|
|
1522
|
+
});
|
|
1523
|
+
}
|
|
1524
|
+
}]);
|
|
1525
|
+
|
|
1526
|
+
return ParamFormModal;
|
|
1527
|
+
}();
|
|
1528
|
+
|
|
1529
|
+
_defineProperty(ParamFormModal, "el", new ReactGlobalComp('param-form-modal', ParamFormModalEl));
|
|
1530
|
+
|
|
1531
|
+
var ParamValueEditor = /*#__PURE__*/function (_PureComponent) {
|
|
1532
|
+
_inherits(ParamValueEditor, _PureComponent);
|
|
1533
|
+
|
|
1534
|
+
var _super = _createSuper(ParamValueEditor);
|
|
1535
|
+
|
|
1536
|
+
function ParamValueEditor() {
|
|
1537
|
+
var _this;
|
|
1538
|
+
|
|
1539
|
+
_classCallCheck(this, ParamValueEditor);
|
|
1540
|
+
|
|
1541
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
1542
|
+
args[_key] = arguments[_key];
|
|
1543
|
+
}
|
|
1544
|
+
|
|
1545
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
1546
|
+
|
|
1547
|
+
_defineProperty(_assertThisInitialized(_this), "ref", React.createRef());
|
|
1548
|
+
|
|
1549
|
+
_defineProperty(_assertThisInitialized(_this), "formItems", [{
|
|
1550
|
+
label: 'Parameter',
|
|
1551
|
+
name: 'paramId',
|
|
1552
|
+
Comp: function Comp(props) {
|
|
1553
|
+
return /*#__PURE__*/React.createElement(ParentSelector, Object.assign({}, props, {
|
|
1554
|
+
readonly: true
|
|
1555
|
+
}));
|
|
1556
|
+
}
|
|
1557
|
+
}, {
|
|
1558
|
+
label: 'Description',
|
|
1559
|
+
name: 'description',
|
|
1560
|
+
Comp: function Comp(props) {
|
|
1561
|
+
return /*#__PURE__*/React.createElement("span", {
|
|
1562
|
+
className: "param-value-editor-desc",
|
|
1563
|
+
style: {
|
|
1564
|
+
lineHeight: '20px',
|
|
1565
|
+
padding: '10px 0'
|
|
1566
|
+
}
|
|
1567
|
+
}, props.value || '-');
|
|
1568
|
+
}
|
|
1569
|
+
}, {
|
|
1570
|
+
label: 'Value before',
|
|
1571
|
+
name: 'valueBefore',
|
|
1572
|
+
Comp: function Comp(props) {
|
|
1573
|
+
return /*#__PURE__*/React.createElement(ParamRenderer, Object.assign({}, props, {
|
|
1574
|
+
readonly: true
|
|
1575
|
+
}));
|
|
1576
|
+
}
|
|
1577
|
+
}, {
|
|
1578
|
+
label: 'Value after',
|
|
1579
|
+
name: 'value',
|
|
1580
|
+
Comp: ParamRenderer,
|
|
1581
|
+
required: true,
|
|
1582
|
+
validator: validatorCvt(function (val) {
|
|
1583
|
+
return paramValidator(val, {
|
|
1584
|
+
valueType: _this.props.valueType
|
|
1585
|
+
});
|
|
1586
|
+
})
|
|
1587
|
+
}]);
|
|
1588
|
+
|
|
1589
|
+
_defineProperty(_assertThisInitialized(_this), "onChange", function (changed, data) {
|
|
1590
|
+
var _this$props$onChange, _this$props;
|
|
1591
|
+
|
|
1592
|
+
(_this$props$onChange = (_this$props = _this.props).onChange) === null || _this$props$onChange === void 0 ? void 0 : _this$props$onChange.call(_this$props, data);
|
|
1593
|
+
});
|
|
1594
|
+
|
|
1595
|
+
return _this;
|
|
1596
|
+
}
|
|
1597
|
+
|
|
1598
|
+
_createClass(ParamValueEditor, [{
|
|
1599
|
+
key: "componentDidMount",
|
|
1600
|
+
value: function componentDidMount() {
|
|
1601
|
+
console.log(1111, 'mounted');
|
|
1602
|
+
}
|
|
1603
|
+
}, {
|
|
1604
|
+
key: "render",
|
|
1605
|
+
value: function render() {
|
|
1606
|
+
var _this2 = this;
|
|
1607
|
+
|
|
1608
|
+
return /*#__PURE__*/React.createElement(Form, {
|
|
1609
|
+
className: "param-value-editor",
|
|
1610
|
+
ref: this.ref,
|
|
1611
|
+
key: this.props.valueType,
|
|
1612
|
+
initialValues: this.props.initialValues,
|
|
1613
|
+
onFinish: this.props.onSubmit,
|
|
1614
|
+
onValuesChange: this.onChange
|
|
1615
|
+
}, this.formItems.map(function (it) {
|
|
1616
|
+
return /*#__PURE__*/React.createElement(Form.Item, {
|
|
1617
|
+
key: it.name,
|
|
1618
|
+
label: it.label,
|
|
1619
|
+
name: it.name,
|
|
1620
|
+
required: it.required,
|
|
1621
|
+
requiredMark: true,
|
|
1622
|
+
rules: [{
|
|
1623
|
+
validator: it.validator || function () {
|
|
1624
|
+
return Promise.resolve();
|
|
1625
|
+
}
|
|
1626
|
+
}],
|
|
1627
|
+
validateTrigger: 'onBlur'
|
|
1628
|
+
}, /*#__PURE__*/React.createElement(it.Comp, {
|
|
1629
|
+
parentOptions: _this2.props.allParams,
|
|
1630
|
+
valueType: _this2.props.valueType
|
|
1631
|
+
}));
|
|
1632
|
+
}), this.props.onSubmit && /*#__PURE__*/React.createElement(Button, {
|
|
1633
|
+
type: "primary",
|
|
1634
|
+
htmlType: "submit"
|
|
1635
|
+
}, "\u63D0\u4EA4"));
|
|
1636
|
+
}
|
|
1637
|
+
}]);
|
|
1638
|
+
|
|
1639
|
+
return ParamValueEditor;
|
|
1640
|
+
}(PureComponent);
|
|
1641
|
+
var ParamValueEditorModalEl = /*#__PURE__*/function (_PureComponent2) {
|
|
1642
|
+
_inherits(ParamValueEditorModalEl, _PureComponent2);
|
|
1643
|
+
|
|
1644
|
+
var _super2 = _createSuper(ParamValueEditorModalEl);
|
|
1645
|
+
|
|
1646
|
+
function ParamValueEditorModalEl() {
|
|
1647
|
+
var _this3;
|
|
1648
|
+
|
|
1649
|
+
_classCallCheck(this, ParamValueEditorModalEl);
|
|
1650
|
+
|
|
1651
|
+
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
1652
|
+
args[_key2] = arguments[_key2];
|
|
1653
|
+
}
|
|
1654
|
+
|
|
1655
|
+
_this3 = _super2.call.apply(_super2, [this].concat(args));
|
|
1656
|
+
|
|
1657
|
+
_defineProperty(_assertThisInitialized(_this3), "ref", React.createRef());
|
|
1658
|
+
|
|
1659
|
+
_defineProperty(_assertThisInitialized(_this3), "state", {
|
|
1660
|
+
visible: false
|
|
1661
|
+
});
|
|
1662
|
+
|
|
1663
|
+
_defineProperty(_assertThisInitialized(_this3), "onShow", function () {
|
|
1664
|
+
return _this3.setState({
|
|
1665
|
+
visible: true
|
|
1666
|
+
});
|
|
1667
|
+
});
|
|
1668
|
+
|
|
1669
|
+
_defineProperty(_assertThisInitialized(_this3), "onHide", function () {
|
|
1670
|
+
return _this3.setState({
|
|
1671
|
+
visible: false
|
|
1672
|
+
});
|
|
1673
|
+
});
|
|
1674
|
+
|
|
1675
|
+
_defineProperty(_assertThisInitialized(_this3), "onSubmit", function () {
|
|
1676
|
+
var form = _this3.ref.current.ref.current;
|
|
1677
|
+
return form.validateFields().then(function () {
|
|
1678
|
+
return _this3.props.onSubmit(form.getFieldsValue());
|
|
1679
|
+
}).then(_this3.onHide);
|
|
1680
|
+
});
|
|
1681
|
+
|
|
1682
|
+
return _this3;
|
|
1683
|
+
}
|
|
1684
|
+
|
|
1685
|
+
_createClass(ParamValueEditorModalEl, [{
|
|
1686
|
+
key: "render",
|
|
1687
|
+
value: function render() {
|
|
1688
|
+
return /*#__PURE__*/React.createElement(Modal, {
|
|
1689
|
+
key: String(this.state.visible),
|
|
1690
|
+
width: 640,
|
|
1691
|
+
title: 'Edit Value',
|
|
1692
|
+
closable: false,
|
|
1693
|
+
visible: this.state.visible,
|
|
1694
|
+
footer: /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Button, {
|
|
1695
|
+
onClick: this.onHide
|
|
1696
|
+
}, "Cancel"), /*#__PURE__*/React.createElement(Button, {
|
|
1697
|
+
type: "primary",
|
|
1698
|
+
onClick: this.onSubmit
|
|
1699
|
+
}, "Submit"))
|
|
1700
|
+
}, /*#__PURE__*/React.createElement(ParamValueEditor, Object.assign({}, this.props, {
|
|
1701
|
+
ref: this.ref,
|
|
1702
|
+
onSubmit: undefined
|
|
1703
|
+
})));
|
|
1704
|
+
}
|
|
1705
|
+
}]);
|
|
1706
|
+
|
|
1707
|
+
return ParamValueEditorModalEl;
|
|
1708
|
+
}(PureComponent);
|
|
1709
|
+
var ParamValueEditorModal = /*#__PURE__*/function () {
|
|
1710
|
+
function ParamValueEditorModal() {
|
|
1711
|
+
_classCallCheck(this, ParamValueEditorModal);
|
|
1712
|
+
}
|
|
1713
|
+
|
|
1714
|
+
_createClass(ParamValueEditorModal, null, [{
|
|
1715
|
+
key: "show",
|
|
1716
|
+
value: function show(props) {
|
|
1717
|
+
return ParamValueEditorModal.el.render(props).then(function () {
|
|
1718
|
+
ParamValueEditorModal.el.ref.onShow();
|
|
1719
|
+
});
|
|
1720
|
+
}
|
|
1721
|
+
}, {
|
|
1722
|
+
key: "hide",
|
|
1723
|
+
value: function hide() {
|
|
1724
|
+
return ParamValueEditorModal.el.render().then(function () {
|
|
1725
|
+
ParamValueEditorModal.el.ref.onHide();
|
|
1726
|
+
});
|
|
1727
|
+
}
|
|
1728
|
+
}]);
|
|
1729
|
+
|
|
1730
|
+
return ParamValueEditorModal;
|
|
1731
|
+
}();
|
|
1732
|
+
|
|
1733
|
+
_defineProperty(ParamValueEditorModal, "el", new ReactGlobalComp('param-value-editor-modal', ParamValueEditorModalEl));
|
|
1734
|
+
|
|
1735
|
+
export { ParamForm, ParamFormModal, ParamRenderer, ParamType, ParamTypeConfig, ParamTypeOptions, ParamValueEditor, ParamValueEditorModal, ParamValueEditorModalEl, emptyValidator, expiriesValidator, expiryValidator, formatNum, isExpired, isNullLike, keyValidator, numRangeValidator, paramValidator, validatorCvt };
|