refactor: 拼多多发布编辑页按基础信息/规格库存/服务承诺分区

This commit is contained in:
2026-10-19 14:13:30 +08:00
parent f2556c58cc
commit 26f438eb6a
2 changed files with 328 additions and 278 deletions
@@ -450,292 +450,303 @@ function onSkuTableWrapRef(el: HTMLElement | null) {
</Teleport>
<div
class="min-h-0 flex-1 space-y-4 overflow-y-auto overscroll-y-contain px-4 py-3"
class="publish-editor-sections min-h-0 flex-1 overflow-y-auto overscroll-y-contain px-4 py-4"
>
<div
data-agent-field="goodsName"
:class="{ 'agent-typing-field': agentTypingField === 'goodsName' }"
>
<Form.Item label="商品标题" required>
<Input v-model:value="form.goodsName" :maxlength="60" show-count />
</Form.Item>
</div>
<div
data-agent-field="goodsDesc"
:class="{ 'agent-typing-field': agentTypingField === 'goodsDesc' }"
>
<Form.Item label="商品描述">
<Input.TextArea
v-model:value="form.goodsDesc"
:rows="2"
placeholder="可选,20-500 字"
/>
</Form.Item>
</div>
<Form.Item label="运费模板" required>
<Select
v-model:value="form.costTemplateId"
class="w-full"
:options="logisticsOptions"
placeholder="选择运费模板"
show-search
option-filter-prop="label"
:disabled="!form.pddShopId"
allow-clear
@change="(v: any) => loadCostTemplateDetail(v)"
/>
</Form.Item>
<Card
v-if="form.costTemplateId || costTemplateDetailLoading"
size="small"
class="mb-3"
title="运费模板详情"
>
<Spin :spinning="costTemplateDetailLoading">
<template v-if="costTemplateDetail">
<Descriptions bordered size="small" :column="2" class="mb-3">
<Descriptions.Item label="模板名称">
{{ costTemplateDetail.templateName || '-' }}
</Descriptions.Item>
<Descriptions.Item label="计费方式">
{{ costTemplateDetail.costTypeLabel || '-' }}
</Descriptions.Item>
<Descriptions.Item label="增值服务">
{{ costTemplateDetail.additionalServiceLabel || '-' }}
</Descriptions.Item>
<Descriptions.Item label="其它">
<Space :size="4" wrap>
<Tag v-if="costTemplateDetail.sfFree" color="success">
顺丰包邮
</Tag>
<Tag
v-if="costTemplateDetail.freeDeliverHouse"
color="processing"
>
包邮区送货上门
</Tag>
<span
v-if="
!costTemplateDetail.sfFree &&
!costTemplateDetail.freeDeliverHouse
"
>
-
</span>
</Space>
</Descriptions.Item>
<Descriptions.Item label="包邮省份" :span="2">
<div
v-if="costTemplateDetail.freeProvinces?.length"
class="free-province-tags"
>
<Tag
v-for="(p, idx) in costTemplateDetail.freeProvinces"
:key="`${p.provinceId}-${idx}`"
>
{{ p.province || p.provinceId }}
</Tag>
</div>
<span v-else>暂无</span>
</Descriptions.Item>
<Descriptions.Item
v-if="costTemplateDetail.freeDeliverHouseAreas?.length"
label="送货上门地区"
:span="2"
>
{{
costTemplateDetail.freeDeliverHouseAreas
.map((a) => a.areaText)
.filter(Boolean)
.join('、') || '-'
}}
</Descriptions.Item>
</Descriptions>
<Table
v-if="costTemplateDetail.paidRegions?.length"
size="small"
:pagination="false"
:data-source="costTemplateDetail.paidRegions"
:row-key="(_: any, i?: number) => `paid-${i ?? 0}`"
:columns="[
{ title: '买家付邮地区', dataIndex: 'provincesText' },
{ title: '首费规则', key: 'first', width: 160 },
{ title: '续费规则', key: 'add', width: 160 },
{ title: '条件包邮', dataIndex: 'freeRuleText', width: 160 },
]"
>
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'first'">
首{{ record.firstStandard ?? '-'
}}{{ costTemplateDetail?.costType === 1 ? 'kg' : '件' }}
/ {{ record.firstCostYuan ?? '-' }}元
</template>
<template v-else-if="column.key === 'add'">
续{{ record.addStandard ?? '-'
}}{{ costTemplateDetail?.costType === 1 ? 'kg' : '件' }}
/ {{ record.addCostYuan ?? '-' }}元
</template>
</template>
</Table>
</template>
<Empty
v-else-if="!costTemplateDetailLoading"
description="暂无模板详情"
:image="Empty.PRESENTED_IMAGE_SIMPLE"
/>
</Spin>
</Card>
<div class="grid grid-cols-2 gap-3">
<Form.Item label="参考价(元)" required>
<InputNumber
v-model:value="form.marketPriceYuan"
class="w-full"
:min="0.01"
:precision="2"
/>
</Form.Item>
<Form.Item label="发货时限" required>
<Select
v-model:value="form.shipmentLimitSecond"
class="w-full"
:options="[
{ label: '24小时', value: 86400 },
{ label: '48小时', value: 172800 },
]"
/>
</Form.Item>
<Form.Item label="满两件折扣" required>
<InputNumber
v-model:value="form.twoPiecesDiscount"
class="w-full"
:min="0"
:max="10"
:precision="1"
:step="0.1"
placeholder="9.5 表示 9.5 折,0 取消"
/>
</Form.Item>
</div>
<div class="flex flex-wrap gap-6">
<Form.Item label="假一赔十" required>
<Switch v-model:checked="form.isFolt" />
</Form.Item>
<Form.Item label="7天无理由" required>
<Switch v-model:checked="form.isRefundable" />
</Form.Item>
<Form.Item label="预售" required>
<Switch v-model:checked="form.isPreSale" />
</Form.Item>
<Form.Item label="二手" required>
<Switch v-model:checked="form.secondHand" />
</Form.Item>
</div>
<template v-if="nonSaleProps.length">
<div class="mb-1 text-sm font-medium">类目属性</div>
<div class="grid grid-cols-2 gap-3">
<Form.Item
v-for="p in nonSaleProps"
:key="String(p.refPid)"
:label="p.name"
:required="!!p.required"
>
<CatPropertyField
v-model:value="form.goodsPropValues[String(p.refPid)]"
v-model:unit="form.goodsPropUnits[String(p.refPid)]"
:property="p"
<Card size="small" class="publish-editor-section" title="基础信息">
<div
data-agent-field="goodsName"
:class="{ 'agent-typing-field': agentTypingField === 'goodsName' }"
>
<Form.Item label="商品标题" required>
<Input v-model:value="form.goodsName" :maxlength="60" show-count />
</Form.Item>
</div>
<div
data-agent-field="goodsDesc"
:class="{ 'agent-typing-field': agentTypingField === 'goodsDesc' }"
>
<Form.Item label="商品描述">
<Input.TextArea
v-model:value="form.goodsDesc"
:rows="2"
placeholder="可选,20-500 字"
/>
</Form.Item>
</div>
</template>
<div class="grid grid-cols-2 gap-4">
<Form.Item label="轮播图" required>
<Upload
v-model:file-list="carouselFileList"
list-type="picture-card"
accept="image/jpeg,image/png,image/jpg"
:before-upload="beforeUploadCarousel"
:on-preview="onPreviewUploadFile"
:on-remove="onRemoveCarousel"
>
<div>
<PlusOutlined />
<div class="mt-1 text-xs">选择</div>
</div>
</Upload>
</Form.Item>
<Form.Item label="详情图" required>
<Upload
v-model:file-list="detailFileList"
list-type="picture-card"
accept="image/jpeg,image/png,image/jpg"
:before-upload="beforeUploadDetail"
:on-preview="onPreviewUploadFile"
:on-remove="onRemoveDetail"
>
<div>
<PlusOutlined />
<div class="mt-1 text-xs">选择</div>
</div>
</Upload>
</Form.Item>
</div>
<template v-if="nonSaleProps.length">
<div class="mb-1 text-sm font-medium">类目属性</div>
<div class="grid grid-cols-2 gap-3">
<Form.Item
v-for="p in nonSaleProps"
:key="String(p.refPid)"
:label="p.name"
:required="!!p.required"
>
<CatPropertyField
v-model:value="form.goodsPropValues[String(p.refPid)]"
v-model:unit="form.goodsPropUnits[String(p.refPid)]"
:property="p"
/>
</Form.Item>
</div>
</template>
<div
v-if="form.catId"
data-agent-field="spec"
class="space-y-4"
:class="{ 'agent-typing-field': agentTypingField === 'spec' }"
>
<SpecAxesCard
:spec-catalog="specCatalog"
:spec-axes="specAxes"
:can-add-spec-axis="canAddSpecAxis"
:catalog-options-for-axis="catalogOptionsForAxis"
:spec-value-display="specValueDisplay"
:spec-value-auto-options="specValueAutoOptions"
@set-list-ref="onSpecAxesListRef"
@axis-catalog-change="onAxisCatalogChange"
@spec-value-input="onSpecValueInput"
@spec-value-commit="onSpecValueCommit"
@spec-value-enter="onSpecValueEnter"
@add-spec-value="addSpecValueSlot"
@remove-spec-value="removeSpecValue"
@remove-spec-axis="removeSpecAxis"
@add-spec-axis="addSpecAxis"
<div class="grid grid-cols-2 gap-4">
<Form.Item label="轮播图" required>
<Upload
v-model:file-list="carouselFileList"
list-type="picture-card"
accept="image/jpeg,image/png,image/jpg"
:before-upload="beforeUploadCarousel"
:on-preview="onPreviewUploadFile"
:on-remove="onRemoveCarousel"
>
<div>
<PlusOutlined />
<div class="mt-1 text-xs">选择</div>
</div>
</Upload>
</Form.Item>
<Form.Item label="详情图" required>
<Upload
v-model:file-list="detailFileList"
list-type="picture-card"
accept="image/jpeg,image/png,image/jpg"
:before-upload="beforeUploadDetail"
:on-preview="onPreviewUploadFile"
:on-remove="onRemoveDetail"
>
<div>
<PlusOutlined />
<div class="mt-1 text-xs">选择</div>
</div>
</Upload>
</Form.Item>
</div>
</Card>
<Card size="small" class="publish-editor-section" title="规格与库存">
<div
v-if="form.catId"
data-agent-field="spec"
class="publish-editor-spec-stack"
:class="{ 'agent-typing-field': agentTypingField === 'spec' }"
>
<SpecAxesCard
:spec-catalog="specCatalog"
:spec-axes="specAxes"
:can-add-spec-axis="canAddSpecAxis"
:catalog-options-for-axis="catalogOptionsForAxis"
:spec-value-display="specValueDisplay"
:spec-value-auto-options="specValueAutoOptions"
@set-list-ref="onSpecAxesListRef"
@axis-catalog-change="onAxisCatalogChange"
@spec-value-input="onSpecValueInput"
@spec-value-commit="onSpecValueCommit"
@spec-value-enter="onSpecValueEnter"
@add-spec-value="addSpecValueSlot"
@remove-spec-value="removeSpecValue"
@remove-spec-axis="removeSpecAxis"
@add-spec-axis="addSpecAxis"
/>
<SkuTableCard
v-model:bind-pick-sku-ids="bindPickSkuIds"
:sku-select-options="skuSelectOptions"
:sku-rows="skuRows"
:spec-axes-length="specAxes.length"
:sku-table-columns="skuTableColumns"
:sku-table-scroll-x="skuTableScrollX"
:sku-spec-cell-display="skuSpecCellDisplay"
:sku-spec-cell-auto-options="skuSpecCellAutoOptions"
:before-upload-sku="beforeUploadSku"
:on-preview-upload-file="onPreviewUploadFile"
@search="debouncedLoadSkuCandidates"
@dropdown-visible-change="onSkuSelectDropdownOpen"
@apply-internal-skus="applyInternalSkusInOrder"
@clear-internal-skus="clearInternalSkuBindings"
@set-table-wrap-ref="onSkuTableWrapRef"
@sku-spec-input="onSkuSpecCellInput"
@sku-spec-commit="onSkuSpecCellCommit"
@out-sku-sn-change="onOutSkuSnChange"
@out-sku-sn-blur="onOutSkuSnBlur"
@bind-internal-sku="bindInternalSku"
@sku-thumb-file-list-change="onSkuThumbFileListChange"
@apply-batch="applySkuBatchFields"
/>
</div>
<Empty
v-else
description="请先选择叶子类目"
:image="Empty.PRESENTED_IMAGE_SIMPLE"
/>
</Card>
<SkuTableCard
v-model:bind-pick-sku-ids="bindPickSkuIds"
:sku-select-options="skuSelectOptions"
:sku-rows="skuRows"
:spec-axes-length="specAxes.length"
:sku-table-columns="skuTableColumns"
:sku-table-scroll-x="skuTableScrollX"
:sku-spec-cell-display="skuSpecCellDisplay"
:sku-spec-cell-auto-options="skuSpecCellAutoOptions"
:before-upload-sku="beforeUploadSku"
:on-preview-upload-file="onPreviewUploadFile"
@search="debouncedLoadSkuCandidates"
@dropdown-visible-change="onSkuSelectDropdownOpen"
@apply-internal-skus="applyInternalSkusInOrder"
@clear-internal-skus="clearInternalSkuBindings"
@set-table-wrap-ref="onSkuTableWrapRef"
@sku-spec-input="onSkuSpecCellInput"
@sku-spec-commit="onSkuSpecCellCommit"
@out-sku-sn-change="onOutSkuSnChange"
@out-sku-sn-blur="onOutSkuSnBlur"
@bind-internal-sku="bindInternalSku"
@sku-thumb-file-list-change="onSkuThumbFileListChange"
@apply-batch="applySkuBatchFields"
/>
</div>
<Card size="small" class="publish-editor-section" title="服务与承诺">
<Form.Item label="运费模板" required>
<Select
v-model:value="form.costTemplateId"
class="w-full"
:options="logisticsOptions"
placeholder="选择运费模板"
show-search
option-filter-prop="label"
:disabled="!form.pddShopId"
allow-clear
@change="(v: any) => loadCostTemplateDetail(v)"
/>
</Form.Item>
<Card
v-if="form.costTemplateId || costTemplateDetailLoading"
size="small"
class="cost-template-detail-card"
title="运费模板详情"
>
<Spin :spinning="costTemplateDetailLoading">
<template v-if="costTemplateDetail">
<Descriptions bordered size="small" :column="2" class="mb-3">
<Descriptions.Item label="模板名称">
{{ costTemplateDetail.templateName || '-' }}
</Descriptions.Item>
<Descriptions.Item label="计费方式">
{{ costTemplateDetail.costTypeLabel || '-' }}
</Descriptions.Item>
<Descriptions.Item label="增值服务">
{{ costTemplateDetail.additionalServiceLabel || '-' }}
</Descriptions.Item>
<Descriptions.Item label="其它">
<Space :size="4" wrap>
<Tag v-if="costTemplateDetail.sfFree" color="success">
顺丰包邮
</Tag>
<Tag
v-if="costTemplateDetail.freeDeliverHouse"
color="processing"
>
包邮区送货上门
</Tag>
<span
v-if="
!costTemplateDetail.sfFree &&
!costTemplateDetail.freeDeliverHouse
"
>
-
</span>
</Space>
</Descriptions.Item>
<Descriptions.Item label="包邮省份" :span="2">
<div
v-if="costTemplateDetail.freeProvinces?.length"
class="free-province-tags"
>
<Tag
v-for="(p, idx) in costTemplateDetail.freeProvinces"
:key="`${p.provinceId}-${idx}`"
>
{{ p.province || p.provinceId }}
</Tag>
</div>
<span v-else>暂无</span>
</Descriptions.Item>
<Descriptions.Item
v-if="costTemplateDetail.freeDeliverHouseAreas?.length"
label="送货上门地区"
:span="2"
>
{{
costTemplateDetail.freeDeliverHouseAreas
.map((a) => a.areaText)
.filter(Boolean)
.join('、') || '-'
}}
</Descriptions.Item>
</Descriptions>
<Table
v-if="costTemplateDetail.paidRegions?.length"
size="small"
:pagination="false"
:data-source="costTemplateDetail.paidRegions"
:row-key="(_: any, i?: number) => `paid-${i ?? 0}`"
:columns="[
{ title: '买家付邮地区', dataIndex: 'provincesText' },
{ title: '首费规则', key: 'first', width: 160 },
{ title: '续费规则', key: 'add', width: 160 },
{ title: '条件包邮', dataIndex: 'freeRuleText', width: 160 },
]"
>
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'first'">
首{{ record.firstStandard ?? '-'
}}{{ costTemplateDetail?.costType === 1 ? 'kg' : '件' }}
/ {{ record.firstCostYuan ?? '-' }}元
</template>
<template v-else-if="column.key === 'add'">
续{{ record.addStandard ?? '-'
}}{{ costTemplateDetail?.costType === 1 ? 'kg' : '件' }}
/ {{ record.addCostYuan ?? '-' }}元
</template>
</template>
</Table>
</template>
<Empty
v-else-if="!costTemplateDetailLoading"
description="暂无模板详情"
:image="Empty.PRESENTED_IMAGE_SIMPLE"
/>
</Spin>
</Card>
<div class="grid grid-cols-2 gap-3">
<Form.Item label="参考价(元)" required>
<InputNumber
v-model:value="form.marketPriceYuan"
class="w-full"
:min="0.01"
:precision="2"
/>
</Form.Item>
<Form.Item label="发货时限" required>
<Select
v-model:value="form.shipmentLimitSecond"
class="w-full"
:options="[
{ label: '24小时', value: 86400 },
{ label: '48小时', value: 172800 },
]"
/>
</Form.Item>
<Form.Item label="满两件折扣" required>
<InputNumber
v-model:value="form.twoPiecesDiscount"
class="w-full"
:min="0"
:max="10"
:precision="1"
:step="0.1"
placeholder="9.5 表示 9.5 折,0 取消"
/>
</Form.Item>
</div>
<div class="flex flex-wrap gap-6">
<Form.Item label="假一赔十" required>
<Switch v-model:checked="form.isFolt" />
</Form.Item>
<Form.Item label="7天无理由" required>
<Switch v-model:checked="form.isRefundable" />
</Form.Item>
<Form.Item label="预售" required>
<Switch v-model:checked="form.isPreSale" />
</Form.Item>
<Form.Item label="二手" required>
<Switch v-model:checked="form.secondHand" />
</Form.Item>
</div>
</Card>
</div>
<div
@@ -785,6 +796,33 @@ function onSkuTableWrapRef(el: HTMLElement | null) {
</template>
<style scoped>
/* 分区 Card 纵向间距(gap 比 space-y 对 ant-card 更稳定) */
.publish-editor-sections {
display: flex;
flex-direction: column;
gap: 1.5rem;
}
.publish-editor-sections :deep(.publish-editor-section.ant-card) {
margin-bottom: 0;
}
/* 规格与库存:销售规格 / SKU 子卡片间距 */
.publish-editor-spec-stack {
display: flex;
flex-direction: column;
gap: 1.5rem;
}
.publish-editor-spec-stack :deep(.ant-card) {
margin-bottom: 0;
}
/* 服务与承诺:运费模板详情与下方参考价等字段 */
.cost-template-detail-card {
margin-bottom: 1.5rem;
}
/* 智能体逐字改写时的轻量高亮,便于视线跟上 */
.agent-typing-field {
position: relative;
@@ -192,6 +192,7 @@ function onColumnBatchEnter(
</script>
<template>
<div class="sku-table-card-stack">
<Card size="small" title="内部 SKU 拉入">
<div class="flex flex-wrap items-center gap-2">
<Select
@@ -491,9 +492,20 @@ function onColumnBatchEnter(
/>
</div>
</Teleport>
</div>
</template>
<style scoped>
.sku-table-card-stack {
display: flex;
flex-direction: column;
gap: 1.5rem;
}
.sku-table-card-stack :deep(.ant-card) {
margin-bottom: 0;
}
.sku-batch-header {
display: inline-flex;
align-items: center;