新增接单模板价格同步

This commit is contained in:
yml2213
2026-08-20 20:24:00 +08:00
parent 6539e0fb21
commit e05a6797a3
9 changed files with 437 additions and 3 deletions
@@ -15,6 +15,7 @@ import {
Form,
Input,
InputNumber,
Modal,
Popconfirm,
Radio,
Select,
@@ -38,6 +39,7 @@ import {
fetchAdminWorkProductRules,
reprocessAdminKuaishouWorkOrderMatches,
saveAdminWorkProductRule,
syncAdminWorkProductRulePrice,
} from '@/services/admin'
import type { CollectField, WorkProductRule, WorkProductRuleMapping } from '@/types/worker-platform'
import type { AdminKuaishouIndustryShopOption } from '@/types/admin'
@@ -54,6 +56,7 @@ export default function ProductRulesPanel() {
const hasInitializedRuleSelection = useRef(false)
const [editingRule, setEditingRule] = useState<WorkProductRule | null>(null)
const [syncingPrice, setSyncingPrice] = useState(false)
const [activeMappingId, setActiveMappingId] = useState<number | 'new' | null>(null)
const [sourcePrefill, setSourcePrefill] = useState<SourcePrefill | null>(null)
@@ -282,6 +285,36 @@ export default function ProductRulesPanel() {
}
}
function confirmSyncRulePrice() {
if (!editingRule) return
Modal.confirm({
title: '同步模板价格',
content:
'将同步接单大厅中该模板的待抢单价格。部分拼单仅调整剩余份额价格,已加入份额报酬保持不变。',
okText: '确认同步',
cancelText: '取消',
onOk: async () => {
setSyncingPrice(true)
try {
const response = await syncAdminWorkProductRulePrice(editingRule.ruleId)
const result = response.data
message.success(
`已同步 ${result.updatedCount} 单:待抢单 ${result.updatedNormalCount} 单,部分拼单 ${result.updatedPartialSharingCount}`,
)
await Promise.all([
queryClient.invalidateQueries({ queryKey: ['admin-worker-platform-product-rules'] }),
queryClient.invalidateQueries({ queryKey: ['admin-worker-platform-orders'] }),
])
} catch (error) {
message.error(error instanceof Error ? error.message : '同步价格失败')
throw error
} finally {
setSyncingPrice(false)
}
},
})
}
async function toggleRuleEnabled(rule: WorkProductRule, enabled: boolean) {
try {
const hasManualSharingOverride = hasManualSharingInput(
@@ -668,6 +701,11 @@ export default function ProductRulesPanel() {
+
</Button>
) : null}
{editingRule ? (
<Button loading={syncingPrice} size="middle" onClick={confirmSyncRulePrice}>
</Button>
) : null}
<Button type="primary" size="middle" htmlType="submit" form="product-rule-form">
{editingRule ? '保存模板' : '创建模板'}
</Button>