fmui-base 2.2.88 → 2.2.90
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/README.md +2 -0
- package/lib/form/form.js +140 -17
- package/lib/form/formExtHelper.js +131 -55
- package/lib/form/subForm.js +272 -21
- package/lib/form/table.js +39 -2
- package/lib/process_info/processInfo.js +2 -1
- package/lib/tblform/README.md +12 -3
- package/lib/tblform/TblForm.js +2 -0
- package/lib/tblform/formFieldProps.js +1 -0
- package/lib/tblform/pureFormAdapter.js +2 -1
- package/package.json +1 -1
package/README.md
CHANGED
package/lib/form/form.js
CHANGED
|
@@ -7,6 +7,8 @@ exports.default = undefined;
|
|
|
7
7
|
|
|
8
8
|
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
|
|
9
9
|
|
|
10
|
+
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
|
|
11
|
+
|
|
10
12
|
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
|
11
13
|
|
|
12
14
|
var _react = require('react');
|
|
@@ -1101,12 +1103,14 @@ var PageHome = function (_React$Component) {
|
|
|
1101
1103
|
item.value = dateStr;
|
|
1102
1104
|
}
|
|
1103
1105
|
});
|
|
1104
|
-
} else if (value && value
|
|
1106
|
+
} else if (typeof value === 'number' && !isNaN(value)) {
|
|
1107
|
+
// 接口偶发返回时间戳:保留数字供组件展示,提交值在下方 sync 时格式化
|
|
1108
|
+
} else if (value && typeof value === 'string' && value.length >= 10) {
|
|
1105
1109
|
value = value.substring(0, 19);
|
|
1106
1110
|
value = new Date(value.replace(/-/g, "/")).getTime();
|
|
1107
|
-
} else if (value && value.length == 4 && dateFormat == "Y") {
|
|
1111
|
+
} else if (value && typeof value === 'string' && value.length == 4 && dateFormat == "Y") {
|
|
1108
1112
|
value = new Date(value).getTime();
|
|
1109
|
-
} else if (value && value.length == 7 && dateFormat == "YM") {
|
|
1113
|
+
} else if (value && typeof value === 'string' && value.length == 7 && dateFormat == "YM") {
|
|
1110
1114
|
value = new Date(value).getTime();
|
|
1111
1115
|
} else {
|
|
1112
1116
|
for (var i = 0; i < mainTblData.length; i++) {
|
|
@@ -1504,9 +1508,13 @@ var PageHome = function (_React$Component) {
|
|
|
1504
1508
|
itemType = itemParam.itemType;
|
|
1505
1509
|
}
|
|
1506
1510
|
if (itemType == 'text' || itemType == 'textarea' || itemType == 'datetime') {
|
|
1511
|
+
var syncValue = value;
|
|
1512
|
+
if (itemType == 'datetime') {
|
|
1513
|
+
syncValue = t.getDatetimeSaveValue(value, itemParam.dateFormat, itemParam.dateFormatShow);
|
|
1514
|
+
}
|
|
1507
1515
|
for (var i = 0; i < data.mainTblData.length; i++) {
|
|
1508
1516
|
if (itemParam.key == data.mainTblData[i].key) {
|
|
1509
|
-
data.mainTblData[i].value =
|
|
1517
|
+
data.mainTblData[i].value = syncValue;
|
|
1510
1518
|
}
|
|
1511
1519
|
}
|
|
1512
1520
|
}
|
|
@@ -1594,6 +1602,9 @@ var PageHome = function (_React$Component) {
|
|
|
1594
1602
|
$("." + itemParam.fieldId).find(".t-datetime-field-placeholder").attr("style", placeholderStyleStr);
|
|
1595
1603
|
}
|
|
1596
1604
|
}
|
|
1605
|
+
if (t.props.dataType === 'sub') {
|
|
1606
|
+
t.applySubFormLabelStyle(itemParam);
|
|
1607
|
+
}
|
|
1597
1608
|
this.props.onChange(data, itemParam);
|
|
1598
1609
|
});
|
|
1599
1610
|
}
|
|
@@ -1910,6 +1921,51 @@ var PageHome = function (_React$Component) {
|
|
|
1910
1921
|
value: function componentDidMount() {
|
|
1911
1922
|
this.loadComponet();
|
|
1912
1923
|
}
|
|
1924
|
+
}, {
|
|
1925
|
+
key: 'componentDidUpdate',
|
|
1926
|
+
value: function componentDidUpdate() {
|
|
1927
|
+
if (this.props.dataType === 'sub' && this.state.loaded && this.state.itemParam && this.state.itemParam.fieldId) {
|
|
1928
|
+
this.applySubFormLabelStyle(this.state.itemParam);
|
|
1929
|
+
}
|
|
1930
|
+
}
|
|
1931
|
+
|
|
1932
|
+
// 子表标签:单列保留主表边距,仅同步字号颜色;多列去掉 label 左边距
|
|
1933
|
+
|
|
1934
|
+
}, {
|
|
1935
|
+
key: 'applySubFormLabelStyle',
|
|
1936
|
+
value: function applySubFormLabelStyle(itemParam) {
|
|
1937
|
+
if (!itemParam || !itemParam.fieldId || typeof $ === 'undefined') {
|
|
1938
|
+
return;
|
|
1939
|
+
}
|
|
1940
|
+
var subColumnCount = parseInt(this.props.subColumnCount, 10);
|
|
1941
|
+
var isSubFormMultiCol = this.props.dataType === 'sub' && !isNaN(subColumnCount) && subColumnCount > 1;
|
|
1942
|
+
var ts = itemParam.formStyleObj && itemParam.formStyleObj.titleStyle ? itemParam.formStyleObj.titleStyle : {};
|
|
1943
|
+
var styleStr = 'font-size:14px;line-height:24px;color:rgb(51, 51, 51);font-weight:bold;';
|
|
1944
|
+
if (ts.fontSize) {
|
|
1945
|
+
styleStr += 'font-size:' + ts.fontSize + ';';
|
|
1946
|
+
}
|
|
1947
|
+
if (ts.color) {
|
|
1948
|
+
styleStr = styleStr.replace(/color:[^;]+;?/, '') + 'color:' + ts.color + ';';
|
|
1949
|
+
}
|
|
1950
|
+
if (ts.fontFamily) {
|
|
1951
|
+
styleStr += 'font-family:' + ts.fontFamily + ';';
|
|
1952
|
+
}
|
|
1953
|
+
if (ts.fontWeight) {
|
|
1954
|
+
styleStr += 'font-weight:' + ts.fontWeight + ';';
|
|
1955
|
+
}
|
|
1956
|
+
if (ts.fontStyle) {
|
|
1957
|
+
styleStr += 'font-style:' + ts.fontStyle + ';';
|
|
1958
|
+
}
|
|
1959
|
+
if (isSubFormMultiCol) {
|
|
1960
|
+
styleStr += 'margin-left:0;padding-left:0;padding-right:0;';
|
|
1961
|
+
}
|
|
1962
|
+
var $root = $('.' + itemParam.fieldId);
|
|
1963
|
+
$root.find('.t-field-layout-v-label-left').attr('style', styleStr);
|
|
1964
|
+
$root.find('.t-field-layout-h-label').attr('style', styleStr);
|
|
1965
|
+
if (isSubFormMultiCol) {
|
|
1966
|
+
$root.find('.t-field-layout-v-label').attr('style', styleStr);
|
|
1967
|
+
}
|
|
1968
|
+
}
|
|
1913
1969
|
|
|
1914
1970
|
//重新加载组件;options.silent=true 时不向上触发 onChange(用于字段关联批量刷新,避免死循环)
|
|
1915
1971
|
|
|
@@ -1960,6 +2016,12 @@ var PageHome = function (_React$Component) {
|
|
|
1960
2016
|
selectText = selectText.substring(0, selectText.length - 1);
|
|
1961
2017
|
}
|
|
1962
2018
|
checkboxValueHas = true;
|
|
2019
|
+
} else if (itemParam.itemType == 'datetime') {
|
|
2020
|
+
itemParam[key] = itemNew[i].value;
|
|
2021
|
+
if (this.props.data) {
|
|
2022
|
+
var saveVal = this.getDatetimeSaveValue(itemNew[i].value, itemParam.dateFormat, itemParam.dateFormatShow);
|
|
2023
|
+
this.editData(itemParam.key, saveVal, this.props.data);
|
|
2024
|
+
}
|
|
1963
2025
|
} else {
|
|
1964
2026
|
itemParam[key] = itemNew[i].value;
|
|
1965
2027
|
}
|
|
@@ -2636,6 +2698,45 @@ var PageHome = function (_React$Component) {
|
|
|
2636
2698
|
return weekdays[dayIndex];
|
|
2637
2699
|
}
|
|
2638
2700
|
|
|
2701
|
+
// 时间字段提交值:统一格式化为字符串,避免 mainTblData 存入时间戳
|
|
2702
|
+
|
|
2703
|
+
}, {
|
|
2704
|
+
key: 'getDatetimeSaveValue',
|
|
2705
|
+
value: function getDatetimeSaveValue(value, dateFormat, dateFormatShow) {
|
|
2706
|
+
if (value == null || value === '') {
|
|
2707
|
+
return '';
|
|
2708
|
+
}
|
|
2709
|
+
if (dateFormat === 'DateInterval') {
|
|
2710
|
+
if ((typeof value === 'undefined' ? 'undefined' : _typeof(value)) === 'object' && value.startDate != null && value.endDate != null) {
|
|
2711
|
+
return this.dateFormat(value, dateFormat, dateFormatShow) || '';
|
|
2712
|
+
}
|
|
2713
|
+
if (typeof value === 'string' && value.indexOf(' - ') >= 0) {
|
|
2714
|
+
return value;
|
|
2715
|
+
}
|
|
2716
|
+
return '';
|
|
2717
|
+
}
|
|
2718
|
+
var raw = value;
|
|
2719
|
+
if ((typeof value === 'undefined' ? 'undefined' : _typeof(value)) === 'object' && value != null && value.value != null) {
|
|
2720
|
+
raw = value.value;
|
|
2721
|
+
}
|
|
2722
|
+
if (typeof raw === 'string') {
|
|
2723
|
+
if (raw.length >= 10 && raw.indexOf('-') >= 0) {
|
|
2724
|
+
return raw.substring(0, 19);
|
|
2725
|
+
}
|
|
2726
|
+
if (/^\d+$/.test(raw)) {
|
|
2727
|
+
raw = parseInt(raw, 10);
|
|
2728
|
+
}
|
|
2729
|
+
}
|
|
2730
|
+
if (typeof raw === 'number' && !isNaN(raw)) {
|
|
2731
|
+
return this.dateFormat(raw, dateFormat, dateFormatShow) || '';
|
|
2732
|
+
}
|
|
2733
|
+
var d = new Date(raw);
|
|
2734
|
+
if (!isNaN(d.getTime())) {
|
|
2735
|
+
return this.dateFormat(d.getTime(), dateFormat, dateFormatShow) || '';
|
|
2736
|
+
}
|
|
2737
|
+
return '';
|
|
2738
|
+
}
|
|
2739
|
+
|
|
2639
2740
|
//时间
|
|
2640
2741
|
|
|
2641
2742
|
}, {
|
|
@@ -2647,18 +2748,27 @@ var PageHome = function (_React$Component) {
|
|
|
2647
2748
|
var itemParam = this.state.itemParam;
|
|
2648
2749
|
var dateFormat = itemParam.dateFormat;
|
|
2649
2750
|
var dateFormatShow = itemParam.dateFormatShow;
|
|
2751
|
+
var dateStr = '';
|
|
2650
2752
|
if (dateFormat == "DateInterval") {
|
|
2651
|
-
if (value.startDate && value.endDate) {
|
|
2652
|
-
|
|
2653
|
-
data =
|
|
2753
|
+
if (value && value.startDate && value.endDate) {
|
|
2754
|
+
dateStr = t.getDatetimeSaveValue(value, dateFormat, dateFormatShow);
|
|
2755
|
+
data = t.editData(code, dateStr, data);
|
|
2654
2756
|
}
|
|
2655
2757
|
} else {
|
|
2656
|
-
var
|
|
2657
|
-
|
|
2658
|
-
|
|
2659
|
-
|
|
2758
|
+
var pickerVal = value && (typeof value === 'undefined' ? 'undefined' : _typeof(value)) === 'object' && value.value != null ? value : { value: value };
|
|
2759
|
+
dateStr = t.getDatetimeSaveValue(pickerVal, dateFormat, dateFormatShow);
|
|
2760
|
+
data = t.editData(code, dateStr, data);
|
|
2761
|
+
if (dateFormat == "YMDT" && dateStr) {
|
|
2762
|
+
pickerVal.value = new Date(dateStr.replace(/-/g, "/")).getTime();
|
|
2763
|
+
} else if (typeof pickerVal.value === 'string' && /^\d+$/.test(pickerVal.value)) {
|
|
2764
|
+
pickerVal.value = parseInt(pickerVal.value, 10);
|
|
2765
|
+
} else if (dateStr && (typeof pickerVal.value !== 'number' || isNaN(pickerVal.value))) {
|
|
2766
|
+
var ts = new Date(dateStr.replace(/-/g, '/')).getTime();
|
|
2767
|
+
if (!isNaN(ts)) {
|
|
2768
|
+
pickerVal.value = ts;
|
|
2769
|
+
}
|
|
2660
2770
|
}
|
|
2661
|
-
|
|
2771
|
+
value = pickerVal;
|
|
2662
2772
|
}
|
|
2663
2773
|
|
|
2664
2774
|
itemParam.value = value;
|
|
@@ -2743,7 +2853,7 @@ var PageHome = function (_React$Component) {
|
|
|
2743
2853
|
var itemParam = this.state.itemParam;
|
|
2744
2854
|
var dateFormat = itemParam.dateFormat;
|
|
2745
2855
|
|
|
2746
|
-
var dateStr = this.
|
|
2856
|
+
var dateStr = this.getDatetimeSaveValue(value, dateFormat);
|
|
2747
2857
|
data = this.editData(code, dateStr, data);
|
|
2748
2858
|
itemParam.value = value;
|
|
2749
2859
|
itemParam.selectValue = dateStr;
|
|
@@ -3583,9 +3693,16 @@ var PageHome = function (_React$Component) {
|
|
|
3583
3693
|
// itemParam:itemParam
|
|
3584
3694
|
// })
|
|
3585
3695
|
}
|
|
3696
|
+
var subColumnCount = parseInt(t.props.subColumnCount, 10);
|
|
3697
|
+
var isSubFormMultiCol = t.props.dataType === 'sub' && !isNaN(subColumnCount) && subColumnCount > 1;
|
|
3698
|
+
var subFormFieldLayout = isSubFormMultiCol ? 'v' : 'h';
|
|
3699
|
+
var rootClassName = this.state.itemParam.isHidden ? 't-DN' : '';
|
|
3700
|
+
if (isSubFormMultiCol) {
|
|
3701
|
+
rootClassName = (rootClassName ? rootClassName + ' ' : '') + 'subform-col-field';
|
|
3702
|
+
}
|
|
3586
3703
|
return _react2.default.createElement(
|
|
3587
3704
|
'div',
|
|
3588
|
-
{ className:
|
|
3705
|
+
{ className: rootClassName },
|
|
3589
3706
|
this.state.itemParam.itemType == 'text' ? _react2.default.createElement(
|
|
3590
3707
|
_Group2.default.List,
|
|
3591
3708
|
{ borderTopNone: true },
|
|
@@ -3613,6 +3730,7 @@ var PageHome = function (_React$Component) {
|
|
|
3613
3730
|
{ className: 't-FBH', id: t.state.prefixName + "_" + t.state.itemParam.key },
|
|
3614
3731
|
_react2.default.createElement(_TextareaField2.default, {
|
|
3615
3732
|
className: 't-W100',
|
|
3733
|
+
layout: subFormFieldLayout,
|
|
3616
3734
|
required: t.state.itemParam.required,
|
|
3617
3735
|
label: t.state.itemParam.title,
|
|
3618
3736
|
readOnly: t.state.itemParam.readOnly,
|
|
@@ -3631,9 +3749,10 @@ var PageHome = function (_React$Component) {
|
|
|
3631
3749
|
{ className: t.state.itemParam.fieldId, style: t.state.itemParam.formStyleObj.contentStyle == null ? {} : t.state.itemParam.formStyleObj.contentStyle },
|
|
3632
3750
|
_react2.default.createElement(
|
|
3633
3751
|
'div',
|
|
3634
|
-
{ className: 't-FBH', id: t.state.prefixName + "_" + t.state.itemParam.key },
|
|
3752
|
+
{ className: isSubFormMultiCol ? '' : 't-FBH', id: t.state.prefixName + "_" + t.state.itemParam.key },
|
|
3635
3753
|
_react2.default.createElement(_TextField2.default, {
|
|
3636
3754
|
className: 't-W100',
|
|
3755
|
+
layout: subFormFieldLayout,
|
|
3637
3756
|
required: t.state.itemParam.required,
|
|
3638
3757
|
readOnly: t.state.itemParam.readOnly,
|
|
3639
3758
|
label: t.state.itemParam.title,
|
|
@@ -3829,9 +3948,10 @@ var PageHome = function (_React$Component) {
|
|
|
3829
3948
|
{ borderTopNone: true },
|
|
3830
3949
|
_react2.default.createElement(
|
|
3831
3950
|
'div',
|
|
3832
|
-
{ className: 't-FBH', id: t.state.prefixName + "_" + t.state.itemParam.key },
|
|
3951
|
+
{ className: isSubFormMultiCol ? '' : 't-FBH', id: t.state.prefixName + "_" + t.state.itemParam.key },
|
|
3833
3952
|
_react2.default.createElement(_SelectField2.default, {
|
|
3834
3953
|
className: 't-W100',
|
|
3954
|
+
layout: subFormFieldLayout,
|
|
3835
3955
|
required: t.state.itemParam.required,
|
|
3836
3956
|
label: t.state.itemParam.title,
|
|
3837
3957
|
readOnly: t.state.itemParam.readOnly,
|
|
@@ -3852,9 +3972,10 @@ var PageHome = function (_React$Component) {
|
|
|
3852
3972
|
{ borderTopNone: true },
|
|
3853
3973
|
_react2.default.createElement(
|
|
3854
3974
|
'div',
|
|
3855
|
-
{ id: t.state.prefixName + "_" + t.state.itemParam.key, className: t.state.itemParam.dateFormat == "DateInterval" ? "" : "t-FBH" },
|
|
3975
|
+
{ id: t.state.prefixName + "_" + t.state.itemParam.key, className: t.state.itemParam.dateFormat == "DateInterval" ? "" : isSubFormMultiCol ? "" : "t-FBH" },
|
|
3856
3976
|
t.state.itemParam.readOnly ? _react2.default.createElement(_TextareaField2.default, {
|
|
3857
3977
|
className: 't-W100',
|
|
3978
|
+
layout: subFormFieldLayout,
|
|
3858
3979
|
required: t.state.itemParam.required,
|
|
3859
3980
|
label: t.state.itemParam.title,
|
|
3860
3981
|
readOnly: t.state.itemParam.readOnly,
|
|
@@ -3883,6 +4004,8 @@ var PageHome = function (_React$Component) {
|
|
|
3883
4004
|
, onOk: t.handleChangeDate.bind(t, t.state.itemParam.key)
|
|
3884
4005
|
}) : _react2.default.createElement(_DatetimeField2.default, {
|
|
3885
4006
|
className: 't-W100',
|
|
4007
|
+
layout: subFormFieldLayout,
|
|
4008
|
+
multiLine: isSubFormMultiCol,
|
|
3886
4009
|
label: t.state.itemParam.title,
|
|
3887
4010
|
required: t.state.itemParam.required,
|
|
3888
4011
|
readOnly: t.state.itemParam.readOnly,
|
|
@@ -5,103 +5,73 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.loadFlowOrFormCommon = loadFlowOrFormCommon;
|
|
7
7
|
exports.resolveMobileFormExt = resolveMobileFormExt;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
exports.clampSubColumnCount = clampSubColumnCount;
|
|
9
|
+
exports.buildDetailItemParam = buildDetailItemParam;
|
|
10
|
+
exports.applyDealwithFormParamExt = applyDealwithFormParamExt;
|
|
11
|
+
exports.resolveSubColumnCountFromConfig = resolveSubColumnCountFromConfig;
|
|
12
|
+
/**
|
|
13
|
+
* 表单扩展加载:流程 flow_common / 纯表单 form_common
|
|
14
|
+
*
|
|
15
|
+
* form_common 使用包内 require.context('./form_common'),避免宿主无 pages/form_common 时 webpack 告警。
|
|
16
|
+
* 宿主扩展目录请通过 webpack alias 映射到 fmui-base/lib/form/form_common(见 tblform/README)。
|
|
13
17
|
*/
|
|
14
18
|
|
|
15
19
|
var formCommonContext = require.context('./form_common', false, /\.js$/);
|
|
16
20
|
|
|
17
21
|
function loadFormCommonModule(formCode) {
|
|
18
|
-
|
|
19
22
|
if (!formCode) {
|
|
20
|
-
|
|
21
23
|
return null;
|
|
22
24
|
}
|
|
23
|
-
|
|
24
25
|
var keys = ['./' + formCode + '.js', './' + formCode];
|
|
25
|
-
|
|
26
26
|
for (var i = 0; i < keys.length; i++) {
|
|
27
|
-
|
|
28
27
|
if (!formCommonContext.keys().includes(keys[i])) {
|
|
29
|
-
|
|
30
28
|
continue;
|
|
31
29
|
}
|
|
32
|
-
|
|
33
30
|
try {
|
|
34
|
-
|
|
35
31
|
var mod = formCommonContext(keys[i]);
|
|
36
|
-
|
|
37
32
|
return mod.default ? mod.default : mod;
|
|
38
33
|
} catch (e) {
|
|
39
|
-
|
|
40
34
|
// try next key
|
|
41
|
-
|
|
42
35
|
}
|
|
43
36
|
}
|
|
44
|
-
|
|
45
37
|
return loadFormCommonFromGlobal(formCode);
|
|
46
38
|
}
|
|
47
39
|
|
|
48
40
|
/** 宿主可在 window 挂载 {formCode}_formCommon,无需改 node_modules */
|
|
49
|
-
|
|
50
41
|
function loadFormCommonFromGlobal(formCode) {
|
|
51
|
-
|
|
52
42
|
if (!formCode) {
|
|
53
|
-
|
|
54
43
|
return null;
|
|
55
44
|
}
|
|
56
|
-
|
|
57
45
|
try {
|
|
58
|
-
|
|
59
46
|
var globalName = formCode + '_formCommon';
|
|
60
|
-
|
|
61
47
|
if (typeof window !== 'undefined' && window[globalName]) {
|
|
62
|
-
|
|
63
48
|
return window[globalName];
|
|
64
49
|
}
|
|
65
|
-
|
|
66
50
|
if (typeof global !== 'undefined' && global[globalName]) {
|
|
67
|
-
|
|
68
51
|
return global[globalName];
|
|
69
52
|
}
|
|
70
53
|
} catch (e) {
|
|
71
|
-
|
|
72
54
|
// ignore
|
|
73
|
-
|
|
74
55
|
}
|
|
75
|
-
|
|
76
56
|
return null;
|
|
77
57
|
}
|
|
78
58
|
|
|
79
59
|
function loadFlowOrFormCommon(props) {
|
|
80
|
-
|
|
81
60
|
var formCode = props && props.formCode || '';
|
|
82
|
-
|
|
83
61
|
var module = props && props.module;
|
|
84
|
-
|
|
85
62
|
if (module === undefined || module === null || module === 'undefined') {
|
|
86
|
-
|
|
87
63
|
module = formCode ? '' : 'approve';
|
|
88
64
|
}
|
|
89
65
|
|
|
90
66
|
var FlowCommon = null;
|
|
91
|
-
|
|
92
67
|
try {
|
|
93
|
-
|
|
94
68
|
if (formCode) {
|
|
95
|
-
|
|
96
69
|
FlowCommon = loadFormCommonModule(formCode);
|
|
97
70
|
} else if (module) {
|
|
98
|
-
|
|
99
71
|
var mod = require('pages/flow_common/' + module);
|
|
100
|
-
|
|
101
72
|
FlowCommon = mod.default ? mod.default : mod;
|
|
102
73
|
}
|
|
103
74
|
} catch (e) {
|
|
104
|
-
|
|
105
75
|
FlowCommon = null;
|
|
106
76
|
}
|
|
107
77
|
|
|
@@ -109,44 +79,150 @@ function loadFlowOrFormCommon(props) {
|
|
|
109
79
|
}
|
|
110
80
|
|
|
111
81
|
/** form_common: {formCode}_mobileExt;流程: {module}_{formKey}_mobileExt */
|
|
112
|
-
|
|
113
82
|
function resolveMobileFormExt(formCode, module, formKey) {
|
|
114
|
-
|
|
115
83
|
if (formCode) {
|
|
116
|
-
|
|
117
84
|
try {
|
|
118
|
-
|
|
119
85
|
var extName = formCode + '_mobileExt';
|
|
120
|
-
|
|
121
86
|
if (typeof eval(extName) !== 'undefined') {
|
|
122
|
-
|
|
123
87
|
return eval(extName);
|
|
124
88
|
}
|
|
125
89
|
} catch (e) {
|
|
126
|
-
|
|
127
90
|
// ignore
|
|
128
|
-
|
|
129
91
|
}
|
|
130
|
-
|
|
131
92
|
return null;
|
|
132
93
|
}
|
|
133
|
-
|
|
134
94
|
if (module && formKey) {
|
|
135
|
-
|
|
136
95
|
try {
|
|
137
|
-
|
|
138
96
|
var _extName = module + '_' + formKey + '_mobileExt';
|
|
139
|
-
|
|
140
97
|
if (typeof eval(_extName) !== 'undefined') {
|
|
141
|
-
|
|
142
98
|
return eval(_extName);
|
|
143
99
|
}
|
|
144
100
|
} catch (e) {
|
|
145
|
-
|
|
146
101
|
// ignore
|
|
147
|
-
|
|
148
102
|
}
|
|
149
103
|
}
|
|
104
|
+
return null;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/** 将子表列数限制在 1-4;无效则返回 null */
|
|
108
|
+
function clampSubColumnCount(count) {
|
|
109
|
+
if (count == null || count === '') {
|
|
110
|
+
return null;
|
|
111
|
+
}
|
|
112
|
+
var n = parseInt(count, 10);
|
|
113
|
+
if (isNaN(n)) {
|
|
114
|
+
return null;
|
|
115
|
+
}
|
|
116
|
+
return Math.max(1, Math.min(4, n));
|
|
117
|
+
}
|
|
150
118
|
|
|
119
|
+
function resolveSubColumnCountFromItemType(itemType) {
|
|
120
|
+
if (itemType === 'twocolumns') {
|
|
121
|
+
return 2;
|
|
122
|
+
}
|
|
123
|
+
if (itemType === 'threecolumns') {
|
|
124
|
+
return 3;
|
|
125
|
+
}
|
|
126
|
+
if (itemType === 'fourcolumns') {
|
|
127
|
+
return 4;
|
|
128
|
+
}
|
|
151
129
|
return null;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/** 由子表字段配置构建 itemParam,供扩展方法使用 */
|
|
133
|
+
function buildDetailItemParam(detailForm) {
|
|
134
|
+
if (!detailForm) {
|
|
135
|
+
return { key: '', itemType: 'detail', title: '' };
|
|
136
|
+
}
|
|
137
|
+
return {
|
|
138
|
+
id: detailForm.id,
|
|
139
|
+
title: detailForm.itemTitle,
|
|
140
|
+
key: detailForm.itemCode,
|
|
141
|
+
itemType: detailForm.itemType || 'detail',
|
|
142
|
+
uniqueName: detailForm.uniqueName,
|
|
143
|
+
subColumnCount: detailForm.subColumnCount
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* 调用现有表单扩展:FlowCommon.dealwithCommonFormParam、mobileExt.dealwithFormParamExt
|
|
149
|
+
* 流程:pages/flow_common/{module};纯表单:form_common / {formCode}_mobileExt
|
|
150
|
+
*/
|
|
151
|
+
function applyDealwithFormParamExt(options) {
|
|
152
|
+
options = options || {};
|
|
153
|
+
var itemParam = options.itemParam;
|
|
154
|
+
if (!itemParam) {
|
|
155
|
+
itemParam = buildDetailItemParam(options.detailForm);
|
|
156
|
+
}
|
|
157
|
+
var FlowCommon = options.FlowCommon;
|
|
158
|
+
var component = options.component;
|
|
159
|
+
var module = options.module;
|
|
160
|
+
var formKey = options.formKey;
|
|
161
|
+
var formCode = options.formCode || '';
|
|
162
|
+
|
|
163
|
+
if (FlowCommon && typeof FlowCommon.dealwithCommonFormParam === 'function') {
|
|
164
|
+
itemParam = FlowCommon.dealwithCommonFormParam(itemParam, component);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
var mobileExt = null;
|
|
168
|
+
try {
|
|
169
|
+
mobileExt = resolveMobileFormExt(formCode, module, formKey);
|
|
170
|
+
} catch (e) {
|
|
171
|
+
// ignore
|
|
172
|
+
}
|
|
173
|
+
if (mobileExt && typeof mobileExt.dealwithFormParamExt === 'function') {
|
|
174
|
+
itemParam = mobileExt.dealwithFormParamExt(itemParam, component);
|
|
175
|
+
}
|
|
176
|
+
if (module && mobileExt && typeof mobileExt[module + '_dealwithFormParamExt'] === 'function') {
|
|
177
|
+
itemParam = mobileExt[module + '_dealwithFormParamExt'](itemParam, component);
|
|
178
|
+
}
|
|
179
|
+
return itemParam;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* 解析子表列数(扩展通过 itemParam.subColumnCount 回写,无新扩展方法)
|
|
184
|
+
* 优先级:扩展 itemParam → 子表 JSON → props → 全表单 → itemType → 默认 1
|
|
185
|
+
*/
|
|
186
|
+
function resolveSubColumnCountFromConfig(options) {
|
|
187
|
+
options = options || {};
|
|
188
|
+
var count = void 0;
|
|
189
|
+
|
|
190
|
+
var itemParam = options.itemParam;
|
|
191
|
+
if (itemParam && itemParam.subColumnCount != null && itemParam.subColumnCount !== '') {
|
|
192
|
+
count = clampSubColumnCount(itemParam.subColumnCount);
|
|
193
|
+
if (count != null) {
|
|
194
|
+
return count;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
var detailForm = options.detailForm;
|
|
199
|
+
if (detailForm) {
|
|
200
|
+
if (detailForm.subColumnCount != null && detailForm.subColumnCount !== '') {
|
|
201
|
+
count = clampSubColumnCount(detailForm.subColumnCount);
|
|
202
|
+
if (count != null) {
|
|
203
|
+
return count;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
count = resolveSubColumnCountFromItemType(detailForm.itemType);
|
|
207
|
+
if (count != null) {
|
|
208
|
+
return count;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
if (options.subColumnCount != null && options.subColumnCount !== '') {
|
|
213
|
+
count = clampSubColumnCount(options.subColumnCount);
|
|
214
|
+
if (count != null) {
|
|
215
|
+
return count;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
var allForm = options.allForm;
|
|
220
|
+
if (allForm && allForm.subColumnCount != null && allForm.subColumnCount !== '') {
|
|
221
|
+
count = clampSubColumnCount(allForm.subColumnCount);
|
|
222
|
+
if (count != null) {
|
|
223
|
+
return count;
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
return 1;
|
|
152
228
|
}
|
package/lib/form/subForm.js
CHANGED
|
@@ -193,24 +193,16 @@ var PageHome = function (_React$Component) {
|
|
|
193
193
|
itemParam.show = true;
|
|
194
194
|
itemParam.value = value;
|
|
195
195
|
itemParam.detailAction = form.detailAction; //添加事件名字
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
itemParam
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
}
|
|
207
|
-
} catch (e) {
|
|
208
|
-
// alert("exception: "+e.message);
|
|
209
|
-
}
|
|
210
|
-
if (mobileExt && typeof mobileExt["dealwithFormParamExt"] === "function") {
|
|
211
|
-
itemParam = mobileExt["dealwithFormParamExt"](itemParam, this);
|
|
212
|
-
itemType = itemParam.itemType;
|
|
213
|
-
}
|
|
196
|
+
// 流程 flow_common / 纯表单 form_common + mobileExt(可设置 itemParam.subColumnCount 等)
|
|
197
|
+
itemParam = (0, _formExtHelper.applyDealwithFormParamExt)({
|
|
198
|
+
itemParam: itemParam,
|
|
199
|
+
FlowCommon: FlowCommon,
|
|
200
|
+
module: module,
|
|
201
|
+
formKey: formKey,
|
|
202
|
+
formCode: this.state.formCode || this.props.formCode,
|
|
203
|
+
component: this
|
|
204
|
+
});
|
|
205
|
+
itemType = itemParam.itemType;
|
|
214
206
|
|
|
215
207
|
this.setState({
|
|
216
208
|
itemParam: itemParam
|
|
@@ -468,6 +460,266 @@ var PageHome = function (_React$Component) {
|
|
|
468
460
|
return itemParam;
|
|
469
461
|
}
|
|
470
462
|
|
|
463
|
+
// 解析子表列数(扩展在 dealwithCommonFormParam / dealwithFormParamExt 中设置 itemParam.subColumnCount)
|
|
464
|
+
|
|
465
|
+
}, {
|
|
466
|
+
key: 'resolveSubColumnCount',
|
|
467
|
+
value: function resolveSubColumnCount(props) {
|
|
468
|
+
var p = props || this.props;
|
|
469
|
+
return (0, _formExtHelper.resolveSubColumnCountFromConfig)({
|
|
470
|
+
itemParam: this.state.itemParam,
|
|
471
|
+
detailForm: p.form,
|
|
472
|
+
subColumnCount: p.subColumnCount,
|
|
473
|
+
allForm: p.allForm
|
|
474
|
+
});
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
// 占满整行的字段类型(多列模式下仍单列展示)
|
|
478
|
+
|
|
479
|
+
}, {
|
|
480
|
+
key: 'isSubFormFieldFullWidth',
|
|
481
|
+
value: function isSubFormFieldFullWidth(itemType) {
|
|
482
|
+
return itemType === 'textarea' || itemType === 'comment' || itemType === 'upload' || itemType === 'image' || itemType === 'html' || itemType === 'note' || itemType === 'title' || itemType === 'detail';
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
// 子表多列时可自动增高、内容换行的字段(单行文本/浮点等)
|
|
486
|
+
|
|
487
|
+
}, {
|
|
488
|
+
key: 'isSubFormFieldAutoWrap',
|
|
489
|
+
value: function isSubFormFieldAutoWrap(itemType) {
|
|
490
|
+
return itemType === 'text';
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
// 下拉、时间(右侧箭头需与值同一行对齐)
|
|
494
|
+
|
|
495
|
+
}, {
|
|
496
|
+
key: 'isSubFormFieldPickType',
|
|
497
|
+
value: function isSubFormFieldPickType(itemType) {
|
|
498
|
+
return itemType === 'select' || itemType === 'datetime';
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
// 子表多列字段单元格 class
|
|
502
|
+
|
|
503
|
+
}, {
|
|
504
|
+
key: 'getSubFormFieldSlotClass',
|
|
505
|
+
value: function getSubFormFieldSlotClass(multiCol, fullWidth, itemType) {
|
|
506
|
+
if (!multiCol || fullWidth) {
|
|
507
|
+
return '';
|
|
508
|
+
}
|
|
509
|
+
if (this.isSubFormFieldAutoWrap(itemType)) {
|
|
510
|
+
return 'subform-col-field-slot subform-col-field-slot-text';
|
|
511
|
+
}
|
|
512
|
+
if (this.isSubFormFieldPickType(itemType)) {
|
|
513
|
+
return 'subform-col-field-slot subform-col-field-slot-pick';
|
|
514
|
+
}
|
|
515
|
+
return 'subform-col-field-slot subform-col-field-slot-fixed';
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
// 子表标签样式:多列去掉边距;单列不覆盖边距,与主表 SaltUI 默认一致
|
|
519
|
+
|
|
520
|
+
}, {
|
|
521
|
+
key: 'getSubFormLabelCssText',
|
|
522
|
+
value: function getSubFormLabelCssText(isMultiCol) {
|
|
523
|
+
var ts = this.props.formStyle && this.props.formStyle.titleStyle ? this.props.formStyle.titleStyle : {};
|
|
524
|
+
var css = {
|
|
525
|
+
fontSize: '14px',
|
|
526
|
+
lineHeight: '24px',
|
|
527
|
+
color: 'rgb(51, 51, 51)',
|
|
528
|
+
fontWeight: 'bold',
|
|
529
|
+
background: 'transparent'
|
|
530
|
+
};
|
|
531
|
+
if (isMultiCol) {
|
|
532
|
+
css.marginLeft = '0';
|
|
533
|
+
css.padding = '4px 0 0 0';
|
|
534
|
+
css.paddingLeft = '0';
|
|
535
|
+
css.paddingRight = '0';
|
|
536
|
+
}
|
|
537
|
+
if (ts.fontSize) {
|
|
538
|
+
css.fontSize = ts.fontSize;
|
|
539
|
+
}
|
|
540
|
+
if (ts.color) {
|
|
541
|
+
css.color = ts.color;
|
|
542
|
+
}
|
|
543
|
+
if (ts.fontWeight) {
|
|
544
|
+
css.fontWeight = ts.fontWeight;
|
|
545
|
+
}
|
|
546
|
+
if (ts.fontFamily) {
|
|
547
|
+
css.fontFamily = ts.fontFamily;
|
|
548
|
+
}
|
|
549
|
+
if (ts.fontStyle) {
|
|
550
|
+
css.fontStyle = ts.fontStyle;
|
|
551
|
+
}
|
|
552
|
+
var parts = [];
|
|
553
|
+
Object.keys(css).forEach(function (k) {
|
|
554
|
+
var key = k.replace(/[A-Z]/g, function (m) {
|
|
555
|
+
return '-' + m.toLowerCase();
|
|
556
|
+
});
|
|
557
|
+
parts.push(key + ':' + css[k]);
|
|
558
|
+
});
|
|
559
|
+
return parts.join(';');
|
|
560
|
+
}
|
|
561
|
+
}, {
|
|
562
|
+
key: 'renderSubFormLabelStyle',
|
|
563
|
+
value: function renderSubFormLabelStyle(isMultiCol) {
|
|
564
|
+
if (!isMultiCol) {
|
|
565
|
+
return null;
|
|
566
|
+
}
|
|
567
|
+
var scope = '.subform-fields-wrap.subform-fields-multi';
|
|
568
|
+
var labelCss = this.getSubFormLabelCssText(true);
|
|
569
|
+
return _react2.default.createElement('style', { dangerouslySetInnerHTML: { __html: [scope + ' .t-field-layout-v-label,', scope + ' .t-field-layout-v-label-left,', scope + ' .t-field-layout-h-label,', scope + ' .t-field-layout-h-label-left{' + labelCss + '}', scope + ' .t-field-layout-v-label,' + scope + ' .t-field-layout-h-label{color:rgb(51,51,51)!important;margin-left:0!important;padding-left:0!important;padding-right:0!important;}'].join('') } });
|
|
570
|
+
}
|
|
571
|
+
|
|
572
|
+
// 子表多列布局样式(按行分组,避免 flex-wrap 导致错位)
|
|
573
|
+
|
|
574
|
+
}, {
|
|
575
|
+
key: 'renderSubFormFieldsStyle',
|
|
576
|
+
value: function renderSubFormFieldsStyle(subColumnCount) {
|
|
577
|
+
if (subColumnCount <= 1) {
|
|
578
|
+
return null;
|
|
579
|
+
}
|
|
580
|
+
var scope = '.subform-fields-wrap.subform-fields-multi';
|
|
581
|
+
var row = scope + ' .subform-fields-row';
|
|
582
|
+
var slot = scope + ' .subform-field-col>.subform-col-field-slot';
|
|
583
|
+
var col = scope + ' .subform-col-field';
|
|
584
|
+
var text = scope + ' .subform-col-field-slot-text';
|
|
585
|
+
var pick = scope + ' .subform-col-field-slot-pick';
|
|
586
|
+
var pickCol = pick + ' ' + col;
|
|
587
|
+
return _react2.default.createElement('style', { dangerouslySetInnerHTML: { __html: [scope + '{display:block;}', row + '{display:flex;align-items:stretch;width:100%;border-bottom:0.5px solid #e9ebee;box-sizing:border-box;}', scope + ' .subform-field-full{width:100%;box-sizing:border-box;border-bottom:0.5px solid #e9ebee;}', scope + ' .subform-field-col{display:flex;flex-direction:column;box-sizing:border-box;}', scope + ' .subform-field-col-empty{visibility:hidden;}', slot + '{box-sizing:border-box;padding:8px 16px 8px 0;overflow:hidden;}', col + '{width:100%;}', col + ' .t-group-list{border-bottom:none!important;background:transparent;}', col + ' .t-group-list-item::after{display:none!important;}', col + '>.t-group-list>.t-group-list-item::after{display:none!important;}', col + ' .t-field-box.t-field-content-box{display:flex!important;flex-direction:column!important;align-items:stretch!important;width:100%!important;min-height:0!important;padding-left:0!important;padding-right:0!important;}', col + ' .t-field-layout-h-label,' + col + ' .t-field-layout-v-label,' + col + ' .t-field-layout-v-label-left{width:100%!important;max-width:100%!important;margin-left:0!important;padding-left:0!important;padding-right:0!important;color:rgb(51,51,51)!important;background:transparent!important;}', col + ' .t-field-box{padding-left:0!important;padding-right:0!important;}', col + ' .t-field-content-box{justify-content:flex-start!important;align-items:flex-start!important;}', col + ' .t-field-content-box .t-FB1,' + col + ' .t-field-multi{width:100%!important;max-width:100%!important;padding:0 0 4px 0!important;text-align:left!important;}', col + ' .t-field-content-box .t-FB1 span,' + col + ' .t-field-multi span,' + col + ' .t-text-field-content-main span{text-align:left!important;word-break:break-word;}', col + ' .t-text-field-content{width:100%;justify-content:flex-start!important;}', col + ' .t-text-field-input{text-align:left!important;}', text + ' .t-text-field-input,' + text + ' .t-text-field-content-main span{white-space:normal!important;word-wrap:break-word;word-break:break-word;line-height:20px;}', text + ' .t-text-field-placeholder.t-DN{display:none!important;}', pickCol + '.t-field.t-select-field.t-FBH,' + pickCol + '.t-field.t-datetime-field.t-FBH{display:block!important;position:relative!important;width:100%!important;}', pickCol + '.t-field-pos-box{width:100%!important;padding-right:28px!important;box-sizing:border-box;}', pickCol + '.t-field-layout-v-label{margin-left:0!important;padding-left:0!important;}', pickCol + '.t-field-content-box{display:flex!important;flex-direction:row!important;align-items:center!important;justify-content:flex-start!important;width:100%!important;min-height:24px!important;padding:2px 0 11px 0!important;}', pickCol + '.t-field-pos-icon{position:absolute!important;right:0!important;top:auto!important;bottom:10px!important;margin:0!important;height:26px!important;display:flex!important;align-items:center!important;justify-content:center!important;}', pickCol + '.t-select-field-content,' + pickCol + '.t-datetime-field-value,' + pickCol + '.t-datetime-field-placeholder,' + pickCol + '.t-select-field-placeholder{min-height:24px!important;line-height:24px!important;}', pickCol + '.t-field-content-box>.t-FB1{flex:1!important;width:100%!important;min-width:0!important;max-width:100%!important;padding:0!important;text-align:left!important;}', pickCol + '.t-select-field-content,' + pickCol + '.t-field-content-box>.t-FB1>div{width:100%!important;text-align:left!important;}', pickCol + '.t-select-field-placeholder,' + pickCol + '.t-datetime-field-placeholder,' + pickCol + '.t-select-field-value,' + pickCol + '.t-datetime-field-value{text-align:left!important;justify-content:flex-start!important;width:100%!important;}', pickCol + '.t-select-field-placeholder,' + pickCol + '.t-datetime-field-placeholder{position:static!important;height:auto!important;line-height:24px!important;flex:none!important;max-width:100%!important;}', pickCol + '.t-select-field-value,' + pickCol + '.t-datetime-field-value{display:flex!important;flex-direction:row!important;align-items:center!important;flex-wrap:nowrap!important;}', pickCol + '.t-select-field-value .t-FB1,' + pickCol + '.t-datetime-field-value .t-FB1,' + pickCol + '.t-select-field-value span,' + pickCol + '.t-datetime-field-value span{text-align:left!important;width:100%!important;}'].join('') } });
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
// 将字段列表按列数拆成行(整行字段单独成行)
|
|
591
|
+
|
|
592
|
+
}, {
|
|
593
|
+
key: 'buildSubFormFieldRows',
|
|
594
|
+
value: function buildSubFormFieldRows(formFields, subColumnCount) {
|
|
595
|
+
var t = this;
|
|
596
|
+
var rows = [];
|
|
597
|
+
var currentRow = [];
|
|
598
|
+
formFields.forEach(function (item2) {
|
|
599
|
+
if (t.isSubFormFieldFullWidth(item2.itemType)) {
|
|
600
|
+
if (currentRow.length) {
|
|
601
|
+
rows.push({ type: 'cols', fields: currentRow });
|
|
602
|
+
currentRow = [];
|
|
603
|
+
}
|
|
604
|
+
rows.push({ type: 'full', field: item2 });
|
|
605
|
+
} else {
|
|
606
|
+
currentRow.push(item2);
|
|
607
|
+
if (currentRow.length >= subColumnCount) {
|
|
608
|
+
rows.push({ type: 'cols', fields: currentRow });
|
|
609
|
+
currentRow = [];
|
|
610
|
+
}
|
|
611
|
+
}
|
|
612
|
+
});
|
|
613
|
+
if (currentRow.length) {
|
|
614
|
+
rows.push({ type: 'cols', fields: currentRow });
|
|
615
|
+
}
|
|
616
|
+
return rows;
|
|
617
|
+
}
|
|
618
|
+
|
|
619
|
+
// 渲染子表一行内的单个字段(公共 props)
|
|
620
|
+
|
|
621
|
+
}, {
|
|
622
|
+
key: 'renderSubFormFieldForm',
|
|
623
|
+
value: function renderSubFormFieldForm(item2, rowIndex, subColumnCount) {
|
|
624
|
+
var t = this;
|
|
625
|
+
var formEl = _react2.default.createElement(_form2.default, {
|
|
626
|
+
className: 'subform_' + item2.uniqueName,
|
|
627
|
+
keyNo: rowIndex,
|
|
628
|
+
ref: item2.uniqueName + '_' + rowIndex,
|
|
629
|
+
dataType: 'sub',
|
|
630
|
+
subTblName: t.state.itemParam.key,
|
|
631
|
+
module: t.state.module,
|
|
632
|
+
formKey: item2.formKey,
|
|
633
|
+
status: t.state.status,
|
|
634
|
+
form: item2,
|
|
635
|
+
allForm: t.props.allForm,
|
|
636
|
+
formStyle: t.props.formStyle,
|
|
637
|
+
data: t.state.itemParam.value[rowIndex],
|
|
638
|
+
fieldControll: t.state.fieldControll,
|
|
639
|
+
caIsPrd: t.props.caIsPrd,
|
|
640
|
+
preCaFields: t.props.preCaFields,
|
|
641
|
+
formRelaFieldMaps: t.props.formRelaFieldMaps,
|
|
642
|
+
linkFields: t.props.linkFields,
|
|
643
|
+
onChange: t.changeSub.bind(t, t.state.itemParam, rowIndex),
|
|
644
|
+
reloadSubItemParam: t.reloadSubItemParam.bind(t)
|
|
645
|
+
});
|
|
646
|
+
if (subColumnCount > 1) {
|
|
647
|
+
return _react2.default.cloneElement(formEl, { subColumnCount: subColumnCount });
|
|
648
|
+
}
|
|
649
|
+
return formEl;
|
|
650
|
+
}
|
|
651
|
+
|
|
652
|
+
// 渲染子表一行内的字段列表(仅 subColumnCount>1 时多列布局,为 1 时与原版一致)
|
|
653
|
+
|
|
654
|
+
}, {
|
|
655
|
+
key: 'renderSubFormFields',
|
|
656
|
+
value: function renderSubFormFields(formFields, rowIndex) {
|
|
657
|
+
var t = this;
|
|
658
|
+
var subColumnCount = t.resolveSubColumnCount(t.props);
|
|
659
|
+
|
|
660
|
+
if (subColumnCount <= 1) {
|
|
661
|
+
return formFields.map(function (item2, j) {
|
|
662
|
+
return t.renderSubFormFieldForm(item2, rowIndex, subColumnCount);
|
|
663
|
+
});
|
|
664
|
+
}
|
|
665
|
+
|
|
666
|
+
var colWidth = 100 / subColumnCount + '%';
|
|
667
|
+
var rows = t.buildSubFormFieldRows(formFields, subColumnCount);
|
|
668
|
+
return _react2.default.createElement(
|
|
669
|
+
'div',
|
|
670
|
+
null,
|
|
671
|
+
t.renderSubFormFieldsStyle(subColumnCount),
|
|
672
|
+
_react2.default.createElement(
|
|
673
|
+
'div',
|
|
674
|
+
{ className: 'subform-fields-wrap subform-fields-multi' },
|
|
675
|
+
rows.map(function (row, ri) {
|
|
676
|
+
if (row.type === 'full') {
|
|
677
|
+
var fullField = row.field;
|
|
678
|
+
return _react2.default.createElement(
|
|
679
|
+
'div',
|
|
680
|
+
{ key: fullField.uniqueName || 'full_' + ri, className: 'subform-field-full' },
|
|
681
|
+
_react2.default.createElement(
|
|
682
|
+
'div',
|
|
683
|
+
{ className: t.getSubFormFieldSlotClass(true, true, fullField.itemType) },
|
|
684
|
+
t.renderSubFormFieldForm(fullField, rowIndex, subColumnCount)
|
|
685
|
+
)
|
|
686
|
+
);
|
|
687
|
+
}
|
|
688
|
+
var cells = [];
|
|
689
|
+
for (var ci = 0; ci < subColumnCount; ci++) {
|
|
690
|
+
var cellField = row.fields[ci];
|
|
691
|
+
if (cellField) {
|
|
692
|
+
cells.push(_react2.default.createElement(
|
|
693
|
+
'div',
|
|
694
|
+
{
|
|
695
|
+
key: cellField.uniqueName || 'col_' + ri + '_' + ci,
|
|
696
|
+
className: 'subform-field-col',
|
|
697
|
+
style: { width: colWidth, boxSizing: 'border-box' }
|
|
698
|
+
},
|
|
699
|
+
_react2.default.createElement(
|
|
700
|
+
'div',
|
|
701
|
+
{ className: t.getSubFormFieldSlotClass(true, false, cellField.itemType) },
|
|
702
|
+
t.renderSubFormFieldForm(cellField, rowIndex, subColumnCount)
|
|
703
|
+
)
|
|
704
|
+
));
|
|
705
|
+
} else {
|
|
706
|
+
cells.push(_react2.default.createElement('div', {
|
|
707
|
+
key: 'empty_' + ri + '_' + ci,
|
|
708
|
+
className: 'subform-field-col subform-field-col-empty',
|
|
709
|
+
style: { width: colWidth, boxSizing: 'border-box' }
|
|
710
|
+
}));
|
|
711
|
+
}
|
|
712
|
+
}
|
|
713
|
+
return _react2.default.createElement(
|
|
714
|
+
'div',
|
|
715
|
+
{ key: 'row_' + ri, className: 'subform-fields-row' },
|
|
716
|
+
cells
|
|
717
|
+
);
|
|
718
|
+
})
|
|
719
|
+
)
|
|
720
|
+
);
|
|
721
|
+
}
|
|
722
|
+
|
|
471
723
|
//明细显示隐藏(全部)
|
|
472
724
|
|
|
473
725
|
}, {
|
|
@@ -741,9 +993,7 @@ var PageHome = function (_React$Component) {
|
|
|
741
993
|
_react2.default.createElement(
|
|
742
994
|
'div',
|
|
743
995
|
{ className: item.show ? "" : "t-DN" },
|
|
744
|
-
item.form
|
|
745
|
-
return _react2.default.createElement(_form2.default, { className: "subform_" + item2.uniqueName, keyNo: i, ref: item2.uniqueName + '_' + i, dataType: 'sub', subTblName: t.state.itemParam.key, module: t.state.module, formKey: item2.formKey, status: t.state.status, form: item2, allForm: t.props.allForm, formStyle: t.props.formStyle, data: t.state.itemParam.value[i], fieldControll: t.state.fieldControll, caIsPrd: t.props.caIsPrd, preCaFields: t.props.preCaFields, formRelaFieldMaps: t.props.formRelaFieldMaps, linkFields: t.props.linkFields, onChange: _this2.changeSub.bind(_this2, _this2.state.itemParam, i), reloadSubItemParam: _this2.reloadSubItemParam.bind(_this2) });
|
|
746
|
-
})
|
|
996
|
+
t.renderSubFormFields(item.form, i)
|
|
747
997
|
)
|
|
748
998
|
);
|
|
749
999
|
});
|
|
@@ -890,6 +1140,7 @@ var PageHome = function (_React$Component) {
|
|
|
890
1140
|
_react2.default.createElement(
|
|
891
1141
|
'div',
|
|
892
1142
|
{ className: this.state.itemParam.show ? "" : 't-DN' },
|
|
1143
|
+
t.renderSubFormLabelStyle(t.resolveSubColumnCount(t.props) > 1),
|
|
893
1144
|
this.getDetai()
|
|
894
1145
|
),
|
|
895
1146
|
_react2.default.createElement(
|
package/lib/form/table.js
CHANGED
|
@@ -2314,6 +2314,43 @@ var PageHome = function (_React$Component) {
|
|
|
2314
2314
|
// })
|
|
2315
2315
|
// }
|
|
2316
2316
|
|
|
2317
|
+
// 子表列数:走 form_common / flow_common / mobileExt 现有扩展(dealwithCommonFormParam、dealwithFormParamExt)
|
|
2318
|
+
|
|
2319
|
+
}, {
|
|
2320
|
+
key: 'getSubColumnCount',
|
|
2321
|
+
value: function getSubColumnCount(detailItem) {
|
|
2322
|
+
var t = this;
|
|
2323
|
+
if (detailItem && detailItem.__subColumnCountResolved != null) {
|
|
2324
|
+
return detailItem.__subColumnCountResolved;
|
|
2325
|
+
}
|
|
2326
|
+
var allForm = t.props.allForm;
|
|
2327
|
+
var formKey = allForm && allForm.formcode;
|
|
2328
|
+
var formCode = t.state.formCode || t.props.formCode || '';
|
|
2329
|
+
var module = t.props.module;
|
|
2330
|
+
var flowCommonRef = FlowCommon;
|
|
2331
|
+
if (!flowCommonRef && formCode) {
|
|
2332
|
+
var loaded = (0, _formExtHelper.loadFlowOrFormCommon)({ formCode: formCode, module: module || '' });
|
|
2333
|
+
flowCommonRef = loaded.FlowCommon;
|
|
2334
|
+
}
|
|
2335
|
+
var itemParam = (0, _formExtHelper.applyDealwithFormParamExt)({
|
|
2336
|
+
detailForm: detailItem,
|
|
2337
|
+
FlowCommon: flowCommonRef,
|
|
2338
|
+
module: module,
|
|
2339
|
+
formKey: formKey,
|
|
2340
|
+
formCode: formCode,
|
|
2341
|
+
component: t
|
|
2342
|
+
});
|
|
2343
|
+
var count = (0, _formExtHelper.resolveSubColumnCountFromConfig)({
|
|
2344
|
+
itemParam: itemParam,
|
|
2345
|
+
detailForm: detailItem,
|
|
2346
|
+
subColumnCount: t.props.subColumnCount,
|
|
2347
|
+
allForm: allForm
|
|
2348
|
+
});
|
|
2349
|
+
if (detailItem) {
|
|
2350
|
+
detailItem.__subColumnCountResolved = count;
|
|
2351
|
+
}
|
|
2352
|
+
return count;
|
|
2353
|
+
}
|
|
2317
2354
|
}, {
|
|
2318
2355
|
key: 'render',
|
|
2319
2356
|
value: function render() {
|
|
@@ -2343,7 +2380,7 @@ var PageHome = function (_React$Component) {
|
|
|
2343
2380
|
}.bind(this)) : item.itemType == 'detail' ? _react2.default.createElement(
|
|
2344
2381
|
'div',
|
|
2345
2382
|
{ className: "subform_" + item.itemCode },
|
|
2346
|
-
_react2.default.createElement(_subForm2.default, { keyNo: i, ref: 'sub_' + item.itemCode, operate: t.props.operate, newspyj: t.props.newspyj, hasCommentField: t.props.hasCommentField, commentUpload: t.props.commentUpload, commentField: t.props.commentField, commentAttitude: t.props.commentAttitude, module: t.props.module, formKey: t.props.allForm.formcode, status: t.props.status, form: item, allForm: t.props.allForm, formStyle: t.props.formStyleObj, isCaUser: t.props.isCaUser, caFirm: t.props.caFirm, caESignatureName: t.props.caESignatureName, caFormSign: t.props.caFormSign, commentList: t.props.commentFieldList, defaultValue: t.props.defaultValue, data: t.props.data, fieldControll: t.props.fieldControll, caIsPrd: t.props.caIsPrd, preCaFields: t.props.preCaFields, formRelaFieldMaps: t.state.formRelaFieldMaps, linkFields: t.state.linkFields, isRemoveCommentFormHtml: t.props.isRemoveCommentFormHtml, inscriptionShow: t.props.inscriptionShow, onChange: this.change.bind(this) })
|
|
2383
|
+
_react2.default.createElement(_subForm2.default, { keyNo: i, ref: 'sub_' + item.itemCode, subColumnCount: t.getSubColumnCount(item), operate: t.props.operate, newspyj: t.props.newspyj, hasCommentField: t.props.hasCommentField, commentUpload: t.props.commentUpload, commentField: t.props.commentField, commentAttitude: t.props.commentAttitude, module: t.props.module, formKey: t.props.allForm.formcode, status: t.props.status, form: item, allForm: t.props.allForm, formStyle: t.props.formStyleObj, isCaUser: t.props.isCaUser, caFirm: t.props.caFirm, caESignatureName: t.props.caESignatureName, caFormSign: t.props.caFormSign, commentList: t.props.commentFieldList, defaultValue: t.props.defaultValue, data: t.props.data, fieldControll: t.props.fieldControll, caIsPrd: t.props.caIsPrd, preCaFields: t.props.preCaFields, formRelaFieldMaps: t.state.formRelaFieldMaps, linkFields: t.state.linkFields, isRemoveCommentFormHtml: t.props.isRemoveCommentFormHtml, inscriptionShow: t.props.inscriptionShow, onChange: this.change.bind(this) })
|
|
2347
2384
|
) : _react2.default.createElement(
|
|
2348
2385
|
'div',
|
|
2349
2386
|
{ className: "form_" + item.uniqueName },
|
|
@@ -2379,7 +2416,7 @@ var PageHome = function (_React$Component) {
|
|
|
2379
2416
|
}.bind(this)) : item.itemType == 'detail' ? _react2.default.createElement(
|
|
2380
2417
|
'div',
|
|
2381
2418
|
{ className: t.state.active == item.tabCode ? "" : "t-DN" },
|
|
2382
|
-
_react2.default.createElement(_subForm2.default, { className: "subform_" + item.itemCode, keyNo: i, ref: 'sub_' + item.itemCode, operate: t.props.operate, newspyj: t.props.newspyj, hasCommentField: t.props.hasCommentField, commentUpload: t.props.commentUpload, commentAttitude: t.props.commentAttitude, commentField: t.props.commentField, module: t.props.module, formKey: t.props.allForm.formcode, isCaUser: t.props.isCaUser, caFirm: t.props.caFirm, caESignatureName: t.props.caESignatureName, caFormSign: t.props.caFormSign, status: t.props.status, form: item, allForm: t.props.allForm, formStyle: t.props.formStyleObj, commentList: t.props.commentFieldList, inscriptionShow: t.props.inscriptionShow, data: t.props.data, fieldControll: t.props.fieldControll, onChange: this.change.bind(this) })
|
|
2419
|
+
_react2.default.createElement(_subForm2.default, { className: "subform_" + item.itemCode, keyNo: i, ref: 'sub_' + item.itemCode, subColumnCount: t.getSubColumnCount(item), operate: t.props.operate, newspyj: t.props.newspyj, hasCommentField: t.props.hasCommentField, commentUpload: t.props.commentUpload, commentAttitude: t.props.commentAttitude, commentField: t.props.commentField, module: t.props.module, formKey: t.props.allForm.formcode, isCaUser: t.props.isCaUser, caFirm: t.props.caFirm, caESignatureName: t.props.caESignatureName, caFormSign: t.props.caFormSign, status: t.props.status, form: item, allForm: t.props.allForm, formStyle: t.props.formStyleObj, commentList: t.props.commentFieldList, inscriptionShow: t.props.inscriptionShow, data: t.props.data, fieldControll: t.props.fieldControll, onChange: this.change.bind(this) })
|
|
2383
2420
|
) : _react2.default.createElement(
|
|
2384
2421
|
'div',
|
|
2385
2422
|
{ className: t.state.active == item.tabCode ? "" : "t-DN" },
|
|
@@ -349,6 +349,7 @@ var PageHome = function (_React$Component) {
|
|
|
349
349
|
userId: loginUserId,
|
|
350
350
|
formItem: [],
|
|
351
351
|
formStyleObj: {}, //表单字体样式
|
|
352
|
+
subColumnCount: props.subColumnCount != null && props.subColumnCount !== '' ? props.subColumnCount : 1, //子表每行列数,默认1
|
|
352
353
|
formTblName: '',
|
|
353
354
|
dataId: dataId,
|
|
354
355
|
formId: props.formId,
|
|
@@ -7786,7 +7787,7 @@ var PageHome = function (_React$Component) {
|
|
|
7786
7787
|
_react2.default.createElement(
|
|
7787
7788
|
_Group2.default.List,
|
|
7788
7789
|
null,
|
|
7789
|
-
this.state.tableStatus == '0' ? "" : _react2.default.createElement(_table2.default, { module: this.state.module, operate: this.state.operate, editType: this.state.editType, dataId: this.state.dataId, hasCommentField: t.state.hasCommentField, newspyj: t.state.newspyj, commentField: t.state.commentField, commentAttitude: t.state.commentAttitude, status: t.state.status, form: t.state.formItem, formStyleObj: t.state.formStyleObj, allForm: t.state.form, data: t.state.editFormData, commentFieldList: t.state.commentFieldList, defaultValue: t.state.defaultValue, commentDefaultList: t.state.commentDefaultList, commentBackList: t.state.commentBackList, fieldControll: t.state.fieldControll, caIsPrd: t.state.caIsPrd, preCaFields: t.state.preCaFields, formRelaField: t.state.formRelaField, isRemoveCommentFormHtml: t.state.isRemoveCommentFormHtml, commentUpload: t.state.commentUpload, isCaUser: t.state.isCaUser, caFirm: t.state.caFirm, caESignatureName: t.state.caESignatureName, caFormSign: t.state.caFormSign, inscriptionShow: t.state.inscriptionShow, onChange: this.change.bind(this) })
|
|
7790
|
+
this.state.tableStatus == '0' ? "" : _react2.default.createElement(_table2.default, { module: this.state.module, operate: this.state.operate, editType: this.state.editType, dataId: this.state.dataId, hasCommentField: t.state.hasCommentField, newspyj: t.state.newspyj, commentField: t.state.commentField, commentAttitude: t.state.commentAttitude, status: t.state.status, form: t.state.formItem, formStyleObj: t.state.formStyleObj, subColumnCount: t.state.subColumnCount, allForm: t.state.form, data: t.state.editFormData, commentFieldList: t.state.commentFieldList, defaultValue: t.state.defaultValue, commentDefaultList: t.state.commentDefaultList, commentBackList: t.state.commentBackList, fieldControll: t.state.fieldControll, caIsPrd: t.state.caIsPrd, preCaFields: t.state.preCaFields, formRelaField: t.state.formRelaField, isRemoveCommentFormHtml: t.state.isRemoveCommentFormHtml, commentUpload: t.state.commentUpload, isCaUser: t.state.isCaUser, caFirm: t.state.caFirm, caESignatureName: t.state.caESignatureName, caFormSign: t.state.caFormSign, inscriptionShow: t.state.inscriptionShow, onChange: this.change.bind(this) })
|
|
7790
7791
|
)
|
|
7791
7792
|
)
|
|
7792
7793
|
)
|
package/lib/tblform/README.md
CHANGED
|
@@ -325,8 +325,11 @@ export default {
|
|
|
325
325
|
// table: TblForm 实例(可访问 refs)
|
|
326
326
|
},
|
|
327
327
|
|
|
328
|
-
/**
|
|
329
|
-
dealwithCommonFormParam(itemParam,
|
|
328
|
+
/** 字段参数处理(子表 SubForm 加载时也会调用,可设置 subColumnCount: 1-4) */
|
|
329
|
+
dealwithCommonFormParam(itemParam, subForm) {
|
|
330
|
+
if (itemParam.key === 'sub_tbl_1') {
|
|
331
|
+
itemParam.subColumnCount = 2;
|
|
332
|
+
}
|
|
330
333
|
return itemParam;
|
|
331
334
|
},
|
|
332
335
|
|
|
@@ -345,12 +348,18 @@ window.test_lizhao0316_mobileExt = {
|
|
|
345
348
|
dealwithFormItemChangeExt(itemParam, table, callback) {
|
|
346
349
|
// callback([{ type: 'main', key: 'f11$', data: '联动值' }]);
|
|
347
350
|
},
|
|
348
|
-
dealwithFormParamExt(itemParam,
|
|
351
|
+
dealwithFormParamExt(itemParam, subForm) {
|
|
352
|
+
// 子表多列:在现有扩展里赋值 subColumnCount(1-4),SubForm/Table 会自动读取
|
|
353
|
+
if (itemParam.key === 'sub_tbl_1') {
|
|
354
|
+
itemParam.subColumnCount = 2;
|
|
355
|
+
}
|
|
349
356
|
return itemParam;
|
|
350
357
|
},
|
|
351
358
|
};
|
|
352
359
|
```
|
|
353
360
|
|
|
361
|
+
流程表单在 `pages/flow_common/{module}.js` 的 **`dealwithCommonFormParam`** 中同样可设置 `itemParam.subColumnCount`;流程页还可通过 `{module}_{formKey}_mobileExt.dealwithFormParamExt` 按子表编码区分列数。无需新增扩展方法名。
|
|
362
|
+
|
|
354
363
|
### 手动加载扩展(高级)
|
|
355
364
|
|
|
356
365
|
```javascript
|
package/lib/tblform/TblForm.js
CHANGED
|
@@ -81,6 +81,7 @@ var TblForm = function (_BaseTable) {
|
|
|
81
81
|
allForm: null,
|
|
82
82
|
editFormData: null,
|
|
83
83
|
formStyleObj: {},
|
|
84
|
+
subColumnCount: props.subColumnCount != null && props.subColumnCount !== '' ? props.subColumnCount : 1,
|
|
84
85
|
fieldControll: {},
|
|
85
86
|
status: '0',
|
|
86
87
|
operate: '',
|
|
@@ -135,6 +136,7 @@ var TblForm = function (_BaseTable) {
|
|
|
135
136
|
allForm: normalized.allForm,
|
|
136
137
|
editFormData: normalized.editFormData,
|
|
137
138
|
formStyleObj: normalized.formStyleObj,
|
|
139
|
+
subColumnCount: normalized.subColumnCount != null ? normalized.subColumnCount : t.props.subColumnCount != null ? t.props.subColumnCount : 1,
|
|
138
140
|
fieldControll: normalized.fieldControll,
|
|
139
141
|
status: normalized.status,
|
|
140
142
|
operate: editType || 'add',
|
|
@@ -22,6 +22,7 @@ function buildFormFieldProps(t, formItem) {
|
|
|
22
22
|
form: formItem,
|
|
23
23
|
allForm: t.state.allForm,
|
|
24
24
|
formStyle: t.state.formStyleObj,
|
|
25
|
+
subColumnCount: t.state.subColumnCount,
|
|
25
26
|
data: t.state.editFormData,
|
|
26
27
|
fieldControll: t.state.fieldControll,
|
|
27
28
|
isRemoveCommentFormHtml: '1',
|
|
@@ -154,6 +154,7 @@ function normalizePureMobileForm(content, editType) {
|
|
|
154
154
|
editFormData: formData,
|
|
155
155
|
status: editTypeToStatus(editType),
|
|
156
156
|
fieldControll: buildFieldControllForEditType(formItem, form.formTblName, editType),
|
|
157
|
-
formStyleObj: form.formStyleObj || {}
|
|
157
|
+
formStyleObj: form.formStyleObj || {},
|
|
158
|
+
subColumnCount: form.subColumnCount != null && form.subColumnCount !== '' ? form.subColumnCount : 1
|
|
158
159
|
};
|
|
159
160
|
}
|