fix: not fetche withdraw request

This commit is contained in:
mahyargdz
2024-12-31 11:29:37 +03:30
parent cd61741d06
commit c7251f7c27
2 changed files with 34 additions and 21 deletions
+5 -2
View File
@@ -41,7 +41,7 @@
</el-dialog> </el-dialog>
<CustomSubHeader> <CustomSubHeader>
<CBreadcrumb class="border-0 mb-0"> دستگاه های نصب شده</CBreadcrumb> <CBreadcrumb class="border-0 mb-0">درخواست های برداشت</CBreadcrumb>
</CustomSubHeader> </CustomSubHeader>
<CRow> <CRow>
@@ -94,7 +94,7 @@
<CCardHeader> <CCardHeader>
<slot name="header"> <slot name="header">
<CIcon name="cil-grid" /> <CIcon name="cil-grid" />
دستگاه های نصب شده درخواست های برداشت
</slot> </slot>
</CCardHeader> </CCardHeader>
@@ -163,6 +163,7 @@ export default {
async asyncData({ $axios, error, query }) { async asyncData({ $axios, error, query }) {
try { try {
const { data } = await $axios.get('/api/admin/gps/withdraw') const { data } = await $axios.get('/api/admin/gps/withdraw')
// console.log('data bardasht hahahahhahahah', data)
return { return {
requestsData: data.data requestsData: data.data
@@ -186,6 +187,8 @@ export default {
return this.$config return this.$config
}, },
filteredItems() { filteredItems() {
console.log('res data', this.requestsData)
const filterUsersByType = this.requestsData.filter(item => { const filterUsersByType = this.requestsData.filter(item => {
if (this.filterType === 'all') return item if (this.filterType === 'all') return item
// eslint-disable-next-line eqeqeq // eslint-disable-next-line eqeqeq
+29 -19
View File
@@ -106,26 +106,36 @@ module.exports.getAllForAdmin = async (req, res) => {
} }
: {} : {}
const aggregationPipeline = [ // const aggregationPipeline = [
{ $match: matchStage }, // { $match: matchStage },
{ // {
$lookup: { // $lookup: {
from: 'users', // from: 'usergps',
localField: 'userId', // localField: 'userId',
foreignField: '_id', // foreignField: '_id',
as: 'userId' // as: 'userId'
} // }
}, // },
{ $unwind: '$userId' }, // { $unwind: '$userId' },
{ $sort: { [sortField]: sortOrder } }, // { $sort: { [sortField]: sortOrder } },
{ $skip: skip }, // { $skip: skip },
{ $limit: rows } // { $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([ const totalDocuments = await Withdraw.countDocuments(matchStage)
Withdraw.aggregate(aggregationPipeline),
Withdraw.countDocuments(matchStage) console.log(data)
])
// const [data, totalDocuments] = await Promise.all([
// Withdraw.aggregate(aggregationPipeline),
// Withdraw.countDocuments(matchStage)
// ])
const totalPages = Math.ceil(totalDocuments / rows) const totalPages = Math.ceil(totalDocuments / rows)