优化金额显示等
This commit is contained in:
@@ -5,8 +5,7 @@ import { Empty, Popup } from '@antmjs/vantui'
|
||||
import { getBillDetailApi } from '@/services/bill'
|
||||
import { getOrderDetailApi } from '@/services/order'
|
||||
import { ORDER_STATUS_TEXT } from '@/types/order'
|
||||
import { formatSpec, resolveFileUrl } from '@/utils/format'
|
||||
import PriceText from '@/components/PriceText'
|
||||
import {formatRetailPrice, formatSpec, resolveFileUrl} from '@/utils/format'
|
||||
import type { OrderDetail } from '@/types/order'
|
||||
import type { BillDetail } from '@/services/bill'
|
||||
import './index.less'
|
||||
@@ -60,18 +59,9 @@ export default function BillDetailPage() {
|
||||
|
||||
const { bill, items, orders } = detail
|
||||
|
||||
/** 附加金额:正=压筐附加,负=回筐抵扣(0 不带头符号) */
|
||||
const addedNum = Number(bill.added_amount)
|
||||
const addedLabel = addedNum < 0 ? '回筐抵扣' : '压筐附加'
|
||||
const addedText =
|
||||
addedNum < 0
|
||||
? `-¥${Math.abs(addedNum).toFixed(2)}`
|
||||
: addedNum > 0
|
||||
? `+¥${addedNum.toFixed(2)}`
|
||||
: '¥0.00'
|
||||
/** 筐/托盘明细:正压负回,数量取绝对值(单价为出账时快照) */
|
||||
const boxPart = `${bill.box_num < 0 ? '回筐' : '压筐'} ${Math.abs(bill.box_num)}×¥${bill.box_price}`
|
||||
const trayPart = `${bill.tray_num < 0 ? '回托盘' : '压托盘'} ${Math.abs(bill.tray_num)}×¥${bill.tray_price}`
|
||||
const boxTotalPrice = (Number(bill.box_price) * bill.box_num).toFixed(2)
|
||||
const trayTotalPrice = (Number(bill.tray_price) * bill.tray_num).toFixed(2)
|
||||
|
||||
return (
|
||||
<View className={`bill-detail ${bill.can_pay ? 'bill-detail--pay' : ''}`}>
|
||||
@@ -124,7 +114,7 @@ export default function BillDetailPage() {
|
||||
|
||||
{/* ===== 金额构成 ===== */}
|
||||
<View className='bill-card'>
|
||||
<Text className='bill-section__title'>金额构成</Text>
|
||||
<Text className='bill-section__title'>金额明细</Text>
|
||||
<View className='bill-card__row'>
|
||||
<Text className='bill-card__label'>商品金额</Text>
|
||||
<Text className='bill-card__value'>¥{bill.product_amount}</Text>
|
||||
@@ -134,9 +124,21 @@ export default function BillDetailPage() {
|
||||
<Text className='bill-card__value'>¥{bill.delivery_fee}</Text>
|
||||
</View>
|
||||
<View className='bill-card__row'>
|
||||
<Text className='bill-card__label'>{addedLabel}({boxPart},{trayPart})</Text>
|
||||
<Text className={`bill-card__value ${addedNum < 0 ? 'bill-card__value--return' : ''}`}>
|
||||
{addedText}
|
||||
<Text className='bill-card__label'>周转筐({bill.box_price} × {bill.box_num})</Text>
|
||||
<Text className={`bill-card__value ${Number(boxTotalPrice) < 0 ? 'bill-card__value--return' : ''}`}>
|
||||
{Number(boxTotalPrice) < 0 ? `- ¥${boxTotalPrice}` : `¥${boxTotalPrice}`}
|
||||
</Text>
|
||||
</View>
|
||||
<View className='bill-card__row'>
|
||||
<Text className='bill-card__label'>周转托盘({bill.tray_price} × {bill.tray_num})</Text>
|
||||
<Text className={`bill-card__value ${Number(trayTotalPrice) < 0 ? 'bill-card__value--return' : ''}`}>
|
||||
{Number(trayTotalPrice) < 0 ? `- ¥${trayTotalPrice}` : `¥${trayTotalPrice}`}
|
||||
</Text>
|
||||
</View>
|
||||
<View className='bill-card__row'>
|
||||
<Text className='bill-card__label'>售后</Text>
|
||||
<Text className={`bill-card__value ${Number(bill.after_sale) < 0 ? 'bill-card__value--return' : ''}`}>
|
||||
{Number(bill.after_sale) < 0 ? `- ¥${bill.after_sale}` : `¥${bill.after_sale}`}
|
||||
</Text>
|
||||
</View>
|
||||
<View className='bill-card__row bill-card__row--total'>
|
||||
@@ -148,7 +150,6 @@ export default function BillDetailPage() {
|
||||
{/* ===== 商品明细(跨订单按商品合并) ===== */}
|
||||
<View className='bill-card'>
|
||||
<Text className='bill-section__title'>商品明细({items?.length ?? 0})</Text>
|
||||
<Text className='bill-section__desc'>同一商品跨订单合并,单价为加权平均价</Text>
|
||||
{(items ?? []).map(item => (
|
||||
<View key={item.product_id} className='bill-goods'>
|
||||
{!!item.image && (
|
||||
@@ -162,13 +163,11 @@ export default function BillDetailPage() {
|
||||
<View className='bill-goods__main'>
|
||||
<Text className='bill-goods__name'>{item.product_name}</Text>
|
||||
<Text className='bill-goods__spec'>
|
||||
{formatSpec(item.product_spec, item.unit)}{' '}
|
||||
<PriceText price={item.price} spec={item.product_spec} />
|
||||
{formatSpec(item.product_spec, item.unit)}{' ¥'}{item.price}
|
||||
</Text>
|
||||
</View>
|
||||
<View className='bill-goods__side'>
|
||||
<Text className='bill-goods__qty'>×{item.quantity}</Text>
|
||||
<Text className='bill-goods__amount'>¥{item.amount}</Text>
|
||||
<Text className='bill-goods__amount'>¥{item.price} × {item.quantity}</Text>
|
||||
</View>
|
||||
</View>
|
||||
))}
|
||||
@@ -216,11 +215,11 @@ export default function BillDetailPage() {
|
||||
<View className='order-popup__item-info'>
|
||||
<Text className='order-popup__item-name'>{item.product_name}</Text>
|
||||
<Text className='order-popup__item-spec'>
|
||||
{formatSpec(item.product_spec, item.unit)}{' '}
|
||||
<PriceText price={item.price} spec={item.product_spec} /> × {item.quantity}
|
||||
{formatSpec(item.product_spec, item.unit)}{' '}
|
||||
单价:{formatRetailPrice(item.price, item.product_spec)} {item.price_unit}
|
||||
</Text>
|
||||
</View>
|
||||
<Text className='order-popup__item-amount'>¥{item.amount}</Text>
|
||||
<Text className='order-popup__item-amount'>¥{item.price} × {item.quantity}</Text>
|
||||
</View>
|
||||
))}
|
||||
</ScrollView>
|
||||
|
||||
Reference in New Issue
Block a user