Skip to content

Commit d98367d

Browse files
jevin98sleeprite
authored andcommitted
!480 fix(table/types): 修复 TableColumn 中 type 存在时 key 仍为必填的问题
* fix(table/types): 修复 TableColumn 中 type 存在时 key 仍为必填的问题
1 parent 7e63441 commit d98367d

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

packages/component/component/table/components/TableMain/TableMainTd.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ export default defineComponent({
211211
}
212212
onDblclick={
213213
isValidType.value
214-
? e => tableEmits("cell-double", data[column.key], e)
214+
? e => tableEmits("cell-double", column.key ? data[column.key] : undefined, e)
215215
: undefined
216216
}
217217
>

packages/component/component/table/components/TableTotal.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ function renderTotalRowCell(column: TableColumn) {
3939
4040
function totalRowMethod(column: TableColumn, dataSource: any[]) {
4141
let precision = 0;
42-
const values = dataSource.map(item => Number(item[column.key]));
42+
const values = dataSource.map(item => Number(item[column.key as string]));
4343
4444
values.forEach((value) => {
4545
const decimal = `${value}`.split(".")[1];

packages/component/component/table/typing.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,8 @@ export const tableEmits = [
6666

6767
export type TableEmit = (event: string, ...args: any[]) => void;
6868

69-
export interface TableColumn {
69+
interface TableBaseColumn {
7070
title: string;
71-
key: string;
7271
customSlot?: Render;
7372
width?: string;
7473
minWidth?: string;
@@ -84,7 +83,6 @@ export interface TableColumn {
8483
*/
8584
ellipsisTooltipProps?: Record<string, any>;
8685
fixed?: "left" | "right";
87-
type?: string;
8886
children?: TableColumn[];
8987
rowspan?: number;
9088
resize?: boolean;
@@ -97,6 +95,10 @@ export interface TableColumn {
9795
) => void;
9896
}
9997

98+
export type TableColumn =
99+
(TableBaseColumn & { type: undefined; key: string }) |
100+
(TableBaseColumn & { type: string; key?: string });
101+
100102
export type FixedDirectionType =
101103
| "_isLastFixedRightColumn"
102104
| "_isFirstFixedLeftColumn";

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy