@bchr/bchr-front-lib 0.3.100 → 0.3.104
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/base/AppFormulaFunctions.js +45 -23
- package/lib/base/layout/ui_tpl/form/FormForBrowse.js +1 -1
- package/lib/base/layout/ui_tpl/form/FormForModify.js +171 -239
- package/lib/services/HttpService.js +14 -12
- package/package.json +1 -1
- package/src/base/AppFormulaFunctions.js +48 -24
- package/src/base/layout/ui_tpl/form/FormForBrowse.js +1 -1
- package/src/base/layout/ui_tpl/form/FormForModify.js +139 -177
- package/src/services/HttpService.js +14 -12
|
@@ -1,26 +1,48 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
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,9 +145,8 @@ var FormForModify = /*#__PURE__*/function (_React$Component) {
|
|
|
137
145
|
}));
|
|
138
146
|
});
|
|
139
147
|
|
|
140
|
-
_defineProperty(_assertThisInitialized(_this2), "buildFormItems", function (
|
|
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
152
|
|
|
@@ -147,91 +154,7 @@ var FormForModify = /*#__PURE__*/function (_React$Component) {
|
|
|
147
154
|
return;
|
|
148
155
|
}
|
|
149
156
|
|
|
150
|
-
var setFieldsValue = _this2.ref.current.setFieldsValue;
|
|
151
|
-
|
|
152
157
|
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
|
-
for (var i = 0, len = editFormulasState.length; i < len; i++) {
|
|
162
|
-
var editFormulaStateItem = editFormulasState[i].editFormulaItem;
|
|
163
|
-
|
|
164
|
-
if (editFormulaStateItem) {
|
|
165
|
-
editFormulaStateItem.otherFormItemResponses.forEach(function (item) {
|
|
166
|
-
if (formItem.code === item.formItemCode) {
|
|
167
|
-
if (item.formItemValue === 'disabled') {
|
|
168
|
-
formItem.b_disabled = true;
|
|
169
|
-
} else if (item.formItemValue === 'enabled') {
|
|
170
|
-
formItem.b_disabled = false;
|
|
171
|
-
} else {
|
|
172
|
-
formItem.initialValue = item.formItemValue || data[formItem.display_code];
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
if (formItem.initialValue || data[formItem.code]) {
|
|
176
|
-
if (formItem.code.indexOf('date') !== -1) {
|
|
177
|
-
setFieldsValue(_defineProperty({}, formItem.code, (0, _moment["default"])(formItem.initialValue || data[formItem.code])));
|
|
178
|
-
|
|
179
|
-
if (formItem.code.endsWith("_date")) {
|
|
180
|
-
data[formItem.code] = (0, _moment["default"])(formItem.initialValue || data[formItem.code]).valueOf();
|
|
181
|
-
} else if (formItem.code.indexOf('_date$') !== -1) {
|
|
182
|
-
data[formItem.code] = (0, _moment["default"])(formItem.initialValue || data[formItem.code]).format("YYYY-MM-DD");
|
|
183
|
-
}
|
|
184
|
-
} else {
|
|
185
|
-
setFieldsValue(_defineProperty({}, formItem.code, formItem.initialValue || data[formItem.code]));
|
|
186
|
-
data[formItem.code] = formItem.initialValue || data[formItem.code];
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
});
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
} else {
|
|
194
|
-
if (formItem.editFormulaConfigs) {
|
|
195
|
-
for (var _i = 0, _len = formItem.editFormulaConfigs.length; _i < _len; _i++) {
|
|
196
|
-
var editFormulaConfig = formItem.editFormulaConfigs[_i];
|
|
197
|
-
var initialValue = formItem.ui_render_type === 'switch' ? (data[formItem.code] && data[formItem.code].toString() || '').toLowerCase() !== 'true' : data[formItem.code];
|
|
198
|
-
var formulaValueOf = formItem.ui_render_type === 'switch' ? (editFormulaConfig.onValueOf || '').toLowerCase() !== 'true' : editFormulaConfig.onValueOf;
|
|
199
|
-
|
|
200
|
-
if (formulaValueOf === initialValue) {
|
|
201
|
-
var currentOtherFormItemResponses = editFormulaConfig.otherFormItemResponses;
|
|
202
|
-
currentOtherFormItemResponses.forEach(function (item) {
|
|
203
|
-
info_set_fields.forEach(function (formItemInner) {
|
|
204
|
-
if (formItemInner.code === item.formItemCode) {
|
|
205
|
-
if (item.formItemValue === 'disabled') {
|
|
206
|
-
formItemInner.b_disabled = true;
|
|
207
|
-
} else if (item.formItemValue === 'enabled') {
|
|
208
|
-
formItemInner.b_disabled = false;
|
|
209
|
-
} else {
|
|
210
|
-
formItemInner.initialValue = item.formItemValue || data[formItemInner.display_code];
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
if (formItemInner.initialValue || data[formItemInner.code]) {
|
|
214
|
-
if (formItemInner.code.indexOf('date') !== -1) {
|
|
215
|
-
setFieldsValue(_defineProperty({}, formItemInner.code, (0, _moment["default"])(formItemInner.initialValue || data[formItemInner.code])));
|
|
216
|
-
|
|
217
|
-
if (formItemInner.code.endsWith("_date")) {
|
|
218
|
-
data[formItemInner.code] = (0, _moment["default"])(formItemInner.initialValue || data[formItemInner.code]).valueOf();
|
|
219
|
-
} else if (formItemInner.code.indexOf('_date$') !== -1) {
|
|
220
|
-
data[formItemInner.code] = (0, _moment["default"])(formItem.initialValue || data[formItemInner.code]).format("YYYY-MM-DD");
|
|
221
|
-
}
|
|
222
|
-
} else {
|
|
223
|
-
setFieldsValue(_defineProperty({}, formItemInner.code, formItemInner.initialValue || data[formItemInner.code]));
|
|
224
|
-
data[formItemInner.code] = formItemInner.initialValue || data[formItemInner.code];
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
});
|
|
229
|
-
});
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
});
|
|
235
158
|
var groupNames = info_set_fields.map(function (item) {
|
|
236
159
|
return item.belong_form_group;
|
|
237
160
|
}).filter(function (item, index, arr) {
|
|
@@ -311,8 +234,8 @@ var FormForModify = /*#__PURE__*/function (_React$Component) {
|
|
|
311
234
|
|
|
312
235
|
var editFormulaConfigs = [];
|
|
313
236
|
|
|
314
|
-
for (var
|
|
315
|
-
var formulaTextItem = pureFormulaTextItems[
|
|
237
|
+
for (var _i = 0, _len = pureFormulaTextItems.length; _i < _len; _i++) {
|
|
238
|
+
var formulaTextItem = pureFormulaTextItems[_i];
|
|
316
239
|
var formulaChildTextItems = formulaTextItem.split("=>");
|
|
317
240
|
|
|
318
241
|
if (formulaChildTextItems.length !== 2) {
|
|
@@ -647,7 +570,7 @@ var FormForModify = /*#__PURE__*/function (_React$Component) {
|
|
|
647
570
|
valuePropName = "checked";
|
|
648
571
|
|
|
649
572
|
if (typeof initialValue !== 'boolean') {
|
|
650
|
-
initialValue = (initialValue || '').toLowerCase() === 'true';
|
|
573
|
+
initialValue = (initialValue + '' || '').toLowerCase() === 'true' || (initialValue + '' || '').toLowerCase() === '1';
|
|
651
574
|
displayValue = initialValue ? "是" : "否";
|
|
652
575
|
}
|
|
653
576
|
|
|
@@ -770,9 +693,131 @@ var FormForModify = /*#__PURE__*/function (_React$Component) {
|
|
|
770
693
|
return dict.title;
|
|
771
694
|
});
|
|
772
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
|
+
|
|
773
818
|
_this2.ref = _this2.props.formref || /*#__PURE__*/_react["default"].createRef();
|
|
774
819
|
_this2.state = {
|
|
775
|
-
|
|
820
|
+
fieldCodeKeyMap: {}
|
|
776
821
|
};
|
|
777
822
|
return _this2;
|
|
778
823
|
}
|
|
@@ -780,32 +825,36 @@ var FormForModify = /*#__PURE__*/function (_React$Component) {
|
|
|
780
825
|
_createClass(FormForModify, [{
|
|
781
826
|
key: "componentDidMount",
|
|
782
827
|
value: function componentDidMount() {
|
|
783
|
-
var _this3 = this;
|
|
784
|
-
|
|
785
828
|
var _this$props = this.props,
|
|
786
829
|
data = _this$props.data,
|
|
787
830
|
info_set_fields = _this$props.info_set_fields;
|
|
788
|
-
var
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
}
|
|
804
|
-
}
|
|
831
|
+
var fieldCodeKeyMap = this.state.fieldCodeKeyMap;
|
|
832
|
+
|
|
833
|
+
if (info_set_fields && info_set_fields.length > 0) {
|
|
834
|
+
return;
|
|
835
|
+
}
|
|
836
|
+
|
|
837
|
+
for (var i = 0, len = info_set_fields.length; i < len; i++) {
|
|
838
|
+
var formItem = info_set_fields[i];
|
|
839
|
+
this.preParseFormItemExtConfig(formItem);
|
|
840
|
+
var code = formItem.code,
|
|
841
|
+
ui_render_type = formItem.ui_render_type;
|
|
842
|
+
var fieldCodeValue = data[code];
|
|
843
|
+
|
|
844
|
+
if (_consts.UI_RENDER_TYPE.SWITCH == ui_render_type) {
|
|
845
|
+
fieldCodeValue = (fieldCodeValue + '' || '').toLowerCase() === 'true' || (fieldCodeValue + '' || '').toLowerCase() === '1' ? "true" : "false";
|
|
805
846
|
}
|
|
806
|
-
|
|
847
|
+
|
|
848
|
+
if (fieldCodeValue) {
|
|
849
|
+
this.formItemOnChangeForFormula(formItem, fieldCodeValue);
|
|
850
|
+
}
|
|
851
|
+
|
|
852
|
+
formItem.b_disabled = formItem.b_readonly;
|
|
853
|
+
fieldCodeKeyMap[formItem.code] = formItem;
|
|
854
|
+
}
|
|
855
|
+
|
|
807
856
|
this.setState({
|
|
808
|
-
|
|
857
|
+
fieldCodeKeyMap: fieldCodeKeyMap
|
|
809
858
|
});
|
|
810
859
|
}
|
|
811
860
|
}, {
|
|
@@ -917,6 +966,10 @@ var FormForModify = /*#__PURE__*/function (_React$Component) {
|
|
|
917
966
|
formData[config.code] = date.format(dateFormat);
|
|
918
967
|
}
|
|
919
968
|
|
|
969
|
+
if (dateString) {
|
|
970
|
+
this.formItemOnChangeForFormula(config, dateString);
|
|
971
|
+
}
|
|
972
|
+
|
|
920
973
|
if (callback && typeof callback === "function") {
|
|
921
974
|
callback(date, dateString);
|
|
922
975
|
}
|
|
@@ -946,8 +999,6 @@ var FormForModify = /*#__PURE__*/function (_React$Component) {
|
|
|
946
999
|
}, {
|
|
947
1000
|
key: "selectOnChange",
|
|
948
1001
|
value: function selectOnChange(config, callback, value, option) {
|
|
949
|
-
var _this4 = this;
|
|
950
|
-
|
|
951
1002
|
var display_code = config.display_code,
|
|
952
1003
|
code = config.code;
|
|
953
1004
|
|
|
@@ -991,75 +1042,8 @@ var FormForModify = /*#__PURE__*/function (_React$Component) {
|
|
|
991
1042
|
this.props.data[display_code] = display_value;
|
|
992
1043
|
}
|
|
993
1044
|
|
|
994
|
-
if (
|
|
995
|
-
|
|
996
|
-
var _this$ref$current = this.ref.current,
|
|
997
|
-
setFieldsValue = _this$ref$current.setFieldsValue,
|
|
998
|
-
resetFields = _this$ref$current.resetFields;
|
|
999
|
-
|
|
1000
|
-
if (value) {
|
|
1001
|
-
var editFormulaItem = config.editFormulaConfigs.filter(function (editFormulaItem) {
|
|
1002
|
-
return editFormulaItem.onValueOf === value.toString();
|
|
1003
|
-
})[0];
|
|
1004
|
-
|
|
1005
|
-
if (editFormulaItem) {
|
|
1006
|
-
if (value) {
|
|
1007
|
-
editFormulaItem.otherFormItemResponses.forEach(function (item) {
|
|
1008
|
-
if (item.formItemValue === 'disabled') {
|
|
1009
|
-
resetFields([item.formItemCode]);
|
|
1010
|
-
setFieldsValue(_defineProperty({}, item.formItemCode, null));
|
|
1011
|
-
|
|
1012
|
-
if (item.formItemCode.endsWith('_pk') && _this4.props.data["".concat(item.formItemCode.split('_pk')[0], "_ext_name")]) {
|
|
1013
|
-
_this4.props.data["".concat(item.formItemCode.split('_pk')[0], "_ext_name")] = null;
|
|
1014
|
-
} else if (item.formItemCode.indexOf('_pk$') !== -1 && _this4.props.data["".concat(item.formItemCode.split('_pk$')[0], "_ext_name$").concat(item.formItemCode.split('_pk$')[1])]) {
|
|
1015
|
-
_this4.props.data["".concat(item.formItemCode.split('_pk$')[0], "_ext_name$").concat(item.formItemCode.split('_pk$')[1])] = null;
|
|
1016
|
-
}
|
|
1017
|
-
|
|
1018
|
-
_this4.props.data[item.formItemCode] = null;
|
|
1019
|
-
}
|
|
1020
|
-
});
|
|
1021
|
-
}
|
|
1022
|
-
|
|
1023
|
-
if (editFormulasState.filter(function (item) {
|
|
1024
|
-
return item.editFormulasStateCode === code;
|
|
1025
|
-
}).length) {
|
|
1026
|
-
editFormulasState.forEach(function (item) {
|
|
1027
|
-
if (item.editFormulasStateCode === code) {
|
|
1028
|
-
item.editFormulaItem = editFormulaItem;
|
|
1029
|
-
}
|
|
1030
|
-
});
|
|
1031
|
-
} else {
|
|
1032
|
-
editFormulasState.push({
|
|
1033
|
-
editFormulasStateCode: code,
|
|
1034
|
-
editFormulaItem: editFormulaItem
|
|
1035
|
-
});
|
|
1036
|
-
}
|
|
1037
|
-
} else {
|
|
1038
|
-
if (editFormulasState.filter(function (item) {
|
|
1039
|
-
return item.editFormulasStateCode === code;
|
|
1040
|
-
}).length) {
|
|
1041
|
-
editFormulasState.forEach(function (item) {
|
|
1042
|
-
if (item.editFormulasStateCode === code) {
|
|
1043
|
-
item.editFormulaItem = null;
|
|
1044
|
-
}
|
|
1045
|
-
});
|
|
1046
|
-
}
|
|
1047
|
-
}
|
|
1048
|
-
} else {
|
|
1049
|
-
if (editFormulasState.filter(function (item) {
|
|
1050
|
-
return item.editFormulasStateCode === code;
|
|
1051
|
-
}).length) {
|
|
1052
|
-
editFormulasState.forEach(function (item) {
|
|
1053
|
-
if (item.editFormulasStateCode === code) {
|
|
1054
|
-
item.editFormulaItem = null;
|
|
1055
|
-
}
|
|
1056
|
-
});
|
|
1057
|
-
}
|
|
1058
|
-
}
|
|
1059
|
-
|
|
1060
|
-
this.setState({
|
|
1061
|
-
editFormulasState: editFormulasState
|
|
1062
|
-
});
|
|
1045
|
+
if (value) {
|
|
1046
|
+
this.formItemOnChangeForFormula(config, value);
|
|
1063
1047
|
}
|
|
1064
1048
|
|
|
1065
1049
|
if (callback && typeof callback === "function") {
|
|
@@ -1091,7 +1075,7 @@ var FormForModify = /*#__PURE__*/function (_React$Component) {
|
|
|
1091
1075
|
}, {
|
|
1092
1076
|
key: "buildTreeNode",
|
|
1093
1077
|
value: function buildTreeNode(defNodes) {
|
|
1094
|
-
var
|
|
1078
|
+
var _this3 = this;
|
|
1095
1079
|
|
|
1096
1080
|
if (!defNodes || defNodes.length === 0) {
|
|
1097
1081
|
return null;
|
|
@@ -1112,7 +1096,7 @@ var FormForModify = /*#__PURE__*/function (_React$Component) {
|
|
|
1112
1096
|
ext_attr_value: ext_attr_value,
|
|
1113
1097
|
selectable: item.selectable,
|
|
1114
1098
|
prop: ext_attr_value
|
|
1115
|
-
},
|
|
1099
|
+
}, _this3.buildTreeNode(item.children));
|
|
1116
1100
|
});
|
|
1117
1101
|
}
|
|
1118
1102
|
}, {
|
|
@@ -1169,59 +1153,7 @@ var FormForModify = /*#__PURE__*/function (_React$Component) {
|
|
|
1169
1153
|
}, {
|
|
1170
1154
|
key: "switchOnChange",
|
|
1171
1155
|
value: function switchOnChange(config, callback, checked, event) {
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
if (config.editFormulaConfigs && config.editFormulaConfigs.length) {
|
|
1175
|
-
var code = config.code;
|
|
1176
|
-
var editFormulasState = this.state.editFormulasState;
|
|
1177
|
-
var _this$ref$current2 = this.ref.current,
|
|
1178
|
-
setFieldsValue = _this$ref$current2.setFieldsValue,
|
|
1179
|
-
resetFields = _this$ref$current2.resetFields;
|
|
1180
|
-
var editFormulaItem = config.editFormulaConfigs.filter(function (editFormulaItem) {
|
|
1181
|
-
return editFormulaItem.onValueOf === checked.toString();
|
|
1182
|
-
})[0];
|
|
1183
|
-
|
|
1184
|
-
if (editFormulaItem) {
|
|
1185
|
-
if (!checked) {
|
|
1186
|
-
editFormulaItem.otherFormItemResponses.forEach(function (item) {
|
|
1187
|
-
resetFields([item.formItemCode]);
|
|
1188
|
-
setFieldsValue(_defineProperty({}, item.formItemCode, null));
|
|
1189
|
-
|
|
1190
|
-
if (item.formItemCode.endsWith('_pk') && _this6.props.data["".concat(item.formItemCode.split('_pk')[0], "_ext_name")]) {
|
|
1191
|
-
_this6.props.data["".concat(item.formItemCode.split('_pk')[0], "_ext_name")] = null;
|
|
1192
|
-
} else if (item.formItemCode.indexOf('_pk$') !== -1 && _this6.props.data["".concat(item.formItemCode.split('_pk$')[0], "_ext_name$").concat(item.formItemCode.split('_pk$')[1])]) {
|
|
1193
|
-
_this6.props.data["".concat(item.formItemCode.split('_pk$')[0], "_ext_name$").concat(item.formItemCode.split('_pk$')[1])] = null;
|
|
1194
|
-
}
|
|
1195
|
-
|
|
1196
|
-
_this6.props.data[item.formItemCode] = null;
|
|
1197
|
-
});
|
|
1198
|
-
}
|
|
1199
|
-
|
|
1200
|
-
if (editFormulasState.filter(function (item) {
|
|
1201
|
-
return item.editFormulasStateCode === code;
|
|
1202
|
-
}).length) {
|
|
1203
|
-
editFormulasState.forEach(function (item) {
|
|
1204
|
-
if (item.editFormulasStateCode === code) {
|
|
1205
|
-
item.editFormulaItem = editFormulaItem;
|
|
1206
|
-
}
|
|
1207
|
-
});
|
|
1208
|
-
} else {
|
|
1209
|
-
editFormulasState.push({
|
|
1210
|
-
editFormulasStateCode: code,
|
|
1211
|
-
editFormulaItem: editFormulaItem
|
|
1212
|
-
});
|
|
1213
|
-
}
|
|
1214
|
-
} else {
|
|
1215
|
-
editFormulasState.push({
|
|
1216
|
-
editFormulasStateCode: code,
|
|
1217
|
-
editFormulaItem: null
|
|
1218
|
-
});
|
|
1219
|
-
}
|
|
1220
|
-
|
|
1221
|
-
this.setState({
|
|
1222
|
-
editFormulasState: editFormulasState
|
|
1223
|
-
});
|
|
1224
|
-
}
|
|
1156
|
+
this.formItemOnChangeForFormula(config, checked);
|
|
1225
1157
|
|
|
1226
1158
|
if (callback && typeof callback === "function") {
|
|
1227
1159
|
callback(checked, event);
|
|
@@ -1319,7 +1251,7 @@ var FormForModify = /*#__PURE__*/function (_React$Component) {
|
|
|
1319
1251
|
key: "render",
|
|
1320
1252
|
value: function render() {
|
|
1321
1253
|
var props = this.props;
|
|
1322
|
-
var
|
|
1254
|
+
var fieldCodeKeyMap = this.state.fieldCodeKeyMap;
|
|
1323
1255
|
return /*#__PURE__*/_react["default"].createElement(_antd.ConfigProvider, {
|
|
1324
1256
|
locale: _zh_CN["default"]
|
|
1325
1257
|
}, /*#__PURE__*/_react["default"].createElement(_antd.Form, _extends({}, props, {
|
|
@@ -1327,7 +1259,7 @@ var FormForModify = /*#__PURE__*/function (_React$Component) {
|
|
|
1327
1259
|
ref: this.ref,
|
|
1328
1260
|
scrollToFirstError: true,
|
|
1329
1261
|
onValuesChange: this.onValuesChange.bind(this)
|
|
1330
|
-
}), this.buildFormItems(
|
|
1262
|
+
}), this.buildFormItems(fieldCodeKeyMap), this.buildExtFormItems()));
|
|
1331
1263
|
}
|
|
1332
1264
|
}]);
|
|
1333
1265
|
|
|
@@ -131,22 +131,24 @@ var HttpService = /*#__PURE__*/function () {
|
|
|
131
131
|
rpcMethodName = "";
|
|
132
132
|
}
|
|
133
133
|
|
|
134
|
-
if (jsonObject) {
|
|
135
|
-
|
|
136
|
-
|
|
134
|
+
if (!this.__checkJSONObjectSecurity(jsonObject)) {
|
|
135
|
+
if (jsonObject) {
|
|
136
|
+
ajaxOptions.data = jsonObject;
|
|
137
|
+
}
|
|
137
138
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
139
|
+
if (ajaxOptions.rpcMethodName) {
|
|
140
|
+
delete ajaxOptions.rpcMethodName;
|
|
141
|
+
}
|
|
141
142
|
|
|
142
|
-
|
|
143
|
-
|
|
143
|
+
ajaxOptions.type = "post";
|
|
144
|
+
ajaxOptions.dataType = "json";
|
|
144
145
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
146
|
+
if (!ajaxOptions.url) {
|
|
147
|
+
ajaxOptions.url = this.requestContextPath + rpcMethodName;
|
|
148
|
+
}
|
|
148
149
|
|
|
149
|
-
|
|
150
|
+
return _jquery["default"].ajax(ajaxOptions);
|
|
151
|
+
}
|
|
150
152
|
}
|
|
151
153
|
}, {
|
|
152
154
|
key: "__postForMock",
|
package/package.json
CHANGED
|
@@ -1,24 +1,48 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
window.AppFormulaFunctions
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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,41 @@ class FormForModify extends React.Component{
|
|
|
30
37
|
this.ref = this.props.formref || React.createRef();
|
|
31
38
|
|
|
32
39
|
this.state = {
|
|
33
|
-
|
|
40
|
+
fieldCodeKeyMap: {},
|
|
34
41
|
}
|
|
35
42
|
}
|
|
36
43
|
|
|
37
44
|
componentDidMount() {
|
|
38
45
|
let {data, info_set_fields} = this.props;
|
|
39
|
-
let {
|
|
40
|
-
|
|
46
|
+
let {fieldCodeKeyMap} = this.state;
|
|
47
|
+
|
|
48
|
+
if (info_set_fields && info_set_fields.length > 0) {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
for (let i = 0, len = info_set_fields.length; i < len; i++) {
|
|
53
|
+
let formItem = info_set_fields[i];
|
|
54
|
+
|
|
41
55
|
this.preParseFormItemExtConfig(formItem);
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
if (formulaValueOf === initialValue) {
|
|
49
|
-
editFormulasState.push({editFormulasStateCode: formItem.code, editFormulaItem: editFormulaConfig})
|
|
50
|
-
}
|
|
51
|
-
}
|
|
56
|
+
|
|
57
|
+
let {code, ui_render_type} = formItem;
|
|
58
|
+
let fieldCodeValue = data[code];
|
|
59
|
+
|
|
60
|
+
if (UI_RENDER_TYPE.SWITCH == ui_render_type) {
|
|
61
|
+
fieldCodeValue = (((fieldCodeValue + '' || '').toLowerCase() === 'true' || (fieldCodeValue + '' || '').toLowerCase() === '1') ? "true" : "false");
|
|
52
62
|
}
|
|
63
|
+
|
|
64
|
+
if (fieldCodeValue) {
|
|
65
|
+
this.formItemOnChangeForFormula(formItem, fieldCodeValue);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
formItem.b_disabled = formItem.b_readonly;
|
|
69
|
+
fieldCodeKeyMap[formItem.code] = formItem;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
this.setState({
|
|
73
|
+
fieldCodeKeyMap,
|
|
53
74
|
})
|
|
54
|
-
this.setState({editFormulasState})
|
|
55
75
|
}
|
|
56
76
|
|
|
57
77
|
buildExtFormItems = () => {
|
|
@@ -129,94 +149,13 @@ class FormForModify extends React.Component{
|
|
|
129
149
|
)
|
|
130
150
|
}
|
|
131
151
|
|
|
132
|
-
buildFormItems = (
|
|
133
|
-
let {
|
|
152
|
+
buildFormItems = () => {
|
|
153
|
+
let {info_set_fields, ext_form_items} = this.props;
|
|
134
154
|
if (this.ref.current == null) {
|
|
135
155
|
return;
|
|
136
156
|
}
|
|
137
157
|
|
|
138
|
-
let {setFieldsValue} = this.ref.current;
|
|
139
158
|
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 editFormulaStateItem = editFormulasState[i].editFormulaItem;
|
|
149
|
-
if (editFormulaStateItem) {
|
|
150
|
-
editFormulaStateItem.otherFormItemResponses.forEach(item => {
|
|
151
|
-
if (formItem.code === item.formItemCode) {
|
|
152
|
-
if (item.formItemValue === 'disabled') {
|
|
153
|
-
formItem.b_disabled = true;
|
|
154
|
-
} else if (item.formItemValue === 'enabled') {
|
|
155
|
-
formItem.b_disabled = false;
|
|
156
|
-
} else {
|
|
157
|
-
formItem.initialValue = item.formItemValue || data[formItem.display_code];
|
|
158
|
-
}
|
|
159
|
-
if (formItem.initialValue || data[formItem.code]) {
|
|
160
|
-
if (formItem.code.indexOf('date') !== -1) {
|
|
161
|
-
setFieldsValue({[formItem.code]: moment(formItem.initialValue || data[formItem.code])});
|
|
162
|
-
if (formItem.code.endsWith("_date")) {
|
|
163
|
-
data[formItem.code] = moment(formItem.initialValue || data[formItem.code]).valueOf();
|
|
164
|
-
} else if (formItem.code.indexOf('_date$') !== -1) {
|
|
165
|
-
data[formItem.code] = moment(formItem.initialValue || data[formItem.code]).format("YYYY-MM-DD");
|
|
166
|
-
}
|
|
167
|
-
} else {
|
|
168
|
-
setFieldsValue({[formItem.code]: formItem.initialValue || data[formItem.code]});
|
|
169
|
-
data[formItem.code] = formItem.initialValue || data[formItem.code];
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
})
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
} else {
|
|
178
|
-
if (formItem.editFormulaConfigs) {
|
|
179
|
-
for (let i = 0, len = formItem.editFormulaConfigs.length; i < len; i++) {
|
|
180
|
-
let editFormulaConfig = formItem.editFormulaConfigs[i];
|
|
181
|
-
let initialValue = formItem.ui_render_type === 'switch' ? ((data[formItem.code] && data[formItem.code].toString()) || '').toLowerCase() !== 'true' : data[formItem.code];
|
|
182
|
-
let formulaValueOf = formItem.ui_render_type === 'switch' ? (editFormulaConfig.onValueOf || '').toLowerCase() !== 'true' : editFormulaConfig.onValueOf;
|
|
183
|
-
|
|
184
|
-
if (formulaValueOf === initialValue) {
|
|
185
|
-
let currentOtherFormItemResponses = editFormulaConfig.otherFormItemResponses;
|
|
186
|
-
currentOtherFormItemResponses.forEach(item => {
|
|
187
|
-
info_set_fields.forEach(formItemInner => {
|
|
188
|
-
if (formItemInner.code === item.formItemCode) {
|
|
189
|
-
if (item.formItemValue === 'disabled') {
|
|
190
|
-
formItemInner.b_disabled = true;
|
|
191
|
-
} else if (item.formItemValue === 'enabled') {
|
|
192
|
-
formItemInner.b_disabled = false;
|
|
193
|
-
} else {
|
|
194
|
-
formItemInner.initialValue = item.formItemValue || data[formItemInner.display_code];
|
|
195
|
-
}
|
|
196
|
-
if (formItemInner.initialValue || data[formItemInner.code]) {
|
|
197
|
-
if (formItemInner.code.indexOf('date') !== -1) {
|
|
198
|
-
setFieldsValue({[formItemInner.code]: moment(formItemInner.initialValue || data[formItemInner.code])})
|
|
199
|
-
if (formItemInner.code.endsWith("_date")) {
|
|
200
|
-
data[formItemInner.code] = moment(formItemInner.initialValue || data[formItemInner.code]).valueOf();
|
|
201
|
-
} else if (formItemInner.code.indexOf('_date$') !== -1) {
|
|
202
|
-
data[formItemInner.code] = moment(formItem.initialValue || data[formItemInner.code]).format("YYYY-MM-DD");
|
|
203
|
-
}
|
|
204
|
-
} else {
|
|
205
|
-
setFieldsValue({[formItemInner.code]: formItemInner.initialValue || data[formItemInner.code]});
|
|
206
|
-
data[formItemInner.code] = formItemInner.initialValue || data[formItemInner.code];
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
})
|
|
211
|
-
})
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
}
|
|
219
|
-
})
|
|
220
159
|
|
|
221
160
|
let groupNames = info_set_fields.map(item => item.belong_form_group).filter((item, index, arr) => item && item.trim().length > 0 && arr.indexOf(item) === index);
|
|
222
161
|
|
|
@@ -703,7 +642,7 @@ class FormForModify extends React.Component{
|
|
|
703
642
|
valuePropName = "checked";
|
|
704
643
|
|
|
705
644
|
if (typeof initialValue !== 'boolean') {
|
|
706
|
-
initialValue = (initialValue || '').toLowerCase() === 'true';
|
|
645
|
+
initialValue = (initialValue + '' || '').toLowerCase() === 'true' || (initialValue + '' || '').toLowerCase() === '1';
|
|
707
646
|
displayValue = (initialValue ? "是" : "否");
|
|
708
647
|
}
|
|
709
648
|
|
|
@@ -927,6 +866,10 @@ class FormForModify extends React.Component{
|
|
|
927
866
|
formData[config.code] = date.format(dateFormat);
|
|
928
867
|
}
|
|
929
868
|
|
|
869
|
+
if (dateString) {
|
|
870
|
+
this.formItemOnChangeForFormula(config, dateString);
|
|
871
|
+
}
|
|
872
|
+
|
|
930
873
|
if (callback && typeof callback === "function") {
|
|
931
874
|
callback(date, dateString);
|
|
932
875
|
}
|
|
@@ -999,56 +942,8 @@ class FormForModify extends React.Component{
|
|
|
999
942
|
this.props.data[display_code] = display_value;
|
|
1000
943
|
}
|
|
1001
944
|
|
|
1002
|
-
if (
|
|
1003
|
-
|
|
1004
|
-
let {setFieldsValue, resetFields} = this.ref.current;
|
|
1005
|
-
|
|
1006
|
-
if (value) {
|
|
1007
|
-
let editFormulaItem = config.editFormulaConfigs.filter(editFormulaItem => editFormulaItem.onValueOf === value.toString())[0];
|
|
1008
|
-
if (editFormulaItem) {
|
|
1009
|
-
if (value) {
|
|
1010
|
-
editFormulaItem.otherFormItemResponses.forEach(item => {
|
|
1011
|
-
if (item.formItemValue === 'disabled') {
|
|
1012
|
-
resetFields([item.formItemCode]);
|
|
1013
|
-
setFieldsValue({[item.formItemCode]: null});
|
|
1014
|
-
if (item.formItemCode.endsWith('_pk') && this.props.data[`${item.formItemCode.split('_pk')[0]}_ext_name`]) {
|
|
1015
|
-
this.props.data[`${item.formItemCode.split('_pk')[0]}_ext_name`] = null;
|
|
1016
|
-
} else if (item.formItemCode.indexOf('_pk$') !== -1 && this.props.data[`${item.formItemCode.split('_pk$')[0]}_ext_name$${item.formItemCode.split('_pk$')[1]}`]) {
|
|
1017
|
-
this.props.data[`${item.formItemCode.split('_pk$')[0]}_ext_name$${item.formItemCode.split('_pk$')[1]}`] = null;
|
|
1018
|
-
}
|
|
1019
|
-
this.props.data[item.formItemCode] = null;
|
|
1020
|
-
}
|
|
1021
|
-
})
|
|
1022
|
-
}
|
|
1023
|
-
if (editFormulasState.filter(item => item.editFormulasStateCode === code).length) {
|
|
1024
|
-
editFormulasState.forEach(item => {
|
|
1025
|
-
if (item.editFormulasStateCode === code) {
|
|
1026
|
-
item.editFormulaItem = editFormulaItem;
|
|
1027
|
-
}
|
|
1028
|
-
})
|
|
1029
|
-
} else {
|
|
1030
|
-
editFormulasState.push({editFormulasStateCode: code, editFormulaItem});
|
|
1031
|
-
}
|
|
1032
|
-
} else {
|
|
1033
|
-
if (editFormulasState.filter(item => item.editFormulasStateCode === code).length) {
|
|
1034
|
-
editFormulasState.forEach(item => {
|
|
1035
|
-
if (item.editFormulasStateCode === code) {
|
|
1036
|
-
item.editFormulaItem = null;
|
|
1037
|
-
}
|
|
1038
|
-
})
|
|
1039
|
-
}
|
|
1040
|
-
}
|
|
1041
|
-
} else {
|
|
1042
|
-
if (editFormulasState.filter(item => item.editFormulasStateCode === code).length) {
|
|
1043
|
-
editFormulasState.forEach(item => {
|
|
1044
|
-
if (item.editFormulasStateCode === code) {
|
|
1045
|
-
item.editFormulaItem = null;
|
|
1046
|
-
}
|
|
1047
|
-
})
|
|
1048
|
-
}
|
|
1049
|
-
}
|
|
1050
|
-
|
|
1051
|
-
this.setState({editFormulasState})
|
|
945
|
+
if (value) {
|
|
946
|
+
this.formItemOnChangeForFormula(config, value)
|
|
1052
947
|
}
|
|
1053
948
|
|
|
1054
949
|
if (callback && typeof callback === "function") {
|
|
@@ -1146,39 +1041,106 @@ class FormForModify extends React.Component{
|
|
|
1146
1041
|
}
|
|
1147
1042
|
}
|
|
1148
1043
|
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
let {
|
|
1153
|
-
let {
|
|
1154
|
-
let
|
|
1044
|
+
formItemOnChangeForFormula = (config, value) => {
|
|
1045
|
+
let formItemFormulaConfigs = config.editFormulaConfigs;
|
|
1046
|
+
if (formItemFormulaConfigs && formItemFormulaConfigs.length > 0) {
|
|
1047
|
+
let {fieldCodeKeyMap} = this.state;
|
|
1048
|
+
let {data, def_docs} = this.props;
|
|
1049
|
+
let {setFieldsValue} = this.ref.current;
|
|
1050
|
+
// value exists
|
|
1051
|
+
let editFormulaItem = config.editFormulaConfigs.find(editFormulaItem => editFormulaItem.onValueOf === value.toString() || editFormulaItem.onValueOf === "value");
|
|
1052
|
+
|
|
1155
1053
|
if (editFormulaItem) {
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1054
|
+
let otherFormItemResponses = editFormulaItem.otherFormItemResponses;
|
|
1055
|
+
|
|
1056
|
+
for (let i = 0, len = otherFormItemResponses.length; i < len; i++) {
|
|
1057
|
+
let otherFormItem = otherFormItemResponses[i];
|
|
1058
|
+
if (!otherFormItem) {
|
|
1059
|
+
continue;
|
|
1060
|
+
}
|
|
1061
|
+
|
|
1062
|
+
let {formItemCode, formItemValue} = otherFormItem;
|
|
1063
|
+
let otherFormItemConfig = fieldCodeKeyMap[formItemCode];
|
|
1064
|
+
if (!otherFormItemConfig) {
|
|
1065
|
+
continue;
|
|
1066
|
+
}
|
|
1067
|
+
|
|
1068
|
+
if (!formItemValue) {
|
|
1069
|
+
continue;
|
|
1070
|
+
}
|
|
1071
|
+
|
|
1072
|
+
let {code, display_code, ref_pk, ui_render_type} = otherFormItemConfig;
|
|
1073
|
+
if (FormulasValueType.Disabled == formItemValue) {
|
|
1074
|
+
data[code] = null;
|
|
1075
|
+
setFieldsValue({[code]: null});
|
|
1076
|
+
|
|
1077
|
+
if (display_code) {
|
|
1078
|
+
data[display_code] = null;
|
|
1079
|
+
setFieldsValue({[display_code]: null});
|
|
1164
1080
|
}
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1081
|
+
|
|
1082
|
+
otherFormItemConfig.b_disabled = true;
|
|
1083
|
+
otherFormItemConfig.b_readonly = true;
|
|
1084
|
+
} else if (FormulasValueType.Enabled == formItemValue) {
|
|
1085
|
+
|
|
1086
|
+
otherFormItemConfig.b_disabled = false;
|
|
1087
|
+
otherFormItemConfig.b_readonly = true;
|
|
1088
|
+
} else if (formItemValue.startsWith(FormulasValueType.Function)) {
|
|
1089
|
+
let formulaFunctionValue;
|
|
1090
|
+
if (formItemValue.search("#value#") !== -1) {
|
|
1091
|
+
formulaFunctionValue = eval(formItemValue.replace('#value#', `value`).replace("@", ","));
|
|
1092
|
+
} else {
|
|
1093
|
+
let formItemValueList = formItemValue.split("#");
|
|
1094
|
+
if (!formItemValueList || formItemValueList.length != 3) {
|
|
1095
|
+
console.log("formula error, detail info: formItemCode=" + formItemValue + ", formItemValue=" + formItemValue);
|
|
1096
|
+
continue;
|
|
1097
|
+
}
|
|
1098
|
+
|
|
1099
|
+
let realFormulaValue = formItemValueList[0] + `data[formItemValueList[1]]` + formItemValueList[2];
|
|
1100
|
+
|
|
1101
|
+
formulaFunctionValue = eval(realFormulaValue.replace("@", ","));
|
|
1172
1102
|
}
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1103
|
+
|
|
1104
|
+
if (!formulaFunctionValue) {
|
|
1105
|
+
console.log("formula function return null, detail info: formItemCode=" + formItemValue + ", formItemValue=" + formItemValue);
|
|
1106
|
+
continue;
|
|
1107
|
+
}
|
|
1108
|
+
|
|
1109
|
+
data[code] = formulaFunctionValue;
|
|
1110
|
+
|
|
1111
|
+
let otherFormItemValue;
|
|
1112
|
+
if (UI_RENDER_TYPE.DATE == ui_render_type) {
|
|
1113
|
+
otherFormItemValue = moment(formulaFunctionValue, "YYYY-MM-DD");
|
|
1114
|
+
} else {
|
|
1115
|
+
otherFormItemValue = formulaFunctionValue;
|
|
1116
|
+
}
|
|
1117
|
+
setFieldsValue({[code]: otherFormItemValue});
|
|
1118
|
+
} else {
|
|
1119
|
+
data[code] = formItemValue;
|
|
1120
|
+
setFieldsValue({[code]: formItemValue});
|
|
1121
|
+
|
|
1122
|
+
if (display_code && display_code.trim().length > 0) {
|
|
1123
|
+
let dictList = def_docs["def_" + ref_pk];
|
|
1124
|
+
if (dictList && dictList.length > 0) {
|
|
1125
|
+
let filteredDict = dictList.find(item => item.pk.toString() == formItemValue);
|
|
1126
|
+
if (filteredDict) {
|
|
1127
|
+
let ref_title = filteredDict.title;
|
|
1128
|
+
|
|
1129
|
+
data[display_code] = ref_title;
|
|
1130
|
+
setFieldsValue({[display_code]: ref_title});
|
|
1131
|
+
}
|
|
1132
|
+
}
|
|
1133
|
+
}
|
|
1134
|
+
}
|
|
1176
1135
|
}
|
|
1177
|
-
} else {
|
|
1178
|
-
editFormulasState.push({editFormulasStateCode: code, editFormulaItem: null});
|
|
1179
1136
|
}
|
|
1180
|
-
|
|
1137
|
+
|
|
1138
|
+
this.setState({fieldCodeKeyMap})
|
|
1181
1139
|
}
|
|
1140
|
+
}
|
|
1141
|
+
|
|
1142
|
+
switchOnChange(config, callback, checked, event) {
|
|
1143
|
+
this.formItemOnChangeForFormula(config, checked);
|
|
1182
1144
|
|
|
1183
1145
|
if (callback && typeof callback === "function") {
|
|
1184
1146
|
callback(checked, event);
|
|
@@ -1241,7 +1203,7 @@ class FormForModify extends React.Component{
|
|
|
1241
1203
|
|
|
1242
1204
|
render() {
|
|
1243
1205
|
let {props} = this;
|
|
1244
|
-
let {
|
|
1206
|
+
let {fieldCodeKeyMap} = this.state;
|
|
1245
1207
|
return (
|
|
1246
1208
|
<ConfigProvider locale={zhCN}>
|
|
1247
1209
|
<Form
|
|
@@ -1251,7 +1213,7 @@ class FormForModify extends React.Component{
|
|
|
1251
1213
|
scrollToFirstError
|
|
1252
1214
|
onValuesChange={this.onValuesChange.bind(this)}
|
|
1253
1215
|
>
|
|
1254
|
-
{this.buildFormItems(
|
|
1216
|
+
{this.buildFormItems(fieldCodeKeyMap)}
|
|
1255
1217
|
{this.buildExtFormItems()}
|
|
1256
1218
|
</Form>
|
|
1257
1219
|
</ConfigProvider>
|
|
@@ -114,22 +114,24 @@ class HttpService {
|
|
|
114
114
|
rpcMethodName = "";
|
|
115
115
|
}
|
|
116
116
|
|
|
117
|
-
if (jsonObject) {
|
|
118
|
-
|
|
119
|
-
|
|
117
|
+
if (!this.__checkJSONObjectSecurity(jsonObject)) {
|
|
118
|
+
if (jsonObject) {
|
|
119
|
+
ajaxOptions.data = jsonObject;
|
|
120
|
+
}
|
|
120
121
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
122
|
+
if (ajaxOptions.rpcMethodName) {
|
|
123
|
+
delete ajaxOptions.rpcMethodName;
|
|
124
|
+
}
|
|
124
125
|
|
|
125
|
-
|
|
126
|
-
|
|
126
|
+
ajaxOptions.type = "post";
|
|
127
|
+
ajaxOptions.dataType = "json";
|
|
127
128
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
129
|
+
if (!ajaxOptions.url) {
|
|
130
|
+
ajaxOptions.url = this.requestContextPath + rpcMethodName;
|
|
131
|
+
}
|
|
131
132
|
|
|
132
|
-
|
|
133
|
+
return $.ajax(ajaxOptions);
|
|
134
|
+
}
|
|
133
135
|
}
|
|
134
136
|
|
|
135
137
|
__postForMock(mockOptions) {
|