mirror of
https://gitee.com/qqtt-ah/ecom-dmb.git
synced 2026-11-23 23:19:19 +08:00
feat: 渠道店铺页接入订单同步与转换数据流
This commit is contained in:
@@ -24,6 +24,8 @@ export namespace PddShopVO {
|
|||||||
export interface Info {
|
export interface Info {
|
||||||
id: number;
|
id: number;
|
||||||
companyId?: number;
|
companyId?: number;
|
||||||
|
/** 绑定的经营店铺 id;未绑定则为空 */
|
||||||
|
ecShopId?: null | number;
|
||||||
pddAuthId?: null | number;
|
pddAuthId?: null | number;
|
||||||
auth?: AuthInfo | null;
|
auth?: AuthInfo | null;
|
||||||
mallId?: number;
|
mallId?: number;
|
||||||
|
|||||||
+229
@@ -0,0 +1,229 @@
|
|||||||
|
<script lang="ts" setup>
|
||||||
|
/**
|
||||||
|
* 渠道店铺列表:订单同步→转换状态卡(点击打开管线抽屉)。
|
||||||
|
* 不展示 BI 计算(属经营店铺侧)。
|
||||||
|
*/
|
||||||
|
import type { PddOrderSyncVO } from '#/api/channel/pdd/order-sync';
|
||||||
|
|
||||||
|
import { computed } from 'vue';
|
||||||
|
|
||||||
|
import { createIconifyIcon } from '@vben/icons';
|
||||||
|
|
||||||
|
import dayjs from 'dayjs';
|
||||||
|
|
||||||
|
defineOptions({ name: 'PddShopOrderFlowCell' });
|
||||||
|
|
||||||
|
export type OrderFlowStageKey = 'convert' | 'sync';
|
||||||
|
|
||||||
|
const props = defineProps<{
|
||||||
|
/** 是否已授权 */
|
||||||
|
authorized: boolean;
|
||||||
|
/** 是否已绑经营店铺(有 ecShopId 才能调订单管线 API) */
|
||||||
|
bound: boolean;
|
||||||
|
status?: null | PddOrderSyncVO.ShopStatus;
|
||||||
|
}>();
|
||||||
|
|
||||||
|
const emit = defineEmits<{
|
||||||
|
open: [stage: OrderFlowStageKey];
|
||||||
|
}>();
|
||||||
|
|
||||||
|
const IconSync = createIconifyIcon('lucide:refresh-cw');
|
||||||
|
const IconConvert = createIconifyIcon('lucide:shuffle');
|
||||||
|
const IconArrow = createIconifyIcon('lucide:chevron-right');
|
||||||
|
const IconLinkOff = createIconifyIcon('lucide:unplug');
|
||||||
|
const IconLock = createIconifyIcon('lucide:shield-off');
|
||||||
|
|
||||||
|
type Tone = 'error' | 'idle' | 'off' | 'ok' | 'warn';
|
||||||
|
|
||||||
|
function formatRelative(time?: null | string) {
|
||||||
|
if (!time) return '';
|
||||||
|
const d = dayjs(time);
|
||||||
|
if (!d.isValid()) return '';
|
||||||
|
const mins = dayjs().diff(d, 'minute');
|
||||||
|
if (mins < 1) return '刚刚';
|
||||||
|
if (mins < 60) return `${mins} 分钟前`;
|
||||||
|
const hours = dayjs().diff(d, 'hour');
|
||||||
|
if (hours < 24) return `${hours} 小时前`;
|
||||||
|
const days = dayjs().diff(d, 'day');
|
||||||
|
if (days < 30) return `${days} 天前`;
|
||||||
|
return d.format('MM-DD');
|
||||||
|
}
|
||||||
|
|
||||||
|
function toneFromInc(status?: null | PddOrderSyncVO.ShopStatus): Tone {
|
||||||
|
const health = status?.incremental?.health;
|
||||||
|
if (health === 'PAUSED') return 'error';
|
||||||
|
if (health === 'LAGGING') return 'warn';
|
||||||
|
if (health === 'OK') return 'ok';
|
||||||
|
if (health === 'OFF' || !status?.incremental?.enabled) return 'off';
|
||||||
|
return 'idle';
|
||||||
|
}
|
||||||
|
|
||||||
|
function toneFromConvert(status?: null | PddOrderSyncVO.ShopStatus): Tone {
|
||||||
|
const summary = status?.convert?.lastSummary;
|
||||||
|
const st = status?.convert?.status;
|
||||||
|
if (st === 2 || (summary && (summary.includes('失败') || summary.includes('限流')))) {
|
||||||
|
return 'error';
|
||||||
|
}
|
||||||
|
if (summary) return 'ok';
|
||||||
|
return 'idle';
|
||||||
|
}
|
||||||
|
|
||||||
|
function toneLabel(tone: Tone) {
|
||||||
|
const map: Record<Tone, string> = {
|
||||||
|
ok: '正常',
|
||||||
|
warn: '滞后',
|
||||||
|
error: '异常',
|
||||||
|
off: '关闭',
|
||||||
|
idle: '待命',
|
||||||
|
};
|
||||||
|
return map[tone];
|
||||||
|
}
|
||||||
|
|
||||||
|
const syncTone = computed(() => toneFromInc(props.status));
|
||||||
|
const convertTone = computed(() => toneFromConvert(props.status));
|
||||||
|
|
||||||
|
const footerHint = computed(() => {
|
||||||
|
const syncInc = formatRelative(props.status?.incremental?.lastSuccessTime);
|
||||||
|
const syncFull = formatRelative(props.status?.lastFullSyncSuccessTime);
|
||||||
|
const parts: string[] = [];
|
||||||
|
if (syncInc) parts.push(`增量 ${syncInc}`);
|
||||||
|
if (syncFull) parts.push(`全量 ${syncFull}`);
|
||||||
|
return parts.length > 0 ? parts.join(' · ') : '点击管理同步与转换';
|
||||||
|
});
|
||||||
|
|
||||||
|
const blockedReason = computed(() => {
|
||||||
|
if (!props.authorized) return '未授权,无法拉订单';
|
||||||
|
if (!props.bound) return '未绑定经营店铺';
|
||||||
|
return '';
|
||||||
|
});
|
||||||
|
|
||||||
|
const canOpen = computed(() => props.authorized && props.bound);
|
||||||
|
|
||||||
|
function onOpen(stage: OrderFlowStageKey, e?: Event) {
|
||||||
|
e?.stopPropagation();
|
||||||
|
if (!canOpen.value) return;
|
||||||
|
emit('open', stage);
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div
|
||||||
|
v-if="!canOpen"
|
||||||
|
class="flow-blocked flex min-w-[220px] items-center gap-2 rounded-[12px] border border-dashed border-slate-200/90 bg-slate-50/80 px-3 py-2 dark:border-slate-700/60 dark:bg-slate-900/40"
|
||||||
|
>
|
||||||
|
<component
|
||||||
|
:is="!authorized ? IconLock : IconLinkOff"
|
||||||
|
class="size-4 shrink-0 text-slate-400"
|
||||||
|
/>
|
||||||
|
<div class="min-w-0">
|
||||||
|
<div class="text-xs font-medium text-slate-500 dark:text-slate-400">
|
||||||
|
订单数据流
|
||||||
|
</div>
|
||||||
|
<div class="truncate text-[11px] text-slate-400 dark:text-slate-500">
|
||||||
|
{{ blockedReason }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<button
|
||||||
|
v-else
|
||||||
|
type="button"
|
||||||
|
class="flow-card group relative flex min-w-[240px] max-w-[320px] flex-col gap-1 rounded-[12px] border border-orange-200/70 bg-gradient-to-br from-orange-50/90 via-white to-amber-50/60 px-2.5 py-2 text-left shadow-[0_1px_2px_rgba(234,88,12,0.04)] transition hover:border-orange-300 hover:shadow-[0_4px_14px_rgba(234,88,12,0.08)] dark:border-orange-900/40 dark:from-orange-950/30 dark:via-slate-900/40 dark:to-amber-950/20 dark:hover:border-orange-700/50"
|
||||||
|
@click="onOpen('sync')"
|
||||||
|
>
|
||||||
|
<div class="flex items-center gap-1.5">
|
||||||
|
<span
|
||||||
|
class="rounded-full bg-orange-100/90 px-1.5 py-px text-[10px] font-semibold tracking-wide text-orange-800 dark:bg-orange-950/50 dark:text-orange-300"
|
||||||
|
>
|
||||||
|
订单
|
||||||
|
</span>
|
||||||
|
<span class="text-[10px] text-slate-400 dark:text-slate-500">
|
||||||
|
同步 → 转换
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="flex items-stretch gap-1">
|
||||||
|
<div
|
||||||
|
class="flow-node flex min-w-0 flex-1 cursor-pointer items-center gap-1.5 rounded-[10px] px-1.5 py-1 transition hover:bg-white/80 dark:hover:bg-slate-800/60"
|
||||||
|
:class="`tone-${syncTone}`"
|
||||||
|
@click="onOpen('sync', $event)"
|
||||||
|
>
|
||||||
|
<span
|
||||||
|
class="flex size-6 shrink-0 items-center justify-center rounded-md bg-white/90 shadow-sm dark:bg-slate-800/80"
|
||||||
|
>
|
||||||
|
<component :is="IconSync" class="size-3.5" />
|
||||||
|
</span>
|
||||||
|
<div class="min-w-0">
|
||||||
|
<div class="text-[11px] font-semibold leading-tight text-slate-800 dark:text-slate-100">
|
||||||
|
同步
|
||||||
|
</div>
|
||||||
|
<div class="text-[10px] leading-tight opacity-90">
|
||||||
|
{{ toneLabel(syncTone) }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="flex shrink-0 items-center text-slate-300 dark:text-slate-600">
|
||||||
|
<component :is="IconArrow" class="size-4" />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div
|
||||||
|
class="flow-node flex min-w-0 flex-1 cursor-pointer items-center gap-1.5 rounded-[10px] px-1.5 py-1 transition hover:bg-white/80 dark:hover:bg-slate-800/60"
|
||||||
|
:class="`tone-${convertTone}`"
|
||||||
|
@click="onOpen('convert', $event)"
|
||||||
|
>
|
||||||
|
<span
|
||||||
|
class="flex size-6 shrink-0 items-center justify-center rounded-md bg-white/90 shadow-sm dark:bg-slate-800/80"
|
||||||
|
>
|
||||||
|
<component :is="IconConvert" class="size-3.5" />
|
||||||
|
</span>
|
||||||
|
<div class="min-w-0">
|
||||||
|
<div class="text-[11px] font-semibold leading-tight text-slate-800 dark:text-slate-100">
|
||||||
|
转换
|
||||||
|
</div>
|
||||||
|
<div class="text-[10px] leading-tight opacity-90">
|
||||||
|
{{ toneLabel(convertTone) }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div
|
||||||
|
class="truncate text-[10px] leading-tight text-slate-500 group-hover:text-orange-700/80 dark:text-slate-400 dark:group-hover:text-orange-300/80"
|
||||||
|
>
|
||||||
|
{{ footerHint }}
|
||||||
|
</div>
|
||||||
|
</button>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.tone-ok {
|
||||||
|
color: rgb(5 150 105);
|
||||||
|
}
|
||||||
|
.tone-warn {
|
||||||
|
color: rgb(217 119 6);
|
||||||
|
}
|
||||||
|
.tone-error {
|
||||||
|
color: rgb(225 29 72);
|
||||||
|
}
|
||||||
|
.tone-off {
|
||||||
|
color: rgb(100 116 139);
|
||||||
|
}
|
||||||
|
.tone-idle {
|
||||||
|
color: rgb(148 163 184);
|
||||||
|
}
|
||||||
|
|
||||||
|
:global(.dark) .tone-ok {
|
||||||
|
color: rgb(52 211 153);
|
||||||
|
}
|
||||||
|
:global(.dark) .tone-warn {
|
||||||
|
color: rgb(251 191 36);
|
||||||
|
}
|
||||||
|
:global(.dark) .tone-error {
|
||||||
|
color: rgb(251 113 133);
|
||||||
|
}
|
||||||
|
:global(.dark) .tone-off,
|
||||||
|
:global(.dark) .tone-idle {
|
||||||
|
color: rgb(148 163 184);
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -1,7 +1,10 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import type { VxeGridProps } from '#/adapter/vxe-table';
|
import type { VxeGridProps } from '#/adapter/vxe-table';
|
||||||
import type { PddShopDTO, PddShopVO } from '#/api/channel/pdd/shop';
|
import type { PddShopDTO, PddShopVO } from '#/api/channel/pdd/shop';
|
||||||
|
import type { PddOrderSyncVO } from '#/api/channel/pdd/order-sync';
|
||||||
import type { PageQueryDTO } from '#/types/common';
|
import type { PageQueryDTO } from '#/types/common';
|
||||||
|
import type { OrderFlowStageKey } from './components/PddShopOrderFlowCell.vue';
|
||||||
|
import type { PipelineStageKey } from '#/views/ec/shop/list/components/ShopOrderPipelineDrawer.vue';
|
||||||
|
|
||||||
import { computed, ref } from 'vue';
|
import { computed, ref } from 'vue';
|
||||||
|
|
||||||
@@ -10,16 +13,20 @@ import { Page } from '@vben/common-ui';
|
|||||||
import { Button, Image, Space, Tag, message } from 'ant-design-vue';
|
import { Button, Image, Space, Tag, message } from 'ant-design-vue';
|
||||||
|
|
||||||
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||||
import {
|
import { getPddShopPageApi } from '#/api/channel/pdd/shop';
|
||||||
getPddShopPageApi,
|
|
||||||
} from '#/api/channel/pdd/shop';
|
|
||||||
import { syncPddGoodsByShopApi } from '#/api/channel/pdd/goods';
|
import { syncPddGoodsByShopApi } from '#/api/channel/pdd/goods';
|
||||||
|
import { batchPddOrderSyncStatusApi } from '#/api/channel/pdd/order-sync';
|
||||||
import { PermissionGate } from '#/components/permission';
|
import { PermissionGate } from '#/components/permission';
|
||||||
|
|
||||||
import PddShopDetailModal from './components/PddShopDetailModal.vue';
|
import PddShopDetailModal from './components/PddShopDetailModal.vue';
|
||||||
|
import PddShopOrderFlowCell from './components/PddShopOrderFlowCell.vue';
|
||||||
|
import ShopOrderPipelineDrawer from '#/views/ec/shop/list/components/ShopOrderPipelineDrawer.vue';
|
||||||
|
|
||||||
defineOptions({ name: 'PddShopManagement' });
|
defineOptions({ name: 'PddShopManagement' });
|
||||||
|
|
||||||
|
/** 渠道页只管同步/转换;BI 计算留在经营店铺 */
|
||||||
|
const CHANNEL_ORDER_STAGES: PipelineStageKey[] = ['sync', 'convert'];
|
||||||
|
|
||||||
const MERCHANT_TYPE_MAP: Record<number, string> = {
|
const MERCHANT_TYPE_MAP: Record<number, string> = {
|
||||||
1: '个人',
|
1: '个人',
|
||||||
2: '企业',
|
2: '企业',
|
||||||
@@ -38,6 +45,11 @@ const AUTH_STATUS_MAP: Record<number, { color: string; text: string }> = {
|
|||||||
const loading = ref(false);
|
const loading = ref(false);
|
||||||
const syncingShopId = ref<null | number>(null);
|
const syncingShopId = ref<null | number>(null);
|
||||||
const shopDetailModalRef = ref<InstanceType<typeof PddShopDetailModal>>();
|
const shopDetailModalRef = ref<InstanceType<typeof PddShopDetailModal>>();
|
||||||
|
const pipelineDrawerRef =
|
||||||
|
ref<InstanceType<typeof ShopOrderPipelineDrawer>>();
|
||||||
|
|
||||||
|
/** 经营店 id → 同步/转换摘要 */
|
||||||
|
const orderFlowStatusMap = ref<Record<number, PddOrderSyncVO.ShopStatus>>({});
|
||||||
|
|
||||||
const searchForm = ref({
|
const searchForm = ref({
|
||||||
mallName: '',
|
mallName: '',
|
||||||
@@ -77,9 +89,16 @@ const gridOptions: VxeGridProps<PddShopVO.Info> = {
|
|||||||
minWidth: 140,
|
minWidth: 140,
|
||||||
slots: { default: 'auth' },
|
slots: { default: 'auth' },
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
title: '订单数据流',
|
||||||
|
minWidth: 280,
|
||||||
|
align: 'center' as const,
|
||||||
|
showOverflow: false,
|
||||||
|
slots: { default: 'orderFlow' },
|
||||||
|
},
|
||||||
{
|
{
|
||||||
field: 'lastSyncTime',
|
field: 'lastSyncTime',
|
||||||
title: '店铺最近同步',
|
title: '店铺资料同步',
|
||||||
minWidth: 160,
|
minWidth: 160,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -98,7 +117,7 @@ const gridOptions: VxeGridProps<PddShopVO.Info> = {
|
|||||||
height: 'auto',
|
height: 'auto',
|
||||||
border: true,
|
border: true,
|
||||||
stripe: true,
|
stripe: true,
|
||||||
rowConfig: { isHover: true, height: 72 },
|
rowConfig: { isHover: true, height: 118 },
|
||||||
showOverflow: true,
|
showOverflow: true,
|
||||||
size: 'small',
|
size: 'small',
|
||||||
toolbarConfig: {
|
toolbarConfig: {
|
||||||
@@ -144,8 +163,10 @@ const gridOptions: VxeGridProps<PddShopVO.Info> = {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
const data = await getPddShopPageApi(params);
|
const data = await getPddShopPageApi(params);
|
||||||
|
const records = data.records ?? [];
|
||||||
|
await loadOrderFlowStatus(records);
|
||||||
return {
|
return {
|
||||||
items: data.records ?? [],
|
items: records,
|
||||||
total: data.total ?? 0,
|
total: data.total ?? 0,
|
||||||
};
|
};
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -231,11 +252,67 @@ function authTag(row: PddShopVO.Info) {
|
|||||||
return AUTH_STATUS_MAP[status] ?? { color: 'default', text: String(status) };
|
return AUTH_STATUS_MAP[status] ?? { color: 'default', text: String(status) };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function isAuthorized(row: PddShopVO.Info) {
|
||||||
|
return row.pddAuthId != null && row.auth?.status !== 0 && row.auth?.status !== 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
function isBound(row: PddShopVO.Info) {
|
||||||
|
return row.ecShopId != null && row.ecShopId > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function loadOrderFlowStatus(records: PddShopVO.Info[]) {
|
||||||
|
const ecIds = [
|
||||||
|
...new Set(
|
||||||
|
records
|
||||||
|
.map((r) => r.ecShopId)
|
||||||
|
.filter((id): id is number => id != null && id > 0),
|
||||||
|
),
|
||||||
|
];
|
||||||
|
if (ecIds.length === 0) {
|
||||||
|
orderFlowStatusMap.value = {};
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
const list = await batchPddOrderSyncStatusApi(ecIds);
|
||||||
|
const map: Record<number, PddOrderSyncVO.ShopStatus> = {};
|
||||||
|
for (const item of list || []) {
|
||||||
|
map[item.shopId] = item;
|
||||||
|
}
|
||||||
|
orderFlowStatusMap.value = map;
|
||||||
|
} catch (error) {
|
||||||
|
console.error('加载订单数据流状态失败:', error);
|
||||||
|
orderFlowStatusMap.value = {};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function openShopDetail(row: PddShopVO.Info) {
|
function openShopDetail(row: PddShopVO.Info) {
|
||||||
if (!row?.id) return;
|
if (!row?.id) return;
|
||||||
shopDetailModalRef.value?.open(row.id);
|
shopDetailModalRef.value?.open(row.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function openOrderFlow(row: PddShopVO.Info, stage: OrderFlowStageKey) {
|
||||||
|
if (!isAuthorized(row)) {
|
||||||
|
message.warning('该店铺尚未授权,无法管理订单数据流');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!isBound(row) || !row.ecShopId) {
|
||||||
|
message.warning('请先在经营店铺中绑定该渠道店');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
pipelineDrawerRef.value?.open(
|
||||||
|
{
|
||||||
|
id: row.ecShopId,
|
||||||
|
name: row.mallName || `mall ${row.mallId ?? row.id}`,
|
||||||
|
},
|
||||||
|
stage,
|
||||||
|
{ stages: CHANNEL_ORDER_STAGES },
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function onPipelineSuccess() {
|
||||||
|
gridApi.reload();
|
||||||
|
}
|
||||||
|
|
||||||
async function handleSyncGoods(row: PddShopVO.Info) {
|
async function handleSyncGoods(row: PddShopVO.Info) {
|
||||||
if (!row?.id) return;
|
if (!row?.id) return;
|
||||||
if (row.pddAuthId == null) {
|
if (row.pddAuthId == null) {
|
||||||
@@ -304,11 +381,34 @@ async function handleSyncGoods(row: PddShopVO.Info) {
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
<template #orderFlow="{ row }: { row: PddShopVO.Info }">
|
||||||
|
<div class="flex w-full justify-center">
|
||||||
|
<PddShopOrderFlowCell
|
||||||
|
:authorized="isAuthorized(row)"
|
||||||
|
:bound="isBound(row)"
|
||||||
|
:status="
|
||||||
|
row.ecShopId != null
|
||||||
|
? orderFlowStatusMap[row.ecShopId]
|
||||||
|
: undefined
|
||||||
|
"
|
||||||
|
@open="(stage) => openOrderFlow(row, stage)"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
<template #action="{ row }: { row: PddShopVO.Info }">
|
<template #action="{ row }: { row: PddShopVO.Info }">
|
||||||
<Space size="small" :wrap="false">
|
<Space size="small" :wrap="false">
|
||||||
<Button type="link" size="small" @click="openShopDetail(row)">
|
<Button type="link" size="small" @click="openShopDetail(row)">
|
||||||
详情
|
详情
|
||||||
</Button>
|
</Button>
|
||||||
|
<Button
|
||||||
|
v-if="isAuthorized(row) && isBound(row)"
|
||||||
|
type="link"
|
||||||
|
size="small"
|
||||||
|
@click="openOrderFlow(row, 'sync')"
|
||||||
|
>
|
||||||
|
订单数据流
|
||||||
|
</Button>
|
||||||
<PermissionGate code="channel:pdd:goods:sync">
|
<PermissionGate code="channel:pdd:goods:sync">
|
||||||
<Button
|
<Button
|
||||||
type="link"
|
type="link"
|
||||||
@@ -325,6 +425,10 @@ async function handleSyncGoods(row: PddShopVO.Info) {
|
|||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
<PddShopDetailModal ref="shopDetailModalRef" />
|
<PddShopDetailModal ref="shopDetailModalRef" />
|
||||||
|
<ShopOrderPipelineDrawer
|
||||||
|
ref="pipelineDrawerRef"
|
||||||
|
@success="onPipelineSuccess"
|
||||||
|
/>
|
||||||
</Page>
|
</Page>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -337,4 +441,13 @@ async function handleSyncGoods(row: PddShopVO.Info) {
|
|||||||
:deep(.pdd-shop-grid .vxe-body--column) {
|
:deep(.pdd-shop-grid .vxe-body--column) {
|
||||||
vertical-align: middle;
|
vertical-align: middle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
:deep(.pdd-shop-grid .vxe-body--row) {
|
||||||
|
height: 118px !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
:deep(.pdd-shop-grid .vxe-cell) {
|
||||||
|
max-height: none;
|
||||||
|
overflow: visible;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
+51
-12
@@ -2,8 +2,8 @@
|
|||||||
/**
|
/**
|
||||||
* 店铺订单管线抽屉:同步 / 转换 / 计算 三阶段合一。
|
* 店铺订单管线抽屉:同步 / 转换 / 计算 三阶段合一。
|
||||||
* 顶区状态+动作;历史全量任务用紧凑表;创建全量内联,不再套第二层弹窗。
|
* 顶区状态+动作;历史全量任务用紧凑表;创建全量内联,不再套第二层弹窗。
|
||||||
|
* shopId 为经营店铺 id(API 约定);可由渠道店页传入仅含 id/name 的引用。
|
||||||
*/
|
*/
|
||||||
import type { ShopVO } from '#/api/ec/shop/types';
|
|
||||||
import type { PddOrderSyncVO } from '#/api/channel/pdd/order-sync';
|
import type { PddOrderSyncVO } from '#/api/channel/pdd/order-sync';
|
||||||
import type { PddOrderConvertVO } from '#/api/channel/pdd/order-convert';
|
import type { PddOrderConvertVO } from '#/api/channel/pdd/order-convert';
|
||||||
import type { BiOrderStatCalcVO } from '#/api/bi/order-stat-calc';
|
import type { BiOrderStatCalcVO } from '#/api/bi/order-stat-calc';
|
||||||
@@ -56,7 +56,26 @@ import { useRealtimeStore } from '#/store';
|
|||||||
|
|
||||||
defineOptions({ name: 'ShopOrderPipelineDrawer' });
|
defineOptions({ name: 'ShopOrderPipelineDrawer' });
|
||||||
|
|
||||||
type PipelineStageKey = 'calc' | 'convert' | 'sync';
|
export type PipelineStageKey = 'calc' | 'convert' | 'sync';
|
||||||
|
|
||||||
|
/** 管线抽屉店铺引用:至少经营店 id + 展示名 */
|
||||||
|
export type PipelineShopRef = {
|
||||||
|
id: number;
|
||||||
|
name: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type PipelineDrawerOpenOptions = {
|
||||||
|
/** 可切换阶段;默认同步/转换/计算全开 */
|
||||||
|
stages?: PipelineStageKey[];
|
||||||
|
};
|
||||||
|
|
||||||
|
const ALL_STAGES: PipelineStageKey[] = ['sync', 'convert', 'calc'];
|
||||||
|
|
||||||
|
const STAGE_LABEL: Record<PipelineStageKey, string> = {
|
||||||
|
sync: '同步',
|
||||||
|
convert: '转换',
|
||||||
|
calc: '计算',
|
||||||
|
};
|
||||||
|
|
||||||
const emit = defineEmits<{ success: [] }>();
|
const emit = defineEmits<{ success: [] }>();
|
||||||
|
|
||||||
@@ -82,7 +101,8 @@ type FullTaskRow = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const openFlag = ref(false);
|
const openFlag = ref(false);
|
||||||
const shop = ref<null | ShopVO.Info>(null);
|
const shop = ref<null | PipelineShopRef>(null);
|
||||||
|
const enabledStages = ref<PipelineStageKey[]>([...ALL_STAGES]);
|
||||||
const stage = ref<PipelineStageKey>('sync');
|
const stage = ref<PipelineStageKey>('sync');
|
||||||
const pageLoading = ref(false);
|
const pageLoading = ref(false);
|
||||||
|
|
||||||
@@ -122,11 +142,14 @@ const title = computed(() =>
|
|||||||
shop.value ? `订单数据流 · ${shop.value.name}` : '订单数据流',
|
shop.value ? `订单数据流 · ${shop.value.name}` : '订单数据流',
|
||||||
);
|
);
|
||||||
|
|
||||||
const stageOptions = [
|
const stageOptions = computed(() =>
|
||||||
{ label: '同步', value: 'sync' },
|
enabledStages.value.map((value) => ({
|
||||||
{ label: '转换', value: 'convert' },
|
label: STAGE_LABEL[value],
|
||||||
{ label: '计算', value: 'calc' },
|
value,
|
||||||
];
|
})),
|
||||||
|
);
|
||||||
|
|
||||||
|
const showStageTabs = computed(() => enabledStages.value.length > 1);
|
||||||
|
|
||||||
const hasActiveSyncTask = computed(() =>
|
const hasActiveSyncTask = computed(() =>
|
||||||
syncTasks.value.some((t) => t.status === 'PENDING' || t.status === 'RUNNING'),
|
syncTasks.value.some((t) => t.status === 'PENDING' || t.status === 'RUNNING'),
|
||||||
@@ -622,9 +645,18 @@ function handleClose() {
|
|||||||
openFlag.value = false;
|
openFlag.value = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function open(record: ShopVO.Info, initial: PipelineStageKey = 'sync') {
|
async function open(
|
||||||
shop.value = record;
|
record: PipelineShopRef,
|
||||||
stage.value = initial;
|
initial: PipelineStageKey = 'sync',
|
||||||
|
options?: PipelineDrawerOpenOptions,
|
||||||
|
) {
|
||||||
|
shop.value = { id: record.id, name: record.name };
|
||||||
|
const stages =
|
||||||
|
options?.stages && options.stages.length > 0
|
||||||
|
? options.stages
|
||||||
|
: [...ALL_STAGES];
|
||||||
|
enabledStages.value = stages;
|
||||||
|
stage.value = stages.includes(initial) ? initial : (stages[0] ?? 'sync');
|
||||||
syncInc.value = null;
|
syncInc.value = null;
|
||||||
syncTasks.value = [];
|
syncTasks.value = [];
|
||||||
convertInc.value = null;
|
convertInc.value = null;
|
||||||
@@ -638,7 +670,7 @@ async function open(record: ShopVO.Info, initial: PipelineStageKey = 'sync') {
|
|||||||
openFlag.value = true;
|
openFlag.value = true;
|
||||||
pageLoading.value = true;
|
pageLoading.value = true;
|
||||||
try {
|
try {
|
||||||
await loadStage(initial);
|
await loadStage(stage.value);
|
||||||
} finally {
|
} finally {
|
||||||
pageLoading.value = false;
|
pageLoading.value = false;
|
||||||
}
|
}
|
||||||
@@ -674,10 +706,17 @@ defineExpose({ open, close: handleClose });
|
|||||||
>
|
>
|
||||||
<div class="flex h-full min-h-0 flex-col gap-4">
|
<div class="flex h-full min-h-0 flex-col gap-4">
|
||||||
<Segmented
|
<Segmented
|
||||||
|
v-if="showStageTabs"
|
||||||
v-model:value="stage"
|
v-model:value="stage"
|
||||||
block
|
block
|
||||||
:options="stageOptions"
|
:options="stageOptions"
|
||||||
/>
|
/>
|
||||||
|
<div
|
||||||
|
v-else
|
||||||
|
class="text-sm font-medium text-slate-700 dark:text-slate-200"
|
||||||
|
>
|
||||||
|
{{ STAGE_LABEL[stage] }}
|
||||||
|
</div>
|
||||||
|
|
||||||
<!-- 同步 -->
|
<!-- 同步 -->
|
||||||
<div
|
<div
|
||||||
|
|||||||
Reference in New Issue
Block a user