@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.
@@ -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
+ };
@@ -22,6 +22,14 @@ 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
+ Clear : "clear",
31
+ Function : "AppFormulaFunctions",
32
+ }
25
33
 
26
34
  class FormForModify extends React.Component{
27
35
  constructor(props) {
@@ -30,28 +38,48 @@ class FormForModify extends React.Component{
30
38
  this.ref = this.props.formref || React.createRef();
31
39
 
32
40
  this.state = {
33
- editFormulasState: []
41
+ fieldCodeKeyMap: {},
34
42
  }
35
43
  }
36
44
 
37
45
  componentDidMount() {
38
46
  let {data, info_set_fields} = this.props;
39
- let {editFormulasState} = this.state;
40
- info_set_fields.forEach(formItem => {
47
+ let {fieldCodeKeyMap} = this.state;
48
+
49
+ if (info_set_fields && info_set_fields.length <= 0) {
50
+ return;
51
+ }
52
+
53
+ let fieldsLength = info_set_fields.length;
54
+ // first parse formula
55
+ for (let i = 0; i < fieldsLength; i++) {
56
+ let formItem = info_set_fields[i];
57
+
41
58
  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
- }
59
+
60
+ formItem.b_disabled = formItem.b_readonly;
61
+ fieldCodeKeyMap[formItem.code] = formItem;
62
+ }
63
+
64
+ // then initialization form item
65
+ for (let i = 0; i < fieldsLength; i++) {
66
+ let formItem = info_set_fields[i];
67
+
68
+ let {code, ui_render_type} = formItem;
69
+ let fieldCodeValue = data[code];
70
+
71
+ if (UI_RENDER_TYPE.SWITCH == ui_render_type) {
72
+ fieldCodeValue = (((fieldCodeValue + '' || '').toLowerCase() === 'true' || (fieldCodeValue + '' || '').toLowerCase() === '1') ? "true" : "false");
52
73
  }
74
+
75
+ if (fieldCodeValue) {
76
+ this.formItemOnChangeForFormula(formItem, fieldCodeValue);
77
+ }
78
+ }
79
+
80
+ this.setState({
81
+ fieldCodeKeyMap,
53
82
  })
54
- this.setState({editFormulasState})
55
83
  }
56
84
 
57
85
  buildExtFormItems = () => {
@@ -129,114 +157,13 @@ class FormForModify extends React.Component{
129
157
  )
130
158
  }
131
159
 
132
- buildFormItems = (editFormulasState) => {
133
- let {data, info_set_fields, ext_form_items} = this.props;
160
+ buildFormItems = () => {
161
+ let {info_set_fields, ext_form_items} = this.props;
134
162
  if (this.ref.current == null) {
135
163
  return;
136
164
  }
137
165
 
138
- let {setFieldsValue} = this.ref.current;
139
166
  if (info_set_fields && info_set_fields.length > 0) {
140
- info_set_fields.forEach(formItem => {
141
- formItem.initialValue = null;
142
-
143
- this.preParseFormItemExtConfig(formItem);
144
-
145
- if (editFormulasState && editFormulasState.length) {
146
- formItem.b_disabled = formItem.b_readonly;
147
- for (let i = 0, len = editFormulasState.length; i < len; i++) {
148
- let editFormulaStateItemCode = editFormulasState[i].editFormulasStateCode;
149
- let editFormulaStateItem = editFormulasState[i].editFormulaItem;
150
- if (editFormulaStateItem) {
151
- editFormulaStateItem.otherFormItemResponses.forEach(item => {
152
- if (formItem.code === item.formItemCode) {
153
- if (item.formItemValue === 'disabled') {
154
- formItem.b_disabled = true;
155
- } else if (item.formItemValue === 'enabled') {
156
- formItem.b_disabled = false;
157
- } else if (item.formItemValue.indexOf('exp') !== -1) {
158
- let expValue = '';
159
- if (isNaN(data[formItem.code])) {
160
- expValue = item.formItemValue.split('exp(')[1].split(')')[0].replace('#value#', data[formItem.code]);
161
- } else {
162
- expValue = String(item.formItemValue.split('exp(')[1].split(')')[0].replace('#value#', Number(data[formItem.code])));
163
- }
164
- formItem.initialValue = eval(expValue);
165
- } else if (item.formItemValue.indexOf('AppFormulaFunctions') !== -1) {
166
- let formulaValue = '';
167
- if (item.formItemValue.indexOf('currentDateToDeadline') !== -1) {
168
- formulaValue = eval(item.formItemValue.replace('#value#', `data[editFormulaStateItemCode], 300`))
169
- } else {
170
- formulaValue = eval(item.formItemValue.replace('#value#', data[editFormulaStateItemCode]))
171
- }
172
- if (formItem.ui_render_type === UI_RENDER_TYPE.DATE || formItem.ui_render_type === UI_RENDER_TYPE.DATE_MONTH || formItem.ui_render_type === UI_RENDER_TYPE.DATE_YEAR || formItem.ui_render_type === UI_RENDER_TYPE.DATE_TIME) {
173
- formulaValue = moment(formulaValue);
174
- }
175
- formItem.initialValue = formulaValue;
176
- } else {
177
- formItem.initialValue = item.formItemValue || data[formItem.display_code];
178
- }
179
- if (formItem.initialValue || data[formItem.code]) {
180
- if (formItem.code.indexOf('date') !== -1) {
181
- setFieldsValue({[formItem.code]: moment(formItem.initialValue || data[formItem.code])});
182
- if (formItem.code.endsWith("_date")) {
183
- data[formItem.code] = moment(formItem.initialValue || data[formItem.code]).valueOf();
184
- } else if (formItem.code.indexOf('_date$') !== -1) {
185
- data[formItem.code] = moment(formItem.initialValue || data[formItem.code]).format("YYYY-MM-DD");
186
- }
187
- } else {
188
- setFieldsValue({[formItem.code]: formItem.initialValue || data[formItem.code]});
189
- data[formItem.code] = formItem.initialValue || data[formItem.code];
190
- }
191
- }
192
- }
193
- })
194
- }
195
- }
196
-
197
- } else {
198
- if (formItem.editFormulaConfigs) {
199
- for (let i = 0, len = formItem.editFormulaConfigs.length; i < len; i++) {
200
- let editFormulaConfig = formItem.editFormulaConfigs[i];
201
- let initialValue = formItem.ui_render_type === 'switch' ? ((data[formItem.code] && data[formItem.code].toString()) || '').toLowerCase() !== 'true' : data[formItem.code];
202
- let formulaValueOf = formItem.ui_render_type === 'switch' ? (editFormulaConfig.onValueOf || '').toLowerCase() !== 'true' : editFormulaConfig.onValueOf;
203
-
204
- if (formulaValueOf === initialValue) {
205
- let currentOtherFormItemResponses = editFormulaConfig.otherFormItemResponses;
206
- currentOtherFormItemResponses.forEach(item => {
207
- info_set_fields.forEach(formItemInner => {
208
- if (formItemInner.code === item.formItemCode) {
209
- if (item.formItemValue === 'disabled') {
210
- formItemInner.b_disabled = true;
211
- } else if (item.formItemValue === 'enabled') {
212
- formItemInner.b_disabled = false;
213
- } else {
214
- formItemInner.initialValue = item.formItemValue || data[formItemInner.display_code];
215
- }
216
- if (formItemInner.initialValue || data[formItemInner.code]) {
217
- if (formItemInner.code.indexOf('date') !== -1) {
218
- setFieldsValue({[formItemInner.code]: moment(formItemInner.initialValue || data[formItemInner.code])})
219
- if (formItemInner.code.endsWith("_date")) {
220
- data[formItemInner.code] = moment(formItemInner.initialValue || data[formItemInner.code]).valueOf();
221
- } else if (formItemInner.code.indexOf('_date$') !== -1) {
222
- data[formItemInner.code] = moment(formItem.initialValue || data[formItemInner.code]).format("YYYY-MM-DD");
223
- }
224
- } else {
225
- setFieldsValue({[formItemInner.code]: formItemInner.initialValue || data[formItemInner.code]});
226
- data[formItemInner.code] = formItemInner.initialValue || data[formItemInner.code];
227
- }
228
- }
229
- }
230
- })
231
- })
232
- }
233
-
234
- }
235
-
236
- }
237
-
238
- }
239
- })
240
167
 
241
168
  let groupNames = info_set_fields.map(item => item.belong_form_group).filter((item, index, arr) => item && item.trim().length > 0 && arr.indexOf(item) === index);
242
169
 
@@ -943,61 +870,14 @@ class FormForModify extends React.Component{
943
870
  }
944
871
 
945
872
  datePickerOnChange(config, callback, formData, dateFormat, date, dateString) {
946
- if (config.editFormulaConfigs && config.editFormulaConfigs.length) {
947
- let {code} = config;
948
- let {editFormulasState} = this.state;
949
- let {setFieldsValue, resetFields} = this.ref.current;
950
- if (dateString) {
951
- let editFormulaItem = config.editFormulaConfigs[0];
952
- if (editFormulaItem) {
953
- if (dateString) {
954
- editFormulaItem.otherFormItemResponses.forEach(item => {
955
- if (item.formItemValue === 'disabled') {
956
- resetFields([item.formItemCode]);
957
- setFieldsValue({[item.formItemCode]: null});
958
- if (item.formItemCode.endsWith('_pk') && this.props.data[`${item.formItemCode.split('_pk')[0]}_ext_name`]) {
959
- this.props.data[`${item.formItemCode.split('_pk')[0]}_ext_name`] = null;
960
- } else if (item.formItemCode.indexOf('_pk$') !== -1 && this.props.data[`${item.formItemCode.split('_pk$')[0]}_ext_name$${item.formItemCode.split('_pk$')[1]}`]) {
961
- this.props.data[`${item.formItemCode.split('_pk$')[0]}_ext_name$${item.formItemCode.split('_pk$')[1]}`] = null;
962
- }
963
- this.props.data[item.formItemCode] = null;
964
- }
965
- })
966
- }
967
- if (editFormulasState.filter(item => item.editFormulasStateCode === code).length) {
968
- editFormulasState.forEach(item => {
969
- if (item.editFormulasStateCode === code) {
970
- item.editFormulaItem = editFormulaItem;
971
- }
972
- })
973
- } else {
974
- editFormulasState.push({editFormulasStateCode: code, editFormulaItem});
975
- }
976
- } else {
977
- if (editFormulasState.filter(item => item.editFormulasStateCode === code).length) {
978
- editFormulasState.forEach(item => {
979
- if (item.editFormulasStateCode === code) {
980
- item.editFormulaItem = null;
981
- }
982
- })
983
- }
984
- }
985
- } else {
986
- if (editFormulasState.filter(item => item.editFormulasStateCode === code).length) {
987
- editFormulasState.forEach(item => {
988
- if (item.editFormulasStateCode === code) {
989
- item.editFormulaItem = null;
990
- }
991
- })
992
- }
993
- }
994
- this.setState({editFormulasState})
995
- }
996
-
997
873
  if (dateFormat != null) {
998
874
  formData[config.code] = date.format(dateFormat);
999
875
  }
1000
876
 
877
+ if (dateString) {
878
+ this.formItemOnChangeForFormula(config, dateString);
879
+ }
880
+
1001
881
  if (callback && typeof callback === "function") {
1002
882
  callback(date, dateString);
1003
883
  }
@@ -1070,56 +950,8 @@ class FormForModify extends React.Component{
1070
950
  this.props.data[display_code] = display_value;
1071
951
  }
1072
952
 
1073
- if (config.editFormulaConfigs && config.editFormulaConfigs.length) {
1074
- let {editFormulasState} = this.state;
1075
- let {setFieldsValue, resetFields} = this.ref.current;
1076
-
1077
- if (value) {
1078
- let editFormulaItem = config.editFormulaConfigs.filter(editFormulaItem => editFormulaItem.onValueOf === value.toString())[0];
1079
- if (editFormulaItem) {
1080
- if (value) {
1081
- editFormulaItem.otherFormItemResponses.forEach(item => {
1082
- if (item.formItemValue === 'disabled') {
1083
- resetFields([item.formItemCode]);
1084
- setFieldsValue({[item.formItemCode]: null});
1085
- if (item.formItemCode.endsWith('_pk') && this.props.data[`${item.formItemCode.split('_pk')[0]}_ext_name`]) {
1086
- this.props.data[`${item.formItemCode.split('_pk')[0]}_ext_name`] = null;
1087
- } else if (item.formItemCode.indexOf('_pk$') !== -1 && this.props.data[`${item.formItemCode.split('_pk$')[0]}_ext_name$${item.formItemCode.split('_pk$')[1]}`]) {
1088
- this.props.data[`${item.formItemCode.split('_pk$')[0]}_ext_name$${item.formItemCode.split('_pk$')[1]}`] = null;
1089
- }
1090
- this.props.data[item.formItemCode] = null;
1091
- }
1092
- })
1093
- }
1094
- if (editFormulasState.filter(item => item.editFormulasStateCode === code).length) {
1095
- editFormulasState.forEach(item => {
1096
- if (item.editFormulasStateCode === code) {
1097
- item.editFormulaItem = editFormulaItem;
1098
- }
1099
- })
1100
- } else {
1101
- editFormulasState.push({editFormulasStateCode: code, editFormulaItem});
1102
- }
1103
- } else {
1104
- if (editFormulasState.filter(item => item.editFormulasStateCode === code).length) {
1105
- editFormulasState.forEach(item => {
1106
- if (item.editFormulasStateCode === code) {
1107
- item.editFormulaItem = null;
1108
- }
1109
- })
1110
- }
1111
- }
1112
- } else {
1113
- if (editFormulasState.filter(item => item.editFormulasStateCode === code).length) {
1114
- editFormulasState.forEach(item => {
1115
- if (item.editFormulasStateCode === code) {
1116
- item.editFormulaItem = null;
1117
- }
1118
- })
1119
- }
1120
- }
1121
-
1122
- this.setState({editFormulasState})
953
+ if (value) {
954
+ this.formItemOnChangeForFormula(config, value)
1123
955
  }
1124
956
 
1125
957
  if (callback && typeof callback === "function") {
@@ -1217,39 +1049,114 @@ class FormForModify extends React.Component{
1217
1049
  }
1218
1050
  }
1219
1051
 
1220
- switchOnChange(config, callback, checked, event) {
1221
- if (config.editFormulaConfigs && config.editFormulaConfigs.length) {
1222
- let {code} = config;
1223
- let {editFormulasState} = this.state;
1224
- let {setFieldsValue, resetFields} = this.ref.current;
1225
- let editFormulaItem = config.editFormulaConfigs.filter(editFormulaItem => editFormulaItem.onValueOf === checked.toString())[0];
1052
+ formItemOnChangeForFormula = (config, value) => {
1053
+ let formItemFormulaConfigs = config.editFormulaConfigs;
1054
+ if (formItemFormulaConfigs && formItemFormulaConfigs.length > 0) {
1055
+ let {fieldCodeKeyMap} = this.state;
1056
+ let {data, def_docs} = this.props;
1057
+ let {setFieldsValue} = this.ref.current;
1058
+ // value exists
1059
+ let editFormulaItem = config.editFormulaConfigs.find(editFormulaItem => editFormulaItem.onValueOf === value.toString() || editFormulaItem.onValueOf === "value");
1060
+
1226
1061
  if (editFormulaItem) {
1227
- if (!checked) {
1228
- editFormulaItem.otherFormItemResponses.forEach(item => {
1229
- resetFields([item.formItemCode]);
1230
- setFieldsValue({[item.formItemCode]: null});
1231
- if (item.formItemCode.endsWith('_pk') && this.props.data[`${item.formItemCode.split('_pk')[0]}_ext_name`]) {
1232
- this.props.data[`${item.formItemCode.split('_pk')[0]}_ext_name`] = null;
1233
- } else if (item.formItemCode.indexOf('_pk$') !== -1 && this.props.data[`${item.formItemCode.split('_pk$')[0]}_ext_name$${item.formItemCode.split('_pk$')[1]}`]) {
1234
- this.props.data[`${item.formItemCode.split('_pk$')[0]}_ext_name$${item.formItemCode.split('_pk$')[1]}`] = null;
1062
+ let otherFormItemResponses = editFormulaItem.otherFormItemResponses;
1063
+
1064
+ for (let i = 0, len = otherFormItemResponses.length; i < len; i++) {
1065
+ let otherFormItem = otherFormItemResponses[i];
1066
+ if (!otherFormItem) {
1067
+ continue;
1068
+ }
1069
+
1070
+ let {formItemCode, formItemValue} = otherFormItem;
1071
+ let otherFormItemConfig = fieldCodeKeyMap[formItemCode];
1072
+ if (!otherFormItemConfig) {
1073
+ continue;
1074
+ }
1075
+
1076
+ if (!formItemValue) {
1077
+ continue;
1078
+ }
1079
+
1080
+ let {code, display_code, ref_pk, ui_render_type} = otherFormItemConfig;
1081
+ if (FormulasValueType.Disabled == formItemValue) {
1082
+ data[code] = null;
1083
+ setFieldsValue({[code]: null});
1084
+
1085
+ if (display_code) {
1086
+ data[display_code] = null;
1087
+ setFieldsValue({[display_code]: null});
1235
1088
  }
1236
- this.props.data[item.formItemCode] = null;
1237
- })
1238
- }
1239
- if (editFormulasState.filter(item => item.editFormulasStateCode === code).length) {
1240
- editFormulasState.forEach(item => {
1241
- if (item.editFormulasStateCode === code) {
1242
- item.editFormulaItem = editFormulaItem;
1089
+
1090
+ otherFormItemConfig.b_disabled = true;
1091
+ otherFormItemConfig.b_readonly = true;
1092
+ } else if (FormulasValueType.Enabled == formItemValue) {
1093
+
1094
+ otherFormItemConfig.b_disabled = false;
1095
+ otherFormItemConfig.b_readonly = false;
1096
+ } else if (FormulasValueType.Clear == formItemValue) {
1097
+ data[code] = null;
1098
+ setFieldsValue({[code]: null});
1099
+
1100
+ if (display_code) {
1101
+ data[display_code] = null;
1102
+ setFieldsValue({[display_code]: null});
1243
1103
  }
1244
- })
1245
- } else {
1246
- editFormulasState.push({editFormulasStateCode: code, editFormulaItem});
1104
+ } else if (formItemValue.startsWith(FormulasValueType.Function)) {
1105
+ let formulaFunctionValue;
1106
+ if (formItemValue.search("#value#") !== -1) {
1107
+ formulaFunctionValue = eval(formItemValue.replace('#value#', `value`).replace("@", ","));
1108
+ } else {
1109
+ let formItemValueList = formItemValue.split("#");
1110
+ if (!formItemValueList || formItemValueList.length != 3) {
1111
+ console.log("formula error, detail info: formItemCode=" + formItemValue + ", formItemValue=" + formItemValue);
1112
+ continue;
1113
+ }
1114
+
1115
+ let realFormulaValue = formItemValueList[0] + `data[formItemValueList[1]]` + formItemValueList[2];
1116
+
1117
+ formulaFunctionValue = eval(realFormulaValue.replace("@", ","));
1118
+ }
1119
+
1120
+ if (!formulaFunctionValue) {
1121
+ console.log("formula function return null, detail info: formItemCode=" + formItemValue + ", formItemValue=" + formItemValue);
1122
+ continue;
1123
+ }
1124
+
1125
+ data[code] = formulaFunctionValue;
1126
+
1127
+ let otherFormItemValue;
1128
+ if (UI_RENDER_TYPE.DATE == ui_render_type) {
1129
+ otherFormItemValue = moment(formulaFunctionValue, "YYYY-MM-DD");
1130
+ } else {
1131
+ otherFormItemValue = formulaFunctionValue;
1132
+ }
1133
+ setFieldsValue({[code]: otherFormItemValue});
1134
+ } else {
1135
+ data[code] = formItemValue;
1136
+ setFieldsValue({[code]: formItemValue});
1137
+
1138
+ if (display_code && display_code.trim().length > 0) {
1139
+ let dictList = def_docs["def_" + ref_pk];
1140
+ if (dictList && dictList.length > 0) {
1141
+ let filteredDict = dictList.find(item => item.pk.toString() == formItemValue);
1142
+ if (filteredDict) {
1143
+ let ref_title = filteredDict.title;
1144
+
1145
+ data[display_code] = ref_title;
1146
+ setFieldsValue({[display_code]: ref_title});
1147
+ }
1148
+ }
1149
+ }
1150
+ }
1247
1151
  }
1248
- } else {
1249
- editFormulasState.push({editFormulasStateCode: code, editFormulaItem: null});
1250
1152
  }
1251
- this.setState({editFormulasState})
1153
+
1154
+ this.setState({fieldCodeKeyMap})
1252
1155
  }
1156
+ }
1157
+
1158
+ switchOnChange(config, callback, checked, event) {
1159
+ this.formItemOnChangeForFormula(config, checked);
1253
1160
 
1254
1161
  if (callback && typeof callback === "function") {
1255
1162
  callback(checked, event);
@@ -1312,7 +1219,7 @@ class FormForModify extends React.Component{
1312
1219
 
1313
1220
  render() {
1314
1221
  let {props} = this;
1315
- let {editFormulasState} = this.state;
1222
+ let {fieldCodeKeyMap} = this.state;
1316
1223
  return (
1317
1224
  <ConfigProvider locale={zhCN}>
1318
1225
  <Form
@@ -1322,7 +1229,7 @@ class FormForModify extends React.Component{
1322
1229
  scrollToFirstError
1323
1230
  onValuesChange={this.onValuesChange.bind(this)}
1324
1231
  >
1325
- {this.buildFormItems(editFormulasState)}
1232
+ {this.buildFormItems(fieldCodeKeyMap)}
1326
1233
  {this.buildExtFormItems()}
1327
1234
  </Form>
1328
1235
  </ConfigProvider>
@@ -114,22 +114,24 @@ class HttpService {
114
114
  rpcMethodName = "";
115
115
  }
116
116
 
117
- if (jsonObject) {
118
- ajaxOptions.data = jsonObject;
119
- }
117
+ if (!this.__checkJSONObjectSecurity(jsonObject)) {
118
+ if (jsonObject) {
119
+ ajaxOptions.data = jsonObject;
120
+ }
120
121
 
121
- if (ajaxOptions.rpcMethodName) {
122
- delete ajaxOptions.rpcMethodName;
123
- }
122
+ if (ajaxOptions.rpcMethodName) {
123
+ delete ajaxOptions.rpcMethodName;
124
+ }
124
125
 
125
- ajaxOptions.type = "post";
126
- ajaxOptions.dataType = "json";
126
+ ajaxOptions.type = "post";
127
+ ajaxOptions.dataType = "json";
127
128
 
128
- if (!ajaxOptions.url) {
129
- ajaxOptions.url = this.requestContextPath + rpcMethodName;
130
- }
129
+ if (!ajaxOptions.url) {
130
+ ajaxOptions.url = this.requestContextPath + rpcMethodName;
131
+ }
131
132
 
132
- return $.ajax(ajaxOptions);
133
+ return $.ajax(ajaxOptions);
134
+ }
133
135
  }
134
136
 
135
137
  __postForMock(mockOptions) {