根据你提供的代码,我已经进行了一些修改,以确保正确显示序号和分页。以下是修改后的完整代码:
<a-table
:columns="columns"
:dataSource="dataSource"
:rowKey="(record, index) => index"
:scroll="{ x: 1800 }"
:pagination="pagination"
@change="handleTableChange"
:loading="loading"
>
<template slot="index" slot-scope="{ text, record, index }">
<div>{{ (pagination.currentPage - 1) * pagination.numPerPage + (index + 1) }}</div>
</template>
</a-table>
data() {
return {
pagination: {
pageSizeOptions: ['10', '20', '30', '40', '100'],
defaultCurrent: 1,
defaultPageSize: 10,
currentPage: 1,
numPerPage: 10,
total: this.pagination.pageCount,
showQuickJumper: true,
showSizeChanger: true,
showTotal: (total, range) => `显示 ${range[0]} ~ ${range[1]} 条记录,共 ${total} 条记录`
},
dataSource: [], // 数据源数组
loading: false // 加载状态标志位
// 其他变量...
// ...
queryTable() {
let condition = this.form.getFieldsValue();
condition.currentPage = this.pagination.defaultCurrent;
condition.numPerPage = this.pagination.defaultPageSize;
this.pagination.currentPage = condition.currentPage;
this.pagination.numPerPage = condition.numPerPage;
console.log(condition);
this.lastQuery(condition);
},
lastQuery(condition) {
this.loading = true;
condition.createTime = this.formstate.createTime;
condition.importDate = this.importDate;
let data = {
...this.formstate,
importDate: condition.importDate,
...condition
};
if (this.formstate.merchantName == '') {
this.formstate.merchantName = null;
}
if (this.formstate.shopName == '') {
this.formstate.shopName = null;
}
this.$http.post("/act-service/queryLegerPage", data)
.then(res => {
console.log(res.data.rows, 'res');
this.dataSource = res.data.rows;
this.pagination.total = res.pageCount;
})
.catch(error => {
this.$message.error(error.response.data.header.msg);
})
.finally(() => {
this.loading = false;
});
}
请注意,以上代码假设pagination.pageCount
为总条数。如果需要通过异步请求获取数据并更新总条数,请根据实际情况进行相应的更改。
希望这些修改能满足你的需求。如果还有其他问题,请随时提问。
内容由零声教学AI助手提供,问题来源于学员提问