@bchr/bchr-front-lib 0.3.102 → 0.3.106

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.
@@ -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,13 @@ 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
+ Clear: "clear",
66
+ Function: "AppFormulaFunctions"
67
+ };
68
+
60
69
  var FormForModify = /*#__PURE__*/function (_React$Component) {
61
70
  _inherits(FormForModify, _React$Component);
62
71
 
@@ -137,9 +146,8 @@ var FormForModify = /*#__PURE__*/function (_React$Component) {
137
146
  }));
138
147
  });
139
148
 
140
- _defineProperty(_assertThisInitialized(_this2), "buildFormItems", function (editFormulasState) {
149
+ _defineProperty(_assertThisInitialized(_this2), "buildFormItems", function () {
141
150
  var _this2$props2 = _this2.props,
142
- data = _this2$props2.data,
143
151
  info_set_fields = _this2$props2.info_set_fields,
144
152
  ext_form_items = _this2$props2.ext_form_items;
145
153
 
@@ -147,120 +155,7 @@ var FormForModify = /*#__PURE__*/function (_React$Component) {
147
155
  return;
148
156
  }
149
157
 
150
- var setFieldsValue = _this2.ref.current.setFieldsValue;
151
-
152
158
  if (info_set_fields && info_set_fields.length > 0) {
153
- info_set_fields.forEach(function (formItem) {
154
- formItem.initialValue = null;
155
-
156
- _this2.preParseFormItemExtConfig(formItem);
157
-
158
- if (editFormulasState && editFormulasState.length) {
159
- formItem.b_disabled = formItem.b_readonly;
160
-
161
- var _loop = function _loop(i, len) {
162
- var editFormulaStateItemCode = editFormulasState[i].editFormulasStateCode;
163
- var editFormulaStateItem = editFormulasState[i].editFormulaItem;
164
-
165
- if (editFormulaStateItem) {
166
- editFormulaStateItem.otherFormItemResponses.forEach(function (item) {
167
- if (formItem.code === item.formItemCode) {
168
- if (item.formItemValue === 'disabled') {
169
- formItem.b_disabled = true;
170
- } else if (item.formItemValue === 'enabled') {
171
- formItem.b_disabled = false;
172
- } else if (item.formItemValue.indexOf('exp') !== -1) {
173
- var expValue = '';
174
-
175
- if (isNaN(data[formItem.code])) {
176
- expValue = item.formItemValue.split('exp(')[1].split(')')[0].replace('#value#', data[formItem.code]);
177
- } else {
178
- expValue = String(item.formItemValue.split('exp(')[1].split(')')[0].replace('#value#', Number(data[formItem.code])));
179
- }
180
-
181
- formItem.initialValue = eval(expValue);
182
- } else if (item.formItemValue.indexOf('AppFormulaFunctions') !== -1) {
183
- var formulaValue = '';
184
-
185
- if (item.formItemValue.indexOf('currentDateToDeadline') !== -1) {
186
- formulaValue = eval(item.formItemValue.replace('#value#', "data[editFormulaStateItemCode], 300"));
187
- } else {
188
- formulaValue = eval(item.formItemValue.replace('#value#', data[editFormulaStateItemCode]));
189
- }
190
-
191
- if (formItem.ui_render_type === _consts.UI_RENDER_TYPE.DATE || formItem.ui_render_type === _consts.UI_RENDER_TYPE.DATE_MONTH || formItem.ui_render_type === _consts.UI_RENDER_TYPE.DATE_YEAR || formItem.ui_render_type === _consts.UI_RENDER_TYPE.DATE_TIME) {
192
- formulaValue = (0, _moment["default"])(formulaValue);
193
- }
194
-
195
- formItem.initialValue = formulaValue;
196
- } else {
197
- formItem.initialValue = item.formItemValue || data[formItem.display_code];
198
- }
199
-
200
- if (formItem.initialValue || data[formItem.code]) {
201
- if (formItem.code.indexOf('date') !== -1) {
202
- setFieldsValue(_defineProperty({}, formItem.code, (0, _moment["default"])(formItem.initialValue || data[formItem.code])));
203
-
204
- if (formItem.code.endsWith("_date")) {
205
- data[formItem.code] = (0, _moment["default"])(formItem.initialValue || data[formItem.code]).valueOf();
206
- } else if (formItem.code.indexOf('_date$') !== -1) {
207
- data[formItem.code] = (0, _moment["default"])(formItem.initialValue || data[formItem.code]).format("YYYY-MM-DD");
208
- }
209
- } else {
210
- setFieldsValue(_defineProperty({}, formItem.code, formItem.initialValue || data[formItem.code]));
211
- data[formItem.code] = formItem.initialValue || data[formItem.code];
212
- }
213
- }
214
- }
215
- });
216
- }
217
- };
218
-
219
- for (var i = 0, len = editFormulasState.length; i < len; i++) {
220
- _loop(i, len);
221
- }
222
- } else {
223
- if (formItem.editFormulaConfigs) {
224
- for (var _i = 0, _len = formItem.editFormulaConfigs.length; _i < _len; _i++) {
225
- var editFormulaConfig = formItem.editFormulaConfigs[_i];
226
- var initialValue = formItem.ui_render_type === 'switch' ? (data[formItem.code] && data[formItem.code].toString() || '').toLowerCase() !== 'true' : data[formItem.code];
227
- var formulaValueOf = formItem.ui_render_type === 'switch' ? (editFormulaConfig.onValueOf || '').toLowerCase() !== 'true' : editFormulaConfig.onValueOf;
228
-
229
- if (formulaValueOf === initialValue) {
230
- var currentOtherFormItemResponses = editFormulaConfig.otherFormItemResponses;
231
- currentOtherFormItemResponses.forEach(function (item) {
232
- info_set_fields.forEach(function (formItemInner) {
233
- if (formItemInner.code === item.formItemCode) {
234
- if (item.formItemValue === 'disabled') {
235
- formItemInner.b_disabled = true;
236
- } else if (item.formItemValue === 'enabled') {
237
- formItemInner.b_disabled = false;
238
- } else {
239
- formItemInner.initialValue = item.formItemValue || data[formItemInner.display_code];
240
- }
241
-
242
- if (formItemInner.initialValue || data[formItemInner.code]) {
243
- if (formItemInner.code.indexOf('date') !== -1) {
244
- setFieldsValue(_defineProperty({}, formItemInner.code, (0, _moment["default"])(formItemInner.initialValue || data[formItemInner.code])));
245
-
246
- if (formItemInner.code.endsWith("_date")) {
247
- data[formItemInner.code] = (0, _moment["default"])(formItemInner.initialValue || data[formItemInner.code]).valueOf();
248
- } else if (formItemInner.code.indexOf('_date$') !== -1) {
249
- data[formItemInner.code] = (0, _moment["default"])(formItem.initialValue || data[formItemInner.code]).format("YYYY-MM-DD");
250
- }
251
- } else {
252
- setFieldsValue(_defineProperty({}, formItemInner.code, formItemInner.initialValue || data[formItemInner.code]));
253
- data[formItemInner.code] = formItemInner.initialValue || data[formItemInner.code];
254
- }
255
- }
256
- }
257
- });
258
- });
259
- }
260
- }
261
- }
262
- }
263
- });
264
159
  var groupNames = info_set_fields.map(function (item) {
265
160
  return item.belong_form_group;
266
161
  }).filter(function (item, index, arr) {
@@ -340,8 +235,8 @@ var FormForModify = /*#__PURE__*/function (_React$Component) {
340
235
 
341
236
  var editFormulaConfigs = [];
342
237
 
343
- for (var _i2 = 0, _len2 = pureFormulaTextItems.length; _i2 < _len2; _i2++) {
344
- var formulaTextItem = pureFormulaTextItems[_i2];
238
+ for (var _i = 0, _len = pureFormulaTextItems.length; _i < _len; _i++) {
239
+ var formulaTextItem = pureFormulaTextItems[_i];
345
240
  var formulaChildTextItems = formulaTextItem.split("=>");
346
241
 
347
242
  if (formulaChildTextItems.length !== 2) {
@@ -799,9 +694,139 @@ var FormForModify = /*#__PURE__*/function (_React$Component) {
799
694
  return dict.title;
800
695
  });
801
696
 
697
+ _defineProperty(_assertThisInitialized(_this2), "formItemOnChangeForFormula", function (config, value) {
698
+ var formItemFormulaConfigs = config.editFormulaConfigs;
699
+
700
+ if (formItemFormulaConfigs && formItemFormulaConfigs.length > 0) {
701
+ var fieldCodeKeyMap = _this2.state.fieldCodeKeyMap;
702
+ var _this2$props4 = _this2.props,
703
+ data = _this2$props4.data,
704
+ def_docs = _this2$props4.def_docs;
705
+ var setFieldsValue = _this2.ref.current.setFieldsValue; // value exists
706
+
707
+ var editFormulaItem = config.editFormulaConfigs.find(function (editFormulaItem) {
708
+ return editFormulaItem.onValueOf === value.toString() || editFormulaItem.onValueOf === "value";
709
+ });
710
+
711
+ if (editFormulaItem) {
712
+ var otherFormItemResponses = editFormulaItem.otherFormItemResponses;
713
+
714
+ var _loop = function _loop(i, len) {
715
+ var otherFormItem = otherFormItemResponses[i];
716
+
717
+ if (!otherFormItem) {
718
+ return "continue";
719
+ }
720
+
721
+ var formItemCode = otherFormItem.formItemCode,
722
+ formItemValue = otherFormItem.formItemValue;
723
+ var otherFormItemConfig = fieldCodeKeyMap[formItemCode];
724
+
725
+ if (!otherFormItemConfig) {
726
+ return "continue";
727
+ }
728
+
729
+ if (!formItemValue) {
730
+ return "continue";
731
+ }
732
+
733
+ var code = otherFormItemConfig.code,
734
+ display_code = otherFormItemConfig.display_code,
735
+ ref_pk = otherFormItemConfig.ref_pk,
736
+ ui_render_type = otherFormItemConfig.ui_render_type;
737
+
738
+ if (FormulasValueType.Disabled == formItemValue) {
739
+ data[code] = null;
740
+ setFieldsValue(_defineProperty({}, code, null));
741
+
742
+ if (display_code) {
743
+ data[display_code] = null;
744
+ setFieldsValue(_defineProperty({}, display_code, null));
745
+ }
746
+
747
+ otherFormItemConfig.b_disabled = true;
748
+ otherFormItemConfig.b_readonly = true;
749
+ } else if (FormulasValueType.Enabled == formItemValue) {
750
+ otherFormItemConfig.b_disabled = false;
751
+ otherFormItemConfig.b_readonly = false;
752
+ } else if (FormulasValueType.Clear == formItemValue) {
753
+ data[code] = null;
754
+ setFieldsValue(_defineProperty({}, code, null));
755
+
756
+ if (display_code) {
757
+ data[display_code] = null;
758
+ setFieldsValue(_defineProperty({}, display_code, null));
759
+ }
760
+ } else if (formItemValue.startsWith(FormulasValueType.Function)) {
761
+ var formulaFunctionValue;
762
+
763
+ if (formItemValue.search("#value#") !== -1) {
764
+ formulaFunctionValue = eval(formItemValue.replace('#value#', "value").replace("@", ","));
765
+ } else {
766
+ var formItemValueList = formItemValue.split("#");
767
+
768
+ if (!formItemValueList || formItemValueList.length != 3) {
769
+ console.log("formula error, detail info: formItemCode=" + formItemValue + ", formItemValue=" + formItemValue);
770
+ return "continue";
771
+ }
772
+
773
+ var realFormulaValue = formItemValueList[0] + "data[formItemValueList[1]]" + formItemValueList[2];
774
+ formulaFunctionValue = eval(realFormulaValue.replace("@", ","));
775
+ }
776
+
777
+ if (!formulaFunctionValue) {
778
+ console.log("formula function return null, detail info: formItemCode=" + formItemValue + ", formItemValue=" + formItemValue);
779
+ return "continue";
780
+ }
781
+
782
+ data[code] = formulaFunctionValue;
783
+ var otherFormItemValue;
784
+
785
+ if (_consts.UI_RENDER_TYPE.DATE == ui_render_type) {
786
+ otherFormItemValue = (0, _moment["default"])(formulaFunctionValue, "YYYY-MM-DD");
787
+ } else {
788
+ otherFormItemValue = formulaFunctionValue;
789
+ }
790
+
791
+ setFieldsValue(_defineProperty({}, code, otherFormItemValue));
792
+ } else {
793
+ data[code] = formItemValue;
794
+ setFieldsValue(_defineProperty({}, code, formItemValue));
795
+
796
+ if (display_code && display_code.trim().length > 0) {
797
+ var dictList = def_docs["def_" + ref_pk];
798
+
799
+ if (dictList && dictList.length > 0) {
800
+ var filteredDict = dictList.find(function (item) {
801
+ return item.pk.toString() == formItemValue;
802
+ });
803
+
804
+ if (filteredDict) {
805
+ var ref_title = filteredDict.title;
806
+ data[display_code] = ref_title;
807
+ setFieldsValue(_defineProperty({}, display_code, ref_title));
808
+ }
809
+ }
810
+ }
811
+ }
812
+ };
813
+
814
+ for (var i = 0, len = otherFormItemResponses.length; i < len; i++) {
815
+ var _ret = _loop(i, len);
816
+
817
+ if (_ret === "continue") continue;
818
+ }
819
+ }
820
+
821
+ _this2.setState({
822
+ fieldCodeKeyMap: fieldCodeKeyMap
823
+ });
824
+ }
825
+ });
826
+
802
827
  _this2.ref = _this2.props.formref || /*#__PURE__*/_react["default"].createRef();
803
828
  _this2.state = {
804
- editFormulasState: []
829
+ fieldCodeKeyMap: {}
805
830
  };
806
831
  return _this2;
807
832
  }
@@ -809,32 +834,42 @@ var FormForModify = /*#__PURE__*/function (_React$Component) {
809
834
  _createClass(FormForModify, [{
810
835
  key: "componentDidMount",
811
836
  value: function componentDidMount() {
812
- var _this3 = this;
813
-
814
837
  var _this$props = this.props,
815
838
  data = _this$props.data,
816
839
  info_set_fields = _this$props.info_set_fields;
817
- var editFormulasState = this.state.editFormulasState;
818
- info_set_fields.forEach(function (formItem) {
819
- _this3.preParseFormItemExtConfig(formItem);
820
-
821
- if (formItem.editFormulaConfigs) {
822
- for (var i = 0, len = formItem.editFormulaConfigs.length; i < len; i++) {
823
- var editFormulaConfig = formItem.editFormulaConfigs[i];
824
- var initialValue = formItem.ui_render_type === 'switch' ? (data[formItem.code] && data[formItem.code].toString() || '').toLowerCase() !== 'true' : data[formItem.code];
825
- var formulaValueOf = formItem.ui_render_type === 'switch' ? (editFormulaConfig.onValueOf || '').toLowerCase() !== 'true' : editFormulaConfig.onValueOf;
826
-
827
- if (formulaValueOf === initialValue) {
828
- editFormulasState.push({
829
- editFormulasStateCode: formItem.code,
830
- editFormulaItem: editFormulaConfig
831
- });
832
- }
833
- }
840
+ var fieldCodeKeyMap = this.state.fieldCodeKeyMap;
841
+
842
+ if (info_set_fields && info_set_fields.length <= 0) {
843
+ return;
844
+ }
845
+
846
+ var fieldsLength = info_set_fields.length; // first parse formula
847
+
848
+ for (var i = 0; i < fieldsLength; i++) {
849
+ var formItem = info_set_fields[i];
850
+ this.preParseFormItemExtConfig(formItem);
851
+ formItem.b_disabled = formItem.b_readonly;
852
+ fieldCodeKeyMap[formItem.code] = formItem;
853
+ } // then initialization form item
854
+
855
+
856
+ for (var _i2 = 0; _i2 < fieldsLength; _i2++) {
857
+ var _formItem = info_set_fields[_i2];
858
+ var code = _formItem.code,
859
+ ui_render_type = _formItem.ui_render_type;
860
+ var fieldCodeValue = data[code];
861
+
862
+ if (_consts.UI_RENDER_TYPE.SWITCH == ui_render_type) {
863
+ fieldCodeValue = (fieldCodeValue + '' || '').toLowerCase() === 'true' || (fieldCodeValue + '' || '').toLowerCase() === '1' ? "true" : "false";
834
864
  }
835
- });
865
+
866
+ if (fieldCodeValue) {
867
+ this.formItemOnChangeForFormula(_formItem, fieldCodeValue);
868
+ }
869
+ }
870
+
836
871
  this.setState({
837
- editFormulasState: editFormulasState
872
+ fieldCodeKeyMap: fieldCodeKeyMap
838
873
  });
839
874
  }
840
875
  }, {
@@ -942,82 +977,14 @@ var FormForModify = /*#__PURE__*/function (_React$Component) {
942
977
  }, {
943
978
  key: "datePickerOnChange",
944
979
  value: function datePickerOnChange(config, callback, formData, dateFormat, date, dateString) {
945
- var _this4 = this;
946
-
947
- if (config.editFormulaConfigs && config.editFormulaConfigs.length) {
948
- var code = config.code;
949
- var editFormulasState = this.state.editFormulasState;
950
- var _this$ref$current = this.ref.current,
951
- setFieldsValue = _this$ref$current.setFieldsValue,
952
- resetFields = _this$ref$current.resetFields;
953
-
954
- if (dateString) {
955
- var editFormulaItem = config.editFormulaConfigs[0];
956
-
957
- if (editFormulaItem) {
958
- if (dateString) {
959
- editFormulaItem.otherFormItemResponses.forEach(function (item) {
960
- if (item.formItemValue === 'disabled') {
961
- resetFields([item.formItemCode]);
962
- setFieldsValue(_defineProperty({}, item.formItemCode, null));
963
-
964
- if (item.formItemCode.endsWith('_pk') && _this4.props.data["".concat(item.formItemCode.split('_pk')[0], "_ext_name")]) {
965
- _this4.props.data["".concat(item.formItemCode.split('_pk')[0], "_ext_name")] = null;
966
- } else if (item.formItemCode.indexOf('_pk$') !== -1 && _this4.props.data["".concat(item.formItemCode.split('_pk$')[0], "_ext_name$").concat(item.formItemCode.split('_pk$')[1])]) {
967
- _this4.props.data["".concat(item.formItemCode.split('_pk$')[0], "_ext_name$").concat(item.formItemCode.split('_pk$')[1])] = null;
968
- }
969
-
970
- _this4.props.data[item.formItemCode] = null;
971
- }
972
- });
973
- }
974
-
975
- if (editFormulasState.filter(function (item) {
976
- return item.editFormulasStateCode === code;
977
- }).length) {
978
- editFormulasState.forEach(function (item) {
979
- if (item.editFormulasStateCode === code) {
980
- item.editFormulaItem = editFormulaItem;
981
- }
982
- });
983
- } else {
984
- editFormulasState.push({
985
- editFormulasStateCode: code,
986
- editFormulaItem: editFormulaItem
987
- });
988
- }
989
- } else {
990
- if (editFormulasState.filter(function (item) {
991
- return item.editFormulasStateCode === code;
992
- }).length) {
993
- editFormulasState.forEach(function (item) {
994
- if (item.editFormulasStateCode === code) {
995
- item.editFormulaItem = null;
996
- }
997
- });
998
- }
999
- }
1000
- } else {
1001
- if (editFormulasState.filter(function (item) {
1002
- return item.editFormulasStateCode === code;
1003
- }).length) {
1004
- editFormulasState.forEach(function (item) {
1005
- if (item.editFormulasStateCode === code) {
1006
- item.editFormulaItem = null;
1007
- }
1008
- });
1009
- }
1010
- }
1011
-
1012
- this.setState({
1013
- editFormulasState: editFormulasState
1014
- });
1015
- }
1016
-
1017
980
  if (dateFormat != null) {
1018
981
  formData[config.code] = date.format(dateFormat);
1019
982
  }
1020
983
 
984
+ if (dateString) {
985
+ this.formItemOnChangeForFormula(config, dateString);
986
+ }
987
+
1021
988
  if (callback && typeof callback === "function") {
1022
989
  callback(date, dateString);
1023
990
  }
@@ -1047,8 +1014,6 @@ var FormForModify = /*#__PURE__*/function (_React$Component) {
1047
1014
  }, {
1048
1015
  key: "selectOnChange",
1049
1016
  value: function selectOnChange(config, callback, value, option) {
1050
- var _this5 = this;
1051
-
1052
1017
  var display_code = config.display_code,
1053
1018
  code = config.code;
1054
1019
 
@@ -1092,75 +1057,8 @@ var FormForModify = /*#__PURE__*/function (_React$Component) {
1092
1057
  this.props.data[display_code] = display_value;
1093
1058
  }
1094
1059
 
1095
- if (config.editFormulaConfigs && config.editFormulaConfigs.length) {
1096
- var editFormulasState = this.state.editFormulasState;
1097
- var _this$ref$current2 = this.ref.current,
1098
- setFieldsValue = _this$ref$current2.setFieldsValue,
1099
- resetFields = _this$ref$current2.resetFields;
1100
-
1101
- if (value) {
1102
- var editFormulaItem = config.editFormulaConfigs.filter(function (editFormulaItem) {
1103
- return editFormulaItem.onValueOf === value.toString();
1104
- })[0];
1105
-
1106
- if (editFormulaItem) {
1107
- if (value) {
1108
- editFormulaItem.otherFormItemResponses.forEach(function (item) {
1109
- if (item.formItemValue === 'disabled') {
1110
- resetFields([item.formItemCode]);
1111
- setFieldsValue(_defineProperty({}, item.formItemCode, null));
1112
-
1113
- if (item.formItemCode.endsWith('_pk') && _this5.props.data["".concat(item.formItemCode.split('_pk')[0], "_ext_name")]) {
1114
- _this5.props.data["".concat(item.formItemCode.split('_pk')[0], "_ext_name")] = null;
1115
- } else if (item.formItemCode.indexOf('_pk$') !== -1 && _this5.props.data["".concat(item.formItemCode.split('_pk$')[0], "_ext_name$").concat(item.formItemCode.split('_pk$')[1])]) {
1116
- _this5.props.data["".concat(item.formItemCode.split('_pk$')[0], "_ext_name$").concat(item.formItemCode.split('_pk$')[1])] = null;
1117
- }
1118
-
1119
- _this5.props.data[item.formItemCode] = null;
1120
- }
1121
- });
1122
- }
1123
-
1124
- if (editFormulasState.filter(function (item) {
1125
- return item.editFormulasStateCode === code;
1126
- }).length) {
1127
- editFormulasState.forEach(function (item) {
1128
- if (item.editFormulasStateCode === code) {
1129
- item.editFormulaItem = editFormulaItem;
1130
- }
1131
- });
1132
- } else {
1133
- editFormulasState.push({
1134
- editFormulasStateCode: code,
1135
- editFormulaItem: editFormulaItem
1136
- });
1137
- }
1138
- } else {
1139
- if (editFormulasState.filter(function (item) {
1140
- return item.editFormulasStateCode === code;
1141
- }).length) {
1142
- editFormulasState.forEach(function (item) {
1143
- if (item.editFormulasStateCode === code) {
1144
- item.editFormulaItem = null;
1145
- }
1146
- });
1147
- }
1148
- }
1149
- } else {
1150
- if (editFormulasState.filter(function (item) {
1151
- return item.editFormulasStateCode === code;
1152
- }).length) {
1153
- editFormulasState.forEach(function (item) {
1154
- if (item.editFormulasStateCode === code) {
1155
- item.editFormulaItem = null;
1156
- }
1157
- });
1158
- }
1159
- }
1160
-
1161
- this.setState({
1162
- editFormulasState: editFormulasState
1163
- });
1060
+ if (value) {
1061
+ this.formItemOnChangeForFormula(config, value);
1164
1062
  }
1165
1063
 
1166
1064
  if (callback && typeof callback === "function") {
@@ -1192,7 +1090,7 @@ var FormForModify = /*#__PURE__*/function (_React$Component) {
1192
1090
  }, {
1193
1091
  key: "buildTreeNode",
1194
1092
  value: function buildTreeNode(defNodes) {
1195
- var _this6 = this;
1093
+ var _this3 = this;
1196
1094
 
1197
1095
  if (!defNodes || defNodes.length === 0) {
1198
1096
  return null;
@@ -1213,7 +1111,7 @@ var FormForModify = /*#__PURE__*/function (_React$Component) {
1213
1111
  ext_attr_value: ext_attr_value,
1214
1112
  selectable: item.selectable,
1215
1113
  prop: ext_attr_value
1216
- }, _this6.buildTreeNode(item.children));
1114
+ }, _this3.buildTreeNode(item.children));
1217
1115
  });
1218
1116
  }
1219
1117
  }, {
@@ -1270,59 +1168,7 @@ var FormForModify = /*#__PURE__*/function (_React$Component) {
1270
1168
  }, {
1271
1169
  key: "switchOnChange",
1272
1170
  value: function switchOnChange(config, callback, checked, event) {
1273
- var _this7 = this;
1274
-
1275
- if (config.editFormulaConfigs && config.editFormulaConfigs.length) {
1276
- var code = config.code;
1277
- var editFormulasState = this.state.editFormulasState;
1278
- var _this$ref$current3 = this.ref.current,
1279
- setFieldsValue = _this$ref$current3.setFieldsValue,
1280
- resetFields = _this$ref$current3.resetFields;
1281
- var editFormulaItem = config.editFormulaConfigs.filter(function (editFormulaItem) {
1282
- return editFormulaItem.onValueOf === checked.toString();
1283
- })[0];
1284
-
1285
- if (editFormulaItem) {
1286
- if (!checked) {
1287
- editFormulaItem.otherFormItemResponses.forEach(function (item) {
1288
- resetFields([item.formItemCode]);
1289
- setFieldsValue(_defineProperty({}, item.formItemCode, null));
1290
-
1291
- if (item.formItemCode.endsWith('_pk') && _this7.props.data["".concat(item.formItemCode.split('_pk')[0], "_ext_name")]) {
1292
- _this7.props.data["".concat(item.formItemCode.split('_pk')[0], "_ext_name")] = null;
1293
- } else if (item.formItemCode.indexOf('_pk$') !== -1 && _this7.props.data["".concat(item.formItemCode.split('_pk$')[0], "_ext_name$").concat(item.formItemCode.split('_pk$')[1])]) {
1294
- _this7.props.data["".concat(item.formItemCode.split('_pk$')[0], "_ext_name$").concat(item.formItemCode.split('_pk$')[1])] = null;
1295
- }
1296
-
1297
- _this7.props.data[item.formItemCode] = null;
1298
- });
1299
- }
1300
-
1301
- if (editFormulasState.filter(function (item) {
1302
- return item.editFormulasStateCode === code;
1303
- }).length) {
1304
- editFormulasState.forEach(function (item) {
1305
- if (item.editFormulasStateCode === code) {
1306
- item.editFormulaItem = editFormulaItem;
1307
- }
1308
- });
1309
- } else {
1310
- editFormulasState.push({
1311
- editFormulasStateCode: code,
1312
- editFormulaItem: editFormulaItem
1313
- });
1314
- }
1315
- } else {
1316
- editFormulasState.push({
1317
- editFormulasStateCode: code,
1318
- editFormulaItem: null
1319
- });
1320
- }
1321
-
1322
- this.setState({
1323
- editFormulasState: editFormulasState
1324
- });
1325
- }
1171
+ this.formItemOnChangeForFormula(config, checked);
1326
1172
 
1327
1173
  if (callback && typeof callback === "function") {
1328
1174
  callback(checked, event);
@@ -1420,7 +1266,7 @@ var FormForModify = /*#__PURE__*/function (_React$Component) {
1420
1266
  key: "render",
1421
1267
  value: function render() {
1422
1268
  var props = this.props;
1423
- var editFormulasState = this.state.editFormulasState;
1269
+ var fieldCodeKeyMap = this.state.fieldCodeKeyMap;
1424
1270
  return /*#__PURE__*/_react["default"].createElement(_antd.ConfigProvider, {
1425
1271
  locale: _zh_CN["default"]
1426
1272
  }, /*#__PURE__*/_react["default"].createElement(_antd.Form, _extends({}, props, {
@@ -1428,7 +1274,7 @@ var FormForModify = /*#__PURE__*/function (_React$Component) {
1428
1274
  ref: this.ref,
1429
1275
  scrollToFirstError: true,
1430
1276
  onValuesChange: this.onValuesChange.bind(this)
1431
- }), this.buildFormItems(editFormulasState), this.buildExtFormItems()));
1277
+ }), this.buildFormItems(fieldCodeKeyMap), this.buildExtFormItems()));
1432
1278
  }
1433
1279
  }]);
1434
1280
 
@@ -131,22 +131,24 @@ var HttpService = /*#__PURE__*/function () {
131
131
  rpcMethodName = "";
132
132
  }
133
133
 
134
- if (jsonObject) {
135
- ajaxOptions.data = jsonObject;
136
- }
134
+ if (!this.__checkJSONObjectSecurity(jsonObject)) {
135
+ if (jsonObject) {
136
+ ajaxOptions.data = jsonObject;
137
+ }
137
138
 
138
- if (ajaxOptions.rpcMethodName) {
139
- delete ajaxOptions.rpcMethodName;
140
- }
139
+ if (ajaxOptions.rpcMethodName) {
140
+ delete ajaxOptions.rpcMethodName;
141
+ }
141
142
 
142
- ajaxOptions.type = "post";
143
- ajaxOptions.dataType = "json";
143
+ ajaxOptions.type = "post";
144
+ ajaxOptions.dataType = "json";
144
145
 
145
- if (!ajaxOptions.url) {
146
- ajaxOptions.url = this.requestContextPath + rpcMethodName;
147
- }
146
+ if (!ajaxOptions.url) {
147
+ ajaxOptions.url = this.requestContextPath + rpcMethodName;
148
+ }
148
149
 
149
- return _jquery["default"].ajax(ajaxOptions);
150
+ return _jquery["default"].ajax(ajaxOptions);
151
+ }
150
152
  }
151
153
  }, {
152
154
  key: "__postForMock",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bchr/bchr-front-lib",
3
- "version": "0.3.102",
3
+ "version": "0.3.106",
4
4
  "description": "bchr front lib",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {