修复订单列表返回状态丢失

This commit is contained in:
yml2213
2026-08-28 23:03:40 +08:00
parent a53b9dc617
commit 41a5b49450
3 changed files with 153 additions and 8 deletions
@@ -2,7 +2,7 @@
import { readError } from '@/shared/utils/error'
import { ElMessage, ElMessageBox } from 'element-plus'
import { computed, onMounted, ref } from 'vue'
import { useRoute } from 'vue-router'
import { useRoute, useRouter } from 'vue-router'
import {
adminCloseOrder,
@@ -33,7 +33,7 @@ import {
readSnapshot,
readSnapshotResources,
} from '@/features/orders/composables/useOrderSnapshot'
import { adminPath } from '@/shared/utils/adminPath'
import { adminPath, isAdminPath } from '@/shared/utils/adminPath'
import { centToYuan, formatCentWithSymbol } from '@/shared/utils/money'
import {
disputeStatusLabel,
@@ -46,6 +46,7 @@ import { formatDateTime } from '@/shared/utils/time'
import { formatGameName, formatListingNo } from '@/shared/utils/listingDisplay'
const route = useRoute()
const router = useRouter()
const loading = ref(false)
const submitting = ref(false)
const order = ref<Order | null>(null)
@@ -122,6 +123,15 @@ const returnLabel = computed(() =>
? '返回会话'
: '返回列表'
)
function goBackToList() {
const back = (window.history.state as { back?: string | null } | null)?.back
if (back && isAdminPath(back)) {
router.back()
return
}
void router.push(returnTarget.value)
}
const refunding = ref(false)
const snapshotText = computed(() => JSON.stringify(order.value?.account_snapshot || {}, null, 2))
@@ -910,9 +920,7 @@ function paymentPaidAt(record: AdminPayment) {
</p>
</div>
<div class="toolbar-actions">
<RouterLink :to="returnTarget">
<el-button>{{ returnLabel }}</el-button>
</RouterLink>
<el-button @click="goBackToList">{{ returnLabel }}</el-button>
<el-button v-if="canResetHandoff" type="success" @click="openAction('reset')">
{{ resetActionLabel }}
</el-button>
@@ -13,6 +13,7 @@ import { formatDateTime } from '@/shared/utils/time'
import { centToYuan, formatMoney } from '@/shared/utils/money'
import { formatListingNo } from '@/shared/utils/listingDisplay'
import { adminPath } from '@/shared/utils/adminPath'
import { useAdminListState } from '@/features/admin/composables/useAdminListState'
import AdminTablePagination from '../components/AdminTablePagination.vue'
const filters = reactive<AdminOrderQuery>({
@@ -31,6 +32,12 @@ const currentPageSize = ref(20)
const route = useRoute()
const router = useRouter()
const canReturnToWithdrawals = computed(() => route.query.from === 'withdrawals')
const { restoreScroll } = useAdminListState({
key: 'orders',
filters,
currentPage,
pageSize: currentPageSize,
})
const orderStatusOptions = [
{ label: '待支付', value: 'pending_payment' },
@@ -77,13 +84,14 @@ const settlementStatusOptions = [
{ label: '已仲裁', value: 'arbitrated' },
] as const
onMounted(() => {
onMounted(async () => {
// 支持从提现审核等页面跳转预填号主/租客搜索
const keyword = route.query.keyword
if (typeof keyword === 'string' && keyword.trim()) {
filters.keyword = keyword.trim()
}
void loadOrders()
await loadOrders()
restoreScroll()
})
async function loadOrders() {
@@ -325,7 +333,9 @@ function isPlatformManaged(row: Order) {
</el-table-column>
<el-table-column label="号主收入" width="120" align="right">
<template #default="{ row }">
<strong class="owner-income-cell">¥{{ money(amountYuan(row.owner_rent_amount_cent)) }}</strong>
<strong class="owner-income-cell"
>¥{{ money(amountYuan(row.owner_rent_amount_cent)) }}</strong
>
</template>
</el-table-column>
<el-table-column label="创建时间" width="170">