修复前端金额展示并整理依赖

This commit is contained in:
yml
2026-06-09 20:32:17 +08:00
parent 4c2199df58
commit 684e30862d
20 changed files with 129 additions and 194 deletions
@@ -274,7 +274,8 @@ function accountTypeLabel(type: string) {
>
<template #title>
<div style="font-size: 13px">
请手动转账 <strong>¥{{ formatCent(withdrawal.actual_amount_cent) }}</strong> 到用户收款账号
请手动转账
<strong>¥{{ formatCent(withdrawal.actual_amount_cent) }}</strong> 到用户收款账号
完成后点击"确认打款"按钮
</div>
</template>
@@ -2,10 +2,7 @@
import { Search } from '@element-plus/icons-vue'
import { onMounted, reactive, ref } from 'vue'
import {
fetchFinanceDetails,
type FinanceDetail,
} from '@/features/admin/api/adminFinance'
import { fetchFinanceDetails, type FinanceDetail } from '@/features/admin/api/adminFinance'
import { formatCentWithSymbol } from '@/shared/utils/money'
import { orderStatusLabel } from '@/utils/statusLabels'
import { formatDateTime } from '@/utils/time'
@@ -156,7 +153,12 @@ function formatInputDate(date: Date) {
<el-input v-model="filters.user_id" clearable placeholder="租客或号主 ID" />
</el-form-item>
<el-form-item label="订单状态">
<el-select v-model="filters.order_status" clearable placeholder="全部状态" class="full-control">
<el-select
v-model="filters.order_status"
clearable
placeholder="全部状态"
class="full-control"
>
<el-option label="待支付" value="pending_payment" />
<el-option label="使用中" value="renting" />
<el-option label="待结账" value="pending_checkout_confirm" />
@@ -222,9 +224,15 @@ function formatInputDate(date: Date) {
{{ moneyCent(row.refunding_amount_cent) }}
</span>
<span class="amount-text amount-cell">{{ moneyCent(row.channel_net_amount_cent) }}</span>
<span class="amount-text amount-cell">{{ moneyCent(row.checkout_platform_fee_cent) }}</span>
<span class="amount-text amount-cell">{{ moneyCent(row.checkout_owner_income_cent) }}</span>
<span class="amount-text amount-cell">{{ moneyCent(row.owner_wallet_income_amount_cent) }}</span>
<span class="amount-text amount-cell">{{
moneyCent(row.checkout_platform_fee_cent)
}}</span>
<span class="amount-text amount-cell">{{
moneyCent(row.checkout_owner_income_cent)
}}</span>
<span class="amount-text amount-cell">{{
moneyCent(row.owner_wallet_income_amount_cent)
}}</span>
<span
class="amount-text amount-cell"
:class="{ 'amount-danger': Math.abs(row.settlement_diff_amount_cent) >= 5 }"
@@ -647,7 +647,11 @@ function readError(error: unknown, fallback: string) {
<span>KD {{ assetNumberText(item, 'secret_kd') }}</span>
</div>
<div class="queue-footer">
<span>¥{{ formatCent(item.price_cent) }} / ¥{{ formatCent(item.deposit_amount_cent) }}</span>
<span
>¥{{ formatCent(item.price_cent) }} / ¥{{
formatCent(item.deposit_amount_cent)
}}</span
>
<el-tag v-if="isExternalUpload(item)" size="small" type="info">{{
uploaderName(item)
}}</el-tag>
@@ -245,9 +245,9 @@ function formatHandoffRecordType(type: string) {
<div v-if="refundStatus" class="metric-card">
<span>退款状态</span>
<strong>{{ refundStatusLabel(refundStatus.refund_status) }}</strong>
<small v-if="refundStatus.refund_amount_cent > 0"
>{{ moneyCent(refundStatus.refund_amount_cent) }}</small
>
<small v-if="refundStatus.refund_amount_cent > 0">{{
moneyCent(refundStatus.refund_amount_cent)
}}</small>
</div>
</div>
@@ -253,10 +253,18 @@ function jsonText(value: unknown) {
<el-dialog v-model="detailVisible" title="支付流水详情" width="820px">
<div v-if="activePayment" class="payment-detail">
<div class="detail-grid">
<p><span>业务类型</span><strong>{{ bizTypeLabel(activePayment.biz_type) }}</strong></p>
<p><span>状态</span><strong>{{ paymentStatusLabel(activePayment.status) }}</strong></p>
<p><span>金额</span><strong>{{ moneyCent(activePayment.amount_cent) }}</strong></p>
<p><span>渠道</span><strong>{{ activePayment.provider || '-' }}</strong></p>
<p>
<span>业务类型</span><strong>{{ bizTypeLabel(activePayment.biz_type) }}</strong>
</p>
<p>
<span>状态</span><strong>{{ paymentStatusLabel(activePayment.status) }}</strong>
</p>
<p>
<span>金额</span><strong>{{ moneyCent(activePayment.amount_cent) }}</strong>
</p>
<p>
<span>渠道</span><strong>{{ activePayment.provider || '-' }}</strong>
</p>
</div>
<h3>请求参数</h3>
<pre>{{ jsonText(activePayment.raw_request) }}</pre>
@@ -88,7 +88,10 @@ function getCategoryLabel(category: string) {
}
function previewText(content: string) {
const text = content.replace(/[#>*_`[\]()!-]/g, '').replace(/\s+/g, ' ').trim()
const text = content
.replace(/[#>*_`[\]()!-]/g, '')
.replace(/\s+/g, ' ')
.trim()
return text.length > 76 ? `${text.slice(0, 76)}...` : text
}
</script>
@@ -13,14 +13,14 @@ import {
import { fetchPostRentalNotice, type PostRentalNotice } from '@/features/orders/api/orders'
import { formatDateMinute } from '@/utils/time'
import { uploadFile } from '@/shared/api/files'
import { formatCent, formatMoney } from '@/shared/utils/money'
import { formatCent } from '@/shared/utils/money'
const session = useSessionStore()
const router = useRouter()
const route = useRoute()
/** 数据项 */
const balance = ref(0)
const availableBalanceCent = ref(0)
const showSettings = ref(false)
const showProfileEditor = ref(false)
const savingProfile = ref(false)
@@ -101,7 +101,7 @@ onMounted(() => {
async function loadBalance() {
try {
const wallet = await fetchWalletBalance()
balance.value = wallet.available_balance_cent
availableBalanceCent.value = wallet.available_balance_cent
} catch {
// 失败静默处理,显示为默认0
}
@@ -317,7 +317,7 @@ function resolveAvatarURL(url: string | undefined | null) {
<div class="balance-row">
<div class="balance-info">
<span class="balance-label">账户可用余额()</span>
<strong class="balance-value">¥{{ formatMoney(balance) }}</strong>
<strong class="balance-value">¥{{ formatCent(availableBalanceCent) }}</strong>
</div>
<button class="withdraw-btn" @click="handleWithdraw">提现</button>
</div>
@@ -94,7 +94,11 @@ const detailMetrics = computed(() => {
value: dailyLoss ? `${dailyLoss}/天` : '--',
tone: 'coin',
},
{ label: '价格', value: `¥${formatMoney(getListingDisplayPrice(listing.value))}`, tone: 'price' },
{
label: '价格',
value: `¥${formatMoney(getListingDisplayPrice(listing.value))}`,
tone: 'price',
},
{ label: '押金', value: `¥${formatCent(listing.value.deposit_amount_cent)}`, tone: '' },
]
})
+18 -6
View File
@@ -185,7 +185,9 @@ export async function cancelOrder(id: number) {
}
export async function submitHandoff(id: number, content: string) {
const { data } = await apiClient.post<ApiResponse<HandoffRecord>>(`/orders/${id}/handoffs`, { content })
const { data } = await apiClient.post<ApiResponse<HandoffRecord>>(`/orders/${id}/handoffs`, {
content,
})
return data.data
}
@@ -203,7 +205,9 @@ export async function fetchHandoffRecords(id: string | number) {
}
export async function confirmReceive(id: number) {
const { data } = await apiClient.post<ApiResponse<{ confirmed: boolean }>>(`/orders/${id}/receive`)
const { data } = await apiClient.post<ApiResponse<{ confirmed: boolean }>>(
`/orders/${id}/receive`
)
return data.data
}
@@ -248,12 +252,16 @@ export async function confirmCheckout(id: number) {
}
export async function acceptCheckout(id: number) {
const { data } = await apiClient.post<ApiResponse<{ accepted: boolean }>>(`/orders/${id}/checkout/accept`)
const { data } = await apiClient.post<ApiResponse<{ accepted: boolean }>>(
`/orders/${id}/checkout/accept`
)
return data.data
}
export async function rejectCheckout(id: number) {
const { data } = await apiClient.post<ApiResponse<{ rejected: boolean }>>(`/orders/${id}/checkout/reject`)
const { data } = await apiClient.post<ApiResponse<{ rejected: boolean }>>(
`/orders/${id}/checkout/reject`
)
return data.data
}
@@ -288,12 +296,16 @@ export async function adminCloseOrder(id: number, reason: string) {
}
export async function adminMarkOrderAbnormal(id: number, reason: string) {
const { data } = await apiClient.post<ApiResponse<Order>>(`/admin/orders/${id}/abnormal`, { reason })
const { data } = await apiClient.post<ApiResponse<Order>>(`/admin/orders/${id}/abnormal`, {
reason,
})
return data.data
}
export async function adminRefundStatus(id: number) {
const { data } = await apiClient.get<ApiResponse<RefundStatus>>(`/admin/orders/${id}/refund-status`)
const { data } = await apiClient.get<ApiResponse<RefundStatus>>(
`/admin/orders/${id}/refund-status`
)
return data.data
}
@@ -563,10 +563,8 @@ function amountYuan(cent: unknown) {
}
function orderRentAmount(item: Order) {
if (item.owner_id === session.userId)
return amountYuan(item.owner_rent_amount_cent)
if (item.renter_id === session.userId)
return amountYuan(item.rent_amount_cent)
if (item.owner_id === session.userId) return amountYuan(item.owner_rent_amount_cent)
if (item.renter_id === session.userId) return amountYuan(item.rent_amount_cent)
return amountYuan(item.display_amount_cent)
}
@@ -687,12 +685,8 @@ async function copyListingCode() {
</div>
<div class="meta-item">
<span class="meta-label">押金</span>
<strong class="meta-value"
>¥{{ money(amountYuan(order.deposit_amount_cent)) }}</strong
>
<span
v-if="amountYuan(order.deposit_waived_amount_cent) > 0"
class="meta-note"
<strong class="meta-value">¥{{ money(amountYuan(order.deposit_amount_cent)) }}</strong>
<span v-if="amountYuan(order.deposit_waived_amount_cent) > 0" class="meta-note"
>已免押 ¥{{ money(amountYuan(order.deposit_waived_amount_cent)) }}</span
>
</div>
@@ -612,10 +612,8 @@ function amountYuan(cent: unknown) {
}
function orderRentAmount(item: Order) {
if (item.owner_id === session.userId)
return amountYuan(item.owner_rent_amount_cent)
if (item.renter_id === session.userId)
return amountYuan(item.rent_amount_cent)
if (item.owner_id === session.userId) return amountYuan(item.owner_rent_amount_cent)
if (item.renter_id === session.userId) return amountYuan(item.rent_amount_cent)
return amountYuan(item.display_amount_cent)
}
@@ -783,12 +781,8 @@ async function copyListingCode() {
<strong class="metric-value"
>¥{{ money(amountYuan(order.deposit_amount_cent)) }}</strong
>
<span
v-if="amountYuan(order.deposit_waived_amount_cent) > 0"
class="metric-note"
>已免押 ¥{{
money(amountYuan(order.deposit_waived_amount_cent))
}}</span
<span v-if="amountYuan(order.deposit_waived_amount_cent) > 0" class="metric-note"
>已免押 ¥{{ money(amountYuan(order.deposit_waived_amount_cent)) }}</span
>
</div>
</div>
@@ -970,9 +964,7 @@ async function copyListingCode() {
<div class="checkout-summary-card">
<div class="summary-row">
<span>实际结算租金</span>
<strong
>¥{{ money(amountYuan(order.checkout.display_amount_cent)) }}</strong
>
<strong>¥{{ money(amountYuan(order.checkout.display_amount_cent)) }}</strong>
</div>
<div class="summary-row">
<span>预收押金</span>
@@ -580,7 +580,9 @@ function selectDailyLoss(value: string | number) {
</div>
<div class="price-cell">
<span>纯币基础价</span>
<strong>{{ calculatedCoinBasePrice ? `¥${formatMoney(calculatedCoinBasePrice)}` : '--' }}</strong>
<strong>{{
calculatedCoinBasePrice ? `¥${formatMoney(calculatedCoinBasePrice)}` : '--'
}}</strong>
</div>
<div class="price-cell">
<span>额外消耗品</span>
@@ -588,7 +590,9 @@ function selectDailyLoss(value: string | number) {
</div>
<div class="price-cell accent">
<span>发布价格</span>
<strong>{{ calculatedSellerPrice ? `¥${formatMoney(calculatedSellerPrice)}` : '--' }}</strong>
<strong>{{
calculatedSellerPrice ? `¥${formatMoney(calculatedSellerPrice)}` : '--'
}}</strong>
</div>
</div>
@@ -608,13 +612,17 @@ function selectDailyLoss(value: string | number) {
<div class="summary-panel">
<div class="summary-main">
<span>卖家发布价格</span>
<strong>{{ calculatedSellerPrice ? `¥${formatMoney(calculatedSellerPrice)}` : '--' }}</strong>
<strong>{{
calculatedSellerPrice ? `¥${formatMoney(calculatedSellerPrice)}` : '--'
}}</strong>
</div>
<div class="summary-breakdown">
<div class="summary-breakdown-title">价格明细</div>
<div>
<span>纯币价格</span>
<strong>{{ calculatedCoinBasePrice ? `¥${formatMoney(calculatedCoinBasePrice)}` : '--' }}</strong>
<strong>{{
calculatedCoinBasePrice ? `¥${formatMoney(calculatedCoinBasePrice)}` : '--'
}}</strong>
</div>
<div>
<span>额外物品价格</span>
@@ -622,7 +630,9 @@ function selectDailyLoss(value: string | number) {
</div>
<div>
<span>押金价格</span>
<strong>{{ form.deposit_amount === '' ? '--' : `¥${formatMoney(Number(form.deposit_amount))}` }}</strong>
<strong>{{
form.deposit_amount === '' ? '--' : `¥${formatMoney(Number(form.deposit_amount))}`
}}</strong>
</div>
</div>
<div class="summary-list">
@@ -9,7 +9,7 @@ import {
submitListingReview,
type Listing,
} from '@/features/listings'
import { formatCent, formatMoney, formatMoneyWithSymbol } from '@/shared/utils/money'
import { formatCent, formatMoneyWithSymbol } from '@/shared/utils/money'
import { listingReviewStatusLabel, listingStatusLabel } from '@/utils/statusLabels'
import { formatListingCode, getListingSellerPrice } from '@/utils/listingDisplay'
+3 -1
View File
@@ -44,7 +44,9 @@ export async function fetchWalletLedger(page = 1, pageSize = 20) {
export async function rechargeWallet(amountYuan: number) {
const amount_cent = yuanToCent(amountYuan)
const { data } = await apiClient.post<ApiResponse<WalletAccount>>('/wallet/recharge', { amount_cent })
const { data } = await apiClient.post<ApiResponse<WalletAccount>>('/wallet/recharge', {
amount_cent,
})
return data.data
}
-1
View File
@@ -2,4 +2,3 @@
export * from './api/wallet'
export * from './api/withdrawal'
export * from './composables/useWallet'
export type * from './types'
-18
View File
@@ -1,18 +0,0 @@
// Wallet 模块类型定义
export interface WalletBalance {
balance: number
frozenBalance: number
}
export interface WalletTransaction {
id: number
type: string
amount: number
balance: number
description: string
createdAt: string
}
export interface RechargeRequest {
amount: number
}
@@ -276,7 +276,9 @@ function amountPrefix(direction: string) {
</div>
<div class="wallet-hero-action">
<span>当前可用</span>
<strong>{{ account ? formatCentWithSymbol(account.available_balance_cent) : '¥0.0' }}</strong>
<strong>{{
account ? formatCentWithSymbol(account.available_balance_cent) : '¥0.0'
}}</strong>
<el-button class="withdraw-button" :icon="Money" type="primary" @click="handleWithdraw">
申请提现
</el-button>
@@ -377,7 +379,9 @@ function amountPrefix(direction: string) {
{{ amountPrefix(row.direction) }}{{ formatCentWithSymbol(row.amount_cent) }}
</span>
<span class="ledger-cell muted-cell">{{ balanceTypeLabel(row.balance_type) }}</span>
<span class="ledger-cell align-right">{{ formatCentWithSymbol(row.balance_after_cent) }}</span>
<span class="ledger-cell align-right">{{
formatCentWithSymbol(row.balance_after_cent)
}}</span>
<span class="ledger-cell" :title="row.remark">{{ row.remark || '-' }}</span>
<span class="ledger-cell">{{ formatDateTime(row.created_at) }}</span>
</div>
@@ -186,9 +186,7 @@ function accountTypeLabel(type: string) {
<el-icon><Money /></el-icon>
冻结余额
</div>
<div class="balance-value frozen">
¥{{ formatCent(account?.frozen_balance_cent) }}
</div>
<div class="balance-value frozen">¥{{ formatCent(account?.frozen_balance_cent) }}</div>
</div>
</div>
</el-card>
@@ -261,7 +259,9 @@ function accountTypeLabel(type: string) {
<el-alert
v-if="
withdrawForm.amount > 0 && account && yuanToCent(withdrawForm.amount) > account.available_balance_cent
withdrawForm.amount > 0 &&
account &&
yuanToCent(withdrawForm.amount) > account.available_balance_cent
"
type="error"
:closable="false"
@@ -312,7 +312,9 @@ function accountTypeLabel(type: string) {
<el-table-column prop="withdraw_no" label="提现单号" min-width="180" />
<el-table-column label="提现金额" width="120">
<template #default="{ row }">
<span style="color: #f56c6c; font-weight: 600"> ¥{{ formatCent(row.amount_cent) }} </span>
<span style="color: #f56c6c; font-weight: 600">
¥{{ formatCent(row.amount_cent) }}
</span>
</template>
</el-table-column>
<el-table-column label="收款方式" width="150">