feat(cost-center): 成本项编码改系统自动生成,补自动发货价格导入脚本
- 新建成本项目不再手填编码:后端按成本类型生成基础编码(auto_purchase / work_order_reward / manual_service / platform_fee / payment_fee / after_sales_loss / shipping_other / other_cost),重复时追加 _2、_3; 接口显式传 code 时仍优先使用,兼容脚本导入 - 前端移除编码输入框,改为说明提示,创建成功提示展示生成的编码 - 新增 scripts/sync-affiliate-dash-prices.ts + scripts/data/affiliate-dash-prices.json: 按上游 38 条自动发货价格补建 aff:<sku> 商品,并按 cost_amount(分)生成 scope=product 的按件成本版本;价格变化时停用旧版本再插新版本 - 自动发货商品同步与价格导入的 attributes_json 改为合并,避免互相覆盖
This commit is contained in:
@@ -110,7 +110,6 @@ type MappingFormValues = {
|
||||
}
|
||||
|
||||
type CostItemFormValues = {
|
||||
code: string
|
||||
name: string
|
||||
costType: CostItem['costType']
|
||||
carrierType: CostItem['carrierType']
|
||||
@@ -208,7 +207,6 @@ function tabKeysForCarrier(carrier: CarrierScope) {
|
||||
type CostItemPreset = {
|
||||
key: string
|
||||
label: string
|
||||
code: string
|
||||
name: string
|
||||
costType: CostItem['costType']
|
||||
carrierType: CostCarrierType
|
||||
@@ -221,7 +219,6 @@ const COST_ITEM_PRESETS: CostItemPreset[] = [
|
||||
{
|
||||
key: 'auto_purchase',
|
||||
label: '自动发货采购成本',
|
||||
code: 'auto_purchase',
|
||||
name: '自动发货采购成本',
|
||||
costType: 'auto_purchase',
|
||||
carrierType: 'affiliate_dash',
|
||||
@@ -231,7 +228,6 @@ const COST_ITEM_PRESETS: CostItemPreset[] = [
|
||||
{
|
||||
key: 'work_order_reward',
|
||||
label: '接单平台打手报酬',
|
||||
code: 'work_order_reward',
|
||||
name: '接单平台打手报酬',
|
||||
costType: 'work_order_reward',
|
||||
carrierType: 'work_order',
|
||||
@@ -241,7 +237,6 @@ const COST_ITEM_PRESETS: CostItemPreset[] = [
|
||||
{
|
||||
key: 'manual_service',
|
||||
label: '人工客服成本',
|
||||
code: 'manual_service',
|
||||
name: '人工客服成本',
|
||||
costType: 'manual_service',
|
||||
carrierType: 'manual',
|
||||
@@ -251,7 +246,6 @@ const COST_ITEM_PRESETS: CostItemPreset[] = [
|
||||
{
|
||||
key: 'platform_fee',
|
||||
label: '平台服务费',
|
||||
code: 'platform_fee',
|
||||
name: '平台服务费',
|
||||
costType: 'platform_fee',
|
||||
carrierType: 'shared',
|
||||
@@ -261,7 +255,6 @@ const COST_ITEM_PRESETS: CostItemPreset[] = [
|
||||
{
|
||||
key: 'payment_fee',
|
||||
label: '支付通道费',
|
||||
code: 'payment_fee',
|
||||
name: '支付通道费',
|
||||
costType: 'payment_fee',
|
||||
carrierType: 'shared',
|
||||
@@ -271,7 +264,6 @@ const COST_ITEM_PRESETS: CostItemPreset[] = [
|
||||
{
|
||||
key: 'after_sales_loss',
|
||||
label: '售后损失',
|
||||
code: 'after_sales_loss',
|
||||
name: '售后损失',
|
||||
costType: 'after_sales_loss',
|
||||
carrierType: 'shared',
|
||||
@@ -781,7 +773,6 @@ export default function AdminCostCenterPage() {
|
||||
costItemForm.resetFields()
|
||||
if (preset) {
|
||||
costItemForm.setFieldsValue({
|
||||
code: preset.code,
|
||||
name: preset.name,
|
||||
costType: preset.costType,
|
||||
carrierType: preset.carrierType,
|
||||
@@ -815,7 +806,6 @@ export default function AdminCostCenterPage() {
|
||||
function openEditCostItem(item: CostItem) {
|
||||
setEditingCostItem(item)
|
||||
costItemForm.setFieldsValue({
|
||||
code: item.code,
|
||||
name: item.name,
|
||||
costType: item.costType,
|
||||
carrierType: item.carrierType,
|
||||
@@ -841,8 +831,8 @@ export default function AdminCostCenterPage() {
|
||||
})
|
||||
message.success('成本项目已更新')
|
||||
} else {
|
||||
await createAdminCostItem(values)
|
||||
message.success('成本项目已创建')
|
||||
const created = await createAdminCostItem(values)
|
||||
message.success(`成本项目已创建(编码 ${created.data.costItem.code})`)
|
||||
}
|
||||
setCostItemModalOpen(false)
|
||||
refreshAll()
|
||||
@@ -2596,14 +2586,12 @@ export default function AdminCostCenterPage() {
|
||||
destroyOnClose
|
||||
>
|
||||
<Form form={costItemForm} layout="vertical" onFinish={submitCostItem}>
|
||||
<Form.Item
|
||||
name="code"
|
||||
label="编码"
|
||||
rules={[{ required: true, message: '请输入编码' }]}
|
||||
extra="建议英文小写 + 下划线,例如 auto_purchase、work_order_reward;创建后不可修改。"
|
||||
>
|
||||
<Input placeholder="例如:work_order_reward" disabled={Boolean(editingCostItem)} />
|
||||
</Form.Item>
|
||||
<Alert
|
||||
type="info"
|
||||
showIcon
|
||||
style={{ marginBottom: 12 }}
|
||||
message="编码由系统自动生成(按成本类型 + 序号),无需填写;创建后不可修改。"
|
||||
/>
|
||||
<Form.Item name="name" label="名称" rules={[{ required: true, message: '请输入名称' }]}>
|
||||
<Input placeholder="例如:接单平台打手报酬" />
|
||||
</Form.Item>
|
||||
|
||||
Reference in New Issue
Block a user