@bchr/bchr-front-lib 0.3.99 → 0.3.103

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.
@@ -1,26 +1,48 @@
1
1
  "use strict";
2
2
 
3
- window.AppFormulaFunctions = {};
4
-
5
- window.AppFormulaFunctions.currentMonthStartDay = function (date) {
6
- var currentDate = new Date(date),
7
- currentYear = currentDate.getFullYear(),
8
- currentMouth = currentDate.getMonth() + 1;
9
- return currentYear + "-" + currentMouth + "-1";
10
- };
11
-
12
- window.AppFormulaFunctions.nextMonthStartDay = function (date) {
13
- var currentDate = new Date(date),
14
- currentYear = currentDate.getFullYear(),
15
- currentMouth = currentDate.getMonth() + 1;
16
- return new Date(currentYear, currentMouth, 1);
17
- };
18
-
19
- window.AppFormulaFunctions.currentDateToDeadline = function (date, during) {
20
- debugger;
21
- var changeDate = new Date(new Date(date).getTime() + during * 24 * 60 * 60 * 1000);
22
- var changeYear = changeDate.getFullYear(),
23
- changeMouth = changeDate.getMonth() + 1,
24
- changeDay = changeDate.getDay();
25
- return changeYear + '-' + changeMouth + '-' + changeDay;
3
+ var _moment = _interopRequireDefault(require("moment"));
4
+
5
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
6
+
7
+ window.AppFormulaFunctions = {
8
+ currentMonthStartDay: function currentMonthStartDay(dateStr) {
9
+ if (dateStr) {
10
+ var baseDate = (0, _moment["default"])(dateStr, "YYYY-MM-DD");
11
+ return baseDate.date(1).format("YYYY-MM-DD");
12
+ }
13
+
14
+ return null;
15
+ },
16
+ nextMonthStartDay: function nextMonthStartDay(dateStr) {
17
+ if (dateStr) {
18
+ var baseDate = (0, _moment["default"])(dateStr, "YYYY-MM-DD");
19
+ return baseDate.add(1, 'months').date(1).format("YYYY-MM-DD");
20
+ }
21
+
22
+ return null;
23
+ },
24
+ datePlusDays: function datePlusDays(dateStr, during_days) {
25
+ if (dateStr && during_days) {
26
+ var baseDate = (0, _moment["default"])(dateStr, "YYYY-MM-DD");
27
+ return baseDate.add(during_days, 'days').format("YYYY-MM-DD");
28
+ }
29
+
30
+ return null;
31
+ },
32
+ datePlusMonths: function datePlusMonths(dateStr, during_months) {
33
+ if (dateStr && during_months) {
34
+ var baseDate = (0, _moment["default"])(dateStr, "YYYY-MM-DD");
35
+ return baseDate.add(during_months, 'months').format("YYYY-MM-DD");
36
+ }
37
+
38
+ return null;
39
+ },
40
+ datePlusYears: function datePlusYears(dateStr, during_years) {
41
+ if (dateStr && during_years) {
42
+ var baseDate = (0, _moment["default"])(dateStr, "YYYY-MM-DD");
43
+ return baseDate.add(during_years, 'years').format("YYYY-MM-DD");
44
+ }
45
+
46
+ return null;
47
+ }
26
48
  };
@@ -372,7 +372,7 @@ var FormForBrowse = /*#__PURE__*/function (_React$Component) {
372
372
  if (typeof initialValue === 'boolean') {
373
373
  value = initialValues[display_code] ? "是" : "否";
374
374
  } else {
375
- value = (initialValue || '').toLowerCase() === 'true' ? "是" : "否";
375
+ value = (initialValue + '' || '').toLowerCase() === 'true' || (initialValue + '' || '').toLowerCase() === '1' ? "是" : "否";
376
376
  }
377
377
 
378
378
  break;
@@ -21,6 +21,8 @@ var _HttpService = _interopRequireDefault(require("../../../../services/HttpServ
21
21
 
22
22
  var _InputPassword = _interopRequireDefault(require("../InputPassword"));
23
23
 
24
+ require("../../../AppFormulaFunctions");
25
+
24
26
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
25
27
 
26
28
  function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
@@ -57,6 +59,12 @@ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.g
57
59
 
58
60
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
59
61
 
62
+ var FormulasValueType = {
63
+ Disabled: "disabled",
64
+ Enabled: "enabled",
65
+ Function: "AppFormulaFunctions"
66
+ };
67
+
60
68
  var FormForModify = /*#__PURE__*/function (_React$Component) {
61
69
  _inherits(FormForModify, _React$Component);
62
70
 
@@ -137,96 +145,16 @@ var FormForModify = /*#__PURE__*/function (_React$Component) {
137
145
  }));
138
146
  });
139
147
 
140
- _defineProperty(_assertThisInitialized(_this2), "buildFormItems", function (editFormulasState) {
148
+ _defineProperty(_assertThisInitialized(_this2), "buildFormItems", function () {
141
149
  var _this2$props2 = _this2.props,
142
- data = _this2$props2.data,
143
150
  info_set_fields = _this2$props2.info_set_fields,
144
151
  ext_form_items = _this2$props2.ext_form_items;
145
- var setFieldsValue = _this2.ref.current.setFieldsValue;
152
+
153
+ if (_this2.ref.current == null) {
154
+ return;
155
+ }
146
156
 
147
157
  if (info_set_fields && info_set_fields.length > 0) {
148
- info_set_fields.forEach(function (formItem) {
149
- formItem.initialValue = null;
150
-
151
- _this2.preParseFormItemExtConfig(formItem);
152
-
153
- if (editFormulasState && editFormulasState.length) {
154
- formItem.b_disabled = formItem.b_readonly;
155
-
156
- for (var i = 0, len = editFormulasState.length; i < len; i++) {
157
- var editFormulaStateItem = editFormulasState[i].editFormulaItem;
158
-
159
- if (editFormulaStateItem) {
160
- editFormulaStateItem.otherFormItemResponses.forEach(function (item) {
161
- if (formItem.code === item.formItemCode) {
162
- if (item.formItemValue === 'disabled') {
163
- formItem.b_disabled = true;
164
- } else if (item.formItemValue === 'enabled') {
165
- formItem.b_disabled = false;
166
- } else {
167
- formItem.initialValue = item.formItemValue || data[formItem.display_code];
168
- }
169
-
170
- if (formItem.initialValue || data[formItem.code]) {
171
- if (formItem.code.indexOf('date') !== -1) {
172
- setFieldsValue(_defineProperty({}, formItem.code, (0, _moment["default"])(formItem.initialValue || data[formItem.code])));
173
-
174
- if (formItem.code.endsWith("_date")) {
175
- data[formItem.code] = (0, _moment["default"])(formItem.initialValue || data[formItem.code]).valueOf();
176
- } else if (formItem.code.indexOf('_date$') !== -1) {
177
- data[formItem.code] = (0, _moment["default"])(formItem.initialValue || data[formItem.code]).format("YYYY-MM-DD");
178
- }
179
- } else {
180
- setFieldsValue(_defineProperty({}, formItem.code, formItem.initialValue || data[formItem.code]));
181
- data[formItem.code] = formItem.initialValue || data[formItem.code];
182
- }
183
- }
184
- }
185
- });
186
- }
187
- }
188
- } else {
189
- if (formItem.editFormulaConfigs) {
190
- for (var _i = 0, _len = formItem.editFormulaConfigs.length; _i < _len; _i++) {
191
- var editFormulaConfig = formItem.editFormulaConfigs[_i];
192
- var initialValue = formItem.ui_render_type === 'switch' ? (data[formItem.code] && data[formItem.code].toString() || '').toLowerCase() !== 'true' : data[formItem.code];
193
- var formulaValueOf = formItem.ui_render_type === 'switch' ? (editFormulaConfig.onValueOf || '').toLowerCase() !== 'true' : editFormulaConfig.onValueOf;
194
-
195
- if (formulaValueOf === initialValue) {
196
- var currentOtherFormItemResponses = editFormulaConfig.otherFormItemResponses;
197
- currentOtherFormItemResponses.forEach(function (item) {
198
- info_set_fields.forEach(function (formItemInner) {
199
- if (formItemInner.code === item.formItemCode) {
200
- if (item.formItemValue === 'disabled') {
201
- formItemInner.b_disabled = true;
202
- } else if (item.formItemValue === 'enabled') {
203
- formItemInner.b_disabled = false;
204
- } else {
205
- formItemInner.initialValue = item.formItemValue || data[formItemInner.display_code];
206
- }
207
-
208
- if (formItemInner.initialValue || data[formItemInner.code]) {
209
- if (formItemInner.code.indexOf('date') !== -1) {
210
- setFieldsValue(_defineProperty({}, formItemInner.code, (0, _moment["default"])(formItemInner.initialValue || data[formItemInner.code])));
211
-
212
- if (formItemInner.code.endsWith("_date")) {
213
- data[formItemInner.code] = (0, _moment["default"])(formItemInner.initialValue || data[formItemInner.code]).valueOf();
214
- } else if (formItemInner.code.indexOf('_date$') !== -1) {
215
- data[formItemInner.code] = (0, _moment["default"])(formItem.initialValue || data[formItemInner.code]).format("YYYY-MM-DD");
216
- }
217
- } else {
218
- setFieldsValue(_defineProperty({}, formItemInner.code, formItemInner.initialValue || data[formItemInner.code]));
219
- data[formItemInner.code] = formItemInner.initialValue || data[formItemInner.code];
220
- }
221
- }
222
- }
223
- });
224
- });
225
- }
226
- }
227
- }
228
- }
229
- });
230
158
  var groupNames = info_set_fields.map(function (item) {
231
159
  return item.belong_form_group;
232
160
  }).filter(function (item, index, arr) {
@@ -306,8 +234,8 @@ var FormForModify = /*#__PURE__*/function (_React$Component) {
306
234
 
307
235
  var editFormulaConfigs = [];
308
236
 
309
- for (var _i2 = 0, _len2 = pureFormulaTextItems.length; _i2 < _len2; _i2++) {
310
- var formulaTextItem = pureFormulaTextItems[_i2];
237
+ for (var _i = 0, _len = pureFormulaTextItems.length; _i < _len; _i++) {
238
+ var formulaTextItem = pureFormulaTextItems[_i];
311
239
  var formulaChildTextItems = formulaTextItem.split("=>");
312
240
 
313
241
  if (formulaChildTextItems.length !== 2) {
@@ -642,7 +570,7 @@ var FormForModify = /*#__PURE__*/function (_React$Component) {
642
570
  valuePropName = "checked";
643
571
 
644
572
  if (typeof initialValue !== 'boolean') {
645
- initialValue = (initialValue || '').toLowerCase() === 'true';
573
+ initialValue = (initialValue + '' || '').toLowerCase() === 'true' || (initialValue + '' || '').toLowerCase() === '1';
646
574
  displayValue = initialValue ? "是" : "否";
647
575
  }
648
576
 
@@ -765,9 +693,131 @@ var FormForModify = /*#__PURE__*/function (_React$Component) {
765
693
  return dict.title;
766
694
  });
767
695
 
696
+ _defineProperty(_assertThisInitialized(_this2), "formItemOnChangeForFormula", function (config, value) {
697
+ var formItemFormulaConfigs = config.editFormulaConfigs;
698
+
699
+ if (formItemFormulaConfigs && formItemFormulaConfigs.length > 0) {
700
+ var fieldCodeKeyMap = _this2.state.fieldCodeKeyMap;
701
+ var _this2$props4 = _this2.props,
702
+ data = _this2$props4.data,
703
+ def_docs = _this2$props4.def_docs;
704
+ var setFieldsValue = _this2.ref.current.setFieldsValue; // value exists
705
+
706
+ var editFormulaItem = config.editFormulaConfigs.find(function (editFormulaItem) {
707
+ return editFormulaItem.onValueOf === value.toString() || editFormulaItem.onValueOf === "value";
708
+ });
709
+
710
+ if (editFormulaItem) {
711
+ var otherFormItemResponses = editFormulaItem.otherFormItemResponses;
712
+
713
+ var _loop = function _loop(i, len) {
714
+ var otherFormItem = otherFormItemResponses[i];
715
+
716
+ if (!otherFormItem) {
717
+ return "continue";
718
+ }
719
+
720
+ var formItemCode = otherFormItem.formItemCode,
721
+ formItemValue = otherFormItem.formItemValue;
722
+ var otherFormItemConfig = fieldCodeKeyMap[formItemCode];
723
+
724
+ if (!otherFormItemConfig) {
725
+ return "continue";
726
+ }
727
+
728
+ if (!formItemValue) {
729
+ return "continue";
730
+ }
731
+
732
+ var code = otherFormItemConfig.code,
733
+ display_code = otherFormItemConfig.display_code,
734
+ ref_pk = otherFormItemConfig.ref_pk,
735
+ ui_render_type = otherFormItemConfig.ui_render_type;
736
+
737
+ if (FormulasValueType.Disabled == formItemValue) {
738
+ data[code] = null;
739
+ setFieldsValue(_defineProperty({}, code, null));
740
+
741
+ if (display_code) {
742
+ data[display_code] = null;
743
+ setFieldsValue(_defineProperty({}, display_code, null));
744
+ }
745
+
746
+ otherFormItemConfig.b_disabled = true;
747
+ otherFormItemConfig.b_readonly = true;
748
+ } else if (FormulasValueType.Enabled == formItemValue) {
749
+ otherFormItemConfig.b_disabled = false;
750
+ otherFormItemConfig.b_readonly = true;
751
+ } else if (formItemValue.startsWith(FormulasValueType.Function)) {
752
+ var formulaFunctionValue;
753
+
754
+ if (formItemValue.search("#value#") !== -1) {
755
+ formulaFunctionValue = eval(formItemValue.replace('#value#', "value").replace("@", ","));
756
+ } else {
757
+ var formItemValueList = formItemValue.split("#");
758
+
759
+ if (!formItemValueList || formItemValueList.length != 3) {
760
+ console.log("formula error, detail info: formItemCode=" + formItemValue + ", formItemValue=" + formItemValue);
761
+ return "continue";
762
+ }
763
+
764
+ var realFormulaValue = formItemValueList[0] + "data[formItemValueList[1]]" + formItemValueList[2];
765
+ formulaFunctionValue = eval(realFormulaValue.replace("@", ","));
766
+ }
767
+
768
+ if (!formulaFunctionValue) {
769
+ console.log("formula function return null, detail info: formItemCode=" + formItemValue + ", formItemValue=" + formItemValue);
770
+ return "continue";
771
+ }
772
+
773
+ data[code] = formulaFunctionValue;
774
+ var otherFormItemValue;
775
+
776
+ if (_consts.UI_RENDER_TYPE.DATE == ui_render_type) {
777
+ otherFormItemValue = (0, _moment["default"])(formulaFunctionValue, "YYYY-MM-DD");
778
+ } else {
779
+ otherFormItemValue = formulaFunctionValue;
780
+ }
781
+
782
+ setFieldsValue(_defineProperty({}, code, otherFormItemValue));
783
+ } else {
784
+ data[code] = formItemValue;
785
+ setFieldsValue(_defineProperty({}, code, formItemValue));
786
+
787
+ if (display_code && display_code.trim().length > 0) {
788
+ var dictList = def_docs["def_" + ref_pk];
789
+
790
+ if (dictList && dictList.length > 0) {
791
+ var filteredDict = dictList.find(function (item) {
792
+ return item.pk.toString() == formItemValue;
793
+ });
794
+
795
+ if (filteredDict) {
796
+ var ref_title = filteredDict.title;
797
+ data[display_code] = ref_title;
798
+ setFieldsValue(_defineProperty({}, display_code, ref_title));
799
+ }
800
+ }
801
+ }
802
+ }
803
+ };
804
+
805
+ for (var i = 0, len = otherFormItemResponses.length; i < len; i++) {
806
+ var _ret = _loop(i, len);
807
+
808
+ if (_ret === "continue") continue;
809
+ }
810
+ }
811
+
812
+ _this2.setState({
813
+ fieldCodeKeyMap: fieldCodeKeyMap
814
+ });
815
+ }
816
+ });
817
+
768
818
  _this2.ref = _this2.props.formref || /*#__PURE__*/_react["default"].createRef();
769
819
  _this2.state = {
770
- editFormulasState: []
820
+ fieldCodeKeyMap: {}
771
821
  };
772
822
  return _this2;
773
823
  }
@@ -775,32 +825,32 @@ var FormForModify = /*#__PURE__*/function (_React$Component) {
775
825
  _createClass(FormForModify, [{
776
826
  key: "componentDidMount",
777
827
  value: function componentDidMount() {
778
- var _this3 = this;
779
-
780
828
  var _this$props = this.props,
781
829
  data = _this$props.data,
782
830
  info_set_fields = _this$props.info_set_fields;
783
- var editFormulasState = this.state.editFormulasState;
784
- info_set_fields.forEach(function (formItem) {
785
- _this3.preParseFormItemExtConfig(formItem);
786
-
787
- if (formItem.editFormulaConfigs) {
788
- for (var i = 0, len = formItem.editFormulaConfigs.length; i < len; i++) {
789
- var editFormulaConfig = formItem.editFormulaConfigs[i];
790
- var initialValue = formItem.ui_render_type === 'switch' ? (data[formItem.code] && data[formItem.code].toString() || '').toLowerCase() !== 'true' : data[formItem.code];
791
- var formulaValueOf = formItem.ui_render_type === 'switch' ? (editFormulaConfig.onValueOf || '').toLowerCase() !== 'true' : editFormulaConfig.onValueOf;
792
-
793
- if (formulaValueOf === initialValue) {
794
- editFormulasState.push({
795
- editFormulasStateCode: formItem.code,
796
- editFormulaItem: editFormulaConfig
797
- });
798
- }
799
- }
831
+ var fieldCodeKeyMap = this.state.fieldCodeKeyMap;
832
+
833
+ for (var i = 0, len = info_set_fields.length; i < len; i++) {
834
+ var formItem = info_set_fields[i];
835
+ this.preParseFormItemExtConfig(formItem);
836
+ var code = formItem.code,
837
+ ui_render_type = formItem.ui_render_type;
838
+ var fieldCodeValue = data[code];
839
+
840
+ if (_consts.UI_RENDER_TYPE.SWITCH == ui_render_type) {
841
+ fieldCodeValue = (fieldCodeValue + '' || '').toLowerCase() === 'true' || (fieldCodeValue + '' || '').toLowerCase() === '1' ? "true" : "false";
800
842
  }
801
- });
843
+
844
+ if (fieldCodeValue) {
845
+ this.formItemOnChangeForFormula(formItem, fieldCodeValue);
846
+ }
847
+
848
+ formItem.b_disabled = formItem.b_readonly;
849
+ fieldCodeKeyMap[formItem.code] = formItem;
850
+ }
851
+
802
852
  this.setState({
803
- editFormulasState: editFormulasState
853
+ fieldCodeKeyMap: fieldCodeKeyMap
804
854
  });
805
855
  }
806
856
  }, {
@@ -912,6 +962,10 @@ var FormForModify = /*#__PURE__*/function (_React$Component) {
912
962
  formData[config.code] = date.format(dateFormat);
913
963
  }
914
964
 
965
+ if (dateString) {
966
+ this.formItemOnChangeForFormula(config, dateString);
967
+ }
968
+
915
969
  if (callback && typeof callback === "function") {
916
970
  callback(date, dateString);
917
971
  }
@@ -941,8 +995,6 @@ var FormForModify = /*#__PURE__*/function (_React$Component) {
941
995
  }, {
942
996
  key: "selectOnChange",
943
997
  value: function selectOnChange(config, callback, value, option) {
944
- var _this4 = this;
945
-
946
998
  var display_code = config.display_code,
947
999
  code = config.code;
948
1000
 
@@ -986,75 +1038,8 @@ var FormForModify = /*#__PURE__*/function (_React$Component) {
986
1038
  this.props.data[display_code] = display_value;
987
1039
  }
988
1040
 
989
- if (config.editFormulaConfigs && config.editFormulaConfigs.length) {
990
- var editFormulasState = this.state.editFormulasState;
991
- var _this$ref$current = this.ref.current,
992
- setFieldsValue = _this$ref$current.setFieldsValue,
993
- resetFields = _this$ref$current.resetFields;
994
-
995
- if (value) {
996
- var editFormulaItem = config.editFormulaConfigs.filter(function (editFormulaItem) {
997
- return editFormulaItem.onValueOf === value.toString();
998
- })[0];
999
-
1000
- if (editFormulaItem) {
1001
- if (value) {
1002
- editFormulaItem.otherFormItemResponses.forEach(function (item) {
1003
- if (item.formItemValue === 'disabled') {
1004
- resetFields([item.formItemCode]);
1005
- setFieldsValue(_defineProperty({}, item.formItemCode, null));
1006
-
1007
- if (item.formItemCode.endsWith('_pk') && _this4.props.data["".concat(item.formItemCode.split('_pk')[0], "_ext_name")]) {
1008
- _this4.props.data["".concat(item.formItemCode.split('_pk')[0], "_ext_name")] = null;
1009
- } else if (item.formItemCode.indexOf('_pk$') !== -1 && _this4.props.data["".concat(item.formItemCode.split('_pk$')[0], "_ext_name$").concat(item.formItemCode.split('_pk$')[1])]) {
1010
- _this4.props.data["".concat(item.formItemCode.split('_pk$')[0], "_ext_name$").concat(item.formItemCode.split('_pk$')[1])] = null;
1011
- }
1012
-
1013
- _this4.props.data[item.formItemCode] = null;
1014
- }
1015
- });
1016
- }
1017
-
1018
- if (editFormulasState.filter(function (item) {
1019
- return item.editFormulasStateCode === code;
1020
- }).length) {
1021
- editFormulasState.forEach(function (item) {
1022
- if (item.editFormulasStateCode === code) {
1023
- item.editFormulaItem = editFormulaItem;
1024
- }
1025
- });
1026
- } else {
1027
- editFormulasState.push({
1028
- editFormulasStateCode: code,
1029
- editFormulaItem: editFormulaItem
1030
- });
1031
- }
1032
- } else {
1033
- if (editFormulasState.filter(function (item) {
1034
- return item.editFormulasStateCode === code;
1035
- }).length) {
1036
- editFormulasState.forEach(function (item) {
1037
- if (item.editFormulasStateCode === code) {
1038
- item.editFormulaItem = null;
1039
- }
1040
- });
1041
- }
1042
- }
1043
- } else {
1044
- if (editFormulasState.filter(function (item) {
1045
- return item.editFormulasStateCode === code;
1046
- }).length) {
1047
- editFormulasState.forEach(function (item) {
1048
- if (item.editFormulasStateCode === code) {
1049
- item.editFormulaItem = null;
1050
- }
1051
- });
1052
- }
1053
- }
1054
-
1055
- this.setState({
1056
- editFormulasState: editFormulasState
1057
- });
1041
+ if (value) {
1042
+ this.formItemOnChangeForFormula(config, value);
1058
1043
  }
1059
1044
 
1060
1045
  if (callback && typeof callback === "function") {
@@ -1086,7 +1071,7 @@ var FormForModify = /*#__PURE__*/function (_React$Component) {
1086
1071
  }, {
1087
1072
  key: "buildTreeNode",
1088
1073
  value: function buildTreeNode(defNodes) {
1089
- var _this5 = this;
1074
+ var _this3 = this;
1090
1075
 
1091
1076
  if (!defNodes || defNodes.length === 0) {
1092
1077
  return null;
@@ -1107,7 +1092,7 @@ var FormForModify = /*#__PURE__*/function (_React$Component) {
1107
1092
  ext_attr_value: ext_attr_value,
1108
1093
  selectable: item.selectable,
1109
1094
  prop: ext_attr_value
1110
- }, _this5.buildTreeNode(item.children));
1095
+ }, _this3.buildTreeNode(item.children));
1111
1096
  });
1112
1097
  }
1113
1098
  }, {
@@ -1164,59 +1149,7 @@ var FormForModify = /*#__PURE__*/function (_React$Component) {
1164
1149
  }, {
1165
1150
  key: "switchOnChange",
1166
1151
  value: function switchOnChange(config, callback, checked, event) {
1167
- var _this6 = this;
1168
-
1169
- if (config.editFormulaConfigs && config.editFormulaConfigs.length) {
1170
- var code = config.code;
1171
- var editFormulasState = this.state.editFormulasState;
1172
- var _this$ref$current2 = this.ref.current,
1173
- setFieldsValue = _this$ref$current2.setFieldsValue,
1174
- resetFields = _this$ref$current2.resetFields;
1175
- var editFormulaItem = config.editFormulaConfigs.filter(function (editFormulaItem) {
1176
- return editFormulaItem.onValueOf === checked.toString();
1177
- })[0];
1178
-
1179
- if (editFormulaItem) {
1180
- if (!checked) {
1181
- editFormulaItem.otherFormItemResponses.forEach(function (item) {
1182
- resetFields([item.formItemCode]);
1183
- setFieldsValue(_defineProperty({}, item.formItemCode, null));
1184
-
1185
- if (item.formItemCode.endsWith('_pk') && _this6.props.data["".concat(item.formItemCode.split('_pk')[0], "_ext_name")]) {
1186
- _this6.props.data["".concat(item.formItemCode.split('_pk')[0], "_ext_name")] = null;
1187
- } else if (item.formItemCode.indexOf('_pk$') !== -1 && _this6.props.data["".concat(item.formItemCode.split('_pk$')[0], "_ext_name$").concat(item.formItemCode.split('_pk$')[1])]) {
1188
- _this6.props.data["".concat(item.formItemCode.split('_pk$')[0], "_ext_name$").concat(item.formItemCode.split('_pk$')[1])] = null;
1189
- }
1190
-
1191
- _this6.props.data[item.formItemCode] = null;
1192
- });
1193
- }
1194
-
1195
- if (editFormulasState.filter(function (item) {
1196
- return item.editFormulasStateCode === code;
1197
- }).length) {
1198
- editFormulasState.forEach(function (item) {
1199
- if (item.editFormulasStateCode === code) {
1200
- item.editFormulaItem = editFormulaItem;
1201
- }
1202
- });
1203
- } else {
1204
- editFormulasState.push({
1205
- editFormulasStateCode: code,
1206
- editFormulaItem: editFormulaItem
1207
- });
1208
- }
1209
- } else {
1210
- editFormulasState.push({
1211
- editFormulasStateCode: code,
1212
- editFormulaItem: null
1213
- });
1214
- }
1215
-
1216
- this.setState({
1217
- editFormulasState: editFormulasState
1218
- });
1219
- }
1152
+ this.formItemOnChangeForFormula(config, checked);
1220
1153
 
1221
1154
  if (callback && typeof callback === "function") {
1222
1155
  callback(checked, event);
@@ -1314,7 +1247,7 @@ var FormForModify = /*#__PURE__*/function (_React$Component) {
1314
1247
  key: "render",
1315
1248
  value: function render() {
1316
1249
  var props = this.props;
1317
- var editFormulasState = this.state.editFormulasState;
1250
+ var fieldCodeKeyMap = this.state.fieldCodeKeyMap;
1318
1251
  return /*#__PURE__*/_react["default"].createElement(_antd.ConfigProvider, {
1319
1252
  locale: _zh_CN["default"]
1320
1253
  }, /*#__PURE__*/_react["default"].createElement(_antd.Form, _extends({}, props, {
@@ -1322,7 +1255,7 @@ var FormForModify = /*#__PURE__*/function (_React$Component) {
1322
1255
  ref: this.ref,
1323
1256
  scrollToFirstError: true,
1324
1257
  onValuesChange: this.onValuesChange.bind(this)
1325
- }), this.buildFormItems(editFormulasState), this.buildExtFormItems()));
1258
+ }), this.buildFormItems(fieldCodeKeyMap), this.buildExtFormItems()));
1326
1259
  }
1327
1260
  }]);
1328
1261
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bchr/bchr-front-lib",
3
- "version": "0.3.99",
3
+ "version": "0.3.103",
4
4
  "description": "bchr front lib",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {
@@ -1,24 +1,48 @@
1
- window.AppFormulaFunctions = {};
2
-
3
- window.AppFormulaFunctions.currentMonthStartDay = function (date) {
4
- var currentDate = new Date(date),
5
- currentYear = currentDate.getFullYear(),
6
- currentMouth = currentDate.getMonth() + 1;
7
- return currentYear + "-" + currentMouth + "-1"
8
- }
9
-
10
- window.AppFormulaFunctions.nextMonthStartDay = function (date) {
11
- var currentDate = new Date(date),
12
- currentYear = currentDate.getFullYear(),
13
- currentMouth = currentDate.getMonth() + 1;
14
- return new Date(currentYear, currentMouth, 1)
15
- }
16
-
17
- window.AppFormulaFunctions.currentDateToDeadline = function (date, during) {
18
- debugger
19
- var changeDate = new Date(new Date(date).getTime() + during * 24 * 60 * 60 * 1000);
20
- var changeYear = changeDate.getFullYear(),
21
- changeMouth = changeDate.getMonth() + 1,
22
- changeDay = changeDate.getDay();
23
- return changeYear + '-' + changeMouth + '-' + changeDay;
24
- }
1
+ import moment from "moment";
2
+
3
+ window.AppFormulaFunctions = {
4
+ currentMonthStartDay : function (dateStr) {
5
+ if (dateStr) {
6
+ let baseDate = moment(dateStr, "YYYY-MM-DD");
7
+ return baseDate.date(1).format("YYYY-MM-DD");
8
+ }
9
+
10
+ return null;
11
+ },
12
+
13
+ nextMonthStartDay : function (dateStr) {
14
+ if (dateStr) {
15
+ let baseDate = moment(dateStr, "YYYY-MM-DD");
16
+ return baseDate.add(1,'months').date(1).format("YYYY-MM-DD");
17
+ }
18
+
19
+ return null;
20
+ },
21
+
22
+ datePlusDays : function (dateStr, during_days) {
23
+ if (dateStr && during_days) {
24
+ let baseDate = moment(dateStr, "YYYY-MM-DD");
25
+ return baseDate.add(during_days, 'days').format("YYYY-MM-DD")
26
+ }
27
+
28
+ return null;
29
+ },
30
+
31
+ datePlusMonths : function (dateStr, during_months) {
32
+ if (dateStr && during_months) {
33
+ let baseDate = moment(dateStr, "YYYY-MM-DD");
34
+ return baseDate.add(during_months, 'months').format("YYYY-MM-DD")
35
+ }
36
+
37
+ return null;
38
+ },
39
+
40
+ datePlusYears : function (dateStr, during_years) {
41
+ if (dateStr && during_years) {
42
+ let baseDate = moment(dateStr, "YYYY-MM-DD");
43
+ return baseDate.add(during_years, 'years').format("YYYY-MM-DD")
44
+ }
45
+
46
+ return null;
47
+ }
48
+ };
@@ -334,7 +334,7 @@ class FormForBrowse extends React.Component{
334
334
  if (typeof initialValue === 'boolean') {
335
335
  value = (initialValues[display_code] ? "是" : "否");
336
336
  } else {
337
- value = ((initialValue || '').toLowerCase() === 'true' ? "是" : "否");
337
+ value = (((initialValue + '' || '').toLowerCase() === 'true' || (initialValue + '' || '').toLowerCase() === '1') ? "是" : "否");
338
338
  }
339
339
  break;
340
340
  default:
@@ -22,6 +22,13 @@ import {UI_RENDER_TYPE} from "../consts";
22
22
  import zhCN from "antd/es/locale/zh_CN";
23
23
  import HttpService from "../../../../services/HttpService";
24
24
  import InputPassword from "../InputPassword";
25
+ import '../../../AppFormulaFunctions'
26
+
27
+ const FormulasValueType = {
28
+ Disabled : "disabled",
29
+ Enabled : "enabled",
30
+ Function : "AppFormulaFunctions",
31
+ }
25
32
 
26
33
  class FormForModify extends React.Component{
27
34
  constructor(props) {
@@ -30,28 +37,37 @@ class FormForModify extends React.Component{
30
37
  this.ref = this.props.formref || React.createRef();
31
38
 
32
39
  this.state = {
33
- editFormulasState: []
40
+ fieldCodeKeyMap: {},
34
41
  }
35
42
  }
36
43
 
37
44
  componentDidMount() {
38
45
  let {data, info_set_fields} = this.props;
39
- let {editFormulasState} = this.state;
40
- info_set_fields.forEach(formItem => {
46
+ let {fieldCodeKeyMap} = this.state;
47
+
48
+ for (let i = 0, len = info_set_fields.length; i < len; i++) {
49
+ let formItem = info_set_fields[i];
50
+
41
51
  this.preParseFormItemExtConfig(formItem);
42
- if (formItem.editFormulaConfigs) {
43
- for (let i = 0, len = formItem.editFormulaConfigs.length; i < len; i++) {
44
- let editFormulaConfig = formItem.editFormulaConfigs[i];
45
- let initialValue = formItem.ui_render_type === 'switch' ? ((data[formItem.code] && data[formItem.code].toString()) || '').toLowerCase() !== 'true' : data[formItem.code];
46
- let formulaValueOf = formItem.ui_render_type === 'switch' ? (editFormulaConfig.onValueOf || '').toLowerCase() !== 'true' : editFormulaConfig.onValueOf;
47
-
48
- if (formulaValueOf === initialValue) {
49
- editFormulasState.push({editFormulasStateCode: formItem.code, editFormulaItem: editFormulaConfig})
50
- }
51
- }
52
+
53
+ let {code, ui_render_type} = formItem;
54
+ let fieldCodeValue = data[code];
55
+
56
+ if (UI_RENDER_TYPE.SWITCH == ui_render_type) {
57
+ fieldCodeValue = (((fieldCodeValue + '' || '').toLowerCase() === 'true' || (fieldCodeValue + '' || '').toLowerCase() === '1') ? "true" : "false");
58
+ }
59
+
60
+ if (fieldCodeValue) {
61
+ this.formItemOnChangeForFormula(formItem, fieldCodeValue);
52
62
  }
63
+
64
+ formItem.b_disabled = formItem.b_readonly;
65
+ fieldCodeKeyMap[formItem.code] = formItem;
66
+ }
67
+
68
+ this.setState({
69
+ fieldCodeKeyMap,
53
70
  })
54
- this.setState({editFormulasState})
55
71
  }
56
72
 
57
73
  buildExtFormItems = () => {
@@ -129,90 +145,13 @@ class FormForModify extends React.Component{
129
145
  )
130
146
  }
131
147
 
132
- buildFormItems = (editFormulasState) => {
133
- let {data, info_set_fields, ext_form_items} = this.props;
134
- let {setFieldsValue} = this.ref.current;
135
- if (info_set_fields && info_set_fields.length > 0) {
136
- info_set_fields.forEach(formItem => {
137
- formItem.initialValue = null;
138
-
139
- this.preParseFormItemExtConfig(formItem);
140
-
141
- if (editFormulasState && editFormulasState.length) {
142
- formItem.b_disabled = formItem.b_readonly;
143
- for (let i = 0, len = editFormulasState.length; i < len; i++) {
144
- let editFormulaStateItem = editFormulasState[i].editFormulaItem;
145
- if (editFormulaStateItem) {
146
- editFormulaStateItem.otherFormItemResponses.forEach(item => {
147
- if (formItem.code === item.formItemCode) {
148
- if (item.formItemValue === 'disabled') {
149
- formItem.b_disabled = true;
150
- } else if (item.formItemValue === 'enabled') {
151
- formItem.b_disabled = false;
152
- } else {
153
- formItem.initialValue = item.formItemValue || data[formItem.display_code];
154
- }
155
- if (formItem.initialValue || data[formItem.code]) {
156
- if (formItem.code.indexOf('date') !== -1) {
157
- setFieldsValue({[formItem.code]: moment(formItem.initialValue || data[formItem.code])});
158
- if (formItem.code.endsWith("_date")) {
159
- data[formItem.code] = moment(formItem.initialValue || data[formItem.code]).valueOf();
160
- } else if (formItem.code.indexOf('_date$') !== -1) {
161
- data[formItem.code] = moment(formItem.initialValue || data[formItem.code]).format("YYYY-MM-DD");
162
- }
163
- } else {
164
- setFieldsValue({[formItem.code]: formItem.initialValue || data[formItem.code]});
165
- data[formItem.code] = formItem.initialValue || data[formItem.code];
166
- }
167
- }
168
- }
169
- })
170
- }
171
- }
172
-
173
- } else {
174
- if (formItem.editFormulaConfigs) {
175
- for (let i = 0, len = formItem.editFormulaConfigs.length; i < len; i++) {
176
- let editFormulaConfig = formItem.editFormulaConfigs[i];
177
- let initialValue = formItem.ui_render_type === 'switch' ? ((data[formItem.code] && data[formItem.code].toString()) || '').toLowerCase() !== 'true' : data[formItem.code];
178
- let formulaValueOf = formItem.ui_render_type === 'switch' ? (editFormulaConfig.onValueOf || '').toLowerCase() !== 'true' : editFormulaConfig.onValueOf;
179
-
180
- if (formulaValueOf === initialValue) {
181
- let currentOtherFormItemResponses = editFormulaConfig.otherFormItemResponses;
182
- currentOtherFormItemResponses.forEach(item => {
183
- info_set_fields.forEach(formItemInner => {
184
- if (formItemInner.code === item.formItemCode) {
185
- if (item.formItemValue === 'disabled') {
186
- formItemInner.b_disabled = true;
187
- } else if (item.formItemValue === 'enabled') {
188
- formItemInner.b_disabled = false;
189
- } else {
190
- formItemInner.initialValue = item.formItemValue || data[formItemInner.display_code];
191
- }
192
- if (formItemInner.initialValue || data[formItemInner.code]) {
193
- if (formItemInner.code.indexOf('date') !== -1) {
194
- setFieldsValue({[formItemInner.code]: moment(formItemInner.initialValue || data[formItemInner.code])})
195
- if (formItemInner.code.endsWith("_date")) {
196
- data[formItemInner.code] = moment(formItemInner.initialValue || data[formItemInner.code]).valueOf();
197
- } else if (formItemInner.code.indexOf('_date$') !== -1) {
198
- data[formItemInner.code] = moment(formItem.initialValue || data[formItemInner.code]).format("YYYY-MM-DD");
199
- }
200
- } else {
201
- setFieldsValue({[formItemInner.code]: formItemInner.initialValue || data[formItemInner.code]});
202
- data[formItemInner.code] = formItemInner.initialValue || data[formItemInner.code];
203
- }
204
- }
205
- }
206
- })
207
- })
208
- }
209
-
210
- }
211
-
212
- }
148
+ buildFormItems = () => {
149
+ let {info_set_fields, ext_form_items} = this.props;
150
+ if (this.ref.current == null) {
151
+ return;
152
+ }
213
153
 
214
- }
215
- })
154
+ if (info_set_fields && info_set_fields.length > 0) {
216
155
 
217
156
  let groupNames = info_set_fields.map(item => item.belong_form_group).filter((item, index, arr) => item && item.trim().length > 0 && arr.indexOf(item) === index);
218
157
 
@@ -699,7 +638,7 @@ class FormForModify extends React.Component{
699
638
  valuePropName = "checked";
700
639
 
701
640
  if (typeof initialValue !== 'boolean') {
702
- initialValue = (initialValue || '').toLowerCase() === 'true';
641
+ initialValue = (initialValue + '' || '').toLowerCase() === 'true' || (initialValue + '' || '').toLowerCase() === '1';
703
642
  displayValue = (initialValue ? "是" : "否");
704
643
  }
705
644
 
@@ -923,6 +862,10 @@ class FormForModify extends React.Component{
923
862
  formData[config.code] = date.format(dateFormat);
924
863
  }
925
864
 
865
+ if (dateString) {
866
+ this.formItemOnChangeForFormula(config, dateString);
867
+ }
868
+
926
869
  if (callback && typeof callback === "function") {
927
870
  callback(date, dateString);
928
871
  }
@@ -995,56 +938,8 @@ class FormForModify extends React.Component{
995
938
  this.props.data[display_code] = display_value;
996
939
  }
997
940
 
998
- if (config.editFormulaConfigs && config.editFormulaConfigs.length) {
999
- let {editFormulasState} = this.state;
1000
- let {setFieldsValue, resetFields} = this.ref.current;
1001
-
1002
- if (value) {
1003
- let editFormulaItem = config.editFormulaConfigs.filter(editFormulaItem => editFormulaItem.onValueOf === value.toString())[0];
1004
- if (editFormulaItem) {
1005
- if (value) {
1006
- editFormulaItem.otherFormItemResponses.forEach(item => {
1007
- if (item.formItemValue === 'disabled') {
1008
- resetFields([item.formItemCode]);
1009
- setFieldsValue({[item.formItemCode]: null});
1010
- if (item.formItemCode.endsWith('_pk') && this.props.data[`${item.formItemCode.split('_pk')[0]}_ext_name`]) {
1011
- this.props.data[`${item.formItemCode.split('_pk')[0]}_ext_name`] = null;
1012
- } else if (item.formItemCode.indexOf('_pk$') !== -1 && this.props.data[`${item.formItemCode.split('_pk$')[0]}_ext_name$${item.formItemCode.split('_pk$')[1]}`]) {
1013
- this.props.data[`${item.formItemCode.split('_pk$')[0]}_ext_name$${item.formItemCode.split('_pk$')[1]}`] = null;
1014
- }
1015
- this.props.data[item.formItemCode] = null;
1016
- }
1017
- })
1018
- }
1019
- if (editFormulasState.filter(item => item.editFormulasStateCode === code).length) {
1020
- editFormulasState.forEach(item => {
1021
- if (item.editFormulasStateCode === code) {
1022
- item.editFormulaItem = editFormulaItem;
1023
- }
1024
- })
1025
- } else {
1026
- editFormulasState.push({editFormulasStateCode: code, editFormulaItem});
1027
- }
1028
- } else {
1029
- if (editFormulasState.filter(item => item.editFormulasStateCode === code).length) {
1030
- editFormulasState.forEach(item => {
1031
- if (item.editFormulasStateCode === code) {
1032
- item.editFormulaItem = null;
1033
- }
1034
- })
1035
- }
1036
- }
1037
- } else {
1038
- if (editFormulasState.filter(item => item.editFormulasStateCode === code).length) {
1039
- editFormulasState.forEach(item => {
1040
- if (item.editFormulasStateCode === code) {
1041
- item.editFormulaItem = null;
1042
- }
1043
- })
1044
- }
1045
- }
1046
-
1047
- this.setState({editFormulasState})
941
+ if (value) {
942
+ this.formItemOnChangeForFormula(config, value)
1048
943
  }
1049
944
 
1050
945
  if (callback && typeof callback === "function") {
@@ -1142,39 +1037,106 @@ class FormForModify extends React.Component{
1142
1037
  }
1143
1038
  }
1144
1039
 
1145
- switchOnChange(config, callback, checked, event) {
1146
- if (config.editFormulaConfigs && config.editFormulaConfigs.length) {
1147
- let {code} = config;
1148
- let {editFormulasState} = this.state;
1149
- let {setFieldsValue, resetFields} = this.ref.current;
1150
- let editFormulaItem = config.editFormulaConfigs.filter(editFormulaItem => editFormulaItem.onValueOf === checked.toString())[0];
1040
+ formItemOnChangeForFormula = (config, value) => {
1041
+ let formItemFormulaConfigs = config.editFormulaConfigs;
1042
+ if (formItemFormulaConfigs && formItemFormulaConfigs.length > 0) {
1043
+ let {fieldCodeKeyMap} = this.state;
1044
+ let {data, def_docs} = this.props;
1045
+ let {setFieldsValue} = this.ref.current;
1046
+ // value exists
1047
+ let editFormulaItem = config.editFormulaConfigs.find(editFormulaItem => editFormulaItem.onValueOf === value.toString() || editFormulaItem.onValueOf === "value");
1048
+
1151
1049
  if (editFormulaItem) {
1152
- if (!checked) {
1153
- editFormulaItem.otherFormItemResponses.forEach(item => {
1154
- resetFields([item.formItemCode]);
1155
- setFieldsValue({[item.formItemCode]: null});
1156
- if (item.formItemCode.endsWith('_pk') && this.props.data[`${item.formItemCode.split('_pk')[0]}_ext_name`]) {
1157
- this.props.data[`${item.formItemCode.split('_pk')[0]}_ext_name`] = null;
1158
- } else if (item.formItemCode.indexOf('_pk$') !== -1 && this.props.data[`${item.formItemCode.split('_pk$')[0]}_ext_name$${item.formItemCode.split('_pk$')[1]}`]) {
1159
- this.props.data[`${item.formItemCode.split('_pk$')[0]}_ext_name$${item.formItemCode.split('_pk$')[1]}`] = null;
1050
+ let otherFormItemResponses = editFormulaItem.otherFormItemResponses;
1051
+
1052
+ for (let i = 0, len = otherFormItemResponses.length; i < len; i++) {
1053
+ let otherFormItem = otherFormItemResponses[i];
1054
+ if (!otherFormItem) {
1055
+ continue;
1056
+ }
1057
+
1058
+ let {formItemCode, formItemValue} = otherFormItem;
1059
+ let otherFormItemConfig = fieldCodeKeyMap[formItemCode];
1060
+ if (!otherFormItemConfig) {
1061
+ continue;
1062
+ }
1063
+
1064
+ if (!formItemValue) {
1065
+ continue;
1066
+ }
1067
+
1068
+ let {code, display_code, ref_pk, ui_render_type} = otherFormItemConfig;
1069
+ if (FormulasValueType.Disabled == formItemValue) {
1070
+ data[code] = null;
1071
+ setFieldsValue({[code]: null});
1072
+
1073
+ if (display_code) {
1074
+ data[display_code] = null;
1075
+ setFieldsValue({[display_code]: null});
1160
1076
  }
1161
- this.props.data[item.formItemCode] = null;
1162
- })
1163
- }
1164
- if (editFormulasState.filter(item => item.editFormulasStateCode === code).length) {
1165
- editFormulasState.forEach(item => {
1166
- if (item.editFormulasStateCode === code) {
1167
- item.editFormulaItem = editFormulaItem;
1077
+
1078
+ otherFormItemConfig.b_disabled = true;
1079
+ otherFormItemConfig.b_readonly = true;
1080
+ } else if (FormulasValueType.Enabled == formItemValue) {
1081
+
1082
+ otherFormItemConfig.b_disabled = false;
1083
+ otherFormItemConfig.b_readonly = true;
1084
+ } else if (formItemValue.startsWith(FormulasValueType.Function)) {
1085
+ let formulaFunctionValue;
1086
+ if (formItemValue.search("#value#") !== -1) {
1087
+ formulaFunctionValue = eval(formItemValue.replace('#value#', `value`).replace("@", ","));
1088
+ } else {
1089
+ let formItemValueList = formItemValue.split("#");
1090
+ if (!formItemValueList || formItemValueList.length != 3) {
1091
+ console.log("formula error, detail info: formItemCode=" + formItemValue + ", formItemValue=" + formItemValue);
1092
+ continue;
1093
+ }
1094
+
1095
+ let realFormulaValue = formItemValueList[0] + `data[formItemValueList[1]]` + formItemValueList[2];
1096
+
1097
+ formulaFunctionValue = eval(realFormulaValue.replace("@", ","));
1168
1098
  }
1169
- })
1170
- } else {
1171
- editFormulasState.push({editFormulasStateCode: code, editFormulaItem});
1099
+
1100
+ if (!formulaFunctionValue) {
1101
+ console.log("formula function return null, detail info: formItemCode=" + formItemValue + ", formItemValue=" + formItemValue);
1102
+ continue;
1103
+ }
1104
+
1105
+ data[code] = formulaFunctionValue;
1106
+
1107
+ let otherFormItemValue;
1108
+ if (UI_RENDER_TYPE.DATE == ui_render_type) {
1109
+ otherFormItemValue = moment(formulaFunctionValue, "YYYY-MM-DD");
1110
+ } else {
1111
+ otherFormItemValue = formulaFunctionValue;
1112
+ }
1113
+ setFieldsValue({[code]: otherFormItemValue});
1114
+ } else {
1115
+ data[code] = formItemValue;
1116
+ setFieldsValue({[code]: formItemValue});
1117
+
1118
+ if (display_code && display_code.trim().length > 0) {
1119
+ let dictList = def_docs["def_" + ref_pk];
1120
+ if (dictList && dictList.length > 0) {
1121
+ let filteredDict = dictList.find(item => item.pk.toString() == formItemValue);
1122
+ if (filteredDict) {
1123
+ let ref_title = filteredDict.title;
1124
+
1125
+ data[display_code] = ref_title;
1126
+ setFieldsValue({[display_code]: ref_title});
1127
+ }
1128
+ }
1129
+ }
1130
+ }
1172
1131
  }
1173
- } else {
1174
- editFormulasState.push({editFormulasStateCode: code, editFormulaItem: null});
1175
1132
  }
1176
- this.setState({editFormulasState})
1133
+
1134
+ this.setState({fieldCodeKeyMap})
1177
1135
  }
1136
+ }
1137
+
1138
+ switchOnChange(config, callback, checked, event) {
1139
+ this.formItemOnChangeForFormula(config, checked);
1178
1140
 
1179
1141
  if (callback && typeof callback === "function") {
1180
1142
  callback(checked, event);
@@ -1237,7 +1199,7 @@ class FormForModify extends React.Component{
1237
1199
 
1238
1200
  render() {
1239
1201
  let {props} = this;
1240
- let {editFormulasState} = this.state;
1202
+ let {fieldCodeKeyMap} = this.state;
1241
1203
  return (
1242
1204
  <ConfigProvider locale={zhCN}>
1243
1205
  <Form
@@ -1247,7 +1209,7 @@ class FormForModify extends React.Component{
1247
1209
  scrollToFirstError
1248
1210
  onValuesChange={this.onValuesChange.bind(this)}
1249
1211
  >
1250
- {this.buildFormItems(editFormulasState)}
1212
+ {this.buildFormItems(fieldCodeKeyMap)}
1251
1213
  {this.buildExtFormItems()}
1252
1214
  </Form>
1253
1215
  </ConfigProvider>