优化提现订单跳转与按钮样式
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
<script setup lang="ts">
|
||||
import { onMounted, ref } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { computed, onMounted, ref } from 'vue'
|
||||
import { useRoute, useRouter } from 'vue-router'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
|
||||
import {
|
||||
@@ -14,6 +14,7 @@ import { adminPath } from '@/shared/utils/adminPath'
|
||||
|
||||
import WithdrawalDetailDialog from '../components/WithdrawalDetailDialog.vue'
|
||||
|
||||
const route = useRoute()
|
||||
const router = useRouter()
|
||||
|
||||
const loading = ref(false)
|
||||
@@ -39,10 +40,48 @@ const statusOptions = [
|
||||
{ label: '已取消', value: 'cancelled' },
|
||||
]
|
||||
|
||||
onMounted(() => {
|
||||
loadWithdrawals()
|
||||
const withdrawalReturnQuery = computed<Record<string, string>>(() => {
|
||||
const query: Record<string, string> = {
|
||||
from: 'withdrawals',
|
||||
withdrawal_page: String(currentPage.value),
|
||||
withdrawal_page_size: String(pageSize.value),
|
||||
}
|
||||
if (filters.value.status) query.withdrawal_status = filters.value.status
|
||||
if (filters.value.user_id) query.withdrawal_user_id = String(filters.value.user_id)
|
||||
return query
|
||||
})
|
||||
|
||||
onMounted(() => {
|
||||
restoreListState()
|
||||
void loadWithdrawals()
|
||||
})
|
||||
|
||||
function routeQueryString(value: unknown) {
|
||||
return typeof value === 'string' ? value : ''
|
||||
}
|
||||
|
||||
function restoreListState() {
|
||||
const status = routeQueryString(route.query.withdrawal_status)
|
||||
if (statusOptions.some(item => item.value === status)) {
|
||||
filters.value.status = status
|
||||
}
|
||||
|
||||
const userID = Number(routeQueryString(route.query.withdrawal_user_id))
|
||||
if (Number.isSafeInteger(userID) && userID > 0) {
|
||||
filters.value.user_id = userID
|
||||
}
|
||||
|
||||
const restoredPage = Number(routeQueryString(route.query.withdrawal_page))
|
||||
if (Number.isSafeInteger(restoredPage) && restoredPage > 0) {
|
||||
currentPage.value = restoredPage
|
||||
}
|
||||
|
||||
const restoredPageSize = Number(routeQueryString(route.query.withdrawal_page_size))
|
||||
if ([10, 20, 50, 100].includes(restoredPageSize)) {
|
||||
pageSize.value = restoredPageSize
|
||||
}
|
||||
}
|
||||
|
||||
async function loadWithdrawals() {
|
||||
loading.value = true
|
||||
try {
|
||||
@@ -76,7 +115,10 @@ function goToOwnerOrders(withdrawal: WithdrawalDetail) {
|
||||
const keyword = withdrawal.user_phone?.trim() || String(withdrawal.user_id || '')
|
||||
void router.push({
|
||||
path: adminPath('orders'),
|
||||
query: keyword ? { keyword } : {},
|
||||
query: {
|
||||
...withdrawalReturnQuery.value,
|
||||
...(keyword ? { keyword } : {}),
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
@@ -311,6 +353,7 @@ function onDetailDialogSaved() {
|
||||
<WithdrawalDetailDialog
|
||||
v-model="showDetailDialog"
|
||||
:withdrawal="selectedWithdrawal"
|
||||
:return-query="withdrawalReturnQuery"
|
||||
@saved="onDetailDialogSaved"
|
||||
/>
|
||||
</section>
|
||||
|
||||
Reference in New Issue
Block a user