diff --git a/src/components/LowDesign/src/LowReport/index.vue b/src/components/LowDesign/src/LowReport/index.vue index 62c3f47..e41ad30 100644 --- a/src/components/LowDesign/src/LowReport/index.vue +++ b/src/components/LowDesign/src/LowReport/index.vue @@ -14,7 +14,9 @@ v-bind="crudBind" :summary-method=summaryMethod1 :row-style="rowStyleMethod" + :span-method="reportCode=='zhxs-hz'? spanMethod:null" :cell-class-name="cellClassNameMethod" + :header-cell-class-name="headerCellClassNameMethod" @search-change="searchChange" @search-reset="resetChange" @refresh-change="refreshChange" @@ -306,6 +308,65 @@ const openSaleDetail=(row)=>{ getSaleInfo(row) } +// 第一列纵向合并的标记数组 +const rowMergeArr = ref([]) + +// 预处理:计算第一列相邻bk相同的纵向合并规则 +const initMerge = () => { + const list = tableData.value + const len = list.length + rowMergeArr.value = new Array(len).fill(1) + + // 遍历所有行,统计相邻bk相同的行数 + let count = 1 + for (let i = 1; i < len; i++) { + if (list[i].bk === list[i - 1].bk) { + // 相同bk,当前行标记为0(隐藏),累加计数 + count++ + rowMergeArr.value[i] = 0 + } else { + // 不同bk,把之前的计数赋值给组内第一行 + rowMergeArr.value[i - count] = count + count = 1 + } + } + // 处理最后一组数据 + rowMergeArr.value[len - count] = count +} + +// Avue 核心合并方法 +const spanMethod = ({ row, rowIndex, columnIndex }) => { + // ====================================== + // 规则1:同一行 bk 和 zone_name 相同 → 横向合并前两列 + // ====================================== + const isSameRowField = row.bk === row.zone_name + + if (isSameRowField) { + // 第一列:跨2列合并 + if (columnIndex === 0) { + return { rowspan: 1, colspan: 2 } + } + // 第二列:隐藏当前单元格 + if (columnIndex === 1) { + return { rowspan: 1, colspan: 0 } + } + } + + // ====================================== + // 规则2:第一列相邻bk相同 → 纵向合并行 + // ====================================== + if (columnIndex === 0) { + return { + rowspan: rowMergeArr.value[rowIndex], + colspan: 1 + } + } + + // ====================================== + // 其他列:完全不合并,保持原样! + // ====================================== + return { rowspan: 1, colspan: 1 } +} const refreshSaleChange=()=>{ getSaleInfo() } @@ -433,10 +494,19 @@ const summaryMethod1=({columns,data})=>{ } const cellClassNameMethod=({row,column,rowIndex,columnIndex})=>{ - // if(textAlignFiels.value[column.property]){ - // return 'textAlignCell' - // } + if(props.reportCode=='zhxs-hz'){ + if(row.zone_name.includes('总计')&&row.zone_name!=='总计') return 'color-B9DEE8' + else if((row.zone_name.includes('合计')&&row.bk!=='合计')||row.zone_name=='其他收入'||(columnIndex==0&&row.zone_name!=='总计')) return 'color-90B3E2' + else if(row.bk=='总计'&&row.zone_name=='总计') return 'color-548CD6' + } } + const headerCellClassNameMethod=({row,column,rowIndex,columnIndex})=>{ + if(props.reportCode=='zhxs-hz'){ + return 'color-90B3E2' + } + } + + function getCurrentDate() { const now = new Date(); // 补零函数:小于10则前面加0 @@ -481,6 +551,8 @@ const initTable = async () => { // stripe: reportVo.tableConfig.includes('stripe'), showSummary:false, stripe:true, + searchShow:props.reportCode=='zhxs-hz'?false:true, + searchShowBtn:props.reportCode=='zhxs-hz'?false:true, searchBtnText:'查询', column: {} } @@ -781,7 +853,7 @@ const getTableData = async (isLoading = true) => { // 获取数据 let data = await ReportApi.getTableList(props.reportCode, searchObj) - + // 功能测试:CS_DTBT报表使用模拟数据 if (props.reportCode === 'CS_DTBT') { data = { @@ -1014,8 +1086,11 @@ const getTableData = async (isLoading = true) => { }) }) resolve(data.records) + if(props.reportCode=='zhxs-hz'){ + initMerge() + } } finally { - + if (isLoading) loading.value = false resolve() } @@ -1173,7 +1248,18 @@ defineExpose({ &.el-table--enable-row-hover .el-table__body tr:hover>td.el-table__cell{ background-color: #FFFFD2; } - + .color-B9DEE8{ + background-color: #B9DEE8 !important; + font-weight: bold !important; + } + .color-90B3E2{ + background-color: #90B3E2 !important; + font-weight: bold !important; + } + .color-548CD6{ + background-color: #548CD6 !important; + font-weight: bold !important; + } td.el-table__cell,th.el-table__cell{ border-right: 1px solid #000 !important; border-bottom: 1px solid #000 !important;