From 0058721468edd1ca74499648f6db48c943e479cc 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: Sun, 7 Aug 2022 01:59:38 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B(table):=20typescript=20=E8=AD=A6?= =?UTF-8?q?=E5=91=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package/component/src/component/table/TableRow.vue | 4 ++-- package/component/src/component/table/index.vue | 13 +++++++------ 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/package/component/src/component/table/TableRow.vue b/package/component/src/component/table/TableRow.vue index 9cc74fe5..50ecdfe0 100644 --- a/package/component/src/component/table/TableRow.vue +++ b/package/component/src/component/table/TableRow.vue @@ -20,7 +20,7 @@ export interface LayTableRowProps { expandSpace: boolean; expandIndex: number; selectedKeys: Recordable[]; - selectedKey: any; + selectedKey: string; tableColumnKeys: Recordable[]; childrenColumnName?: string; columns: Recordable[]; @@ -73,7 +73,7 @@ const tableSelectedKeys: WritableComputedRef = computed({ }, }); -const tableSelectedKey: WritableComputedRef = computed({ +const tableSelectedKey: WritableComputedRef = computed({ get() { return props.selectedKey; }, diff --git a/package/component/src/component/table/index.vue b/package/component/src/component/table/index.vue index 4bdd676f..231a5a33 100644 --- a/package/component/src/component/table/index.vue +++ b/package/component/src/component/table/index.vue @@ -34,7 +34,7 @@ export interface LayTableProps { columns: Recordable[]; dataSource: Recordable[]; defaultToolbar?: boolean; - selectedKey?: any; + selectedKey?: string; selectedKeys?: Recordable[]; indentSize?: number; childrenColumnName?: string; @@ -58,6 +58,7 @@ const props = withDefaults(defineProps(), { childrenColumnName: "children", dataSource: () => [], selectedKeys: () => [], + selectedKey: '', maxHeight: "auto", even: false, rowClassName: "", @@ -117,7 +118,7 @@ watch( { deep: true } ); -const tableSelectedKey: WritableComputedRef = computed({ +const tableSelectedKey: WritableComputedRef = computed({ get() { return props.selectedKey; }, @@ -318,10 +319,10 @@ const getFixedColumn = () => { hasr.value = true; } else { // @ts-ignore - if ( - tableBody.value?.scrollLeft + tableBody.value?.offsetWidth + 2 > - tableBody.value?.scrollWidth - ) { + const t = tableBody.value?.scrollLeft + tableBody.value?.offsetWidth + 2; + const s = tableBody.value?.scrollWidth; + // @ts-ignore + if (t > s) { hasl.value = true; hasr.value = false; } else {