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
|
@@ -0,0 +1,129 @@
|
|
|
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 createPageTopHtml = (componentItem) => {
|
|
5
|
+
let pageBreakHtml = `<div class="print-page-top"></div>`;
|
|
6
|
+
return pageBreakHtml;
|
|
7
|
+
};
|
|
8
|
+
const createPageBottomHtml = (componentItem) => {
|
|
9
|
+
let pageBreakHtml = `<div class="print-page-bottom"></div>`;
|
|
10
|
+
return pageBreakHtml;
|
|
11
|
+
};
|
|
12
|
+
const createPageBreakHtml = (componentItem) => {
|
|
13
|
+
let pageBreakHtml = `<div class="print-page-break"></div>`;
|
|
14
|
+
return pageBreakHtml;
|
|
15
|
+
};
|
|
16
|
+
const createTextHtml = (componentItem) => {
|
|
17
|
+
let titleHtml = `<div class="${createHtmlUtils.formatComponentClass({
|
|
18
|
+
componentItem,
|
|
19
|
+
className: "print-text"
|
|
20
|
+
})}" style="${printDesignerStyleHelper.createTextStyle({
|
|
21
|
+
styleConfig: componentItem.style
|
|
22
|
+
})}">${componentItem.props.defaultContent}</div>`;
|
|
23
|
+
return titleHtml;
|
|
24
|
+
};
|
|
25
|
+
const createDynamicTextHtml = (componentItem) => {
|
|
26
|
+
let text = printData[componentItem.props.field];
|
|
27
|
+
if (!!componentItem.props.isDateTime) {
|
|
28
|
+
text = createHtmlUtils.formatDate({
|
|
29
|
+
dateText: text,
|
|
30
|
+
format: componentItem.props.dateTimeFormat
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
let textHtml = `<div class="${createHtmlUtils.formatComponentClass({
|
|
34
|
+
componentItem,
|
|
35
|
+
className: "print-dynamic-text"
|
|
36
|
+
})}" style="${printDesignerStyleHelper.createDynamicTextStyle({
|
|
37
|
+
styleConfig: componentItem.style
|
|
38
|
+
})}">
|
|
39
|
+
<div class="print-dynamic-text_label" style="${printDesignerStyleHelper.createDynamicTextLabelStyle({
|
|
40
|
+
styleConfig: componentItem.style
|
|
41
|
+
})}">${componentItem.props.label}</div>
|
|
42
|
+
<div class="print-dynamic-text_content" style="${printDesignerStyleHelper.createDynamicTextContentStyle({
|
|
43
|
+
styleConfig: componentItem.style
|
|
44
|
+
})}">${text}</div>
|
|
45
|
+
</div>`;
|
|
46
|
+
return textHtml;
|
|
47
|
+
};
|
|
48
|
+
const createTableHtml = (componentItem) => {
|
|
49
|
+
let tableHtml = `<table class="${createHtmlUtils.formatComponentClass({
|
|
50
|
+
componentItem,
|
|
51
|
+
className: "print-table"
|
|
52
|
+
})}" cellpadding="0" cellspacing="0" style="${printDesignerStyleHelper.createTableStyle({
|
|
53
|
+
styleConfig: componentItem.style
|
|
54
|
+
})}">${_createTableHeaderHtml(componentItem)}${_createTableContentHtml(componentItem)}</table>`;
|
|
55
|
+
return tableHtml;
|
|
56
|
+
};
|
|
57
|
+
function _createTableHeaderHtml(componentItem) {
|
|
58
|
+
let tableHeaderHtml = "";
|
|
59
|
+
componentItem.columns.forEach((columnItem, columnIndex) => {
|
|
60
|
+
tableHeaderHtml += `<th style="${printDesignerStyleHelper.createTableHeaderStyle({
|
|
61
|
+
tableStyleConfig: componentItem.style,
|
|
62
|
+
columnStyleConfig: columnItem.style
|
|
63
|
+
})}">${columnItem.props.headerTitle}</th>`;
|
|
64
|
+
});
|
|
65
|
+
tableHeaderHtml = `<tr>${tableHeaderHtml}</tr>`;
|
|
66
|
+
return tableHeaderHtml;
|
|
67
|
+
}
|
|
68
|
+
function _createTableContentHtml(componentItem) {
|
|
69
|
+
let tableData = printData[componentItem.props.field];
|
|
70
|
+
let tableContentHtml = "";
|
|
71
|
+
tableData.forEach((tableDataItem, tableDataIndex) => {
|
|
72
|
+
let trHtml = "";
|
|
73
|
+
componentItem.columns.forEach((columnItem, columnIndex) => {
|
|
74
|
+
trHtml += `<td style="${printDesignerStyleHelper.createTableCellStyle({
|
|
75
|
+
tableStyleConfig: componentItem.style,
|
|
76
|
+
columnStyleConfig: columnItem.style
|
|
77
|
+
})}">${tableDataItem[columnItem.props.field]}</td>`;
|
|
78
|
+
});
|
|
79
|
+
trHtml = `<tr>${trHtml}</tr>`;
|
|
80
|
+
tableContentHtml += trHtml;
|
|
81
|
+
});
|
|
82
|
+
return tableContentHtml;
|
|
83
|
+
}
|
|
84
|
+
const createBarcodeHtml = (componentItem) => {
|
|
85
|
+
let barcodeHtml = `<div class="${createHtmlUtils.formatComponentClass({
|
|
86
|
+
componentItem,
|
|
87
|
+
className: "print-barcode"
|
|
88
|
+
})}" style="${printDesignerStyleHelper.createBarcodeContainerStyle({
|
|
89
|
+
styleConfig: componentItem.style
|
|
90
|
+
})}"><svg name="barcode_${componentItem.id}"></svg></div>`;
|
|
91
|
+
return barcodeHtml;
|
|
92
|
+
};
|
|
93
|
+
const createQrcodeHtml = (componentItem) => {
|
|
94
|
+
let barcodeHtml = `<div class="${createHtmlUtils.formatComponentClass({
|
|
95
|
+
componentItem,
|
|
96
|
+
className: "print-qrcode"
|
|
97
|
+
})}" style="${printDesignerStyleHelper.createQrcodeContainerStyle({
|
|
98
|
+
styleConfig: componentItem.style
|
|
99
|
+
})}"><div name="qrcode_${componentItem.id}"></div></div>`;
|
|
100
|
+
return barcodeHtml;
|
|
101
|
+
};
|
|
102
|
+
const createImageHtml = (componentItem) => {
|
|
103
|
+
let propsConfig = componentItem.props;
|
|
104
|
+
let imageSrc = "";
|
|
105
|
+
if (!!propsConfig && !propsConfig.field && !!propsConfig.src) {
|
|
106
|
+
imageSrc = propsConfig.src;
|
|
107
|
+
} else if (!!propsConfig && !!propsConfig.field) {
|
|
108
|
+
imageSrc = printData[propsConfig.field];
|
|
109
|
+
}
|
|
110
|
+
let imageHtml = `<div class="${createHtmlUtils.formatComponentClass({
|
|
111
|
+
componentItem,
|
|
112
|
+
className: "print-image"
|
|
113
|
+
})}" style="${printDesignerStyleHelper.createImageContainerStyle({
|
|
114
|
+
styleConfig: componentItem.style
|
|
115
|
+
})}"><img src="${imageSrc}" /></div>`;
|
|
116
|
+
return imageHtml;
|
|
117
|
+
};
|
|
118
|
+
return {
|
|
119
|
+
createPageTopHtml,
|
|
120
|
+
createPageBottomHtml,
|
|
121
|
+
createPageBreakHtml,
|
|
122
|
+
createTextHtml,
|
|
123
|
+
createDynamicTextHtml,
|
|
124
|
+
createTableHtml,
|
|
125
|
+
createBarcodeHtml,
|
|
126
|
+
createQrcodeHtml,
|
|
127
|
+
createImageHtml
|
|
128
|
+
};
|
|
129
|
+
};
|
package/dist/print-designer-api/use-create-html/use-complex-table-helper/complex-table-tools.js
ADDED
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { deepCopy } from "../../print-designer-utils";
|
|
2
|
+
const getHeaderCellId = ({ rowIndex, colIndex } = {}) => {
|
|
3
|
+
return `${rowIndex}-${colIndex}`;
|
|
4
|
+
};
|
|
5
|
+
const createHeaderSpanDetails = ({ complexTableDetails } = {}) => {
|
|
6
|
+
let spanHeaderCellDict = {};
|
|
7
|
+
let spanHeaderCellList = [];
|
|
8
|
+
if (!complexTableDetails.headerLayout || complexTableDetails.headerLayout.length <= 0) {
|
|
9
|
+
return { spanHeaderCellDict, spanHeaderCellList };
|
|
10
|
+
}
|
|
11
|
+
complexTableDetails.headerLayout.forEach((item, index) => {
|
|
12
|
+
let rowspan = !!item.rowspan ? item.rowspan : 1;
|
|
13
|
+
let colspan = !!item.colspan ? item.colspan : 1;
|
|
14
|
+
let minRowIndex = item.rowIndex;
|
|
15
|
+
let maxRowIndex = item.rowIndex + rowspan - 1;
|
|
16
|
+
let minColIndex = item.colIndex;
|
|
17
|
+
let maxColIndex = item.colIndex + colspan - 1;
|
|
18
|
+
let itemSpanCellList = [];
|
|
19
|
+
for (let rowIndex = minRowIndex; rowIndex <= maxRowIndex; rowIndex++) {
|
|
20
|
+
for (let colIndex = minColIndex; colIndex <= maxColIndex; colIndex++) {
|
|
21
|
+
let newCellDetails;
|
|
22
|
+
if (rowIndex === item.rowIndex && colIndex === item.colIndex) {
|
|
23
|
+
newCellDetails = {
|
|
24
|
+
rowIndex,
|
|
25
|
+
colIndex,
|
|
26
|
+
rowspan,
|
|
27
|
+
colspan,
|
|
28
|
+
show: true
|
|
29
|
+
};
|
|
30
|
+
} else {
|
|
31
|
+
newCellDetails = {
|
|
32
|
+
rowIndex,
|
|
33
|
+
colIndex,
|
|
34
|
+
rowspan,
|
|
35
|
+
colspan,
|
|
36
|
+
startRowIndex: item.rowIndex,
|
|
37
|
+
startColIndex: item.colIndex,
|
|
38
|
+
show: false
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
itemSpanCellList.push(newCellDetails);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
spanHeaderCellDict[getHeaderCellId({ rowIndex: item.rowIndex, colIndex: item.colIndex })] = itemSpanCellList;
|
|
45
|
+
spanHeaderCellList.push(...itemSpanCellList);
|
|
46
|
+
});
|
|
47
|
+
return { spanHeaderCellDict, spanHeaderCellList };
|
|
48
|
+
};
|
|
49
|
+
const getHeaderCellShow = ({ rowIndex, colIndex, spanHeaderCellList }) => {
|
|
50
|
+
if (!spanHeaderCellList || spanHeaderCellList.length <= 0) {
|
|
51
|
+
return true;
|
|
52
|
+
}
|
|
53
|
+
let cellItem = spanHeaderCellList.find((item, index) => {
|
|
54
|
+
return rowIndex === item.rowIndex && item.colIndex === colIndex;
|
|
55
|
+
});
|
|
56
|
+
if (!cellItem) {
|
|
57
|
+
return true;
|
|
58
|
+
}
|
|
59
|
+
if (!!cellItem) {
|
|
60
|
+
return cellItem.show;
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
const getRowspan = ({ rowIndex, colIndex, headerLayout } = {}) => {
|
|
64
|
+
let nowRowspan = 1;
|
|
65
|
+
if (!headerLayout || headerLayout.length <= 0) {
|
|
66
|
+
return nowRowspan;
|
|
67
|
+
}
|
|
68
|
+
let cellItem = headerLayout.find((item, index) => {
|
|
69
|
+
return rowIndex === item.rowIndex && item.colIndex === colIndex;
|
|
70
|
+
});
|
|
71
|
+
if (!cellItem) {
|
|
72
|
+
return nowRowspan;
|
|
73
|
+
}
|
|
74
|
+
if (!!cellItem && !!cellItem.rowspan) {
|
|
75
|
+
return cellItem.rowspan;
|
|
76
|
+
}
|
|
77
|
+
return nowRowspan;
|
|
78
|
+
};
|
|
79
|
+
const getColspan = ({ rowIndex, colIndex, headerLayout } = {}) => {
|
|
80
|
+
let nowColspan = 1;
|
|
81
|
+
if (!headerLayout || headerLayout.length <= 0) {
|
|
82
|
+
return nowColspan;
|
|
83
|
+
}
|
|
84
|
+
let cellItem = headerLayout.find((item, index) => {
|
|
85
|
+
return rowIndex === item.rowIndex && item.colIndex === colIndex;
|
|
86
|
+
});
|
|
87
|
+
if (!cellItem) {
|
|
88
|
+
return nowColspan;
|
|
89
|
+
}
|
|
90
|
+
if (!!cellItem && !!cellItem.colspan) {
|
|
91
|
+
return cellItem.colspan;
|
|
92
|
+
}
|
|
93
|
+
return nowColspan;
|
|
94
|
+
};
|
|
95
|
+
const getTableData = ({ complexTableDetails, printData } = {}) => {
|
|
96
|
+
if (!complexTableDetails.props || !complexTableDetails.props.field) {
|
|
97
|
+
return [];
|
|
98
|
+
}
|
|
99
|
+
let field = complexTableDetails.props.field;
|
|
100
|
+
if (Array.isArray(printData[field])) {
|
|
101
|
+
return deepCopy(printData[field]);
|
|
102
|
+
}
|
|
103
|
+
return [];
|
|
104
|
+
};
|
|
105
|
+
const formatHeaderRules = ({ complexTableDetails }) => {
|
|
106
|
+
let headerRules = complexTableDetails.headerRules;
|
|
107
|
+
if (!headerRules) {
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
let { spanHeaderCellDict, spanHeaderCellList } = createHeaderSpanDetails({ complexTableDetails });
|
|
111
|
+
spanHeaderCellList.forEach((item, index) => {
|
|
112
|
+
if (!!item.show) {
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
let headerCellId = getHeaderCellId({ rowIndex: item.rowIndex, colIndex: item.colIndex });
|
|
116
|
+
if (!!headerRules[headerCellId]) {
|
|
117
|
+
delete headerRules[headerCellId];
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
};
|
|
121
|
+
export default {
|
|
122
|
+
getHeaderCellId,
|
|
123
|
+
createHeaderSpanDetails,
|
|
124
|
+
getHeaderCellShow,
|
|
125
|
+
getRowspan,
|
|
126
|
+
getColspan,
|
|
127
|
+
getTableData,
|
|
128
|
+
formatHeaderRules
|
|
129
|
+
};
|
package/dist/print-designer-api/use-create-html/use-complex-table-helper/create-table-header.js
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { deepCopy } from "../../print-designer-utils";
|
|
2
|
+
import printDesignerStyleHelper from "../../print-designer-style-helper";
|
|
3
|
+
import complexTableTools from "./complex-table-tools";
|
|
4
|
+
const getHeaderCellHtml = ({ rowIndex, colIndex, spanHeaderCellList, complexTableDetails } = {}) => {
|
|
5
|
+
let cellShow = complexTableTools.getHeaderCellShow({ rowIndex, colIndex, spanHeaderCellList });
|
|
6
|
+
let headerCellHtml = "";
|
|
7
|
+
if (!cellShow) {
|
|
8
|
+
return "";
|
|
9
|
+
}
|
|
10
|
+
let headerLayout = complexTableDetails.headerLayout;
|
|
11
|
+
let propsConfig = complexTableDetails.props;
|
|
12
|
+
let styleConfig = complexTableDetails.style;
|
|
13
|
+
let headerRules = complexTableDetails.headerRules;
|
|
14
|
+
let headerRulesId = printDesignerStyleHelper.getComplexTableHeaderRulesId({
|
|
15
|
+
rowIndex,
|
|
16
|
+
colIndex
|
|
17
|
+
});
|
|
18
|
+
let tdPropsConfig = {};
|
|
19
|
+
let tdStyleConfig = {};
|
|
20
|
+
if (!!headerRules && !!headerRules[headerRulesId]) {
|
|
21
|
+
tdPropsConfig = headerRules[headerRulesId].props;
|
|
22
|
+
tdStyleConfig = headerRules[headerRulesId].style;
|
|
23
|
+
}
|
|
24
|
+
if (!!tdPropsConfig.slash) {
|
|
25
|
+
// 有斜线
|
|
26
|
+
headerCellHtml = `<td rowspan="${complexTableTools.getRowspan({
|
|
27
|
+
rowIndex,
|
|
28
|
+
colIndex,
|
|
29
|
+
headerLayout
|
|
30
|
+
})}" colspan="${complexTableTools.getColspan({
|
|
31
|
+
rowIndex,
|
|
32
|
+
colIndex,
|
|
33
|
+
headerLayout
|
|
34
|
+
})}" style="${printDesignerStyleHelper.createComplexTableHeaderTdStyle({
|
|
35
|
+
complexTablePropsConfig: propsConfig,
|
|
36
|
+
complexTableStyleConfig: styleConfig,
|
|
37
|
+
tdPropsConfig,
|
|
38
|
+
tdStyleConfig
|
|
39
|
+
})}">${_createHeaderCellSlashHtml({
|
|
40
|
+
complexTableId: complexTableDetails.id,
|
|
41
|
+
rowIndex,
|
|
42
|
+
colIndex,
|
|
43
|
+
complexTableStyleConfig: complexTableDetails.style,
|
|
44
|
+
tdPropsConfig
|
|
45
|
+
})}</td>`;
|
|
46
|
+
} else {
|
|
47
|
+
// 无斜线
|
|
48
|
+
headerCellHtml = `<td rowspan="${complexTableTools.getRowspan({
|
|
49
|
+
rowIndex,
|
|
50
|
+
colIndex,
|
|
51
|
+
headerLayout
|
|
52
|
+
})}" colspan="${complexTableTools.getColspan({
|
|
53
|
+
rowIndex,
|
|
54
|
+
colIndex,
|
|
55
|
+
headerLayout
|
|
56
|
+
})}" style="${printDesignerStyleHelper.createComplexTableHeaderTdStyle({
|
|
57
|
+
complexTablePropsConfig: propsConfig,
|
|
58
|
+
complexTableStyleConfig: styleConfig,
|
|
59
|
+
tdPropsConfig,
|
|
60
|
+
tdStyleConfig
|
|
61
|
+
})}"><div style="${printDesignerStyleHelper.createComplexTableHeaderTdContainerStyle({
|
|
62
|
+
complexTablePropsConfig: propsConfig,
|
|
63
|
+
complexTableStyleConfig: styleConfig,
|
|
64
|
+
tdPropsConfig,
|
|
65
|
+
tdStyleConfig
|
|
66
|
+
})}">${_createHeaderTdText({ rowIndex, colIndex, complexTableDetails })}</div></td>`;
|
|
67
|
+
}
|
|
68
|
+
return headerCellHtml;
|
|
69
|
+
};
|
|
70
|
+
function _createHeaderTdText({ rowIndex, colIndex, complexTableDetails } = {}) {
|
|
71
|
+
let headerRules = complexTableDetails.headerRules;
|
|
72
|
+
let headerRulesId = printDesignerStyleHelper.getComplexTableHeaderRulesId({
|
|
73
|
+
rowIndex,
|
|
74
|
+
colIndex
|
|
75
|
+
});
|
|
76
|
+
let tdPropsConfig = false;
|
|
77
|
+
if (!!headerRules && !!headerRules[headerRulesId]) {
|
|
78
|
+
tdPropsConfig = headerRules[headerRulesId].props;
|
|
79
|
+
}
|
|
80
|
+
if (!!tdPropsConfig) {
|
|
81
|
+
return tdPropsConfig.title;
|
|
82
|
+
}
|
|
83
|
+
return "";
|
|
84
|
+
}
|
|
85
|
+
function _createHeaderCellSlashHtml({ complexTableId, rowIndex, colIndex, complexTableStyleConfig, tdPropsConfig } = {}) {
|
|
86
|
+
let slashContainerHtml = "";
|
|
87
|
+
let slashHtml = "";
|
|
88
|
+
let slashTextLeftHtml = "";
|
|
89
|
+
let slashTexRightHtml = "";
|
|
90
|
+
let slashTexLeft = "";
|
|
91
|
+
let slashTexRight = "";
|
|
92
|
+
if (!!tdPropsConfig && !!tdPropsConfig.slashTextLeft) {
|
|
93
|
+
slashTexLeft = tdPropsConfig.slashTextLeft;
|
|
94
|
+
}
|
|
95
|
+
if (!!tdPropsConfig && !!tdPropsConfig.slashTextRight) {
|
|
96
|
+
slashTexRight = tdPropsConfig.slashTextRight;
|
|
97
|
+
}
|
|
98
|
+
slashHtml = `<div class="_p-c-t_td-slash_slash"></div>`;
|
|
99
|
+
slashTextLeftHtml = `<div class="_p-c-t_td-slash_left">${slashTexLeft}</div>`;
|
|
100
|
+
slashTexRightHtml = `<div class="_p-c-t_td-slash_right">${slashTexRight}</div>`;
|
|
101
|
+
slashContainerHtml = `<div name="${complexTableId}_header_${complexTableTools.getHeaderCellId({
|
|
102
|
+
rowIndex,
|
|
103
|
+
colIndex
|
|
104
|
+
})}_slash" class="print-complex-table_td-slash print-complex-table_td-slash--${
|
|
105
|
+
tdPropsConfig.slashDirection
|
|
106
|
+
}">${slashTextLeftHtml}${slashHtml}${slashTexRightHtml}</div>`;
|
|
107
|
+
return slashContainerHtml;
|
|
108
|
+
}
|
|
109
|
+
export default {
|
|
110
|
+
getHeaderCellHtml
|
|
111
|
+
};
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { deepCopy } from "../../print-designer-utils";
|
|
2
|
+
import useDefault from "./use-default";
|
|
3
|
+
import useFixedHeight from "./use-fixed-height";
|
|
4
|
+
import useAutoHeightPreview from "./use-auto-height-preview";
|
|
5
|
+
import useAutoHeight from "./use-auto-height";
|
|
6
|
+
import usePaginationPreview from "./use-pagination-preview";
|
|
7
|
+
import usePagination from "./use-pagination";
|
|
8
|
+
export default ({ printData, printConfig, formConfig, layoutConfig, createHtmlByComponentItem, errorLogs } = {}) => {
|
|
9
|
+
const createComplexTableHtml = (item) => {
|
|
10
|
+
let complexTableHtml = "";
|
|
11
|
+
if (!item.props || !item.props.headerRow || !item.props.col) {
|
|
12
|
+
return complexTableHtml;
|
|
13
|
+
}
|
|
14
|
+
if (!item.props.canContinue && !item.props.isPaginationMode) {
|
|
15
|
+
const defaultInstance = useDefault({
|
|
16
|
+
printData,
|
|
17
|
+
printConfig,
|
|
18
|
+
formConfig,
|
|
19
|
+
layoutConfig,
|
|
20
|
+
createHtmlByComponentItem,
|
|
21
|
+
errorLogs
|
|
22
|
+
});
|
|
23
|
+
return defaultInstance.createComplexTableHtml(item);
|
|
24
|
+
}
|
|
25
|
+
if (!!item.props.canContinue && item.props.continuePrintMode == "fixedHeight") {
|
|
26
|
+
const fixedHeightInstance = useFixedHeight({
|
|
27
|
+
printData,
|
|
28
|
+
printConfig,
|
|
29
|
+
formConfig,
|
|
30
|
+
layoutConfig,
|
|
31
|
+
createHtmlByComponentItem,
|
|
32
|
+
errorLogs
|
|
33
|
+
});
|
|
34
|
+
return fixedHeightInstance.createComplexTableHtml(item);
|
|
35
|
+
}
|
|
36
|
+
if (!!item.props.canContinue && item.props.continuePrintMode == "_autoHeight_previewElements") {
|
|
37
|
+
// _autoHeight_previewElements 该值是代码运行中动态赋予的,无法在设计器中设置
|
|
38
|
+
const autoHeightPreviewInstance = useAutoHeightPreview({
|
|
39
|
+
printData,
|
|
40
|
+
printConfig,
|
|
41
|
+
formConfig,
|
|
42
|
+
layoutConfig,
|
|
43
|
+
createHtmlByComponentItem,
|
|
44
|
+
errorLogs
|
|
45
|
+
});
|
|
46
|
+
return autoHeightPreviewInstance.createComplexTableHtml(item);
|
|
47
|
+
}
|
|
48
|
+
if (!!item.props.canContinue && item.props.continuePrintMode == "autoHeight") {
|
|
49
|
+
const autoHeightInstance = useAutoHeight({
|
|
50
|
+
printData,
|
|
51
|
+
printConfig,
|
|
52
|
+
formConfig,
|
|
53
|
+
layoutConfig,
|
|
54
|
+
createHtmlByComponentItem,
|
|
55
|
+
errorLogs
|
|
56
|
+
});
|
|
57
|
+
return autoHeightInstance.createComplexTableHtml(item);
|
|
58
|
+
}
|
|
59
|
+
if (!!item.props.isPaginationMode && !!item.props._paginationModePreview) {
|
|
60
|
+
// _paginationModePreview 该属性是代码运行中动态赋予的,无法在设计器中设置
|
|
61
|
+
const paginationPreviewInstance = usePaginationPreview({
|
|
62
|
+
printData,
|
|
63
|
+
printConfig,
|
|
64
|
+
formConfig,
|
|
65
|
+
layoutConfig,
|
|
66
|
+
createHtmlByComponentItem,
|
|
67
|
+
errorLogs
|
|
68
|
+
});
|
|
69
|
+
return paginationPreviewInstance.createComplexTableHtml(item);
|
|
70
|
+
}
|
|
71
|
+
if (!!item.props.isPaginationMode && !item.props._paginationModePreview) {
|
|
72
|
+
const paginationInstance = usePagination({
|
|
73
|
+
printData,
|
|
74
|
+
printConfig,
|
|
75
|
+
formConfig,
|
|
76
|
+
layoutConfig,
|
|
77
|
+
createHtmlByComponentItem,
|
|
78
|
+
errorLogs
|
|
79
|
+
});
|
|
80
|
+
return paginationInstance.createComplexTableHtml(item);
|
|
81
|
+
}
|
|
82
|
+
return complexTableHtml;
|
|
83
|
+
};
|
|
84
|
+
return {
|
|
85
|
+
createComplexTableHtml
|
|
86
|
+
};
|
|
87
|
+
};
|
package/dist/print-designer-api/use-create-html/use-complex-table-helper/use-auto-height-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--auto-continue-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
|
+
};
|