@signalplus/params-about 0.1.3 → 0.1.6

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/lib/es/index.js CHANGED
@@ -1,18 +1,21 @@
1
1
  /**
2
2
  * Bundle of @signalplus/params-about
3
- * Generated: 2022-04-07
4
- * Version: 0.1.3
3
+ * Generated: 2022-04-08
4
+ * Version: 0.1.6
5
5
  * License: MIT
6
6
  * Author: 2631541504@qq.com
7
7
  */
8
8
 
9
- import React, { PureComponent, useMemo } from 'react';
9
+ import React, { PureComponent, useMemo, useState, useEffect } from 'react';
10
10
  import classNames from 'classnames';
11
11
  import dayjs from 'dayjs';
12
12
  import Big from 'big.js';
13
13
  import { PlusOutlined, DeleteOutlined, CloseOutlined, CheckOutlined, DownOutlined } from '@ant-design/icons';
14
- import { Popover, Cascader, Input, Select, Form, Button, Modal } from 'antd';
14
+ import { Popover, Cascader, Input, Select, Form, Button, message, Modal } from 'antd';
15
15
  import ReactGlobalComp from 'react-global-comp';
16
+ import { isEqual } from 'lodash-es';
17
+ import ReactFileInput from '@livelybone/react-file-input';
18
+ import { useRequest } from 'ahooks';
16
19
 
