mirror of
https://gitee.com/qqtt-ah/ecom-dmb.git
synced 2026-11-24 19:49:19 +08:00
feat: 店铺增加三侧操作和查看
This commit is contained in:
+254
@@ -0,0 +1,254 @@
|
||||
<script lang="ts" setup>
|
||||
import type { ShopVO } from '#/api/ec/shop/types';
|
||||
import type { BiOrderStatCalcVO } from '#/api/bi/order-stat-calc';
|
||||
|
||||
import { computed, ref } from 'vue';
|
||||
|
||||
import {
|
||||
Alert,
|
||||
Button,
|
||||
Card,
|
||||
Descriptions,
|
||||
Empty,
|
||||
List,
|
||||
Modal,
|
||||
Progress,
|
||||
Space,
|
||||
Tag,
|
||||
Typography,
|
||||
message,
|
||||
} from 'ant-design-vue';
|
||||
import dayjs from 'dayjs';
|
||||
|
||||
import {
|
||||
getBiOrderStatIncCalcStatusApi,
|
||||
listBiOrderStatFullCalcTasksApi,
|
||||
resumeBiOrderStatIncCalcApi,
|
||||
} from '#/api/bi/order-stat-calc';
|
||||
|
||||
defineOptions({ name: 'BiOrderStatCalcModal' });
|
||||
|
||||
const emit = defineEmits<{ success: [] }>();
|
||||
|
||||
const openFlag = ref(false);
|
||||
const shop = ref<null | ShopVO.Info>(null);
|
||||
const loading = ref(false);
|
||||
const listLoading = ref(false);
|
||||
const resuming = ref(false);
|
||||
const incremental = ref<null | BiOrderStatCalcVO.IncStatus>(null);
|
||||
const fullTasks = ref<BiOrderStatCalcVO.FullTask[]>([]);
|
||||
|
||||
const title = computed(() =>
|
||||
shop.value ? `BI 计算 - ${shop.value.name}` : 'BI 计算',
|
||||
);
|
||||
|
||||
const statusLabel = computed(() => {
|
||||
const s = incremental.value?.status;
|
||||
if (s === 2) return '出错暂停';
|
||||
if (s === 1) return '正常';
|
||||
return '未开始';
|
||||
});
|
||||
|
||||
const statusColor = computed(() => {
|
||||
const s = incremental.value?.status;
|
||||
if (s === 2) return 'error';
|
||||
if (s === 1) return 'success';
|
||||
return 'default';
|
||||
});
|
||||
|
||||
function formatTime(time?: null | string) {
|
||||
if (!time) return '-';
|
||||
const d = dayjs(time);
|
||||
return d.isValid() ? d.format('YYYY-MM-DD HH:mm:ss') : '-';
|
||||
}
|
||||
|
||||
function statusTag(status: string) {
|
||||
const map: Record<string, { color: string; text: string }> = {
|
||||
PENDING: { color: 'default', text: '等待中' },
|
||||
RUNNING: { color: 'processing', text: '执行中' },
|
||||
SUCCESS: { color: 'success', text: '成功' },
|
||||
FAILED: { color: 'error', text: '失败' },
|
||||
CANCELLED: { color: 'warning', text: '已取消' },
|
||||
};
|
||||
return map[status] || { color: 'default', text: status };
|
||||
}
|
||||
|
||||
function taskProgressPercent(task: BiOrderStatCalcVO.FullTask) {
|
||||
if (!task.totalDays) return 0;
|
||||
return Math.min(100, Math.round((task.doneDays / task.totalDays) * 100));
|
||||
}
|
||||
|
||||
async function loadInc() {
|
||||
if (!shop.value) return;
|
||||
try {
|
||||
incremental.value = await getBiOrderStatIncCalcStatusApi(shop.value.id);
|
||||
} catch (error) {
|
||||
console.error('加载 BI 计算店态失败:', error);
|
||||
}
|
||||
}
|
||||
|
||||
async function loadFullTasks() {
|
||||
if (!shop.value) return;
|
||||
try {
|
||||
listLoading.value = true;
|
||||
fullTasks.value = await listBiOrderStatFullCalcTasksApi(shop.value.id, 30);
|
||||
} catch (error) {
|
||||
console.error('加载全量计算任务失败:', error);
|
||||
} finally {
|
||||
listLoading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
async function handleResume() {
|
||||
if (!shop.value) return;
|
||||
try {
|
||||
resuming.value = true;
|
||||
incremental.value = await resumeBiOrderStatIncCalcApi(shop.value.id);
|
||||
message.success('已恢复计算');
|
||||
emit('success');
|
||||
} catch (error) {
|
||||
console.error('恢复计算失败:', error);
|
||||
message.error('恢复计算失败');
|
||||
} finally {
|
||||
resuming.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
function handleClose() {
|
||||
openFlag.value = false;
|
||||
}
|
||||
|
||||
async function open(record: ShopVO.Info) {
|
||||
shop.value = record;
|
||||
incremental.value = null;
|
||||
fullTasks.value = [];
|
||||
openFlag.value = true;
|
||||
loading.value = true;
|
||||
try {
|
||||
await Promise.all([loadInc(), loadFullTasks()]);
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
defineExpose({ open, close: handleClose });
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Modal
|
||||
v-model:open="openFlag"
|
||||
:title="title"
|
||||
:width="720"
|
||||
:footer="null"
|
||||
destroy-on-close
|
||||
@cancel="handleClose"
|
||||
>
|
||||
<Space direction="vertical" :size="16" class="w-full">
|
||||
<Card size="small">
|
||||
<template #title>
|
||||
<Space>
|
||||
<span>增量计算</span>
|
||||
<Tag :color="statusColor">{{ statusLabel }}</Tag>
|
||||
</Space>
|
||||
</template>
|
||||
<template #extra>
|
||||
<Button
|
||||
v-if="incremental?.status === 2"
|
||||
size="small"
|
||||
type="primary"
|
||||
:loading="resuming"
|
||||
@click="handleResume"
|
||||
>
|
||||
恢复运行
|
||||
</Button>
|
||||
</template>
|
||||
<Space direction="vertical" :size="12" class="w-full">
|
||||
<Typography.Text type="secondary">
|
||||
将转换侧 delta 累加到 BI 日汇聚;出错暂停后需人工恢复。
|
||||
</Typography.Text>
|
||||
<Descriptions bordered size="small" :column="1">
|
||||
<Descriptions.Item label="上次成功">
|
||||
{{ formatTime(incremental?.lastSuccessTime) }}
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="最近统计日">
|
||||
{{ incremental?.lastStatDate || '-' }}
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="最近订单">
|
||||
{{
|
||||
incremental?.lastAppliedOrderId
|
||||
? `#${incremental.lastAppliedOrderId}`
|
||||
: '-'
|
||||
}}
|
||||
</Descriptions.Item>
|
||||
</Descriptions>
|
||||
<Alert
|
||||
v-if="incremental?.lastSummary"
|
||||
:type="incremental?.status === 2 ? 'error' : 'info'"
|
||||
show-icon
|
||||
:message="incremental.lastSummary"
|
||||
/>
|
||||
</Space>
|
||||
</Card>
|
||||
|
||||
<Card size="small" title="全量计算任务">
|
||||
<template #extra>
|
||||
<Button size="small" :loading="listLoading" @click="loadFullTasks">
|
||||
刷新
|
||||
</Button>
|
||||
</template>
|
||||
<List
|
||||
v-if="fullTasks.length > 0"
|
||||
:data-source="fullTasks"
|
||||
:loading="listLoading"
|
||||
item-layout="vertical"
|
||||
size="small"
|
||||
class="max-h-[40vh] overflow-y-auto"
|
||||
>
|
||||
<template #renderItem="{ item: task }">
|
||||
<List.Item>
|
||||
<List.Item.Meta>
|
||||
<template #title>
|
||||
<Space wrap>
|
||||
<span>#{{ task.id }}</span>
|
||||
<Tag :color="statusTag(task.status).color">
|
||||
{{ statusTag(task.status).text }}
|
||||
</Tag>
|
||||
<Typography.Text type="secondary">
|
||||
{{ task.doneDays }}/{{ task.totalDays }} 天
|
||||
</Typography.Text>
|
||||
</Space>
|
||||
</template>
|
||||
<template #description>
|
||||
<div>区间 {{ task.dateFrom }} ~ {{ task.dateTo }}</div>
|
||||
<div>
|
||||
创建 {{ formatTime(task.createTime) }}
|
||||
<template v-if="task.finishTime">
|
||||
· 结束 {{ formatTime(task.finishTime) }}
|
||||
</template>
|
||||
</div>
|
||||
</template>
|
||||
</List.Item.Meta>
|
||||
<Progress
|
||||
v-if="task.status === 'RUNNING' || task.status === 'SUCCESS'"
|
||||
:percent="taskProgressPercent(task)"
|
||||
size="small"
|
||||
/>
|
||||
<Alert
|
||||
v-if="task.lastError"
|
||||
class="mt-2"
|
||||
type="error"
|
||||
show-icon
|
||||
:message="task.lastError"
|
||||
/>
|
||||
</List.Item>
|
||||
</template>
|
||||
</List>
|
||||
<Empty
|
||||
v-else
|
||||
:image="Empty.PRESENTED_IMAGE_SIMPLE"
|
||||
description="暂无全量计算任务"
|
||||
/>
|
||||
</Card>
|
||||
</Space>
|
||||
</Modal>
|
||||
</template>
|
||||
+250
@@ -0,0 +1,250 @@
|
||||
<script lang="ts" setup>
|
||||
import type { ShopVO } from '#/api/ec/shop/types';
|
||||
import type { PddOrderConvertVO } from '#/api/channel/pdd/order-convert';
|
||||
|
||||
import { computed, ref } from 'vue';
|
||||
|
||||
import {
|
||||
Alert,
|
||||
Button,
|
||||
Card,
|
||||
Descriptions,
|
||||
Empty,
|
||||
List,
|
||||
Modal,
|
||||
Progress,
|
||||
Space,
|
||||
Tag,
|
||||
Typography,
|
||||
message,
|
||||
} from 'ant-design-vue';
|
||||
import dayjs from 'dayjs';
|
||||
|
||||
import {
|
||||
getPddOrderConvertIncStatusApi,
|
||||
listPddOrderConvertFullTasksApi,
|
||||
resumePddOrderConvertIncApi,
|
||||
} from '#/api/channel/pdd/order-convert';
|
||||
|
||||
defineOptions({ name: 'PddOrderConvertModal' });
|
||||
|
||||
const emit = defineEmits<{ success: [] }>();
|
||||
|
||||
const openFlag = ref(false);
|
||||
const shop = ref<null | ShopVO.Info>(null);
|
||||
const loading = ref(false);
|
||||
const listLoading = ref(false);
|
||||
const resuming = ref(false);
|
||||
const incremental = ref<null | PddOrderConvertVO.IncStatus>(null);
|
||||
const fullTasks = ref<PddOrderConvertVO.FullTask[]>([]);
|
||||
|
||||
const title = computed(() =>
|
||||
shop.value ? `订单转换 - ${shop.value.name}` : '订单转换',
|
||||
);
|
||||
|
||||
const statusLabel = computed(() => {
|
||||
const s = incremental.value?.status;
|
||||
if (s === 2) return '出错暂停';
|
||||
if (s === 1) return '正常';
|
||||
return '未开始';
|
||||
});
|
||||
|
||||
const statusColor = computed(() => {
|
||||
const s = incremental.value?.status;
|
||||
if (s === 2) return 'error';
|
||||
if (s === 1) return 'success';
|
||||
return 'default';
|
||||
});
|
||||
|
||||
function formatTime(time?: null | string) {
|
||||
if (!time) return '-';
|
||||
const d = dayjs(time);
|
||||
return d.isValid() ? d.format('YYYY-MM-DD HH:mm:ss') : '-';
|
||||
}
|
||||
|
||||
function statusTag(status: string) {
|
||||
const map: Record<string, { color: string; text: string }> = {
|
||||
PENDING: { color: 'default', text: '等待中' },
|
||||
RUNNING: { color: 'processing', text: '执行中' },
|
||||
SUCCESS: { color: 'success', text: '成功' },
|
||||
FAILED: { color: 'error', text: '失败' },
|
||||
CANCELLED: { color: 'warning', text: '已取消' },
|
||||
};
|
||||
return map[status] || { color: 'default', text: status };
|
||||
}
|
||||
|
||||
function taskProgressPercent(task: PddOrderConvertVO.FullTask) {
|
||||
if (!task.totalDays) return 0;
|
||||
return Math.min(100, Math.round((task.doneDays / task.totalDays) * 100));
|
||||
}
|
||||
|
||||
async function loadInc() {
|
||||
if (!shop.value) return;
|
||||
try {
|
||||
incremental.value = await getPddOrderConvertIncStatusApi(shop.value.id);
|
||||
} catch (error) {
|
||||
console.error('加载转换店态失败:', error);
|
||||
}
|
||||
}
|
||||
|
||||
async function loadFullTasks() {
|
||||
if (!shop.value) return;
|
||||
try {
|
||||
listLoading.value = true;
|
||||
fullTasks.value = await listPddOrderConvertFullTasksApi(shop.value.id, 30);
|
||||
} catch (error) {
|
||||
console.error('加载全量转换任务失败:', error);
|
||||
} finally {
|
||||
listLoading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
async function handleResume() {
|
||||
if (!shop.value) return;
|
||||
try {
|
||||
resuming.value = true;
|
||||
incremental.value = await resumePddOrderConvertIncApi(shop.value.id);
|
||||
message.success('已恢复转换');
|
||||
emit('success');
|
||||
} catch (error) {
|
||||
console.error('恢复转换失败:', error);
|
||||
message.error('恢复转换失败');
|
||||
} finally {
|
||||
resuming.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
function handleClose() {
|
||||
openFlag.value = false;
|
||||
}
|
||||
|
||||
async function open(record: ShopVO.Info) {
|
||||
shop.value = record;
|
||||
incremental.value = null;
|
||||
fullTasks.value = [];
|
||||
openFlag.value = true;
|
||||
loading.value = true;
|
||||
try {
|
||||
await Promise.all([loadInc(), loadFullTasks()]);
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
defineExpose({ open, close: handleClose });
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Modal
|
||||
v-model:open="openFlag"
|
||||
:title="title"
|
||||
:width="720"
|
||||
:footer="null"
|
||||
destroy-on-close
|
||||
@cancel="handleClose"
|
||||
>
|
||||
<Space direction="vertical" :size="16" class="w-full">
|
||||
<Card size="small">
|
||||
<template #title>
|
||||
<Space>
|
||||
<span>增量转换</span>
|
||||
<Tag :color="statusColor">{{ statusLabel }}</Tag>
|
||||
</Space>
|
||||
</template>
|
||||
<template #extra>
|
||||
<Button
|
||||
v-if="incremental?.status === 2"
|
||||
size="small"
|
||||
type="primary"
|
||||
:loading="resuming"
|
||||
@click="handleResume"
|
||||
>
|
||||
恢复运行
|
||||
</Button>
|
||||
</template>
|
||||
<Space direction="vertical" :size="12" class="w-full">
|
||||
<Typography.Text type="secondary">
|
||||
将渠道订单写入内部订单;出错暂停后需人工恢复才会继续消费。
|
||||
</Typography.Text>
|
||||
<Descriptions bordered size="small" :column="1">
|
||||
<Descriptions.Item label="上次成功">
|
||||
{{ formatTime(incremental?.lastSuccessTime) }}
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="转换游标">
|
||||
{{ formatTime(incremental?.lastCursorAt) }}
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="最近批次单数">
|
||||
{{ incremental?.lastConvertedCount ?? '-' }}
|
||||
</Descriptions.Item>
|
||||
</Descriptions>
|
||||
<Alert
|
||||
v-if="incremental?.lastSummary"
|
||||
:type="incremental?.status === 2 ? 'error' : 'info'"
|
||||
show-icon
|
||||
:message="incremental.lastSummary"
|
||||
/>
|
||||
</Space>
|
||||
</Card>
|
||||
|
||||
<Card size="small" title="全量转换任务">
|
||||
<template #extra>
|
||||
<Button size="small" :loading="listLoading" @click="loadFullTasks">
|
||||
刷新
|
||||
</Button>
|
||||
</template>
|
||||
<List
|
||||
v-if="fullTasks.length > 0"
|
||||
:data-source="fullTasks"
|
||||
:loading="listLoading"
|
||||
item-layout="vertical"
|
||||
size="small"
|
||||
class="max-h-[40vh] overflow-y-auto"
|
||||
>
|
||||
<template #renderItem="{ item: task }">
|
||||
<List.Item>
|
||||
<List.Item.Meta>
|
||||
<template #title>
|
||||
<Space wrap>
|
||||
<span>#{{ task.id }}</span>
|
||||
<Tag :color="statusTag(task.status).color">
|
||||
{{ statusTag(task.status).text }}
|
||||
</Tag>
|
||||
<Typography.Text type="secondary">
|
||||
{{ task.doneDays }}/{{ task.totalDays }} 天
|
||||
</Typography.Text>
|
||||
</Space>
|
||||
</template>
|
||||
<template #description>
|
||||
<div>区间 {{ task.dateFrom }} ~ {{ task.dateTo }}</div>
|
||||
<div>
|
||||
创建 {{ formatTime(task.createTime) }}
|
||||
<template v-if="task.finishTime">
|
||||
· 结束 {{ formatTime(task.finishTime) }}
|
||||
</template>
|
||||
</div>
|
||||
</template>
|
||||
</List.Item.Meta>
|
||||
<Progress
|
||||
v-if="task.status === 'RUNNING' || task.status === 'SUCCESS'"
|
||||
:percent="taskProgressPercent(task)"
|
||||
size="small"
|
||||
/>
|
||||
<Alert
|
||||
v-if="task.lastError"
|
||||
class="mt-2"
|
||||
type="error"
|
||||
show-icon
|
||||
:message="task.lastError"
|
||||
/>
|
||||
</List.Item>
|
||||
</template>
|
||||
</List>
|
||||
<Empty
|
||||
v-else
|
||||
:image="Empty.PRESENTED_IMAGE_SIMPLE"
|
||||
description="暂无全量转换任务"
|
||||
/>
|
||||
</Card>
|
||||
</Space>
|
||||
</Modal>
|
||||
</template>
|
||||
+9
-15
@@ -11,7 +11,6 @@ import {
|
||||
Card,
|
||||
DatePicker,
|
||||
Descriptions,
|
||||
Drawer,
|
||||
Empty,
|
||||
Form,
|
||||
List,
|
||||
@@ -39,7 +38,7 @@ import {
|
||||
import { RealtimeSseEvent } from '#/api/notify/sse';
|
||||
import { useRealtimeStore } from '#/store';
|
||||
|
||||
defineOptions({ name: 'PddOrderSyncDrawer' });
|
||||
defineOptions({ name: 'PddOrderSyncModal' });
|
||||
|
||||
interface Emits {
|
||||
(e: 'success'): void;
|
||||
@@ -79,7 +78,7 @@ let pollTimer: null | ReturnType<typeof setInterval> = null;
|
||||
let unsubProgress: (() => void) | null = null;
|
||||
const terminalNotifiedTaskIds = new Set<number>();
|
||||
|
||||
const drawerTitle = computed(() =>
|
||||
const modalTitle = computed(() =>
|
||||
shop.value ? `同步拼多多订单 - ${shop.value.name}` : '同步拼多多订单',
|
||||
);
|
||||
|
||||
@@ -421,13 +420,14 @@ defineExpose({ open, close: handleClose });
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Drawer
|
||||
<Modal
|
||||
v-model:open="openFlag"
|
||||
:title="drawerTitle"
|
||||
width="600"
|
||||
:title="modalTitle"
|
||||
:width="720"
|
||||
:footer="null"
|
||||
destroy-on-close
|
||||
:mask-closable="!hasActiveFullTask"
|
||||
@close="handleClose"
|
||||
@cancel="handleClose"
|
||||
>
|
||||
<Space direction="vertical" :size="16" class="w-full">
|
||||
<Card size="small">
|
||||
@@ -500,7 +500,7 @@ defineExpose({ open, close: handleClose });
|
||||
:loading="listLoading"
|
||||
item-layout="vertical"
|
||||
size="small"
|
||||
class="max-h-[52vh] overflow-y-auto"
|
||||
class="max-h-[40vh] overflow-y-auto"
|
||||
>
|
||||
<template #renderItem="{ item: task }">
|
||||
<List.Item>
|
||||
@@ -580,13 +580,7 @@ defineExpose({ open, close: handleClose });
|
||||
/>
|
||||
</Card>
|
||||
</Space>
|
||||
|
||||
<template #footer>
|
||||
<Space class="w-full justify-end">
|
||||
<Button @click="handleClose">关闭</Button>
|
||||
</Space>
|
||||
</template>
|
||||
</Drawer>
|
||||
</Modal>
|
||||
|
||||
<Modal
|
||||
v-model:open="createModalOpen"
|
||||
@@ -10,7 +10,7 @@ import { computed, onMounted, onUnmounted, ref } from 'vue';
|
||||
import { Page } from '@vben/common-ui';
|
||||
import { createIconifyIcon } from '@vben/icons';
|
||||
|
||||
import { Button, message, Popconfirm, Space, Tag } from 'ant-design-vue';
|
||||
import { Button, message, Popconfirm, Space, Steps, Tag } from 'ant-design-vue';
|
||||
import dayjs from 'dayjs';
|
||||
|
||||
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
@@ -23,7 +23,9 @@ import {
|
||||
getPlatformTagColor,
|
||||
} from '#/utils/platform-display';
|
||||
|
||||
import PddOrderSyncDrawer from './components/PddOrderSyncDrawer.vue';
|
||||
import BiOrderStatCalcModal from './components/BiOrderStatCalcModal.vue';
|
||||
import PddOrderConvertModal from './components/PddOrderConvertModal.vue';
|
||||
import PddOrderSyncModal from './components/PddOrderSyncModal.vue';
|
||||
import ShopFormModal from './components/ShopFormModal.vue';
|
||||
import PddShopDetailModal from '#/views/channel/pdd/shop/components/PddShopDetailModal.vue';
|
||||
|
||||
@@ -37,11 +39,27 @@ const loading = ref(false);
|
||||
const authorizing = ref(false);
|
||||
const shopFormModalRef = ref();
|
||||
const pddShopDetailModalRef = ref();
|
||||
const pddOrderSyncDrawerRef = ref();
|
||||
const pddOrderSyncModalRef = ref();
|
||||
const pddOrderConvertModalRef = ref();
|
||||
const biOrderStatCalcModalRef = ref();
|
||||
|
||||
/** shopId -> 同步摘要 */
|
||||
/** shopId -> 同步/转换/计算摘要 */
|
||||
const syncStatusMap = ref<Record<number, PddOrderSyncVO.ShopStatus>>({});
|
||||
|
||||
/** 主行带店铺字段;次行用 shop 挂店铺,供 VXE data 使用(避免联合类型与 Data<T> 不兼容) */
|
||||
type ShopListRow = Partial<ShopVO.Info> & {
|
||||
_rowKey: string;
|
||||
_rowType: 'main' | 'pipeline';
|
||||
_shopIndex: number;
|
||||
/** 主行:是否有管线次行(序号列 rowspan) */
|
||||
_hasPipeline?: boolean;
|
||||
id: number;
|
||||
/** 次行必有;主行可不设 */
|
||||
shop?: ShopVO.Info;
|
||||
};
|
||||
|
||||
const COLUMN_COUNT = 8;
|
||||
|
||||
const searchForm = ref({
|
||||
name: '',
|
||||
platformCode: undefined as string | undefined,
|
||||
@@ -51,19 +69,46 @@ const platformOptions = ref<{ label: string; value: string }[]>([]);
|
||||
|
||||
let authPollTimer: null | ReturnType<typeof setInterval> = null;
|
||||
|
||||
const gridOptions: VxeGridProps<any> = {
|
||||
function toShopListRows(records: ShopVO.Info[]): ShopListRow[] {
|
||||
const rows: ShopListRow[] = [];
|
||||
records.forEach((shop, index) => {
|
||||
const hasPipeline =
|
||||
shop.platformCode === PLATFORM_CODE_PDD && Boolean(shop.pddShop);
|
||||
rows.push({
|
||||
...shop,
|
||||
_rowKey: `${shop.id}-main`,
|
||||
_rowType: 'main',
|
||||
_shopIndex: index,
|
||||
_hasPipeline: hasPipeline,
|
||||
});
|
||||
if (hasPipeline) {
|
||||
rows.push({
|
||||
_rowKey: `${shop.id}-pipeline`,
|
||||
_rowType: 'pipeline',
|
||||
_shopIndex: index,
|
||||
id: shop.id,
|
||||
shop,
|
||||
});
|
||||
}
|
||||
});
|
||||
return rows;
|
||||
}
|
||||
|
||||
const gridOptions: VxeGridProps<ShopListRow> = {
|
||||
columns: [
|
||||
{
|
||||
type: 'seq' as const,
|
||||
width: 80,
|
||||
width: 64,
|
||||
title: '序号',
|
||||
align: 'center' as const,
|
||||
showOverflow: false,
|
||||
slots: { default: 'seq' },
|
||||
},
|
||||
{
|
||||
title: 'Logo',
|
||||
width: 120,
|
||||
align: 'center' as const,
|
||||
showOverflow: false,
|
||||
slots: { default: 'logo' },
|
||||
slots: { default: 'logoOrPipeline' },
|
||||
},
|
||||
{
|
||||
field: 'name',
|
||||
@@ -77,6 +122,7 @@ const gridOptions: VxeGridProps<any> = {
|
||||
title: '平台',
|
||||
minWidth: 120,
|
||||
showOverflow: true,
|
||||
slots: { default: 'platformName' },
|
||||
},
|
||||
{
|
||||
title: '外部店铺',
|
||||
@@ -85,37 +131,53 @@ const gridOptions: VxeGridProps<any> = {
|
||||
showOverflow: false,
|
||||
slots: { default: 'externalShop' },
|
||||
},
|
||||
{
|
||||
title: '订单同步',
|
||||
minWidth: 200,
|
||||
align: 'center' as const,
|
||||
showOverflow: false,
|
||||
slots: { default: 'orderSync' },
|
||||
},
|
||||
{
|
||||
field: 'createTime',
|
||||
title: '创建时间',
|
||||
minWidth: 'auto',
|
||||
slots: { default: 'createTime' },
|
||||
},
|
||||
{
|
||||
field: 'updateTime',
|
||||
title: '更新时间',
|
||||
minWidth: 'auto',
|
||||
slots: { default: 'updateTime' },
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
minWidth: 320,
|
||||
fixed: 'right' as const,
|
||||
showOverflow: false,
|
||||
slots: { default: 'action' },
|
||||
},
|
||||
],
|
||||
height: 'auto',
|
||||
border: true,
|
||||
stripe: true,
|
||||
stripe: false,
|
||||
rowConfig: {
|
||||
isHover: true,
|
||||
height: 88,
|
||||
keyField: '_rowKey',
|
||||
},
|
||||
rowClassName: ({ row }) =>
|
||||
row._rowType === 'pipeline' ? 'shop-row-pipeline' : 'shop-row-main',
|
||||
spanMethod: ({ row, columnIndex }) => {
|
||||
// 序号列:主行与管线次行纵向合并
|
||||
if (columnIndex === 0) {
|
||||
if (row._rowType === 'main' && row._hasPipeline) {
|
||||
return { rowspan: 2, colspan: 1 };
|
||||
}
|
||||
if (row._rowType === 'pipeline') {
|
||||
return { rowspan: 0, colspan: 0 };
|
||||
}
|
||||
return { rowspan: 1, colspan: 1 };
|
||||
}
|
||||
// 管线次行:从 Logo 起横向合并剩余列展示三阶段
|
||||
if (row._rowType === 'pipeline') {
|
||||
if (columnIndex === 1) {
|
||||
return { rowspan: 1, colspan: COLUMN_COUNT - 1 };
|
||||
}
|
||||
return { rowspan: 0, colspan: 0 };
|
||||
}
|
||||
return { rowspan: 1, colspan: 1 };
|
||||
},
|
||||
showOverflow: true,
|
||||
size: 'small',
|
||||
@@ -162,9 +224,10 @@ const gridOptions: VxeGridProps<any> = {
|
||||
},
|
||||
};
|
||||
const data = await getShopPageApi(params);
|
||||
await loadSyncStatusForShops(data.records || []);
|
||||
const records = data.records || [];
|
||||
await loadSyncStatusForShops(records);
|
||||
return {
|
||||
items: data.records,
|
||||
items: toShopListRows(records),
|
||||
total: data.total,
|
||||
};
|
||||
} catch (error) {
|
||||
@@ -278,75 +341,156 @@ function formatRelative(time?: null | string) {
|
||||
return d.format('MM-DD');
|
||||
}
|
||||
|
||||
function fullSyncLabel(status?: PddOrderSyncVO.ShopStatus) {
|
||||
const task = status?.fullTask;
|
||||
if (!task) return '-';
|
||||
if (task.status === 'PENDING' || task.status === 'RUNNING') {
|
||||
return `进行中 ${task.doneDays ?? 0}/${task.totalDays ?? 0}`;
|
||||
}
|
||||
if (task.status === 'FAILED') return '失败';
|
||||
if (task.status === 'CANCELLED') return '已取消';
|
||||
if (task.status === 'SUCCESS') {
|
||||
const rel = formatRelative(task.finishTime);
|
||||
return rel ? `已完成(${rel})` : '已完成';
|
||||
}
|
||||
return task.status;
|
||||
}
|
||||
type PipelineTone = 'error' | 'idle' | 'off' | 'ok' | 'warn';
|
||||
|
||||
function fullSyncColor(status?: PddOrderSyncVO.ShopStatus) {
|
||||
const s = status?.fullTask?.status;
|
||||
if (s === 'RUNNING' || s === 'PENDING') return 'processing';
|
||||
if (s === 'FAILED') return 'error';
|
||||
if (s === 'SUCCESS') return 'success';
|
||||
if (s === 'CANCELLED') return 'default';
|
||||
return 'default';
|
||||
}
|
||||
type PipelineStepView = {
|
||||
key: string;
|
||||
title: string;
|
||||
tone: PipelineTone;
|
||||
statusText: string;
|
||||
/** 全量 · 增量 两行时间 */
|
||||
fullTimeText: string;
|
||||
incTimeText: string;
|
||||
stepStatus: 'error' | 'finish' | 'process' | 'wait';
|
||||
};
|
||||
|
||||
function incSyncLabel(status?: PddOrderSyncVO.ShopStatus) {
|
||||
const inc = status?.incremental;
|
||||
if (!inc) return '关';
|
||||
const health = inc.health || (inc.enabled ? 'OK' : 'OFF');
|
||||
const map: Record<string, string> = {
|
||||
OFF: '关',
|
||||
OK: '开·正常',
|
||||
LAGGING: '开·滞后',
|
||||
PAUSED: '开·暂停',
|
||||
};
|
||||
const base = map[health] || (inc.enabled ? '开' : '关');
|
||||
const anchor = inc.lastSuccessTime || inc.lastCursorAt;
|
||||
const rel = formatRelative(anchor);
|
||||
return rel ? `${base} · ${rel}` : base;
|
||||
}
|
||||
|
||||
function incSyncColor(status?: PddOrderSyncVO.ShopStatus) {
|
||||
function toneFromInc(status?: PddOrderSyncVO.ShopStatus): PipelineTone {
|
||||
const health = status?.incremental?.health;
|
||||
if (health === 'PAUSED') return 'error';
|
||||
if (health === 'LAGGING') return 'warning';
|
||||
if (health === 'OK') return 'success';
|
||||
return 'default';
|
||||
if (health === 'LAGGING') return 'warn';
|
||||
if (health === 'OK') return 'ok';
|
||||
if (health === 'OFF' || !status?.incremental?.enabled) return 'off';
|
||||
return 'idle';
|
||||
}
|
||||
|
||||
function toneFromStage(
|
||||
summary?: string,
|
||||
status?: number,
|
||||
): PipelineTone {
|
||||
if (status === 2 || (summary && (summary.includes('失败') || summary.includes('限流')))) {
|
||||
return 'error';
|
||||
}
|
||||
if (summary) return 'ok';
|
||||
return 'idle';
|
||||
}
|
||||
|
||||
function toneLabel(tone: PipelineTone) {
|
||||
const map: Record<PipelineTone, string> = {
|
||||
ok: '正常',
|
||||
warn: '滞后',
|
||||
error: '异常',
|
||||
off: '关闭',
|
||||
idle: '未开始',
|
||||
};
|
||||
return map[tone];
|
||||
}
|
||||
|
||||
function toneToStepStatus(
|
||||
tone: PipelineTone,
|
||||
): 'error' | 'finish' | 'process' | 'wait' {
|
||||
if (tone === 'ok') return 'finish';
|
||||
if (tone === 'error') return 'error';
|
||||
if (tone === 'warn') return 'process';
|
||||
return 'wait';
|
||||
}
|
||||
|
||||
function formatStageTime(time?: null | string) {
|
||||
if (!time) return '-';
|
||||
const rel = formatRelative(time);
|
||||
return rel || '-';
|
||||
}
|
||||
|
||||
/** 次行管线:同步 → 转换 → 计算(各侧全量/增量最近成功时间) */
|
||||
function buildPipelineSteps(
|
||||
status?: PddOrderSyncVO.ShopStatus,
|
||||
): PipelineStepView[] {
|
||||
const syncTone = toneFromInc(status);
|
||||
const convertTone = toneFromStage(
|
||||
status?.convert?.lastSummary,
|
||||
status?.convert?.status,
|
||||
);
|
||||
const calcTone = toneFromStage(
|
||||
status?.calc?.lastSummary,
|
||||
status?.calc?.status,
|
||||
);
|
||||
return [
|
||||
{
|
||||
key: 'sync',
|
||||
title: '同步',
|
||||
tone: syncTone,
|
||||
statusText: toneLabel(syncTone),
|
||||
fullTimeText: formatStageTime(status?.lastFullSyncSuccessTime),
|
||||
incTimeText: formatStageTime(status?.incremental?.lastSuccessTime),
|
||||
stepStatus: toneToStepStatus(syncTone),
|
||||
},
|
||||
{
|
||||
key: 'convert',
|
||||
title: '转换',
|
||||
tone: convertTone,
|
||||
statusText: toneLabel(convertTone),
|
||||
fullTimeText: formatStageTime(status?.convert?.lastFullSuccessTime),
|
||||
incTimeText: formatStageTime(status?.convert?.lastSuccessTime),
|
||||
stepStatus: toneToStepStatus(convertTone),
|
||||
},
|
||||
{
|
||||
key: 'calc',
|
||||
title: '计算',
|
||||
tone: calcTone,
|
||||
statusText: toneLabel(calcTone),
|
||||
fullTimeText: formatStageTime(status?.calc?.lastFullSuccessTime),
|
||||
incTimeText: formatStageTime(status?.calc?.lastSuccessTime),
|
||||
stepStatus: toneToStepStatus(calcTone),
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
function isPipelineRow(row: ShopListRow): boolean {
|
||||
return row._rowType === 'pipeline';
|
||||
}
|
||||
|
||||
type PipelineStageKey = 'calc' | 'convert' | 'sync';
|
||||
|
||||
function openPipelineStage(shop: ShopVO.Info, stage: PipelineStageKey) {
|
||||
if (!hasExternalShop(shop)) {
|
||||
message.warning('请先完成拼多多授权绑定');
|
||||
return;
|
||||
}
|
||||
if (stage === 'sync') {
|
||||
pddOrderSyncModalRef.value?.open(shop);
|
||||
return;
|
||||
}
|
||||
if (stage === 'convert') {
|
||||
pddOrderConvertModalRef.value?.open(shop);
|
||||
return;
|
||||
}
|
||||
biOrderStatCalcModalRef.value?.open(shop);
|
||||
}
|
||||
|
||||
function refreshTable() {
|
||||
gridApi?.reload();
|
||||
}
|
||||
|
||||
function isPddShop(row: ShopVO.Info) {
|
||||
function isPddShop(row: { platformCode?: string }) {
|
||||
return row.platformCode === PLATFORM_CODE_PDD;
|
||||
}
|
||||
|
||||
function hasExternalShop(row: ShopVO.Info) {
|
||||
function hasExternalShop(row: { pddShop?: ShopVO.Info['pddShop'] }) {
|
||||
return Boolean(row.pddShop);
|
||||
}
|
||||
|
||||
function asShopInfo(row: ShopListRow): ShopVO.Info {
|
||||
return row as ShopVO.Info;
|
||||
}
|
||||
|
||||
function handleAdd() {
|
||||
shopFormModalRef.value?.open(false);
|
||||
}
|
||||
|
||||
function handleEdit(record: ShopVO.Info) {
|
||||
shopFormModalRef.value?.open(true, record);
|
||||
function handleEdit(record: ShopListRow) {
|
||||
shopFormModalRef.value?.open(true, asShopInfo(record));
|
||||
}
|
||||
|
||||
async function handleDelete(record: ShopVO.Info) {
|
||||
async function handleDelete(record: ShopListRow) {
|
||||
try {
|
||||
await deleteShopApi(record.id);
|
||||
message.success('删除成功');
|
||||
@@ -361,7 +505,7 @@ function handleModalSuccess() {
|
||||
refreshTable();
|
||||
}
|
||||
|
||||
function handleViewExternalShop(record: ShopVO.Info) {
|
||||
function handleViewExternalShop(record: ShopListRow) {
|
||||
const pddShopId = record.pddShop?.id;
|
||||
if (!pddShopId) {
|
||||
message.warning('暂无外部店铺详情,请先完成授权同步');
|
||||
@@ -370,14 +514,6 @@ function handleViewExternalShop(record: ShopVO.Info) {
|
||||
pddShopDetailModalRef.value?.open(Number(pddShopId), record.name);
|
||||
}
|
||||
|
||||
function handleSyncPddOrders(record: ShopVO.Info) {
|
||||
if (!hasExternalShop(record)) {
|
||||
message.warning('请先完成拼多多授权绑定后再同步订单');
|
||||
return;
|
||||
}
|
||||
pddOrderSyncDrawerRef.value?.open(record);
|
||||
}
|
||||
|
||||
function clearAuthPoll() {
|
||||
if (authPollTimer) {
|
||||
clearInterval(authPollTimer);
|
||||
@@ -385,7 +521,7 @@ function clearAuthPoll() {
|
||||
}
|
||||
}
|
||||
|
||||
async function handleAuthorizePdd(record: ShopVO.Info) {
|
||||
async function handleAuthorizePdd(record: ShopListRow) {
|
||||
if (authorizing.value) return;
|
||||
try {
|
||||
authorizing.value = true;
|
||||
@@ -436,8 +572,55 @@ onUnmounted(() => {
|
||||
</Space>
|
||||
</template>
|
||||
|
||||
<template #logo="{ row }: { row: ShopVO.Info }">
|
||||
<div class="shop-logo-cell flex items-center justify-center">
|
||||
<template #seq="{ row }: { row: ShopListRow }">
|
||||
<span v-if="!isPipelineRow(row)">{{ row._shopIndex + 1 }}</span>
|
||||
</template>
|
||||
|
||||
<template #logoOrPipeline="{ row }: { row: ShopListRow }">
|
||||
<div
|
||||
v-if="isPipelineRow(row) && row.shop"
|
||||
class="flex w-full items-center px-1 text-left"
|
||||
>
|
||||
<Steps size="small" class="shop-pipeline-steps min-w-0 flex-1">
|
||||
<Steps.Step
|
||||
v-for="step in buildPipelineSteps(syncStatusMap[row.shop.id])"
|
||||
:key="step.key"
|
||||
:status="step.stepStatus"
|
||||
>
|
||||
<template #title>
|
||||
<span
|
||||
class="cursor-pointer hover:text-primary"
|
||||
@click.stop="
|
||||
openPipelineStage(
|
||||
row.shop!,
|
||||
step.key as PipelineStageKey,
|
||||
)
|
||||
"
|
||||
>
|
||||
{{ step.title }} · {{ step.statusText }}
|
||||
</span>
|
||||
</template>
|
||||
<template #description>
|
||||
<div
|
||||
class="cursor-pointer text-[11px] leading-tight text-slate-500 dark:text-[hsl(240deg_5%_64.9%)]"
|
||||
@click.stop="
|
||||
openPipelineStage(
|
||||
row.shop!,
|
||||
step.key as PipelineStageKey,
|
||||
)
|
||||
"
|
||||
>
|
||||
<div>全量 {{ step.fullTimeText }}</div>
|
||||
<div>增量 {{ step.incTimeText }}</div>
|
||||
</div>
|
||||
</template>
|
||||
</Steps.Step>
|
||||
</Steps>
|
||||
</div>
|
||||
<div
|
||||
v-else
|
||||
class="shop-logo-cell flex items-center justify-center"
|
||||
>
|
||||
<img
|
||||
v-if="row.logo"
|
||||
:src="row.logo"
|
||||
@@ -453,12 +636,19 @@ onUnmounted(() => {
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<template #name="{ row }: { row: ShopVO.Info }">
|
||||
<span>{{ row.name }}</span>
|
||||
<template #name="{ row }: { row: ShopListRow }">
|
||||
<span v-if="!isPipelineRow(row)">{{ row.name }}</span>
|
||||
</template>
|
||||
|
||||
<template #externalShop="{ row }: { row: ShopVO.Info }">
|
||||
<div v-if="isPddShop(row)" class="flex flex-col items-center gap-1">
|
||||
<template #platformName="{ row }: { row: ShopListRow }">
|
||||
<span v-if="!isPipelineRow(row)">{{ row.platformName }}</span>
|
||||
</template>
|
||||
|
||||
<template #externalShop="{ row }: { row: ShopListRow }">
|
||||
<div
|
||||
v-if="!isPipelineRow(row) && isPddShop(row)"
|
||||
class="flex flex-col items-center gap-1"
|
||||
>
|
||||
<Tag
|
||||
v-if="hasExternalShop(row)"
|
||||
:color="getPlatformTagColor(row.platformCode)"
|
||||
@@ -481,40 +671,19 @@ onUnmounted(() => {
|
||||
渠道店#{{ row.pddShop.id }}
|
||||
</span>
|
||||
</div>
|
||||
<span v-else class="text-slate-400">-</span>
|
||||
<span v-else-if="!isPipelineRow(row)" class="text-slate-400">-</span>
|
||||
</template>
|
||||
|
||||
<template #orderSync="{ row }: { row: ShopVO.Info }">
|
||||
<div
|
||||
v-if="isPddShop(row) && hasExternalShop(row)"
|
||||
class="inline-flex cursor-pointer flex-col items-center gap-1"
|
||||
@click="handleSyncPddOrders(row)"
|
||||
>
|
||||
<div class="flex items-center gap-1 text-xs">
|
||||
<span class="text-slate-500">全量</span>
|
||||
<Tag :color="fullSyncColor(syncStatusMap[row.id])" class="!mr-0">
|
||||
{{ fullSyncLabel(syncStatusMap[row.id]) }}
|
||||
</Tag>
|
||||
</div>
|
||||
<div class="flex items-center gap-1 text-xs">
|
||||
<span class="text-slate-500">增量</span>
|
||||
<Tag :color="incSyncColor(syncStatusMap[row.id])" class="!mr-0">
|
||||
{{ incSyncLabel(syncStatusMap[row.id]) }}
|
||||
</Tag>
|
||||
</div>
|
||||
</div>
|
||||
<span v-else class="text-slate-400">-</span>
|
||||
<template #createTime="{ row }: { row: ShopListRow }">
|
||||
<span v-if="!isPipelineRow(row)">{{ row.createTime }}</span>
|
||||
</template>
|
||||
|
||||
<template #action="{ row }: { row: ShopVO.Info }">
|
||||
<Space>
|
||||
<Button
|
||||
v-if="isPddShop(row) && hasExternalShop(row)"
|
||||
size="small"
|
||||
@click="handleSyncPddOrders(row)"
|
||||
>
|
||||
同步订单
|
||||
</Button>
|
||||
<template #updateTime="{ row }: { row: ShopListRow }">
|
||||
<span v-if="!isPipelineRow(row)">{{ row.updateTime }}</span>
|
||||
</template>
|
||||
|
||||
<template #action="{ row }: { row: ShopListRow }">
|
||||
<Space v-if="!isPipelineRow(row)">
|
||||
<Button
|
||||
v-if="isPddShop(row)"
|
||||
size="small"
|
||||
@@ -538,7 +707,18 @@ onUnmounted(() => {
|
||||
|
||||
<ShopFormModal ref="shopFormModalRef" @success="handleModalSuccess" />
|
||||
<PddShopDetailModal ref="pddShopDetailModalRef" />
|
||||
<PddOrderSyncDrawer ref="pddOrderSyncDrawerRef" @success="handleModalSuccess" />
|
||||
<PddOrderSyncModal
|
||||
ref="pddOrderSyncModalRef"
|
||||
@success="handleModalSuccess"
|
||||
/>
|
||||
<PddOrderConvertModal
|
||||
ref="pddOrderConvertModalRef"
|
||||
@success="handleModalSuccess"
|
||||
/>
|
||||
<BiOrderStatCalcModal
|
||||
ref="biOrderStatCalcModalRef"
|
||||
@success="handleModalSuccess"
|
||||
/>
|
||||
</Page>
|
||||
</template>
|
||||
|
||||
@@ -547,6 +727,48 @@ onUnmounted(() => {
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
:deep(.shop-grid .shop-row-pipeline .vxe-body--column) {
|
||||
border-top: none;
|
||||
padding-block: 6px !important;
|
||||
}
|
||||
|
||||
/* Steps 默认 description max-width:140px 会挤换行,占满节点间空隙并单行省略 */
|
||||
:deep(.shop-pipeline-steps.ant-steps) {
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
:deep(.shop-pipeline-steps .ant-steps-item-container) {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
}
|
||||
|
||||
:deep(.shop-pipeline-steps .ant-steps-item-content) {
|
||||
min-width: 0;
|
||||
width: calc(100% - 24px);
|
||||
}
|
||||
|
||||
:deep(.shop-pipeline-steps .ant-steps-item-title) {
|
||||
padding-inline-end: 8px !important;
|
||||
font-size: 12px !important;
|
||||
line-height: 22px !important;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
:deep(.shop-pipeline-steps .ant-steps-item-title::after) {
|
||||
top: 11px !important;
|
||||
}
|
||||
|
||||
:deep(.shop-pipeline-steps .ant-steps-item-description) {
|
||||
max-width: none !important;
|
||||
padding-inline-end: 12px;
|
||||
margin-top: 0 !important;
|
||||
overflow: hidden;
|
||||
font-size: 12px !important;
|
||||
line-height: 18px !important;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.shop-logo-cell {
|
||||
min-height: 64px;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user