cui-print 1.0.28
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 +29 -0
- package/dist/font/iconfont.css +151 -0
- package/dist/font/iconfont.js +1 -0
- package/dist/font/iconfont.json +247 -0
- package/dist/font/iconfont.ttf +0 -0
- package/dist/font/iconfont.woff +0 -0
- package/dist/font/iconfont.woff2 +0 -0
- package/dist/index.css +1 -0
- package/dist/index.es.js +51053 -0
- package/dist/index.umd.js +1030 -0
- package/dist/print-designer-api/create-style/create-base-component-style.js +116 -0
- package/dist/print-designer-api/create-style/create-complex-table-style.js +472 -0
- package/dist/print-designer-api/create-style/create-form-component-style.js +78 -0
- package/dist/print-designer-api/create-style/create-form-item-style.js +144 -0
- package/dist/print-designer-api/create-style/create-grid-style.js +49 -0
- package/dist/print-designer-api/create-style/create-table-layout-style.js +128 -0
- package/dist/print-designer-api/create-style/create-table-style.js +93 -0
- package/dist/print-designer-api/print-designer-helper.js +912 -0
- package/dist/print-designer-api/print-designer-style-helper.js +96 -0
- package/dist/print-designer-api/print-designer-utils.js +27 -0
- package/dist/print-designer-api/print-global-style/base.less +20 -0
- package/dist/print-designer-api/print-global-style/common.less +3 -0
- package/dist/print-designer-api/print-global-style/custom.less +4 -0
- package/dist/print-designer-api/print-global-style/index.css +812 -0
- package/dist/print-designer-api/print-global-style/index.js +813 -0
- package/dist/print-designer-api/print-global-style/index.less +9 -0
- package/dist/print-designer-api/print-global-style/print-base-component.less +123 -0
- package/dist/print-designer-api/print-global-style/print-container.less +57 -0
- package/dist/print-designer-api/print-global-style/print-continue/index.less +14 -0
- package/dist/print-designer-api/print-global-style/print-continue/print-complex-table/auto-continue-not-span.less +61 -0
- package/dist/print-designer-api/print-global-style/print-continue/print-complex-table/auto-continue-preview.less +12 -0
- package/dist/print-designer-api/print-global-style/print-continue/print-complex-table/auto-continue-span.less +88 -0
- package/dist/print-designer-api/print-global-style/print-continue/print-complex-table/fixed-continue.less +37 -0
- package/dist/print-designer-api/print-global-style/print-continue/print-complex-table/index.less +96 -0
- package/dist/print-designer-api/print-global-style/print-continue/print-complex-table/pagination-preview.less +12 -0
- package/dist/print-designer-api/print-global-style/print-continue/print-complex-table/pagination.less +61 -0
- package/dist/print-designer-api/print-global-style/print-form-component.less +161 -0
- package/dist/print-designer-api/print-global-style/print-form-item.less +162 -0
- package/dist/print-designer-api/print-global-style/printing.less +16 -0
- package/dist/print-designer-api/print-soket.js +31 -0
- package/dist/print-designer-api/use-create-html/create-html-utils.js +43 -0
- package/dist/print-designer-api/use-create-html/index.js +287 -0
- package/dist/print-designer-api/use-create-html/use-base-component-helper.js +129 -0
- package/dist/print-designer-api/use-create-html/use-complex-table-helper/complex-table-tools.js +129 -0
- package/dist/print-designer-api/use-create-html/use-complex-table-helper/create-table-header.js +111 -0
- package/dist/print-designer-api/use-create-html/use-complex-table-helper/index.js +87 -0
- package/dist/print-designer-api/use-create-html/use-complex-table-helper/use-auto-height-preview.js +84 -0
- package/dist/print-designer-api/use-create-html/use-complex-table-helper/use-auto-height.js +379 -0
- package/dist/print-designer-api/use-create-html/use-complex-table-helper/use-default.js +75 -0
- package/dist/print-designer-api/use-create-html/use-complex-table-helper/use-fixed-height.js +220 -0
- package/dist/print-designer-api/use-create-html/use-complex-table-helper/use-pagination-preview.js +84 -0
- package/dist/print-designer-api/use-create-html/use-complex-table-helper/use-pagination.js +272 -0
- package/dist/print-designer-api/use-create-html/use-form-component-helper.js +164 -0
- package/dist/print-designer-api/use-create-html/use-format/index.js +102 -0
- package/dist/print-designer-api/use-create-html/use-format/use-complex-table-auto.js +337 -0
- package/dist/print-designer-api/use-create-html/use-format/use-complex-table-fiexd.js +233 -0
- package/dist/print-designer-api/use-create-html/use-format/use-complex-table-pagination.js +286 -0
- package/dist/print-designer-api/use-create-html/use-grid-helper.js +35 -0
- package/dist/print-designer-api/use-create-html/use-table-layout-helper.js +213 -0
- package/dist/print-designer-api/use-create-print-js/index.js +147 -0
- package/dist/print-designer-api/use-create-print-js/use-base-component-helper.js +54 -0
- package/dist/print-designer-api/use-create-print-js/use-form-component-helper.js +4 -0
- package/dist/print-designer-api/use-create-print-js/use-table-layout-helper.js +5 -0
- package/dist/print-designer-images/demo.jpg +0 -0
- package/dist/print-designer-images/demo02.jpg +0 -0
- package/dist/style/default-style.css +137 -0
- package/dist/style/main.less +66 -0
- package/dist/test/base/designer-config.js +594 -0
- package/dist/test/base/index.js +3 -0
- package/dist/test/base/print-data.js +40 -0
- package/dist/test/complex-table/designer-config.js +1668 -0
- package/dist/test/complex-table/index.js +3 -0
- package/dist/test/complex-table/print-data.js +294 -0
- package/dist/test/form/designer-config.js +2057 -0
- package/dist/test/form/index.js +3 -0
- package/dist/test/form/print-data.js +38 -0
- package/dist/test/index.js +4 -0
- package/dist/wui-print-designer-plugins/JsBarcode.all.min.js +2 -0
- package/dist/wui-print-designer-plugins/qrcode.min.js +1 -0
- package/package.json +65 -0
package/dist/print-designer-api/use-create-html/use-complex-table-helper/use-pagination-preview.js
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { deepCopy, camelToKebab } from "../../print-designer-utils";
|
|
2
|
+
import printDesignerStyleHelper from "../../print-designer-style-helper";
|
|
3
|
+
import complexTableTools from "./complex-table-tools";
|
|
4
|
+
import createTableHeader from "./create-table-header";
|
|
5
|
+
export default ({ printData, printConfig, formConfig, layoutConfig, createHtmlByComponentItem, errorLogs } = {}) => {
|
|
6
|
+
const createComplexTableHtml = (complexTableDetails) => {
|
|
7
|
+
return _createHtml({ complexTableDetails });
|
|
8
|
+
};
|
|
9
|
+
function _createHtml({ complexTableDetails } = {}) {
|
|
10
|
+
let complexTableHtml = "";
|
|
11
|
+
let { spanHeaderCellDict, spanHeaderCellList } = complexTableTools.createHeaderSpanDetails({ complexTableDetails });
|
|
12
|
+
let headerRowLength = complexTableDetails.props.headerRow;
|
|
13
|
+
let colLength = complexTableDetails.props.col;
|
|
14
|
+
let tableData = complexTableTools.getTableData({ complexTableDetails, printData });
|
|
15
|
+
for (let rowIndex = 0; rowIndex < headerRowLength; rowIndex++) {
|
|
16
|
+
let headerCellHtml = ``;
|
|
17
|
+
for (let colIndex = 0; colIndex < colLength; colIndex++) {
|
|
18
|
+
let nowCellHtml = createTableHeader.getHeaderCellHtml({ rowIndex, colIndex, spanHeaderCellList, complexTableDetails });
|
|
19
|
+
headerCellHtml += nowCellHtml;
|
|
20
|
+
}
|
|
21
|
+
let rowHtml = `<tr class="complex-table-header-tr" header-index="${rowIndex}">${headerCellHtml}</tr>`;
|
|
22
|
+
complexTableHtml += rowHtml;
|
|
23
|
+
}
|
|
24
|
+
for (let rowIndex = 0; rowIndex < tableData.length; rowIndex++) {
|
|
25
|
+
let contentCellHtml = ``;
|
|
26
|
+
for (let colIndex = 0; colIndex < colLength; colIndex++) {
|
|
27
|
+
let nowCellHtml = _getContentCellHtml({ rowIndex, colIndex, tableData, complexTableDetails });
|
|
28
|
+
contentCellHtml += nowCellHtml;
|
|
29
|
+
}
|
|
30
|
+
let rowHtml = `<tr class="complex-table-content-tr" content-index="${rowIndex}">${contentCellHtml}</tr>`;
|
|
31
|
+
complexTableHtml += rowHtml;
|
|
32
|
+
}
|
|
33
|
+
complexTableHtml = `<table class="print-complex-table print-complex-table--pagination-preview"
|
|
34
|
+
style="${printDesignerStyleHelper.createComplexTableStyle({
|
|
35
|
+
propsConfig: complexTableDetails.props,
|
|
36
|
+
styleConfig: complexTableDetails.style
|
|
37
|
+
})}"
|
|
38
|
+
cellspacing="0"
|
|
39
|
+
cellpadding="0">${complexTableHtml}
|
|
40
|
+
</table>`;
|
|
41
|
+
return complexTableHtml;
|
|
42
|
+
}
|
|
43
|
+
function _getContentCellHtml({ rowIndex, colIndex, tableData, complexTableDetails } = {}) {
|
|
44
|
+
let propsConfig = complexTableDetails.props;
|
|
45
|
+
let styleConfig = complexTableDetails.style;
|
|
46
|
+
let contentCellHtml = "";
|
|
47
|
+
contentCellHtml = `<td style="${printDesignerStyleHelper.createComplexTableContentTdStyle({
|
|
48
|
+
complexTablePropsConfig: propsConfig,
|
|
49
|
+
complexTableStyleConfig: styleConfig
|
|
50
|
+
})}"><div class="content-text" style="${printDesignerStyleHelper.createComplexTableContentTdContainerStyle({
|
|
51
|
+
complexTablePropsConfig: propsConfig,
|
|
52
|
+
complexTableStyleConfig: styleConfig
|
|
53
|
+
})}">${_createContentTdText({ rowIndex, colIndex, tableData, complexTableDetails })}</div></td>`;
|
|
54
|
+
return contentCellHtml;
|
|
55
|
+
}
|
|
56
|
+
function _createContentTdText({ rowIndex, colIndex, tableData, complexTableDetails } = {}) {
|
|
57
|
+
let propsConfig = complexTableDetails.props;
|
|
58
|
+
if (!propsConfig.columnsField || !propsConfig.columnsField[colIndex]) {
|
|
59
|
+
return "";
|
|
60
|
+
}
|
|
61
|
+
if (!tableData[rowIndex]) {
|
|
62
|
+
return "";
|
|
63
|
+
}
|
|
64
|
+
let columnField = propsConfig.columnsField[colIndex].field;
|
|
65
|
+
let columnFieldList = columnField.split("&#");
|
|
66
|
+
let nowContentTdText = "";
|
|
67
|
+
columnFieldList.forEach((filed) => {
|
|
68
|
+
let columnItemText = tableData[rowIndex][filed];
|
|
69
|
+
if (!columnItemText && columnItemText !== 0) {
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
columnItemText = `${columnItemText}`;
|
|
73
|
+
columnItemText = columnItemText
|
|
74
|
+
.replace(/[\s\n]+$/, "")
|
|
75
|
+
.replace(/ /g, " ")
|
|
76
|
+
.replace(/\n/g, "<br>");
|
|
77
|
+
nowContentTdText += columnItemText;
|
|
78
|
+
});
|
|
79
|
+
return nowContentTdText;
|
|
80
|
+
}
|
|
81
|
+
return {
|
|
82
|
+
createComplexTableHtml
|
|
83
|
+
};
|
|
84
|
+
};
|
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
import { deepCopy, camelToKebab } from "../../print-designer-utils";
|
|
2
|
+
import printDesignerStyleHelper from "../../print-designer-style-helper";
|
|
3
|
+
import complexTableTools from "./complex-table-tools";
|
|
4
|
+
import createTableHeader from "./create-table-header";
|
|
5
|
+
export default ({ printData, printConfig, formConfig, layoutConfig, createHtmlByComponentItem, errorLogs } = {}) => {
|
|
6
|
+
const createComplexTableHtml = (complexTableDetails) => {
|
|
7
|
+
if (!complexTableDetails._tablePaginationConfig) {
|
|
8
|
+
return "";
|
|
9
|
+
}
|
|
10
|
+
if (!!complexTableDetails._tablePaginationConfig && complexTableDetails._tablePaginationConfig.type == "pagination_default") {
|
|
11
|
+
return _createHtml({ complexTableDetails });
|
|
12
|
+
}
|
|
13
|
+
if (
|
|
14
|
+
!!complexTableDetails._tablePaginationConfig &&
|
|
15
|
+
complexTableDetails._tablePaginationConfig.type == "pagination_afterBlankRow"
|
|
16
|
+
) {
|
|
17
|
+
// 添加表格含空白内容
|
|
18
|
+
return _createHtmlHasBlankContent({ complexTableDetails });
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
function _createHtml({ complexTableDetails } = {}) {
|
|
22
|
+
let complexTableHtml = "";
|
|
23
|
+
let { spanHeaderCellDict, spanHeaderCellList } = complexTableTools.createHeaderSpanDetails({ complexTableDetails });
|
|
24
|
+
let headerRowLength = complexTableDetails.props.headerRow;
|
|
25
|
+
let colLength = complexTableDetails.props.col;
|
|
26
|
+
let tableData = complexTableTools.getTableData({ complexTableDetails, printData });
|
|
27
|
+
for (let rowIndex = 0; rowIndex < headerRowLength; rowIndex++) {
|
|
28
|
+
let headerCellHtml = ``;
|
|
29
|
+
for (let colIndex = 0; colIndex < colLength; colIndex++) {
|
|
30
|
+
let nowCellHtml = createTableHeader.getHeaderCellHtml({ rowIndex, colIndex, spanHeaderCellList, complexTableDetails });
|
|
31
|
+
headerCellHtml += nowCellHtml;
|
|
32
|
+
}
|
|
33
|
+
let rowHtml = `<tr class="complex-table-header-tr" header-index="${rowIndex}">${headerCellHtml}</tr>`;
|
|
34
|
+
complexTableHtml += rowHtml;
|
|
35
|
+
}
|
|
36
|
+
for (let rowIndex = 0; rowIndex < tableData.length; rowIndex++) {
|
|
37
|
+
let contentCellHtml = ``;
|
|
38
|
+
for (let colIndex = 0; colIndex < colLength; colIndex++) {
|
|
39
|
+
let nowCellHtml = _getContentCellHtml({ rowIndex, colIndex, tableData, complexTableDetails });
|
|
40
|
+
contentCellHtml += nowCellHtml;
|
|
41
|
+
}
|
|
42
|
+
let rowHtml = `<tr class="${_formatContentTrClass({
|
|
43
|
+
complexTableDetails,
|
|
44
|
+
rowData: tableData[rowIndex]
|
|
45
|
+
})}" content-index="${rowIndex}">${contentCellHtml}</tr>`;
|
|
46
|
+
complexTableHtml += rowHtml;
|
|
47
|
+
}
|
|
48
|
+
let tableClassList = ["print-complex-table", "print-complex-table--pagination"];
|
|
49
|
+
let tableClass = tableClassList.join(" ");
|
|
50
|
+
complexTableHtml = `<table class="${tableClass}"
|
|
51
|
+
style="${printDesignerStyleHelper.createComplexTableStyle({
|
|
52
|
+
propsConfig: complexTableDetails.props,
|
|
53
|
+
styleConfig: complexTableDetails.style
|
|
54
|
+
})}"
|
|
55
|
+
cellspacing="0"
|
|
56
|
+
cellpadding="0">${complexTableHtml}
|
|
57
|
+
</table>`;
|
|
58
|
+
let isPaginationEnabled = complexTableDetails.props.isPaginationEnabled;
|
|
59
|
+
if (!!isPaginationEnabled) {
|
|
60
|
+
complexTableHtml += _getPaginationHtml({ complexTableDetails });
|
|
61
|
+
}
|
|
62
|
+
return complexTableHtml;
|
|
63
|
+
}
|
|
64
|
+
function _createHtmlHasBlankContent({ complexTableDetails } = {}) {
|
|
65
|
+
let complexTableHtml = "";
|
|
66
|
+
let { spanHeaderCellDict, spanHeaderCellList } = complexTableTools.createHeaderSpanDetails({ complexTableDetails });
|
|
67
|
+
let headerRowLength = complexTableDetails.props.headerRow;
|
|
68
|
+
let colLength = complexTableDetails.props.col;
|
|
69
|
+
let tableData = complexTableTools.getTableData({ complexTableDetails, printData });
|
|
70
|
+
let tablePaginationConfig = complexTableDetails._tablePaginationConfig;
|
|
71
|
+
for (let rowIndex = 0; rowIndex < headerRowLength; rowIndex++) {
|
|
72
|
+
let headerCellHtml = ``;
|
|
73
|
+
for (let colIndex = 0; colIndex < colLength; colIndex++) {
|
|
74
|
+
let nowCellHtml = createTableHeader.getHeaderCellHtml({ rowIndex, colIndex, spanHeaderCellList, complexTableDetails });
|
|
75
|
+
headerCellHtml += nowCellHtml;
|
|
76
|
+
}
|
|
77
|
+
let rowHtml = `<tr class="complex-table-header-tr" header-index="${rowIndex}">${headerCellHtml}</tr>`;
|
|
78
|
+
complexTableHtml += rowHtml;
|
|
79
|
+
}
|
|
80
|
+
for (let rowIndex = 0; rowIndex < tableData.length; rowIndex++) {
|
|
81
|
+
let contentCellHtml = ``;
|
|
82
|
+
for (let colIndex = 0; colIndex < colLength; colIndex++) {
|
|
83
|
+
let nowCellHtml = _getContentCellHtml({ rowIndex, colIndex, tableData, complexTableDetails });
|
|
84
|
+
contentCellHtml += nowCellHtml;
|
|
85
|
+
}
|
|
86
|
+
let rowHtml = `<tr class="${_formatContentTrClass({
|
|
87
|
+
complexTableDetails,
|
|
88
|
+
rowData: tableData[rowIndex]
|
|
89
|
+
})}" content-index="${rowIndex}">${contentCellHtml}</tr>`;
|
|
90
|
+
complexTableHtml += rowHtml;
|
|
91
|
+
}
|
|
92
|
+
for (let rowIndex = 0; rowIndex < tablePaginationConfig.blankRowCount; rowIndex++) {
|
|
93
|
+
let contentCellHtml = ``;
|
|
94
|
+
for (let colIndex = 0; colIndex < colLength; colIndex++) {
|
|
95
|
+
let nowCellHtml = _getBlankContentCellHtml({ rowIndex, colIndex, complexTableDetails });
|
|
96
|
+
contentCellHtml += nowCellHtml;
|
|
97
|
+
}
|
|
98
|
+
let rowHtml = `<tr class="complex-table-blank-tr complex-table-blank-tr--after" blank-index="${rowIndex}">${contentCellHtml}</tr>`;
|
|
99
|
+
complexTableHtml += rowHtml;
|
|
100
|
+
}
|
|
101
|
+
let tableClassList = ["print-complex-table", "print-complex-table--pagination"];
|
|
102
|
+
let tableClass = tableClassList.join(" ");
|
|
103
|
+
complexTableHtml = `<table class="${tableClass}"
|
|
104
|
+
style="${printDesignerStyleHelper.createComplexTableStyle({
|
|
105
|
+
propsConfig: complexTableDetails.props,
|
|
106
|
+
styleConfig: complexTableDetails.style
|
|
107
|
+
})}"
|
|
108
|
+
cellspacing="0"
|
|
109
|
+
cellpadding="0">${complexTableHtml}
|
|
110
|
+
</table>`;
|
|
111
|
+
let isPaginationEnabled = complexTableDetails.props.isPaginationEnabled;
|
|
112
|
+
if (!!isPaginationEnabled) {
|
|
113
|
+
complexTableHtml += _getPaginationHtml({ complexTableDetails });
|
|
114
|
+
}
|
|
115
|
+
return complexTableHtml;
|
|
116
|
+
}
|
|
117
|
+
function _getContentCellHtml({ rowIndex, colIndex, tableData, complexTableDetails } = {}) {
|
|
118
|
+
let propsConfig = complexTableDetails.props;
|
|
119
|
+
let styleConfig = complexTableDetails.style;
|
|
120
|
+
let contentCellHtml = "";
|
|
121
|
+
let rowData = tableData[rowIndex];
|
|
122
|
+
if (!!rowData._paginationMode_type && rowData._paginationMode_type == "excessBlankRow" && rowIndex > 0) {
|
|
123
|
+
// 超出的空白行
|
|
124
|
+
contentCellHtml = `<td style="${printDesignerStyleHelper.createComplexTableContentTdStyle({
|
|
125
|
+
complexTablePropsConfig: propsConfig,
|
|
126
|
+
complexTableStyleConfig: styleConfig
|
|
127
|
+
})}"><div></div></td>`;
|
|
128
|
+
return contentCellHtml;
|
|
129
|
+
}
|
|
130
|
+
if (!!rowData._paginationMode_type && rowData._paginationMode_type == "excessBlankRow" && rowIndex === 0) {
|
|
131
|
+
// 超出的空白行 跨页
|
|
132
|
+
contentCellHtml = `<td style="${printDesignerStyleHelper.createComplexTableContentTdStyle({
|
|
133
|
+
complexTablePropsConfig: propsConfig,
|
|
134
|
+
complexTableStyleConfig: styleConfig
|
|
135
|
+
})}"><div class="excess-td-container" style="${_createExcessBlankRowTdContainerStyle({
|
|
136
|
+
rowIndex,
|
|
137
|
+
colIndex,
|
|
138
|
+
tableData,
|
|
139
|
+
complexTableDetails
|
|
140
|
+
})}"><div style="${printDesignerStyleHelper.createComplexTableContentTdContainerStyle({
|
|
141
|
+
complexTablePropsConfig: propsConfig,
|
|
142
|
+
complexTableStyleConfig: styleConfig
|
|
143
|
+
})}${_createExcessBlankRowTdContainerContentStyle({
|
|
144
|
+
rowIndex,
|
|
145
|
+
colIndex,
|
|
146
|
+
tableData,
|
|
147
|
+
complexTableDetails
|
|
148
|
+
})}">${_createContentTdText({
|
|
149
|
+
rowIndex,
|
|
150
|
+
colIndex,
|
|
151
|
+
tableData,
|
|
152
|
+
complexTableDetails
|
|
153
|
+
})}</div></div></td>`;
|
|
154
|
+
return contentCellHtml;
|
|
155
|
+
}
|
|
156
|
+
// 其他情况
|
|
157
|
+
contentCellHtml = `<td style="${printDesignerStyleHelper.createComplexTableContentTdStyle({
|
|
158
|
+
complexTablePropsConfig: propsConfig,
|
|
159
|
+
complexTableStyleConfig: styleConfig
|
|
160
|
+
})}"><div style="${printDesignerStyleHelper.createComplexTableContentTdContainerStyle({
|
|
161
|
+
complexTablePropsConfig: propsConfig,
|
|
162
|
+
complexTableStyleConfig: styleConfig
|
|
163
|
+
})}">${_createContentTdText({ rowIndex, colIndex, tableData, complexTableDetails })}</div></td>`;
|
|
164
|
+
return contentCellHtml;
|
|
165
|
+
}
|
|
166
|
+
function _createContentTdText({ rowIndex, colIndex, tableData, complexTableDetails } = {}) {
|
|
167
|
+
let propsConfig = complexTableDetails.props;
|
|
168
|
+
if (!propsConfig.columnsField || !propsConfig.columnsField[colIndex]) {
|
|
169
|
+
return "";
|
|
170
|
+
}
|
|
171
|
+
if (!tableData[rowIndex]) {
|
|
172
|
+
return "";
|
|
173
|
+
}
|
|
174
|
+
let columnField = propsConfig.columnsField[colIndex].field;
|
|
175
|
+
let columnFieldList = columnField.split("&#");
|
|
176
|
+
let nowContentTdText = "";
|
|
177
|
+
columnFieldList.forEach((filed) => {
|
|
178
|
+
let columnItemText = tableData[rowIndex][filed];
|
|
179
|
+
if (!columnItemText && columnItemText !== 0) {
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
columnItemText = `${columnItemText}`;
|
|
183
|
+
columnItemText = columnItemText
|
|
184
|
+
.replace(/[\s\n]+$/, "")
|
|
185
|
+
.replace(/ /g, " ")
|
|
186
|
+
.replace(/\n/g, "<br>");
|
|
187
|
+
nowContentTdText += columnItemText;
|
|
188
|
+
});
|
|
189
|
+
return nowContentTdText;
|
|
190
|
+
}
|
|
191
|
+
function _getBlankContentCellHtml({ rowIndex, colIndex, tableData, complexTableDetails } = {}) {
|
|
192
|
+
let propsConfig = complexTableDetails.props;
|
|
193
|
+
let styleConfig = complexTableDetails.style;
|
|
194
|
+
let contentCellHtml = "";
|
|
195
|
+
contentCellHtml = `<td style="${printDesignerStyleHelper.createComplexTableContentTdStyle({
|
|
196
|
+
complexTablePropsConfig: propsConfig,
|
|
197
|
+
complexTableStyleConfig: styleConfig
|
|
198
|
+
})}"><div style="${printDesignerStyleHelper.createComplexTableContentTdContainerStyle({
|
|
199
|
+
complexTablePropsConfig: propsConfig,
|
|
200
|
+
complexTableStyleConfig: styleConfig
|
|
201
|
+
})}"></div></td>`;
|
|
202
|
+
return contentCellHtml;
|
|
203
|
+
}
|
|
204
|
+
function _getPaginationHtml({ complexTableDetails } = {}) {
|
|
205
|
+
let paginationHtml = `<div class="print-complex-table_pagination">第${complexTableDetails._tablePaginationConfig.currentPage}页</div>`;
|
|
206
|
+
return paginationHtml;
|
|
207
|
+
}
|
|
208
|
+
function _createExcessBlankRowTdContainerStyle({ rowIndex, colIndex, tableData, complexTableDetails }) {
|
|
209
|
+
let propsConfig = complexTableDetails.props;
|
|
210
|
+
if (!propsConfig.columnsField || !propsConfig.columnsField[colIndex]) {
|
|
211
|
+
return "";
|
|
212
|
+
}
|
|
213
|
+
let nowRow = tableData[rowIndex];
|
|
214
|
+
if (!nowRow) {
|
|
215
|
+
return "";
|
|
216
|
+
}
|
|
217
|
+
let styleText = "";
|
|
218
|
+
let styleObj = {};
|
|
219
|
+
let containerHeight =
|
|
220
|
+
(nowRow._paginationMode_excessRowsLength - nowRow._paginationMode_excessIndex) * propsConfig.contentRowHeight;
|
|
221
|
+
styleObj.height = `${containerHeight}px`;
|
|
222
|
+
Object.keys(styleObj).forEach((key, index) => {
|
|
223
|
+
styleText += `${camelToKebab(key)}:${styleObj[key]};`;
|
|
224
|
+
});
|
|
225
|
+
return styleText;
|
|
226
|
+
}
|
|
227
|
+
function _createExcessBlankRowTdContainerContentStyle({ rowIndex, colIndex, tableData, complexTableDetails }) {
|
|
228
|
+
let propsConfig = complexTableDetails.props;
|
|
229
|
+
if (!propsConfig.columnsField || !propsConfig.columnsField[colIndex]) {
|
|
230
|
+
return "";
|
|
231
|
+
}
|
|
232
|
+
let nowRow = tableData[rowIndex];
|
|
233
|
+
if (!nowRow) {
|
|
234
|
+
return "";
|
|
235
|
+
}
|
|
236
|
+
let styleText = "";
|
|
237
|
+
let styleObj = {
|
|
238
|
+
position: "absolute",
|
|
239
|
+
top: 0,
|
|
240
|
+
left: 0,
|
|
241
|
+
right: 0
|
|
242
|
+
};
|
|
243
|
+
let topSpace = (nowRow._paginationMode_excessIndex + 1) * propsConfig.contentRowHeight;
|
|
244
|
+
styleObj.top = `-${topSpace}px`;
|
|
245
|
+
Object.keys(styleObj).forEach((key, index) => {
|
|
246
|
+
styleText += `${camelToKebab(key)}:${styleObj[key]};`;
|
|
247
|
+
});
|
|
248
|
+
return styleText;
|
|
249
|
+
}
|
|
250
|
+
function _formatContentTrClass({ complexTableDetails, rowData }) {
|
|
251
|
+
let classList = ["complex-table-content-tr"];
|
|
252
|
+
if (
|
|
253
|
+
!!rowData._paginationMode_type &&
|
|
254
|
+
rowData._paginationMode_type == "notExcess" &&
|
|
255
|
+
rowData._paginationMode_excessRowsLength >= 1
|
|
256
|
+
) {
|
|
257
|
+
classList.push("complex-table-content-tr--excess-blank-begin");
|
|
258
|
+
} else if (
|
|
259
|
+
!!rowData._paginationMode_type &&
|
|
260
|
+
rowData._paginationMode_type == "excessBlankRow" &&
|
|
261
|
+
rowData._paginationMode_excessIndex == rowData._paginationMode_excessRowsLength - 1
|
|
262
|
+
) {
|
|
263
|
+
classList.push("complex-table-content-tr--excess-blank-end");
|
|
264
|
+
} else if (!!rowData._paginationMode_type && rowData._paginationMode_type == "excessBlankRow") {
|
|
265
|
+
classList.push("complex-table-content-tr--excess-blank");
|
|
266
|
+
}
|
|
267
|
+
return classList.join(" ");
|
|
268
|
+
}
|
|
269
|
+
return {
|
|
270
|
+
createComplexTableHtml
|
|
271
|
+
};
|
|
272
|
+
};
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import printDesignerStyleHelper from "../print-designer-style-helper";
|
|
2
|
+
import createHtmlUtils from "./create-html-utils";
|
|
3
|
+
export default ({ printData, printConfig, formConfig, layoutConfig, errorLogs } = {}) => {
|
|
4
|
+
const createInputHtml = (componentItem) => {
|
|
5
|
+
let text = printData[componentItem.props.field];
|
|
6
|
+
let inputHtml = `<div class="print-form_input print-form_input--${_getComponentSize(
|
|
7
|
+
componentItem
|
|
8
|
+
)} ${createHtmlUtils.formatComponentClass({
|
|
9
|
+
componentItem
|
|
10
|
+
})}" style="${printDesignerStyleHelper.createInputStyle({
|
|
11
|
+
styleConfig: componentItem.style
|
|
12
|
+
})}">${text}</div>`;
|
|
13
|
+
return _createFormItemHtml(componentItem, inputHtml);
|
|
14
|
+
};
|
|
15
|
+
const createTextareaHtml = (componentItem) => {
|
|
16
|
+
let text = printData[componentItem.props.field];
|
|
17
|
+
if (!text) {
|
|
18
|
+
text = "";
|
|
19
|
+
}
|
|
20
|
+
text = text.replace(/ /g, " ").replace(/\n/g, "<br>");
|
|
21
|
+
let textareaHtml = `<div class="print-form_textarea print-form_textarea--${_getComponentSize(
|
|
22
|
+
componentItem
|
|
23
|
+
)} ${createHtmlUtils.formatComponentClass({
|
|
24
|
+
componentItem
|
|
25
|
+
})}" style="${printDesignerStyleHelper.createTextareaStyle({
|
|
26
|
+
styleConfig: componentItem.style,
|
|
27
|
+
formConfig,
|
|
28
|
+
formComponentProps: componentItem.formComponentProps
|
|
29
|
+
})}">${text}</div>`;
|
|
30
|
+
return _createFormItemHtml(componentItem, textareaHtml);
|
|
31
|
+
};
|
|
32
|
+
const createRadioHtml = (componentItem) => {
|
|
33
|
+
let value = printData[componentItem.props.field];
|
|
34
|
+
let dataSource = [];
|
|
35
|
+
if (Array.isArray(componentItem.props.dataSource)) {
|
|
36
|
+
dataSource = componentItem.props.dataSource;
|
|
37
|
+
}
|
|
38
|
+
let radioGroupHtml = ``;
|
|
39
|
+
dataSource.forEach((item, index) => {
|
|
40
|
+
let radioClassList = [];
|
|
41
|
+
if (item.value === value) {
|
|
42
|
+
radioClassList.push("print-form_radio--active");
|
|
43
|
+
}
|
|
44
|
+
let radioHtml = `<div class="print-form_radio ${radioClassList.join(" ")}">
|
|
45
|
+
<div class="print-form_radio-icon"></div>
|
|
46
|
+
<div class="print-form_radio-label">${item.label}</div>
|
|
47
|
+
</div>`;
|
|
48
|
+
radioGroupHtml += radioHtml;
|
|
49
|
+
});
|
|
50
|
+
radioGroupHtml = `<div class="print-form_radio-group print-form_radio-group--${_getComponentSize(
|
|
51
|
+
componentItem
|
|
52
|
+
)} ${createHtmlUtils.formatComponentClass({
|
|
53
|
+
componentItem
|
|
54
|
+
})}">${radioGroupHtml}</div>`;
|
|
55
|
+
return _createFormItemHtml(componentItem, radioGroupHtml);
|
|
56
|
+
};
|
|
57
|
+
const createCheckboxHtml = (componentItem) => {
|
|
58
|
+
let value = printData[componentItem.props.field];
|
|
59
|
+
let dataSource = [];
|
|
60
|
+
if (Array.isArray(componentItem.props.dataSource)) {
|
|
61
|
+
dataSource = componentItem.props.dataSource;
|
|
62
|
+
}
|
|
63
|
+
let valueList = value.split(",");
|
|
64
|
+
let checkboxGroupHtml = ``;
|
|
65
|
+
dataSource.forEach((item, index) => {
|
|
66
|
+
let checkboxClassList = [];
|
|
67
|
+
if (valueList.indexOf(item.value) >= 0) {
|
|
68
|
+
checkboxClassList.push("print-form_checkbox--active");
|
|
69
|
+
}
|
|
70
|
+
let checkboxHtml = `<div class="print-form_checkbox ${checkboxClassList.join(" ")}">
|
|
71
|
+
<div class="print-form_checkbox-icon"></div>
|
|
72
|
+
<div class="print-form_checkbox-label">${item.label}</div>
|
|
73
|
+
</div>`;
|
|
74
|
+
checkboxGroupHtml += checkboxHtml;
|
|
75
|
+
});
|
|
76
|
+
checkboxGroupHtml = `<div class="print-form_checkbox-group print-form_checkbox-group--${_getComponentSize(
|
|
77
|
+
componentItem
|
|
78
|
+
)} ${createHtmlUtils.formatComponentClass({
|
|
79
|
+
componentItem
|
|
80
|
+
})}">${checkboxGroupHtml}</div>`;
|
|
81
|
+
return _createFormItemHtml(componentItem, checkboxGroupHtml);
|
|
82
|
+
};
|
|
83
|
+
const createSelectHtml = (componentItem) => {
|
|
84
|
+
let value = printData[componentItem.props.field];
|
|
85
|
+
let dataSource = [];
|
|
86
|
+
if (Array.isArray(componentItem.props.dataSource)) {
|
|
87
|
+
dataSource = componentItem.props.dataSource;
|
|
88
|
+
}
|
|
89
|
+
let nowItem = dataSource.find((item, index) => {
|
|
90
|
+
return item.value === value;
|
|
91
|
+
});
|
|
92
|
+
let nowLabel = "";
|
|
93
|
+
if (!!nowItem) {
|
|
94
|
+
nowLabel = nowItem.label;
|
|
95
|
+
}
|
|
96
|
+
let selectHtml = `<div class="print-form_select print-form_select--${_getComponentSize(
|
|
97
|
+
componentItem
|
|
98
|
+
)} ${createHtmlUtils.formatComponentClass({
|
|
99
|
+
componentItem
|
|
100
|
+
})}">${nowLabel}</div>`;
|
|
101
|
+
return _createFormItemHtml(componentItem, selectHtml);
|
|
102
|
+
};
|
|
103
|
+
const createDatetimeHtml = (componentItem) => {
|
|
104
|
+
let text = printData[componentItem.props.field];
|
|
105
|
+
let datetimeHtml = `<div class="print-form_datetime print-form_datetime--${_getComponentSize(
|
|
106
|
+
componentItem
|
|
107
|
+
)} ${createHtmlUtils.formatComponentClass({
|
|
108
|
+
componentItem
|
|
109
|
+
})}" style="${printDesignerStyleHelper.createDatetimeStyle({
|
|
110
|
+
styleConfig: componentItem.style
|
|
111
|
+
})}">${text}</div>`;
|
|
112
|
+
return _createFormItemHtml(componentItem, datetimeHtml);
|
|
113
|
+
};
|
|
114
|
+
function _createFormItemHtml(componentItem, componentHtml) {
|
|
115
|
+
let formItemLabelHtml;
|
|
116
|
+
if (!componentItem.formItemProps.label) {
|
|
117
|
+
formItemLabelHtml = "";
|
|
118
|
+
} else if (!formConfig.props.labelWidth && !componentItem.formItemProps.labelWidth) {
|
|
119
|
+
formItemLabelHtml = "";
|
|
120
|
+
} else {
|
|
121
|
+
formItemLabelHtml = `<label class="print-form-item_label" style="${printDesignerStyleHelper.createFormItemLabelStyle({
|
|
122
|
+
styleConfig: componentItem.style,
|
|
123
|
+
formConfigProps: formConfig.props,
|
|
124
|
+
formItemProps: componentItem.formItemProps
|
|
125
|
+
})}"><p style="${printDesignerStyleHelper.createFormItemLabelContentStyle({
|
|
126
|
+
styleConfig: componentItem.style,
|
|
127
|
+
formConfigProps: formConfig.props,
|
|
128
|
+
formItemProps: componentItem.formItemProps
|
|
129
|
+
})}">${componentItem.formItemProps.label}</p></label>`;
|
|
130
|
+
}
|
|
131
|
+
let formItemContentHtml = `<div class="print-form-item_content" style="${printDesignerStyleHelper.createFormItemMainStyle({
|
|
132
|
+
styleConfig: componentItem.style
|
|
133
|
+
})}">${componentHtml}</div>`;
|
|
134
|
+
let formItemProps = !!componentItem.formItemProps ? componentItem.formItemProps : {};
|
|
135
|
+
let formItemClassList = [];
|
|
136
|
+
if (!!formItemProps.labelPosition) {
|
|
137
|
+
formItemClassList.push(`print-form-item_label-${formItemProps.labelPosition}`);
|
|
138
|
+
}
|
|
139
|
+
let formItemClassStr = formItemClassList.join(" ");
|
|
140
|
+
let formItemHtml = `<div class="print-form-item ${formItemClassStr} ${createHtmlUtils.formatComponentClass({
|
|
141
|
+
componentItem
|
|
142
|
+
})}" style="${printDesignerStyleHelper.createFormItemStyle({
|
|
143
|
+
styleConfig: componentItem.style
|
|
144
|
+
})}">${formItemLabelHtml}${formItemContentHtml}</div>`;
|
|
145
|
+
return formItemHtml;
|
|
146
|
+
}
|
|
147
|
+
function _getComponentSize(componentItem) {
|
|
148
|
+
if (!!componentItem.formComponentProps && !!componentItem.formComponentProps.size) {
|
|
149
|
+
return componentItem.formComponentProps.size;
|
|
150
|
+
}
|
|
151
|
+
if (!!formConfig.props && !!formConfig.props.size) {
|
|
152
|
+
return formConfig.props.size;
|
|
153
|
+
}
|
|
154
|
+
return "default";
|
|
155
|
+
}
|
|
156
|
+
return {
|
|
157
|
+
createInputHtml,
|
|
158
|
+
createTextareaHtml,
|
|
159
|
+
createRadioHtml,
|
|
160
|
+
createCheckboxHtml,
|
|
161
|
+
createSelectHtml,
|
|
162
|
+
createDatetimeHtml
|
|
163
|
+
};
|
|
164
|
+
};
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import useComplexTableFixed from "./use-complex-table-fiexd";
|
|
2
|
+
import useComplexTableAuto from "./use-complex-table-auto";
|
|
3
|
+
import useComplexTablePagination from "./use-complex-table-pagination";
|
|
4
|
+
import { deepCopy } from "../../print-designer-utils";
|
|
5
|
+
export default ({
|
|
6
|
+
printData,
|
|
7
|
+
printConfig,
|
|
8
|
+
formConfig,
|
|
9
|
+
layoutConfig,
|
|
10
|
+
printedRowCount = 0,
|
|
11
|
+
printedRows = [],
|
|
12
|
+
continuePrintElements,
|
|
13
|
+
tablePaginationElements
|
|
14
|
+
} = {}) => {
|
|
15
|
+
const formatLayoutConfig = () => {
|
|
16
|
+
let printModeDetails = _getPrintModeDetails();
|
|
17
|
+
let newLayoutConfig = _formatPrintPagination();
|
|
18
|
+
if (printModeDetails.type == "default") {
|
|
19
|
+
// 默认模式
|
|
20
|
+
return newLayoutConfig;
|
|
21
|
+
}
|
|
22
|
+
let continueConfig = printModeDetails.type == "continuePrint" ? printModeDetails.layoutConfigItem : false;
|
|
23
|
+
let tablePaginationConfig = printModeDetails.type == "tablePagination" ? printModeDetails.layoutConfigItem : false;
|
|
24
|
+
if (!!continueConfig && continueConfig.props.canContinue && continueConfig.props.continuePrintMode == "fixedHeight") {
|
|
25
|
+
// 需要续打 固定高度
|
|
26
|
+
const complexTableFixedInstance = useComplexTableFixed({
|
|
27
|
+
printData,
|
|
28
|
+
printConfig,
|
|
29
|
+
formConfig,
|
|
30
|
+
layoutConfig: newLayoutConfig,
|
|
31
|
+
printedRowCount
|
|
32
|
+
});
|
|
33
|
+
return complexTableFixedInstance.formatLayoutConfig();
|
|
34
|
+
}
|
|
35
|
+
if (!!continueConfig && !!continueConfig.props.canContinue && continueConfig.props.continuePrintMode == "autoHeight") {
|
|
36
|
+
// 需要续打 自适应高度
|
|
37
|
+
const complexTableAutoInstance = useComplexTableAuto({
|
|
38
|
+
printData,
|
|
39
|
+
printConfig,
|
|
40
|
+
formConfig,
|
|
41
|
+
layoutConfig: newLayoutConfig,
|
|
42
|
+
printedRows,
|
|
43
|
+
continuePrintElements
|
|
44
|
+
});
|
|
45
|
+
return complexTableAutoInstance.formatLayoutConfig();
|
|
46
|
+
}
|
|
47
|
+
if (!!tablePaginationConfig) {
|
|
48
|
+
//启用分页
|
|
49
|
+
const complexTablePaginationInstance = useComplexTablePagination({
|
|
50
|
+
printData,
|
|
51
|
+
printConfig,
|
|
52
|
+
formConfig,
|
|
53
|
+
layoutConfig: newLayoutConfig,
|
|
54
|
+
tablePaginationElements
|
|
55
|
+
});
|
|
56
|
+
return complexTablePaginationInstance.formatLayoutConfig();
|
|
57
|
+
}
|
|
58
|
+
return newLayoutConfig;
|
|
59
|
+
};
|
|
60
|
+
function _getPrintModeDetails() {
|
|
61
|
+
let printModeDetails = {
|
|
62
|
+
type: "default",
|
|
63
|
+
layoutConfigItem: false
|
|
64
|
+
};
|
|
65
|
+
if (!layoutConfig || layoutConfig.length <= 0) {
|
|
66
|
+
return printModeDetails;
|
|
67
|
+
}
|
|
68
|
+
layoutConfig.forEach((item, index) => {
|
|
69
|
+
if (!!printModeDetails.layoutConfigItem) {
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
let nowProps = !!item.props ? item.props : {};
|
|
73
|
+
if (item.type == "complexTable" && !!nowProps.canContinue) {
|
|
74
|
+
printModeDetails.type = "continuePrint";
|
|
75
|
+
printModeDetails.layoutConfigItem = deepCopy(item);
|
|
76
|
+
} else if (item.type == "complexTable" && !!nowProps.isPaginationMode && !!nowProps._paginationModePreview) {
|
|
77
|
+
printModeDetails.type = "tablePaginationPreview";
|
|
78
|
+
printModeDetails.layoutConfigItem = deepCopy(item);
|
|
79
|
+
} else if (item.type == "complexTable" && !!nowProps.isPaginationMode && !nowProps._paginationModePreview) {
|
|
80
|
+
printModeDetails.type = "tablePagination";
|
|
81
|
+
printModeDetails.layoutConfigItem = deepCopy(item);
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
return printModeDetails;
|
|
85
|
+
}
|
|
86
|
+
function _formatPrintPagination() {
|
|
87
|
+
let layoutConfigCopy = deepCopy(layoutConfig);
|
|
88
|
+
let newLayoutConfig = [];
|
|
89
|
+
let printPaginationConfig = [{ type: "pageBottom" }, { type: "pageBreak" }, { type: "pageTop" }];
|
|
90
|
+
layoutConfigCopy.forEach((item, index) => {
|
|
91
|
+
if (item.type == "printPagination") {
|
|
92
|
+
newLayoutConfig.push(...printPaginationConfig);
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
newLayoutConfig.push(item);
|
|
96
|
+
});
|
|
97
|
+
return newLayoutConfig;
|
|
98
|
+
}
|
|
99
|
+
return {
|
|
100
|
+
formatLayoutConfig
|
|
101
|
+
};
|
|
102
|
+
};
|