作者 dong

序号列修复

... ... @@ -106,11 +106,6 @@
return res;
},
columns,
indexColumnProps: {
title: '序号',
width: 80,
fixed: 'left',
},
formConfig: {
schemas: searchFormSchema,
autoSubmitOnEnter: true,
... ...
... ... @@ -52,36 +52,6 @@
const queryParam = reactive<any>({});
const checkedKeys = ref<Array<string | number>>([]);
const userStore = useUserStore();
// 分页信息
const pagination = ref({
current: 1,
pageSize: 10,
total: 0,
});
// 处理表格变化事件(包括分页变化)
function handleTableChange(pag) {
if (pag) {
pagination.value = {
current: pag.current,
pageSize: pag.pageSize,
total: pag.total,
};
}
}
// 创建序号列
const indexColumn: BasicColumn = {
title: '序号',
align: 'center',
dataIndex: 'index',
key: 'rowIndex',
width: 60,
customRender: ({ index }) => {
// 使用分页状态计算连续序号
return (pagination.value.current - 1) * pagination.value.pageSize + index + 1;
},
};
// 添加知识库名称映射
const knowledgeMap = ref<Record<string, string>>({});
... ... @@ -136,7 +106,7 @@
const filteredColumns = defaultColumns.filter((col) => col.dataIndex !== 'name' && col.title !== '知识库名称');
// 添加新的知识库列
return [indexColumn, ...filteredColumns, knowledgeColumn];
return [...filteredColumns, knowledgeColumn];
});
//注册model
... ... @@ -145,7 +115,18 @@
const { prefixCls, tableContext, onExportXls, onImportXls } = useListPage({
tableProps: {
title: 'test',
api: list,
api: async (params) => {
const res = await list(params);
// 处理序号 - 关键修改
if (res?.records && Array.isArray(res.records)) {
const startIndex = (params.pageNo - 1) * params.pageSize + 1;
res.records = res.records.map((item, index) => ({
...item,
index: startIndex + index,
}));
}
return res;
},
columns: tableColumns,
canResize: false,
formConfig: {
... ...
... ... @@ -6,6 +6,13 @@ import { listknowledge } from '@/views/super/airag/test/Test.api';
//列表数据
export const columns: BasicColumn[] = [
{
title: '序号',
align: 'center',
dataIndex: 'index',
key: 'rowIndex',
width: 60,
},
/*{
title: 'ID',
align: 'center',
... ...