Commit cdc42d4b authored by qinhaitao's avatar qinhaitao

feat: 导出自动分页

parent 6a189251
......@@ -92,7 +92,7 @@ Component({
// 获取中奖名单
async handleOpenWinnerList(evt) {
const { activityId } = evt.target.dataset.x.record;
const { data,success } = await findWinnerInfoList({ activityId});
const { data,success } = await findWinnerInfoList({ activityId });
if (success) {
this.setData({
......
......@@ -14,14 +14,16 @@ let resultsModel = new ResultsModel();
// 活动中奖名单
const findWinnerInfoList = async (context) => {
let {
activityId
activityId,
pageNo = 1,
pageSize = 500
} = context.data;
if (!activityId) {
return resultsModel.error(CODE_TYPES.PARAMS_ERROR, `缺少activityId`);
}
let rankopenprizeService = new RankopenprizeService(context);
// 获取活动中奖列表
let awardslist = await rankopenprizeService.getAwardslistByActivityId(activityId);
let awardslist = await rankopenprizeService.getAwardslistByActivityId(activityId, pageNo, pageSize);
console.log(`awardslist: ${JSON.stringify(awardslist)}`);
let winnersObj = {};
awardslist.forEach((v, index, arr) => {
......@@ -62,8 +64,21 @@ const exportAwardsList = async (context) => {
return resultsModel.error(CODE_TYPES.PARAMS_ERROR, `缺少title`);
}
let rankopenprizeService = new RankopenprizeService(context);
let pageNo = 1;
let pageSize = 500
let awardslist = []
// 自动分页
while (awardslist.length >= (pageNo - 1) * 500) {
let nowPageNoList = await rankopenprizeService.getAwardslistByActivityId(activityId, pageNo, pageSize);
awardslist = [...awardslist, ...nowPageNoList]
pageNo += 1;
}
// 获取活动中奖列表
let awardslist = await rankopenprizeService.getAwardslistByActivityId(activityId);
console.log(`awardslist: ${JSON.stringify(awardslist)}`);
let xlsxData = [
......
......@@ -28,11 +28,11 @@ class RankopenprizeService {
}
// 根据活动id查找中奖名单
async getAwardslistByActivityId(activityId) {
async getAwardslistByActivityId(activityId, pageNo, pageSize) {
if (!activityId) {
return false;
}
return await this.rankopenprizeDao.find(
let result = await this.rankopenprizeDao.find(
{
activityId: activityId,
},
......@@ -41,8 +41,12 @@ class RankopenprizeService {
score: -1,
rankTime: -1,
},
limit: pageSize,
skip: (pageNo - 1) * pageSize,
}
);
return result
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment