Skip to content

Commit 33b176e

Browse files
committed
fix: Fixed the issue that the result set was overwritten when the field aliases were taken the same
1 parent d8fd071 commit 33b176e

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

  • chat2db-client/src/components/SearchResult/TableBox

chat2db-client/src/components/SearchResult/TableBox/index.tsx

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -124,13 +124,13 @@ export default function TableBox(props: ITableProps) {
124124

125125
const columns: ArtColumn[] = useMemo(
126126
() =>
127-
(headerList || []).map((item, index) => {
127+
(headerList || []).map((item, colIndex) => {
128128
const { dataType, name } = item;
129129
const isNumber = dataType === TableDataType.NUMERIC;
130130
const isNumericalOrder = dataType === TableDataType.CHAT2DB_ROW_NUMBER;
131131
if (isNumericalOrder) {
132132
return {
133-
code: `${preCode}No.`,
133+
code: `${preCode}${colIndex}No.`,
134134
name: 'No.',
135135
key: name,
136136
lock: true,
@@ -146,7 +146,7 @@ export default function TableBox(props: ITableProps) {
146146
};
147147
}
148148
return {
149-
code: `${preCode}${name}`,
149+
code: `${preCode}${colIndex}${name}`,
150150
name: name,
151151
key: name,
152152
width: 120,
@@ -174,8 +174,8 @@ export default function TableBox(props: ITableProps) {
174174
} else {
175175
return (dataList || []).map((item, rowIndex) => {
176176
const rowData: any = {};
177-
item.map((i: string | null, index: number) => {
178-
const name = `${preCode}${columns[index].name}`;
177+
item.map((i: string | null, colIndex: number) => {
178+
const name = `${preCode}${colIndex}${columns[colIndex].name}`;
179179
if (i === null) {
180180
rowData[name] = '<null>';
181181
} else {
@@ -212,6 +212,7 @@ export default function TableBox(props: ITableProps) {
212212
const onPageNoChange = (pageNo: number) => {
213213
onConfigChange && onConfigChange({ ...config, pageNo });
214214
};
215+
215216
const onPageSizeChange = (pageSize: number) => {
216217
onConfigChange && onConfigChange({ ...config, pageSize, pageNo: 1 });
217218
};
@@ -221,6 +222,7 @@ export default function TableBox(props: ITableProps) {
221222
return await props.onSearchTotal();
222223
}
223224
};
225+
224226
const renderContent = () => {
225227
const bottomStatus = (
226228
<div className={styles.statusBar}>
@@ -271,6 +273,7 @@ export default function TableBox(props: ITableProps) {
271273
);
272274
}
273275
};
276+
274277
return (
275278
<div className={classnames(className, styles.tableBox)}>
276279
{renderContent()}

0 commit comments

Comments
 (0)