@zgfe/modules-dm 1.0.57-zhongyuan.31 → 1.0.57-zhongyuan.33

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.
@@ -20,6 +20,7 @@ import React, { useContext, useEffect, useState } from 'react';
20
20
  import { BizEventSelector, BizAttributeSelector, BizGlobalDataContext } from '@zgfe/business-lib';
21
21
  import './css/index.less';
22
22
  import request from '../../utils/ajax';
23
+ import { generateUniqueId } from '../../utils/index';
23
24
  import apis from '../../constants/api';
24
25
  var TextArea = Input.TextArea;
25
26
  var AddRule = function AddRule(_ref) {
@@ -61,7 +62,7 @@ var AddRule = function AddRule(_ref) {
61
62
  }, 300);
62
63
  };
63
64
  var onFinish = function onFinish(values) {
64
- console.log('Success:', values);
65
+ console.log('Success:', values, optionsRule);
65
66
  if (currentRuleDetail) {
66
67
  // currentRuleDetail 有值为修改状态
67
68
  request(apis.rule.updateRule, {
@@ -170,25 +171,28 @@ var AddRule = function AddRule(_ref) {
170
171
  if (type === 3) {
171
172
  setOptionsRule([].concat(_toConsumableArray(optionsRule), [{
172
173
  ruleType: type,
173
- content: '(1,1)'
174
+ content: '(1,1)',
175
+ uniqueId: generateUniqueId()
174
176
  }]));
175
177
  return;
176
178
  }
177
179
  if (type === 1) {
178
180
  setOptionsRule([].concat(_toConsumableArray(optionsRule), [{
179
181
  ruleType: type,
180
- content: bizAttributeSelectorValue.type
182
+ content: bizAttributeSelectorValue.type,
183
+ uniqueId: generateUniqueId()
181
184
  }]));
182
185
  return;
183
186
  }
184
187
  setOptionsRule([].concat(_toConsumableArray(optionsRule), [{
185
188
  ruleType: type,
186
- content: undefined
189
+ content: undefined,
190
+ uniqueId: generateUniqueId()
187
191
  }]));
188
192
  };
189
- var handleRuleDel = function handleRuleDel(index) {
193
+ var handleRuleDel = function handleRuleDel(uniqueId) {
190
194
  setOptionsRule(optionsRule.filter(function (o, i) {
191
- return i !== index;
195
+ return o.uniqueId !== uniqueId;
192
196
  }));
193
197
  };
194
198
  // 校验对象的类型 eventProp:事件校验 user:用户校验
@@ -238,12 +242,12 @@ var AddRule = function AddRule(_ref) {
238
242
  value: _value
239
243
  }));
240
244
  // 初始化属性基础类型
241
- var newArr = optionsRule.map(function (o) {
242
- if (o.ruleType == 1) {
243
- o.content = attr.type;
244
- }
245
- });
246
- setOptionsRule(newArr);
245
+ // const newArr = optionsRule.map((o) => {
246
+ // if (o.ruleType == 1) {
247
+ // o.content = attr.type;
248
+ // }
249
+ // });
250
+ // setOptionsRule(newArr);
247
251
  setOptions(attr.type != '3' ? [].concat(initOptions, [{
248
252
  label: '字典校验',
249
253
  value: 6
@@ -386,13 +390,14 @@ var AddRule = function AddRule(_ref) {
386
390
  }, /*#__PURE__*/React.createElement("div", null, (bizAttributeSelectorValue === null || bizAttributeSelectorValue === void 0 ? void 0 : bizAttributeSelectorValue.label) || bizAttributeSelectorValue.name), /*#__PURE__*/React.createElement(TypeComponent, {
387
391
  type: o.ruleType,
388
392
  optionsValue: optionsRule,
393
+ id: o.uniqueId,
389
394
  editStatus: currentRuleDetail ? true : false
390
395
  }), /*#__PURE__*/React.createElement("div", {
391
396
  style: {
392
397
  cursor: 'pointer'
393
398
  },
394
399
  onClick: function onClick() {
395
- return handleRuleDel(index);
400
+ return handleRuleDel(o.uniqueId);
396
401
  }
397
402
  }, "X"));
398
403
  }))), /*#__PURE__*/React.createElement(Space, null, options.map(function (item, index) {
@@ -422,9 +427,11 @@ function parseRange(str) {
422
427
  };
423
428
  }
424
429
  var TypeComponent = function TypeComponent(_ref2) {
430
+ var _optionsValue$find;
425
431
  var type = _ref2.type,
426
432
  optionsValue = _ref2.optionsValue,
427
- editStatus = _ref2.editStatus;
433
+ editStatus = _ref2.editStatus,
434
+ id = _ref2.id;
428
435
  // type:1 string 2:正则 3:数字区间 4:枚举
429
436
  var Component = null;
430
437
  var _useContext2 = useContext(BizGlobalDataContext),
@@ -437,7 +444,7 @@ var TypeComponent = function TypeComponent(_ref2) {
437
444
  var handleEnumChange = function handleEnumChange(value) {
438
445
  setEnumValue(value);
439
446
  optionsValue.filter(function (r) {
440
- return r.ruleType == type;
447
+ return r.uniqueId == id;
441
448
  })[0].content = value;
442
449
  };
443
450
  // 区间
@@ -485,9 +492,6 @@ var TypeComponent = function TypeComponent(_ref2) {
485
492
  useEffect(function () {
486
493
  if (editStatus) {
487
494
  var _optionsValue$filter, _optionsValue$filter$;
488
- console.log(optionsValue, 'optionsValue', optionsValue.filter(function (o) {
489
- return o.ruleType == 3;
490
- }));
491
495
  if ((_optionsValue$filter = optionsValue.filter(function (o) {
492
496
  return o.ruleType == 3;
493
497
  })) === null || _optionsValue$filter === void 0 ? void 0 : (_optionsValue$filter$ = _optionsValue$filter[0]) === null || _optionsValue$filter$ === void 0 ? void 0 : _optionsValue$filter$.content) {
@@ -505,12 +509,16 @@ var TypeComponent = function TypeComponent(_ref2) {
505
509
  getDictList();
506
510
  }
507
511
  }, []);
512
+ var _useState27 = useState((_optionsValue$find = optionsValue.find(function (o) {
513
+ return o.uniqueId == id;
514
+ })) === null || _optionsValue$find === void 0 ? void 0 : _optionsValue$find.content),
515
+ _useState28 = _slicedToArray(_useState27, 2),
516
+ typeValue = _useState28[0],
517
+ setTypeValue = _useState28[1];
508
518
  switch (type) {
509
519
  case 1:
510
520
  Component = /*#__PURE__*/React.createElement(Select, {
511
- value: Number(optionsValue.filter(function (r) {
512
- return r.ruleType == type;
513
- })[0].content),
521
+ value: Number(typeValue),
514
522
  // disabled={true}
515
523
  options: [{
516
524
  value: 1,
@@ -523,8 +531,9 @@ var TypeComponent = function TypeComponent(_ref2) {
523
531
  label: '日期类型'
524
532
  }],
525
533
  onChange: function onChange(value) {
534
+ setTypeValue(value);
526
535
  optionsValue.filter(function (r) {
527
- return r.ruleType == type;
536
+ return r.uniqueId == id;
528
537
  })[0].content = value;
529
538
  }
530
539
  });
@@ -533,11 +542,11 @@ var TypeComponent = function TypeComponent(_ref2) {
533
542
  Component = /*#__PURE__*/React.createElement(Input, {
534
543
  placeholder: "\u8BF7\u8F93\u5165\u6B63\u5219\u8868\u5355\u5F0F",
535
544
  value: optionsValue.filter(function (r) {
536
- return r.ruleType == type;
545
+ return r.uniqueId == id;
537
546
  })[0].content,
538
547
  onChange: function onChange(event) {
539
548
  optionsValue.filter(function (r) {
540
- return r.ruleType == type;
549
+ return r.uniqueId == id;
541
550
  })[0].content = event.target.value;
542
551
  }
543
552
  });
@@ -554,7 +563,7 @@ var TypeComponent = function TypeComponent(_ref2) {
554
563
  onClick: function onClick() {
555
564
  setIncludedMinState(function (pre) {
556
565
  optionsValue.filter(function (r) {
557
- return r.ruleType == type;
566
+ return r.uniqueId == id;
558
567
  })[0].content = "".concat(!includedMinState ? '[' : '(').concat(minNum, ",").concat(maxNum).concat(includedMaxState ? ']' : ')');
559
568
  return !pre;
560
569
  });
@@ -566,7 +575,7 @@ var TypeComponent = function TypeComponent(_ref2) {
566
575
  onChange: function onChange(value) {
567
576
  setMinNum(value);
568
577
  optionsValue.filter(function (r) {
569
- return r.ruleType == type;
578
+ return r.uniqueId == id;
570
579
  })[0].content = "".concat(includedMinState ? '[' : '(').concat(value, ",").concat(maxNum).concat(includedMaxState ? ']' : ')');
571
580
  }
572
581
  }), "-", /*#__PURE__*/React.createElement(InputNumber, {
@@ -576,7 +585,7 @@ var TypeComponent = function TypeComponent(_ref2) {
576
585
  onChange: function onChange(value) {
577
586
  setMaxNum(value);
578
587
  optionsValue.filter(function (r) {
579
- return r.ruleType == type;
588
+ return r.uniqueId == id;
580
589
  })[0].content = "".concat(includedMinState ? '[' : '(').concat(minNum, ",").concat(value).concat(includedMaxState ? ']' : ')');
581
590
  }
582
591
  }), /*#__PURE__*/React.createElement(Tooltip, {
@@ -588,7 +597,7 @@ var TypeComponent = function TypeComponent(_ref2) {
588
597
  onClick: function onClick() {
589
598
  setIncludedMaxState(function (pre) {
590
599
  optionsValue.filter(function (r) {
591
- return r.ruleType == type;
600
+ return r.uniqueId == id;
592
601
  })[0].content = "".concat(includedMinState ? '[' : '(').concat(minNum, ",").concat(maxNum).concat(!includedMaxState ? ']' : ')');
593
602
  return !pre;
594
603
  });
@@ -603,25 +612,23 @@ var TypeComponent = function TypeComponent(_ref2) {
603
612
  },
604
613
  placeholder: "\u8BF7\u8F93\u5165",
605
614
  value: optionsValue.filter(function (r) {
606
- return r.ruleType == type;
615
+ return r.uniqueId == id;
607
616
  })[0].content,
608
617
  onChange: handleEnumChange,
609
618
  options: optionsEnum
610
619
  });
611
620
  break;
612
621
  case 6:
613
- Component = /*#__PURE__*/React.createElement(Select
614
- // defaultValue={Number(optionsValue.filter((r) => r.ruleType == type)[0].content)}
615
- , {
616
- // defaultValue={Number(optionsValue.filter((r) => r.ruleType == type)[0].content)}
617
- value: optionsValue.filter(function (r) {
618
- return r.ruleType == type;
619
- })[0].content,
622
+ Component = /*#__PURE__*/React.createElement(Select, {
623
+ defaultValue: Number(optionsValue.filter(function (r) {
624
+ return r.uniqueId == id;
625
+ })[0].content),
626
+ // value={optionsValue.filter((r) => r.ruleType == type)[0].content}
620
627
  placeholder: "\u9009\u62E9\u5B57\u5178\u89C4\u5219",
621
628
  options: dictList,
622
629
  onChange: function onChange(value) {
623
630
  optionsValue.filter(function (r) {
624
- return r.ruleType == type;
631
+ return r.uniqueId == id;
625
632
  })[0].content = value;
626
633
  }
627
634
  });