mirror of
https://gitee.com/qqtt-ah/ecom-dmb.git
synced 2026-11-25 06:29:20 +08:00
feat: 发布工作台点击标题模态框展示系统草稿详情
This commit is contained in:
+522
@@ -0,0 +1,522 @@
|
|||||||
|
<script lang="ts" setup>
|
||||||
|
import type { PddPublishDeskVO } from '#/api/channel/pdd/goods';
|
||||||
|
|
||||||
|
import { computed, ref, watch } from 'vue';
|
||||||
|
|
||||||
|
import { useVbenModal } from '@vben/common-ui';
|
||||||
|
|
||||||
|
import {
|
||||||
|
Descriptions,
|
||||||
|
DescriptionsItem,
|
||||||
|
Image,
|
||||||
|
Spin,
|
||||||
|
Table,
|
||||||
|
Tag,
|
||||||
|
} from 'ant-design-vue';
|
||||||
|
|
||||||
|
import { getPddPublishDeskDraftApi } from '#/api/channel/pdd/goods';
|
||||||
|
import { getFileAccessUrlApi } from '#/api/sys/file';
|
||||||
|
|
||||||
|
defineOptions({ name: 'PddPublishDraftDetailModal' });
|
||||||
|
|
||||||
|
const props = defineProps<{
|
||||||
|
draftId?: number;
|
||||||
|
/** 列表行快照,打开时先展示,接口返回后覆盖 */
|
||||||
|
preview?: PddPublishDeskVO.Draft | null;
|
||||||
|
}>();
|
||||||
|
|
||||||
|
const open = defineModel<boolean>('open', { default: false });
|
||||||
|
|
||||||
|
const emit = defineEmits<{
|
||||||
|
edit: [id: number];
|
||||||
|
}>();
|
||||||
|
|
||||||
|
const [Modal, modalApi] = useVbenModal({
|
||||||
|
title: '系统草稿详情',
|
||||||
|
class: 'w-[860px] max-w-[calc(100vw-2rem)]',
|
||||||
|
draggable: true,
|
||||||
|
destroyOnClose: true,
|
||||||
|
bordered: true,
|
||||||
|
cancelText: '关闭',
|
||||||
|
confirmText: '编辑',
|
||||||
|
onOpenChange(isOpen) {
|
||||||
|
open.value = isOpen;
|
||||||
|
},
|
||||||
|
onCancel() {
|
||||||
|
closeModal();
|
||||||
|
},
|
||||||
|
onConfirm() {
|
||||||
|
onEdit();
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const loading = ref(false);
|
||||||
|
const imagesLoading = ref(false);
|
||||||
|
const draft = ref<PddPublishDeskVO.Draft | null>(null);
|
||||||
|
|
||||||
|
const statusLabel: Record<string, { text: string; color: string }> = {
|
||||||
|
EDITING: { text: '编辑中', color: 'default' },
|
||||||
|
NEED_CHECK: { text: '待校验', color: 'orange' },
|
||||||
|
READY: { text: '可发布', color: 'blue' },
|
||||||
|
PUBLISHING: { text: '发布中', color: 'processing' },
|
||||||
|
FAILED: { text: '失败', color: 'error' },
|
||||||
|
};
|
||||||
|
|
||||||
|
type PersistedUpload = {
|
||||||
|
fileId?: number;
|
||||||
|
name?: string;
|
||||||
|
url?: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
type EditorSnapshot = {
|
||||||
|
goodsName?: string;
|
||||||
|
goodsDesc?: string;
|
||||||
|
selectedCatPathLabel?: string;
|
||||||
|
marketPriceYuan?: number;
|
||||||
|
};
|
||||||
|
|
||||||
|
type SkuRow = {
|
||||||
|
key: string;
|
||||||
|
specText: string;
|
||||||
|
outSkuSn: string;
|
||||||
|
priceYuan?: number;
|
||||||
|
multiPriceYuan?: number;
|
||||||
|
quantity?: number;
|
||||||
|
internalLabel: string;
|
||||||
|
thumbUrl?: string;
|
||||||
|
thumbFileId?: number;
|
||||||
|
};
|
||||||
|
|
||||||
|
type DraftImage = { key: string; url: string; alt?: string };
|
||||||
|
|
||||||
|
function readPersistedList(raw: unknown): PersistedUpload[] {
|
||||||
|
if (!Array.isArray(raw)) return [];
|
||||||
|
return raw
|
||||||
|
.map((item) => {
|
||||||
|
const o = item as Record<string, unknown>;
|
||||||
|
const fileId = o.fileId;
|
||||||
|
return {
|
||||||
|
fileId:
|
||||||
|
typeof fileId === 'number' && Number.isFinite(fileId)
|
||||||
|
? fileId
|
||||||
|
: undefined,
|
||||||
|
name: typeof o.name === 'string' ? o.name : undefined,
|
||||||
|
url: typeof o.url === 'string' ? o.url : undefined,
|
||||||
|
};
|
||||||
|
})
|
||||||
|
.filter((p) => p.fileId != null || (p.url && !p.url.startsWith('blob:')));
|
||||||
|
}
|
||||||
|
|
||||||
|
function parsePayload(payloadJson?: string): {
|
||||||
|
editor: EditorSnapshot;
|
||||||
|
hasPublishPayload: boolean;
|
||||||
|
skus: SkuRow[];
|
||||||
|
carouselRaw: PersistedUpload[];
|
||||||
|
detailRaw: PersistedUpload[];
|
||||||
|
} {
|
||||||
|
const empty = {
|
||||||
|
editor: {} as EditorSnapshot,
|
||||||
|
hasPublishPayload: false,
|
||||||
|
skus: [] as SkuRow[],
|
||||||
|
carouselRaw: [] as PersistedUpload[],
|
||||||
|
detailRaw: [] as PersistedUpload[],
|
||||||
|
};
|
||||||
|
if (!payloadJson) return empty;
|
||||||
|
try {
|
||||||
|
const root = JSON.parse(payloadJson) as {
|
||||||
|
editorState?: Record<string, unknown>;
|
||||||
|
publishPayload?: unknown;
|
||||||
|
};
|
||||||
|
const es = root.editorState ?? {};
|
||||||
|
const editor: EditorSnapshot = {
|
||||||
|
goodsName:
|
||||||
|
typeof es.goodsName === 'string' ? es.goodsName : undefined,
|
||||||
|
goodsDesc:
|
||||||
|
typeof es.goodsDesc === 'string' ? es.goodsDesc : undefined,
|
||||||
|
selectedCatPathLabel:
|
||||||
|
typeof es.selectedCatPathLabel === 'string'
|
||||||
|
? es.selectedCatPathLabel
|
||||||
|
: undefined,
|
||||||
|
marketPriceYuan:
|
||||||
|
typeof es.marketPriceYuan === 'number'
|
||||||
|
? es.marketPriceYuan
|
||||||
|
: undefined,
|
||||||
|
};
|
||||||
|
const rows = es.skuRows;
|
||||||
|
const skus: SkuRow[] = [];
|
||||||
|
if (Array.isArray(rows)) {
|
||||||
|
rows.forEach((r, i) => {
|
||||||
|
const raw = r as Record<string, unknown>;
|
||||||
|
const saleValues = raw.saleValues;
|
||||||
|
let specText = '';
|
||||||
|
if (
|
||||||
|
saleValues &&
|
||||||
|
typeof saleValues === 'object' &&
|
||||||
|
!Array.isArray(saleValues)
|
||||||
|
) {
|
||||||
|
specText = Object.values(saleValues as Record<string, unknown>)
|
||||||
|
.map((v) => String(v ?? '').trim())
|
||||||
|
.filter(Boolean)
|
||||||
|
.join(' / ');
|
||||||
|
}
|
||||||
|
const productName = String(raw.productName || '').trim();
|
||||||
|
const internalSkuName = String(raw.internalSkuName || '').trim();
|
||||||
|
let internalLabel = '—';
|
||||||
|
if (productName && internalSkuName) {
|
||||||
|
internalLabel = `${productName} / ${internalSkuName}`;
|
||||||
|
} else if (internalSkuName || productName) {
|
||||||
|
internalLabel = internalSkuName || productName;
|
||||||
|
}
|
||||||
|
const price = raw.priceYuan;
|
||||||
|
const multi = raw.multiPriceYuan;
|
||||||
|
const qty = raw.quantity;
|
||||||
|
const thumb = raw.thumb as PersistedUpload | null | undefined;
|
||||||
|
const thumbUrl =
|
||||||
|
thumb?.url && !thumb.url.startsWith('blob:')
|
||||||
|
? thumb.url
|
||||||
|
: undefined;
|
||||||
|
skus.push({
|
||||||
|
key: String(i),
|
||||||
|
specText: specText || String(raw.skuName || '').trim() || '—',
|
||||||
|
outSkuSn: String(raw.outSkuSn || '').trim() || '—',
|
||||||
|
priceYuan:
|
||||||
|
typeof price === 'number' && Number.isFinite(price)
|
||||||
|
? price
|
||||||
|
: undefined,
|
||||||
|
multiPriceYuan:
|
||||||
|
typeof multi === 'number' && Number.isFinite(multi)
|
||||||
|
? multi
|
||||||
|
: undefined,
|
||||||
|
quantity:
|
||||||
|
typeof qty === 'number' && Number.isFinite(qty) ? qty : undefined,
|
||||||
|
internalLabel,
|
||||||
|
thumbUrl,
|
||||||
|
thumbFileId:
|
||||||
|
typeof thumb?.fileId === 'number' ? thumb.fileId : undefined,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
editor,
|
||||||
|
hasPublishPayload:
|
||||||
|
root.publishPayload != null && typeof root.publishPayload === 'object',
|
||||||
|
skus,
|
||||||
|
carouselRaw: readPersistedList(es.carouselFiles),
|
||||||
|
detailRaw: readPersistedList(es.detailFiles),
|
||||||
|
};
|
||||||
|
} catch {
|
||||||
|
return empty;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const parsed = computed(() => parsePayload(draft.value?.payloadJson));
|
||||||
|
|
||||||
|
const carouselImages = ref<DraftImage[]>([]);
|
||||||
|
const detailImages = ref<DraftImage[]>([]);
|
||||||
|
const skuThumbByKey = ref<Map<string, string>>(new Map());
|
||||||
|
|
||||||
|
const displayTitle = computed(
|
||||||
|
() =>
|
||||||
|
draft.value?.title ||
|
||||||
|
parsed.value.editor.goodsName ||
|
||||||
|
'未命名草稿',
|
||||||
|
);
|
||||||
|
|
||||||
|
const skuRowsForTable = computed(() =>
|
||||||
|
parsed.value.skus.map((row) => ({
|
||||||
|
...row,
|
||||||
|
thumbUrl: skuThumbByKey.value.get(row.key) ?? row.thumbUrl,
|
||||||
|
})),
|
||||||
|
);
|
||||||
|
|
||||||
|
const skuColumns = [
|
||||||
|
{ title: '缩略图', key: 'thumb', width: 72 },
|
||||||
|
{ title: '规格', dataIndex: 'specText', key: 'specText', ellipsis: true },
|
||||||
|
{ title: '商家编码', dataIndex: 'outSkuSn', key: 'outSkuSn', width: 120 },
|
||||||
|
{ title: '原价', key: 'priceYuan', width: 88 },
|
||||||
|
{ title: '拼团价', key: 'multiPriceYuan', width: 88 },
|
||||||
|
{ title: '库存', dataIndex: 'quantity', key: 'quantity', width: 72 },
|
||||||
|
{
|
||||||
|
title: '内部SKU',
|
||||||
|
dataIndex: 'internalLabel',
|
||||||
|
key: 'internalLabel',
|
||||||
|
ellipsis: true,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
function formatPrice(price?: number) {
|
||||||
|
if (price == null || Number.isNaN(price)) return '—';
|
||||||
|
return `¥${price.toFixed(2)}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function resolveUrl(fileId: number, cached?: string): Promise<string> {
|
||||||
|
if (cached && !cached.startsWith('blob:')) return cached;
|
||||||
|
try {
|
||||||
|
return await getFileAccessUrlApi(fileId);
|
||||||
|
} catch {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function loadImagesFromPayload(payloadJson?: string) {
|
||||||
|
carouselImages.value = [];
|
||||||
|
detailImages.value = [];
|
||||||
|
skuThumbByKey.value = new Map();
|
||||||
|
const data = parsePayload(payloadJson);
|
||||||
|
imagesLoading.value = true;
|
||||||
|
try {
|
||||||
|
const needIds = new Set<number>();
|
||||||
|
for (const p of [...data.carouselRaw, ...data.detailRaw]) {
|
||||||
|
if (p.fileId != null && (!p.url || p.url.startsWith('blob:'))) {
|
||||||
|
needIds.add(p.fileId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (const row of data.skus) {
|
||||||
|
if (!row.thumbUrl && row.thumbFileId != null) {
|
||||||
|
needIds.add(row.thumbFileId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const urlById = new Map<number, string>();
|
||||||
|
await Promise.all(
|
||||||
|
[...needIds].map(async (id) => {
|
||||||
|
const url = await resolveUrl(id);
|
||||||
|
if (url) urlById.set(id, url);
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
|
const pickUrl = (p: PersistedUpload) => {
|
||||||
|
if (p.url && !p.url.startsWith('blob:')) return p.url;
|
||||||
|
if (p.fileId != null) return urlById.get(p.fileId) ?? '';
|
||||||
|
return '';
|
||||||
|
};
|
||||||
|
|
||||||
|
const buildImages = (
|
||||||
|
raw: PersistedUpload[],
|
||||||
|
keyPrefix: string,
|
||||||
|
defaultAlt: (index: number) => string,
|
||||||
|
): DraftImage[] => {
|
||||||
|
const images: DraftImage[] = [];
|
||||||
|
raw.forEach((p, i) => {
|
||||||
|
const url = pickUrl(p);
|
||||||
|
if (!url) return;
|
||||||
|
images.push({
|
||||||
|
key: `${keyPrefix}-${i}`,
|
||||||
|
url,
|
||||||
|
alt: p.name || defaultAlt(i),
|
||||||
|
});
|
||||||
|
});
|
||||||
|
return images;
|
||||||
|
};
|
||||||
|
|
||||||
|
carouselImages.value = buildImages(
|
||||||
|
data.carouselRaw,
|
||||||
|
'c',
|
||||||
|
(i) => `轮播图 ${i + 1}`,
|
||||||
|
);
|
||||||
|
detailImages.value = buildImages(
|
||||||
|
data.detailRaw,
|
||||||
|
'd',
|
||||||
|
(i) => `详情图 ${i + 1}`,
|
||||||
|
);
|
||||||
|
|
||||||
|
const thumbMap = new Map<string, string>();
|
||||||
|
for (const row of data.skus) {
|
||||||
|
if (row.thumbUrl) {
|
||||||
|
thumbMap.set(row.key, row.thumbUrl);
|
||||||
|
} else if (row.thumbFileId != null) {
|
||||||
|
const url = urlById.get(row.thumbFileId);
|
||||||
|
if (url) thumbMap.set(row.key, url);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
skuThumbByKey.value = thumbMap;
|
||||||
|
} finally {
|
||||||
|
imagesLoading.value = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function loadDetail(id: number) {
|
||||||
|
loading.value = true;
|
||||||
|
try {
|
||||||
|
draft.value = await getPddPublishDeskDraftApi(id);
|
||||||
|
await loadImagesFromPayload(draft.value.payloadJson);
|
||||||
|
} finally {
|
||||||
|
loading.value = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
watch(open, (isOpen) => {
|
||||||
|
if (isOpen) {
|
||||||
|
modalApi.open();
|
||||||
|
} else {
|
||||||
|
modalApi.close();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
watch(displayTitle, (title) => {
|
||||||
|
modalApi.setState({ title });
|
||||||
|
});
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => [open.value, props.draftId] as const,
|
||||||
|
([isOpen, id]) => {
|
||||||
|
if (!isOpen || id == null) {
|
||||||
|
draft.value = null;
|
||||||
|
carouselImages.value = [];
|
||||||
|
detailImages.value = [];
|
||||||
|
skuThumbByKey.value = new Map();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
draft.value = props.preview ?? null;
|
||||||
|
void loadImagesFromPayload(props.preview?.payloadJson);
|
||||||
|
void loadDetail(id);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
function closeModal() {
|
||||||
|
open.value = false;
|
||||||
|
modalApi.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
function onEdit() {
|
||||||
|
if (draft.value?.id == null) return;
|
||||||
|
emit('edit', draft.value.id);
|
||||||
|
closeModal();
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<Modal>
|
||||||
|
<Spin :spinning="loading">
|
||||||
|
<div v-if="draft" class="space-y-4 pb-1">
|
||||||
|
<Descriptions bordered :column="2" size="small">
|
||||||
|
<DescriptionsItem label="状态">
|
||||||
|
<Tag :color="statusLabel[draft.status]?.color || 'default'">
|
||||||
|
{{ statusLabel[draft.status]?.text || draft.status }}
|
||||||
|
</Tag>
|
||||||
|
</DescriptionsItem>
|
||||||
|
<DescriptionsItem label="渠道店铺">
|
||||||
|
{{ draft.shopName || '未分配' }}
|
||||||
|
</DescriptionsItem>
|
||||||
|
<DescriptionsItem label="类目" :span="2">
|
||||||
|
{{ parsed.editor.selectedCatPathLabel || '—' }}
|
||||||
|
</DescriptionsItem>
|
||||||
|
<DescriptionsItem label="SKU 数">
|
||||||
|
{{ draft.skuCount ?? parsed.skus.length ?? 0 }}
|
||||||
|
</DescriptionsItem>
|
||||||
|
<DescriptionsItem label="可投递数据">
|
||||||
|
<Tag :color="parsed.hasPublishPayload ? 'success' : 'default'">
|
||||||
|
{{ parsed.hasPublishPayload ? '已生成' : '未生成' }}
|
||||||
|
</Tag>
|
||||||
|
</DescriptionsItem>
|
||||||
|
<DescriptionsItem label="推草稿 / 店">
|
||||||
|
{{ draft.pushSuccessCount ?? 0 }} 次 /
|
||||||
|
{{ draft.pushShopCount ?? 0 }} 店
|
||||||
|
</DescriptionsItem>
|
||||||
|
<DescriptionsItem label="已发布 / 店">
|
||||||
|
{{ draft.publishSuccessCount ?? 0 }} 次 /
|
||||||
|
{{ draft.publishShopCount ?? 0 }} 店
|
||||||
|
</DescriptionsItem>
|
||||||
|
<DescriptionsItem
|
||||||
|
v-if="parsed.editor.marketPriceYuan != null"
|
||||||
|
label="参考价"
|
||||||
|
>
|
||||||
|
{{ formatPrice(parsed.editor.marketPriceYuan) }}
|
||||||
|
</DescriptionsItem>
|
||||||
|
<DescriptionsItem label="创建时间">
|
||||||
|
{{ draft.createTime || '—' }}
|
||||||
|
</DescriptionsItem>
|
||||||
|
<DescriptionsItem label="更新时间">
|
||||||
|
{{ draft.updateTime || '—' }}
|
||||||
|
</DescriptionsItem>
|
||||||
|
<DescriptionsItem
|
||||||
|
v-if="parsed.editor.goodsDesc"
|
||||||
|
label="商品描述"
|
||||||
|
:span="2"
|
||||||
|
>
|
||||||
|
<div class="whitespace-pre-wrap text-sm">
|
||||||
|
{{ parsed.editor.goodsDesc }}
|
||||||
|
</div>
|
||||||
|
</DescriptionsItem>
|
||||||
|
<DescriptionsItem
|
||||||
|
v-if="draft.lastError"
|
||||||
|
label="最近错误"
|
||||||
|
:span="2"
|
||||||
|
>
|
||||||
|
<span class="text-red-500">{{ draft.lastError }}</span>
|
||||||
|
</DescriptionsItem>
|
||||||
|
</Descriptions>
|
||||||
|
|
||||||
|
<Spin :spinning="imagesLoading">
|
||||||
|
<div class="mb-4">
|
||||||
|
<div class="mb-2 text-sm font-medium">轮播图</div>
|
||||||
|
<Image.PreviewGroup v-if="carouselImages.length > 0">
|
||||||
|
<div class="flex flex-wrap gap-2">
|
||||||
|
<Image
|
||||||
|
v-for="img in carouselImages"
|
||||||
|
:key="img.key"
|
||||||
|
:src="img.url"
|
||||||
|
:alt="img.alt"
|
||||||
|
:width="88"
|
||||||
|
:height="88"
|
||||||
|
class="rounded object-cover"
|
||||||
|
:style="{ objectFit: 'cover' }"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</Image.PreviewGroup>
|
||||||
|
<div v-else class="text-muted-foreground text-sm">暂无轮播图</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="mb-4">
|
||||||
|
<div class="mb-2 text-sm font-medium">详情图</div>
|
||||||
|
<Image.PreviewGroup v-if="detailImages.length > 0">
|
||||||
|
<div class="flex flex-wrap gap-2">
|
||||||
|
<Image
|
||||||
|
v-for="img in detailImages"
|
||||||
|
:key="img.key"
|
||||||
|
:src="img.url"
|
||||||
|
:alt="img.alt"
|
||||||
|
:width="88"
|
||||||
|
:height="88"
|
||||||
|
class="rounded object-cover"
|
||||||
|
:style="{ objectFit: 'cover' }"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</Image.PreviewGroup>
|
||||||
|
<div v-else class="text-muted-foreground text-sm">暂无详情图</div>
|
||||||
|
</div>
|
||||||
|
</Spin>
|
||||||
|
|
||||||
|
<div class="text-sm font-medium">SKU 明细</div>
|
||||||
|
<Table
|
||||||
|
size="small"
|
||||||
|
:pagination="false"
|
||||||
|
:scroll="{ x: 720 }"
|
||||||
|
:columns="skuColumns"
|
||||||
|
:data-source="skuRowsForTable"
|
||||||
|
row-key="key"
|
||||||
|
:locale="{ emptyText: '暂无 SKU 数据(请先在编辑页保存)' }"
|
||||||
|
>
|
||||||
|
<template #bodyCell="{ column: col, record: sku }">
|
||||||
|
<template v-if="col.key === 'thumb'">
|
||||||
|
<Image
|
||||||
|
v-if="sku.thumbUrl"
|
||||||
|
:src="sku.thumbUrl"
|
||||||
|
:width="48"
|
||||||
|
:height="48"
|
||||||
|
class="rounded object-cover"
|
||||||
|
:style="{ objectFit: 'cover' }"
|
||||||
|
/>
|
||||||
|
<span v-else class="text-muted-foreground text-xs">—</span>
|
||||||
|
</template>
|
||||||
|
<template v-else-if="col.key === 'priceYuan'">
|
||||||
|
{{ formatPrice(sku.priceYuan) }}
|
||||||
|
</template>
|
||||||
|
<template v-else-if="col.key === 'multiPriceYuan'">
|
||||||
|
{{ formatPrice(sku.multiPriceYuan) }}
|
||||||
|
</template>
|
||||||
|
</template>
|
||||||
|
</Table>
|
||||||
|
</div>
|
||||||
|
</Spin>
|
||||||
|
</Modal>
|
||||||
|
</template>
|
||||||
@@ -34,6 +34,8 @@ import { getPddShopPageApi } from '#/api/channel/pdd/shop';
|
|||||||
import { PermissionGate } from '#/components/permission';
|
import { PermissionGate } from '#/components/permission';
|
||||||
import PddShopColPage from '#/views/channel/pdd/components/PddShopColPage.vue';
|
import PddShopColPage from '#/views/channel/pdd/components/PddShopColPage.vue';
|
||||||
|
|
||||||
|
import PddPublishDraftDetailModal from './PddPublishDraftDetailModal.vue';
|
||||||
|
|
||||||
defineOptions({ name: 'PddGoodsPublishDesk' });
|
defineOptions({ name: 'PddGoodsPublishDesk' });
|
||||||
|
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
@@ -62,6 +64,10 @@ const currentJob = ref<PddPublishDeskVO.Job | null>(null);
|
|||||||
const pushingDraftId = ref<number | null>(null);
|
const pushingDraftId = ref<number | null>(null);
|
||||||
let jobPollTimer: ReturnType<typeof setInterval> | undefined;
|
let jobPollTimer: ReturnType<typeof setInterval> | undefined;
|
||||||
|
|
||||||
|
const detailOpen = ref(false);
|
||||||
|
const detailDraftId = ref<number | undefined>();
|
||||||
|
const detailPreview = ref<PddPublishDeskVO.Draft | null>(null);
|
||||||
|
|
||||||
const statusLabel: Record<string, { text: string; color: string }> = {
|
const statusLabel: Record<string, { text: string; color: string }> = {
|
||||||
EDITING: { text: '编辑中', color: 'default' },
|
EDITING: { text: '编辑中', color: 'default' },
|
||||||
NEED_CHECK: { text: '待校验', color: 'orange' },
|
NEED_CHECK: { text: '待校验', color: 'orange' },
|
||||||
@@ -326,6 +332,12 @@ function openEdit(id: number) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function openDraftDetail(record: PddPublishDeskVO.Draft) {
|
||||||
|
detailDraftId.value = record.id;
|
||||||
|
detailPreview.value = record;
|
||||||
|
detailOpen.value = true;
|
||||||
|
}
|
||||||
|
|
||||||
async function removeDraft(id: number) {
|
async function removeDraft(id: number) {
|
||||||
Modal.confirm({
|
Modal.confirm({
|
||||||
title: '删除草稿?',
|
title: '删除草稿?',
|
||||||
@@ -544,7 +556,16 @@ onUnmounted(() => stopJobPoll());
|
|||||||
:locale="{ emptyText: '暂无系统草稿' }"
|
:locale="{ emptyText: '暂无系统草稿' }"
|
||||||
>
|
>
|
||||||
<template #bodyCell="{ column, record }">
|
<template #bodyCell="{ column, record }">
|
||||||
<template v-if="column.key === 'skuCount'">
|
<template v-if="column.key === 'title'">
|
||||||
|
<Button
|
||||||
|
type="link"
|
||||||
|
class="h-auto max-w-full px-0 text-left"
|
||||||
|
@click="openDraftDetail(record)"
|
||||||
|
>
|
||||||
|
<span class="truncate">{{ record.title }}</span>
|
||||||
|
</Button>
|
||||||
|
</template>
|
||||||
|
<template v-else-if="column.key === 'skuCount'">
|
||||||
<Popover
|
<Popover
|
||||||
v-if="getDraftSkuPreviews(record).length > 0"
|
v-if="getDraftSkuPreviews(record).length > 0"
|
||||||
trigger="hover"
|
trigger="hover"
|
||||||
@@ -690,6 +711,13 @@ onUnmounted(() => stopJobPoll());
|
|||||||
</div>
|
</div>
|
||||||
</Modal>
|
</Modal>
|
||||||
|
|
||||||
|
<PddPublishDraftDetailModal
|
||||||
|
v-model:open="detailOpen"
|
||||||
|
:draft-id="detailDraftId"
|
||||||
|
:preview="detailPreview"
|
||||||
|
@edit="openEdit"
|
||||||
|
/>
|
||||||
|
|
||||||
<Modal
|
<Modal
|
||||||
v-model:open="jobOpen"
|
v-model:open="jobOpen"
|
||||||
title="批量发布进度"
|
title="批量发布进度"
|
||||||
|
|||||||
Reference in New Issue
Block a user