From 2596f283a883e318e906dc80a874937dfdf50f94 Mon Sep 17 00:00:00 2001 From: LoopZhou <363415642@qq.com> Date: Tue, 10 May 2022 18:51:32 +0800 Subject: [PATCH 1/3] =?UTF-8?q?fix(table):=20=E5=88=97=E6=8B=96=E5=8A=A8?= =?UTF-8?q?=E5=88=B0=E6=9C=80=E7=AA=84=E5=90=8E=E4=B8=8D=E8=83=BD=E5=86=8D?= =?UTF-8?q?=E6=AC=A1=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/table/hooks/useColumnResize.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/table/hooks/useColumnResize.tsx b/src/table/hooks/useColumnResize.tsx index a29211407..45ffb9418 100644 --- a/src/table/hooks/useColumnResize.tsx +++ b/src/table/hooks/useColumnResize.tsx @@ -21,7 +21,7 @@ export default function useColumnResize(tableElmRef: Ref, refr const onColumnMouseover = (e: MouseEvent) => { if (!resizeLineRef.value) return; - const target = e.target as HTMLElement; + const target = (e.target as HTMLElement).closest('th'); const targetBoundRect = target.getBoundingClientRect(); if (!resizeLineParams.isDragging) { // 最小宽度暂定为30,如果单元格小于30,则不能拖拽 @@ -41,7 +41,7 @@ export default function useColumnResize(tableElmRef: Ref, refr // 非resize的点击,不做处理 if (!resizeLineParams.draggingCol) return; - const target = e.target as HTMLElement; + const target = (e.target as HTMLElement).closest('th'); const targetBoundRect = target.getBoundingClientRect(); const tableBoundRect = tableElmRef.value?.getBoundingClientRect(); const resizeLinePos = targetBoundRect.right - tableBoundRect.left; From 34b04f0f0cee2af766793d7f7b728cc5895b80f3 Mon Sep 17 00:00:00 2001 From: LoopZhou <363415642@qq.com> Date: Wed, 11 May 2022 11:31:33 +0800 Subject: [PATCH 2/3] =?UTF-8?q?fix(table):=20=E5=88=97=E6=8B=96=E5=8A=A8?= =?UTF-8?q?=E5=90=8E=EF=BC=8C=E9=80=89=E4=B8=AD=E8=A1=8C=E5=88=97=E6=8B=96?= =?UTF-8?q?=E5=8A=A8=E5=90=8E=E5=88=B0=E8=B7=9D=E7=A6=BB=E8=A2=AB=E9=87=8D?= =?UTF-8?q?=E7=BD=AE=E4=BA=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/table/hooks/useRowSelect.tsx | 14 ++++++++++---- src/table/primary-table.tsx | 2 +- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/table/hooks/useRowSelect.tsx b/src/table/hooks/useRowSelect.tsx index 6a063549f..24e64e444 100644 --- a/src/table/hooks/useRowSelect.tsx +++ b/src/table/hooks/useRowSelect.tsx @@ -139,12 +139,18 @@ export default function useRowSelect(props: TdPrimaryTableProps) { function formatToRowSelectColumn(col: PrimaryTableCol) { const isSelection = ['multiple', 'single'].includes(col.type); if (!isSelection) return col; - return { - ...col, - width: col.width || 64, + + !col.width + && Object.assign(col, { + width: 64, + }); + + const result = Object.assign(col, { cell: (h: CreateElement, p: PrimaryTableCellParams) => renderSelectCell(h, p), title: col.type === 'multiple' ? getSelectedHeader(h) : '', - }; + }); + + return result; } return { diff --git a/src/table/primary-table.tsx b/src/table/primary-table.tsx index 3d87b09be..153b7aad3 100644 --- a/src/table/primary-table.tsx +++ b/src/table/primary-table.tsx @@ -120,7 +120,7 @@ export default defineComponent({ const getColumns = (columns: PrimaryTableCol[]) => { const arr: PrimaryTableCol[] = []; for (let i = 0, len = columns.length; i < len; i++) { - let item = { ...columns[i] }; + let item = columns[i]; // 自定义列显示控制 const isDisplayColumn = item.children?.length || tDisplayColumns.value?.includes(item.colKey); if (!isDisplayColumn && props.columnController) continue; From 5f264cbd4a2ec4bba5d2bfc4d3bd64cb7b7a603d Mon Sep 17 00:00:00 2001 From: LoopZhou <363415642@qq.com> Date: Thu, 12 May 2022 15:24:14 +0800 Subject: [PATCH 3/3] =?UTF-8?q?fix(table):=20=E5=88=97=E6=8B=96=E5=8A=A8?= =?UTF-8?q?=E5=90=8E=EF=BC=8C=E9=80=89=E4=B8=AD=E8=A1=8C=E5=88=97=E6=8B=96?= =?UTF-8?q?=E5=8A=A8=E5=90=8E=E5=88=B0=E8=B7=9D=E7=A6=BB=E8=A2=AB=E9=87=8D?= =?UTF-8?q?=E7=BD=AE=E4=BA=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/table/hooks/useRowSelect.tsx | 19 +++++++------------ src/table/primary-table.tsx | 2 +- 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/src/table/hooks/useRowSelect.tsx b/src/table/hooks/useRowSelect.tsx index 24e64e444..a997fde8f 100644 --- a/src/table/hooks/useRowSelect.tsx +++ b/src/table/hooks/useRowSelect.tsx @@ -65,11 +65,12 @@ export default function useRowSelect(props: TdPrimaryTableProps) { // eslint-disable-next-line function getSelectedHeader(h: CreateElement) { - const isIndeterminate = intersectionKeys.value.length > 0 && intersectionKeys.value.length < canSelectedRows.value.length; return () => ( 0 && intersectionKeys.value.length < canSelectedRows.value.length + } disabled={!canSelectedRows.value.length} {...{ on: { change: handleSelectAll } }} /> @@ -139,18 +140,12 @@ export default function useRowSelect(props: TdPrimaryTableProps) { function formatToRowSelectColumn(col: PrimaryTableCol) { const isSelection = ['multiple', 'single'].includes(col.type); if (!isSelection) return col; - - !col.width - && Object.assign(col, { - width: 64, - }); - - const result = Object.assign(col, { + return { + ...col, + width: col.width || 64, cell: (h: CreateElement, p: PrimaryTableCellParams) => renderSelectCell(h, p), title: col.type === 'multiple' ? getSelectedHeader(h) : '', - }); - - return result; + }; } return { diff --git a/src/table/primary-table.tsx b/src/table/primary-table.tsx index 153b7aad3..3d87b09be 100644 --- a/src/table/primary-table.tsx +++ b/src/table/primary-table.tsx @@ -120,7 +120,7 @@ export default defineComponent({ const getColumns = (columns: PrimaryTableCol[]) => { const arr: PrimaryTableCol[] = []; for (let i = 0, len = columns.length; i < len; i++) { - let item = columns[i]; + let item = { ...columns[i] }; // 自定义列显示控制 const isDisplayColumn = item.children?.length || tDisplayColumns.value?.includes(item.colKey); if (!isDisplayColumn && props.columnController) continue;