From c7251f7c276a45b1265c4ae30190e9f1aa357576 Mon Sep 17 00:00:00 2001 From: mahyargdz Date: Tue, 31 Dec 2024 11:29:37 +0330 Subject: [PATCH] fix: not fetche withdraw request --- pages/admin/gps/withdraw/index.vue | 7 +++-- server/controllers/GPS.Withdraw.js | 48 ++++++++++++++++++------------ 2 files changed, 34 insertions(+), 21 deletions(-) diff --git a/pages/admin/gps/withdraw/index.vue b/pages/admin/gps/withdraw/index.vue index d1683c2..f78dfa7 100644 --- a/pages/admin/gps/withdraw/index.vue +++ b/pages/admin/gps/withdraw/index.vue @@ -41,7 +41,7 @@ - دستگاه های نصب شده + درخواست های برداشت @@ -94,7 +94,7 @@ - دستگاه های نصب شده + درخواست های برداشت @@ -163,6 +163,7 @@ export default { async asyncData({ $axios, error, query }) { try { const { data } = await $axios.get('/api/admin/gps/withdraw') + // console.log('data bardasht hahahahhahahah', data) return { requestsData: data.data @@ -186,6 +187,8 @@ export default { return this.$config }, filteredItems() { + console.log('res data', this.requestsData) + const filterUsersByType = this.requestsData.filter(item => { if (this.filterType === 'all') return item // eslint-disable-next-line eqeqeq diff --git a/server/controllers/GPS.Withdraw.js b/server/controllers/GPS.Withdraw.js index 89e050f..3de3600 100644 --- a/server/controllers/GPS.Withdraw.js +++ b/server/controllers/GPS.Withdraw.js @@ -106,26 +106,36 @@ module.exports.getAllForAdmin = async (req, res) => { } : {} - const aggregationPipeline = [ - { $match: matchStage }, - { - $lookup: { - from: 'users', - localField: 'userId', - foreignField: '_id', - as: 'userId' - } - }, - { $unwind: '$userId' }, - { $sort: { [sortField]: sortOrder } }, - { $skip: skip }, - { $limit: rows } - ] + // const aggregationPipeline = [ + // { $match: matchStage }, + // { + // $lookup: { + // from: 'usergps', + // localField: 'userId', + // foreignField: '_id', + // as: 'userId' + // } + // }, + // { $unwind: '$userId' }, + // { $sort: { [sortField]: sortOrder } }, + // { $skip: skip }, + // { $limit: rows } + // ] + // const data = await Withdraw.aggregate(aggregationPipeline) + const data = await Withdraw.find(matchStage) + .sort({ [sortField]: sortOrder }) + .skip(skip) + .limit(rows) + .populate('userId') - const [data, totalDocuments] = await Promise.all([ - Withdraw.aggregate(aggregationPipeline), - Withdraw.countDocuments(matchStage) - ]) + const totalDocuments = await Withdraw.countDocuments(matchStage) + + console.log(data) + + // const [data, totalDocuments] = await Promise.all([ + // Withdraw.aggregate(aggregationPipeline), + // Withdraw.countDocuments(matchStage) + // ]) const totalPages = Math.ceil(totalDocuments / rows)