mirror of
https://gitee.com/qqtt-ah/ecom-dmb.git
synced 2026-11-24 02:39:19 +08:00
fix: 发布编辑器折扣改为正常折扣并由前端换算后提交
This commit is contained in:
+8
-5
@@ -390,7 +390,7 @@ function onSkuTableWrapRef(el: HTMLElement | null) {
|
|||||||
<Teleport defer to="#pdd-publish-edit-header-fields">
|
<Teleport defer to="#pdd-publish-edit-header-fields">
|
||||||
<div class="w-full min-w-0 space-y-2">
|
<div class="w-full min-w-0 space-y-2">
|
||||||
<div class="grid grid-cols-1 gap-3 md:grid-cols-2">
|
<div class="grid grid-cols-1 gap-3 md:grid-cols-2">
|
||||||
<div class="min-w-0">
|
<div class="min-w-0 w-full">
|
||||||
<div class="mb-1 text-sm font-medium">
|
<div class="mb-1 text-sm font-medium">
|
||||||
渠道店铺 <span class="text-destructive">*</span>
|
渠道店铺 <span class="text-destructive">*</span>
|
||||||
</div>
|
</div>
|
||||||
@@ -405,7 +405,7 @@ function onSkuTableWrapRef(el: HTMLElement | null) {
|
|||||||
@search="(kw: string) => loadShops(kw)"
|
@search="(kw: string) => loadShops(kw)"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div class="min-w-0">
|
<div class="min-w-0 w-full">
|
||||||
<div class="mb-1 flex items-center gap-1.5 text-sm font-medium">
|
<div class="mb-1 flex items-center gap-1.5 text-sm font-medium">
|
||||||
<span>
|
<span>
|
||||||
叶子类目 <span class="text-destructive">*</span>
|
叶子类目 <span class="text-destructive">*</span>
|
||||||
@@ -436,10 +436,12 @@ function onSkuTableWrapRef(el: HTMLElement | null) {
|
|||||||
/>
|
/>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
</div>
|
</div>
|
||||||
|
<!-- Cascader 默认不吃满格子,需显式 100% 与店铺 Select 对齐 -->
|
||||||
<Cascader
|
<Cascader
|
||||||
v-model:value="form.catPath"
|
v-model:value="form.catPath"
|
||||||
v-model:search-value="catCascaderSearch"
|
v-model:search-value="catCascaderSearch"
|
||||||
class="w-full"
|
class="w-full"
|
||||||
|
:style="{ width: '100%' }"
|
||||||
:options="displayCatOptions"
|
:options="displayCatOptions"
|
||||||
:load-data="catLoadData"
|
:load-data="catLoadData"
|
||||||
:show-search="{
|
:show-search="{
|
||||||
@@ -640,9 +642,10 @@ function onSkuTableWrapRef(el: HTMLElement | null) {
|
|||||||
v-model:value="form.twoPiecesDiscount"
|
v-model:value="form.twoPiecesDiscount"
|
||||||
class="w-full"
|
class="w-full"
|
||||||
:min="0"
|
:min="0"
|
||||||
:max="100"
|
:max="10"
|
||||||
:precision="0"
|
:precision="1"
|
||||||
placeholder="95 表示 95 折,0 取消"
|
:step="0.1"
|
||||||
|
placeholder="9.5 表示 9.5 折,0 取消"
|
||||||
/>
|
/>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
+12
-10
@@ -18,12 +18,14 @@ import {
|
|||||||
updatePddPublishDeskDraftApi,
|
updatePddPublishDeskDraftApi,
|
||||||
} from '#/api/channel/pdd/goods';
|
} from '#/api/channel/pdd/goods';
|
||||||
|
|
||||||
import type {
|
import {
|
||||||
PersistedUpload,
|
twoPiecesDiscountFromStored,
|
||||||
PublishFormFields,
|
twoPiecesDiscountToApi,
|
||||||
SpecAxis,
|
type PersistedUpload,
|
||||||
SpecCatalogItem,
|
type PublishFormFields,
|
||||||
SkuRow,
|
type SpecAxis,
|
||||||
|
type SpecCatalogItem,
|
||||||
|
type SkuRow,
|
||||||
} from '../types';
|
} from '../types';
|
||||||
|
|
||||||
type EmitDraft = {
|
type EmitDraft = {
|
||||||
@@ -185,9 +187,9 @@ export function usePublishDraft(options: {
|
|||||||
if (
|
if (
|
||||||
form.twoPiecesDiscount == null ||
|
form.twoPiecesDiscount == null ||
|
||||||
form.twoPiecesDiscount < 0 ||
|
form.twoPiecesDiscount < 0 ||
|
||||||
form.twoPiecesDiscount > 100
|
form.twoPiecesDiscount > 10
|
||||||
) {
|
) {
|
||||||
message.warning('请填写满两件折扣(0-100,95表示95折)');
|
message.warning('请填写正常折扣(0-10,9.5 表示 9.5 折)');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
for (const p of nonSaleProps.value) {
|
for (const p of nonSaleProps.value) {
|
||||||
@@ -362,7 +364,7 @@ export function usePublishDraft(options: {
|
|||||||
isPreSale: form.isPreSale,
|
isPreSale: form.isPreSale,
|
||||||
isRefundable: form.isRefundable,
|
isRefundable: form.isRefundable,
|
||||||
secondHand: form.secondHand,
|
secondHand: form.secondHand,
|
||||||
twoPiecesDiscount: form.twoPiecesDiscount,
|
twoPiecesDiscount: twoPiecesDiscountToApi(form.twoPiecesDiscount),
|
||||||
carouselImages: carouselFileIds.map(String),
|
carouselImages: carouselFileIds.map(String),
|
||||||
detailImages: detailFileIds.map(String),
|
detailImages: detailFileIds.map(String),
|
||||||
goodsProperties,
|
goodsProperties,
|
||||||
@@ -459,7 +461,7 @@ export function usePublishDraft(options: {
|
|||||||
}
|
}
|
||||||
if (typeof es.secondHand === 'boolean') form.secondHand = es.secondHand;
|
if (typeof es.secondHand === 'boolean') form.secondHand = es.secondHand;
|
||||||
if (typeof es.twoPiecesDiscount === 'number') {
|
if (typeof es.twoPiecesDiscount === 'number') {
|
||||||
form.twoPiecesDiscount = es.twoPiecesDiscount;
|
form.twoPiecesDiscount = twoPiecesDiscountFromStored(es.twoPiecesDiscount);
|
||||||
}
|
}
|
||||||
if (
|
if (
|
||||||
es.goodsPropValues &&
|
es.goodsPropValues &&
|
||||||
|
|||||||
@@ -60,15 +60,6 @@ function goBack() {
|
|||||||
>
|
>
|
||||||
<template #title>
|
<template #title>
|
||||||
<div class="w-full space-y-3">
|
<div class="w-full space-y-3">
|
||||||
<div class="mb-0 flex items-baseline text-lg font-semibold">
|
|
||||||
编辑系统草稿
|
|
||||||
<span
|
|
||||||
v-if="draftId"
|
|
||||||
class="text-muted-foreground ml-2 text-sm font-normal"
|
|
||||||
>
|
|
||||||
#{{ draftId }}
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
<!-- Editor Teleport:店铺 / 类目 -->
|
<!-- Editor Teleport:店铺 / 类目 -->
|
||||||
<div id="pdd-publish-edit-header-fields" class="w-full min-w-0"></div>
|
<div id="pdd-publish-edit-header-fields" class="w-full min-w-0"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -101,10 +101,23 @@ export type PublishFormFields = {
|
|||||||
isPreSale: boolean;
|
isPreSale: boolean;
|
||||||
isRefundable: boolean;
|
isRefundable: boolean;
|
||||||
secondHand: boolean;
|
secondHand: boolean;
|
||||||
|
/** 表单展示用折扣:0–10,9.5=9.5折;提交接口时 *10 */
|
||||||
twoPiecesDiscount: number;
|
twoPiecesDiscount: number;
|
||||||
goodsPropValues: Record<string, string>;
|
goodsPropValues: Record<string, string>;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/** 表单折扣 → 拼多多接口整数(9.5 → 95) */
|
||||||
|
export function twoPiecesDiscountToApi(ui: number | null | undefined): number {
|
||||||
|
if (ui == null || Number.isNaN(ui)) return 95;
|
||||||
|
return Math.round(ui * 10);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 接口/旧草稿整数 → 表单折扣(95 → 9.5;已是 0–10 则原样) */
|
||||||
|
export function twoPiecesDiscountFromStored(raw: number): number {
|
||||||
|
if (raw > 10) return Math.round((raw / 10) * 10) / 10;
|
||||||
|
return raw;
|
||||||
|
}
|
||||||
|
|
||||||
/** 创建空白发布表单字段 */
|
/** 创建空白发布表单字段 */
|
||||||
export function createEmptyPublishForm(): PublishFormFields {
|
export function createEmptyPublishForm(): PublishFormFields {
|
||||||
return {
|
return {
|
||||||
@@ -117,11 +130,11 @@ export function createEmptyPublishForm(): PublishFormFields {
|
|||||||
costTemplateId: undefined,
|
costTemplateId: undefined,
|
||||||
marketPriceYuan: undefined,
|
marketPriceYuan: undefined,
|
||||||
shipmentLimitSecond: 172800,
|
shipmentLimitSecond: 172800,
|
||||||
isFolt: true,
|
isFolt: false,
|
||||||
isPreSale: false,
|
isPreSale: false,
|
||||||
isRefundable: true,
|
isRefundable: true,
|
||||||
secondHand: false,
|
secondHand: false,
|
||||||
twoPiecesDiscount: 95,
|
twoPiecesDiscount: 9.5,
|
||||||
goodsPropValues: {},
|
goodsPropValues: {},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user