mirror of
https://gitee.com/qqtt-ah/ecom-dmb.git
synced 2026-11-24 23:49:19 +08:00
feat: 店铺列表推广费管线(导入→转换)、失败明细与重试,并禁用拼多多广告费日表 CRUD
This commit is contained in:
@@ -6,39 +6,17 @@ import type { PageQueryDTO } from '#/types/common';
|
||||
|
||||
import { ref, watch } from 'vue';
|
||||
|
||||
import { createIconifyIcon } from '@vben/icons';
|
||||
|
||||
import {
|
||||
Button,
|
||||
Card,
|
||||
DatePicker,
|
||||
Input,
|
||||
message,
|
||||
Popconfirm,
|
||||
Space,
|
||||
} from 'ant-design-vue';
|
||||
import { Alert, Card, DatePicker, Input, message } from 'ant-design-vue';
|
||||
|
||||
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
import {
|
||||
deletePddGoodsAdFeeApi,
|
||||
getPddGoodsAdFeePageApi,
|
||||
} from '#/api/channel/pdd/goods-ad-fee';
|
||||
import { getPddGoodsAdFeePageApi } from '#/api/channel/pdd/goods-ad-fee';
|
||||
import PddShopColPage from '#/views/channel/pdd/components/PddShopColPage.vue';
|
||||
|
||||
import GoodsAdFeeFormModal from './components/GoodsAdFeeFormModal.vue';
|
||||
|
||||
defineOptions({ name: 'PddGoodsAdFeeManagement' });
|
||||
|
||||
const PlusIcon = createIconifyIcon('lucide:plus');
|
||||
|
||||
const loading = ref(false);
|
||||
|
||||
const selectedShopId = ref<number | undefined>(undefined);
|
||||
|
||||
const formModalVisible = ref(false);
|
||||
const currentAdFeeData = ref<null | PddGoodsAdFeeVO.Info>(null);
|
||||
const presetChannelShopId = ref<number | null>(null);
|
||||
|
||||
const searchForm = ref({
|
||||
goodsId: undefined as string | undefined,
|
||||
feeDateStart: undefined as string | undefined,
|
||||
@@ -49,12 +27,6 @@ function onShopSelect(shop: PddShopVO.Info | null) {
|
||||
selectedShopId.value = shop?.id;
|
||||
}
|
||||
|
||||
function handleAddForShop(shopId: number) {
|
||||
currentAdFeeData.value = null;
|
||||
presetChannelShopId.value = shopId;
|
||||
formModalVisible.value = true;
|
||||
}
|
||||
|
||||
const gridOptions: VxeGridProps<PddGoodsAdFeeVO.Info> = {
|
||||
columns: [
|
||||
{
|
||||
@@ -90,12 +62,6 @@ const gridOptions: VxeGridProps<PddGoodsAdFeeVO.Info> = {
|
||||
title: '最近同步',
|
||||
minWidth: 160,
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
minWidth: 140,
|
||||
fixed: 'right' as const,
|
||||
slots: { default: 'action' },
|
||||
},
|
||||
],
|
||||
height: '100%',
|
||||
border: true,
|
||||
@@ -179,51 +145,13 @@ watch(selectedShopId, () => {
|
||||
gridApi.reload();
|
||||
});
|
||||
|
||||
function resetModalPreset() {
|
||||
presetChannelShopId.value = null;
|
||||
}
|
||||
|
||||
function handleAdd() {
|
||||
currentAdFeeData.value = null;
|
||||
resetModalPreset();
|
||||
formModalVisible.value = true;
|
||||
}
|
||||
|
||||
function handleEdit(record: PddGoodsAdFeeVO.Info) {
|
||||
resetModalPreset();
|
||||
currentAdFeeData.value = record;
|
||||
formModalVisible.value = true;
|
||||
}
|
||||
|
||||
async function handleDelete(id: number) {
|
||||
try {
|
||||
await deletePddGoodsAdFeeApi(id);
|
||||
message.success('删除成功');
|
||||
refreshTable();
|
||||
} catch {
|
||||
message.error('删除失败');
|
||||
}
|
||||
}
|
||||
|
||||
function handleFormSuccess() {
|
||||
resetModalPreset();
|
||||
refreshTable();
|
||||
}
|
||||
|
||||
function handleFormCancel() {
|
||||
resetModalPreset();
|
||||
formModalVisible.value = false;
|
||||
}
|
||||
|
||||
const formatAmount = (amount: number) => `¥${Number(amount || 0).toFixed(2)}`;
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<PddShopColPage
|
||||
show-add-action
|
||||
:selected-shop-id="selectedShopId"
|
||||
@select="onShopSelect"
|
||||
@add-for-shop="handleAddForShop"
|
||||
>
|
||||
<Card
|
||||
class="ml-1 flex h-full min-h-0 min-w-0 flex-1 flex-col sm:ml-2"
|
||||
@@ -236,11 +164,11 @@ const formatAmount = (amount: number) => `¥${Number(amount || 0).toFixed(2)}`;
|
||||
}"
|
||||
>
|
||||
<template #title>
|
||||
<span class="text-base font-semibold">广告费记录</span>
|
||||
<span class="text-base font-semibold">广告费记录(只读)</span>
|
||||
</template>
|
||||
|
||||
<template #extra>
|
||||
<Space wrap size="small" class="max-w-[min(100%,48rem)]">
|
||||
<div class="flex flex-wrap items-center gap-2">
|
||||
<Input
|
||||
v-model:value="searchForm.goodsId"
|
||||
allow-clear
|
||||
@@ -266,13 +194,18 @@ const formatAmount = (amount: number) => `¥${Number(amount || 0).toFixed(2)}`;
|
||||
allow-clear
|
||||
@change="() => refreshTable()"
|
||||
/>
|
||||
<Button type="primary" @click="handleAdd">
|
||||
<PlusIcon class="mr-1 h-4 w-4" />
|
||||
新增广告费
|
||||
</Button>
|
||||
</Space>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<div class="px-2 pt-2 sm:px-3">
|
||||
<Alert
|
||||
type="info"
|
||||
show-icon
|
||||
message="手动维护已关闭"
|
||||
description="请通过浏览器扩展批量导入推广费;导入与转换进度可在「店铺管理」推广费管线查看。"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div
|
||||
class="min-h-0 flex-1 overflow-hidden px-2 pb-2 pt-2 sm:px-3 sm:pb-3"
|
||||
>
|
||||
@@ -291,28 +224,8 @@ const formatAmount = (amount: number) => `¥${Number(amount || 0).toFixed(2)}`;
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<template #action="{ row }">
|
||||
<Space>
|
||||
<Button size="small" @click="handleEdit(row)">编辑</Button>
|
||||
<Popconfirm
|
||||
title="确定要删除这条广告费记录吗?"
|
||||
@confirm="handleDelete(row.id)"
|
||||
>
|
||||
<Button size="small" danger>删除</Button>
|
||||
</Popconfirm>
|
||||
</Space>
|
||||
</template>
|
||||
</Grid>
|
||||
</div>
|
||||
</Card>
|
||||
|
||||
<GoodsAdFeeFormModal
|
||||
v-model:open="formModalVisible"
|
||||
:ad-fee-data="currentAdFeeData"
|
||||
:preset-channel-shop-id="presetChannelShopId"
|
||||
@success="handleFormSuccess"
|
||||
@cancel="handleFormCancel"
|
||||
/>
|
||||
</PddShopColPage>
|
||||
</template>
|
||||
|
||||
+308
@@ -0,0 +1,308 @@
|
||||
<script lang="ts" setup>
|
||||
/**
|
||||
* 店铺推广费管线抽屉:导入 → 转换。
|
||||
*/
|
||||
import type { ShopVO } from '#/api/ec/shop/types';
|
||||
import type { PddGoodsAdFeeImportVO } from '#/api/channel/pdd/goods-ad-fee-import';
|
||||
|
||||
import { computed, ref } from 'vue';
|
||||
|
||||
import {
|
||||
Button,
|
||||
Drawer,
|
||||
Modal,
|
||||
Segmented,
|
||||
Space,
|
||||
Table,
|
||||
Tag,
|
||||
message,
|
||||
} from 'ant-design-vue';
|
||||
import dayjs from 'dayjs';
|
||||
|
||||
import {
|
||||
getPddGoodsAdFeeImportTaskApi,
|
||||
listPddGoodsAdFeeImportFailedItemsApi,
|
||||
listPddGoodsAdFeeImportTasksApi,
|
||||
retryPddGoodsAdFeeConvertApi,
|
||||
} from '#/api/channel/pdd/goods-ad-fee-import';
|
||||
|
||||
defineOptions({ name: 'ShopAdFeePipelineDrawer' });
|
||||
|
||||
type PipelineStageKey = 'convert' | 'import';
|
||||
|
||||
const emit = defineEmits<{ success: [] }>();
|
||||
|
||||
const openFlag = ref(false);
|
||||
const shop = ref<null | ShopVO.Info>(null);
|
||||
const stage = ref<PipelineStageKey>('import');
|
||||
const pageLoading = ref(false);
|
||||
|
||||
const tasks = ref<PddGoodsAdFeeImportVO.ImportTask[]>([]);
|
||||
const listLoading = ref(false);
|
||||
const retryingId = ref<null | number>(null);
|
||||
|
||||
const failedOpen = ref(false);
|
||||
const failedTaskId = ref<null | number>(null);
|
||||
const failedLoading = ref(false);
|
||||
const failedItems = ref<PddGoodsAdFeeImportVO.ImportItem[]>([]);
|
||||
const failedTotal = ref(0);
|
||||
const failedPage = ref(1);
|
||||
const failedPageSize = ref(20);
|
||||
|
||||
const title = computed(() =>
|
||||
shop.value ? `推广费数据流 · ${shop.value.name}` : '推广费数据流',
|
||||
);
|
||||
|
||||
const stageOptions = [
|
||||
{ label: '导入', value: 'import' },
|
||||
{ label: '转换', value: 'convert' },
|
||||
];
|
||||
|
||||
const taskColumns = [
|
||||
{ title: '任务ID', dataIndex: 'id', width: 88 },
|
||||
{ title: '导入状态', key: 'importStatus', width: 100 },
|
||||
{ title: '导入摘要', dataIndex: 'message', ellipsis: true },
|
||||
{ title: '成功/失败', key: 'importCount', width: 100 },
|
||||
{ title: '转换状态', key: 'convertStatus', width: 100 },
|
||||
{ title: '转换摘要', dataIndex: 'convertMessage', ellipsis: true },
|
||||
{ title: '完成时间', key: 'finishedAt', width: 150 },
|
||||
{ title: '操作', key: 'action', width: 180, fixed: 'right' as const },
|
||||
];
|
||||
|
||||
const failedColumns = [
|
||||
{ title: '商品ID', dataIndex: 'goodsId', width: 140 },
|
||||
{ title: '费用日期', dataIndex: 'feeDate', width: 110 },
|
||||
{ title: '金额', dataIndex: 'feeAmount', width: 90 },
|
||||
{ title: '失败码', dataIndex: 'failCode', width: 100 },
|
||||
{ title: '原因', dataIndex: 'failReason', ellipsis: true },
|
||||
];
|
||||
|
||||
function importStatusTag(status?: string) {
|
||||
const map: Record<string, { color: string; text: string }> = {
|
||||
pending: { color: 'default', text: '待处理' },
|
||||
processing: { color: 'processing', text: '进行中' },
|
||||
success: { color: 'success', text: '成功' },
|
||||
partial: { color: 'warning', text: '部分成功' },
|
||||
failed: { color: 'error', text: '失败' },
|
||||
};
|
||||
return map[status || ''] || { color: 'default', text: status || '-' };
|
||||
}
|
||||
|
||||
function convertStatusTag(status?: string) {
|
||||
const map: Record<string, { color: string; text: string }> = {
|
||||
pending: { color: 'default', text: '待转换' },
|
||||
processing: { color: 'processing', text: '转换中' },
|
||||
success: { color: 'success', text: '成功' },
|
||||
partial: { color: 'warning', text: '部分成功' },
|
||||
failed: { color: 'error', text: '失败' },
|
||||
skipped: { color: 'default', text: '已跳过' },
|
||||
};
|
||||
return map[status || ''] || { color: 'default', text: status || '-' };
|
||||
}
|
||||
|
||||
function formatTime(time?: string) {
|
||||
if (!time) return '-';
|
||||
const d = dayjs(time);
|
||||
return d.isValid() ? d.format('MM-DD HH:mm') : '-';
|
||||
}
|
||||
|
||||
function canRetryConvert(task: PddGoodsAdFeeImportVO.ImportTask) {
|
||||
const terminal = ['success', 'partial', 'failed'].includes(task.status);
|
||||
const hasSuccess = (task.successCount ?? 0) > 0;
|
||||
const convertTerminal = ['success', 'partial', 'failed', 'skipped'].includes(
|
||||
task.convertStatus || '',
|
||||
);
|
||||
return terminal && hasSuccess && convertTerminal && task.convertStatus !== 'processing';
|
||||
}
|
||||
|
||||
function canShowFailed(task: PddGoodsAdFeeImportVO.ImportTask) {
|
||||
return (task.failCount ?? 0) > 0;
|
||||
}
|
||||
|
||||
async function loadTasks() {
|
||||
if (!shop.value?.id) return;
|
||||
listLoading.value = true;
|
||||
try {
|
||||
const res = await listPddGoodsAdFeeImportTasksApi({
|
||||
page: 1,
|
||||
pageSize: 30,
|
||||
filters: { ecShopId: shop.value.id },
|
||||
});
|
||||
tasks.value = res.records || [];
|
||||
} catch (e) {
|
||||
console.error('加载推广费导入任务失败:', e);
|
||||
tasks.value = [];
|
||||
} finally {
|
||||
listLoading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
async function loadFailedItems() {
|
||||
if (!failedTaskId.value) return;
|
||||
failedLoading.value = true;
|
||||
try {
|
||||
const res = await listPddGoodsAdFeeImportFailedItemsApi(failedTaskId.value, {
|
||||
page: failedPage.value,
|
||||
pageSize: failedPageSize.value,
|
||||
});
|
||||
failedItems.value = res.records || [];
|
||||
failedTotal.value = res.total || 0;
|
||||
} catch (e) {
|
||||
console.error('加载失败明细失败:', e);
|
||||
failedItems.value = [];
|
||||
failedTotal.value = 0;
|
||||
} finally {
|
||||
failedLoading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
async function openDrawer(target: ShopVO.Info, initialStage: PipelineStageKey = 'import') {
|
||||
shop.value = target;
|
||||
stage.value = initialStage;
|
||||
openFlag.value = true;
|
||||
pageLoading.value = true;
|
||||
try {
|
||||
await loadTasks();
|
||||
} finally {
|
||||
pageLoading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
function closeDrawer() {
|
||||
openFlag.value = false;
|
||||
}
|
||||
|
||||
async function handleRetryConvert(task: PddGoodsAdFeeImportVO.ImportTask) {
|
||||
if (retryingId.value) return;
|
||||
retryingId.value = task.id;
|
||||
try {
|
||||
await retryPddGoodsAdFeeConvertApi(task.id);
|
||||
message.success('已投递转换');
|
||||
await getPddGoodsAdFeeImportTaskApi(task.id);
|
||||
await loadTasks();
|
||||
emit('success');
|
||||
} catch (e) {
|
||||
console.error('重试转换失败:', e);
|
||||
message.error('重试转换失败');
|
||||
} finally {
|
||||
retryingId.value = null;
|
||||
}
|
||||
}
|
||||
|
||||
function openFailedModal(task: PddGoodsAdFeeImportVO.ImportTask) {
|
||||
failedTaskId.value = task.id;
|
||||
failedPage.value = 1;
|
||||
failedOpen.value = true;
|
||||
loadFailedItems();
|
||||
}
|
||||
|
||||
function onFailedPageChange(page: number, pageSize: number) {
|
||||
failedPage.value = page;
|
||||
failedPageSize.value = pageSize;
|
||||
loadFailedItems();
|
||||
}
|
||||
|
||||
function asTask(record: unknown): PddGoodsAdFeeImportVO.ImportTask {
|
||||
return record as PddGoodsAdFeeImportVO.ImportTask;
|
||||
}
|
||||
|
||||
defineExpose({ open: openDrawer });
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Drawer
|
||||
:open="openFlag"
|
||||
:title="title"
|
||||
width="920"
|
||||
destroy-on-close
|
||||
@close="closeDrawer"
|
||||
>
|
||||
<div class="mb-4">
|
||||
<Segmented v-model:value="stage" :options="stageOptions" block />
|
||||
</div>
|
||||
|
||||
<div v-if="stage === 'import'" class="mb-3 text-sm text-slate-500">
|
||||
推广费通过浏览器扩展批量导入;此处可查看导入任务与失败明细。
|
||||
</div>
|
||||
<div v-else class="mb-3 text-sm text-slate-500">
|
||||
导入成功后自动投递转换;可对失败或需重跑的任务手动重试转换。
|
||||
</div>
|
||||
|
||||
<Table
|
||||
:columns="taskColumns"
|
||||
:data-source="tasks"
|
||||
:loading="listLoading || pageLoading"
|
||||
row-key="id"
|
||||
size="small"
|
||||
:scroll="{ x: 900 }"
|
||||
:pagination="false"
|
||||
>
|
||||
<template #bodyCell="{ column, record }">
|
||||
<template v-if="column.key === 'importStatus'">
|
||||
<Tag :color="importStatusTag(asTask(record).status).color">
|
||||
{{ importStatusTag(asTask(record).status).text }}
|
||||
</Tag>
|
||||
</template>
|
||||
<template v-else-if="column.key === 'importCount'">
|
||||
{{ asTask(record).successCount ?? 0 }}/{{ asTask(record).failCount ?? 0 }}
|
||||
</template>
|
||||
<template v-else-if="column.key === 'convertStatus'">
|
||||
<Tag :color="convertStatusTag(asTask(record).convertStatus).color">
|
||||
{{ convertStatusTag(asTask(record).convertStatus).text }}
|
||||
</Tag>
|
||||
</template>
|
||||
<template v-else-if="column.key === 'finishedAt'">
|
||||
{{
|
||||
formatTime(
|
||||
asTask(record).finishedAt || asTask(record).convertFinishedAt,
|
||||
)
|
||||
}}
|
||||
</template>
|
||||
<template v-else-if="column.key === 'action'">
|
||||
<Space>
|
||||
<Button
|
||||
v-if="canShowFailed(asTask(record))"
|
||||
type="link"
|
||||
size="small"
|
||||
@click="openFailedModal(asTask(record))"
|
||||
>
|
||||
失败明细
|
||||
</Button>
|
||||
<Button
|
||||
v-if="canRetryConvert(asTask(record))"
|
||||
type="link"
|
||||
size="small"
|
||||
:loading="retryingId === asTask(record).id"
|
||||
@click="handleRetryConvert(asTask(record))"
|
||||
>
|
||||
重试转换
|
||||
</Button>
|
||||
</Space>
|
||||
</template>
|
||||
</template>
|
||||
</Table>
|
||||
|
||||
<Modal
|
||||
v-model:open="failedOpen"
|
||||
title="导入失败明细"
|
||||
width="760"
|
||||
:footer="null"
|
||||
destroy-on-close
|
||||
>
|
||||
<Table
|
||||
:columns="failedColumns"
|
||||
:data-source="failedItems"
|
||||
:loading="failedLoading"
|
||||
row-key="id"
|
||||
size="small"
|
||||
:pagination="{
|
||||
current: failedPage,
|
||||
pageSize: failedPageSize,
|
||||
total: failedTotal,
|
||||
showSizeChanger: true,
|
||||
onChange: onFailedPageChange,
|
||||
}"
|
||||
/>
|
||||
</Modal>
|
||||
</Drawer>
|
||||
</template>
|
||||
@@ -16,6 +16,8 @@ import dayjs from 'dayjs';
|
||||
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
import { getPddAuthorizeUrlApi } from '#/api/channel/pdd/auth';
|
||||
import { batchPddOrderSyncStatusApi } from '#/api/channel/pdd/order-sync';
|
||||
import { batchPddAdFeePipelineStatusApi } from '#/api/channel/pdd/goods-ad-fee-import';
|
||||
import type { PddGoodsAdFeeImportVO } from '#/api/channel/pdd/goods-ad-fee-import';
|
||||
import { getPlatformListApi } from '#/api/ec/platform';
|
||||
import { deleteShopApi, getShopPageApi } from '#/api/ec/shop';
|
||||
import {
|
||||
@@ -25,6 +27,7 @@ import {
|
||||
|
||||
import ShopFormModal from './components/ShopFormModal.vue';
|
||||
import ShopOrderPipelineDrawer from './components/ShopOrderPipelineDrawer.vue';
|
||||
import ShopAdFeePipelineDrawer from './components/ShopAdFeePipelineDrawer.vue';
|
||||
import PddShopDetailModal from '#/views/channel/pdd/shop/components/PddShopDetailModal.vue';
|
||||
|
||||
defineOptions({ name: 'ShopManagement' });
|
||||
@@ -38,14 +41,17 @@ const authorizing = ref(false);
|
||||
const shopFormModalRef = ref();
|
||||
const pddShopDetailModalRef = ref();
|
||||
const pipelineDrawerRef = ref<InstanceType<typeof ShopOrderPipelineDrawer>>();
|
||||
const adFeePipelineDrawerRef = ref<InstanceType<typeof ShopAdFeePipelineDrawer>>();
|
||||
|
||||
/** shopId -> 同步/转换/计算摘要 */
|
||||
const syncStatusMap = ref<Record<number, PddOrderSyncVO.ShopStatus>>({});
|
||||
/** shopId -> 推广费导入/转换摘要(最近一条任务) */
|
||||
const adFeeStatusMap = ref<Record<number, PddGoodsAdFeeImportVO.ShopStatus>>({});
|
||||
|
||||
/** 主行带店铺字段;次行用 shop 挂店铺,供 VXE data 使用(避免联合类型与 Data<T> 不兼容) */
|
||||
type ShopListRow = Partial<ShopVO.Info> & {
|
||||
_rowKey: string;
|
||||
_rowType: 'main' | 'pipeline';
|
||||
_rowType: 'adfee-pipeline' | 'main' | 'pipeline';
|
||||
_shopIndex: number;
|
||||
/** 主行:是否有管线次行(序号列 rowspan) */
|
||||
_hasPipeline?: boolean;
|
||||
@@ -85,6 +91,13 @@ function toShopListRows(records: ShopVO.Info[]): ShopListRow[] {
|
||||
id: shop.id,
|
||||
shop,
|
||||
});
|
||||
rows.push({
|
||||
_rowKey: `${shop.id}-adfee-pipeline`,
|
||||
_rowType: 'adfee-pipeline',
|
||||
_shopIndex: index,
|
||||
id: shop.id,
|
||||
shop,
|
||||
});
|
||||
}
|
||||
});
|
||||
return rows;
|
||||
@@ -153,21 +166,24 @@ const gridOptions: VxeGridProps<ShopListRow> = {
|
||||
isHover: true,
|
||||
keyField: '_rowKey',
|
||||
},
|
||||
rowClassName: ({ row }) =>
|
||||
row._rowType === 'pipeline' ? 'shop-row-pipeline' : 'shop-row-main',
|
||||
rowClassName: ({ row }) => {
|
||||
if (row._rowType === 'pipeline') return 'shop-row-pipeline';
|
||||
if (row._rowType === 'adfee-pipeline') return 'shop-row-adfee-pipeline';
|
||||
return 'shop-row-main';
|
||||
},
|
||||
spanMethod: ({ row, columnIndex }) => {
|
||||
// 序号列:主行与管线次行纵向合并
|
||||
// 序号列:主行与两条管线次行纵向合并
|
||||
if (columnIndex === 0) {
|
||||
if (row._rowType === 'main' && row._hasPipeline) {
|
||||
return { rowspan: 2, colspan: 1 };
|
||||
return { rowspan: 3, colspan: 1 };
|
||||
}
|
||||
if (row._rowType === 'pipeline') {
|
||||
if (row._rowType === 'pipeline' || row._rowType === 'adfee-pipeline') {
|
||||
return { rowspan: 0, colspan: 0 };
|
||||
}
|
||||
return { rowspan: 1, colspan: 1 };
|
||||
}
|
||||
// 管线次行:从 Logo 起横向合并剩余列展示三阶段
|
||||
if (row._rowType === 'pipeline') {
|
||||
// 管线次行:从 Logo 起横向合并剩余列
|
||||
if (row._rowType === 'pipeline' || row._rowType === 'adfee-pipeline') {
|
||||
if (columnIndex === 1) {
|
||||
return { rowspan: 1, colspan: COLUMN_COUNT - 1 };
|
||||
}
|
||||
@@ -222,6 +238,7 @@ const gridOptions: VxeGridProps<ShopListRow> = {
|
||||
const data = await getShopPageApi(params);
|
||||
const records = data.records || [];
|
||||
await loadSyncStatusForShops(records);
|
||||
await loadAdFeeStatusForShops(records);
|
||||
return {
|
||||
items: toShopListRows(records),
|
||||
total: data.total,
|
||||
@@ -323,6 +340,27 @@ async function loadSyncStatusForShops(records: ShopVO.Info[]) {
|
||||
}
|
||||
}
|
||||
|
||||
async function loadAdFeeStatusForShops(records: ShopVO.Info[]) {
|
||||
const pddIds = records
|
||||
.filter((r) => r.platformCode === PLATFORM_CODE_PDD && hasExternalShop(r))
|
||||
.map((r) => r.id);
|
||||
if (pddIds.length === 0) {
|
||||
adFeeStatusMap.value = {};
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const list = await batchPddAdFeePipelineStatusApi(pddIds);
|
||||
const map: Record<number, PddGoodsAdFeeImportVO.ShopStatus> = {};
|
||||
for (const item of list || []) {
|
||||
map[item.shopId] = item;
|
||||
}
|
||||
adFeeStatusMap.value = map;
|
||||
} catch (error) {
|
||||
console.error('加载推广费管线状态失败:', error);
|
||||
adFeeStatusMap.value = {};
|
||||
}
|
||||
}
|
||||
|
||||
function formatRelative(time?: null | string) {
|
||||
if (!time) return '';
|
||||
const d = dayjs(time);
|
||||
@@ -444,7 +482,16 @@ function isPipelineRow(row: ShopListRow): boolean {
|
||||
return row._rowType === 'pipeline';
|
||||
}
|
||||
|
||||
function isAdFeePipelineRow(row: ShopListRow): boolean {
|
||||
return row._rowType === 'adfee-pipeline';
|
||||
}
|
||||
|
||||
function isSubPipelineRow(row: ShopListRow): boolean {
|
||||
return isPipelineRow(row) || isAdFeePipelineRow(row);
|
||||
}
|
||||
|
||||
type PipelineStageKey = 'calc' | 'convert' | 'sync';
|
||||
type AdFeePipelineStageKey = 'convert' | 'import';
|
||||
|
||||
function openPipelineStage(shop: ShopVO.Info, stage: PipelineStageKey) {
|
||||
if (!hasExternalShop(shop)) {
|
||||
@@ -454,6 +501,68 @@ function openPipelineStage(shop: ShopVO.Info, stage: PipelineStageKey) {
|
||||
pipelineDrawerRef.value?.open(shop, stage);
|
||||
}
|
||||
|
||||
function openAdFeePipelineStage(shop: ShopVO.Info, stage: AdFeePipelineStageKey) {
|
||||
if (!hasExternalShop(shop)) {
|
||||
message.warning('请先完成拼多多授权绑定');
|
||||
return;
|
||||
}
|
||||
adFeePipelineDrawerRef.value?.open(shop, stage);
|
||||
}
|
||||
|
||||
type AdFeePipelineStepView = {
|
||||
key: AdFeePipelineStageKey;
|
||||
title: string;
|
||||
tone: PipelineTone;
|
||||
statusText: string;
|
||||
timeText: string;
|
||||
stepStatus: 'error' | 'finish' | 'process' | 'wait';
|
||||
};
|
||||
|
||||
function toneFromAdFeeStage(
|
||||
status?: string | null,
|
||||
summary?: string | null,
|
||||
): PipelineTone {
|
||||
if (status === 'failed') return 'error';
|
||||
if (status === 'partial') return 'warn';
|
||||
if (status === 'processing' || status === 'pending') return 'warn';
|
||||
if (status === 'success') return 'ok';
|
||||
if (status === 'skipped') return 'off';
|
||||
if (summary) return 'idle';
|
||||
return 'idle';
|
||||
}
|
||||
|
||||
/** 推广费次行:导入 → 转换(最近一条任务摘要) */
|
||||
function buildAdFeePipelineSteps(
|
||||
status?: PddGoodsAdFeeImportVO.ShopStatus,
|
||||
): AdFeePipelineStepView[] {
|
||||
const importTone = toneFromAdFeeStage(
|
||||
status?.importStage?.status,
|
||||
status?.importStage?.summary,
|
||||
);
|
||||
const convertTone = toneFromAdFeeStage(
|
||||
status?.convertStage?.status,
|
||||
status?.convertStage?.summary,
|
||||
);
|
||||
return [
|
||||
{
|
||||
key: 'import',
|
||||
title: '导入',
|
||||
tone: importTone,
|
||||
statusText: toneLabel(importTone),
|
||||
timeText: formatStageTime(status?.importStage?.lastFinishedAt),
|
||||
stepStatus: toneToStepStatus(importTone),
|
||||
},
|
||||
{
|
||||
key: 'convert',
|
||||
title: '转换',
|
||||
tone: convertTone,
|
||||
statusText: toneLabel(convertTone),
|
||||
timeText: formatStageTime(status?.convertStage?.lastFinishedAt),
|
||||
stepStatus: toneToStepStatus(convertTone),
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
function refreshTable() {
|
||||
gridApi?.reload();
|
||||
}
|
||||
@@ -561,7 +670,7 @@ onUnmounted(() => {
|
||||
</template>
|
||||
|
||||
<template #seq="{ row }: { row: ShopListRow }">
|
||||
<span v-if="!isPipelineRow(row)">{{ row._shopIndex + 1 }}</span>
|
||||
<span v-if="!isSubPipelineRow(row)">{{ row._shopIndex + 1 }}</span>
|
||||
</template>
|
||||
|
||||
<template #logoOrPipeline="{ row }: { row: ShopListRow }">
|
||||
@@ -569,6 +678,7 @@ onUnmounted(() => {
|
||||
v-if="isPipelineRow(row) && row.shop"
|
||||
class="flex w-full items-center px-1 text-left"
|
||||
>
|
||||
<span class="mr-2 shrink-0 text-xs text-slate-400">订单</span>
|
||||
<Steps size="small" class="shop-pipeline-steps min-w-0 flex-1">
|
||||
<Steps.Step
|
||||
v-for="step in buildPipelineSteps(syncStatusMap[row.shop.id])"
|
||||
@@ -605,6 +715,46 @@ onUnmounted(() => {
|
||||
</Steps.Step>
|
||||
</Steps>
|
||||
</div>
|
||||
<div
|
||||
v-else-if="isAdFeePipelineRow(row) && row.shop"
|
||||
class="flex w-full items-center px-1 text-left"
|
||||
>
|
||||
<span class="mr-2 shrink-0 text-xs text-slate-400">推广费</span>
|
||||
<Steps size="small" class="shop-pipeline-steps min-w-0 flex-1">
|
||||
<Steps.Step
|
||||
v-for="step in buildAdFeePipelineSteps(adFeeStatusMap[row.shop.id])"
|
||||
:key="step.key"
|
||||
:status="step.stepStatus"
|
||||
>
|
||||
<template #title>
|
||||
<span
|
||||
class="cursor-pointer hover:text-primary"
|
||||
@click.stop="
|
||||
openAdFeePipelineStage(
|
||||
row.shop!,
|
||||
step.key as AdFeePipelineStageKey,
|
||||
)
|
||||
"
|
||||
>
|
||||
{{ 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="
|
||||
openAdFeePipelineStage(
|
||||
row.shop!,
|
||||
step.key as AdFeePipelineStageKey,
|
||||
)
|
||||
"
|
||||
>
|
||||
<div>最近 {{ step.timeText }}</div>
|
||||
</div>
|
||||
</template>
|
||||
</Steps.Step>
|
||||
</Steps>
|
||||
</div>
|
||||
<div
|
||||
v-else
|
||||
class="shop-logo-cell flex items-center justify-center"
|
||||
@@ -625,16 +775,16 @@ onUnmounted(() => {
|
||||
</template>
|
||||
|
||||
<template #name="{ row }: { row: ShopListRow }">
|
||||
<span v-if="!isPipelineRow(row)">{{ row.name }}</span>
|
||||
<span v-if="!isSubPipelineRow(row)">{{ row.name }}</span>
|
||||
</template>
|
||||
|
||||
<template #platformName="{ row }: { row: ShopListRow }">
|
||||
<span v-if="!isPipelineRow(row)">{{ row.platformName }}</span>
|
||||
<span v-if="!isSubPipelineRow(row)">{{ row.platformName }}</span>
|
||||
</template>
|
||||
|
||||
<template #externalShop="{ row }: { row: ShopListRow }">
|
||||
<div
|
||||
v-if="!isPipelineRow(row) && isPddShop(row)"
|
||||
v-if="!isSubPipelineRow(row) && isPddShop(row)"
|
||||
class="flex flex-col items-center gap-1"
|
||||
>
|
||||
<Tag
|
||||
@@ -659,19 +809,19 @@ onUnmounted(() => {
|
||||
渠道店#{{ row.pddShop.id }}
|
||||
</span>
|
||||
</div>
|
||||
<span v-else-if="!isPipelineRow(row)" class="text-slate-400">-</span>
|
||||
<span v-else-if="!isSubPipelineRow(row)" class="text-slate-400">-</span>
|
||||
</template>
|
||||
|
||||
<template #createTime="{ row }: { row: ShopListRow }">
|
||||
<span v-if="!isPipelineRow(row)">{{ row.createTime }}</span>
|
||||
<span v-if="!isSubPipelineRow(row)">{{ row.createTime }}</span>
|
||||
</template>
|
||||
|
||||
<template #updateTime="{ row }: { row: ShopListRow }">
|
||||
<span v-if="!isPipelineRow(row)">{{ row.updateTime }}</span>
|
||||
<span v-if="!isSubPipelineRow(row)">{{ row.updateTime }}</span>
|
||||
</template>
|
||||
|
||||
<template #action="{ row }: { row: ShopListRow }">
|
||||
<Space v-if="!isPipelineRow(row)">
|
||||
<Space v-if="!isSubPipelineRow(row)">
|
||||
<Button
|
||||
v-if="isPddShop(row)"
|
||||
size="small"
|
||||
@@ -699,6 +849,10 @@ onUnmounted(() => {
|
||||
ref="pipelineDrawerRef"
|
||||
@success="handleModalSuccess"
|
||||
/>
|
||||
<ShopAdFeePipelineDrawer
|
||||
ref="adFeePipelineDrawerRef"
|
||||
@success="handleModalSuccess"
|
||||
/>
|
||||
</Page>
|
||||
</template>
|
||||
|
||||
@@ -707,7 +861,8 @@ onUnmounted(() => {
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
:deep(.shop-grid .shop-row-pipeline .vxe-body--column) {
|
||||
:deep(.shop-grid .shop-row-pipeline .vxe-body--column),
|
||||
:deep(.shop-grid .shop-row-adfee-pipeline .vxe-body--column) {
|
||||
border-top: none;
|
||||
padding-block: 6px !important;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user