修复支持分页查找-姓名

This commit is contained in:
WindowBird 2025-09-17 16:00:22 +08:00
parent 07ca8b76ca
commit be06c06f43
3 changed files with 29 additions and 10 deletions

View File

@ -9,7 +9,7 @@
:width="'100%'" :width="'100%'"
btn-text="搜索" btn-text="搜索"
placeholder="请输入搜索关键词" placeholder="请输入搜索关键词"
@search="onSearch" @search="onSearch()"
/> />
<view class="filter-btn" @click="show = true"> <view class="filter-btn" @click="show = true">
<image <image
@ -204,6 +204,11 @@ export default {
this.initData(options.formedId); this.initData(options.formedId);
} }
}, },
onReachBottom() {
//
this.loadMoreDonationRecords();
},
methods: { methods: {
changeSortAmount(order) { changeSortAmount(order) {
this.filter.sortAmount = order; this.filter.sortAmount = order;

View File

@ -61,21 +61,23 @@ export const dataManagerMixin = {
} }
try { try {
console.log("isLoadMore", isLoadMore);
// 更新页码 // 更新页码
if (isLoadMore) { if (isLoadMore) {
this.pageNum++; this.pageNum++;
console.log("this.pageNum", this.pageNum);
} else { } else {
this.pageNum = 1; this.pageNum = 1;
} }
// 构建请求参数 // 构建请求参数
const requestParams = { const requestParams = {
pageNum: this.pageNum,
pageSize: this.pageSize,
...this.currentParams, ...this.currentParams,
...params, ...params,
pageNum: this.pageNum,
pageSize: this.pageSize,
}; };
console.log("requestParams", requestParams);
// 调用API // 调用API
const response = await apiCall(requestParams); const response = await apiCall(requestParams);
@ -109,8 +111,16 @@ export const dataManagerMixin = {
// 更新状态 // 更新状态
this.total = total; this.total = total;
this.hasMore = newData.length === this.pageSize;
this.currentParams = { ...requestParams }; this.currentParams = { ...requestParams };
console.log("@@@hasMore", this.hasMore);
this.hasMore =
this.pageSize * this.currentParams.pageNum < this.total;
console.log("this.hasMore", this.hasMore);
console.log("this.total", this.total);
console.log("this.pageSize", this.pageSize);
console.log("this.currentParams.pageNum", this.currentParams.pageNum);
// 成功回调 // 成功回调
if (onSuccess) { if (onSuccess) {
@ -178,7 +188,7 @@ export const dataManagerMixin = {
*/ */
searchData(searchParams = {}, options = {}) { searchData(searchParams = {}, options = {}) {
return this.fetchData({ return this.fetchData({
isLoadMore: false, // isLoadMore: false,
params: searchParams, params: searchParams,
...options, ...options,
}); });

View File

@ -122,7 +122,7 @@ export const donationMixin = {
dataTransformer: this.transformDonationData, dataTransformer: this.transformDonationData,
params: baseParams, params: baseParams,
dataPath: "data.list.rows", dataPath: "data.list.rows",
totalPath: "data.total", totalPath: "data.list.total",
onSuccess: (data, response) => { onSuccess: (data, response) => {
console.log("捐款记录加载成功:", data.length, "条"); console.log("捐款记录加载成功:", data.length, "条");
}, },
@ -137,14 +137,18 @@ export const donationMixin = {
* @param {string} val 搜索关键词 * @param {string} val 搜索关键词
*/ */
async onSearch(val) { async onSearch(val) {
console.log("@@@@@@@@@@val", val);
this.searchKeyword = val; this.searchKeyword = val;
console.log("@@@@@@@@@@", this.searchKeyword);
await this.searchData( await this.searchData(
{ ...this.getBaseParams(), realName: val }, { ...this.getBaseParams(), realName: val.trim() },
{ {
apiCall: getDonorList, apiCall: getDonorList,
dataTransformer: this.transformDonationData, dataTransformer: this.transformDonationData,
dataPath: "data.list.rows", dataPath: "data.list.rows",
totalPath: "data.total", totalPath: "data.list.total",
onSuccess: (data, response) => { onSuccess: (data, response) => {
console.log("搜索完成,找到:", data.length, "条记录"); console.log("搜索完成,找到:", data.length, "条记录");
}, },
@ -167,7 +171,7 @@ export const donationMixin = {
dataTransformer: this.transformDonationData, dataTransformer: this.transformDonationData,
params: currentParams, params: currentParams,
dataPath: "data.list.rows", dataPath: "data.list.rows",
totalPath: "data.total", totalPath: "data.list.total",
onSuccess: (data, response) => { onSuccess: (data, response) => {
console.log("加载更多完成,新增:", data.length, "条记录"); console.log("加载更多完成,新增:", data.length, "条记录");
}, },