mirror of
https://gitee.com/qqtt-ah/ecom-dmb.git
synced 2026-11-24 17:49:19 +08:00
feat: 新增拼多多店铺管理和商品管理
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
import type { PageQueryDTO, PageResultVO } from '#/types/common';
|
||||
|
||||
import { requestClient } from '#/api/request';
|
||||
|
||||
import type { PddGoodsDTO, PddGoodsVO } from './types';
|
||||
|
||||
/** 分页查询拼多多渠道商品 */
|
||||
export async function getPddGoodsPageApi(
|
||||
params: PageQueryDTO<PddGoodsDTO.Filters>,
|
||||
) {
|
||||
return requestClient.post<PageResultVO<PddGoodsVO.Info>>(
|
||||
'/channel/pdd/goods/list',
|
||||
params,
|
||||
);
|
||||
}
|
||||
|
||||
/** 拼多多商品详情(含 SKU) */
|
||||
export async function getPddGoodsDetailApi(id: number) {
|
||||
return requestClient.get<PddGoodsVO.Info>(`/channel/pdd/goods/detail/${id}`);
|
||||
}
|
||||
|
||||
/** 删除拼多多商品及 SKU */
|
||||
export async function deletePddGoodsApi(id: number) {
|
||||
return requestClient.delete<void>(`/channel/pdd/goods/delete/${id}`);
|
||||
}
|
||||
|
||||
/** 按渠道店铺同步商品 */
|
||||
export async function syncPddGoodsByShopApi(pddShopId: number) {
|
||||
return requestClient.post<PddGoodsVO.SyncResult>(
|
||||
`/channel/pdd/goods/sync/${pddShopId}`,
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
export * from './apis';
|
||||
export * from './types';
|
||||
@@ -0,0 +1,59 @@
|
||||
export namespace PddGoodsDTO {
|
||||
export interface Filters {
|
||||
/** 渠道店铺ID(channel_pdd_shop.id) */
|
||||
shopId?: number;
|
||||
mallId?: number;
|
||||
goodsName?: string;
|
||||
goodsId?: string;
|
||||
/** 0否 1是 */
|
||||
isOnsale?: number;
|
||||
/** 0否 1是 */
|
||||
isMoreSku?: number;
|
||||
}
|
||||
}
|
||||
|
||||
export namespace PddGoodsVO {
|
||||
export interface Sku {
|
||||
id?: number;
|
||||
goodsRowId?: number;
|
||||
goodsId?: string;
|
||||
skuId?: string;
|
||||
spec?: string;
|
||||
specDetails?: string;
|
||||
skuQuantity?: number;
|
||||
reserveQuantity?: number;
|
||||
isSkuOnsale?: number;
|
||||
outerGoodsId?: string;
|
||||
outerId?: string;
|
||||
}
|
||||
|
||||
export interface Info {
|
||||
id: number;
|
||||
companyId?: number;
|
||||
shopId?: number;
|
||||
mallId?: number;
|
||||
goodsId?: string;
|
||||
goodsName?: string;
|
||||
goodsQuantity?: number;
|
||||
goodsReserveQuantity?: number;
|
||||
imageUrl?: string;
|
||||
thumbUrl?: string;
|
||||
isMoreSku?: number;
|
||||
isOnsale?: number;
|
||||
pddCreatedAt?: string;
|
||||
lastSyncTime?: string;
|
||||
createTime?: string;
|
||||
updateTime?: string;
|
||||
skus?: Sku[];
|
||||
}
|
||||
|
||||
export interface SyncResult {
|
||||
pddShopId: number;
|
||||
mallId?: number;
|
||||
syncedCount?: number;
|
||||
createdCount?: number;
|
||||
updatedCount?: number;
|
||||
skuCount?: number;
|
||||
pageCount?: number;
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,20 @@
|
||||
import type { PddShopInfo } from '#/api/ec/shop/types';
|
||||
import type { PageQueryDTO, PageResultVO } from '#/types/common';
|
||||
|
||||
import { requestClient } from '#/api/request';
|
||||
|
||||
/**
|
||||
* 拼多多渠道店铺详情(含授权信息,不含 token)
|
||||
*/
|
||||
import type { PddShopDTO, PddShopVO } from './types';
|
||||
|
||||
/** 分页查询拼多多渠道店铺 */
|
||||
export async function getPddShopPageApi(
|
||||
params: PageQueryDTO<PddShopDTO.Filters>,
|
||||
) {
|
||||
return requestClient.post<PageResultVO<PddShopVO.Info>>(
|
||||
'/channel/pdd/shop/list',
|
||||
params,
|
||||
);
|
||||
}
|
||||
|
||||
/** 拼多多渠道店铺详情(含授权信息,不含 token) */
|
||||
export async function getPddShopDetailApi(id: number) {
|
||||
return requestClient.get<PddShopInfo>(`/channel/pdd/shop/detail/${id}`);
|
||||
return requestClient.get<PddShopVO.Info>(`/channel/pdd/shop/detail/${id}`);
|
||||
}
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
export * from './apis';
|
||||
export * from './types';
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
export namespace PddShopDTO {
|
||||
export interface Filters {
|
||||
mallName?: string;
|
||||
merchantType?: number;
|
||||
mallCharacter?: number;
|
||||
pddAuthId?: number;
|
||||
}
|
||||
}
|
||||
|
||||
export namespace PddShopVO {
|
||||
export interface AuthInfo {
|
||||
id: number;
|
||||
companyId?: number;
|
||||
ownerId?: string;
|
||||
expiresAt?: string;
|
||||
refreshTokenExpiresAt?: string;
|
||||
scope?: string;
|
||||
/** 0失效 1正常 2已撤销 */
|
||||
status?: number;
|
||||
createTime?: string;
|
||||
updateTime?: string;
|
||||
}
|
||||
|
||||
export interface Info {
|
||||
id: number;
|
||||
companyId?: number;
|
||||
pddAuthId?: null | number;
|
||||
auth?: AuthInfo | null;
|
||||
mallId?: number;
|
||||
mallName?: string;
|
||||
logo?: string;
|
||||
mallDesc?: string;
|
||||
merchantType?: number;
|
||||
mallCharacter?: number;
|
||||
lastSyncTime?: string;
|
||||
createTime?: string;
|
||||
updateTime?: string;
|
||||
}
|
||||
}
|
||||
+150
@@ -0,0 +1,150 @@
|
||||
<script lang="ts" setup>
|
||||
import type { PddGoodsVO } from '#/api/channel/pdd/goods';
|
||||
|
||||
import { ref } from 'vue';
|
||||
|
||||
import {
|
||||
Descriptions,
|
||||
DescriptionsItem,
|
||||
Drawer,
|
||||
Image,
|
||||
Spin,
|
||||
Table,
|
||||
Tag,
|
||||
message,
|
||||
} from 'ant-design-vue';
|
||||
|
||||
import { getPddGoodsDetailApi } from '#/api/channel/pdd/goods';
|
||||
|
||||
defineOptions({ name: 'PddGoodsDetailDrawer' });
|
||||
|
||||
const openFlag = ref(false);
|
||||
const loading = ref(false);
|
||||
const shopName = ref('');
|
||||
const detail = ref<null | PddGoodsVO.Info>(null);
|
||||
|
||||
const skuColumns = [
|
||||
{
|
||||
title: '外部SKU',
|
||||
dataIndex: 'outerId',
|
||||
key: 'outerId',
|
||||
ellipsis: true,
|
||||
width: 140,
|
||||
},
|
||||
{ title: '规格', dataIndex: 'spec', key: 'spec', ellipsis: true },
|
||||
{ title: '库存', dataIndex: 'skuQuantity', key: 'skuQuantity', width: 80 },
|
||||
{
|
||||
title: '预扣',
|
||||
dataIndex: 'reserveQuantity',
|
||||
key: 'reserveQuantity',
|
||||
width: 80,
|
||||
},
|
||||
{ title: '在架', key: 'isSkuOnsale', width: 80 },
|
||||
{
|
||||
title: '外部商品',
|
||||
dataIndex: 'outerGoodsId',
|
||||
key: 'outerGoodsId',
|
||||
ellipsis: true,
|
||||
width: 120,
|
||||
},
|
||||
];
|
||||
|
||||
async function open(id: number, shopLabel?: string) {
|
||||
openFlag.value = true;
|
||||
shopName.value = shopLabel || '';
|
||||
loading.value = true;
|
||||
detail.value = null;
|
||||
try {
|
||||
detail.value = await getPddGoodsDetailApi(id);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
message.error('加载商品详情失败');
|
||||
openFlag.value = false;
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
function close() {
|
||||
openFlag.value = false;
|
||||
}
|
||||
|
||||
defineExpose({ open, close });
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Drawer
|
||||
v-model:open="openFlag"
|
||||
:title="detail?.goodsName || '拼多多商品详情'"
|
||||
width="720"
|
||||
destroy-on-close
|
||||
>
|
||||
<Spin :spinning="loading">
|
||||
<template v-if="detail">
|
||||
<div class="mb-4 flex gap-4">
|
||||
<Image
|
||||
v-if="detail.thumbUrl || detail.imageUrl"
|
||||
:src="detail.thumbUrl || detail.imageUrl"
|
||||
:width="72"
|
||||
:height="72"
|
||||
/>
|
||||
<div class="min-w-0 flex-1">
|
||||
<div class="truncate text-base font-medium">
|
||||
{{ detail.goodsName }}
|
||||
</div>
|
||||
<div class="mt-2 flex flex-wrap gap-2">
|
||||
<Tag :color="detail.isOnsale === 1 ? 'success' : 'default'">
|
||||
{{ detail.isOnsale === 1 ? '在架' : '下架' }}
|
||||
</Tag>
|
||||
<Tag :color="detail.isMoreSku === 1 ? 'blue' : 'default'">
|
||||
{{ detail.isMoreSku === 1 ? '多SKU' : '单SKU' }}
|
||||
</Tag>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<Descriptions bordered :column="2" size="small" class="mb-4">
|
||||
<DescriptionsItem label="goods_id">
|
||||
{{ detail.goodsId || '-' }}
|
||||
</DescriptionsItem>
|
||||
<DescriptionsItem label="mall_id">
|
||||
{{ detail.mallId ?? '-' }}
|
||||
</DescriptionsItem>
|
||||
<DescriptionsItem label="渠道店铺" :span="2">
|
||||
{{ shopName || `渠道店#${detail.shopId}` }}
|
||||
</DescriptionsItem>
|
||||
<DescriptionsItem label="总库存">
|
||||
{{ detail.goodsQuantity ?? 0 }}
|
||||
</DescriptionsItem>
|
||||
<DescriptionsItem label="预扣库存">
|
||||
{{ detail.goodsReserveQuantity ?? 0 }}
|
||||
</DescriptionsItem>
|
||||
<DescriptionsItem label="最近同步">
|
||||
{{ detail.lastSyncTime || '-' }}
|
||||
</DescriptionsItem>
|
||||
<DescriptionsItem label="平台创建">
|
||||
{{ detail.pddCreatedAt || '-' }}
|
||||
</DescriptionsItem>
|
||||
</Descriptions>
|
||||
|
||||
<div class="mb-2 text-sm font-medium">SKU 明细</div>
|
||||
<Table
|
||||
size="small"
|
||||
:pagination="false"
|
||||
:columns="skuColumns"
|
||||
:data-source="detail.skus || []"
|
||||
:row-key="(r: PddGoodsVO.Sku) => String(r.id ?? r.skuId)"
|
||||
:scroll="{ x: 700 }"
|
||||
>
|
||||
<template #bodyCell="{ column, record }">
|
||||
<template v-if="column.key === 'isSkuOnsale'">
|
||||
<Tag :color="record.isSkuOnsale === 1 ? 'success' : 'default'">
|
||||
{{ record.isSkuOnsale === 1 ? '在架' : '下架' }}
|
||||
</Tag>
|
||||
</template>
|
||||
</template>
|
||||
</Table>
|
||||
</template>
|
||||
</Spin>
|
||||
</Drawer>
|
||||
</template>
|
||||
@@ -0,0 +1,387 @@
|
||||
<script lang="ts" setup>
|
||||
import type { VxeGridProps } from '#/adapter/vxe-table';
|
||||
import type { PddGoodsDTO, PddGoodsVO } from '#/api/channel/pdd/goods';
|
||||
import type { PddShopVO } from '#/api/channel/pdd/shop';
|
||||
import type { PageQueryDTO } from '#/types/common';
|
||||
|
||||
import { computed, onMounted, ref } from 'vue';
|
||||
|
||||
import { Page } from '@vben/common-ui';
|
||||
|
||||
import { Button, Image, Popconfirm, Space, Tag, message } from 'ant-design-vue';
|
||||
|
||||
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
import {
|
||||
deletePddGoodsApi,
|
||||
getPddGoodsPageApi,
|
||||
} from '#/api/channel/pdd/goods';
|
||||
import { getPddShopPageApi } from '#/api/channel/pdd/shop';
|
||||
|
||||
import PddGoodsDetailDrawer from './components/PddGoodsDetailDrawer.vue';
|
||||
import PddShopDetailModal from '#/views/channel/pdd/shop/components/PddShopDetailModal.vue';
|
||||
|
||||
defineOptions({ name: 'PddGoodsManagement' });
|
||||
|
||||
const loading = ref(false);
|
||||
const detailDrawerRef = ref<InstanceType<typeof PddGoodsDetailDrawer>>();
|
||||
const shopDetailModalRef = ref<InstanceType<typeof PddShopDetailModal>>();
|
||||
const shopOptions = ref<{ label: string; value: number }[]>([]);
|
||||
const shopNameById = ref<Record<number, string>>({});
|
||||
|
||||
const searchForm = ref({
|
||||
shopId: undefined as number | undefined,
|
||||
goodsName: '',
|
||||
goodsId: '',
|
||||
isOnsale: undefined as number | undefined,
|
||||
});
|
||||
|
||||
const gridReloadRef = ref<null | (() => void)>(null);
|
||||
|
||||
async function loadShops() {
|
||||
try {
|
||||
const data = await getPddShopPageApi({
|
||||
page: 1,
|
||||
pageSize: 500,
|
||||
filters: {},
|
||||
});
|
||||
const list = data.records ?? [];
|
||||
shopOptions.value = list.map((s: PddShopVO.Info) => ({
|
||||
label: s.mallName || `店铺#${s.id}`,
|
||||
value: s.id,
|
||||
}));
|
||||
const map: Record<number, string> = {};
|
||||
for (const s of list) {
|
||||
map[s.id] = s.mallName || `店铺#${s.id}`;
|
||||
}
|
||||
shopNameById.value = map;
|
||||
|
||||
await gridApi.formApi?.updateSchema([
|
||||
{
|
||||
fieldName: 'shopId',
|
||||
componentProps: { options: shopOptions.value },
|
||||
},
|
||||
]);
|
||||
} catch {
|
||||
message.error('获取渠道店铺失败');
|
||||
}
|
||||
}
|
||||
|
||||
const gridOptions: VxeGridProps<PddGoodsVO.Info> = {
|
||||
columns: [
|
||||
{ type: 'seq' as const, width: 56, title: '序号' },
|
||||
{
|
||||
title: '主图',
|
||||
width: 80,
|
||||
align: 'center' as const,
|
||||
showOverflow: false,
|
||||
slots: { default: 'thumb' },
|
||||
},
|
||||
{
|
||||
title: '商品名称',
|
||||
minWidth: 200,
|
||||
showOverflow: 'tooltip' as const,
|
||||
slots: { default: 'goodsName' },
|
||||
},
|
||||
{
|
||||
title: '渠道店铺',
|
||||
minWidth: 140,
|
||||
showOverflow: 'tooltip' as const,
|
||||
slots: { default: 'shop' },
|
||||
},
|
||||
{
|
||||
title: '状态',
|
||||
width: 90,
|
||||
slots: { default: 'onsale' },
|
||||
},
|
||||
{
|
||||
title: 'SKU',
|
||||
width: 80,
|
||||
slots: { default: 'moreSku' },
|
||||
},
|
||||
{
|
||||
field: 'goodsQuantity',
|
||||
title: '库存',
|
||||
width: 80,
|
||||
},
|
||||
{
|
||||
field: 'pddCreatedAt',
|
||||
title: '拼多多创建时间',
|
||||
minWidth: 160,
|
||||
},
|
||||
{
|
||||
field: 'lastSyncTime',
|
||||
title: '最近同步',
|
||||
minWidth: 160,
|
||||
},
|
||||
{
|
||||
field: 'updateTime',
|
||||
title: '更新时间',
|
||||
minWidth: 160,
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
minWidth: 140,
|
||||
fixed: 'right' as const,
|
||||
showOverflow: false,
|
||||
slots: { default: 'action' },
|
||||
},
|
||||
],
|
||||
height: 'auto',
|
||||
border: true,
|
||||
stripe: true,
|
||||
rowConfig: { isHover: true, height: 72 },
|
||||
showOverflow: true,
|
||||
size: 'small',
|
||||
toolbarConfig: {
|
||||
custom: true,
|
||||
refresh: true,
|
||||
zoom: true,
|
||||
},
|
||||
data: [],
|
||||
pagerConfig: {
|
||||
enabled: true,
|
||||
pageSizes: [10, 20, 50, 100],
|
||||
layouts: [
|
||||
'PrevJump',
|
||||
'PrevPage',
|
||||
'Number',
|
||||
'NextPage',
|
||||
'NextJump',
|
||||
'Sizes',
|
||||
'FullJump',
|
||||
'Total',
|
||||
] as (
|
||||
| 'FullJump'
|
||||
| 'NextJump'
|
||||
| 'NextPage'
|
||||
| 'Number'
|
||||
| 'PrevJump'
|
||||
| 'PrevPage'
|
||||
| 'Sizes'
|
||||
| 'Total'
|
||||
)[],
|
||||
},
|
||||
proxyConfig: {
|
||||
ajax: {
|
||||
query: async ({ page }: any) => {
|
||||
try {
|
||||
loading.value = true;
|
||||
const params: PageQueryDTO<PddGoodsDTO.Filters> = {
|
||||
page: page.currentPage,
|
||||
pageSize: page.pageSize,
|
||||
filters: {
|
||||
shopId: searchForm.value.shopId,
|
||||
goodsName: searchForm.value.goodsName || undefined,
|
||||
goodsId: searchForm.value.goodsId || undefined,
|
||||
isOnsale: searchForm.value.isOnsale,
|
||||
},
|
||||
};
|
||||
const data = await getPddGoodsPageApi(params);
|
||||
return {
|
||||
items: data.records ?? [],
|
||||
total: data.total ?? 0,
|
||||
};
|
||||
} catch (error) {
|
||||
console.error('获取拼多多商品失败:', error);
|
||||
message.error('获取拼多多商品失败');
|
||||
return { items: [], total: 0 };
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
const formOptions = computed(() => ({
|
||||
schema: [
|
||||
{
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
placeholder: '全部店铺',
|
||||
options: shopOptions.value,
|
||||
allowClear: true,
|
||||
showSearch: true,
|
||||
optionFilterProp: 'label',
|
||||
onChange: (val: number | undefined) => {
|
||||
searchForm.value.shopId = val;
|
||||
gridReloadRef.value?.();
|
||||
},
|
||||
},
|
||||
fieldName: 'shopId',
|
||||
label: '渠道店铺',
|
||||
},
|
||||
{
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '商品名称(模糊)',
|
||||
allowClear: true,
|
||||
onChange: (e: any) => {
|
||||
searchForm.value.goodsName = e?.target?.value ?? '';
|
||||
},
|
||||
onPressEnter: () => gridReloadRef.value?.(),
|
||||
},
|
||||
fieldName: 'goodsName',
|
||||
label: '商品名称',
|
||||
},
|
||||
{
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '拼多多商品ID',
|
||||
allowClear: true,
|
||||
onChange: (e: any) => {
|
||||
searchForm.value.goodsId = e?.target?.value ?? '';
|
||||
},
|
||||
onPressEnter: () => gridReloadRef.value?.(),
|
||||
},
|
||||
fieldName: 'goodsId',
|
||||
label: 'goods_id',
|
||||
},
|
||||
{
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
placeholder: '全部',
|
||||
allowClear: true,
|
||||
options: [
|
||||
{ label: '在架', value: 1 },
|
||||
{ label: '下架', value: 0 },
|
||||
],
|
||||
onChange: (val: number | undefined) => {
|
||||
searchForm.value.isOnsale = val;
|
||||
gridReloadRef.value?.();
|
||||
},
|
||||
},
|
||||
fieldName: 'isOnsale',
|
||||
label: '在架状态',
|
||||
},
|
||||
],
|
||||
submitButtonOptions: { content: '搜索' },
|
||||
resetButtonOptions: { content: '重置' },
|
||||
handleSubmit: async () => {
|
||||
gridReloadRef.value?.();
|
||||
},
|
||||
handleReset: async () => {
|
||||
searchForm.value = {
|
||||
shopId: undefined,
|
||||
goodsName: '',
|
||||
goodsId: '',
|
||||
isOnsale: undefined,
|
||||
};
|
||||
gridReloadRef.value?.();
|
||||
},
|
||||
}));
|
||||
|
||||
const [Grid, gridApi] = useVbenVxeGrid({
|
||||
gridOptions,
|
||||
formOptions: formOptions.value,
|
||||
showSearchForm: true,
|
||||
tableTitle: '拼多多渠道商品',
|
||||
});
|
||||
|
||||
gridReloadRef.value = () => gridApi.reload();
|
||||
|
||||
function openDetail(row: PddGoodsVO.Info) {
|
||||
const shopLabel = row.shopId
|
||||
? shopNameById.value[row.shopId]
|
||||
: undefined;
|
||||
detailDrawerRef.value?.open(row.id, shopLabel);
|
||||
}
|
||||
|
||||
function openShopDetail(row: PddGoodsVO.Info) {
|
||||
if (!row.shopId) {
|
||||
message.warning('该商品未关联渠道店铺');
|
||||
return;
|
||||
}
|
||||
shopDetailModalRef.value?.open(row.shopId);
|
||||
}
|
||||
|
||||
async function handleDelete(row: PddGoodsVO.Info) {
|
||||
try {
|
||||
await deletePddGoodsApi(row.id);
|
||||
message.success('已删除');
|
||||
gridApi.reload();
|
||||
} catch (error: any) {
|
||||
message.error(error?.message || '删除失败');
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(async () => {
|
||||
await loadShops();
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Page auto-content-height>
|
||||
<Grid class="pdd-goods-grid">
|
||||
<template #thumb="{ row }: { row: PddGoodsVO.Info }">
|
||||
<Image
|
||||
v-if="row.thumbUrl || row.imageUrl"
|
||||
:src="row.thumbUrl || row.imageUrl"
|
||||
:width="40"
|
||||
:height="40"
|
||||
class="goods-thumb"
|
||||
/>
|
||||
<span v-else class="text-slate-400">-</span>
|
||||
</template>
|
||||
|
||||
<template #goodsName="{ row }: { row: PddGoodsVO.Info }">
|
||||
<Button type="link" size="small" class="!px-0" @click="openDetail(row)">
|
||||
{{ row.goodsName || '-' }}
|
||||
</Button>
|
||||
</template>
|
||||
|
||||
<template #shop="{ row }: { row: PddGoodsVO.Info }">
|
||||
<Button
|
||||
v-if="row.shopId"
|
||||
type="link"
|
||||
size="small"
|
||||
class="!px-0"
|
||||
@click="openShopDetail(row)"
|
||||
>
|
||||
{{ shopNameById[row.shopId] || `渠道店#${row.shopId}` }}
|
||||
</Button>
|
||||
<span v-else>-</span>
|
||||
</template>
|
||||
|
||||
<template #onsale="{ row }: { row: PddGoodsVO.Info }">
|
||||
<Tag :color="row.isOnsale === 1 ? 'success' : 'default'">
|
||||
{{ row.isOnsale === 1 ? '在架' : '下架' }}
|
||||
</Tag>
|
||||
</template>
|
||||
|
||||
<template #moreSku="{ row }: { row: PddGoodsVO.Info }">
|
||||
<Tag :color="row.isMoreSku === 1 ? 'blue' : 'default'">
|
||||
{{ row.isMoreSku === 1 ? '多SKU' : '单SKU' }}
|
||||
</Tag>
|
||||
</template>
|
||||
|
||||
<template #action="{ row }: { row: PddGoodsVO.Info }">
|
||||
<Space size="small" :wrap="false">
|
||||
<Button type="link" size="small" @click="openDetail(row)">
|
||||
详情
|
||||
</Button>
|
||||
<Popconfirm
|
||||
title="确定删除该商品及全部 SKU 吗?"
|
||||
@confirm="handleDelete(row)"
|
||||
>
|
||||
<Button type="link" size="small" danger>删除</Button>
|
||||
</Popconfirm>
|
||||
</Space>
|
||||
</template>
|
||||
</Grid>
|
||||
|
||||
<PddGoodsDetailDrawer ref="detailDrawerRef" />
|
||||
<PddShopDetailModal ref="shopDetailModalRef" />
|
||||
</Page>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.goods-thumb {
|
||||
border-radius: 6px;
|
||||
object-fit: cover;
|
||||
}
|
||||
|
||||
:deep(.pdd-goods-grid .vxe-body--column) {
|
||||
vertical-align: middle;
|
||||
}
|
||||
</style>
|
||||
+12
-6
@@ -1,5 +1,5 @@
|
||||
<script lang="ts" setup>
|
||||
import type { PddShopInfo } from '#/api/ec/shop/types';
|
||||
import type { PddShopVO } from '#/api/channel/pdd/shop';
|
||||
|
||||
import { computed, ref } from 'vue';
|
||||
|
||||
@@ -9,6 +9,8 @@ import { Descriptions, Spin, Tag, message } from 'ant-design-vue';
|
||||
|
||||
import { getPddShopDetailApi } from '#/api/channel/pdd/shop';
|
||||
|
||||
defineOptions({ name: 'PddShopDetailModal' });
|
||||
|
||||
const MERCHANT_TYPE_MAP: Record<number, string> = {
|
||||
1: '个人',
|
||||
2: '企业',
|
||||
@@ -32,7 +34,7 @@ const AUTH_STATUS_MAP: Record<number, { color: string; label: string }> = {
|
||||
};
|
||||
|
||||
const loading = ref(false);
|
||||
const pddShop = ref<null | PddShopInfo>(null);
|
||||
const pddShop = ref<null | PddShopVO.Info>(null);
|
||||
const internalShopName = ref('');
|
||||
|
||||
const [Modal, modalApi] = useVbenModal({
|
||||
@@ -64,9 +66,13 @@ const authStatus = computed(() => {
|
||||
return AUTH_STATUS_MAP[status] ?? { color: 'default', label: String(status) };
|
||||
});
|
||||
|
||||
/**
|
||||
* @param pddShopId channel_pdd_shop.id
|
||||
* @param shopName 可选:内部店铺名等上下文标题旁注
|
||||
*/
|
||||
async function open(pddShopId: number, shopName?: string) {
|
||||
if (!pddShopId) {
|
||||
message.warning('暂无外部店铺详情,请先完成授权同步');
|
||||
message.warning('暂无外部店铺详情');
|
||||
return;
|
||||
}
|
||||
internalShopName.value = shopName || '';
|
||||
@@ -88,7 +94,7 @@ defineExpose({ open });
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Modal title="拼多多外部店铺" content-class="px-5 py-4">
|
||||
<Modal title="拼多多渠道店铺详情" content-class="px-5 py-4">
|
||||
<Spin :spinning="loading">
|
||||
<div v-if="pddShop" class="space-y-4">
|
||||
<div class="flex items-center gap-3">
|
||||
@@ -103,13 +109,13 @@ defineExpose({ open });
|
||||
{{ pddShop.mallName || '-' }}
|
||||
</div>
|
||||
<div v-if="internalShopName" class="mt-1 text-xs text-slate-500">
|
||||
内部店铺:{{ internalShopName }}
|
||||
{{ internalShopName }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<Descriptions :column="1" bordered size="small" title="店铺信息">
|
||||
<Descriptions.Item label="平台店铺主键">
|
||||
<Descriptions.Item label="渠道店铺ID">
|
||||
{{ pddShop.id }}
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="mall_id">
|
||||
@@ -0,0 +1,329 @@
|
||||
<script lang="ts" setup>
|
||||
import type { VxeGridProps } from '#/adapter/vxe-table';
|
||||
import type { PddShopDTO, PddShopVO } from '#/api/channel/pdd/shop';
|
||||
import type { PageQueryDTO } from '#/types/common';
|
||||
|
||||
import { computed, ref } from 'vue';
|
||||
|
||||
import { Page } from '@vben/common-ui';
|
||||
|
||||
import { Button, Image, Space, Tag, message } from 'ant-design-vue';
|
||||
|
||||
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
import {
|
||||
getPddShopPageApi,
|
||||
} from '#/api/channel/pdd/shop';
|
||||
import { syncPddGoodsByShopApi } from '#/api/channel/pdd/goods';
|
||||
|
||||
import PddShopDetailModal from './components/PddShopDetailModal.vue';
|
||||
|
||||
defineOptions({ name: 'PddShopManagement' });
|
||||
|
||||
const MERCHANT_TYPE_MAP: Record<number, string> = {
|
||||
1: '个人',
|
||||
2: '企业',
|
||||
3: '旗舰店',
|
||||
4: '专卖店',
|
||||
5: '专营店',
|
||||
6: '普通店',
|
||||
};
|
||||
|
||||
const AUTH_STATUS_MAP: Record<number, { color: string; text: string }> = {
|
||||
0: { color: 'error', text: '失效' },
|
||||
1: { color: 'success', text: '正常' },
|
||||
2: { color: 'default', text: '已撤销' },
|
||||
};
|
||||
|
||||
const loading = ref(false);
|
||||
const syncingShopId = ref<null | number>(null);
|
||||
const shopDetailModalRef = ref<InstanceType<typeof PddShopDetailModal>>();
|
||||
|
||||
const searchForm = ref({
|
||||
mallName: '',
|
||||
merchantType: undefined as number | undefined,
|
||||
});
|
||||
|
||||
const gridReloadRef = ref<null | (() => void)>(null);
|
||||
|
||||
const gridOptions: VxeGridProps<PddShopVO.Info> = {
|
||||
columns: [
|
||||
{ type: 'seq' as const, width: 56, title: '序号' },
|
||||
{
|
||||
title: 'Logo',
|
||||
width: 88,
|
||||
align: 'center' as const,
|
||||
showOverflow: false,
|
||||
slots: { default: 'logo' },
|
||||
},
|
||||
{
|
||||
title: '店铺名称',
|
||||
minWidth: 160,
|
||||
showOverflow: 'tooltip' as const,
|
||||
slots: { default: 'mallName' },
|
||||
},
|
||||
{
|
||||
field: 'mallId',
|
||||
title: 'mall_id',
|
||||
minWidth: 120,
|
||||
},
|
||||
{
|
||||
title: '店铺类型',
|
||||
width: 100,
|
||||
slots: { default: 'merchantType' },
|
||||
},
|
||||
{
|
||||
title: '授权',
|
||||
minWidth: 140,
|
||||
slots: { default: 'auth' },
|
||||
},
|
||||
{
|
||||
field: 'lastSyncTime',
|
||||
title: '店铺最近同步',
|
||||
minWidth: 160,
|
||||
},
|
||||
{
|
||||
field: 'createTime',
|
||||
title: '创建时间',
|
||||
minWidth: 160,
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
minWidth: 200,
|
||||
fixed: 'right' as const,
|
||||
showOverflow: false,
|
||||
slots: { default: 'action' },
|
||||
},
|
||||
],
|
||||
height: 'auto',
|
||||
border: true,
|
||||
stripe: true,
|
||||
rowConfig: { isHover: true, height: 72 },
|
||||
showOverflow: true,
|
||||
size: 'small',
|
||||
toolbarConfig: {
|
||||
custom: true,
|
||||
refresh: true,
|
||||
zoom: true,
|
||||
},
|
||||
data: [],
|
||||
pagerConfig: {
|
||||
enabled: true,
|
||||
pageSizes: [10, 20, 50, 100],
|
||||
layouts: [
|
||||
'PrevJump',
|
||||
'PrevPage',
|
||||
'Number',
|
||||
'NextPage',
|
||||
'NextJump',
|
||||
'Sizes',
|
||||
'FullJump',
|
||||
'Total',
|
||||
] as (
|
||||
| 'FullJump'
|
||||
| 'NextJump'
|
||||
| 'NextPage'
|
||||
| 'Number'
|
||||
| 'PrevJump'
|
||||
| 'PrevPage'
|
||||
| 'Sizes'
|
||||
| 'Total'
|
||||
)[],
|
||||
},
|
||||
proxyConfig: {
|
||||
ajax: {
|
||||
query: async ({ page }: any) => {
|
||||
try {
|
||||
loading.value = true;
|
||||
const params: PageQueryDTO<PddShopDTO.Filters> = {
|
||||
page: page.currentPage,
|
||||
pageSize: page.pageSize,
|
||||
filters: {
|
||||
mallName: searchForm.value.mallName || undefined,
|
||||
merchantType: searchForm.value.merchantType,
|
||||
},
|
||||
};
|
||||
const data = await getPddShopPageApi(params);
|
||||
return {
|
||||
items: data.records ?? [],
|
||||
total: data.total ?? 0,
|
||||
};
|
||||
} catch (error) {
|
||||
console.error('获取拼多多店铺失败:', error);
|
||||
message.error('获取拼多多店铺失败');
|
||||
return { items: [], total: 0 };
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
const formOptions = computed(() => ({
|
||||
schema: [
|
||||
{
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '店铺名称(模糊)',
|
||||
allowClear: true,
|
||||
onChange: (e: any) => {
|
||||
searchForm.value.mallName = e?.target?.value ?? '';
|
||||
},
|
||||
onPressEnter: () => gridReloadRef.value?.(),
|
||||
},
|
||||
fieldName: 'mallName',
|
||||
label: '店铺名称',
|
||||
},
|
||||
{
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
placeholder: '全部类型',
|
||||
allowClear: true,
|
||||
options: Object.entries(MERCHANT_TYPE_MAP).map(([value, label]) => ({
|
||||
label,
|
||||
value: Number(value),
|
||||
})),
|
||||
onChange: (val: number | undefined) => {
|
||||
searchForm.value.merchantType = val;
|
||||
gridReloadRef.value?.();
|
||||
},
|
||||
},
|
||||
fieldName: 'merchantType',
|
||||
label: '店铺类型',
|
||||
},
|
||||
],
|
||||
submitButtonOptions: { content: '搜索' },
|
||||
resetButtonOptions: { content: '重置' },
|
||||
handleSubmit: async () => {
|
||||
gridReloadRef.value?.();
|
||||
},
|
||||
handleReset: async () => {
|
||||
searchForm.value = { mallName: '', merchantType: undefined };
|
||||
gridReloadRef.value?.();
|
||||
},
|
||||
}));
|
||||
|
||||
const [Grid, gridApi] = useVbenVxeGrid({
|
||||
gridOptions,
|
||||
formOptions: formOptions.value,
|
||||
showSearchForm: true,
|
||||
tableTitle: '拼多多渠道店铺',
|
||||
});
|
||||
|
||||
gridReloadRef.value = () => gridApi.reload();
|
||||
|
||||
function merchantTypeText(type?: null | number) {
|
||||
if (type == null) return '-';
|
||||
return MERCHANT_TYPE_MAP[type] ?? String(type);
|
||||
}
|
||||
|
||||
function authTag(row: PddShopVO.Info) {
|
||||
if (row.pddAuthId == null) {
|
||||
return { color: 'default', text: '未授权' };
|
||||
}
|
||||
const status = row.auth?.status;
|
||||
if (status == null) {
|
||||
return { color: 'processing', text: '已绑定' };
|
||||
}
|
||||
return AUTH_STATUS_MAP[status] ?? { color: 'default', text: String(status) };
|
||||
}
|
||||
|
||||
function openShopDetail(row: PddShopVO.Info) {
|
||||
if (!row?.id) return;
|
||||
shopDetailModalRef.value?.open(row.id);
|
||||
}
|
||||
|
||||
async function handleSyncGoods(row: PddShopVO.Info) {
|
||||
if (!row?.id) return;
|
||||
if (row.pddAuthId == null) {
|
||||
message.warning('该店铺尚未绑定授权,无法同步商品');
|
||||
return;
|
||||
}
|
||||
if (syncingShopId.value != null) {
|
||||
message.warning('已有同步任务进行中,请稍候');
|
||||
return;
|
||||
}
|
||||
syncingShopId.value = row.id;
|
||||
const hide = message.loading(`正在同步「${row.mallName || row.mallId}」商品…`, 0);
|
||||
try {
|
||||
const result = await syncPddGoodsByShopApi(row.id);
|
||||
message.success(
|
||||
`同步完成:共 ${result.syncedCount ?? 0} 个商品(新增 ${result.createdCount ?? 0} / 更新 ${result.updatedCount ?? 0}),SKU ${result.skuCount ?? 0}`,
|
||||
);
|
||||
gridApi.reload();
|
||||
} catch (error: any) {
|
||||
message.error(error?.message || '同步商品失败');
|
||||
} finally {
|
||||
hide();
|
||||
syncingShopId.value = null;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Page auto-content-height>
|
||||
<Grid class="pdd-shop-grid">
|
||||
<template #logo="{ row }: { row: PddShopVO.Info }">
|
||||
<Image
|
||||
v-if="row.logo"
|
||||
:src="row.logo"
|
||||
:width="40"
|
||||
:height="40"
|
||||
class="shop-logo"
|
||||
/>
|
||||
<span v-else class="text-slate-400">-</span>
|
||||
</template>
|
||||
|
||||
<template #mallName="{ row }: { row: PddShopVO.Info }">
|
||||
<Button type="link" size="small" class="!px-0" @click="openShopDetail(row)">
|
||||
{{ row.mallName || '-' }}
|
||||
</Button>
|
||||
</template>
|
||||
|
||||
<template #merchantType="{ row }: { row: PddShopVO.Info }">
|
||||
{{ merchantTypeText(row.merchantType) }}
|
||||
</template>
|
||||
|
||||
<template #auth="{ row }: { row: PddShopVO.Info }">
|
||||
<Tag :color="authTag(row).color">{{ authTag(row).text }}</Tag>
|
||||
<div
|
||||
v-if="row.auth?.ownerId"
|
||||
class="mt-1 max-w-[140px] truncate text-xs text-slate-400"
|
||||
:title="row.auth.ownerId"
|
||||
>
|
||||
{{ row.auth.ownerId }}
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<template #action="{ row }: { row: PddShopVO.Info }">
|
||||
<Space size="small" :wrap="false">
|
||||
<Button type="link" size="small" @click="openShopDetail(row)">
|
||||
详情
|
||||
</Button>
|
||||
<Button
|
||||
type="link"
|
||||
size="small"
|
||||
:loading="syncingShopId === row.id"
|
||||
:disabled="syncingShopId != null && syncingShopId !== row.id"
|
||||
@click="handleSyncGoods(row)"
|
||||
>
|
||||
同步商品
|
||||
</Button>
|
||||
</Space>
|
||||
</template>
|
||||
</Grid>
|
||||
|
||||
<PddShopDetailModal ref="shopDetailModalRef" />
|
||||
</Page>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.shop-logo {
|
||||
border-radius: 6px;
|
||||
object-fit: cover;
|
||||
}
|
||||
|
||||
:deep(.pdd-shop-grid .vxe-body--column) {
|
||||
vertical-align: middle;
|
||||
}
|
||||
</style>
|
||||
@@ -14,7 +14,7 @@ import {
|
||||
getPlatformTagColor,
|
||||
} from '#/utils/platform-display';
|
||||
|
||||
import PddShopDetailModal from '../list/components/PddShopDetailModal.vue';
|
||||
import PddShopDetailModal from '#/views/channel/pdd/shop/components/PddShopDetailModal.vue';
|
||||
|
||||
defineOptions({ name: 'ShopDetails' });
|
||||
|
||||
|
||||
@@ -24,8 +24,8 @@ import {
|
||||
} from '#/utils/platform-display';
|
||||
|
||||
import PddOrderSyncDrawer from './components/PddOrderSyncDrawer.vue';
|
||||
import PddShopDetailModal from './components/PddShopDetailModal.vue';
|
||||
import ShopFormModal from './components/ShopFormModal.vue';
|
||||
import PddShopDetailModal from '#/views/channel/pdd/shop/components/PddShopDetailModal.vue';
|
||||
|
||||
defineOptions({ name: 'ShopManagement' });
|
||||
|
||||
|
||||
Reference in New Issue
Block a user