|
|
|
<template>
|
|
|
|
<div>
|
|
|
|
<!--引用表格-->
|
|
|
|
<BasicTable @register="registerTable" :rowSelection="rowSelection">
|
|
|
|
<BasicTable @register="registerTable" :rowSelection="rowSelection" @change="handleTableChange">
|
|
|
|
<!--插槽:table标题-->
|
|
|
|
<template #tableTitle>
|
|
|
|
<a-button type="primary" v-auth="'embeddings:embeddings:add'" @click="handleAdd" preIcon="ant-design:plus-outlined"> 新增</a-button>
|
|
|
|
<!-- <a-button type="primary" v-auth="'embeddings:embeddings:exportXls'" preIcon="ant-design:export-outlined" @click="onExportXls"> 导出</a-button>-->
|
|
|
|
<!--<a-button type="primary" v-auth="'embeddings:embeddings:exportXls'" preIcon="ant-design:export-outlined" @click="onExportXls"> 导出</a-button>-->
|
|
|
|
<j-upload-button type="primary" v-auth="'embeddings:embeddings:importWord'" preIcon="ant-design:import-outlined" @click="onImportXls"
|
|
|
|
>导入</j-upload-button
|
|
|
|
>
|
|
...
|
...
|
@@ -24,7 +24,7 @@ |
|
|
|
</a-button>
|
|
|
|
</a-dropdown>
|
|
|
|
<!-- 高级查询 -->
|
|
|
|
<!-- <super-query :config="superQueryConfig" @search="handleSuperQuery" />-->
|
|
|
|
<!-- <super-query :config="superQueryConfig" @search="handleSuperQuery" />-->
|
|
|
|
</template>
|
|
|
|
<!--操作栏-->
|
|
|
|
<template #action="{ record }">
|
|
...
|
...
|
@@ -48,10 +48,40 @@ |
|
|
|
import { list, batchDelete, getImportUrl, getExportUrl, deleteOne, listknowledge } from './Test.api';
|
|
|
|
import { useUserStore } from '/@/store/modules/user';
|
|
|
|
import JUploadButton from '@/components/Button/src/JUploadButton.vue';
|
|
|
|
import { columns as defaultColumns } from './Test.data'; // 导入默认列配置
|
|
|
|
import { columns as defaultColumns } from './Test.data';
|
|
|
|
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>>({});
|
|
|
|
|
|
...
|
...
|
@@ -106,7 +136,7 @@ |
|
|
|
const filteredColumns = defaultColumns.filter((col) => col.dataIndex !== 'name' && col.title !== '知识库名称');
|
|
|
|
|
|
|
|
// 添加新的知识库列
|
|
|
|
return [...filteredColumns, knowledgeColumn];
|
|
|
|
return [indexColumn, ...filteredColumns, knowledgeColumn];
|
|
|
|
});
|
|
|
|
|
|
|
|
//注册model
|
|
...
|
...
|
@@ -151,7 +181,7 @@ |
|
|
|
success: handleSuccess,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
const [registerTable, { reload }, { rowSelection, selectedRowKeys }] = tableContext;
|
|
|
|
const [registerTable, { reload, setPagination }, { rowSelection, selectedRowKeys }] = tableContext;
|
|
|
|
|
|
|
|
// 高级查询配置
|
|
|
|
const superQueryConfig = reactive(superQuerySchema);
|
|
...
|
...
|
@@ -203,14 +233,43 @@ |
|
|
|
* 删除事件
|
|
|
|
*/
|
|
|
|
async function handleDelete(record) {
|
|
|
|
resetPaginationAfterDelete();
|
|
|
|
await deleteOne({ id: record.id }, handleSuccess);
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* 批量删除事件
|
|
|
|
*/
|
|
|
|
async function batchHandleDelete() {
|
|
|
|
resetPaginationAfterDelete();
|
|
|
|
await batchDelete({ ids: selectedRowKeys.value }, handleSuccess);
|
|
|
|
}
|
|
|
|
|
|
|
|
// 新增:删除操作后重置分页状态
|
|
|
|
function resetPaginationAfterDelete() {
|
|
|
|
// 获取当前分页状态
|
|
|
|
const currentPagination = pagination.value;
|
|
|
|
|
|
|
|
// 计算删除后总页数
|
|
|
|
const totalPages = Math.ceil((currentPagination.total - 1) / currentPagination.pageSize);
|
|
|
|
|
|
|
|
// 如果当前页码大于总页数,则回到最后一页
|
|
|
|
if (currentPagination.current > totalPages && totalPages > 0) {
|
|
|
|
pagination.value = {
|
|
|
|
...currentPagination,
|
|
|
|
current: totalPages,
|
|
|
|
total: currentPagination.total - 1,
|
|
|
|
};
|
|
|
|
} else {
|
|
|
|
// 否则保持当前页,但更新总数
|
|
|
|
pagination.value = {
|
|
|
|
...currentPagination,
|
|
|
|
total: currentPagination.total - 1,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
// 设置表格分页状态
|
|
|
|
setPagination(pagination.value);
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* 成功回调
|
|
|
|
*/
|
...
|
...
|
|