pagination for withdraw
This commit is contained in:
@@ -91,7 +91,7 @@
|
|||||||
</CRow>
|
</CRow>
|
||||||
|
|
||||||
<CCard>
|
<CCard>
|
||||||
<CCardHeader>
|
<CCardHeader >
|
||||||
<slot name="header">
|
<slot name="header">
|
||||||
<CIcon name="cil-grid" />
|
<CIcon name="cil-grid" />
|
||||||
درخواست های برداشت
|
درخواست های برداشت
|
||||||
@@ -99,7 +99,7 @@
|
|||||||
</CCardHeader>
|
</CCardHeader>
|
||||||
|
|
||||||
<CCardBody>
|
<CCardBody>
|
||||||
<el-table :data="filteredItems" :row-class-name="hasUnread" style="width: 100%">
|
<el-table :data="paginatedItems" :row-class-name="hasUnread" style="width: 100%">
|
||||||
<el-table-column type="index" label="#"> </el-table-column>
|
<el-table-column type="index" label="#"> </el-table-column>
|
||||||
|
|
||||||
<el-table-column label="مبلغ تومانی " width="150px">
|
<el-table-column label="مبلغ تومانی " width="150px">
|
||||||
@@ -156,6 +156,17 @@
|
|||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
</el-table>
|
</el-table>
|
||||||
|
<div style="direction:ltr; textAlign:center; marginTop:20px;">
|
||||||
|
<el-pagination
|
||||||
|
v-if="paginate"
|
||||||
|
background
|
||||||
|
layout="prev, pager, next"
|
||||||
|
:current-page="currentPage"
|
||||||
|
:page-count="totalPages"
|
||||||
|
@current-change="handlePageChange"
|
||||||
|
>
|
||||||
|
</el-pagination>
|
||||||
|
</div>
|
||||||
</CCardBody>
|
</CCardBody>
|
||||||
</CCard>
|
</CCard>
|
||||||
</div>
|
</div>
|
||||||
@@ -167,11 +178,19 @@ export default {
|
|||||||
layout: 'admin',
|
layout: 'admin',
|
||||||
async asyncData({ $axios, error, query }) {
|
async asyncData({ $axios, error, query }) {
|
||||||
try {
|
try {
|
||||||
const { data } = await $axios.get('/api/admin/gps/withdraw')
|
const page = parseInt(query.page) || 1
|
||||||
// console.log('data bardasht hahahahhahahah', data)
|
const rows = parseInt(query.rows) || 10
|
||||||
|
const { data } = await $axios.get('/api/admin/gps/withdraw', {
|
||||||
|
params: {
|
||||||
|
page,
|
||||||
|
rows
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
return {
|
return {
|
||||||
requestsData: data.data
|
requestsData: data.data,
|
||||||
|
totalDocuments: data.totalDocuments || 0,
|
||||||
|
totalPages: data.totalPages || 1
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error)
|
console.log(error)
|
||||||
@@ -180,10 +199,13 @@ export default {
|
|||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
requestsData: [],
|
requestsData: [],
|
||||||
|
totalDocuments: 0,
|
||||||
|
totalPages: 1,
|
||||||
centerDialogVisible: false,
|
centerDialogVisible: false,
|
||||||
requestData: {},
|
requestData: {},
|
||||||
filterText: '',
|
filterText: '',
|
||||||
trackingNumber: null
|
trackingNumber: null,
|
||||||
|
pageSize: 10
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -207,7 +229,7 @@ export default {
|
|||||||
const filterText = this.filterText
|
const filterText = this.filterText
|
||||||
if (!this.filterText.length) return filterUsersByType
|
if (!this.filterText.length) return filterUsersByType
|
||||||
else {
|
else {
|
||||||
return this.requestsData.filter(item => {
|
return filterUsersByType.filter(item => {
|
||||||
return (
|
return (
|
||||||
item.userId.mobile_number.includes(filterText) ||
|
item.userId.mobile_number.includes(filterText) ||
|
||||||
item.userId.national_code.includes(filterText) ||
|
item.userId.national_code.includes(filterText) ||
|
||||||
@@ -217,6 +239,18 @@ export default {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
totalFilteredItems() {
|
||||||
|
return this.filteredItems.length
|
||||||
|
},
|
||||||
|
paginatedItems() {
|
||||||
|
return this.filteredItems
|
||||||
|
},
|
||||||
|
currentPage() {
|
||||||
|
return parseInt(this.$route.query?.page) || 1
|
||||||
|
},
|
||||||
|
paginate() {
|
||||||
|
return this.totalPages > 1
|
||||||
|
},
|
||||||
filterType: {
|
filterType: {
|
||||||
get() {
|
get() {
|
||||||
return this.$route.query?.filter
|
return this.$route.query?.filter
|
||||||
@@ -226,7 +260,47 @@ export default {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
watch: {
|
||||||
|
filterText() {
|
||||||
|
this.fetchData(1)
|
||||||
|
},
|
||||||
|
filterType() {
|
||||||
|
this.fetchData(1)
|
||||||
|
},
|
||||||
|
'$route.query.page'() {
|
||||||
|
this.fetchData()
|
||||||
|
}
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
async fetchData(page = null) {
|
||||||
|
const currentPage = page || this.currentPage
|
||||||
|
try {
|
||||||
|
const { data } = await this.$axios.get('/api/admin/gps/withdraw', {
|
||||||
|
params: {
|
||||||
|
page: currentPage,
|
||||||
|
rows: this.pageSize
|
||||||
|
}
|
||||||
|
})
|
||||||
|
this.requestsData = data.data
|
||||||
|
this.totalDocuments = data.totalDocuments || 0
|
||||||
|
this.totalPages = data.totalPages || 1
|
||||||
|
} catch (error) {
|
||||||
|
console.log(error)
|
||||||
|
this.$message({
|
||||||
|
type: 'error',
|
||||||
|
message: 'خطا در دریافت اطلاعات'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
},
|
||||||
|
handlePageChange(page) {
|
||||||
|
this.$router.push({
|
||||||
|
name: 'admin-gps-withdraw',
|
||||||
|
query: {
|
||||||
|
...this.$route.query,
|
||||||
|
page
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
showDialog(data) {
|
showDialog(data) {
|
||||||
this.requestData = data
|
this.requestData = data
|
||||||
this.centerDialogVisible = true
|
this.centerDialogVisible = true
|
||||||
|
|||||||
Reference in New Issue
Block a user