作者 dong

序号列修复

... ... @@ -8,11 +8,10 @@ export const columns: BasicColumn[] = [
{
title: '序号',
align: 'center',
dataIndex: 'index',
key: 'rowIndex',
dataIndex: 'index', // 使用数据中的index字段
key: 'index',
width: 60,
// 这里只需简单的序号,实际计算在组件内完成
customRender: ({ index }) => index + 1,
// 移除原有的customRender
},
{
title: '按钮名称',
... ... @@ -98,10 +97,7 @@ export const formSchema: FormSchema[] = [
field: 'buttonValues',
component: 'InputTextArea', // 替换为文本域组件
componentProps: {
autoSize: {
minRows: 1, // 最小行数
maxRows: 6, // 最大行数
},
rows: 6,
style: { width: '100%' }, // 宽度自适应
},
required: true,
... ...
<template>
<div>
<!--引用表格-->
<BasicTable @register="registerTable" :rowSelection="rowSelection" @change="handleTableChange">
<BasicTable @register="registerTable" :rowSelection="rowSelection">
<!--插槽:table标题-->
<template #tableTitle>
<a-button type="primary" v-auth="'airagbutton:airag_button:add'" @click="handleAdd" preIcon="ant-design:plus-outlined"> 新增</a-button>
... ... @@ -41,60 +41,37 @@
</template>
<script lang="ts" name="airagbutton-airagButton" setup>
import {ref, reactive, computed} from 'vue';
import { ref, reactive } from 'vue';
import { BasicTable, TableAction } from '/@/components/Table';
import { useModal } from '/@/components/Modal';
import { useListPage } from '/@/hooks/system/useListPage';
import AiragButtonModal from './components/AiragButtonModal.vue';
import { columns, searchFormSchema, superQuerySchema } from './AiragButton.data';
import { list, deleteOne, batchDelete, getImportUrl, getExportUrl, saveOrUpdate } from './AiragButton.api';
import { list, deleteOne, batchDelete, getImportUrl, getExportUrl } from './AiragButton.api';
import { useUserStore } from '/@/store/modules/user';
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数据
const { prefixCls, tableContext, onExportXls, onImportXls } = useListPage({
tableProps: {
title: '按钮表单',
api: list,
columns: tableColumns.value,
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,
canResize: false,
formConfig: {
//labelWidth: 120,
... ... @@ -104,13 +81,6 @@ import {ref, reactive, computed} from 'vue';
fieldMapToNumber: [],
fieldMapToTime: [],
},
pagination: {
current: 1,
pageSize: 10,
showSizeChanger: true,
pageSizeOptions: ['10', '20', '30'],
showTotal: (total) => `共 ${total} 条`,
},
actionColumn: {
width: 120,
fixed: 'right',
... ... @@ -131,7 +101,6 @@ import {ref, reactive, computed} from 'vue';
});
const [registerTable, { reload }, { rowSelection, selectedRowKeys }] = tableContext;
// 高级查询配置
const superQueryConfig = reactive(superQuerySchema);
... ...
... ... @@ -6,11 +6,10 @@ export const columns: BasicColumn[] = [
{
title: '序号',
align: 'center',
dataIndex: 'index',
key: 'rowIndex',
dataIndex: 'index', // 使用数据中的index字段
key: 'index',
width: 60,
// 这里只需简单的序号,实际计算在组件内完成
customRender: ({ index }) => index + 1,
// 移除原有的customRender
},
{
title: '问题',
... ...
... ... @@ -39,7 +39,7 @@
</template>
<script lang="ts" name="airaglog-airagLog" setup>
import {ref, reactive, computed} from 'vue';
import { ref, reactive } from 'vue';
import { BasicTable, TableAction } from '/@/components/Table';
import { useModal } from '/@/components/Modal';
import { useListPage } from '/@/hooks/system/useListPage';
... ... @@ -51,47 +51,25 @@ import {ref, reactive, computed} from 'vue';
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数据
const { prefixCls, tableContext, onExportXls, onImportXls } = useListPage({
tableProps: {
title: '日志管理',
api: list,
columns: tableColumns.value,
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,
canResize: false,
formConfig: {
//labelWidth: 120,
... ... @@ -108,13 +86,6 @@ import {ref, reactive, computed} from 'vue';
],
],
},
pagination: {
current: 1,
pageSize: 10,
showSizeChanger: true,
pageSizeOptions: ['10', '20', '30'],
showTotal: (total) => `共 ${total} 条`,
},
actionColumn: {
width: 120,
fixed: 'right',
... ...
... ... @@ -9,8 +9,6 @@ export const columns: BasicColumn[] = [
dataIndex: 'index',
key: 'rowIndex',
width: 60,
// 这里只需简单的序号,实际计算在组件内完成
customRender: ({ index }) => index + 1,
},
{
title: 'ID',
... ...
... ... @@ -67,41 +67,6 @@
const uploadProgress = ref(0);
const progressColor = ref('#1890ff');
const uploadStatus = ref<'normal' | 'exception' | 'active' | 'success'>('normal');
// 分页信息
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;
});
});
// 知识库选择表单
const [registerImportForm] = useForm({
labelWidth: 100,
... ... @@ -128,8 +93,24 @@
const { tableContext, onExportXls } = useListPage({
tableProps: {
title: '问答向量库',
api: list,
columns: tableColumns.value,
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,
indexColumnProps: {
title: '序号',
width: 80,
fixed: 'left',
},
formConfig: {
schemas: searchFormSchema,
autoSubmitOnEnter: true,
... ...
... ... @@ -24,7 +24,7 @@
</a-button>
</a-dropdown>
<!-- 高级查询 -->
<!-- <super-query :config="superQueryConfig" @search="handleSuperQuery" />-->
<!-- <super-query :config="superQueryConfig" @search="handleSuperQuery" />-->
</template>
<!--操作栏-->
<template #action="{ record }">
... ...