mirror of
https://gitee.com/qqtt-ah/ecom-dmb.git
synced 2026-11-23 23:19: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">
|
||||
<div class="w-full min-w-0 space-y-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">
|
||||
渠道店铺 <span class="text-destructive">*</span>
|
||||
</div>
|
||||
@@ -405,7 +405,7 @@ function onSkuTableWrapRef(el: HTMLElement | null) {
|
||||
@search="(kw: string) => loadShops(kw)"
|
||||
/>
|
||||
</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">
|
||||
<span>
|
||||
叶子类目 <span class="text-destructive">*</span>
|
||||
@@ -436,10 +436,12 @@ function onSkuTableWrapRef(el: HTMLElement | null) {
|
||||
/>
|
||||
</Tooltip>
|
||||
</div>
|
||||
<!-- Cascader 默认不吃满格子,需显式 100% 与店铺 Select 对齐 -->
|
||||
<Cascader
|
||||
v-model:value="form.catPath"
|
||||
v-model:search-value="catCascaderSearch"
|
||||
class="w-full"
|
||||
:style="{ width: '100%' }"
|
||||
:options="displayCatOptions"
|
||||
:load-data="catLoadData"
|
||||
:show-search="{
|
||||
@@ -640,9 +642,10 @@ function onSkuTableWrapRef(el: HTMLElement | null) {
|
||||
v-model:value="form.twoPiecesDiscount"
|
||||
class="w-full"
|
||||
:min="0"
|
||||
:max="100"
|
||||
:precision="0"
|
||||
placeholder="95 表示 95 折,0 取消"
|
||||
:max="10"
|
||||
:precision="1"
|
||||
:step="0.1"
|
||||
placeholder="9.5 表示 9.5 折,0 取消"
|
||||
/>
|
||||
</Form.Item>
|
||||
</div>
|
||||
|
||||
+12
-10
@@ -18,12 +18,14 @@ import {
|
||||
updatePddPublishDeskDraftApi,
|
||||
} from '#/api/channel/pdd/goods';
|
||||
|
||||
import type {
|
||||
PersistedUpload,
|
||||
PublishFormFields,
|
||||
SpecAxis,
|
||||
SpecCatalogItem,
|
||||
SkuRow,
|
||||
import {
|
||||
twoPiecesDiscountFromStored,
|
||||
twoPiecesDiscountToApi,
|
||||
type PersistedUpload,
|
||||
type PublishFormFields,
|
||||
type SpecAxis,
|
||||
type SpecCatalogItem,
|
||||
type SkuRow,
|
||||
} from '../types';
|
||||
|
||||
type EmitDraft = {
|
||||
@@ -185,9 +187,9 @@ export function usePublishDraft(options: {
|
||||
if (
|
||||
form.twoPiecesDiscount == null ||
|
||||
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;
|
||||
}
|
||||
for (const p of nonSaleProps.value) {
|
||||
@@ -362,7 +364,7 @@ export function usePublishDraft(options: {
|
||||
isPreSale: form.isPreSale,
|
||||
isRefundable: form.isRefundable,
|
||||
secondHand: form.secondHand,
|
||||
twoPiecesDiscount: form.twoPiecesDiscount,
|
||||
twoPiecesDiscount: twoPiecesDiscountToApi(form.twoPiecesDiscount),
|
||||
carouselImages: carouselFileIds.map(String),
|
||||
detailImages: detailFileIds.map(String),
|
||||
goodsProperties,
|
||||
@@ -459,7 +461,7 @@ export function usePublishDraft(options: {
|
||||
}
|
||||
if (typeof es.secondHand === 'boolean') form.secondHand = es.secondHand;
|
||||
if (typeof es.twoPiecesDiscount === 'number') {
|
||||
form.twoPiecesDiscount = es.twoPiecesDiscount;
|
||||
form.twoPiecesDiscount = twoPiecesDiscountFromStored(es.twoPiecesDiscount);
|
||||
}
|
||||
if (
|
||||
es.goodsPropValues &&
|
||||
|
||||
@@ -60,15 +60,6 @@ function goBack() {
|
||||
>
|
||||
<template #title>
|
||||
<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:店铺 / 类目 -->
|
||||
<div id="pdd-publish-edit-header-fields" class="w-full min-w-0"></div>
|
||||
</div>
|
||||
|
||||
@@ -101,10 +101,23 @@ export type PublishFormFields = {
|
||||
isPreSale: boolean;
|
||||
isRefundable: boolean;
|
||||
secondHand: boolean;
|
||||
/** 表单展示用折扣:0–10,9.5=9.5折;提交接口时 *10 */
|
||||
twoPiecesDiscount: number;
|
||||
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 {
|
||||
return {
|
||||
@@ -117,11 +130,11 @@ export function createEmptyPublishForm(): PublishFormFields {
|
||||
costTemplateId: undefined,
|
||||
marketPriceYuan: undefined,
|
||||
shipmentLimitSecond: 172800,
|
||||
isFolt: true,
|
||||
isFolt: false,
|
||||
isPreSale: false,
|
||||
isRefundable: true,
|
||||
secondHand: false,
|
||||
twoPiecesDiscount: 95,
|
||||
twoPiecesDiscount: 9.5,
|
||||
goodsPropValues: {},
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user