@signalplus/params-about 0.1.0 → 0.1.1
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 +171 -96
- package/lib/css/Bool.scss +19 -0
- package/lib/css/Expiries.scss +108 -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 +9 -276
- package/lib/css/var.scss +7 -0
- package/lib/es/index.js +687 -88
- package/package.json +7 -42
- 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.1
|
|
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
|
}
|
|
@@ -524,7 +621,8 @@ var Num = /*#__PURE__*/function (_PureComponent) {
|
|
|
524
621
|
type: "text",
|
|
525
622
|
placeholder: this.props.placeholder || 'Value',
|
|
526
623
|
value: this.state.tempValue || '',
|
|
527
|
-
onChange: this.onChange
|
|
624
|
+
onChange: this.onChange,
|
|
625
|
+
onBlur: this.props.onBlur
|
|
528
626
|
}), this.props.isPercentage && /*#__PURE__*/React.createElement("span", {
|
|
529
627
|
className: "param-number-suffix"
|
|
530
628
|
}, "%"));
|
|
@@ -590,7 +688,8 @@ var NumRange = /*#__PURE__*/function (_PureComponent) {
|
|
|
590
688
|
value: (_this$props$value = this.props.value) === null || _this$props$value === void 0 ? void 0 : _this$props$value.min,
|
|
591
689
|
onChange: this.onChange.bind(null, 'min'),
|
|
592
690
|
isPercentage: this.props.isPercentage,
|
|
593
|
-
readonly: this.props.readonly
|
|
691
|
+
readonly: this.props.readonly,
|
|
692
|
+
onBlur: this.props.onBlur
|
|
594
693
|
}), /*#__PURE__*/React.createElement("span", {
|
|
595
694
|
className: "param-number-range-sep"
|
|
596
695
|
}, this.props.readonly ? ',' : '-'), /*#__PURE__*/React.createElement("span", {
|
|
@@ -600,7 +699,8 @@ var NumRange = /*#__PURE__*/function (_PureComponent) {
|
|
|
600
699
|
value: (_this$props$value2 = this.props.value) === null || _this$props$value2 === void 0 ? void 0 : _this$props$value2.max,
|
|
601
700
|
onChange: this.onChange.bind(null, 'max'),
|
|
602
701
|
isPercentage: this.props.isPercentage,
|
|
603
|
-
readonly: this.props.readonly
|
|
702
|
+
readonly: this.props.readonly,
|
|
703
|
+
onBlur: this.props.onBlur
|
|
604
704
|
}));
|
|
605
705
|
}
|
|
606
706
|
}]);
|
|
@@ -608,16 +708,6 @@ var NumRange = /*#__PURE__*/function (_PureComponent) {
|
|
|
608
708
|
return NumRange;
|
|
609
709
|
}(PureComponent);
|
|
610
710
|
|
|
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
711
|
function _arrayWithoutHoles(arr) {
|
|
622
712
|
if (Array.isArray(arr)) return _arrayLikeToArray(arr);
|
|
623
713
|
}
|
|
@@ -626,15 +716,6 @@ function _iterableToArray(iter) {
|
|
|
626
716
|
if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter);
|
|
627
717
|
}
|
|
628
718
|
|
|
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
719
|
function _nonIterableSpread() {
|
|
639
720
|
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
721
|
}
|
|
@@ -715,7 +796,8 @@ var TextArray = /*#__PURE__*/function (_PureComponent) {
|
|
|
715
796
|
type: "text",
|
|
716
797
|
placeholder: "Phone",
|
|
717
798
|
value: it,
|
|
718
|
-
onChange: _this2.onChange.bind(null, i)
|
|
799
|
+
onChange: _this2.onChange.bind(null, i),
|
|
800
|
+
onBlur: _this2.props.onBlur
|
|
719
801
|
}), /*#__PURE__*/React.createElement("div", {
|
|
720
802
|
className: "param-arr-ops"
|
|
721
803
|
}, /*#__PURE__*/React.createElement(PlusOutlined, {
|
|
@@ -759,15 +841,21 @@ var Expiries = /*#__PURE__*/function (_PureComponent) {
|
|
|
759
841
|
});
|
|
760
842
|
|
|
761
843
|
_defineProperty(_assertThisInitialized(_this), "onChange", function (val) {
|
|
762
|
-
var _this$props$onChange, _this$props;
|
|
844
|
+
var _this$props$onChange, _this$props, _this$props$onBlur, _this$props2;
|
|
763
845
|
|
|
764
846
|
var value = _toConsumableArray(_this.props.value || []);
|
|
765
847
|
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
848
|
+
if (_this.props.multiple !== false) {
|
|
849
|
+
var index = value.findIndex(function (it) {
|
|
850
|
+
return it === val;
|
|
851
|
+
});
|
|
852
|
+
if (index > -1) value.splice(index, 1);else value.push(val);
|
|
853
|
+
} else {
|
|
854
|
+
value = [val];
|
|
855
|
+
}
|
|
856
|
+
|
|
770
857
|
(_this$props$onChange = (_this$props = _this.props).onChange) === null || _this$props$onChange === void 0 ? void 0 : _this$props$onChange.call(_this$props, value);
|
|
858
|
+
(_this$props$onBlur = (_this$props2 = _this.props).onBlur) === null || _this$props$onBlur === void 0 ? void 0 : _this$props$onBlur.call(_this$props2);
|
|
771
859
|
if (_this.props.multiple === false) _this.handleVisibleChange(false);
|
|
772
860
|
});
|
|
773
861
|
|
|
@@ -777,7 +865,8 @@ var Expiries = /*#__PURE__*/function (_PureComponent) {
|
|
|
777
865
|
_createClass(Expiries, [{
|
|
778
866
|
key: "renderValue",
|
|
779
867
|
value: function renderValue() {
|
|
780
|
-
var _this$props$value
|
|
868
|
+
var _this$props$value,
|
|
869
|
+
_this2 = this;
|
|
781
870
|
|
|
782
871
|
var value = (_this$props$value = this.props.value) === null || _this$props$value === void 0 ? void 0 : _this$props$value.filter(function (it) {
|
|
783
872
|
return it && !isExpired(it);
|
|
@@ -807,15 +896,20 @@ var Expiries = /*#__PURE__*/function (_PureComponent) {
|
|
|
807
896
|
return value.map(function (it) {
|
|
808
897
|
return /*#__PURE__*/React.createElement("span", {
|
|
809
898
|
className: "param-expiries-multi-val",
|
|
810
|
-
key: it
|
|
811
|
-
|
|
899
|
+
key: it,
|
|
900
|
+
onClick: function onClick(e) {
|
|
901
|
+
return e.stopPropagation();
|
|
902
|
+
}
|
|
903
|
+
}, it, /*#__PURE__*/React.createElement(CloseOutlined, {
|
|
904
|
+
onClick: _this2.onChange.bind(null, it)
|
|
905
|
+
}));
|
|
812
906
|
});
|
|
813
907
|
}
|
|
814
908
|
}, {
|
|
815
909
|
key: "render",
|
|
816
910
|
value: function render() {
|
|
817
911
|
var _this$props$options,
|
|
818
|
-
|
|
912
|
+
_this3 = this;
|
|
819
913
|
|
|
820
914
|
return /*#__PURE__*/React.createElement(Popover, {
|
|
821
915
|
overlayClassName: "param-expiries-popover",
|
|
@@ -824,20 +918,23 @@ var Expiries = /*#__PURE__*/function (_PureComponent) {
|
|
|
824
918
|
visible: !this.props.readonly && this.state.visible,
|
|
825
919
|
onVisibleChange: this.handleVisibleChange,
|
|
826
920
|
content: (_this$props$options = this.props.options) === null || _this$props$options === void 0 ? void 0 : _this$props$options.map(function (it) {
|
|
827
|
-
var
|
|
921
|
+
var _this3$props$value, _this3$props$calcDisa, _this3$props, _this3$onChange;
|
|
828
922
|
|
|
829
|
-
var checked = (
|
|
923
|
+
var checked = (_this3$props$value = _this3.props.value) === null || _this3$props$value === void 0 ? void 0 : _this3$props$value.includes(it);
|
|
924
|
+
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
925
|
return /*#__PURE__*/React.createElement("div", {
|
|
831
926
|
className: classNames('param-expiries-option', {
|
|
832
|
-
'param-expiries-option-checked': checked
|
|
927
|
+
'param-expiries-option-checked': checked,
|
|
928
|
+
'param-expiries-option-disabled': disabled
|
|
833
929
|
}),
|
|
834
930
|
key: it,
|
|
835
|
-
onClick: (
|
|
931
|
+
onClick: disabled ? undefined : (_this3$onChange = _this3.onChange) === null || _this3$onChange === void 0 ? void 0 : _this3$onChange.bind(null, it)
|
|
836
932
|
}, it, checked && /*#__PURE__*/React.createElement(CheckOutlined, null));
|
|
837
933
|
})
|
|
838
934
|
}, /*#__PURE__*/React.createElement("div", {
|
|
839
935
|
className: classNames('param-expiries', {
|
|
840
|
-
readonly: this.props.readonly
|
|
936
|
+
readonly: this.props.readonly,
|
|
937
|
+
multiple: this.props.multiple !== false
|
|
841
938
|
}, this.props.className),
|
|
842
939
|
style: this.props.style
|
|
843
940
|
}, this.renderValue(), !this.props.readonly && this.props.options && /*#__PURE__*/React.createElement(DownOutlined, {
|
|
@@ -880,7 +977,7 @@ var ExpiriesLimit = /*#__PURE__*/function (_PureComponent) {
|
|
|
880
977
|
});
|
|
881
978
|
|
|
882
979
|
_defineProperty(_assertThisInitialized(_this), "onAdd", function (i) {
|
|
883
|
-
var _this$props$onChange2, _this$props2;
|
|
980
|
+
var _this$props$onChange2, _this$props2, _this$props$onBlur, _this$props3;
|
|
884
981
|
|
|
885
982
|
var value = _toConsumableArray(_this.value);
|
|
886
983
|
|
|
@@ -888,15 +985,17 @@ var ExpiriesLimit = /*#__PURE__*/function (_PureComponent) {
|
|
|
888
985
|
expiry: ''
|
|
889
986
|
});
|
|
890
987
|
(_this$props$onChange2 = (_this$props2 = _this.props).onChange) === null || _this$props$onChange2 === void 0 ? void 0 : _this$props$onChange2.call(_this$props2, value);
|
|
988
|
+
(_this$props$onBlur = (_this$props3 = _this.props).onBlur) === null || _this$props$onBlur === void 0 ? void 0 : _this$props$onBlur.call(_this$props3);
|
|
891
989
|
});
|
|
892
990
|
|
|
893
991
|
_defineProperty(_assertThisInitialized(_this), "onDel", function (i) {
|
|
894
|
-
var _this$props$onChange3, _this$
|
|
992
|
+
var _this$props$onChange3, _this$props4, _this$props$onBlur2, _this$props5;
|
|
895
993
|
|
|
896
994
|
var value = _toConsumableArray(_this.value);
|
|
897
995
|
|
|
898
996
|
value.splice(i, 1);
|
|
899
|
-
(_this$props$onChange3 = (_this$
|
|
997
|
+
(_this$props$onChange3 = (_this$props4 = _this.props).onChange) === null || _this$props$onChange3 === void 0 ? void 0 : _this$props$onChange3.call(_this$props4, value);
|
|
998
|
+
(_this$props$onBlur2 = (_this$props5 = _this.props).onBlur) === null || _this$props$onBlur2 === void 0 ? void 0 : _this$props$onBlur2.call(_this$props5);
|
|
900
999
|
});
|
|
901
1000
|
|
|
902
1001
|
return _this;
|
|
@@ -906,10 +1005,11 @@ var ExpiriesLimit = /*#__PURE__*/function (_PureComponent) {
|
|
|
906
1005
|
key: "render",
|
|
907
1006
|
value: function render() {
|
|
908
1007
|
var _this$props$value,
|
|
1008
|
+
_this$props$value2,
|
|
909
1009
|
_this2 = this;
|
|
910
1010
|
|
|
911
1011
|
this.value = ((_this$props$value = this.props.value) === null || _this$props$value === void 0 ? void 0 : _this$props$value.filter(function (it) {
|
|
912
|
-
return
|
|
1012
|
+
return !isExpired(it.expiry);
|
|
913
1013
|
})) || [];
|
|
914
1014
|
if (!this.value.length) this.value.push({
|
|
915
1015
|
expiry: ''
|
|
@@ -919,14 +1019,18 @@ var ExpiriesLimit = /*#__PURE__*/function (_PureComponent) {
|
|
|
919
1019
|
readonly: this.props.readonly
|
|
920
1020
|
}, this.props.className),
|
|
921
1021
|
style: this.props.style
|
|
922
|
-
}, this.props.readonly ? this.value.filter(function (it) {
|
|
1022
|
+
}, 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
1023
|
return it.expiry;
|
|
924
1024
|
}).map(function (it, i) {
|
|
925
1025
|
return /*#__PURE__*/React.createElement("span", {
|
|
926
1026
|
className: "param-expiries-limit-val",
|
|
927
1027
|
key: i
|
|
928
|
-
}, it.expiry,
|
|
929
|
-
|
|
1028
|
+
}, it.expiry, /*#__PURE__*/React.createElement("span", {
|
|
1029
|
+
className: "param-expiries-limit-val-sep"
|
|
1030
|
+
}, "/"), it.minAumPercentage && it.maxAumPercentage ? "(".concat(NumCvt.show(it.minAumPercentage, true), "%, ").concat(NumCvt.show(it.maxAumPercentage, true), "%)") : '-', /*#__PURE__*/React.createElement("span", {
|
|
1031
|
+
className: "param-expiries-limit-val-sep"
|
|
1032
|
+
}, "/"), it.minAbs && it.maxAbs ? "(".concat(it.minAbs, ", ").concat(it.maxAbs, ")") : '-');
|
|
1033
|
+
}) : '-' : /*#__PURE__*/React.createElement("div", {
|
|
930
1034
|
className: "param-expiries-limit-inputs"
|
|
931
1035
|
}, /*#__PURE__*/React.createElement("div", {
|
|
932
1036
|
className: "param-expiries readonly"
|
|
@@ -947,7 +1051,13 @@ var ExpiriesLimit = /*#__PURE__*/function (_PureComponent) {
|
|
|
947
1051
|
value: [it.expiry],
|
|
948
1052
|
onChange: function onChange(val) {
|
|
949
1053
|
return _this2.onChange(i, val[0], 'expiry');
|
|
950
|
-
}
|
|
1054
|
+
},
|
|
1055
|
+
calcDisabled: function calcDisabled(expiry) {
|
|
1056
|
+
return _this2.value.some(function (item) {
|
|
1057
|
+
return item !== it && item.expiry === expiry;
|
|
1058
|
+
});
|
|
1059
|
+
},
|
|
1060
|
+
onBlur: _this2.props.onBlur
|
|
951
1061
|
}), /*#__PURE__*/React.createElement(NumRange, {
|
|
952
1062
|
value: {
|
|
953
1063
|
min: it.minAumPercentage,
|
|
@@ -959,7 +1069,8 @@ var ExpiriesLimit = /*#__PURE__*/function (_PureComponent) {
|
|
|
959
1069
|
maxAumPercentage: val === null || val === void 0 ? void 0 : val.max
|
|
960
1070
|
});
|
|
961
1071
|
},
|
|
962
|
-
isPercentage: true
|
|
1072
|
+
isPercentage: true,
|
|
1073
|
+
onBlur: _this2.props.onBlur
|
|
963
1074
|
}), /*#__PURE__*/React.createElement(NumRange, {
|
|
964
1075
|
value: {
|
|
965
1076
|
min: it.minAbs,
|
|
@@ -970,7 +1081,8 @@ var ExpiriesLimit = /*#__PURE__*/function (_PureComponent) {
|
|
|
970
1081
|
minAbs: val === null || val === void 0 ? void 0 : val.min,
|
|
971
1082
|
maxAbs: val === null || val === void 0 ? void 0 : val.max
|
|
972
1083
|
});
|
|
973
|
-
}
|
|
1084
|
+
},
|
|
1085
|
+
onBlur: _this2.props.onBlur
|
|
974
1086
|
}), /*#__PURE__*/React.createElement("div", {
|
|
975
1087
|
className: "param-arr-ops"
|
|
976
1088
|
}, /*#__PURE__*/React.createElement(PlusOutlined, {
|
|
@@ -1030,28 +1142,31 @@ var ParamTypeConfig = (_ParamTypeConfig = {}, _defineProperty(_ParamTypeConfig,
|
|
|
1030
1142
|
name: '到期日 Limit',
|
|
1031
1143
|
key: 'expiryLimitList',
|
|
1032
1144
|
Comp: ExpiriesLimit,
|
|
1033
|
-
validator: function validator(val
|
|
1034
|
-
var
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
}
|
|
1145
|
+
validator: function validator($val) {
|
|
1146
|
+
for (var i = 0; i < $val.length; i++) {
|
|
1147
|
+
var val = $val[i];
|
|
1148
|
+
var error = expiryValidator(val === null || val === void 0 ? void 0 : val.expiry);
|
|
1149
|
+
|
|
1150
|
+
if (error) {
|
|
1151
|
+
// return { [i]: { expire: error } }
|
|
1152
|
+
return "Expiry field of the ".concat(i + 1, "th item: ").concat(error);
|
|
1153
|
+
}
|
|
1042
1154
|
|
|
1043
1155
|
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
|
|
1156
|
+
// return {
|
|
1157
|
+
// [i]: 'at least one parameter must be specified between AUM and ABS',
|
|
1158
|
+
// }
|
|
1159
|
+
return "The ".concat(i + 1, "th item: at least one parameter must be specified between AUM and ABS");
|
|
1045
1160
|
}
|
|
1046
1161
|
|
|
1047
|
-
if (val.minAbs > val.maxAbs) return
|
|
1048
|
-
|
|
1049
|
-
});
|
|
1162
|
+
if (val.minAbs > val.maxAbs) // return { [i]: { minAbs: 'Min ABS should smaller than Max ABS' } }
|
|
1163
|
+
return "The ".concat(i + 1, "th item: Min ABS should smaller than Max ABS");
|
|
1050
1164
|
|
|
1051
1165
|
if (val.minAumPercentage > val.maxAumPercentage) {
|
|
1052
|
-
return
|
|
1053
|
-
|
|
1054
|
-
}
|
|
1166
|
+
// return {
|
|
1167
|
+
// [i]: { minAumPercentage: 'Min AUM should smaller than Max AUM' },
|
|
1168
|
+
// }
|
|
1169
|
+
return "The ".concat(i + 1, "th item: Min AUM should smaller than Max AUM");
|
|
1055
1170
|
}
|
|
1056
1171
|
}
|
|
1057
1172
|
|
|
@@ -1065,9 +1180,27 @@ var ParamTypeConfig = (_ParamTypeConfig = {}, _defineProperty(_ParamTypeConfig,
|
|
|
1065
1180
|
}), _defineProperty(_ParamTypeConfig, ParamType.Phone, {
|
|
1066
1181
|
name: '联系人电话',
|
|
1067
1182
|
key: 'list',
|
|
1068
|
-
Comp: TextArray
|
|
1069
|
-
validator: emptyValidator
|
|
1183
|
+
Comp: TextArray
|
|
1070
1184
|
}), _ParamTypeConfig);
|
|
1185
|
+
function paramValidator(val, values) {
|
|
1186
|
+
var _config$validator;
|
|
1187
|
+
|
|
1188
|
+
var config = ParamTypeConfig[values.valueType];
|
|
1189
|
+
console.log();
|
|
1190
|
+
if (!config) return '';
|
|
1191
|
+
var value = config.key ? val === null || val === void 0 ? void 0 : val[config.key] : val;
|
|
1192
|
+
return ((_config$validator = config.validator) === null || _config$validator === void 0 ? void 0 : _config$validator.call(config, value)) || '';
|
|
1193
|
+
}
|
|
1194
|
+
var ParamTypeOptions = Object.entries(ParamTypeConfig).map(function (_ref) {
|
|
1195
|
+
var _ref2 = _slicedToArray(_ref, 2),
|
|
1196
|
+
value = _ref2[0],
|
|
1197
|
+
config = _ref2[1];
|
|
1198
|
+
|
|
1199
|
+
return _objectSpread2(_objectSpread2({}, config), {}, {
|
|
1200
|
+
value: value,
|
|
1201
|
+
label: config.name
|
|
1202
|
+
});
|
|
1203
|
+
});
|
|
1071
1204
|
|
|
1072
1205
|
var ParamRenderer = /*#__PURE__*/function (_PureComponent) {
|
|
1073
1206
|
_inherits(ParamRenderer, _PureComponent);
|
|
@@ -1122,4 +1255,470 @@ var ParamRenderer = /*#__PURE__*/function (_PureComponent) {
|
|
|
1122
1255
|
return ParamRenderer;
|
|
1123
1256
|
}(PureComponent);
|
|
1124
1257
|
|
|
1125
|
-
|
|
1258
|
+
function ParentSelector(props) {
|
|
1259
|
+
var value = useMemo(function () {
|
|
1260
|
+
var _props$parentOptions;
|
|
1261
|
+
|
|
1262
|
+
var $value = [];
|
|
1263
|
+
|
|
1264
|
+
var find = function find(item) {
|
|
1265
|
+
var _item$children;
|
|
1266
|
+
|
|
1267
|
+
var index = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
1268
|
+
$value[index] = item.value;
|
|
1269
|
+
if (String(item.value) === String(props.value)) return true;
|
|
1270
|
+
$value.length = index + 1;
|
|
1271
|
+
return Boolean((_item$children = item.children) === null || _item$children === void 0 ? void 0 : _item$children.some(function (it) {
|
|
1272
|
+
return find(it, index + 1);
|
|
1273
|
+
}));
|
|
1274
|
+
};
|
|
1275
|
+
|
|
1276
|
+
var matched = props.value && ((_props$parentOptions = props.parentOptions) === null || _props$parentOptions === void 0 ? void 0 : _props$parentOptions.some(function (it) {
|
|
1277
|
+
return find(it);
|
|
1278
|
+
}));
|
|
1279
|
+
if (!matched) return [];
|
|
1280
|
+
return $value;
|
|
1281
|
+
}, [props.parentOptions, props.value]);
|
|
1282
|
+
return /*#__PURE__*/React.createElement(Cascader, Object.assign({}, props, {
|
|
1283
|
+
disabled: props.readonly,
|
|
1284
|
+
placeholder: '请选择',
|
|
1285
|
+
options: props.parentOptions,
|
|
1286
|
+
className: classNames('param-parent-selector', {
|
|
1287
|
+
readonly: props.readonly
|
|
1288
|
+
}, props.className),
|
|
1289
|
+
value: value,
|
|
1290
|
+
onChange: function onChange(val) {
|
|
1291
|
+
var _props$onChange;
|
|
1292
|
+
|
|
1293
|
+
return (_props$onChange = props.onChange) === null || _props$onChange === void 0 ? void 0 : _props$onChange.call(props, val.pop());
|
|
1294
|
+
}
|
|
1295
|
+
}));
|
|
1296
|
+
}
|
|
1297
|
+
|
|
1298
|
+
var ParamForm = /*#__PURE__*/function (_PureComponent) {
|
|
1299
|
+
_inherits(ParamForm, _PureComponent);
|
|
1300
|
+
|
|
1301
|
+
var _super = _createSuper(ParamForm);
|
|
1302
|
+
|
|
1303
|
+
function ParamForm() {
|
|
1304
|
+
var _this;
|
|
1305
|
+
|
|
1306
|
+
_classCallCheck(this, ParamForm);
|
|
1307
|
+
|
|
1308
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
1309
|
+
args[_key] = arguments[_key];
|
|
1310
|
+
}
|
|
1311
|
+
|
|
1312
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
1313
|
+
|
|
1314
|
+
_defineProperty(_assertThisInitialized(_this), "ref", React.createRef());
|
|
1315
|
+
|
|
1316
|
+
_defineProperty(_assertThisInitialized(_this), "formItems", [{
|
|
1317
|
+
label: '所属分组',
|
|
1318
|
+
name: 'parentId',
|
|
1319
|
+
Comp: ParentSelector,
|
|
1320
|
+
required: true,
|
|
1321
|
+
validator: validatorCvt(function (val) {
|
|
1322
|
+
return emptyValidator(val);
|
|
1323
|
+
})
|
|
1324
|
+
}, {
|
|
1325
|
+
label: '参数 Key',
|
|
1326
|
+
name: 'key',
|
|
1327
|
+
Comp: function Comp(props) {
|
|
1328
|
+
return /*#__PURE__*/React.createElement(Input, Object.assign({
|
|
1329
|
+
placeholder: '请输入'
|
|
1330
|
+
}, props));
|
|
1331
|
+
},
|
|
1332
|
+
required: true,
|
|
1333
|
+
validator: validatorCvt(keyValidator)
|
|
1334
|
+
}, {
|
|
1335
|
+
label: '参数名称',
|
|
1336
|
+
name: 'name',
|
|
1337
|
+
Comp: function Comp(props) {
|
|
1338
|
+
return /*#__PURE__*/React.createElement(Input, Object.assign({
|
|
1339
|
+
placeholder: '请输入'
|
|
1340
|
+
}, props));
|
|
1341
|
+
}
|
|
1342
|
+
}, {
|
|
1343
|
+
label: '参数类型',
|
|
1344
|
+
name: 'valueType',
|
|
1345
|
+
Comp: function Comp(props) {
|
|
1346
|
+
return /*#__PURE__*/React.createElement(Select, Object.assign({
|
|
1347
|
+
placeholder: '请选择'
|
|
1348
|
+
}, props, {
|
|
1349
|
+
options: undefined
|
|
1350
|
+
}), ParamTypeOptions.map(function (it) {
|
|
1351
|
+
return /*#__PURE__*/React.createElement(Select.Option, {
|
|
1352
|
+
key: it.value,
|
|
1353
|
+
value: it.value
|
|
1354
|
+
}, it.label);
|
|
1355
|
+
}));
|
|
1356
|
+
},
|
|
1357
|
+
required: true,
|
|
1358
|
+
validator: validatorCvt(function (val) {
|
|
1359
|
+
return emptyValidator(val);
|
|
1360
|
+
})
|
|
1361
|
+
}, {
|
|
1362
|
+
label: '默认值',
|
|
1363
|
+
name: 'defaultValue',
|
|
1364
|
+
Comp: ParamRenderer,
|
|
1365
|
+
validator: validatorCvt(paramValidator, function () {
|
|
1366
|
+
return _this.ref.current;
|
|
1367
|
+
})
|
|
1368
|
+
}, {
|
|
1369
|
+
label: '参数说明',
|
|
1370
|
+
name: 'description',
|
|
1371
|
+
Comp: function Comp(props) {
|
|
1372
|
+
return /*#__PURE__*/React.createElement(Input.TextArea, Object.assign({
|
|
1373
|
+
placeholder: '请输入'
|
|
1374
|
+
}, props));
|
|
1375
|
+
}
|
|
1376
|
+
}]);
|
|
1377
|
+
|
|
1378
|
+
_defineProperty(_assertThisInitialized(_this), "onChange", function (changed, data) {
|
|
1379
|
+
var _this$props$onChange, _this$props;
|
|
1380
|
+
|
|
1381
|
+
(_this$props$onChange = (_this$props = _this.props).onChange) === null || _this$props$onChange === void 0 ? void 0 : _this$props$onChange.call(_this$props, data);
|
|
1382
|
+
if ('valueType' in changed) _this.forceUpdate();
|
|
1383
|
+
});
|
|
1384
|
+
|
|
1385
|
+
return _this;
|
|
1386
|
+
}
|
|
1387
|
+
|
|
1388
|
+
_createClass(ParamForm, [{
|
|
1389
|
+
key: "render",
|
|
1390
|
+
value: function render() {
|
|
1391
|
+
var _this2 = this;
|
|
1392
|
+
|
|
1393
|
+
return /*#__PURE__*/React.createElement(Form, {
|
|
1394
|
+
className: "param-form",
|
|
1395
|
+
ref: this.ref,
|
|
1396
|
+
key: JSON.stringify(this.props.initialValues),
|
|
1397
|
+
initialValues: this.props.initialValues,
|
|
1398
|
+
onFinish: this.props.onSubmit,
|
|
1399
|
+
onValuesChange: this.onChange
|
|
1400
|
+
}, this.formItems.map(function (it) {
|
|
1401
|
+
var _this2$ref$current;
|
|
1402
|
+
|
|
1403
|
+
return /*#__PURE__*/React.createElement(Form.Item, {
|
|
1404
|
+
key: it.name,
|
|
1405
|
+
label: it.label,
|
|
1406
|
+
name: it.name,
|
|
1407
|
+
required: it.required,
|
|
1408
|
+
requiredMark: true,
|
|
1409
|
+
rules: [{
|
|
1410
|
+
validator: it.validator || function () {
|
|
1411
|
+
return Promise.resolve();
|
|
1412
|
+
}
|
|
1413
|
+
}],
|
|
1414
|
+
validateTrigger: 'onBlur'
|
|
1415
|
+
}, /*#__PURE__*/React.createElement(it.Comp, {
|
|
1416
|
+
parentOptions: _this2.props.parentOptions,
|
|
1417
|
+
options: _this2.props.expiriesOptions,
|
|
1418
|
+
valueType: (_this2$ref$current = _this2.ref.current) === null || _this2$ref$current === void 0 ? void 0 : _this2$ref$current.getFieldValue('valueType')
|
|
1419
|
+
}));
|
|
1420
|
+
}), this.props.onSubmit && /*#__PURE__*/React.createElement(Button, {
|
|
1421
|
+
type: "primary",
|
|
1422
|
+
htmlType: "submit"
|
|
1423
|
+
}, "\u63D0\u4EA4"));
|
|
1424
|
+
}
|
|
1425
|
+
}]);
|
|
1426
|
+
|
|
1427
|
+
return ParamForm;
|
|
1428
|
+
}(PureComponent);
|
|
1429
|
+
|
|
1430
|
+
var ParamFormModalEl = /*#__PURE__*/function (_PureComponent2) {
|
|
1431
|
+
_inherits(ParamFormModalEl, _PureComponent2);
|
|
1432
|
+
|
|
1433
|
+
var _super2 = _createSuper(ParamFormModalEl);
|
|
1434
|
+
|
|
1435
|
+
function ParamFormModalEl() {
|
|
1436
|
+
var _this3;
|
|
1437
|
+
|
|
1438
|
+
_classCallCheck(this, ParamFormModalEl);
|
|
1439
|
+
|
|
1440
|
+
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
1441
|
+
args[_key2] = arguments[_key2];
|
|
1442
|
+
}
|
|
1443
|
+
|
|
1444
|
+
_this3 = _super2.call.apply(_super2, [this].concat(args));
|
|
1445
|
+
|
|
1446
|
+
_defineProperty(_assertThisInitialized(_this3), "ref", React.createRef());
|
|
1447
|
+
|
|
1448
|
+
_defineProperty(_assertThisInitialized(_this3), "state", {
|
|
1449
|
+
visible: false
|
|
1450
|
+
});
|
|
1451
|
+
|
|
1452
|
+
_defineProperty(_assertThisInitialized(_this3), "onShow", function () {
|
|
1453
|
+
return _this3.setState({
|
|
1454
|
+
visible: true
|
|
1455
|
+
});
|
|
1456
|
+
});
|
|
1457
|
+
|
|
1458
|
+
_defineProperty(_assertThisInitialized(_this3), "onHide", function () {
|
|
1459
|
+
return _this3.setState({
|
|
1460
|
+
visible: false
|
|
1461
|
+
});
|
|
1462
|
+
});
|
|
1463
|
+
|
|
1464
|
+
_defineProperty(_assertThisInitialized(_this3), "onSubmit", function () {
|
|
1465
|
+
var form = _this3.ref.current.ref.current;
|
|
1466
|
+
return form.validateFields().then(function () {
|
|
1467
|
+
return _this3.props.onSubmit(form.getFieldsValue());
|
|
1468
|
+
}).then(_this3.onHide);
|
|
1469
|
+
});
|
|
1470
|
+
|
|
1471
|
+
return _this3;
|
|
1472
|
+
}
|
|
1473
|
+
|
|
1474
|
+
_createClass(ParamFormModalEl, [{
|
|
1475
|
+
key: "render",
|
|
1476
|
+
value: function render() {
|
|
1477
|
+
var _this$props$initialVa;
|
|
1478
|
+
|
|
1479
|
+
return /*#__PURE__*/React.createElement(Modal, {
|
|
1480
|
+
width: 640,
|
|
1481
|
+
closable: false,
|
|
1482
|
+
title: !((_this$props$initialVa = this.props.initialValues) === null || _this$props$initialVa === void 0 ? void 0 : _this$props$initialVa.paramId) ? '新增参数' : '修改参数',
|
|
1483
|
+
visible: this.state.visible,
|
|
1484
|
+
footer: /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Button, {
|
|
1485
|
+
onClick: this.onHide
|
|
1486
|
+
}, "\u53D6\u6D88"), /*#__PURE__*/React.createElement(Button, {
|
|
1487
|
+
type: "primary",
|
|
1488
|
+
onClick: this.onSubmit
|
|
1489
|
+
}, "\u786E\u8BA4"))
|
|
1490
|
+
}, /*#__PURE__*/React.createElement(ParamForm, Object.assign({}, this.props, {
|
|
1491
|
+
ref: this.ref,
|
|
1492
|
+
onSubmit: undefined
|
|
1493
|
+
})));
|
|
1494
|
+
}
|
|
1495
|
+
}]);
|
|
1496
|
+
|
|
1497
|
+
return ParamFormModalEl;
|
|
1498
|
+
}(PureComponent);
|
|
1499
|
+
|
|
1500
|
+
var ParamFormModal = /*#__PURE__*/function () {
|
|
1501
|
+
function ParamFormModal() {
|
|
1502
|
+
_classCallCheck(this, ParamFormModal);
|
|
1503
|
+
}
|
|
1504
|
+
|
|
1505
|
+
_createClass(ParamFormModal, null, [{
|
|
1506
|
+
key: "show",
|
|
1507
|
+
value: function show(props) {
|
|
1508
|
+
return ParamFormModal.el.render(props).then(function () {
|
|
1509
|
+
ParamFormModal.el.ref.onShow();
|
|
1510
|
+
});
|
|
1511
|
+
}
|
|
1512
|
+
}, {
|
|
1513
|
+
key: "hide",
|
|
1514
|
+
value: function hide() {
|
|
1515
|
+
return ParamFormModal.el.render().then(function () {
|
|
1516
|
+
ParamFormModal.el.ref.onHide();
|
|
1517
|
+
});
|
|
1518
|
+
}
|
|
1519
|
+
}]);
|
|
1520
|
+
|
|
1521
|
+
return ParamFormModal;
|
|
1522
|
+
}();
|
|
1523
|
+
|
|
1524
|
+
_defineProperty(ParamFormModal, "el", new ReactGlobalComp('param-form-modal', ParamFormModalEl));
|
|
1525
|
+
|
|
1526
|
+
var ParamValueEditor = /*#__PURE__*/function (_PureComponent) {
|
|
1527
|
+
_inherits(ParamValueEditor, _PureComponent);
|
|
1528
|
+
|
|
1529
|
+
var _super = _createSuper(ParamValueEditor);
|
|
1530
|
+
|
|
1531
|
+
function ParamValueEditor() {
|
|
1532
|
+
var _this;
|
|
1533
|
+
|
|
1534
|
+
_classCallCheck(this, ParamValueEditor);
|
|
1535
|
+
|
|
1536
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
1537
|
+
args[_key] = arguments[_key];
|
|
1538
|
+
}
|
|
1539
|
+
|
|
1540
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
1541
|
+
|
|
1542
|
+
_defineProperty(_assertThisInitialized(_this), "ref", React.createRef());
|
|
1543
|
+
|
|
1544
|
+
_defineProperty(_assertThisInitialized(_this), "formItems", [{
|
|
1545
|
+
label: 'Parameter',
|
|
1546
|
+
name: 'paramId',
|
|
1547
|
+
Comp: function Comp(props) {
|
|
1548
|
+
return /*#__PURE__*/React.createElement(ParentSelector, Object.assign({}, props, {
|
|
1549
|
+
readonly: true
|
|
1550
|
+
}));
|
|
1551
|
+
}
|
|
1552
|
+
}, {
|
|
1553
|
+
label: 'Description',
|
|
1554
|
+
name: 'description',
|
|
1555
|
+
Comp: function Comp(props) {
|
|
1556
|
+
return /*#__PURE__*/React.createElement("span", {
|
|
1557
|
+
className: "param-value-editor-desc",
|
|
1558
|
+
style: {
|
|
1559
|
+
lineHeight: '20px',
|
|
1560
|
+
padding: '10px 0'
|
|
1561
|
+
}
|
|
1562
|
+
}, props.value || '-');
|
|
1563
|
+
}
|
|
1564
|
+
}, {
|
|
1565
|
+
label: 'Value before',
|
|
1566
|
+
name: 'valueBefore',
|
|
1567
|
+
Comp: function Comp(props) {
|
|
1568
|
+
return /*#__PURE__*/React.createElement(ParamRenderer, Object.assign({}, props, {
|
|
1569
|
+
readonly: true
|
|
1570
|
+
}));
|
|
1571
|
+
}
|
|
1572
|
+
}, {
|
|
1573
|
+
label: 'Value after',
|
|
1574
|
+
name: 'value',
|
|
1575
|
+
Comp: ParamRenderer,
|
|
1576
|
+
required: true,
|
|
1577
|
+
validator: validatorCvt(function (val) {
|
|
1578
|
+
return paramValidator(val, {
|
|
1579
|
+
valueType: _this.props.valueType
|
|
1580
|
+
});
|
|
1581
|
+
})
|
|
1582
|
+
}]);
|
|
1583
|
+
|
|
1584
|
+
_defineProperty(_assertThisInitialized(_this), "onChange", function (changed, data) {
|
|
1585
|
+
var _this$props$onChange, _this$props;
|
|
1586
|
+
|
|
1587
|
+
(_this$props$onChange = (_this$props = _this.props).onChange) === null || _this$props$onChange === void 0 ? void 0 : _this$props$onChange.call(_this$props, data);
|
|
1588
|
+
});
|
|
1589
|
+
|
|
1590
|
+
return _this;
|
|
1591
|
+
}
|
|
1592
|
+
|
|
1593
|
+
_createClass(ParamValueEditor, [{
|
|
1594
|
+
key: "render",
|
|
1595
|
+
value: function render() {
|
|
1596
|
+
var _this2 = this;
|
|
1597
|
+
|
|
1598
|
+
return /*#__PURE__*/React.createElement(Form, {
|
|
1599
|
+
className: "param-value-editor",
|
|
1600
|
+
ref: this.ref,
|
|
1601
|
+
key: this.props.valueType,
|
|
1602
|
+
initialValues: this.props.initialValues,
|
|
1603
|
+
onFinish: this.props.onSubmit,
|
|
1604
|
+
onValuesChange: this.onChange
|
|
1605
|
+
}, this.formItems.map(function (it) {
|
|
1606
|
+
return /*#__PURE__*/React.createElement(Form.Item, {
|
|
1607
|
+
key: it.name,
|
|
1608
|
+
label: it.label,
|
|
1609
|
+
name: it.name,
|
|
1610
|
+
required: it.required,
|
|
1611
|
+
requiredMark: true,
|
|
1612
|
+
rules: [{
|
|
1613
|
+
validator: it.validator || function () {
|
|
1614
|
+
return Promise.resolve();
|
|
1615
|
+
}
|
|
1616
|
+
}],
|
|
1617
|
+
validateTrigger: 'onBlur'
|
|
1618
|
+
}, /*#__PURE__*/React.createElement(it.Comp, {
|
|
1619
|
+
parentOptions: _this2.props.allParams,
|
|
1620
|
+
valueType: _this2.props.valueType
|
|
1621
|
+
}));
|
|
1622
|
+
}), this.props.onSubmit && /*#__PURE__*/React.createElement(Button, {
|
|
1623
|
+
type: "primary",
|
|
1624
|
+
htmlType: "submit"
|
|
1625
|
+
}, "\u63D0\u4EA4"));
|
|
1626
|
+
}
|
|
1627
|
+
}]);
|
|
1628
|
+
|
|
1629
|
+
return ParamValueEditor;
|
|
1630
|
+
}(PureComponent);
|
|
1631
|
+
var ParamValueEditorModalEl = /*#__PURE__*/function (_PureComponent2) {
|
|
1632
|
+
_inherits(ParamValueEditorModalEl, _PureComponent2);
|
|
1633
|
+
|
|
1634
|
+
var _super2 = _createSuper(ParamValueEditorModalEl);
|
|
1635
|
+
|
|
1636
|
+
function ParamValueEditorModalEl() {
|
|
1637
|
+
var _this3;
|
|
1638
|
+
|
|
1639
|
+
_classCallCheck(this, ParamValueEditorModalEl);
|
|
1640
|
+
|
|
1641
|
+
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
1642
|
+
args[_key2] = arguments[_key2];
|
|
1643
|
+
}
|
|
1644
|
+
|
|
1645
|
+
_this3 = _super2.call.apply(_super2, [this].concat(args));
|
|
1646
|
+
|
|
1647
|
+
_defineProperty(_assertThisInitialized(_this3), "ref", React.createRef());
|
|
1648
|
+
|
|
1649
|
+
_defineProperty(_assertThisInitialized(_this3), "state", {
|
|
1650
|
+
visible: false
|
|
1651
|
+
});
|
|
1652
|
+
|
|
1653
|
+
_defineProperty(_assertThisInitialized(_this3), "onShow", function () {
|
|
1654
|
+
return _this3.setState({
|
|
1655
|
+
visible: true
|
|
1656
|
+
});
|
|
1657
|
+
});
|
|
1658
|
+
|
|
1659
|
+
_defineProperty(_assertThisInitialized(_this3), "onHide", function () {
|
|
1660
|
+
return _this3.setState({
|
|
1661
|
+
visible: false
|
|
1662
|
+
});
|
|
1663
|
+
});
|
|
1664
|
+
|
|
1665
|
+
_defineProperty(_assertThisInitialized(_this3), "onSubmit", function () {
|
|
1666
|
+
var form = _this3.ref.current.ref.current;
|
|
1667
|
+
return form.validateFields().then(function () {
|
|
1668
|
+
return _this3.props.onSubmit(form.getFieldsValue());
|
|
1669
|
+
}).then(_this3.onHide);
|
|
1670
|
+
});
|
|
1671
|
+
|
|
1672
|
+
return _this3;
|
|
1673
|
+
}
|
|
1674
|
+
|
|
1675
|
+
_createClass(ParamValueEditorModalEl, [{
|
|
1676
|
+
key: "render",
|
|
1677
|
+
value: function render() {
|
|
1678
|
+
return /*#__PURE__*/React.createElement(Modal, {
|
|
1679
|
+
width: 640,
|
|
1680
|
+
title: 'Edit Value',
|
|
1681
|
+
closable: false,
|
|
1682
|
+
visible: this.state.visible,
|
|
1683
|
+
footer: /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Button, {
|
|
1684
|
+
onClick: this.onHide
|
|
1685
|
+
}, "Cancel"), /*#__PURE__*/React.createElement(Button, {
|
|
1686
|
+
type: "primary",
|
|
1687
|
+
onClick: this.onSubmit
|
|
1688
|
+
}, "Submit"))
|
|
1689
|
+
}, /*#__PURE__*/React.createElement(ParamValueEditor, Object.assign({}, this.props, {
|
|
1690
|
+
ref: this.ref,
|
|
1691
|
+
onSubmit: undefined
|
|
1692
|
+
})));
|
|
1693
|
+
}
|
|
1694
|
+
}]);
|
|
1695
|
+
|
|
1696
|
+
return ParamValueEditorModalEl;
|
|
1697
|
+
}(PureComponent);
|
|
1698
|
+
var ParamValueEditorModal = /*#__PURE__*/function () {
|
|
1699
|
+
function ParamValueEditorModal() {
|
|
1700
|
+
_classCallCheck(this, ParamValueEditorModal);
|
|
1701
|
+
}
|
|
1702
|
+
|
|
1703
|
+
_createClass(ParamValueEditorModal, null, [{
|
|
1704
|
+
key: "show",
|
|
1705
|
+
value: function show(props) {
|
|
1706
|
+
return ParamValueEditorModal.el.render(props).then(function () {
|
|
1707
|
+
ParamValueEditorModal.el.ref.onShow();
|
|
1708
|
+
});
|
|
1709
|
+
}
|
|
1710
|
+
}, {
|
|
1711
|
+
key: "hide",
|
|
1712
|
+
value: function hide() {
|
|
1713
|
+
return ParamValueEditorModal.el.render().then(function () {
|
|
1714
|
+
ParamValueEditorModal.el.ref.onHide();
|
|
1715
|
+
});
|
|
1716
|
+
}
|
|
1717
|
+
}]);
|
|
1718
|
+
|
|
1719
|
+
return ParamValueEditorModal;
|
|
1720
|
+
}();
|
|
1721
|
+
|
|
1722
|
+
_defineProperty(ParamValueEditorModal, "el", new ReactGlobalComp('param-value-editor-modal', ParamValueEditorModalEl));
|
|
1723
|
+
|
|
1724
|
+
export { ParamForm, ParamFormModal, ParamRenderer, ParamType, ParamTypeConfig, ParamTypeOptions, ParamValueEditor, ParamValueEditorModal, ParamValueEditorModalEl, emptyValidator, expiriesValidator, expiryValidator, formatNum, isExpired, isNullLike, keyValidator, numRangeValidator, paramValidator, validatorCvt };
|