作者 dong

序号列

... ... @@ -6,6 +6,15 @@ import { saveOrUpdate } from '@/views/super/airag/airagbutton/AiragButton.api';
//列表数据
export const columns: BasicColumn[] = [
{
title: '序号',
align: 'center',
dataIndex: 'index',
key: 'rowIndex',
width: 60,
// 这里只需简单的序号,实际计算在组件内完成
customRender: ({ index }) => index + 1,
},
{
title: '按钮名称',
align: 'center',
dataIndex: 'buttonName',
... ...
<template>
<div>
<!--引用表格-->
<BasicTable @register="registerTable" :rowSelection="rowSelection">
<BasicTable @register="registerTable" :rowSelection="rowSelection" @change="handleTableChange">
<!--插槽:table标题-->
<template #tableTitle>
<a-button type="primary" v-auth="'airagbutton:airag_button:add'" @click="handleAdd" preIcon="ant-design:plus-outlined"> 新增</a-button>
... ... @@ -26,7 +26,7 @@
</a-button>
</a-dropdown>
<!-- 高级查询 -->
<!-- <super-query :config="superQueryConfig" @search="handleSuperQuery" />-->
<!-- <super-query :config="superQueryConfig" @search="handleSuperQuery" />-->
</template>
<!--操作栏-->
<template #action="{ record }">
... ... @@ -41,7 +41,7 @@
</template>
<script lang="ts" name="airagbutton-airagButton" setup>
import { ref, reactive } from 'vue';
import {ref, reactive, computed} from 'vue';
import { BasicTable, TableAction } from '/@/components/Table';
import { useModal } from '/@/components/Modal';
import { useListPage } from '/@/hooks/system/useListPage';
... ... @@ -52,6 +52,41 @@
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 tableColumns = computed(() => {
return columns.map((col) => {
if (col.dataIndex === 'index') {
// 序号列特殊处理
return {
...col,
customRender: ({ index }) => {
return (pagination.value.current - 1) * pagination.value.pageSize + index + 1;
},
};
}
return col;
});
});
//注册model
const [registerModal, { openModal }] = useModal();
//注册table数据
... ... @@ -59,7 +94,7 @@
tableProps: {
title: '按钮表单',
api: list,
columns,
columns: tableColumns.value,
canResize: false,
formConfig: {
//labelWidth: 120,
... ... @@ -69,6 +104,13 @@
fieldMapToNumber: [],
fieldMapToTime: [],
},
pagination: {
current: 1,
pageSize: 10,
showSizeChanger: true,
pageSizeOptions: ['10', '20', '30'],
showTotal: (total) => `共 ${total} 条`,
},
actionColumn: {
width: 120,
fixed: 'right',
... ...
... ... @@ -4,6 +4,15 @@ import { listKnowledgeName, listmodelid } from '@/views/super/airag/airaglog/Air
//列表数据
export const columns: BasicColumn[] = [
{
title: '序号',
align: 'center',
dataIndex: 'index',
key: 'rowIndex',
width: 60,
// 这里只需简单的序号,实际计算在组件内完成
customRender: ({ index }) => index + 1,
},
{
title: '问题',
align: 'center',
dataIndex: 'question',
... ...
<template>
<div>
<!--引用表格-->
<BasicTable @register="registerTable" :rowSelection="rowSelection">
<BasicTable @register="registerTable" :rowSelection="rowSelection" @change="handleTableChange">
<!--插槽:table标题-->
<template #tableTitle>
<a-button type="primary" v-auth="'airaglog:airag_log:add'" @click="handleAdd" preIcon="ant-design:plus-outlined"> 新增</a-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 }">
... ... @@ -39,7 +39,7 @@
</template>
<script lang="ts" name="airaglog-airagLog" setup>
import { ref, reactive } from 'vue';
import {ref, reactive, computed} from 'vue';
import { BasicTable, TableAction } from '/@/components/Table';
import { useModal } from '/@/components/Modal';
import { useListPage } from '/@/hooks/system/useListPage';
... ... @@ -51,6 +51,39 @@
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 tableColumns = computed(() => {
return columns.map((col) => {
if (col.dataIndex === 'index') {
// 序号列特殊处理
return {
...col,
customRender: ({ index }) => {
return (pagination.value.current - 1) * pagination.value.pageSize + index + 1;
},
};
}
return col;
});
});
//注册model
const [registerModal, { openModal }] = useModal();
//注册table数据
... ... @@ -58,7 +91,7 @@
tableProps: {
title: '日志管理',
api: list,
columns,
columns: tableColumns.value,
canResize: false,
formConfig: {
//labelWidth: 120,
... ... @@ -75,6 +108,13 @@
],
],
},
pagination: {
current: 1,
pageSize: 10,
showSizeChanger: true,
pageSizeOptions: ['10', '20', '30'],
showTotal: (total) => `共 ${total} 条`,
},
actionColumn: {
width: 120,
fixed: 'right',
... ...
... ... @@ -3,21 +3,15 @@ import { FormSchema } from '/@/components/Table';
import { listKnowledge } from '@/views/super/airag/questionembedding/QuestionEmbedding.api';
export const columns: BasicColumn[] = [
// {
// title: '序号',
// align: 'center',
// dataIndex: 'index',
// key: 'rowIndex',
// width: 60,
// customRender: function ({ index }) {
// // 获取分页参数
// const pagination = this.$parent.pagination;
// if (!pagination) return index + 1;
//
// // 计算连续序号: (当前页 - 1) * 每页条数 + 当前行索引 + 1
// return (pagination.current - 1) * pagination.pageSize + index + 1;
// },
// },
{
title: '序号',
align: 'center',
dataIndex: 'index',
key: 'rowIndex',
width: 60,
// 这里只需简单的序号,实际计算在组件内完成
customRender: ({ index }) => index + 1,
},
{
title: 'ID',
align: 'center',
... ...
... ... @@ -44,7 +44,7 @@
</template>
<script lang="ts" setup>
import { ref, reactive, watch } from 'vue';
import { ref, reactive, computed } from 'vue';
import { UploadOutlined } from '@ant-design/icons-vue';
import { BasicTable, TableAction } from '/@/components/Table';
import { BasicModal } from '/@/components/Modal';
... ... @@ -81,11 +81,27 @@
pagination.value = {
current: pag.current,
pageSize: pag.pageSize,
total: pag.total
total: pag.total,
};
}
}
// 创建带序号列的列配置
const tableColumns = computed(() => {
return columns.map((col) => {
if (col.dataIndex === 'index') {
// 序号列特殊处理
return {
...col,
customRender: ({ index }) => {
return (pagination.value.current - 1) * pagination.value.pageSize + index + 1;
},
};
}
return col;
});
});
// 知识库选择表单
const [registerImportForm] = useForm({
labelWidth: 100,
... ... @@ -113,13 +129,19 @@
tableProps: {
title: '问答向量库',
api: list,
columns,
columns: tableColumns.value,
formConfig: {
schemas: searchFormSchema,
autoSubmitOnEnter: true,
showAdvancedButton: true,
},
pagination: pagination.value, // 传递分页配置
pagination: {
current: 1,
pageSize: 10,
showSizeChanger: true,
pageSizeOptions: ['10', '20', '30'],
showTotal: (total) => `共 ${total} 条`,
},
actionColumn: {
width: 120,
fixed: 'right',
... ... @@ -132,11 +154,7 @@
},
});
const [registerTable, { reload }, { rowSelection, selectedRowKeys, pagination: tablePagination }] = tableContext;
watch(tablePagination, (newVal) => {
pagination.value = newVal;
});
const [registerTable, { reload }, { rowSelection, selectedRowKeys }] = tableContext;
function handleOpenImportModal() {
importModalVisible.value = true;
... ...
<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);
}
/**
* 成功回调
*/
... ...