mirror of
https://gitee.com/qqtt-ah/ecom-dmb.git
synced 2026-11-25 19:09:20 +08:00
feat: 优化刷单,月度目标,推广管理页面
This commit is contained in:
@@ -4,7 +4,6 @@ import type {
|
||||
PromotionFeeDTO,
|
||||
PromotionFeeVO,
|
||||
} from '#/api/ec/promotion-fee/types';
|
||||
import type { ShopVO } from '#/api/ec/shop/types';
|
||||
import type { PageQueryDTO } from '#/types/common';
|
||||
|
||||
import { computed, onMounted, ref, watch } from 'vue';
|
||||
@@ -16,13 +15,11 @@ import {
|
||||
Button,
|
||||
Card,
|
||||
DatePicker,
|
||||
Empty,
|
||||
Flex,
|
||||
message,
|
||||
Popconfirm,
|
||||
Select,
|
||||
Space,
|
||||
Spin,
|
||||
} from 'ant-design-vue';
|
||||
|
||||
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
@@ -30,26 +27,20 @@ import {
|
||||
deletePromotionFeeApi,
|
||||
getPromotionFeePageApi,
|
||||
} from '#/api/ec/promotion-fee';
|
||||
import { getShopPageApi } from '#/api/ec/shop/apis';
|
||||
import { getAllPromotionFeeTypeListApi } from '#/api/ec/promotion-fee/type/apis';
|
||||
import ShopSidebarList from '#/views/ec/components/ShopSidebarList.vue';
|
||||
|
||||
import PromotionFeeFormModal from './components/PromotionFeeFormModal.vue';
|
||||
import {
|
||||
SIDEBAR_LIST_SHELL_CLASS,
|
||||
sidebarListRowClass,
|
||||
} from '#/utils/sidebar-list-styles';
|
||||
|
||||
defineOptions({ name: 'PromotionFeeManagement' });
|
||||
|
||||
const PlusIcon = createIconifyIcon('lucide:plus');
|
||||
const StoreIcon = createIconifyIcon('lucide:store');
|
||||
|
||||
const loading = ref(false);
|
||||
const shopsLoading = ref(false);
|
||||
const shops = ref<ShopVO.Info[]>([]);
|
||||
|
||||
/** 未选择具体店铺:undefined 表示全部店铺 */
|
||||
const selectedShopId = ref<number | undefined>(undefined);
|
||||
const selectedShopName = ref<string | undefined>(undefined);
|
||||
|
||||
const formModalVisible = ref(false);
|
||||
const currentPromotionFeeData = ref<null | PromotionFeeVO.Info>(null);
|
||||
@@ -64,10 +55,12 @@ async function fetchFeeTypeOptions() {
|
||||
feeTypeLoading.value = true;
|
||||
try {
|
||||
const data = await getAllPromotionFeeTypeListApi();
|
||||
feeTypeOptions.value = (data || []).map((type: { id: number; typeName: string }) => ({
|
||||
label: type.typeName,
|
||||
value: type.id,
|
||||
}));
|
||||
feeTypeOptions.value = (data || []).map(
|
||||
(type: { id: number; typeName: string }) => ({
|
||||
label: type.typeName,
|
||||
value: type.id,
|
||||
}),
|
||||
);
|
||||
feeTypeFetched.value = true;
|
||||
} catch {
|
||||
message.error('获取推广费类型失败');
|
||||
@@ -82,33 +75,27 @@ const searchForm = ref({
|
||||
feeDateEnd: undefined as string | undefined,
|
||||
});
|
||||
|
||||
async function loadShops() {
|
||||
shopsLoading.value = true;
|
||||
try {
|
||||
const data = await getShopPageApi({ page: 1, pageSize: 500, filters: {} });
|
||||
shops.value = data.records ?? [];
|
||||
} catch {
|
||||
message.error('获取店铺列表失败');
|
||||
shops.value = [];
|
||||
} finally {
|
||||
shopsLoading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
const selectedShopLabel = computed(() => {
|
||||
if (selectedShopId.value == null) {
|
||||
return '全部店铺';
|
||||
}
|
||||
const s = shops.value.find((x) => x.id === selectedShopId.value);
|
||||
return s?.name ?? `店铺 #${selectedShopId.value}`;
|
||||
return selectedShopName.value || `店铺 #${selectedShopId.value}`;
|
||||
});
|
||||
|
||||
function selectShopAll() {
|
||||
selectedShopId.value = undefined;
|
||||
function onShopSelect(shop: { id: number; name: string } | null) {
|
||||
if (!shop) {
|
||||
selectedShopId.value = undefined;
|
||||
selectedShopName.value = undefined;
|
||||
return;
|
||||
}
|
||||
selectedShopId.value = shop.id;
|
||||
selectedShopName.value = shop.name;
|
||||
}
|
||||
|
||||
function selectShop(id: number) {
|
||||
selectedShopId.value = id;
|
||||
function handleAddForShop(shopId: number) {
|
||||
currentPromotionFeeData.value = null;
|
||||
presetShopIdForModal.value = shopId;
|
||||
formModalVisible.value = true;
|
||||
}
|
||||
|
||||
const gridOptions: VxeGridProps<PromotionFeeVO.Info> = {
|
||||
@@ -245,7 +232,6 @@ watch(selectedShopId, () => {
|
||||
});
|
||||
|
||||
onMounted(() => {
|
||||
void loadShops();
|
||||
void fetchFeeTypeOptions();
|
||||
});
|
||||
|
||||
@@ -259,13 +245,6 @@ const handleAdd = () => {
|
||||
formModalVisible.value = true;
|
||||
};
|
||||
|
||||
function handleAddForShop(shopId: number) {
|
||||
selectShop(shopId);
|
||||
currentPromotionFeeData.value = null;
|
||||
presetShopIdForModal.value = shopId;
|
||||
formModalVisible.value = true;
|
||||
}
|
||||
|
||||
const handleEdit = (record: PromotionFeeVO.Info) => {
|
||||
resetModalPreset();
|
||||
currentPromotionFeeData.value = record;
|
||||
@@ -293,18 +272,6 @@ const handleFormCancel = () => {
|
||||
};
|
||||
|
||||
const formatAmount = (amount: number) => `¥${amount.toFixed(2)}`;
|
||||
|
||||
function shopRowClass(id: number | 'all') {
|
||||
const active =
|
||||
id === 'all'
|
||||
? selectedShopId.value === undefined
|
||||
: selectedShopId.value === id;
|
||||
const layout =
|
||||
id === 'all'
|
||||
? 'mb-1.5 flex w-full cursor-pointer items-center gap-2 text-left'
|
||||
: 'group flex w-full cursor-pointer items-center gap-2';
|
||||
return sidebarListRowClass(active, layout);
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -324,72 +291,13 @@ function shopRowClass(id: number | 'all') {
|
||||
</Space>
|
||||
</template>
|
||||
|
||||
<Flex gap="middle" class="h-full min-h-0">
|
||||
<!-- 左:店铺(与 company-menu-manage 一致:Card + h-full + 内部滚动) -->
|
||||
<Card
|
||||
class="flex h-full w-[420px] shrink-0 flex-col"
|
||||
:body-style="{
|
||||
height: '100%',
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
gap: '8px',
|
||||
minHeight: 0,
|
||||
padding: '12px',
|
||||
}"
|
||||
>
|
||||
<template #title>
|
||||
<span class="flex items-center gap-2 text-base font-semibold">
|
||||
<StoreIcon class="h-4 w-4" />
|
||||
店铺
|
||||
</span>
|
||||
</template>
|
||||
<Spin :spinning="shopsLoading" class="flex min-h-0 flex-1 flex-col">
|
||||
<div :class="SIDEBAR_LIST_SHELL_CLASS">
|
||||
<button
|
||||
type="button"
|
||||
:class="shopRowClass('all')"
|
||||
@click="selectShopAll"
|
||||
>
|
||||
<span class="min-w-0 flex-1 truncate">全部店铺</span>
|
||||
<span class="shrink-0 text-xs font-normal text-muted-foreground">
|
||||
全部记录
|
||||
</span>
|
||||
</button>
|
||||
<Empty
|
||||
v-if="!shopsLoading && shops.length === 0"
|
||||
class="py-8"
|
||||
description="暂无店铺"
|
||||
/>
|
||||
<div v-else class="space-y-1">
|
||||
<div
|
||||
v-for="shop in shops"
|
||||
:key="shop.id"
|
||||
:class="shopRowClass(shop.id)"
|
||||
class="group w-full"
|
||||
>
|
||||
<button
|
||||
type="button"
|
||||
class="min-w-0 flex-1 truncate text-left"
|
||||
@click="selectShop(shop.id)"
|
||||
>
|
||||
{{ shop.name }}
|
||||
</button>
|
||||
<Button
|
||||
type="link"
|
||||
size="small"
|
||||
class="!h-7 shrink-0 !px-1 !text-xs font-semibold opacity-80 group-hover:opacity-100"
|
||||
@click.stop="handleAddForShop(shop.id)"
|
||||
>
|
||||
<PlusIcon class="mr-0.5 inline h-3.5 w-3.5" />
|
||||
添加
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</Spin>
|
||||
</Card>
|
||||
<Flex gap="middle" class="h-full min-h-0 overflow-hidden">
|
||||
<ShopSidebarList
|
||||
:selected-shop-id="selectedShopId"
|
||||
@select="onShopSelect"
|
||||
@add-for-shop="handleAddForShop"
|
||||
/>
|
||||
|
||||
<!-- 右:推广记录 -->
|
||||
<Card
|
||||
class="flex h-full min-h-0 min-w-0 flex-1 flex-col"
|
||||
:body-style="{
|
||||
@@ -445,7 +353,9 @@ function shopRowClass(id: number | 'all') {
|
||||
当前:{{ selectedShopLabel }}
|
||||
</div>
|
||||
|
||||
<div class="min-h-0 flex-1 overflow-hidden px-2 pb-2 pt-0 sm:px-3 sm:pb-3">
|
||||
<div
|
||||
class="min-h-0 flex-1 overflow-hidden px-2 pb-2 pt-0 sm:px-3 sm:pb-3"
|
||||
>
|
||||
<Grid :loading="loading" class="h-full min-h-0">
|
||||
<template #toolbar-tools>
|
||||
<span class="text-xs text-muted-foreground">
|
||||
|
||||
Reference in New Issue
Block a user