fix(consignment): 售价与差价分两行展示,避免差价被折断
This commit is contained in:
@@ -3,10 +3,12 @@ import { Typography } from 'antd'
|
||||
import { formatFenMoney, resolvePaymentPriceDiff } from '@/utils/consignment-payment-price-diff'
|
||||
|
||||
/**
|
||||
* 寄售售价 + 差价:`¥110.00(+¥20.00)`。
|
||||
* 寄售售价 + 差价:售价一行,差价另起一行。
|
||||
*
|
||||
* 差价 = 工单用户付款金额 - 售价;正数绿、负数红、0 黄。
|
||||
* 拼单(多份售价)或用户付款未知时不显示括号。
|
||||
* 表格列宽由 PercentTable 归一化成百分比,单行放不下时浏览器会把「(+¥」拆开,
|
||||
* 因此这里显式分成两行,并禁止差价折行。
|
||||
* 拼单(多份售价)或用户付款未知时不显示差价。
|
||||
*/
|
||||
export default function ConsignmentPriceWithDiff({
|
||||
userPaymentFen,
|
||||
@@ -19,9 +21,19 @@ export default function ConsignmentPriceWithDiff({
|
||||
}) {
|
||||
const diff = resolvePaymentPriceDiff(userPaymentFen, salePriceFen, { sharingEnabled })
|
||||
return (
|
||||
<Typography.Text style={{ fontSize: 13 }}>
|
||||
{formatFenMoney(salePriceFen)}
|
||||
{diff ? <span style={{ color: diff.color }}>({diff.text})</span> : null}
|
||||
<Typography.Text
|
||||
style={{
|
||||
fontSize: 13,
|
||||
display: 'inline-flex',
|
||||
flexDirection: 'column',
|
||||
alignItems: 'flex-start',
|
||||
lineHeight: 1.45,
|
||||
}}
|
||||
>
|
||||
<span style={{ whiteSpace: 'nowrap' }}>{formatFenMoney(salePriceFen)}</span>
|
||||
{diff ? (
|
||||
<span style={{ color: diff.color, fontSize: 12, whiteSpace: 'nowrap' }}>{diff.text}</span>
|
||||
) : null}
|
||||
</Typography.Text>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
import assert from 'node:assert/strict'
|
||||
import { readFile } from 'node:fs/promises'
|
||||
import test from 'node:test'
|
||||
|
||||
test('售价与差价分两行展示,差价完整不折行', async () => {
|
||||
const source = await readFile(
|
||||
new URL('../src/components/admin/ConsignmentPriceWithDiff.tsx', import.meta.url),
|
||||
'utf8',
|
||||
)
|
||||
|
||||
// PercentTable 会把列宽归一化成百分比,单行放不下时会把「(+¥」拆开,必须显式分行。
|
||||
assert.ok(source.includes("flexDirection: 'column'"), '售价与差价必须垂直排列')
|
||||
assert.ok(source.includes("whiteSpace: 'nowrap'"), '售价与差价都必须禁止折行')
|
||||
assert.ok(source.includes('fontSize: 12'), '差价字号应小于售价')
|
||||
assert.ok(!source.includes('({diff.text})'), '差价不再使用全角括号包裹')
|
||||
})
|
||||
Reference in New Issue
Block a user