From 9ddf369176ad62c5f5d9dfcfc28b3d78d35e3c3a 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: Wed, 10 Aug 2022 14:56:48 +0800
Subject: [PATCH] =?UTF-8?q?=E2=9C=A8(component):=20=E6=96=B0=E5=A2=9E=20ta?=
=?UTF-8?q?ble=20=E7=BB=84=E4=BB=B6=20getCheckboxProps=20=E4=B8=8E=20getRa?=
=?UTF-8?q?dioProps=20=E6=96=B9=E6=B3=95?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../src/component/table/TableRow.vue | 14 +++++-
.../component/src/component/table/index.vue | 44 ++++++++++++-------
.../src/document/zh-CN/components/table.md | 12 ++++-
3 files changed, 50 insertions(+), 20 deletions(-)
diff --git a/package/component/src/component/table/TableRow.vue b/package/component/src/component/table/TableRow.vue
index 36696e0b..77b791a6 100644
--- a/package/component/src/component/table/TableRow.vue
+++ b/package/component/src/component/table/TableRow.vue
@@ -34,6 +34,8 @@ export interface LayTableRowProps {
spanMethod: Function;
defaultExpandAll: boolean;
expandKeys: Recordable[];
+ getCheckboxProps: Function;
+ getRadioProps: Function;
}
const slot = useSlots();
@@ -272,6 +274,9 @@ const isAutoShow = (
return true;
}
};
+
+const checkboxProps = props.getCheckboxProps(props.data, props.index);
+const radioProps = props.getRadioProps(props.data, props.index);
@@ -334,7 +339,11 @@ const isAutoShow = (
@click="handleExpand"
>
-
+
@@ -389,6 +398,7 @@ const isAutoShow = (
@@ -602,6 +612,8 @@ const isAutoShow = (
:rowClassName="rowClassName"
:spanMethod="spanMethod"
:defaultExpandAll="defaultExpandAll"
+ :getCheckboxProps="getCheckboxProps"
+ :getRadioProps="getRadioProps"
@row="rowClick"
@row-double="rowDoubleClick"
@row-contextmenu="rowContextmenu"
diff --git a/package/component/src/component/table/index.vue b/package/component/src/component/table/index.vue
index 90bf2a7b..1b4e227a 100644
--- a/package/component/src/component/table/index.vue
+++ b/package/component/src/component/table/index.vue
@@ -50,6 +50,8 @@ export interface LayTableProps {
defaultExpandAll?: boolean;
expandKeys?: Recordable[];
loading?: boolean;
+ getCheckboxProps?: Function;
+ getRadioProps?: Function;
}
const props = withDefaults(defineProps(), {
@@ -71,6 +73,8 @@ const props = withDefaults(defineProps(), {
spanMethod: () => {},
expandKeys: () => [],
loading: false,
+ getCheckboxProps: () => {},
+ getRadioProps: () => {}
});
const tableId = uuidv4();
@@ -326,37 +330,41 @@ const print = function () {
};
/**
- * excel 导出
+ * excel 导出
*/
const exportData = () => {
var tableStr = ``;
- for(let tableHeadColumn of tableHeadColumns.value){
- tableStr += '';
- for(let column of tableHeadColumn){
- tableStr += `${column.title} | `
- }
- tableStr += '
';
+ for (let tableHeadColumn of tableHeadColumns.value) {
+ tableStr += "";
+ for (let column of tableHeadColumn) {
+ tableStr += `${column.title} | `;
+ }
+ tableStr += "
";
}
tableDataSource.value.forEach((item, rowIndex) => {
- tableStr += ''
+ tableStr += "
";
tableBodyColumns.value.forEach((tableColumn, columnIndex) => {
Object.keys(item).forEach((name) => {
if (tableColumn.key === name) {
- const rowColSpan = props.spanMethod(item, tableColumn, rowIndex, columnIndex);
+ const rowColSpan = props.spanMethod(
+ item,
+ tableColumn,
+ rowIndex,
+ columnIndex
+ );
const rowspan = rowColSpan ? rowColSpan[0] : 1;
const colspan = rowColSpan ? rowColSpan[1] : 1;
- if(rowspan != 0 && colspan != 0) {
- tableStr += `${item[name]} | `
+ if (rowspan != 0 && colspan != 0) {
+ tableStr += `${item[name]} | `;
}
}
- });
- });
- tableStr += '
'
+ });
+ });
+ tableStr += "";
});
var worksheet = "Sheet1";
var uri = "data:application/vnd.ms-excel;base64,";
- var exportTemplate =
- `