优化按件拼单自动计算
This commit is contained in:
@@ -106,10 +106,16 @@ export default function ProductRulesPanel() {
|
||||
rewardAmount: rule.rewardAmount / 100,
|
||||
unitPrice: rule.unitPriceFen / 100,
|
||||
sharingEnabled: rule.sharing?.enabled || false,
|
||||
sharingTotalQuantity: rule.sharing?.totalQuantity || 1,
|
||||
sharingUnitReward: (rule.sharing?.unitReward || 0) / 100,
|
||||
sharingTotalAmount:
|
||||
((rule.sharing?.totalQuantity || 1) * (rule.sharing?.unitReward || 0)) / 100,
|
||||
sharingAutoFromOrder: rule.sharing?.autoFromOrder || false,
|
||||
sharingTotalQuantity: rule.sharing?.autoFromOrder
|
||||
? undefined
|
||||
: rule.sharing?.totalQuantity || 1,
|
||||
sharingUnitReward: rule.sharing?.autoFromOrder
|
||||
? undefined
|
||||
: (rule.sharing?.unitReward || 0) / 100,
|
||||
sharingTotalAmount: rule.sharing?.autoFromOrder
|
||||
? undefined
|
||||
: ((rule.sharing?.totalQuantity || 1) * (rule.sharing?.unitReward || 0)) / 100,
|
||||
timeoutMinutes: rule.timeoutMinutes || 0,
|
||||
timeoutPolicy: rule.timeoutPolicy || 'reopen',
|
||||
fieldsText: formatRuleFields(rule.requirement?.fields || []),
|
||||
@@ -142,6 +148,7 @@ export default function ProductRulesPanel() {
|
||||
pricingMode?: string
|
||||
unitPrice?: number
|
||||
sharingEnabled?: boolean
|
||||
sharingAutoFromOrder?: boolean
|
||||
sharingTotalQuantity?: number
|
||||
sharingUnitReward?: number
|
||||
sharingTotalAmount?: number
|
||||
@@ -154,6 +161,8 @@ export default function ProductRulesPanel() {
|
||||
}) {
|
||||
try {
|
||||
const unitMode = values.pricingMode === 'unit'
|
||||
const hasManualSharingOverride =
|
||||
Number(values.sharingTotalQuantity || 0) > 0 || Number(values.sharingUnitReward || 0) > 0
|
||||
const { pricingMode: _pricingMode, ...payload } = values
|
||||
await saveAdminWorkProductRule({
|
||||
...payload,
|
||||
@@ -161,6 +170,8 @@ export default function ProductRulesPanel() {
|
||||
ruleKey: editingRule?.ruleKey || '',
|
||||
match: editingRule?.match,
|
||||
unitPrice: unitMode ? Number(values.unitPrice || 0) : 0,
|
||||
sharingAutoFromOrder:
|
||||
unitMode && values.sharingEnabled === true && !hasManualSharingOverride,
|
||||
})
|
||||
message.success(editingRule ? '接单模板已更新' : '接单模板已创建')
|
||||
resetRuleForm()
|
||||
@@ -193,10 +204,16 @@ export default function ProductRulesPanel() {
|
||||
rewardAmount: rule.rewardAmount / 100,
|
||||
unitPrice: rule.unitPriceFen / 100,
|
||||
sharingEnabled: rule.sharing?.enabled || false,
|
||||
sharingTotalQuantity: rule.sharing?.totalQuantity || 1,
|
||||
sharingUnitReward: (rule.sharing?.unitReward || 0) / 100,
|
||||
sharingTotalAmount:
|
||||
((rule.sharing?.totalQuantity || 1) * (rule.sharing?.unitReward || 0)) / 100,
|
||||
sharingAutoFromOrder: rule.sharing?.autoFromOrder || false,
|
||||
sharingTotalQuantity: rule.sharing?.autoFromOrder
|
||||
? undefined
|
||||
: rule.sharing?.totalQuantity || 1,
|
||||
sharingUnitReward: rule.sharing?.autoFromOrder
|
||||
? undefined
|
||||
: (rule.sharing?.unitReward || 0) / 100,
|
||||
sharingTotalAmount: rule.sharing?.autoFromOrder
|
||||
? undefined
|
||||
: ((rule.sharing?.totalQuantity || 1) * (rule.sharing?.unitReward || 0)) / 100,
|
||||
timeoutMinutes: rule.timeoutMinutes || 0,
|
||||
timeoutPolicy: rule.timeoutPolicy || 'reopen',
|
||||
fieldsText: formatRuleFields(rule.requirement?.fields || []),
|
||||
@@ -340,7 +357,7 @@ export default function ProductRulesPanel() {
|
||||
render: (_, row) => (
|
||||
<div className="cell-stack">
|
||||
<Typography.Text strong style={{ color: '#3f8600', fontSize: 13 }}>
|
||||
{formatMoney(row.rewardAmount)}
|
||||
{row.sharing?.autoFromOrder ? '随订单自动计算' : formatMoney(row.rewardAmount)}
|
||||
</Typography.Text>
|
||||
{row.unitPriceFen > 0 ? (
|
||||
<Typography.Text type="secondary" style={{ fontSize: 11 }}>
|
||||
@@ -461,11 +478,8 @@ export default function ProductRulesPanel() {
|
||||
pricingMode: 'fixed',
|
||||
rewardAmount: 25,
|
||||
enabled: true,
|
||||
autoCreate: false,
|
||||
autoCreate: true,
|
||||
sharingEnabled: false,
|
||||
sharingTotalQuantity: 10,
|
||||
sharingUnitReward: 5,
|
||||
sharingTotalAmount: 50,
|
||||
fieldsText:
|
||||
'gameId:游戏编号\ngameNickname:游戏昵称\nsystem:系统#安卓,苹果\nserverZone:区服#QQ区,微信区',
|
||||
}}
|
||||
@@ -563,8 +577,28 @@ export default function ProductRulesPanel() {
|
||||
</div>
|
||||
|
||||
<Form.Item noStyle shouldUpdate>
|
||||
{({ getFieldValue }) =>
|
||||
getFieldValue('sharingEnabled') ? (
|
||||
{({ getFieldValue }) => {
|
||||
const sharingEnabled = getFieldValue('sharingEnabled')
|
||||
const unitMode = getFieldValue('pricingMode') === 'unit'
|
||||
if (!sharingEnabled) return null
|
||||
|
||||
if (unitMode) {
|
||||
return (
|
||||
<div className="sharing-box-inline">
|
||||
<Typography.Text type="secondary" className="span-2">
|
||||
默认按匹配 SKU 数量和上方单价自动生成拼单;填写以下两项后改为固定配置。
|
||||
</Typography.Text>
|
||||
<Form.Item label="拼单数量(可选)" name="sharingTotalQuantity">
|
||||
<InputNumber min={1} max={100000} addonAfter="份" className="full-width" />
|
||||
</Form.Item>
|
||||
<Form.Item label="拼单单价(可选)" name="sharingUnitReward">
|
||||
<InputNumber min={0.01} step={1} addonAfter="元" className="full-width" />
|
||||
</Form.Item>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="sharing-box-inline">
|
||||
<Form.Item
|
||||
label="拼单数量"
|
||||
@@ -612,8 +646,8 @@ export default function ProductRulesPanel() {
|
||||
/>
|
||||
</Form.Item>
|
||||
</div>
|
||||
) : null
|
||||
}
|
||||
)
|
||||
}}
|
||||
</Form.Item>
|
||||
|
||||
{/* 资料字段: 默认展开 4 行全部清晰可见,无内嵌滚动条 */}
|
||||
|
||||
Reference in New Issue
Block a user