From 0f4144fafc6777db594b9da16834f7df21d50048 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=B1=E7=9C=A0=E5=84=80=E5=BC=8F?= <854085467@qq.com> Date: Thu, 4 Aug 2022 10:32:29 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8(component):=20=E6=96=B0=E5=A2=9E=20sp?= =?UTF-8?q?an-method=20=E5=B1=9E=E6=80=A7,=20=E6=94=AF=E6=8C=81=E8=A1=8C?= =?UTF-8?q?=E5=88=97=E5=90=88=E5=B9=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/component/table/TableRow.vue | 50 +++++++++++- .../component/src/component/table/index.vue | 8 +- .../src/document/zh-CN/components/table.md | 76 +++++++++++++++++++ 3 files changed, 129 insertions(+), 5 deletions(-) diff --git a/package/component/src/component/table/TableRow.vue b/package/component/src/component/table/TableRow.vue index 32f9fe04..aaa8557a 100644 --- a/package/component/src/component/table/TableRow.vue +++ b/package/component/src/component/table/TableRow.vue @@ -31,6 +31,7 @@ export interface LayTableRowProps { rowStyle: string | Function; id: string; data: any; + spanMethod: Function; } const slot = useSlots(); @@ -188,6 +189,37 @@ const renderFixedClassName = (column: any, columnIndex: number) => { } } }; + +const spanMethodAttr = ( + row: any, + column: any, + rowIndex: number, + columnIndex: number) => { + +const attrs = props.spanMethod(row, column, rowIndex, columnIndex); + if(attrs instanceof Array) { + return {rowspan: attrs[0], colspan: attrs[1]} + } else if(attrs instanceof Object) { + return attrs; + } else { + return {rowspan: 1, colspan: 1} + } +} + +const isAutoShow = ( + row: any, + column: any, + rowIndex: number, + columnIndex: number) => { + + const attrs = spanMethodAttr(row, column, rowIndex, columnIndex); + if(attrs.colspan == 0 && attrs.rowspan == 0) { + return false; + } else { + return true; + } + +}