17
20
  function _defineProperty(obj, key, value) {
18
21
  if (key in obj) {
@@ -563,7 +566,7 @@ var NumCvt = /*#__PURE__*/function () {
563
566
  return NumCvt;
564
567
  }();
565
568
 
566
- function initState(props) {
569
+ function initState$1(props) {
567
570
  return {
568
571
  preProps: props,
569
572
  tempValue: NumCvt.show(props.value, props.isPercentage)
@@ -586,7 +589,7 @@ var Num = /*#__PURE__*/function (_PureComponent) {
586
589
 
587
590
  _this = _super.call.apply(_super, [this].concat(args));
588
591
 
589
- _defineProperty(_assertThisInitialized(_this), "state", initState(_this.props));
592
+ _defineProperty(_assertThisInitialized(_this), "state", initState$1(_this.props));
590
593
 
591
594
  _defineProperty(_assertThisInitialized(_this), "onChange", function (e) {
592
595
  var $value = e.target.value;
@@ -754,7 +757,7 @@ var TextArray = /*#__PURE__*/function (_PureComponent) {
754
757
  var value = _toConsumableArray(_this.value);
755
758
 
756
759
  value[i] = val;
757
- (_this$props$onChange = (_this$props = _this.props).onChange) === null || _this$props$onChange === void 0 ? void 0 : _this$props$onChange.call(_this$props, value);
760
+ (_this$props$onChange = (_this$props = _this.props).onChange) === null || _this$props$onChange === void 0 ? void 0 : _this$props$onChange.call(_this$props, value.length === 1 && !value[0] ? undefined : value);
758
761
  });
759
762
 
760
763
  _defineProperty(_assertThisInitialized(_this), "onAdd", function (i) {
@@ -772,7 +775,7 @@ var TextArray = /*#__PURE__*/function (_PureComponent) {
772
775
  var value = _toConsumableArray(_this.value);
773
776
 
774
777
  value.splice(i, 1);
775
- (_this$props$onChange3 = (_this$props3 = _this.props).onChange) === null || _this$props$onChange3 === void 0 ? void 0 : _this$props$onChange3.call(_this$props3, value);
778
+ (_this$props$onChange3 = (_this$props3 = _this.props).onChange) === null || _this$props$onChange3 === void 0 ? void 0 : _this$props$onChange3.call(_this$props3, value.length ? value : undefined);
776
779
  });
777
780
 
778
781
  return _this;
@@ -977,7 +980,7 @@ var ExpiriesLimit = /*#__PURE__*/function (_PureComponent) {
977
980
  expiry: ''
978
981
  };
979
982
  if (key) value[i][key] = val;else value[i] = _objectSpread2(_objectSpread2({}, value[i]), val);
980
- (_this$props$onChange = (_this$props = _this.props).onChange) === null || _this$props$onChange === void 0 ? void 0 : _this$props$onChange.call(_this$props, value);
983
+ (_this$props$onChange = (_this$props = _this.props).onChange) === null || _this$props$onChange === void 0 ? void 0 : _this$props$onChange.call(_this$props, value.length === 1 && !value[0].expiry && !value[0].minAumPercentage && !value[0].maxAumPercentage && !value[0].minAbs && !value[0].maxAbs ? undefined : value);
981
984
  });
982
985
 
983
986
  _defineProperty(_assertThisInitialized(_this), "onAdd", function (i) {
@@ -998,7 +1001,7 @@ var ExpiriesLimit = /*#__PURE__*/function (_PureComponent) {
998
1001
  var value = _toConsumableArray(_this.value);
999
1002
 
1000
1003
  value.splice(i, 1);
1001
- (_this$props$onChange3 = (_this$props4 = _this.props).onChange) === null || _this$props$onChange3 === void 0 ? void 0 : _this$props$onChange3.call(_this$props4, value);
1004
+ (_this$props$onChange3 = (_this$props4 = _this.props).onChange) === null || _this$props$onChange3 === void 0 ? void 0 : _this$props$onChange3.call(_this$props4, value.length ? value : undefined);
1002
1005
  (_this$props$onBlur2 = (_this$props5 = _this.props).onBlur) === null || _this$props$onBlur2 === void 0 ? void 0 : _this$props$onBlur2.call(_this$props5);
1003
1006
  });
1004
1007
 
@@ -1249,6 +1252,7 @@ var ParamRenderer = /*#__PURE__*/function (_PureComponent) {
1249
1252
  value: function render() {
1250
1253
  var Comp = this.typeConfig.Comp;
1251
1254
  return /*#__PURE__*/React.createElement(Comp, Object.assign({}, this.props, {
1255
+ options: this.props.expiriesOptions,
1252
1256
  value: this.value,
1253
1257
  onChange: this.onChange,
1254
1258
  className: classNames('param-renderer', this.props.className)
@@ -1260,11 +1264,23 @@ var ParamRenderer = /*#__PURE__*/function (_PureComponent) {
1260
1264
  }(PureComponent);
1261
1265
 
1262
1266
  function ParentSelector(props) {
1263
- var value = useMemo(function () {
1267
+ var _useMemo = useMemo(function () {
1264
1268
  var _props$parentOptions;
1265
1269
 
1266
1270
  var $value = [];
1267
1271
 
1272
+ var cvt = function cvt(it) {
1273
+ var _it$children;
1274
+
1275
+ return _objectSpread2(_objectSpread2({}, it), {}, {
1276
+ label: it.name,
1277
+ value: String(it.$paramId),
1278
+ children: (_it$children = it.children) === null || _it$children === void 0 ? void 0 : _it$children.map(cvt)
1279
+ });
1280
+ };
1281
+
1282
+ var $options = ((_props$parentOptions = props.parentOptions) === null || _props$parentOptions === void 0 ? void 0 : _props$parentOptions.map(cvt)) || [];
1283
+
1268
1284
  var find = function find(item) {
1269
1285
  var _item$children;
1270
1286
 
@@ -1277,16 +1293,26 @@ function ParentSelector(props) {
1277
1293
  }));
1278
1294
  };
1279
1295
 
1280
- var matched = props.value && ((_props$parentOptions = props.parentOptions) === null || _props$parentOptions === void 0 ? void 0 : _props$parentOptions.some(function (it) {
1296
+ var matched = props.value && $options.some(function (it) {
1281
1297
  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, {
1298
+ });
1299
+ if (!matched) return {
1300
+ value: [],
1301
+ options: $options
1302
+ };
1303
+ return {
1304
+ value: $value,
1305
+ options: $options
1306
+ };
1307
+ }, [props.parentOptions, props.value]),
1308
+ value = _useMemo.value,
1309
+ options = _useMemo.options;
1310
+
1311
+ return /*#__PURE__*/React.createElement(Cascader, {
1312
+ style: props.style,
1287
1313
  disabled: props.readonly,
1288
1314
  placeholder: '请选择',
1289
- options: props.parentOptions,
1315
+ options: options,
1290
1316
  className: classNames('param-parent-selector', {
1291
1317
  readonly: props.readonly
1292
1318
  }, props.className),
@@ -1296,7 +1322,7 @@ function ParentSelector(props) {
1296
1322
 
1297
1323
  return (_props$onChange = props.onChange) === null || _props$onChange === void 0 ? void 0 : _props$onChange.call(props, val.pop());
1298
1324
  }
1299
- }));
1325
+ });
1300
1326
  }
1301
1327
 
1302
1328
  var ParamForm = /*#__PURE__*/function (_PureComponent) {
@@ -1317,68 +1343,6 @@ var ParamForm = /*#__PURE__*/function (_PureComponent) {
1317
1343
 
1318
1344
  _defineProperty(_assertThisInitialized(_this), "ref", React.createRef());
1319
1345
 
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
1346
  _defineProperty(_assertThisInitialized(_this), "onChange", function (changed, data) {
1383
1347
  var _this$props$onChange, _this$props;
1384
1348
 
@@ -1390,10 +1354,84 @@ var ParamForm = /*#__PURE__*/function (_PureComponent) {
1390
1354
  }
1391
1355
 
1392
1356
  _createClass(ParamForm, [{
1393
- key: "render",
1394
- value: function render() {
1357
+ key: "formItems",
1358
+ get: function get() {
1395
1359
  var _this2 = this;
1396
1360
 
1361
+ return [{
1362
+ label: '所属分组',
1363
+ name: 'parentId',
1364
+ Comp: function Comp(props) {
1365
+ return /*#__PURE__*/React.createElement(ParentSelector, Object.assign({}, props, {
1366
+ parentOptions: _this2.props.parentOptions
1367
+ }));
1368
+ },
1369
+ required: true,
1370
+ validator: validatorCvt(function (val) {
1371
+ return emptyValidator(val);
1372
+ })
1373
+ }, {
1374
+ label: '参数 Key',
1375
+ name: 'key',
1376
+ Comp: function Comp(props) {
1377
+ return /*#__PURE__*/React.createElement(Input, Object.assign({
1378
+ placeholder: '请输入'
1379
+ }, props));
1380
+ },
1381
+ required: true,
1382
+ validator: validatorCvt(keyValidator)
1383
+ }, {
1384
+ label: '参数名称',
1385
+ name: 'name',
1386
+ Comp: function Comp(props) {
1387
+ return /*#__PURE__*/React.createElement(Input, Object.assign({
1388
+ placeholder: '请输入'
1389
+ }, props));
1390
+ }
1391
+ }, {
1392
+ label: '参数类型',
1393
+ name: 'valueType',
1394
+ Comp: function Comp(props) {
1395
+ return /*#__PURE__*/React.createElement(Select, Object.assign({
1396
+ placeholder: '请选择'
1397
+ }, props), ParamTypeOptions.map(function (it) {
1398
+ return /*#__PURE__*/React.createElement(Select.Option, {
1399
+ key: it.value,
1400
+ value: it.value
1401
+ }, it.label);
1402
+ }));
1403
+ },
1404
+ required: true,
1405
+ validator: validatorCvt(function (val) {
1406
+ return emptyValidator(val);
1407
+ })
1408
+ }, {
1409
+ label: '默认值',
1410
+ name: 'defaultValue',
1411
+ Comp: function Comp(props) {
1412
+ var _this2$ref$current;
1413
+
1414
+ return /*#__PURE__*/React.createElement(ParamRenderer, Object.assign({}, props, {
1415
+ expiriesOptions: _this2.props.expiriesOptions,
1416
+ valueType: (_this2$ref$current = _this2.ref.current) === null || _this2$ref$current === void 0 ? void 0 : _this2$ref$current.getFieldValue('valueType')
1417
+ }));
1418
+ },
1419
+ validator: validatorCvt(paramValidator, function () {
1420
+ return _this2.ref.current;
1421
+ })
1422
+ }, {
1423
+ label: '参数说明',
1424
+ name: 'description',
1425
+ Comp: function Comp(props) {
1426
+ return /*#__PURE__*/React.createElement(Input.TextArea, Object.assign({
1427
+ placeholder: '请输入'
1428
+ }, props));
1429
+ }
1430
+ }];
1431
+ }
1432
+ }, {
1433
+ key: "render",
1434
+ value: function render() {
1397
1435
  return /*#__PURE__*/React.createElement(Form, {
1398
1436
  className: "param-form",
1399
1437
  ref: this.ref,
@@ -1402,8 +1440,6 @@ var ParamForm = /*#__PURE__*/function (_PureComponent) {
1402
1440
  onFinish: this.props.onSubmit,
1403
1441
  onValuesChange: this.onChange
1404
1442
  }, this.formItems.map(function (it) {
1405
- var _this2$ref$current;
1406
-
1407
1443
  return /*#__PURE__*/React.createElement(Form.Item, {
1408
1444
  key: it.name,
1409
1445
  label: it.label,
@@ -1416,11 +1452,7 @@ var ParamForm = /*#__PURE__*/function (_PureComponent) {
1416
1452
  }
1417
1453
  }],
1418
1454
  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
- }));
1455
+ }, /*#__PURE__*/React.createElement(it.Comp, null));
1424
1456
  }), this.props.onSubmit && /*#__PURE__*/React.createElement(Button, {
1425
1457
  type: "primary",
1426
1458
  htmlType: "submit"
@@ -1450,7 +1482,8 @@ var ParamFormModalEl = /*#__PURE__*/function (_PureComponent2) {
1450
1482
  _defineProperty(_assertThisInitialized(_this3), "ref", React.createRef());
1451
1483
 
1452
1484
  _defineProperty(_assertThisInitialized(_this3), "state", {
1453
- visible: false
1485
+ visible: false,
1486
+ pending: false
1454
1487
  });
1455
1488
 
1456
1489
  _defineProperty(_assertThisInitialized(_this3), "onShow", function () {
@@ -1468,29 +1501,50 @@ var ParamFormModalEl = /*#__PURE__*/function (_PureComponent2) {
1468
1501
  _defineProperty(_assertThisInitialized(_this3), "onSubmit", function () {
1469
1502
  var form = _this3.ref.current.ref.current;
1470
1503
  return form.validateFields().then(function () {
1471
- return _this3.props.onSubmit(form.getFieldsValue());
1472
- }).then(_this3.onHide);
1504
+ return _this3.setState({
1505
+ pending: true
1506
+ });
1507
+ }).then(function () {
1508
+ var data = _objectSpread2(_objectSpread2({}, _this3.props.initialValues), form.getFieldsValue());
1509
+
1510
+ if (_this3.isEdit && isEqual(data, _this3.props.initialValues)) {
1511
+ message.warning('请修改后再提交');
1512
+ return Promise.reject();
1513
+ }
1514
+
1515
+ return _this3.props.onSubmit(data);
1516
+ }).then(_this3.onHide).finally(function () {
1517
+ return _this3.setState({
1518
+ pending: false
1519
+ });
1520
+ });
1473
1521
  });
1474
1522
 
1475
1523
  return _this3;
1476
1524
  }
1477
1525
 
1478
1526
  _createClass(ParamFormModalEl, [{
1479
- key: "render",
1480
- value: function render() {
1527
+ key: "isEdit",
1528
+ get: function get() {
1481
1529
  var _this$props$initialVa;
1482
1530
 
1531
+ return Boolean((_this$props$initialVa = this.props.initialValues) === null || _this$props$initialVa === void 0 ? void 0 : _this$props$initialVa.paramId);
1532
+ }
1533
+ }, {
1534
+ key: "render",
1535
+ value: function render() {
1483
1536
  return /*#__PURE__*/React.createElement(Modal, {
1484
1537
  key: String(this.state.visible),
1485
1538
  width: 640,
1486
1539
  closable: false,
1487
- title: !((_this$props$initialVa = this.props.initialValues) === null || _this$props$initialVa === void 0 ? void 0 : _this$props$initialVa.paramId) ? '新增参数' : '修改参数',
1540
+ title: !this.isEdit ? '新增参数' : '修改参数',
1488
1541
  visible: this.state.visible,
1489
1542
  footer: /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Button, {
1490
1543
  onClick: this.onHide
1491
1544
  }, "\u53D6\u6D88"), /*#__PURE__*/React.createElement(Button, {
1492
1545
  type: "primary",
1493
- onClick: this.onSubmit
1546
+ onClick: this.onSubmit,
1547
+ loading: this.state.pending
1494
1548
  }, "\u786E\u8BA4"))
1495
1549
  }, /*#__PURE__*/React.createElement(ParamForm, Object.assign({}, this.props, {
1496
1550
  ref: this.ref,
@@ -1546,46 +1600,6 @@ var ParamValueEditor = /*#__PURE__*/function (_PureComponent) {
1546
1600
 
1547
1601
  _defineProperty(_assertThisInitialized(_this), "ref", React.createRef());
1548
1602
 
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
1603
  _defineProperty(_assertThisInitialized(_this), "onChange", function (changed, data) {
1590
1604
  var _this$props$onChange, _this$props;
1591
1605
 
@@ -1596,15 +1610,59 @@ var ParamValueEditor = /*#__PURE__*/function (_PureComponent) {
1596
1610
  }
1597
1611
 
1598
1612
  _createClass(ParamValueEditor, [{
1599
- key: "componentDidMount",
1600
- value: function componentDidMount() {
1601
- console.log(1111, 'mounted');
1613
+ key: "formItems",
1614
+ get: function get() {
1615
+ var _this2 = this;
1616
+
1617
+ return [{
1618
+ label: 'Parameter',
1619
+ name: 'paramId',
1620
+ Comp: function Comp(props) {
1621
+ return /*#__PURE__*/React.createElement(ParentSelector, Object.assign({}, props, {
1622
+ readonly: true
1623
+ }));
1624
+ }
1625
+ }, {
1626
+ label: 'Description',
1627
+ name: 'description',
1628
+ Comp: function Comp(props) {
1629
+ return /*#__PURE__*/React.createElement("span", {
1630
+ className: "param-value-editor-desc",
1631
+ style: {
1632
+ lineHeight: '20px',
1633
+ padding: '10px 0'
1634
+ }
1635
+ }, props.value || '-');
1636
+ }
1637
+ }, {
1638
+ label: 'Value before',
1639
+ name: 'valueBefore',
1640
+ Comp: function Comp(props) {
1641
+ return /*#__PURE__*/React.createElement(ParamRenderer, Object.assign({}, props, {
1642
+ readonly: true,
1643
+ parentOptions: _this2.props.allParams
1644
+ }));
1645
+ }
1646
+ }, {
1647
+ label: 'Value after',
1648
+ name: 'value',
1649
+ Comp: function Comp(props) {
1650
+ return /*#__PURE__*/React.createElement(ParamRenderer, Object.assign({}, props, {
1651
+ expiriesOptions: _this2.props.expiriesOptions,
1652
+ valueType: _this2.props.valueType
1653
+ }));
1654
+ },
1655
+ required: true,
1656
+ validator: validatorCvt(function (val) {
1657
+ return paramValidator(val, {
1658
+ valueType: _this2.props.valueType
1659
+ });
1660
+ })
1661
+ }];
1602
1662
  }
1603
1663
  }, {
1604
1664
  key: "render",
1605
1665
  value: function render() {
1606
- var _this2 = this;
1607
-
1608
1666
  return /*#__PURE__*/React.createElement(Form, {
1609
1667
  className: "param-value-editor",
1610
1668
  ref: this.ref,
@@ -1625,10 +1683,7 @@ var ParamValueEditor = /*#__PURE__*/function (_PureComponent) {
1625
1683
  }
1626
1684
  }],
1627
1685
  validateTrigger: 'onBlur'
1628
- }, /*#__PURE__*/React.createElement(it.Comp, {
1629
- parentOptions: _this2.props.allParams,
1630
- valueType: _this2.props.valueType
1631
- }));
1686
+ }, /*#__PURE__*/React.createElement(it.Comp, null));
1632
1687
  }), this.props.onSubmit && /*#__PURE__*/React.createElement(Button, {
1633
1688
  type: "primary",
1634
1689
  htmlType: "submit"
@@ -1657,7 +1712,8 @@ var ParamValueEditorModalEl = /*#__PURE__*/function (_PureComponent2) {
1657
1712
  _defineProperty(_assertThisInitialized(_this3), "ref", React.createRef());
1658
1713
 
1659
1714
  _defineProperty(_assertThisInitialized(_this3), "state", {
1660
- visible: false
1715
+ visible: false,
1716
+ pending: false
1661
1717
  });
1662
1718
 
1663
1719
  _defineProperty(_assertThisInitialized(_this3), "onShow", function () {
@@ -1675,8 +1731,23 @@ var ParamValueEditorModalEl = /*#__PURE__*/function (_PureComponent2) {
1675
1731
  _defineProperty(_assertThisInitialized(_this3), "onSubmit", function () {
1676
1732
  var form = _this3.ref.current.ref.current;
1677
1733
  return form.validateFields().then(function () {
1678
- return _this3.props.onSubmit(form.getFieldsValue());
1679
- }).then(_this3.onHide);
1734
+ return _this3.setState({
1735
+ pending: true
1736
+ });
1737
+ }).then(function () {
1738
+ var data = _objectSpread2(_objectSpread2({}, _this3.props.initialValues), form.getFieldsValue());
1739
+
1740
+ if (isEqual(data, _this3.props.initialValues)) {
1741
+ message.warning('请修改后再提交');
1742
+ return Promise.reject();
1743
+ }
1744
+
1745
+ return _this3.props.onSubmit(data);
1746
+ }).then(_this3.onHide).finally(function () {
1747
+ return _this3.setState({
1748
+ pending: false
1749
+ });
1750
+ });
1680
1751
  });
1681
1752
 
1682
1753
  return _this3;
@@ -1695,7 +1766,8 @@ var ParamValueEditorModalEl = /*#__PURE__*/function (_PureComponent2) {
1695
1766
  onClick: this.onHide
1696
1767
  }, "Cancel"), /*#__PURE__*/React.createElement(Button, {
1697
1768
  type: "primary",
1698
- onClick: this.onSubmit
1769
+ onClick: this.onSubmit,
1770
+ loading: this.state.pending
1699
1771
  }, "Submit"))
1700
1772
  }, /*#__PURE__*/React.createElement(ParamValueEditor, Object.assign({}, this.props, {
1701
1773
  ref: this.ref,
@@ -1732,4 +1804,540 @@ var ParamValueEditorModal = /*#__PURE__*/function () {
1732
1804
 
1733
1805
  _defineProperty(ParamValueEditorModal, "el", new ReactGlobalComp('param-value-editor-modal', ParamValueEditorModalEl));
1734
1806
 
1735
- export { ParamForm, ParamFormModal, ParamRenderer, ParamType, ParamTypeConfig, ParamTypeOptions, ParamValueEditor, ParamValueEditorModal, ParamValueEditorModalEl, emptyValidator, expiriesValidator, expiryValidator, formatNum, isExpired, isNullLike, keyValidator, numRangeValidator, paramValidator, validatorCvt };
1807
+ var ImageUpload = function ImageUpload(props) {
1808
+ var _useRequest = useRequest(function () {
1809
+ var _props$getSignedUrl;
1810
+
1811
+ return Promise.resolve(props.value && ((_props$getSignedUrl = props.getSignedUrl) === null || _props$getSignedUrl === void 0 ? void 0 : _props$getSignedUrl.call(props, props.value)));
1812
+ }, {
1813
+ refreshDeps: [props.value]
1814
+ }),
1815
+ url = _useRequest.data;
1816
+
1817
+ var _useState = useState(function () {
1818
+ return url ? [{
1819
+ url: url
1820
+ }] : [];
1821
+ }),
1822
+ _useState2 = _slicedToArray(_useState, 2),
1823
+ files = _useState2[0],
1824
+ setFiles = _useState2[1];
1825
+
1826
+ useEffect(function () {
1827
+ return setFiles(url ? [{
1828
+ url: url
1829
+ }] : []);
1830
+ }, [url]);
1831
+
1832
+ var _useRequest2 = useRequest(function ($files) {
1833
+ var _$files$, _props$handleUpload, _props$onChange2;
1834
+
1835
+ setFiles($files);
1836
+ var file = (_$files$ = $files[0]) === null || _$files$ === void 0 ? void 0 : _$files$.file;
1837
+ if (file) return (_props$handleUpload = props.handleUpload) === null || _props$handleUpload === void 0 ? void 0 : _props$handleUpload.call(props, file).then(function (key) {
1838
+ var _props$onChange;
1839
+
1840
+ return (_props$onChange = props.onChange) === null || _props$onChange === void 0 ? void 0 : _props$onChange.call(props, key);
1841
+ });
1842
+ return Promise.resolve((_props$onChange2 = props.onChange) === null || _props$onChange2 === void 0 ? void 0 : _props$onChange2.call(props, undefined));
1843
+ }, {
1844
+ manual: true
1845
+ }),
1846
+ run = _useRequest2.run,
1847
+ loading = _useRequest2.loading;
1848
+
1849
+ return /*#__PURE__*/React.createElement(ReactFileInput, Object.assign({}, props, {
1850
+ uploading: loading,
1851
+ className: classNames(props.className, 'param-image-upload'),
1852
+ files: files,
1853
+ onChange: run
1854
+ }));
1855
+ };
1856
+
1857
+ var ParamGroupEditor = /*#__PURE__*/function (_PureComponent) {
1858
+ _inherits(ParamGroupEditor, _PureComponent);
1859
+
1860
+ var _super = _createSuper(ParamGroupEditor);
1861
+
1862
+ function ParamGroupEditor() {
1863
+ var _this;
1864
+
1865
+ _classCallCheck(this, ParamGroupEditor);
1866
+
1867
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
1868
+ args[_key] = arguments[_key];
1869
+ }
1870
+
1871
+ _this = _super.call.apply(_super, [this].concat(args));
1872
+
1873
+ _defineProperty(_assertThisInitialized(_this), "ref", React.createRef());
1874
+
1875
+ _defineProperty(_assertThisInitialized(_this), "onChange", function (changed, data) {
1876
+ var _this$props$onChange, _this$props;
1877
+
1878
+ (_this$props$onChange = (_this$props = _this.props).onChange) === null || _this$props$onChange === void 0 ? void 0 : _this$props$onChange.call(_this$props, data);
1879
+ });
1880
+
1881
+ return _this;
1882
+ }
1883
+
1884
+ _createClass(ParamGroupEditor, [{
1885
+ key: "formItems",
1886
+ get: function get() {
1887
+ var _this$props$initialVa,
1888
+ _this2 = this;
1889
+
1890
+ var isFirstLevel = !this.props.allParams && !((_this$props$initialVa = this.props.initialValues) === null || _this$props$initialVa === void 0 ? void 0 : _this$props$initialVa.parentId);
1891
+ var items = [{
1892
+ label: '参数组名称',
1893
+ name: 'name',
1894
+ Comp: function Comp(props) {
1895
+ return /*#__PURE__*/React.createElement(Input, Object.assign({}, props, {
1896
+ placeholder: '请输入'
1897
+ }));
1898
+ },
1899
+ validator: validatorCvt(function (val) {
1900
+ return emptyValidator(val);
1901
+ })
1902
+ }, {
1903
+ label: '业务流程图',
1904
+ name: 'descriptionUrl',
1905
+ Comp: function Comp(props) {
1906
+ return /*#__PURE__*/React.createElement(ImageUpload, Object.assign({}, props, {
1907
+ getSignedUrl: _this2.props.getSignedUrl,
1908
+ handleUpload: _this2.props.handleUpload
1909
+ }));
1910
+ },
1911
+ validator: isFirstLevel ? validatorCvt(function (val) {
1912
+ return emptyValidator(val);
1913
+ }) : undefined
1914
+ }];
1915
+
1916
+ if (!isFirstLevel) {
1917
+ items.unshift({
1918
+ label: '父级参数组',
1919
+ name: 'parentId',
1920
+ Comp: function Comp(props) {
1921
+ return /*#__PURE__*/React.createElement(ParentSelector, Object.assign({}, props, {
1922
+ parentOptions: _this2.props.allParams
1923
+ }));
1924
+ }
1925
+ });
1926
+ }
1927
+
1928
+ return items;
1929
+ }
1930
+ }, {
1931
+ key: "render",
1932
+ value: function render() {
1933
+ return /*#__PURE__*/React.createElement(Form, {
1934
+ className: "param-value-editor",
1935
+ ref: this.ref,
1936
+ initialValues: this.props.initialValues,
1937
+ onFinish: this.props.onSubmit,
1938
+ onValuesChange: this.onChange
1939
+ }, this.formItems.map(function (it) {
1940
+ return /*#__PURE__*/React.createElement(Form.Item, {
1941
+ key: it.name,
1942
+ label: it.label,
1943
+ name: it.name,
1944
+ required: it.required,
1945
+ requiredMark: true,
1946
+ rules: [{
1947
+ validator: it.validator || function () {
1948
+ return Promise.resolve();
1949
+ }
1950
+ }],
1951
+ validateTrigger: 'onBlur'
1952
+ }, /*#__PURE__*/React.createElement(it.Comp, null));
1953
+ }), this.props.onSubmit && /*#__PURE__*/React.createElement(Button, {
1954
+ type: "primary",
1955
+ htmlType: "submit"
1956
+ }, "\u63D0\u4EA4"));
1957
+ }
1958
+ }]);
1959
+
1960
+ return ParamGroupEditor;
1961
+ }(PureComponent);
1962
+ var ParamGroupEditorModalEl = /*#__PURE__*/function (_PureComponent2) {
1963
+ _inherits(ParamGroupEditorModalEl, _PureComponent2);
1964
+
1965
+ var _super2 = _createSuper(ParamGroupEditorModalEl);
1966
+
1967
+ function ParamGroupEditorModalEl() {
1968
+ var _this3;
1969
+
1970
+ _classCallCheck(this, ParamGroupEditorModalEl);
1971
+
1972
+ for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
1973
+ args[_key2] = arguments[_key2];
1974
+ }
1975
+
1976
+ _this3 = _super2.call.apply(_super2, [this].concat(args));
1977
+
1978
+ _defineProperty(_assertThisInitialized(_this3), "ref", React.createRef());
1979
+
1980
+ _defineProperty(_assertThisInitialized(_this3), "state", {
1981
+ visible: false,
1982
+ pending: false
1983
+ });
1984
+
1985
+ _defineProperty(_assertThisInitialized(_this3), "onShow", function () {
1986
+ return _this3.setState({
1987
+ visible: true
1988
+ });
1989
+ });
1990
+
1991
+ _defineProperty(_assertThisInitialized(_this3), "onHide", function () {
1992
+ return _this3.setState({
1993
+ visible: false
1994
+ });
1995
+ });
1996
+
1997
+ _defineProperty(_assertThisInitialized(_this3), "onSubmit", function () {
1998
+ var form = _this3.ref.current.ref.current;
1999
+ return form.validateFields().then(function () {
2000
+ return _this3.setState({
2001
+ pending: true
2002
+ });
2003
+ }).then(function () {
2004
+ var data = _objectSpread2(_objectSpread2({}, _this3.props.initialValues), form.getFieldsValue());
2005
+
2006
+ if (_this3.isEdit && isEqual(data, _this3.props.initialValues)) {
2007
+ message.warning('请修改后再提交');
2008
+ return Promise.reject();
2009
+ }
2010
+
2011
+ return _this3.props.onSubmit(data);
2012
+ }).then(_this3.onHide).finally(function () {
2013
+ return _this3.setState({
2014
+ pending: false
2015
+ });
2016
+ });
2017
+ });
2018
+
2019
+ return _this3;
2020
+ }
2021
+
2022
+ _createClass(ParamGroupEditorModalEl, [{
2023
+ key: "isEdit",
2024
+ get: function get() {
2025
+ var _this$props$initialVa2;
2026
+
2027
+ return Boolean((_this$props$initialVa2 = this.props.initialValues) === null || _this$props$initialVa2 === void 0 ? void 0 : _this$props$initialVa2.paramId);
2028
+ }
2029
+ }, {
2030
+ key: "render",
2031
+ value: function render() {
2032
+ var _this$props$initialVa3;
2033
+
2034
+ return /*#__PURE__*/React.createElement(Modal, {
2035
+ key: String(this.state.visible),
2036
+ width: 640,
2037
+ title: ((_this$props$initialVa3 = this.props.initialValues) === null || _this$props$initialVa3 === void 0 ? void 0 : _this$props$initialVa3.paramId) ? '编辑参数组' : '新增参数组',
2038
+ closable: false,
2039
+ visible: this.state.visible,
2040
+ footer: /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Button, {
2041
+ onClick: this.onHide
2042
+ }, "\u53D6\u6D88"), /*#__PURE__*/React.createElement(Button, {
2043
+ type: "primary",
2044
+ onClick: this.onSubmit,
2045
+ loading: this.state.pending
2046
+ }, "\u786E\u5B9A"))
2047
+ }, /*#__PURE__*/React.createElement(ParamGroupEditor, Object.assign({}, this.props, {
2048
+ ref: this.ref,
2049
+ onSubmit: undefined
2050
+ })));
2051
+ }
2052
+ }]);
2053
+
2054
+ return ParamGroupEditorModalEl;
2055
+ }(PureComponent);
2056
+ var ParamGroupEditorModal = /*#__PURE__*/function () {
2057
+ function ParamGroupEditorModal() {
2058
+ _classCallCheck(this, ParamGroupEditorModal);
2059
+ }
2060
+
2061
+ _createClass(ParamGroupEditorModal, null, [{
2062
+ key: "show",
2063
+ value: function show(props) {
2064
+ return ParamGroupEditorModal.el.render(props).then(function () {
2065
+ ParamGroupEditorModal.el.ref.onShow();
2066
+ });
2067
+ }
2068
+ }, {
2069
+ key: "hide",
2070
+ value: function hide() {
2071
+ return ParamGroupEditorModal.el.render().then(function () {
2072
+ ParamGroupEditorModal.el.ref.onHide();
2073
+ });
2074
+ }
2075
+ }]);
2076
+
2077
+ return ParamGroupEditorModal;
2078
+ }();
2079
+
2080
+ _defineProperty(ParamGroupEditorModal, "el", new ReactGlobalComp('param-group-editor-modal', ParamGroupEditorModalEl));
2081
+
2082
+ function genOptions(props) {
2083
+ var filter = function filter(it) {
2084
+ return it.valueType !== ParamType.ParamGroup;
2085
+ };
2086
+
2087
+ var cvt = function cvt(it) {
2088
+ var _it$children;
2089
+
2090
+ return _objectSpread2(_objectSpread2({}, it), {}, {
2091
+ disabled: props.targetParams.includes(String(it.$paramId)),
2092
+ children: (_it$children = it.children) === null || _it$children === void 0 ? void 0 : _it$children.filter(filter).map(cvt)
2093
+ });
2094
+ };
2095
+
2096
+ return props.allParams.map(cvt) || [];
2097
+ }
2098
+
2099
+ function genParamsMap(props) {
2100
+ var map = {};
2101
+
2102
+ var append = function append(it) {
2103
+ var _it$children2;
2104
+
2105
+ map[it.$paramId] = _objectSpread2(_objectSpread2({}, it), {}, {
2106
+ disabled: props.targetParams.includes(String(it.$paramId))
2107
+ });
2108
+ (_it$children2 = it.children) === null || _it$children2 === void 0 ? void 0 : _it$children2.forEach(append);
2109
+ };
2110
+
2111
+ props.allParams.forEach(append);
2112
+ return map;
2113
+ }
2114
+
2115
+ function initState(props) {
2116
+ return {
2117
+ preProps: props,
2118
+ options: genOptions(props),
2119
+ paramsMap: genParamsMap(props)
2120
+ };
2121
+ }
2122
+
2123
+ var ParamMover = /*#__PURE__*/function (_PureComponent) {
2124
+ _inherits(ParamMover, _PureComponent);
2125
+
2126
+ var _super = _createSuper(ParamMover);
2127
+
2128
+ function ParamMover() {
2129
+ var _this;
2130
+
2131
+ _classCallCheck(this, ParamMover);
2132
+
2133
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
2134
+ args[_key] = arguments[_key];
2135
+ }
2136
+
2137
+ _this = _super.call.apply(_super, [this].concat(args));
2138
+
2139
+ _defineProperty(_assertThisInitialized(_this), "state", initState(_this.props));
2140
+
2141
+ _defineProperty(_assertThisInitialized(_this), "ref", React.createRef());
2142
+
2143
+ return _this;
2144
+ }
2145
+
2146
+ _createClass(ParamMover, [{
2147
+ key: "newParams",
2148
+ get: function get() {
2149
+ var _this2 = this;
2150
+
2151
+ var _getFieldsValue = this.ref.current.getFieldsValue(),
2152
+ parentId = _getFieldsValue.parentId;
2153
+
2154
+ var filter = function filter(it) {
2155
+ return !_this2.props.targetParams.includes(String(it.$paramId));
2156
+ };
2157
+
2158
+ var map = function map(it) {
2159
+ var _it$children3;
2160
+
2161
+ if (it.$paramId === parentId) {
2162
+ return _objectSpread2(_objectSpread2({}, it), {}, {
2163
+ children: (it.children || []).concat(_this2.props.targetParams.map(function ($paramId) {
2164
+ return _objectSpread2(_objectSpread2({}, _this2.state.paramsMap[$paramId]), {}, {
2165
+ parentId: it.$paramId
2166
+ });
2167
+ }))
2168
+ });
2169
+ }
2170
+
2171
+ return _objectSpread2(_objectSpread2({}, it), {}, {
2172
+ children: (_it$children3 = it.children) === null || _it$children3 === void 0 ? void 0 : _it$children3.filter(filter).map(map)
2173
+ });
2174
+ };
2175
+
2176
+ return this.props.allParams.filter(filter).map(map);
2177
+ }
2178
+ }, {
2179
+ key: "formItems",
2180
+ get: function get() {
2181
+ var _this3 = this;
2182
+
2183
+ var items = [{
2184
+ label: '选择分组',
2185
+ name: 'parentId',
2186
+ Comp: function Comp(props) {
2187
+ return /*#__PURE__*/React.createElement(ParentSelector, Object.assign({}, props, {
2188
+ parentOptions: _this3.state.options
2189
+ }));
2190
+ }
2191
+ }];
2192
+ return items;
2193
+ }
2194
+ }, {
2195
+ key: "render",
2196
+ value: function render() {
2197
+ return /*#__PURE__*/React.createElement(Form, {
2198
+ className: "param-value-editor",
2199
+ ref: this.ref,
2200
+ onFinish: this.props.onSubmit
2201
+ }, this.formItems.map(function (it) {
2202
+ return /*#__PURE__*/React.createElement(Form.Item, {
2203
+ key: it.name,
2204
+ label: it.label,
2205
+ name: it.name,
2206
+ required: it.required,
2207
+ requiredMark: true,
2208
+ rules: [{
2209
+ validator: it.validator || function () {
2210
+ return Promise.resolve();
2211
+ }
2212
+ }],
2213
+ validateTrigger: 'onBlur'
2214
+ }, /*#__PURE__*/React.createElement(it.Comp, null));
2215
+ }), this.props.onSubmit && /*#__PURE__*/React.createElement(Button, {
2216
+ type: "primary",
2217
+ htmlType: "submit"
2218
+ }, "\u63D0\u4EA4"));
2219
+ }
2220
+ }], [{
2221
+ key: "getDerivedStateFromProps",
2222
+ value: function getDerivedStateFromProps(props, state) {
2223
+ if (props.allParams !== state.preProps.allParams) {
2224
+ state.paramsMap = genParamsMap(props);
2225
+
2226
+ if (props.targetParams !== state.preProps.targetParams) {
2227
+ state.options = genOptions(props);
2228
+ }
2229
+ }
2230
+
2231
+ return _objectSpread2(_objectSpread2({}, state), {}, {
2232
+ preProps: props
2233
+ });
2234
+ }
2235
+ }]);
2236
+
2237
+ return ParamMover;
2238
+ }(PureComponent);
2239
+ var ParamMoverModalEl = /*#__PURE__*/function (_PureComponent2) {
2240
+ _inherits(ParamMoverModalEl, _PureComponent2);
2241
+
2242
+ var _super2 = _createSuper(ParamMoverModalEl);
2243
+
2244
+ function ParamMoverModalEl() {
2245
+ var _this4;
2246
+
2247
+ _classCallCheck(this, ParamMoverModalEl);
2248
+
2249
+ for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
2250
+ args[_key2] = arguments[_key2];
2251
+ }
2252
+
2253
+ _this4 = _super2.call.apply(_super2, [this].concat(args));
2254
+
2255
+ _defineProperty(_assertThisInitialized(_this4), "ref", React.createRef());
2256
+
2257
+ _defineProperty(_assertThisInitialized(_this4), "state", {
2258
+ visible: false,
2259
+ pending: false
2260
+ });
2261
+
2262
+ _defineProperty(_assertThisInitialized(_this4), "onShow", function () {
2263
+ return _this4.setState({
2264
+ visible: true
2265
+ });
2266
+ });
2267
+
2268
+ _defineProperty(_assertThisInitialized(_this4), "onHide", function () {
2269
+ return _this4.setState({
2270
+ visible: false
2271
+ });
2272
+ });
2273
+
2274
+ _defineProperty(_assertThisInitialized(_this4), "onSubmit", function () {
2275
+ var form = _this4.ref.current.ref.current;
2276
+ return form.validateFields().then(function () {
2277
+ return _this4.setState({
2278
+ pending: true
2279
+ });
2280
+ }).then(function () {
2281
+ return _this4.props.onSubmit(_this4.ref.current.newParams);
2282
+ }).then(_this4.onHide).finally(function () {
2283
+ return _this4.setState({
2284
+ pending: false
2285
+ });
2286
+ });
2287
+ });
2288
+
2289
+ return _this4;
2290
+ }
2291
+
2292
+ _createClass(ParamMoverModalEl, [{
2293
+ key: "render",
2294
+ value: function render() {
2295
+ return /*#__PURE__*/React.createElement(Modal, {
2296
+ key: String(this.state.visible),
2297
+ width: 640,
2298
+ title: '移动参数',
2299
+ closable: false,
2300
+ visible: this.state.visible,
2301
+ footer: /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Button, {
2302
+ onClick: this.onHide
2303
+ }, "\u53D6\u6D88"), /*#__PURE__*/React.createElement(Button, {
2304
+ type: "primary",
2305
+ onClick: this.onSubmit,
2306
+ loading: this.state.pending
2307
+ }, "\u786E\u5B9A"))
2308
+ }, /*#__PURE__*/React.createElement(ParamMover, Object.assign({}, this.props, {
2309
+ ref: this.ref,
2310
+ onSubmit: undefined
2311
+ })));
2312
+ }
2313
+ }]);
2314
+
2315
+ return ParamMoverModalEl;
2316
+ }(PureComponent);
2317
+ var ParamMoverModal = /*#__PURE__*/function () {
2318
+ function ParamMoverModal() {
2319
+ _classCallCheck(this, ParamMoverModal);
2320
+ }
2321
+
2322
+ _createClass(ParamMoverModal, null, [{
2323
+ key: "show",
2324
+ value: function show(props) {
2325
+ return ParamMoverModal.el.render(props).then(function () {
2326
+ ParamMoverModal.el.ref.onShow();
2327
+ });
2328
+ }
2329
+ }, {
2330
+ key: "hide",
2331
+ value: function hide() {
2332
+ return ParamMoverModal.el.render().then(function () {
2333
+ ParamMoverModal.el.ref.onHide();
2334
+ });
2335
+ }
2336
+ }]);
2337
+
2338
+ return ParamMoverModal;
2339
+ }();
2340
+
2341
+ _defineProperty(ParamMoverModal, "el", new ReactGlobalComp('param-mover-modal', ParamMoverModalEl));
2342
+
2343
+ export { ParamForm, ParamFormModal, ParamGroupEditor, ParamGroupEditorModal, ParamGroupEditorModalEl, ParamMover, ParamMoverModal, ParamMoverModalEl, ParamRenderer, ParamType, ParamTypeConfig, ParamTypeOptions, ParamValueEditor, ParamValueEditorModal, ParamValueEditorModalEl, emptyValidator, expiriesValidator, expiryValidator, formatNum, isExpired, isNullLike, keyValidator, numRangeValidator, paramValidator, validatorCvt };