作者 dong

序号列

@@ -6,6 +6,15 @@ import { saveOrUpdate } from '@/views/super/airag/airagbutton/AiragButton.api'; @@ -6,6 +6,15 @@ import { saveOrUpdate } from '@/views/super/airag/airagbutton/AiragButton.api';
6 //列表数据 6 //列表数据
7 export const columns: BasicColumn[] = [ 7 export const columns: BasicColumn[] = [
8 { 8 {
  9 + title: '序号',
  10 + align: 'center',
  11 + dataIndex: 'index',
  12 + key: 'rowIndex',
  13 + width: 60,
  14 + // 这里只需简单的序号,实际计算在组件内完成
  15 + customRender: ({ index }) => index + 1,
  16 + },
  17 + {
9 title: '按钮名称', 18 title: '按钮名称',
10 align: 'center', 19 align: 'center',
11 dataIndex: 'buttonName', 20 dataIndex: 'buttonName',
1 <template> 1 <template>
2 <div> 2 <div>
3 <!--引用表格--> 3 <!--引用表格-->
4 - <BasicTable @register="registerTable" :rowSelection="rowSelection"> 4 + <BasicTable @register="registerTable" :rowSelection="rowSelection" @change="handleTableChange">
5 <!--插槽:table标题--> 5 <!--插槽:table标题-->
6 <template #tableTitle> 6 <template #tableTitle>
7 <a-button type="primary" v-auth="'airagbutton:airag_button:add'" @click="handleAdd" preIcon="ant-design:plus-outlined"> 新增</a-button> 7 <a-button type="primary" v-auth="'airagbutton:airag_button:add'" @click="handleAdd" preIcon="ant-design:plus-outlined"> 新增</a-button>
@@ -26,7 +26,7 @@ @@ -26,7 +26,7 @@
26 </a-button> 26 </a-button>
27 </a-dropdown> 27 </a-dropdown>
28 <!-- 高级查询 --> 28 <!-- 高级查询 -->
29 -<!-- <super-query :config="superQueryConfig" @search="handleSuperQuery" />--> 29 + <!-- <super-query :config="superQueryConfig" @search="handleSuperQuery" />-->
30 </template> 30 </template>
31 <!--操作栏--> 31 <!--操作栏-->
32 <template #action="{ record }"> 32 <template #action="{ record }">
@@ -41,7 +41,7 @@ @@ -41,7 +41,7 @@
41 </template> 41 </template>
42 42
43 <script lang="ts" name="airagbutton-airagButton" setup> 43 <script lang="ts" name="airagbutton-airagButton" setup>
44 - import { ref, reactive } from 'vue'; 44 +import {ref, reactive, computed} from 'vue';
45 import { BasicTable, TableAction } from '/@/components/Table'; 45 import { BasicTable, TableAction } from '/@/components/Table';
46 import { useModal } from '/@/components/Modal'; 46 import { useModal } from '/@/components/Modal';
47 import { useListPage } from '/@/hooks/system/useListPage'; 47 import { useListPage } from '/@/hooks/system/useListPage';
@@ -52,6 +52,41 @@ @@ -52,6 +52,41 @@
52 const queryParam = reactive<any>({}); 52 const queryParam = reactive<any>({});
53 const checkedKeys = ref<Array<string | number>>([]); 53 const checkedKeys = ref<Array<string | number>>([]);
54 const userStore = useUserStore(); 54 const userStore = useUserStore();
  55 +
  56 + // 分页信息
  57 + const pagination = ref({
  58 + current: 1,
  59 + pageSize: 10,
  60 + total: 0,
  61 + });
  62 +
  63 + // 处理表格变化事件(包括分页变化)
  64 + function handleTableChange(pag) {
  65 + if (pag) {
  66 + pagination.value = {
  67 + current: pag.current,
  68 + pageSize: pag.pageSize,
  69 + total: pag.total,
  70 + };
  71 + }
  72 + }
  73 +
  74 + // 创建带序号列的列配置
  75 + const tableColumns = computed(() => {
  76 + return columns.map((col) => {
  77 + if (col.dataIndex === 'index') {
  78 + // 序号列特殊处理
  79 + return {
  80 + ...col,
  81 + customRender: ({ index }) => {
  82 + return (pagination.value.current - 1) * pagination.value.pageSize + index + 1;
  83 + },
  84 + };
  85 + }
  86 + return col;
  87 + });
  88 + });
  89 +
55 //注册model 90 //注册model
56 const [registerModal, { openModal }] = useModal(); 91 const [registerModal, { openModal }] = useModal();
57 //注册table数据 92 //注册table数据
@@ -59,7 +94,7 @@ @@ -59,7 +94,7 @@
59 tableProps: { 94 tableProps: {
60 title: '按钮表单', 95 title: '按钮表单',
61 api: list, 96 api: list,
62 - columns, 97 + columns: tableColumns.value,
63 canResize: false, 98 canResize: false,
64 formConfig: { 99 formConfig: {
65 //labelWidth: 120, 100 //labelWidth: 120,
@@ -69,6 +104,13 @@ @@ -69,6 +104,13 @@
69 fieldMapToNumber: [], 104 fieldMapToNumber: [],
70 fieldMapToTime: [], 105 fieldMapToTime: [],
71 }, 106 },
  107 + pagination: {
  108 + current: 1,
  109 + pageSize: 10,
  110 + showSizeChanger: true,
  111 + pageSizeOptions: ['10', '20', '30'],
  112 + showTotal: (total) => `共 ${total} 条`,
  113 + },
72 actionColumn: { 114 actionColumn: {
73 width: 120, 115 width: 120,
74 fixed: 'right', 116 fixed: 'right',
@@ -4,6 +4,15 @@ import { listKnowledgeName, listmodelid } from '@/views/super/airag/airaglog/Air @@ -4,6 +4,15 @@ import { listKnowledgeName, listmodelid } from '@/views/super/airag/airaglog/Air
4 //列表数据 4 //列表数据
5 export const columns: BasicColumn[] = [ 5 export const columns: BasicColumn[] = [
6 { 6 {
  7 + title: '序号',
  8 + align: 'center',
  9 + dataIndex: 'index',
  10 + key: 'rowIndex',
  11 + width: 60,
  12 + // 这里只需简单的序号,实际计算在组件内完成
  13 + customRender: ({ index }) => index + 1,
  14 + },
  15 + {
7 title: '问题', 16 title: '问题',
8 align: 'center', 17 align: 'center',
9 dataIndex: 'question', 18 dataIndex: 'question',
1 <template> 1 <template>
2 <div> 2 <div>
3 <!--引用表格--> 3 <!--引用表格-->
4 - <BasicTable @register="registerTable" :rowSelection="rowSelection"> 4 + <BasicTable @register="registerTable" :rowSelection="rowSelection" @change="handleTableChange">
5 <!--插槽:table标题--> 5 <!--插槽:table标题-->
6 <template #tableTitle> 6 <template #tableTitle>
7 <a-button type="primary" v-auth="'airaglog:airag_log:add'" @click="handleAdd" preIcon="ant-design:plus-outlined"> 新增</a-button> 7 <a-button type="primary" v-auth="'airaglog:airag_log:add'" @click="handleAdd" preIcon="ant-design:plus-outlined"> 新增</a-button>
@@ -24,7 +24,7 @@ @@ -24,7 +24,7 @@
24 </a-button> 24 </a-button>
25 </a-dropdown> 25 </a-dropdown>
26 <!-- 高级查询 --> 26 <!-- 高级查询 -->
27 -<!-- <super-query :config="superQueryConfig" @search="handleSuperQuery" />--> 27 + <!-- <super-query :config="superQueryConfig" @search="handleSuperQuery" />-->
28 </template> 28 </template>
29 <!--操作栏--> 29 <!--操作栏-->
30 <template #action="{ record }"> 30 <template #action="{ record }">
@@ -39,7 +39,7 @@ @@ -39,7 +39,7 @@
39 </template> 39 </template>
40 40
41 <script lang="ts" name="airaglog-airagLog" setup> 41 <script lang="ts" name="airaglog-airagLog" setup>
42 - import { ref, reactive } from 'vue'; 42 +import {ref, reactive, computed} from 'vue';
43 import { BasicTable, TableAction } from '/@/components/Table'; 43 import { BasicTable, TableAction } from '/@/components/Table';
44 import { useModal } from '/@/components/Modal'; 44 import { useModal } from '/@/components/Modal';
45 import { useListPage } from '/@/hooks/system/useListPage'; 45 import { useListPage } from '/@/hooks/system/useListPage';
@@ -51,6 +51,39 @@ @@ -51,6 +51,39 @@
51 const queryParam = reactive<any>({}); 51 const queryParam = reactive<any>({});
52 const checkedKeys = ref<Array<string | number>>([]); 52 const checkedKeys = ref<Array<string | number>>([]);
53 const userStore = useUserStore(); 53 const userStore = useUserStore();
  54 + // 分页信息
  55 + const pagination = ref({
  56 + current: 1,
  57 + pageSize: 10,
  58 + total: 0,
  59 + });
  60 +
  61 + // 处理表格变化事件(包括分页变化)
  62 + function handleTableChange(pag) {
  63 + if (pag) {
  64 + pagination.value = {
  65 + current: pag.current,
  66 + pageSize: pag.pageSize,
  67 + total: pag.total,
  68 + };
  69 + }
  70 + }
  71 +
  72 + // 创建带序号列的列配置
  73 + const tableColumns = computed(() => {
  74 + return columns.map((col) => {
  75 + if (col.dataIndex === 'index') {
  76 + // 序号列特殊处理
  77 + return {
  78 + ...col,
  79 + customRender: ({ index }) => {
  80 + return (pagination.value.current - 1) * pagination.value.pageSize + index + 1;
  81 + },
  82 + };
  83 + }
  84 + return col;
  85 + });
  86 + });
54 //注册model 87 //注册model
55 const [registerModal, { openModal }] = useModal(); 88 const [registerModal, { openModal }] = useModal();
56 //注册table数据 89 //注册table数据
@@ -58,7 +91,7 @@ @@ -58,7 +91,7 @@
58 tableProps: { 91 tableProps: {
59 title: '日志管理', 92 title: '日志管理',
60 api: list, 93 api: list,
61 - columns, 94 + columns: tableColumns.value,
62 canResize: false, 95 canResize: false,
63 formConfig: { 96 formConfig: {
64 //labelWidth: 120, 97 //labelWidth: 120,
@@ -75,6 +108,13 @@ @@ -75,6 +108,13 @@
75 ], 108 ],
76 ], 109 ],
77 }, 110 },
  111 + pagination: {
  112 + current: 1,
  113 + pageSize: 10,
  114 + showSizeChanger: true,
  115 + pageSizeOptions: ['10', '20', '30'],
  116 + showTotal: (total) => `共 ${total} 条`,
  117 + },
78 actionColumn: { 118 actionColumn: {
79 width: 120, 119 width: 120,
80 fixed: 'right', 120 fixed: 'right',
@@ -3,21 +3,15 @@ import { FormSchema } from '/@/components/Table'; @@ -3,21 +3,15 @@ import { FormSchema } from '/@/components/Table';
3 import { listKnowledge } from '@/views/super/airag/questionembedding/QuestionEmbedding.api'; 3 import { listKnowledge } from '@/views/super/airag/questionembedding/QuestionEmbedding.api';
4 4
5 export const columns: BasicColumn[] = [ 5 export const columns: BasicColumn[] = [
6 - // {  
7 - // title: '序号',  
8 - // align: 'center',  
9 - // dataIndex: 'index',  
10 - // key: 'rowIndex',  
11 - // width: 60,  
12 - // customRender: function ({ index }) {  
13 - // // 获取分页参数  
14 - // const pagination = this.$parent.pagination;  
15 - // if (!pagination) return index + 1;  
16 - //  
17 - // // 计算连续序号: (当前页 - 1) * 每页条数 + 当前行索引 + 1  
18 - // return (pagination.current - 1) * pagination.pageSize + index + 1;  
19 - // },  
20 - // }, 6 + {
  7 + title: '序号',
  8 + align: 'center',
  9 + dataIndex: 'index',
  10 + key: 'rowIndex',
  11 + width: 60,
  12 + // 这里只需简单的序号,实际计算在组件内完成
  13 + customRender: ({ index }) => index + 1,
  14 + },
21 { 15 {
22 title: 'ID', 16 title: 'ID',
23 align: 'center', 17 align: 'center',
@@ -44,7 +44,7 @@ @@ -44,7 +44,7 @@
44 </template> 44 </template>
45 45
46 <script lang="ts" setup> 46 <script lang="ts" setup>
47 - import { ref, reactive, watch } from 'vue'; 47 + import { ref, reactive, computed } from 'vue';
48 import { UploadOutlined } from '@ant-design/icons-vue'; 48 import { UploadOutlined } from '@ant-design/icons-vue';
49 import { BasicTable, TableAction } from '/@/components/Table'; 49 import { BasicTable, TableAction } from '/@/components/Table';
50 import { BasicModal } from '/@/components/Modal'; 50 import { BasicModal } from '/@/components/Modal';
@@ -81,11 +81,27 @@ @@ -81,11 +81,27 @@
81 pagination.value = { 81 pagination.value = {
82 current: pag.current, 82 current: pag.current,
83 pageSize: pag.pageSize, 83 pageSize: pag.pageSize,
84 - total: pag.total 84 + total: pag.total,
85 }; 85 };
86 } 86 }
87 } 87 }
88 88
  89 + // 创建带序号列的列配置
  90 + const tableColumns = computed(() => {
  91 + return columns.map((col) => {
  92 + if (col.dataIndex === 'index') {
  93 + // 序号列特殊处理
  94 + return {
  95 + ...col,
  96 + customRender: ({ index }) => {
  97 + return (pagination.value.current - 1) * pagination.value.pageSize + index + 1;
  98 + },
  99 + };
  100 + }
  101 + return col;
  102 + });
  103 + });
  104 +
89 // 知识库选择表单 105 // 知识库选择表单
90 const [registerImportForm] = useForm({ 106 const [registerImportForm] = useForm({
91 labelWidth: 100, 107 labelWidth: 100,
@@ -113,13 +129,19 @@ @@ -113,13 +129,19 @@
113 tableProps: { 129 tableProps: {
114 title: '问答向量库', 130 title: '问答向量库',
115 api: list, 131 api: list,
116 - columns, 132 + columns: tableColumns.value,
117 formConfig: { 133 formConfig: {
118 schemas: searchFormSchema, 134 schemas: searchFormSchema,
119 autoSubmitOnEnter: true, 135 autoSubmitOnEnter: true,
120 showAdvancedButton: true, 136 showAdvancedButton: true,
121 }, 137 },
122 - pagination: pagination.value, // 传递分页配置 138 + pagination: {
  139 + current: 1,
  140 + pageSize: 10,
  141 + showSizeChanger: true,
  142 + pageSizeOptions: ['10', '20', '30'],
  143 + showTotal: (total) => `共 ${total} 条`,
  144 + },
123 actionColumn: { 145 actionColumn: {
124 width: 120, 146 width: 120,
125 fixed: 'right', 147 fixed: 'right',
@@ -132,11 +154,7 @@ @@ -132,11 +154,7 @@
132 }, 154 },
133 }); 155 });
134 156
135 - const [registerTable, { reload }, { rowSelection, selectedRowKeys, pagination: tablePagination }] = tableContext;  
136 -  
137 - watch(tablePagination, (newVal) => {  
138 - pagination.value = newVal;  
139 - }); 157 + const [registerTable, { reload }, { rowSelection, selectedRowKeys }] = tableContext;
140 158
141 function handleOpenImportModal() { 159 function handleOpenImportModal() {
142 importModalVisible.value = true; 160 importModalVisible.value = true;
1 <template> 1 <template>
2 <div> 2 <div>
3 <!--引用表格--> 3 <!--引用表格-->
4 - <BasicTable @register="registerTable" :rowSelection="rowSelection"> 4 + <BasicTable @register="registerTable" :rowSelection="rowSelection" @change="handleTableChange">
5 <!--插槽:table标题--> 5 <!--插槽:table标题-->
6 <template #tableTitle> 6 <template #tableTitle>
7 <a-button type="primary" v-auth="'embeddings:embeddings:add'" @click="handleAdd" preIcon="ant-design:plus-outlined"> 新增</a-button> 7 <a-button type="primary" v-auth="'embeddings:embeddings:add'" @click="handleAdd" preIcon="ant-design:plus-outlined"> 新增</a-button>
8 -<!-- <a-button type="primary" v-auth="'embeddings:embeddings:exportXls'" preIcon="ant-design:export-outlined" @click="onExportXls"> 导出</a-button>--> 8 + <!--<a-button type="primary" v-auth="'embeddings:embeddings:exportXls'" preIcon="ant-design:export-outlined" @click="onExportXls"> 导出</a-button>-->
9 <j-upload-button type="primary" v-auth="'embeddings:embeddings:importWord'" preIcon="ant-design:import-outlined" @click="onImportXls" 9 <j-upload-button type="primary" v-auth="'embeddings:embeddings:importWord'" preIcon="ant-design:import-outlined" @click="onImportXls"
10 >导入</j-upload-button 10 >导入</j-upload-button
11 > 11 >
@@ -24,7 +24,7 @@ @@ -24,7 +24,7 @@
24 </a-button> 24 </a-button>
25 </a-dropdown> 25 </a-dropdown>
26 <!-- 高级查询 --> 26 <!-- 高级查询 -->
27 -<!-- <super-query :config="superQueryConfig" @search="handleSuperQuery" />--> 27 + <!-- <super-query :config="superQueryConfig" @search="handleSuperQuery" />-->
28 </template> 28 </template>
29 <!--操作栏--> 29 <!--操作栏-->
30 <template #action="{ record }"> 30 <template #action="{ record }">
@@ -48,10 +48,40 @@ @@ -48,10 +48,40 @@
48 import { list, batchDelete, getImportUrl, getExportUrl, deleteOne, listknowledge } from './Test.api'; 48 import { list, batchDelete, getImportUrl, getExportUrl, deleteOne, listknowledge } from './Test.api';
49 import { useUserStore } from '/@/store/modules/user'; 49 import { useUserStore } from '/@/store/modules/user';
50 import JUploadButton from '@/components/Button/src/JUploadButton.vue'; 50 import JUploadButton from '@/components/Button/src/JUploadButton.vue';
51 - import { columns as defaultColumns } from './Test.data'; // 导入默认列配置 51 + import { columns as defaultColumns } from './Test.data';
52 const queryParam = reactive<any>({}); 52 const queryParam = reactive<any>({});
53 const checkedKeys = ref<Array<string | number>>([]); 53 const checkedKeys = ref<Array<string | number>>([]);
54 const userStore = useUserStore(); 54 const userStore = useUserStore();
  55 + // 分页信息
  56 + const pagination = ref({
  57 + current: 1,
  58 + pageSize: 10,
  59 + total: 0,
  60 + });
  61 +
  62 + // 处理表格变化事件(包括分页变化)
  63 + function handleTableChange(pag) {
  64 + if (pag) {
  65 + pagination.value = {
  66 + current: pag.current,
  67 + pageSize: pag.pageSize,
  68 + total: pag.total,
  69 + };
  70 + }
  71 + }
  72 +
  73 + // 创建序号列
  74 + const indexColumn: BasicColumn = {
  75 + title: '序号',
  76 + align: 'center',
  77 + dataIndex: 'index',
  78 + key: 'rowIndex',
  79 + width: 60,
  80 + customRender: ({ index }) => {
  81 + // 使用分页状态计算连续序号
  82 + return (pagination.value.current - 1) * pagination.value.pageSize + index + 1;
  83 + },
  84 + };
55 // 添加知识库名称映射 85 // 添加知识库名称映射
56 const knowledgeMap = ref<Record<string, string>>({}); 86 const knowledgeMap = ref<Record<string, string>>({});
57 87
@@ -106,7 +136,7 @@ @@ -106,7 +136,7 @@
106 const filteredColumns = defaultColumns.filter((col) => col.dataIndex !== 'name' && col.title !== '知识库名称'); 136 const filteredColumns = defaultColumns.filter((col) => col.dataIndex !== 'name' && col.title !== '知识库名称');
107 137
108 // 添加新的知识库列 138 // 添加新的知识库列
109 - return [...filteredColumns, knowledgeColumn]; 139 + return [indexColumn, ...filteredColumns, knowledgeColumn];
110 }); 140 });
111 141
112 //注册model 142 //注册model
@@ -151,7 +181,7 @@ @@ -151,7 +181,7 @@
151 success: handleSuccess, 181 success: handleSuccess,
152 }, 182 },
153 }); 183 });
154 - const [registerTable, { reload }, { rowSelection, selectedRowKeys }] = tableContext; 184 + const [registerTable, { reload, setPagination }, { rowSelection, selectedRowKeys }] = tableContext;
155 185
156 // 高级查询配置 186 // 高级查询配置
157 const superQueryConfig = reactive(superQuerySchema); 187 const superQueryConfig = reactive(superQuerySchema);
@@ -203,14 +233,43 @@ @@ -203,14 +233,43 @@
203 * 删除事件 233 * 删除事件
204 */ 234 */
205 async function handleDelete(record) { 235 async function handleDelete(record) {
  236 + resetPaginationAfterDelete();
206 await deleteOne({ id: record.id }, handleSuccess); 237 await deleteOne({ id: record.id }, handleSuccess);
207 } 238 }
208 /** 239 /**
209 * 批量删除事件 240 * 批量删除事件
210 */ 241 */
211 async function batchHandleDelete() { 242 async function batchHandleDelete() {
  243 + resetPaginationAfterDelete();
212 await batchDelete({ ids: selectedRowKeys.value }, handleSuccess); 244 await batchDelete({ ids: selectedRowKeys.value }, handleSuccess);
213 } 245 }
  246 +
  247 + // 新增:删除操作后重置分页状态
  248 + function resetPaginationAfterDelete() {
  249 + // 获取当前分页状态
  250 + const currentPagination = pagination.value;
  251 +
  252 + // 计算删除后总页数
  253 + const totalPages = Math.ceil((currentPagination.total - 1) / currentPagination.pageSize);
  254 +
  255 + // 如果当前页码大于总页数,则回到最后一页
  256 + if (currentPagination.current > totalPages && totalPages > 0) {
  257 + pagination.value = {
  258 + ...currentPagination,
  259 + current: totalPages,
  260 + total: currentPagination.total - 1,
  261 + };
  262 + } else {
  263 + // 否则保持当前页,但更新总数
  264 + pagination.value = {
  265 + ...currentPagination,
  266 + total: currentPagination.total - 1,
  267 + };
  268 + }
  269 +
  270 + // 设置表格分页状态
  271 + setPagination(pagination.value);
  272 + }
214 /** 273 /**
215 * 成功回调 274 * 成功回调
216 */ 275 */