diff --git a/src/components/panel/index.vue b/src/components/panel/index.vue index 6df6429..6cffb25 100644 --- a/src/components/panel/index.vue +++ b/src/components/panel/index.vue @@ -13,13 +13,19 @@ - + + + + + - + @@ -34,6 +40,7 @@ import page from './page.vue' import style from './style.vue' import options from './options/index.vue' import layers from './layers.vue' +import tablecColumn from './tablecColumn.vue' export default { components: { @@ -41,12 +48,26 @@ export default { appearance: style, options, layers, + tablecColumn, + }, + watch: { + '$vptd.state.page.tempItems': { + handler(tempItems) { + this.hasTable(tempItems) + }, + immediate: true, // 初始化立即执行 + } }, - data() { return { - activeNames: ['1', '2', '3', '4'], + isTable: false, + activeNames: ['1', '2', '3', '4', '5'], } }, + methods: { + hasTable(tempItems) { + this.isTable = tempItems.some(item => item.type === 'braid-table') + } + } } diff --git a/src/components/widgets/table/index.vue b/src/components/widgets/table/index.vue index 15f690f..07377df 100644 --- a/src/components/widgets/table/index.vue +++ b/src/components/widgets/table/index.vue @@ -20,6 +20,7 @@ cellpadding="2" style="border-collapse: collapse; font-size: 12px" bordercolor="#000000" + :key="indexKey" > {{ item.value }} + + + + + @@ -73,13 +85,24 @@ export default { BorderColor: '#000000', AutoHeight: false, // 高度自动(模板在该元素位置以下的元素都关联打印) BottomMargin: 0 // 距离下边距 - } + }, + tindex: 0, + showFooter: false }, props: [ 'val' // 文本对象 ], + watch: { + 'val.lastTrConfig': { + handler() { + this.indexKey++ + }, + deep: true // 深度监听 + } + }, data() { return { + indexKey: 1, tid: 'table-' + getUUID(8) } }, @@ -91,7 +114,10 @@ export default { item.thid = 'thid-' + getUUID(6) } return col - } + }, + activeElement() { + return this.$vptd.state.activeElement + }, }, mounted() { this.$nextTick(() => { @@ -130,6 +156,9 @@ export default { modifyTitle(cur, e) { cur.title = e.target.innerText }, + handleColumn(index) { + this.activeElement.tindex = index + }, // 设置表格列宽 setTableColWidth(item) { if (item.width) { @@ -140,7 +169,11 @@ export default { } } return '' - } + }, + contentBlur(item, e) { + item.content = e.target.innerHTML + e.target.innerHTML = item.content + }, } } diff --git a/src/libs/lodop/index.js b/src/libs/lodop/index.js index 7bae4e1..526d490 100644 --- a/src/libs/lodop/index.js +++ b/src/libs/lodop/index.js @@ -319,7 +319,8 @@ function _AddPrintItem(LODOP, tempItem, pageIndex = 0) { let html = tableTempTohtml( printItem.columns ? printItem.columns : [], printItem.defaultValue, - printItem.style + printItem.style, + printItem ); if (lodopStyle.AutoHeight) { LODOP.ADD_PRINT_TABLE( diff --git a/src/libs/lodop/tools.js b/src/libs/lodop/tools.js index 683b8c9..91988da 100644 --- a/src/libs/lodop/tools.js +++ b/src/libs/lodop/tools.js @@ -22,7 +22,7 @@ export const tempToPrint = (temp, data) => { * @param columns 表格列配置信息 * @param data 表格数据 */ -export const tableTempTohtml = (columns, data, style) => { +export const tableTempTohtml = (columns, data, style, tableConfig) => { // 表格全局样式 let styleStr = 'text-align:' + style.Alignment + ';' styleStr += 'font-size:' + style.FontSize + 'pt;' @@ -63,7 +63,18 @@ export const tableTempTohtml = (columns, data, style) => { html += '' }) } - + // 解析表尾 + if (tableConfig.showFooter) { + html += '' + tableConfig.lastTrConfig.forEach((config) => { + if (config.tdata) { + html += `##` + } else { + html += `${config.content}` + } + }) + html += '' + } html += '' html += '' return html diff --git a/src/libs/props.js b/src/libs/props.js index 0c10952..f9a468e 100644 --- a/src/libs/props.js +++ b/src/libs/props.js @@ -56,3 +56,18 @@ export const getLineStyle = () => [ { label: "实线", value: 0, type: "solid" }, { label: "虚线", value: 2, type: "dashed" } ]; + +export const getStatisticType = () => [ + { label: "求和", value: 'Sum' }, + { label: "最大值", value: 'AllMax' }, + { label: "最小值", value: 'AllMin' }, +]; +export const getFormatType = () => [ + { label: "0", value: '0' }, + { label: "0.00", value: '0.00' }, + { label: "#.##", value: '#.##' }, + { label: "#,##0.00", value: '#,##0.00' }, + { label: "0.000E+00", value: '0.000E+00' }, + { label: "大写金额", value: 'UpperMoney' }, + { label: "中文数字", value: 'ChineseNum' }, +];