mirror of
https://gitee.com/qqtt-ah/ecom-dmb.git
synced 2026-11-25 21:09:19 +08:00
feat: 优化可两栏布局的页面都改成两栏
This commit is contained in:
@@ -0,0 +1,79 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import type { PddShopVO } from '#/api/channel/pdd/shop';
|
||||||
|
|
||||||
|
import { ColPage } from '@vben/common-ui';
|
||||||
|
|
||||||
|
import PddShopSidebarList from '#/views/channel/pdd/components/PddShopSidebarList.vue';
|
||||||
|
|
||||||
|
defineOptions({ name: 'PddShopColPage' });
|
||||||
|
|
||||||
|
withDefaults(
|
||||||
|
defineProps<{
|
||||||
|
/** undefined = 全部渠道店铺 */
|
||||||
|
selectedShopId?: number;
|
||||||
|
showAddAction?: boolean;
|
||||||
|
autoContentHeight?: boolean;
|
||||||
|
leftWidth?: number;
|
||||||
|
leftMinWidth?: number;
|
||||||
|
leftMaxWidth?: number;
|
||||||
|
leftCollapsedWidth?: number;
|
||||||
|
leftCollapsible?: boolean;
|
||||||
|
resizable?: boolean;
|
||||||
|
splitHandle?: boolean;
|
||||||
|
splitLine?: boolean;
|
||||||
|
}>(),
|
||||||
|
{
|
||||||
|
showAddAction: false,
|
||||||
|
autoContentHeight: true,
|
||||||
|
leftWidth: 22,
|
||||||
|
leftMinWidth: 16,
|
||||||
|
leftMaxWidth: 36,
|
||||||
|
leftCollapsedWidth: 5,
|
||||||
|
leftCollapsible: true,
|
||||||
|
resizable: true,
|
||||||
|
splitHandle: false,
|
||||||
|
splitLine: false,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
const emit = defineEmits<{
|
||||||
|
'update:selectedShopId': [id: number | undefined];
|
||||||
|
select: [shop: PddShopVO.Info | null];
|
||||||
|
addForShop: [shopId: number];
|
||||||
|
}>();
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<ColPage
|
||||||
|
:auto-content-height="autoContentHeight"
|
||||||
|
:left-width="leftWidth"
|
||||||
|
:left-min-width="leftMinWidth"
|
||||||
|
:left-max-width="leftMaxWidth"
|
||||||
|
:left-collapsed-width="leftCollapsedWidth"
|
||||||
|
:left-collapsible="leftCollapsible"
|
||||||
|
:right-width="100 - leftWidth"
|
||||||
|
:resizable="resizable"
|
||||||
|
:split-handle="splitHandle"
|
||||||
|
:split-line="splitLine"
|
||||||
|
content-class="!p-2 sm:!p-3"
|
||||||
|
>
|
||||||
|
<template #left="{ isCollapsed, expand, collapse }">
|
||||||
|
<div class="flex h-full min-h-0 min-w-0 flex-col overflow-hidden">
|
||||||
|
<PddShopSidebarList
|
||||||
|
fluid
|
||||||
|
:collapsed="isCollapsed"
|
||||||
|
show-collapse-action
|
||||||
|
:selected-shop-id="selectedShopId"
|
||||||
|
:show-add-action="showAddAction"
|
||||||
|
@collapse="collapse"
|
||||||
|
@expand="expand"
|
||||||
|
@update:selected-shop-id="emit('update:selectedShopId', $event)"
|
||||||
|
@select="emit('select', $event)"
|
||||||
|
@add-for-shop="emit('addForShop', $event)"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<slot />
|
||||||
|
</ColPage>
|
||||||
|
</template>
|
||||||
+389
@@ -0,0 +1,389 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import type { PddShopVO } from '#/api/channel/pdd/shop';
|
||||||
|
|
||||||
|
import { computed, onMounted, ref } from 'vue';
|
||||||
|
|
||||||
|
import { createIconifyIcon } from '@vben/icons';
|
||||||
|
|
||||||
|
import {
|
||||||
|
Button,
|
||||||
|
Card,
|
||||||
|
Empty,
|
||||||
|
Input,
|
||||||
|
message,
|
||||||
|
Spin,
|
||||||
|
Tooltip,
|
||||||
|
} from 'ant-design-vue';
|
||||||
|
|
||||||
|
import { getPddShopPageApi } from '#/api/channel/pdd/shop';
|
||||||
|
import ShopLogoAvatar from '#/views/ec/components/ShopLogoAvatar.vue';
|
||||||
|
|
||||||
|
defineOptions({ name: 'PddShopSidebarList' });
|
||||||
|
|
||||||
|
const props = withDefaults(
|
||||||
|
defineProps<{
|
||||||
|
/** undefined = 全部渠道店铺 */
|
||||||
|
selectedShopId?: number;
|
||||||
|
showAddAction?: boolean;
|
||||||
|
fluid?: boolean;
|
||||||
|
showCollapseAction?: boolean;
|
||||||
|
collapsed?: boolean;
|
||||||
|
}>(),
|
||||||
|
{
|
||||||
|
selectedShopId: undefined,
|
||||||
|
showAddAction: false,
|
||||||
|
fluid: false,
|
||||||
|
showCollapseAction: false,
|
||||||
|
collapsed: false,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
const emit = defineEmits<{
|
||||||
|
'update:selectedShopId': [id: number | undefined];
|
||||||
|
select: [shop: PddShopVO.Info | null];
|
||||||
|
addForShop: [shopId: number];
|
||||||
|
collapse: [];
|
||||||
|
expand: [];
|
||||||
|
}>();
|
||||||
|
|
||||||
|
const StoreIcon = createIconifyIcon('lucide:store');
|
||||||
|
const PlusIcon = createIconifyIcon('lucide:plus');
|
||||||
|
const PanelCloseIcon = createIconifyIcon('lucide:panel-left-close');
|
||||||
|
const PanelOpenIcon = createIconifyIcon('lucide:panel-left-open');
|
||||||
|
const ChevronUpIcon = createIconifyIcon('lucide:chevron-up');
|
||||||
|
const ChevronDownIcon = createIconifyIcon('lucide:chevron-down');
|
||||||
|
|
||||||
|
const shopSearchName = ref('');
|
||||||
|
const shops = ref<PddShopVO.Info[]>([]);
|
||||||
|
const shopsLoading = ref(false);
|
||||||
|
const shopPagination = ref({ current: 1, pageSize: 20, total: 0 });
|
||||||
|
|
||||||
|
const shopTotalPages = computed(() => {
|
||||||
|
const { total, pageSize } = shopPagination.value;
|
||||||
|
return Math.max(1, Math.ceil(total / pageSize) || 1);
|
||||||
|
});
|
||||||
|
|
||||||
|
const allSelected = computed(() => props.selectedShopId === undefined);
|
||||||
|
|
||||||
|
function shopLabel(shop: PddShopVO.Info) {
|
||||||
|
return shop.mallName || `店铺 #${shop.id}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function searchShops(resetPage = false) {
|
||||||
|
if (resetPage) {
|
||||||
|
shopPagination.value.current = 1;
|
||||||
|
}
|
||||||
|
shopsLoading.value = true;
|
||||||
|
try {
|
||||||
|
const result = await getPddShopPageApi({
|
||||||
|
page: shopPagination.value.current,
|
||||||
|
pageSize: shopPagination.value.pageSize,
|
||||||
|
filters: {
|
||||||
|
mallName: shopSearchName.value || undefined,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
shops.value = result.records ?? [];
|
||||||
|
shopPagination.value.total = result.total ?? 0;
|
||||||
|
} catch (error: any) {
|
||||||
|
message.error(error?.message || '获取拼多多店铺列表失败');
|
||||||
|
shops.value = [];
|
||||||
|
} finally {
|
||||||
|
shopsLoading.value = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function resetShopSearch() {
|
||||||
|
shopSearchName.value = '';
|
||||||
|
void searchShops(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
function goShopPage(page: number) {
|
||||||
|
const next = Math.min(shopTotalPages.value, Math.max(1, page));
|
||||||
|
if (next === shopPagination.value.current) return;
|
||||||
|
shopPagination.value.current = next;
|
||||||
|
void searchShops();
|
||||||
|
}
|
||||||
|
|
||||||
|
function selectAll() {
|
||||||
|
emit('update:selectedShopId', undefined);
|
||||||
|
emit('select', null);
|
||||||
|
}
|
||||||
|
|
||||||
|
function selectShop(shop: PddShopVO.Info) {
|
||||||
|
emit('update:selectedShopId', shop.id);
|
||||||
|
emit('select', shop);
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleAdd(shopId: number) {
|
||||||
|
const shop = shops.value.find((s) => s.id === shopId) ?? null;
|
||||||
|
emit('update:selectedShopId', shopId);
|
||||||
|
if (shop) {
|
||||||
|
emit('select', shop);
|
||||||
|
}
|
||||||
|
emit('addForShop', shopId);
|
||||||
|
}
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
void searchShops();
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div
|
||||||
|
v-if="collapsed"
|
||||||
|
class="flex h-full min-h-0 w-full flex-col items-center gap-1 pb-2 pt-3"
|
||||||
|
>
|
||||||
|
<Tooltip title="展开店铺列表">
|
||||||
|
<Button type="text" size="small" class="!px-1" @click="emit('expand')">
|
||||||
|
<PanelOpenIcon class="h-4 w-4" />
|
||||||
|
</Button>
|
||||||
|
</Tooltip>
|
||||||
|
|
||||||
|
<div
|
||||||
|
class="flex min-h-0 w-full flex-1 flex-col items-center gap-1.5 overflow-y-auto px-1 pb-1 pt-2"
|
||||||
|
>
|
||||||
|
<Tooltip title="全部店铺">
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
class="inline-flex shrink-0 rounded-md p-0.5 transition-colors hover:bg-accent"
|
||||||
|
:class="
|
||||||
|
allSelected
|
||||||
|
? 'ring-2 ring-primary ring-offset-1 ring-offset-background'
|
||||||
|
: undefined
|
||||||
|
"
|
||||||
|
@click="selectAll"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
class="flex h-9 w-9 items-center justify-center rounded-md border border-dashed border-border bg-muted/50"
|
||||||
|
>
|
||||||
|
<StoreIcon class="h-4 w-4 text-muted-foreground" />
|
||||||
|
</div>
|
||||||
|
</button>
|
||||||
|
</Tooltip>
|
||||||
|
|
||||||
|
<Spin
|
||||||
|
:spinning="shopsLoading"
|
||||||
|
size="small"
|
||||||
|
wrapper-class-name="pdd-shop-sidebar-collapsed-spin"
|
||||||
|
>
|
||||||
|
<div class="flex w-full flex-col items-center gap-1.5">
|
||||||
|
<Tooltip v-for="shop in shops" :key="shop.id" :title="shopLabel(shop)">
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
class="inline-flex shrink-0 rounded-md p-0.5 transition-colors hover:bg-accent"
|
||||||
|
:class="
|
||||||
|
selectedShopId === shop.id
|
||||||
|
? 'ring-2 ring-primary ring-offset-1 ring-offset-background'
|
||||||
|
: undefined
|
||||||
|
"
|
||||||
|
@click="selectShop(shop)"
|
||||||
|
>
|
||||||
|
<ShopLogoAvatar
|
||||||
|
:logo="shop.logo"
|
||||||
|
:name="shopLabel(shop)"
|
||||||
|
:size="36"
|
||||||
|
/>
|
||||||
|
</button>
|
||||||
|
</Tooltip>
|
||||||
|
</div>
|
||||||
|
</Spin>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div
|
||||||
|
v-if="shopTotalPages > 1"
|
||||||
|
class="flex shrink-0 flex-col items-center gap-0.5"
|
||||||
|
>
|
||||||
|
<Button
|
||||||
|
type="text"
|
||||||
|
size="small"
|
||||||
|
class="!h-6 !px-1"
|
||||||
|
:disabled="shopPagination.current <= 1 || shopsLoading"
|
||||||
|
@click="goShopPage(shopPagination.current - 1)"
|
||||||
|
>
|
||||||
|
<ChevronUpIcon class="h-3.5 w-3.5" />
|
||||||
|
</Button>
|
||||||
|
<span class="text-[10px] leading-none text-muted-foreground">
|
||||||
|
{{ shopPagination.current }}/{{ shopTotalPages }}
|
||||||
|
</span>
|
||||||
|
<Button
|
||||||
|
type="text"
|
||||||
|
size="small"
|
||||||
|
class="!h-6 !px-1"
|
||||||
|
:disabled="shopPagination.current >= shopTotalPages || shopsLoading"
|
||||||
|
@click="goShopPage(shopPagination.current + 1)"
|
||||||
|
>
|
||||||
|
<ChevronDownIcon class="h-3.5 w-3.5" />
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<Card
|
||||||
|
v-else
|
||||||
|
class="flex h-full flex-col overflow-hidden"
|
||||||
|
:class="fluid ? 'w-full min-w-0' : 'w-[320px] shrink-0'"
|
||||||
|
:body-style="{
|
||||||
|
height: '100%',
|
||||||
|
display: 'flex',
|
||||||
|
flexDirection: 'column',
|
||||||
|
gap: '8px',
|
||||||
|
minHeight: 0,
|
||||||
|
minWidth: 0,
|
||||||
|
overflow: 'hidden',
|
||||||
|
padding: '12px',
|
||||||
|
}"
|
||||||
|
>
|
||||||
|
<template #title>
|
||||||
|
<span class="flex items-center gap-2 text-base font-semibold">
|
||||||
|
<StoreIcon class="h-4 w-4" />
|
||||||
|
拼多多店铺
|
||||||
|
</span>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<template v-if="showCollapseAction" #extra>
|
||||||
|
<Tooltip title="收起店铺列表">
|
||||||
|
<Button type="text" size="small" class="!px-1" @click="emit('collapse')">
|
||||||
|
<PanelCloseIcon class="h-4 w-4" />
|
||||||
|
</Button>
|
||||||
|
</Tooltip>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<div class="flex min-w-0 shrink-0 items-center gap-2">
|
||||||
|
<Input
|
||||||
|
v-model:value="shopSearchName"
|
||||||
|
placeholder="店铺名称"
|
||||||
|
allow-clear
|
||||||
|
class="min-w-0 flex-1"
|
||||||
|
@press-enter="searchShops(true)"
|
||||||
|
/>
|
||||||
|
<Button type="primary" class="shrink-0" @click="searchShops(true)">
|
||||||
|
搜索
|
||||||
|
</Button>
|
||||||
|
<Button class="shrink-0" @click="resetShopSearch">重置</Button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden">
|
||||||
|
<div class="min-h-0 flex-1 overflow-y-auto">
|
||||||
|
<Card
|
||||||
|
size="small"
|
||||||
|
:body-style="{ padding: '10px 12px' }"
|
||||||
|
class="mb-2 cursor-pointer !shadow-none hover:border-primary"
|
||||||
|
:class="allSelected ? 'border-primary bg-primary/5' : undefined"
|
||||||
|
@click="selectAll"
|
||||||
|
>
|
||||||
|
<div class="flex items-center gap-2">
|
||||||
|
<div
|
||||||
|
class="flex h-9 w-9 shrink-0 items-center justify-center rounded-md border border-dashed border-border bg-muted/50"
|
||||||
|
>
|
||||||
|
<StoreIcon class="h-4 w-4 text-muted-foreground" />
|
||||||
|
</div>
|
||||||
|
<div class="min-w-0 flex-1">
|
||||||
|
<div class="flex items-center justify-between gap-2">
|
||||||
|
<span class="min-w-0 truncate text-sm font-medium">全部店铺</span>
|
||||||
|
<span class="shrink-0 text-xs text-muted-foreground">全部记录</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</Card>
|
||||||
|
|
||||||
|
<Spin :spinning="shopsLoading">
|
||||||
|
<Empty
|
||||||
|
v-if="!shopsLoading && shops.length === 0"
|
||||||
|
class="py-8"
|
||||||
|
description="暂无拼多多店铺"
|
||||||
|
/>
|
||||||
|
<template v-else>
|
||||||
|
<Card
|
||||||
|
v-for="shop in shops"
|
||||||
|
:key="shop.id"
|
||||||
|
size="small"
|
||||||
|
:body-style="{ padding: '10px 12px' }"
|
||||||
|
class="group mb-2 cursor-pointer !shadow-none last:mb-0 hover:border-primary"
|
||||||
|
:class="
|
||||||
|
selectedShopId === shop.id
|
||||||
|
? 'border-primary bg-primary/5'
|
||||||
|
: undefined
|
||||||
|
"
|
||||||
|
@click="selectShop(shop)"
|
||||||
|
>
|
||||||
|
<div class="flex items-start gap-2">
|
||||||
|
<ShopLogoAvatar
|
||||||
|
:logo="shop.logo"
|
||||||
|
:name="shopLabel(shop)"
|
||||||
|
:size="36"
|
||||||
|
/>
|
||||||
|
<div class="flex min-w-0 flex-1 items-start justify-between gap-2">
|
||||||
|
<div class="min-w-0 flex-1">
|
||||||
|
<div class="truncate text-sm font-medium">
|
||||||
|
{{ shopLabel(shop) }}
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
v-if="shop.mallId != null"
|
||||||
|
class="mt-1 text-xs text-muted-foreground"
|
||||||
|
>
|
||||||
|
mall_id: {{ shop.mallId }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<Button
|
||||||
|
v-if="showAddAction"
|
||||||
|
type="link"
|
||||||
|
size="small"
|
||||||
|
class="!h-7 shrink-0 !px-1 !text-xs opacity-80 group-hover:opacity-100"
|
||||||
|
@click.stop="handleAdd(shop.id)"
|
||||||
|
>
|
||||||
|
<PlusIcon class="mr-0.5 inline h-3.5 w-3.5" />
|
||||||
|
添加
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</Card>
|
||||||
|
</template>
|
||||||
|
</Spin>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div
|
||||||
|
class="mt-2 flex w-full min-w-0 shrink-0 items-center justify-between gap-2"
|
||||||
|
>
|
||||||
|
<Button
|
||||||
|
size="small"
|
||||||
|
class="shrink-0"
|
||||||
|
:disabled="shopPagination.current <= 1 || shopsLoading"
|
||||||
|
@click="goShopPage(shopPagination.current - 1)"
|
||||||
|
>
|
||||||
|
上一页
|
||||||
|
</Button>
|
||||||
|
<span
|
||||||
|
class="min-w-0 flex-1 truncate text-center text-xs text-muted-foreground"
|
||||||
|
>
|
||||||
|
{{ shopPagination.current }} / {{ shopTotalPages }}
|
||||||
|
<span class="ml-1 opacity-70">({{ shopPagination.total }})</span>
|
||||||
|
</span>
|
||||||
|
<Button
|
||||||
|
size="small"
|
||||||
|
class="shrink-0"
|
||||||
|
:disabled="
|
||||||
|
shopPagination.current >= shopTotalPages || shopsLoading
|
||||||
|
"
|
||||||
|
@click="goShopPage(shopPagination.current + 1)"
|
||||||
|
>
|
||||||
|
下一页
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</Card>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
:deep(.pdd-shop-sidebar-collapsed-spin) {
|
||||||
|
display: flex;
|
||||||
|
width: 100%;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
:deep(.pdd-shop-sidebar-collapsed-spin .ant-spin-container) {
|
||||||
|
display: flex;
|
||||||
|
width: 100%;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
-240
@@ -1,240 +0,0 @@
|
|||||||
<script setup lang="ts">
|
|
||||||
import type { PddShopVO } from '#/api/channel/pdd/shop';
|
|
||||||
|
|
||||||
import { computed, onMounted, ref } from 'vue';
|
|
||||||
|
|
||||||
import { createIconifyIcon } from '@vben/icons';
|
|
||||||
|
|
||||||
import {
|
|
||||||
Button,
|
|
||||||
Card,
|
|
||||||
Empty,
|
|
||||||
Input,
|
|
||||||
message,
|
|
||||||
Spin,
|
|
||||||
} from 'ant-design-vue';
|
|
||||||
|
|
||||||
import { getPddShopPageApi } from '#/api/channel/pdd/shop';
|
|
||||||
|
|
||||||
defineOptions({ name: 'PddShopSidebarList' });
|
|
||||||
|
|
||||||
const props = withDefaults(
|
|
||||||
defineProps<{
|
|
||||||
selectedShopId?: number;
|
|
||||||
showAddAction?: boolean;
|
|
||||||
}>(),
|
|
||||||
{
|
|
||||||
selectedShopId: undefined,
|
|
||||||
showAddAction: true,
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
const emit = defineEmits<{
|
|
||||||
'update:selectedShopId': [id: number | undefined];
|
|
||||||
select: [shop: PddShopVO.Info | null];
|
|
||||||
addForShop: [shopId: number];
|
|
||||||
}>();
|
|
||||||
|
|
||||||
const StoreIcon = createIconifyIcon('lucide:store');
|
|
||||||
const PlusIcon = createIconifyIcon('lucide:plus');
|
|
||||||
|
|
||||||
const shopSearchName = ref('');
|
|
||||||
const shops = ref<PddShopVO.Info[]>([]);
|
|
||||||
const shopsLoading = ref(false);
|
|
||||||
const shopPagination = ref({ current: 1, pageSize: 20, total: 0 });
|
|
||||||
|
|
||||||
const shopTotalPages = computed(() => {
|
|
||||||
const { total, pageSize } = shopPagination.value;
|
|
||||||
return Math.max(1, Math.ceil(total / pageSize) || 1);
|
|
||||||
});
|
|
||||||
|
|
||||||
const allSelected = computed(() => props.selectedShopId === undefined);
|
|
||||||
|
|
||||||
async function searchShops(resetPage = false) {
|
|
||||||
if (resetPage) {
|
|
||||||
shopPagination.value.current = 1;
|
|
||||||
}
|
|
||||||
shopsLoading.value = true;
|
|
||||||
try {
|
|
||||||
const result = await getPddShopPageApi({
|
|
||||||
page: shopPagination.value.current,
|
|
||||||
pageSize: shopPagination.value.pageSize,
|
|
||||||
filters: {
|
|
||||||
mallName: shopSearchName.value || undefined,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
shops.value = result.records ?? [];
|
|
||||||
shopPagination.value.total = result.total ?? 0;
|
|
||||||
} catch (error: any) {
|
|
||||||
message.error(error?.message || '获取渠道店铺列表失败');
|
|
||||||
shops.value = [];
|
|
||||||
} finally {
|
|
||||||
shopsLoading.value = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function resetShopSearch() {
|
|
||||||
shopSearchName.value = '';
|
|
||||||
void searchShops(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
function goShopPage(page: number) {
|
|
||||||
const next = Math.min(shopTotalPages.value, Math.max(1, page));
|
|
||||||
if (next === shopPagination.value.current) return;
|
|
||||||
shopPagination.value.current = next;
|
|
||||||
void searchShops();
|
|
||||||
}
|
|
||||||
|
|
||||||
function selectAll() {
|
|
||||||
emit('update:selectedShopId', undefined);
|
|
||||||
emit('select', null);
|
|
||||||
}
|
|
||||||
|
|
||||||
function selectShop(shop: PddShopVO.Info) {
|
|
||||||
emit('update:selectedShopId', shop.id);
|
|
||||||
emit('select', shop);
|
|
||||||
}
|
|
||||||
|
|
||||||
function handleAdd(shopId: number) {
|
|
||||||
const shop = shops.value.find((s) => s.id === shopId) ?? null;
|
|
||||||
emit('update:selectedShopId', shopId);
|
|
||||||
if (shop) {
|
|
||||||
emit('select', shop);
|
|
||||||
}
|
|
||||||
emit('addForShop', shopId);
|
|
||||||
}
|
|
||||||
|
|
||||||
onMounted(() => {
|
|
||||||
void searchShops();
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<Card
|
|
||||||
class="flex h-full w-[320px] shrink-0 flex-col overflow-hidden"
|
|
||||||
:body-style="{
|
|
||||||
height: '100%',
|
|
||||||
display: 'flex',
|
|
||||||
flexDirection: 'column',
|
|
||||||
gap: '8px',
|
|
||||||
minHeight: 0,
|
|
||||||
minWidth: 0,
|
|
||||||
overflow: 'hidden',
|
|
||||||
padding: '12px',
|
|
||||||
}"
|
|
||||||
>
|
|
||||||
<template #title>
|
|
||||||
<span class="flex items-center gap-2 text-base font-semibold">
|
|
||||||
<StoreIcon class="h-4 w-4" />
|
|
||||||
渠道店铺
|
|
||||||
</span>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<div class="flex min-w-0 shrink-0 items-center gap-2">
|
|
||||||
<Input
|
|
||||||
v-model:value="shopSearchName"
|
|
||||||
placeholder="店铺名称"
|
|
||||||
allow-clear
|
|
||||||
class="min-w-0 flex-1"
|
|
||||||
@press-enter="searchShops(true)"
|
|
||||||
/>
|
|
||||||
<Button type="primary" class="shrink-0" @click="searchShops(true)">
|
|
||||||
搜索
|
|
||||||
</Button>
|
|
||||||
<Button class="shrink-0" @click="resetShopSearch">重置</Button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden">
|
|
||||||
<div class="min-h-0 flex-1 overflow-y-auto">
|
|
||||||
<Card
|
|
||||||
size="small"
|
|
||||||
:body-style="{ padding: '10px 12px' }"
|
|
||||||
class="mb-2 cursor-pointer !shadow-none hover:border-primary"
|
|
||||||
:class="allSelected ? 'border-primary bg-primary/5' : undefined"
|
|
||||||
@click="selectAll"
|
|
||||||
>
|
|
||||||
<div class="flex items-center justify-between gap-2">
|
|
||||||
<span class="min-w-0 truncate text-sm font-medium">全部店铺</span>
|
|
||||||
<span class="shrink-0 text-xs text-muted-foreground">全部记录</span>
|
|
||||||
</div>
|
|
||||||
</Card>
|
|
||||||
|
|
||||||
<Spin :spinning="shopsLoading">
|
|
||||||
<Empty
|
|
||||||
v-if="!shopsLoading && shops.length === 0"
|
|
||||||
class="py-8"
|
|
||||||
description="暂无渠道店铺"
|
|
||||||
/>
|
|
||||||
<template v-else>
|
|
||||||
<Card
|
|
||||||
v-for="shop in shops"
|
|
||||||
:key="shop.id"
|
|
||||||
size="small"
|
|
||||||
:body-style="{ padding: '10px 12px' }"
|
|
||||||
class="group mb-2 cursor-pointer !shadow-none last:mb-0 hover:border-primary"
|
|
||||||
:class="
|
|
||||||
selectedShopId === shop.id
|
|
||||||
? 'border-primary bg-primary/5'
|
|
||||||
: undefined
|
|
||||||
"
|
|
||||||
@click="selectShop(shop)"
|
|
||||||
>
|
|
||||||
<div class="flex items-start justify-between gap-2">
|
|
||||||
<div class="min-w-0 flex-1">
|
|
||||||
<div class="truncate text-sm font-medium">
|
|
||||||
{{ shop.mallName || `店铺 #${shop.id}` }}
|
|
||||||
</div>
|
|
||||||
<div
|
|
||||||
v-if="shop.mallId != null"
|
|
||||||
class="mt-1 text-xs text-muted-foreground"
|
|
||||||
>
|
|
||||||
mall_id: {{ shop.mallId }}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<Button
|
|
||||||
v-if="showAddAction"
|
|
||||||
type="link"
|
|
||||||
size="small"
|
|
||||||
class="!h-7 shrink-0 !px-1 !text-xs opacity-80 group-hover:opacity-100"
|
|
||||||
@click.stop="handleAdd(shop.id)"
|
|
||||||
>
|
|
||||||
<PlusIcon class="mr-0.5 inline h-3.5 w-3.5" />
|
|
||||||
添加
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
</Card>
|
|
||||||
</template>
|
|
||||||
</Spin>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div
|
|
||||||
class="mt-2 flex w-full min-w-0 shrink-0 items-center justify-between gap-2"
|
|
||||||
>
|
|
||||||
<Button
|
|
||||||
size="small"
|
|
||||||
class="shrink-0"
|
|
||||||
:disabled="shopPagination.current <= 1 || shopsLoading"
|
|
||||||
@click="goShopPage(shopPagination.current - 1)"
|
|
||||||
>
|
|
||||||
上一页
|
|
||||||
</Button>
|
|
||||||
<span
|
|
||||||
class="min-w-0 flex-1 truncate text-center text-xs text-muted-foreground"
|
|
||||||
>
|
|
||||||
{{ shopPagination.current }} / {{ shopTotalPages }}
|
|
||||||
<span class="ml-1 opacity-70">({{ shopPagination.total }})</span>
|
|
||||||
</span>
|
|
||||||
<Button
|
|
||||||
size="small"
|
|
||||||
class="shrink-0"
|
|
||||||
:disabled="
|
|
||||||
shopPagination.current >= shopTotalPages || shopsLoading
|
|
||||||
"
|
|
||||||
@click="goShopPage(shopPagination.current + 1)"
|
|
||||||
>
|
|
||||||
下一页
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</Card>
|
|
||||||
</template>
|
|
||||||
@@ -1,18 +1,17 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import type { VxeGridProps } from '#/adapter/vxe-table';
|
import type { VxeGridProps } from '#/adapter/vxe-table';
|
||||||
import type { PddGoodsAdFeeVO } from '#/api/channel/pdd/goods-ad-fee';
|
import type { PddGoodsAdFeeVO } from '#/api/channel/pdd/goods-ad-fee';
|
||||||
|
import type { PddShopVO } from '#/api/channel/pdd/shop';
|
||||||
import type { PageQueryDTO } from '#/types/common';
|
import type { PageQueryDTO } from '#/types/common';
|
||||||
|
|
||||||
import { computed, ref, watch } from 'vue';
|
import { ref, watch } from 'vue';
|
||||||
|
|
||||||
import { Page } from '@vben/common-ui';
|
|
||||||
import { createIconifyIcon } from '@vben/icons';
|
import { createIconifyIcon } from '@vben/icons';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
Button,
|
Button,
|
||||||
Card,
|
Card,
|
||||||
DatePicker,
|
DatePicker,
|
||||||
Flex,
|
|
||||||
Input,
|
Input,
|
||||||
message,
|
message,
|
||||||
Popconfirm,
|
Popconfirm,
|
||||||
@@ -24,9 +23,9 @@ import {
|
|||||||
deletePddGoodsAdFeeApi,
|
deletePddGoodsAdFeeApi,
|
||||||
getPddGoodsAdFeePageApi,
|
getPddGoodsAdFeePageApi,
|
||||||
} from '#/api/channel/pdd/goods-ad-fee';
|
} from '#/api/channel/pdd/goods-ad-fee';
|
||||||
|
import PddShopColPage from '#/views/channel/pdd/components/PddShopColPage.vue';
|
||||||
|
|
||||||
import GoodsAdFeeFormModal from './components/GoodsAdFeeFormModal.vue';
|
import GoodsAdFeeFormModal from './components/GoodsAdFeeFormModal.vue';
|
||||||
import PddShopSidebarList from './components/PddShopSidebarList.vue';
|
|
||||||
|
|
||||||
defineOptions({ name: 'PddGoodsAdFeeManagement' });
|
defineOptions({ name: 'PddGoodsAdFeeManagement' });
|
||||||
|
|
||||||
@@ -35,7 +34,6 @@ const PlusIcon = createIconifyIcon('lucide:plus');
|
|||||||
const loading = ref(false);
|
const loading = ref(false);
|
||||||
|
|
||||||
const selectedShopId = ref<number | undefined>(undefined);
|
const selectedShopId = ref<number | undefined>(undefined);
|
||||||
const selectedShopName = ref<string | undefined>(undefined);
|
|
||||||
|
|
||||||
const formModalVisible = ref(false);
|
const formModalVisible = ref(false);
|
||||||
const currentAdFeeData = ref<null | PddGoodsAdFeeVO.Info>(null);
|
const currentAdFeeData = ref<null | PddGoodsAdFeeVO.Info>(null);
|
||||||
@@ -47,21 +45,8 @@ const searchForm = ref({
|
|||||||
feeDateEnd: undefined as string | undefined,
|
feeDateEnd: undefined as string | undefined,
|
||||||
});
|
});
|
||||||
|
|
||||||
const selectedShopLabel = computed(() => {
|
function onShopSelect(shop: PddShopVO.Info | null) {
|
||||||
if (selectedShopId.value == null) {
|
selectedShopId.value = shop?.id;
|
||||||
return '全部店铺';
|
|
||||||
}
|
|
||||||
return selectedShopName.value || `店铺 #${selectedShopId.value}`;
|
|
||||||
});
|
|
||||||
|
|
||||||
function onShopSelect(shop: { id: number; mallName?: string } | null) {
|
|
||||||
if (!shop) {
|
|
||||||
selectedShopId.value = undefined;
|
|
||||||
selectedShopName.value = undefined;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
selectedShopId.value = shop.id;
|
|
||||||
selectedShopName.value = shop.mallName;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleAddForShop(shopId: number) {
|
function handleAddForShop(shopId: number) {
|
||||||
@@ -187,7 +172,7 @@ function refreshTable() {
|
|||||||
const [Grid, gridApi] = useVbenVxeGrid({
|
const [Grid, gridApi] = useVbenVxeGrid({
|
||||||
gridOptions,
|
gridOptions,
|
||||||
showSearchForm: false,
|
showSearchForm: false,
|
||||||
tableTitle: '广告费记录',
|
tableTitle: '',
|
||||||
});
|
});
|
||||||
|
|
||||||
watch(selectedShopId, () => {
|
watch(selectedShopId, () => {
|
||||||
@@ -234,31 +219,14 @@ const formatAmount = (amount: number) => `¥${Number(amount || 0).toFixed(2)}`;
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<Page title="商品广告费" :auto-content-height="true">
|
<PddShopColPage
|
||||||
<template #description>
|
show-add-action
|
||||||
<div class="text-foreground/80 mt-2">
|
|
||||||
左侧选择拼多多渠道店铺筛选右侧按日广告费;未选店铺时展示全部记录。可在店铺行快捷新增。
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<template #extra>
|
|
||||||
<Space>
|
|
||||||
<Button type="primary" @click="handleAdd">
|
|
||||||
<PlusIcon class="mr-2 h-4 w-4" />
|
|
||||||
新增广告费
|
|
||||||
</Button>
|
|
||||||
</Space>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<Flex gap="middle" class="h-full min-h-0 overflow-hidden">
|
|
||||||
<PddShopSidebarList
|
|
||||||
:selected-shop-id="selectedShopId"
|
:selected-shop-id="selectedShopId"
|
||||||
@select="onShopSelect"
|
@select="onShopSelect"
|
||||||
@add-for-shop="handleAddForShop"
|
@add-for-shop="handleAddForShop"
|
||||||
/>
|
>
|
||||||
|
|
||||||
<Card
|
<Card
|
||||||
class="flex h-full min-h-0 min-w-0 flex-1 flex-col"
|
class="ml-1 flex h-full min-h-0 min-w-0 flex-1 flex-col sm:ml-2"
|
||||||
:body-style="{
|
:body-style="{
|
||||||
height: '100%',
|
height: '100%',
|
||||||
minHeight: 0,
|
minHeight: 0,
|
||||||
@@ -270,8 +238,9 @@ const formatAmount = (amount: number) => `¥${Number(amount || 0).toFixed(2)}`;
|
|||||||
<template #title>
|
<template #title>
|
||||||
<span class="text-base font-semibold">广告费记录</span>
|
<span class="text-base font-semibold">广告费记录</span>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<template #extra>
|
<template #extra>
|
||||||
<Space wrap size="small" class="max-w-[min(100%,42rem)]">
|
<Space wrap size="small" class="max-w-[min(100%,48rem)]">
|
||||||
<Input
|
<Input
|
||||||
v-model:value="searchForm.goodsId"
|
v-model:value="searchForm.goodsId"
|
||||||
allow-clear
|
allow-clear
|
||||||
@@ -297,25 +266,17 @@ const formatAmount = (amount: number) => `¥${Number(amount || 0).toFixed(2)}`;
|
|||||||
allow-clear
|
allow-clear
|
||||||
@change="() => refreshTable()"
|
@change="() => refreshTable()"
|
||||||
/>
|
/>
|
||||||
|
<Button type="primary" @click="handleAdd">
|
||||||
|
<PlusIcon class="mr-1 h-4 w-4" />
|
||||||
|
新增广告费
|
||||||
|
</Button>
|
||||||
</Space>
|
</Space>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<div
|
<div
|
||||||
class="shrink-0 border-t border-border px-4 py-2 text-xs text-muted-foreground"
|
class="min-h-0 flex-1 overflow-hidden px-2 pb-2 pt-2 sm:px-3 sm:pb-3"
|
||||||
>
|
|
||||||
当前:{{ selectedShopLabel }}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<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">
|
<Grid :loading="loading" class="h-full min-h-0">
|
||||||
<template #toolbar-tools>
|
|
||||||
<span class="text-xs text-muted-foreground">
|
|
||||||
使用上方 goods_id 与日期筛选
|
|
||||||
</span>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<template #feeAmount="{ row }">
|
<template #feeAmount="{ row }">
|
||||||
<span class="font-semibold text-red-600">
|
<span class="font-semibold text-red-600">
|
||||||
{{ formatAmount(row.feeAmount) }}
|
{{ formatAmount(row.feeAmount) }}
|
||||||
@@ -345,7 +306,6 @@ const formatAmount = (amount: number) => `¥${Number(amount || 0).toFixed(2)}`;
|
|||||||
</Grid>
|
</Grid>
|
||||||
</div>
|
</div>
|
||||||
</Card>
|
</Card>
|
||||||
</Flex>
|
|
||||||
|
|
||||||
<GoodsAdFeeFormModal
|
<GoodsAdFeeFormModal
|
||||||
v-model:open="formModalVisible"
|
v-model:open="formModalVisible"
|
||||||
@@ -354,5 +314,5 @@ const formatAmount = (amount: number) => `¥${Number(amount || 0).toFixed(2)}`;
|
|||||||
@success="handleFormSuccess"
|
@success="handleFormSuccess"
|
||||||
@cancel="handleFormCancel"
|
@cancel="handleFormCancel"
|
||||||
/>
|
/>
|
||||||
</Page>
|
</PddShopColPage>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -4,11 +4,9 @@ import type { PddGoodsDTO, PddGoodsVO } from '#/api/channel/pdd/goods';
|
|||||||
import type { PddShopVO } from '#/api/channel/pdd/shop';
|
import type { PddShopVO } from '#/api/channel/pdd/shop';
|
||||||
import type { PageQueryDTO } from '#/types/common';
|
import type { PageQueryDTO } from '#/types/common';
|
||||||
|
|
||||||
import { computed, onMounted, ref } from 'vue';
|
import { computed, onMounted, ref, watch } from 'vue';
|
||||||
|
|
||||||
import { Page } from '@vben/common-ui';
|
import { Button, Card, Image, Popconfirm, Space, Tag, message } from 'ant-design-vue';
|
||||||
|
|
||||||
import { Button, Image, Popconfirm, Space, Tag, message } from 'ant-design-vue';
|
|
||||||
|
|
||||||
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||||
import {
|
import {
|
||||||
@@ -16,18 +14,20 @@ import {
|
|||||||
getPddGoodsPageApi,
|
getPddGoodsPageApi,
|
||||||
} from '#/api/channel/pdd/goods';
|
} from '#/api/channel/pdd/goods';
|
||||||
import { getPddShopPageApi } from '#/api/channel/pdd/shop';
|
import { getPddShopPageApi } from '#/api/channel/pdd/shop';
|
||||||
|
import PddShopColPage from '#/views/channel/pdd/components/PddShopColPage.vue';
|
||||||
import PddGoodsDetailDrawer from './components/PddGoodsDetailDrawer.vue';
|
|
||||||
import PddShopDetailModal from '#/views/channel/pdd/shop/components/PddShopDetailModal.vue';
|
import PddShopDetailModal from '#/views/channel/pdd/shop/components/PddShopDetailModal.vue';
|
||||||
import ProductDetailDrawer from '#/views/ec/product/list/components/ProductDetailDrawer.vue';
|
import ProductDetailDrawer from '#/views/ec/product/list/components/ProductDetailDrawer.vue';
|
||||||
|
|
||||||
|
import PddGoodsDetailDrawer from './components/PddGoodsDetailDrawer.vue';
|
||||||
|
|
||||||
defineOptions({ name: 'PddGoodsManagement' });
|
defineOptions({ name: 'PddGoodsManagement' });
|
||||||
|
|
||||||
const loading = ref(false);
|
const loading = ref(false);
|
||||||
const detailDrawerRef = ref<InstanceType<typeof PddGoodsDetailDrawer>>();
|
const detailDrawerRef = ref<InstanceType<typeof PddGoodsDetailDrawer>>();
|
||||||
const shopDetailModalRef = ref<InstanceType<typeof PddShopDetailModal>>();
|
const shopDetailModalRef = ref<InstanceType<typeof PddShopDetailModal>>();
|
||||||
const productDetailDrawerRef = ref<InstanceType<typeof ProductDetailDrawer>>();
|
const productDetailDrawerRef = ref<InstanceType<typeof ProductDetailDrawer>>();
|
||||||
const shopOptions = ref<{ label: string; value: number }[]>([]);
|
/** 左侧选中的拼多多渠道店铺 ID */
|
||||||
|
const selectedShopId = ref<number | undefined>(undefined);
|
||||||
const shopNameById = ref<Record<number, string>>({});
|
const shopNameById = ref<Record<number, string>>({});
|
||||||
|
|
||||||
const searchForm = ref({
|
const searchForm = ref({
|
||||||
@@ -39,35 +39,34 @@ const searchForm = ref({
|
|||||||
|
|
||||||
const gridReloadRef = ref<null | (() => void)>(null);
|
const gridReloadRef = ref<null | (() => void)>(null);
|
||||||
|
|
||||||
async function loadShops() {
|
async function loadShopNames() {
|
||||||
try {
|
try {
|
||||||
const data = await getPddShopPageApi({
|
const data = await getPddShopPageApi({
|
||||||
page: 1,
|
page: 1,
|
||||||
pageSize: 500,
|
pageSize: 500,
|
||||||
filters: {},
|
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> = {};
|
const map: Record<number, string> = {};
|
||||||
for (const s of list) {
|
for (const s of data.records ?? []) {
|
||||||
map[s.id] = s.mallName || `店铺#${s.id}`;
|
map[s.id] = s.mallName || `店铺#${s.id}`;
|
||||||
}
|
}
|
||||||
shopNameById.value = map;
|
shopNameById.value = map;
|
||||||
|
|
||||||
await gridApi.formApi?.updateSchema([
|
|
||||||
{
|
|
||||||
fieldName: 'shopId',
|
|
||||||
componentProps: { options: shopOptions.value },
|
|
||||||
},
|
|
||||||
]);
|
|
||||||
} catch {
|
} catch {
|
||||||
message.error('获取渠道店铺失败');
|
message.error('获取渠道店铺失败');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function onShopSelect(shop: PddShopVO.Info | null) {
|
||||||
|
if (!shop) {
|
||||||
|
selectedShopId.value = undefined;
|
||||||
|
searchForm.value.shopId = undefined;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
selectedShopId.value = shop.id;
|
||||||
|
searchForm.value.shopId = shop.id;
|
||||||
|
shopNameById.value[shop.id] = shop.mallName || `店铺#${shop.id}`;
|
||||||
|
}
|
||||||
|
|
||||||
const gridOptions: VxeGridProps<PddGoodsVO.Info> = {
|
const gridOptions: VxeGridProps<PddGoodsVO.Info> = {
|
||||||
columns: [
|
columns: [
|
||||||
{ type: 'seq' as const, width: 56, title: '序号' },
|
{ type: 'seq' as const, width: 56, title: '序号' },
|
||||||
@@ -134,7 +133,7 @@ const gridOptions: VxeGridProps<PddGoodsVO.Info> = {
|
|||||||
slots: { default: 'action' },
|
slots: { default: 'action' },
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
height: 'auto',
|
height: '100%',
|
||||||
border: true,
|
border: true,
|
||||||
stripe: true,
|
stripe: true,
|
||||||
rowConfig: { isHover: true, height: 72 },
|
rowConfig: { isHover: true, height: 72 },
|
||||||
@@ -203,22 +202,6 @@ const gridOptions: VxeGridProps<PddGoodsVO.Info> = {
|
|||||||
|
|
||||||
const formOptions = computed(() => ({
|
const formOptions = computed(() => ({
|
||||||
schema: [
|
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',
|
component: 'Input',
|
||||||
componentProps: {
|
componentProps: {
|
||||||
@@ -283,11 +266,15 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
|||||||
gridOptions,
|
gridOptions,
|
||||||
formOptions: formOptions.value,
|
formOptions: formOptions.value,
|
||||||
showSearchForm: true,
|
showSearchForm: true,
|
||||||
tableTitle: '拼多多渠道商品',
|
tableTitle: '',
|
||||||
});
|
});
|
||||||
|
|
||||||
gridReloadRef.value = () => gridApi.reload();
|
gridReloadRef.value = () => gridApi.reload();
|
||||||
|
|
||||||
|
watch(selectedShopId, () => {
|
||||||
|
gridApi.reload();
|
||||||
|
});
|
||||||
|
|
||||||
function openDetail(row: PddGoodsVO.Info) {
|
function openDetail(row: PddGoodsVO.Info) {
|
||||||
const shopLabel = row.shopId
|
const shopLabel = row.shopId
|
||||||
? shopNameById.value[row.shopId]
|
? shopNameById.value[row.shopId]
|
||||||
@@ -322,13 +309,30 @@ async function handleDelete(row: PddGoodsVO.Info) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
await loadShops();
|
await loadShopNames();
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<Page auto-content-height>
|
<PddShopColPage :selected-shop-id="selectedShopId" @select="onShopSelect">
|
||||||
<Grid class="pdd-goods-grid">
|
<Card
|
||||||
|
class="ml-1 flex h-full min-h-0 min-w-0 flex-1 flex-col sm:ml-2"
|
||||||
|
:body-style="{
|
||||||
|
height: '100%',
|
||||||
|
minHeight: 0,
|
||||||
|
padding: 0,
|
||||||
|
display: 'flex',
|
||||||
|
flexDirection: 'column',
|
||||||
|
}"
|
||||||
|
>
|
||||||
|
<template #title>
|
||||||
|
<span class="text-base font-semibold">拼多多商品</span>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<div
|
||||||
|
class="min-h-0 flex-1 overflow-hidden px-2 pb-2 pt-2 sm:px-3 sm:pb-3"
|
||||||
|
>
|
||||||
|
<Grid class="pdd-goods-grid h-full min-h-0" :loading="loading">
|
||||||
<template #thumb="{ row }: { row: PddGoodsVO.Info }">
|
<template #thumb="{ row }: { row: PddGoodsVO.Info }">
|
||||||
<Image
|
<Image
|
||||||
v-if="row.thumbUrl || row.imageUrl"
|
v-if="row.thumbUrl || row.imageUrl"
|
||||||
@@ -398,6 +402,8 @@ onMounted(async () => {
|
|||||||
</Space>
|
</Space>
|
||||||
</template>
|
</template>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
</div>
|
||||||
|
</Card>
|
||||||
|
|
||||||
<PddGoodsDetailDrawer
|
<PddGoodsDetailDrawer
|
||||||
ref="detailDrawerRef"
|
ref="detailDrawerRef"
|
||||||
@@ -405,7 +411,7 @@ onMounted(async () => {
|
|||||||
/>
|
/>
|
||||||
<PddShopDetailModal ref="shopDetailModalRef" />
|
<PddShopDetailModal ref="shopDetailModalRef" />
|
||||||
<ProductDetailDrawer ref="productDetailDrawerRef" />
|
<ProductDetailDrawer ref="productDetailDrawerRef" />
|
||||||
</Page>
|
</PddShopColPage>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
|
|||||||
@@ -1,20 +1,20 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import type { VxeGridProps } from '#/adapter/vxe-table';
|
import type { VxeGridProps } from '#/adapter/vxe-table';
|
||||||
import type { PddOrderDTO, PddOrderVO } from '#/api/channel/pdd/order';
|
import type { PddOrderDTO, PddOrderVO } from '#/api/channel/pdd/order';
|
||||||
|
import type { PddShopVO } from '#/api/channel/pdd/shop';
|
||||||
import type { ShopDTO, ShopVO } from '#/api/ec/shop/types';
|
import type { ShopDTO, ShopVO } from '#/api/ec/shop/types';
|
||||||
import type { PageQueryDTO } from '#/types/common';
|
import type { PageQueryDTO } from '#/types/common';
|
||||||
|
|
||||||
import { computed, onMounted, ref } from 'vue';
|
import { computed, onMounted, ref, watch } from 'vue';
|
||||||
|
|
||||||
import { Page } from '@vben/common-ui';
|
import { Button, Card, Image, Space, Tag, Tooltip, message } from 'ant-design-vue';
|
||||||
|
|
||||||
import dayjs from 'dayjs';
|
|
||||||
|
|
||||||
import { Button, Image, Space, Tag, Tooltip, message } from 'ant-design-vue';
|
|
||||||
|
|
||||||
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||||
import { getPddOrderPageApi } from '#/api/channel/pdd/order';
|
import { getPddOrderPageApi } from '#/api/channel/pdd/order';
|
||||||
import { getShopPageApi } from '#/api/ec/shop';
|
import { getShopPageApi } from '#/api/ec/shop';
|
||||||
|
import PddShopColPage from '#/views/channel/pdd/components/PddShopColPage.vue';
|
||||||
|
|
||||||
|
import dayjs from 'dayjs';
|
||||||
|
|
||||||
import PddOrderDetailDrawer from './components/PddOrderDetailDrawer.vue';
|
import PddOrderDetailDrawer from './components/PddOrderDetailDrawer.vue';
|
||||||
|
|
||||||
@@ -37,7 +37,10 @@ const REFUND_STATUS_MAP: Record<number, { color: string; text: string }> = {
|
|||||||
|
|
||||||
const loading = ref(false);
|
const loading = ref(false);
|
||||||
const detailDrawerRef = ref<InstanceType<typeof PddOrderDetailDrawer>>();
|
const detailDrawerRef = ref<InstanceType<typeof PddOrderDetailDrawer>>();
|
||||||
const shopOptions = ref<{ label: string; value: number }[]>([]);
|
/** 左侧选中的拼多多渠道店铺 ID */
|
||||||
|
const selectedPddShopId = ref<number | undefined>(undefined);
|
||||||
|
/** 渠道店铺 ID → 内部店铺 ID(订单表 shop_id 为 ec_shop.id) */
|
||||||
|
const ecShopIdByPddShopId = ref<Record<number, number>>({});
|
||||||
const shopNameById = ref<Record<number, string>>({});
|
const shopNameById = ref<Record<number, string>>({});
|
||||||
|
|
||||||
const DEFAULT_LIST_DAYS = 7;
|
const DEFAULT_LIST_DAYS = 7;
|
||||||
@@ -94,7 +97,7 @@ function goodsSpecTooltip(row: PddOrderVO.Info) {
|
|||||||
return text || undefined;
|
return text || undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function loadPddShops() {
|
async function loadShopMappings() {
|
||||||
try {
|
try {
|
||||||
const data = await getShopPageApi({
|
const data = await getShopPageApi({
|
||||||
page: 1,
|
page: 1,
|
||||||
@@ -107,21 +110,36 @@ async function loadPddShops() {
|
|||||||
!!s.pddShop ||
|
!!s.pddShop ||
|
||||||
!!s.externalShopId,
|
!!s.externalShopId,
|
||||||
);
|
);
|
||||||
shopOptions.value = list.map((s) => ({ label: s.name, value: s.id }));
|
const ecMap: Record<number, number> = {};
|
||||||
const map: Record<number, string> = {};
|
const nameMap: Record<number, string> = {};
|
||||||
for (const s of list) map[s.id] = s.name;
|
for (const s of list) {
|
||||||
shopNameById.value = map;
|
nameMap[s.id] = s.name;
|
||||||
|
if (s.externalShopId != null) {
|
||||||
await gridApi.formApi?.updateSchema([
|
ecMap[s.externalShopId] = s.id;
|
||||||
{
|
|
||||||
fieldName: 'shopId',
|
|
||||||
componentProps: { options: shopOptions.value },
|
|
||||||
},
|
|
||||||
]);
|
|
||||||
} catch {
|
|
||||||
message.error('获取店铺列表失败');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
ecShopIdByPddShopId.value = ecMap;
|
||||||
|
shopNameById.value = nameMap;
|
||||||
|
} catch {
|
||||||
|
message.error('获取店铺映射失败');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function onShopSelect(shop: PddShopVO.Info | null) {
|
||||||
|
if (!shop) {
|
||||||
|
selectedPddShopId.value = undefined;
|
||||||
|
searchForm.value.shopId = undefined;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
selectedPddShopId.value = shop.id;
|
||||||
|
const ecShopId = ecShopIdByPddShopId.value[shop.id];
|
||||||
|
if (ecShopId == null) {
|
||||||
|
message.warning('该拼多多店铺尚未绑定内部店铺,暂无订单数据');
|
||||||
|
searchForm.value.shopId = -1;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
searchForm.value.shopId = ecShopId;
|
||||||
|
}
|
||||||
|
|
||||||
const gridOptions: VxeGridProps<PddOrderVO.Info> = {
|
const gridOptions: VxeGridProps<PddOrderVO.Info> = {
|
||||||
columns: [
|
columns: [
|
||||||
@@ -187,7 +205,7 @@ const gridOptions: VxeGridProps<PddOrderVO.Info> = {
|
|||||||
slots: { default: 'action' },
|
slots: { default: 'action' },
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
height: 'auto',
|
height: '100%',
|
||||||
border: true,
|
border: true,
|
||||||
stripe: true,
|
stripe: true,
|
||||||
rowConfig: { isHover: true, height: 84 },
|
rowConfig: { isHover: true, height: 84 },
|
||||||
@@ -273,22 +291,6 @@ const formOptions = computed(() => ({
|
|||||||
fieldName: 'orderSn',
|
fieldName: 'orderSn',
|
||||||
label: '订单号',
|
label: '订单号',
|
||||||
},
|
},
|
||||||
{
|
|
||||||
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: 'Select',
|
component: 'Select',
|
||||||
componentProps: {
|
componentProps: {
|
||||||
@@ -362,23 +364,47 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
|||||||
gridOptions,
|
gridOptions,
|
||||||
formOptions: formOptions.value,
|
formOptions: formOptions.value,
|
||||||
showSearchForm: true,
|
showSearchForm: true,
|
||||||
tableTitle: '拼多多订单',
|
tableTitle: '',
|
||||||
});
|
});
|
||||||
|
|
||||||
gridReloadRef.value = () => gridApi.reload();
|
gridReloadRef.value = () => gridApi.reload();
|
||||||
|
|
||||||
|
watch(selectedPddShopId, () => {
|
||||||
|
gridApi.reload();
|
||||||
|
});
|
||||||
|
|
||||||
function openDetail(row: PddOrderVO.Info) {
|
function openDetail(row: PddOrderVO.Info) {
|
||||||
detailDrawerRef.value?.open(row.id, shopNameById.value[row.shopId]);
|
detailDrawerRef.value?.open(row.id, shopNameById.value[row.shopId]);
|
||||||
}
|
}
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
await loadPddShops();
|
await loadShopMappings();
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<Page auto-content-height>
|
<PddShopColPage
|
||||||
<Grid class="pdd-order-grid">
|
:selected-shop-id="selectedPddShopId"
|
||||||
|
@select="onShopSelect"
|
||||||
|
>
|
||||||
|
<Card
|
||||||
|
class="ml-1 flex h-full min-h-0 min-w-0 flex-1 flex-col sm:ml-2"
|
||||||
|
:body-style="{
|
||||||
|
height: '100%',
|
||||||
|
minHeight: 0,
|
||||||
|
padding: 0,
|
||||||
|
display: 'flex',
|
||||||
|
flexDirection: 'column',
|
||||||
|
}"
|
||||||
|
>
|
||||||
|
<template #title>
|
||||||
|
<span class="text-base font-semibold">拼多多订单</span>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<div
|
||||||
|
class="min-h-0 flex-1 overflow-hidden px-2 pb-2 pt-2 sm:px-3 sm:pb-3"
|
||||||
|
>
|
||||||
|
<Grid class="pdd-order-grid h-full min-h-0" :loading="loading">
|
||||||
<template #shopName="{ row }">
|
<template #shopName="{ row }">
|
||||||
{{ shopNameById[row.shopId] || `店铺#${row.shopId}` }}
|
{{ shopNameById[row.shopId] || `店铺#${row.shopId}` }}
|
||||||
</template>
|
</template>
|
||||||
@@ -447,9 +473,11 @@ onMounted(async () => {
|
|||||||
</Space>
|
</Space>
|
||||||
</template>
|
</template>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
</div>
|
||||||
|
</Card>
|
||||||
|
|
||||||
<PddOrderDetailDrawer ref="detailDrawerRef" />
|
<PddOrderDetailDrawer ref="detailDrawerRef" />
|
||||||
</Page>
|
</PddShopColPage>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
|
|||||||
@@ -0,0 +1,73 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import type { CompanyVO } from '#/api/company/types';
|
||||||
|
|
||||||
|
import { ColPage } from '@vben/common-ui';
|
||||||
|
|
||||||
|
import CompanySidebarList from '#/views/company/components/CompanySidebarList.vue';
|
||||||
|
|
||||||
|
defineOptions({ name: 'CompanyColPage' });
|
||||||
|
|
||||||
|
withDefaults(
|
||||||
|
defineProps<{
|
||||||
|
selectedCompanyId?: number;
|
||||||
|
autoContentHeight?: boolean;
|
||||||
|
leftWidth?: number;
|
||||||
|
leftMinWidth?: number;
|
||||||
|
leftMaxWidth?: number;
|
||||||
|
leftCollapsedWidth?: number;
|
||||||
|
leftCollapsible?: boolean;
|
||||||
|
resizable?: boolean;
|
||||||
|
splitHandle?: boolean;
|
||||||
|
splitLine?: boolean;
|
||||||
|
}>(),
|
||||||
|
{
|
||||||
|
autoContentHeight: true,
|
||||||
|
leftWidth: 22,
|
||||||
|
leftMinWidth: 16,
|
||||||
|
leftMaxWidth: 36,
|
||||||
|
leftCollapsedWidth: 5,
|
||||||
|
leftCollapsible: true,
|
||||||
|
resizable: true,
|
||||||
|
splitHandle: false,
|
||||||
|
splitLine: false,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
const emit = defineEmits<{
|
||||||
|
'update:selectedCompanyId': [id: number | undefined];
|
||||||
|
select: [company: CompanyVO.CompanyInfoVO];
|
||||||
|
}>();
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<ColPage
|
||||||
|
:auto-content-height="autoContentHeight"
|
||||||
|
:left-width="leftWidth"
|
||||||
|
:left-min-width="leftMinWidth"
|
||||||
|
:left-max-width="leftMaxWidth"
|
||||||
|
:left-collapsed-width="leftCollapsedWidth"
|
||||||
|
:left-collapsible="leftCollapsible"
|
||||||
|
:right-width="100 - leftWidth"
|
||||||
|
:resizable="resizable"
|
||||||
|
:split-handle="splitHandle"
|
||||||
|
:split-line="splitLine"
|
||||||
|
content-class="!p-2 sm:!p-3"
|
||||||
|
>
|
||||||
|
<template #left="{ isCollapsed, expand, collapse }">
|
||||||
|
<div class="flex h-full min-h-0 min-w-0 flex-col overflow-hidden">
|
||||||
|
<CompanySidebarList
|
||||||
|
fluid
|
||||||
|
:collapsed="isCollapsed"
|
||||||
|
show-collapse-action
|
||||||
|
:selected-company-id="selectedCompanyId"
|
||||||
|
@collapse="collapse"
|
||||||
|
@expand="expand"
|
||||||
|
@update:selected-company-id="emit('update:selectedCompanyId', $event)"
|
||||||
|
@select="emit('select', $event)"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<slot />
|
||||||
|
</ColPage>
|
||||||
|
</template>
|
||||||
@@ -0,0 +1,55 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import { computed } from 'vue';
|
||||||
|
|
||||||
|
import { createIconifyIcon } from '@vben/icons';
|
||||||
|
|
||||||
|
import { Avatar } from 'ant-design-vue';
|
||||||
|
|
||||||
|
defineOptions({ name: 'CompanyLogoAvatar' });
|
||||||
|
|
||||||
|
const props = withDefaults(
|
||||||
|
defineProps<{
|
||||||
|
logo?: string;
|
||||||
|
name?: string;
|
||||||
|
size?: number;
|
||||||
|
}>(),
|
||||||
|
{
|
||||||
|
logo: undefined,
|
||||||
|
name: undefined,
|
||||||
|
size: 36,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
const BuildingIcon = createIconifyIcon('lucide:building-2');
|
||||||
|
|
||||||
|
const fallbackText = computed(() => {
|
||||||
|
const text = props.name?.trim();
|
||||||
|
return text ? text.charAt(0).toUpperCase() : '';
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<Avatar
|
||||||
|
:size="size"
|
||||||
|
:src="logo"
|
||||||
|
:alt="name"
|
||||||
|
shape="square"
|
||||||
|
class="company-logo-avatar shrink-0 !rounded-md !bg-muted"
|
||||||
|
>
|
||||||
|
<span v-if="fallbackText" class="text-xs font-medium">{{ fallbackText }}</span>
|
||||||
|
<BuildingIcon v-else class="h-4 w-4 text-muted-foreground" />
|
||||||
|
</Avatar>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.company-logo-avatar {
|
||||||
|
display: inline-flex !important;
|
||||||
|
align-items: center !important;
|
||||||
|
justify-content: center !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.company-logo-avatar span {
|
||||||
|
display: block;
|
||||||
|
line-height: 1;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -0,0 +1,330 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import type { CompanyVO } from '#/api/company/types';
|
||||||
|
|
||||||
|
import { computed, onMounted, ref } from 'vue';
|
||||||
|
|
||||||
|
import { createIconifyIcon } from '@vben/icons';
|
||||||
|
|
||||||
|
import {
|
||||||
|
Button,
|
||||||
|
Card,
|
||||||
|
Empty,
|
||||||
|
Input,
|
||||||
|
message,
|
||||||
|
Select,
|
||||||
|
Spin,
|
||||||
|
Tag,
|
||||||
|
Tooltip,
|
||||||
|
} from 'ant-design-vue';
|
||||||
|
|
||||||
|
import { getCompanyPageApi } from '#/api/company';
|
||||||
|
import CompanyLogoAvatar from '#/views/company/components/CompanyLogoAvatar.vue';
|
||||||
|
|
||||||
|
defineOptions({ name: 'CompanySidebarList' });
|
||||||
|
|
||||||
|
const props = withDefaults(
|
||||||
|
defineProps<{
|
||||||
|
selectedCompanyId?: number;
|
||||||
|
fluid?: boolean;
|
||||||
|
showCollapseAction?: boolean;
|
||||||
|
collapsed?: boolean;
|
||||||
|
}>(),
|
||||||
|
{
|
||||||
|
selectedCompanyId: undefined,
|
||||||
|
fluid: false,
|
||||||
|
showCollapseAction: false,
|
||||||
|
collapsed: false,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
const emit = defineEmits<{
|
||||||
|
'update:selectedCompanyId': [id: number | undefined];
|
||||||
|
select: [company: CompanyVO.CompanyInfoVO];
|
||||||
|
collapse: [];
|
||||||
|
expand: [];
|
||||||
|
}>();
|
||||||
|
|
||||||
|
const BuildingIcon = createIconifyIcon('lucide:building-2');
|
||||||
|
const PanelCloseIcon = createIconifyIcon('lucide:panel-left-close');
|
||||||
|
const PanelOpenIcon = createIconifyIcon('lucide:panel-left-open');
|
||||||
|
const ChevronUpIcon = createIconifyIcon('lucide:chevron-up');
|
||||||
|
const ChevronDownIcon = createIconifyIcon('lucide:chevron-down');
|
||||||
|
|
||||||
|
const companySearchForm = ref({
|
||||||
|
name: '',
|
||||||
|
status: undefined as number | undefined,
|
||||||
|
});
|
||||||
|
|
||||||
|
const companies = ref<CompanyVO.CompanyInfoVO[]>([]);
|
||||||
|
const companiesLoading = ref(false);
|
||||||
|
const companyPagination = ref({ current: 1, pageSize: 20, total: 0 });
|
||||||
|
|
||||||
|
const companyTotalPages = computed(() => {
|
||||||
|
const { total, pageSize } = companyPagination.value;
|
||||||
|
return Math.max(1, Math.ceil(total / pageSize) || 1);
|
||||||
|
});
|
||||||
|
|
||||||
|
async function searchCompanies(resetPage = false) {
|
||||||
|
if (resetPage) {
|
||||||
|
companyPagination.value.current = 1;
|
||||||
|
}
|
||||||
|
companiesLoading.value = true;
|
||||||
|
try {
|
||||||
|
const result = await getCompanyPageApi({
|
||||||
|
page: companyPagination.value.current,
|
||||||
|
pageSize: companyPagination.value.pageSize,
|
||||||
|
filters: {
|
||||||
|
name: companySearchForm.value.name || undefined,
|
||||||
|
status: companySearchForm.value.status,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
companies.value = result.records ?? [];
|
||||||
|
companyPagination.value.total = result.total ?? 0;
|
||||||
|
} catch (error: any) {
|
||||||
|
message.error(error?.message || '获取公司列表失败');
|
||||||
|
companies.value = [];
|
||||||
|
} finally {
|
||||||
|
companiesLoading.value = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function resetCompanySearch() {
|
||||||
|
companySearchForm.value = { name: '', status: undefined };
|
||||||
|
void searchCompanies(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
function goCompanyPage(page: number) {
|
||||||
|
const next = Math.min(companyTotalPages.value, Math.max(1, page));
|
||||||
|
if (next === companyPagination.value.current) return;
|
||||||
|
companyPagination.value.current = next;
|
||||||
|
void searchCompanies();
|
||||||
|
}
|
||||||
|
|
||||||
|
function selectCompany(company: CompanyVO.CompanyInfoVO) {
|
||||||
|
emit('update:selectedCompanyId', company.id);
|
||||||
|
emit('select', company);
|
||||||
|
}
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
void searchCompanies();
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div
|
||||||
|
v-if="collapsed"
|
||||||
|
class="flex h-full min-h-0 w-full flex-col items-center gap-1 pb-2 pt-3"
|
||||||
|
>
|
||||||
|
<Tooltip title="展开公司列表">
|
||||||
|
<Button type="text" size="small" class="!px-1" @click="emit('expand')">
|
||||||
|
<PanelOpenIcon class="h-4 w-4" />
|
||||||
|
</Button>
|
||||||
|
</Tooltip>
|
||||||
|
|
||||||
|
<div
|
||||||
|
class="flex min-h-0 w-full flex-1 flex-col items-center gap-1.5 overflow-y-auto px-1 pb-1 pt-2"
|
||||||
|
>
|
||||||
|
<Spin
|
||||||
|
:spinning="companiesLoading"
|
||||||
|
size="small"
|
||||||
|
wrapper-class-name="company-sidebar-collapsed-spin"
|
||||||
|
>
|
||||||
|
<div class="flex w-full flex-col items-center gap-1.5">
|
||||||
|
<Tooltip v-for="company in companies" :key="company.id" :title="company.name">
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
class="inline-flex shrink-0 rounded-md p-0.5 transition-colors hover:bg-accent"
|
||||||
|
:class="
|
||||||
|
selectedCompanyId === company.id
|
||||||
|
? 'ring-2 ring-primary ring-offset-1 ring-offset-background'
|
||||||
|
: undefined
|
||||||
|
"
|
||||||
|
@click="selectCompany(company)"
|
||||||
|
>
|
||||||
|
<CompanyLogoAvatar
|
||||||
|
:logo="company.logo"
|
||||||
|
:name="company.name"
|
||||||
|
:size="36"
|
||||||
|
/>
|
||||||
|
</button>
|
||||||
|
</Tooltip>
|
||||||
|
</div>
|
||||||
|
</Spin>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div
|
||||||
|
v-if="companyTotalPages > 1"
|
||||||
|
class="flex shrink-0 flex-col items-center gap-0.5"
|
||||||
|
>
|
||||||
|
<Button
|
||||||
|
type="text"
|
||||||
|
size="small"
|
||||||
|
class="!h-6 !px-1"
|
||||||
|
:disabled="companyPagination.current <= 1 || companiesLoading"
|
||||||
|
@click="goCompanyPage(companyPagination.current - 1)"
|
||||||
|
>
|
||||||
|
<ChevronUpIcon class="h-3.5 w-3.5" />
|
||||||
|
</Button>
|
||||||
|
<span class="text-[10px] leading-none text-muted-foreground">
|
||||||
|
{{ companyPagination.current }}/{{ companyTotalPages }}
|
||||||
|
</span>
|
||||||
|
<Button
|
||||||
|
type="text"
|
||||||
|
size="small"
|
||||||
|
class="!h-6 !px-1"
|
||||||
|
:disabled="companyPagination.current >= companyTotalPages || companiesLoading"
|
||||||
|
@click="goCompanyPage(companyPagination.current + 1)"
|
||||||
|
>
|
||||||
|
<ChevronDownIcon class="h-3.5 w-3.5" />
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<Card
|
||||||
|
v-else
|
||||||
|
class="flex h-full flex-col overflow-hidden"
|
||||||
|
:class="fluid ? 'w-full min-w-0' : 'w-[320px] shrink-0'"
|
||||||
|
:body-style="{
|
||||||
|
height: '100%',
|
||||||
|
display: 'flex',
|
||||||
|
flexDirection: 'column',
|
||||||
|
gap: '8px',
|
||||||
|
minHeight: 0,
|
||||||
|
minWidth: 0,
|
||||||
|
overflow: 'hidden',
|
||||||
|
padding: '12px',
|
||||||
|
}"
|
||||||
|
>
|
||||||
|
<template #title>
|
||||||
|
<span class="flex items-center gap-2 text-base font-semibold">
|
||||||
|
<BuildingIcon class="h-4 w-4" />
|
||||||
|
公司
|
||||||
|
</span>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<template v-if="showCollapseAction" #extra>
|
||||||
|
<Tooltip title="收起公司列表">
|
||||||
|
<Button type="text" size="small" class="!px-1" @click="emit('collapse')">
|
||||||
|
<PanelCloseIcon class="h-4 w-4" />
|
||||||
|
</Button>
|
||||||
|
</Tooltip>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<div class="flex min-w-0 shrink-0 flex-col gap-2">
|
||||||
|
<Input
|
||||||
|
v-model:value="companySearchForm.name"
|
||||||
|
placeholder="公司名称"
|
||||||
|
allow-clear
|
||||||
|
class="w-full min-w-0"
|
||||||
|
@press-enter="searchCompanies(true)"
|
||||||
|
/>
|
||||||
|
<div class="flex min-w-0 items-center gap-2">
|
||||||
|
<Select
|
||||||
|
v-model:value="companySearchForm.status"
|
||||||
|
placeholder="状态"
|
||||||
|
allow-clear
|
||||||
|
class="min-w-0 flex-1"
|
||||||
|
:options="[
|
||||||
|
{ label: '启用', value: 1 },
|
||||||
|
{ label: '禁用', value: 0 },
|
||||||
|
]"
|
||||||
|
/>
|
||||||
|
<Button type="primary" class="shrink-0" @click="searchCompanies(true)">
|
||||||
|
搜索
|
||||||
|
</Button>
|
||||||
|
<Button class="shrink-0" @click="resetCompanySearch">重置</Button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden">
|
||||||
|
<div class="min-h-0 flex-1 overflow-y-auto">
|
||||||
|
<Spin :spinning="companiesLoading">
|
||||||
|
<Empty
|
||||||
|
v-if="!companiesLoading && companies.length === 0"
|
||||||
|
class="py-8"
|
||||||
|
description="暂无公司"
|
||||||
|
/>
|
||||||
|
<template v-else>
|
||||||
|
<Card
|
||||||
|
v-for="company in companies"
|
||||||
|
:key="company.id"
|
||||||
|
size="small"
|
||||||
|
:body-style="{ padding: '10px 12px' }"
|
||||||
|
class="mb-2 cursor-pointer !shadow-none last:mb-0 hover:border-primary"
|
||||||
|
:class="
|
||||||
|
selectedCompanyId === company.id
|
||||||
|
? 'border-primary bg-primary/5'
|
||||||
|
: undefined
|
||||||
|
"
|
||||||
|
@click="selectCompany(company)"
|
||||||
|
>
|
||||||
|
<div class="flex items-center gap-2">
|
||||||
|
<CompanyLogoAvatar
|
||||||
|
:logo="company.logo"
|
||||||
|
:name="company.name"
|
||||||
|
:size="36"
|
||||||
|
/>
|
||||||
|
<div class="flex min-w-0 flex-1 items-center justify-between gap-2">
|
||||||
|
<span class="min-w-0 truncate text-sm font-medium">
|
||||||
|
{{ company.name }}
|
||||||
|
</span>
|
||||||
|
<Tag
|
||||||
|
class="m-0 shrink-0"
|
||||||
|
:color="company.status === 1 ? 'green' : 'red'"
|
||||||
|
>
|
||||||
|
{{ company.status === 1 ? '启用' : '禁用' }}
|
||||||
|
</Tag>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</Card>
|
||||||
|
</template>
|
||||||
|
</Spin>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div
|
||||||
|
class="mt-2 flex w-full min-w-0 shrink-0 items-center justify-between gap-2"
|
||||||
|
>
|
||||||
|
<Button
|
||||||
|
size="small"
|
||||||
|
class="shrink-0"
|
||||||
|
:disabled="companyPagination.current <= 1 || companiesLoading"
|
||||||
|
@click="goCompanyPage(companyPagination.current - 1)"
|
||||||
|
>
|
||||||
|
上一页
|
||||||
|
</Button>
|
||||||
|
<span
|
||||||
|
class="min-w-0 flex-1 truncate text-center text-xs text-muted-foreground"
|
||||||
|
>
|
||||||
|
{{ companyPagination.current }} / {{ companyTotalPages }}
|
||||||
|
<span class="ml-1 opacity-70">({{ companyPagination.total }})</span>
|
||||||
|
</span>
|
||||||
|
<Button
|
||||||
|
size="small"
|
||||||
|
class="shrink-0"
|
||||||
|
:disabled="
|
||||||
|
companyPagination.current >= companyTotalPages || companiesLoading
|
||||||
|
"
|
||||||
|
@click="goCompanyPage(companyPagination.current + 1)"
|
||||||
|
>
|
||||||
|
下一页
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</Card>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
:deep(.company-sidebar-collapsed-spin) {
|
||||||
|
display: flex;
|
||||||
|
width: 100%;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
:deep(.company-sidebar-collapsed-spin .ant-spin-container) {
|
||||||
|
display: flex;
|
||||||
|
width: 100%;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -1,19 +1,13 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import type { CompanyVO } from '#/api/company/types';
|
import type { CompanyVO } from '#/api/company/types';
|
||||||
|
|
||||||
import { computed, onMounted, ref } from 'vue';
|
import { computed, ref } from 'vue';
|
||||||
|
|
||||||
import { Page } from '@vben/common-ui';
|
|
||||||
import { createIconifyIcon } from '@vben/icons';
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
Button,
|
Button,
|
||||||
Card,
|
Card,
|
||||||
Empty,
|
Empty,
|
||||||
Flex,
|
|
||||||
Input,
|
|
||||||
message,
|
message,
|
||||||
Select,
|
|
||||||
Space,
|
Space,
|
||||||
Spin,
|
Spin,
|
||||||
Tag,
|
Tag,
|
||||||
@@ -25,27 +19,13 @@ import {
|
|||||||
getCompanyMenusApi,
|
getCompanyMenusApi,
|
||||||
getCompanyMenuIdsApi,
|
getCompanyMenuIdsApi,
|
||||||
} from '#/api/company/menu/apis';
|
} from '#/api/company/menu/apis';
|
||||||
import { getCompanyPageApi } from '#/api/company';
|
import CompanyColPage from '#/views/company/components/CompanyColPage.vue';
|
||||||
|
|
||||||
defineOptions({
|
defineOptions({
|
||||||
name: 'CompanyMenuManagePage',
|
name: 'CompanyMenuManagePage',
|
||||||
});
|
});
|
||||||
|
|
||||||
const BuildingIcon = createIconifyIcon('lucide:building-2');
|
const selectedCompanyId = ref<number | undefined>(undefined);
|
||||||
|
|
||||||
const companySearchForm = ref({
|
|
||||||
name: '',
|
|
||||||
status: undefined as number | undefined,
|
|
||||||
});
|
|
||||||
|
|
||||||
const companyList = ref<CompanyVO.CompanyInfoVO[]>([]);
|
|
||||||
const companyLoading = ref(false);
|
|
||||||
const companyPagination = ref({
|
|
||||||
current: 1,
|
|
||||||
pageSize: 20,
|
|
||||||
total: 0,
|
|
||||||
});
|
|
||||||
|
|
||||||
const currentCompany = ref<CompanyVO.CompanyInfoVO | null>(null);
|
const currentCompany = ref<CompanyVO.CompanyInfoVO | null>(null);
|
||||||
|
|
||||||
const systemMenuList = ref<any[]>([]);
|
const systemMenuList = ref<any[]>([]);
|
||||||
@@ -54,13 +34,6 @@ const selectedMenuIds = ref<number[]>([]);
|
|||||||
const menuExpandedKeys = ref<(number | string)[]>([]);
|
const menuExpandedKeys = ref<(number | string)[]>([]);
|
||||||
const menuLoading = ref(false);
|
const menuLoading = ref(false);
|
||||||
|
|
||||||
const selectedCompanyLabel = computed(() => {
|
|
||||||
if (!currentCompany.value) {
|
|
||||||
return '请先选择公司';
|
|
||||||
}
|
|
||||||
return currentCompany.value.name;
|
|
||||||
});
|
|
||||||
|
|
||||||
const menuTreeData = computed(() => {
|
const menuTreeData = computed(() => {
|
||||||
const list = systemMenuList.value;
|
const list = systemMenuList.value;
|
||||||
const map = new Map<number, any>();
|
const map = new Map<number, any>();
|
||||||
@@ -89,29 +62,10 @@ const stats = computed(() => ({
|
|||||||
changed: selectedMenuIds.value.length !== companyMenuIds.value.length,
|
changed: selectedMenuIds.value.length !== companyMenuIds.value.length,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
async function searchCompanies() {
|
function onCompanySelect(company: CompanyVO.CompanyInfoVO) {
|
||||||
companyLoading.value = true;
|
|
||||||
try {
|
|
||||||
const result = await getCompanyPageApi({
|
|
||||||
page: companyPagination.value.current,
|
|
||||||
pageSize: companyPagination.value.pageSize,
|
|
||||||
filters: {
|
|
||||||
name: companySearchForm.value.name || undefined,
|
|
||||||
status: companySearchForm.value.status,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
companyList.value = result.records;
|
|
||||||
companyPagination.value.total = result.total;
|
|
||||||
} catch (error: any) {
|
|
||||||
message.error(error?.message || '获取公司列表失败');
|
|
||||||
} finally {
|
|
||||||
companyLoading.value = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function selectCompany(company: CompanyVO.CompanyInfoVO) {
|
|
||||||
currentCompany.value = company;
|
currentCompany.value = company;
|
||||||
await loadCompanyMenus();
|
selectedCompanyId.value = company.id;
|
||||||
|
void loadCompanyMenus();
|
||||||
}
|
}
|
||||||
|
|
||||||
async function loadCompanyMenus() {
|
async function loadCompanyMenus() {
|
||||||
@@ -208,47 +162,40 @@ async function handleSave() {
|
|||||||
message.error(error?.message || '保存失败');
|
message.error(error?.message || '保存失败');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function resetCompanySearch() {
|
|
||||||
companySearchForm.value = { name: '', status: undefined };
|
|
||||||
companyPagination.value.current = 1;
|
|
||||||
searchCompanies();
|
|
||||||
}
|
|
||||||
|
|
||||||
function handleCompanyPageChange(page: number, pageSize: number) {
|
|
||||||
companyPagination.value.current = page;
|
|
||||||
companyPagination.value.pageSize = pageSize;
|
|
||||||
searchCompanies();
|
|
||||||
}
|
|
||||||
|
|
||||||
const companyTotalPages = computed(() => {
|
|
||||||
const { total, pageSize } = companyPagination.value;
|
|
||||||
return Math.max(1, Math.ceil(total / pageSize) || 1);
|
|
||||||
});
|
|
||||||
|
|
||||||
function goCompanyPage(page: number) {
|
|
||||||
const next = Math.min(companyTotalPages.value, Math.max(1, page));
|
|
||||||
if (next === companyPagination.value.current) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
handleCompanyPageChange(next, companyPagination.value.pageSize);
|
|
||||||
}
|
|
||||||
|
|
||||||
onMounted(() => {
|
|
||||||
searchCompanies();
|
|
||||||
});
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<Page title="公司菜单管理" :auto-content-height="true">
|
<CompanyColPage
|
||||||
<template #description>
|
:selected-company-id="selectedCompanyId"
|
||||||
<div class="text-foreground/80 mt-2">
|
@select="onCompanySelect"
|
||||||
左侧选择公司,右侧勾选并保存该公司可访问的菜单。
|
>
|
||||||
</div>
|
<Card
|
||||||
|
class="ml-1 flex h-full min-h-0 min-w-0 flex-1 flex-col sm:ml-2"
|
||||||
|
:body-style="{
|
||||||
|
height: '100%',
|
||||||
|
minHeight: 0,
|
||||||
|
padding: 0,
|
||||||
|
display: 'flex',
|
||||||
|
flexDirection: 'column',
|
||||||
|
}"
|
||||||
|
>
|
||||||
|
<template #title>
|
||||||
|
<span class="text-base font-semibold">菜单分配</span>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<template #extra>
|
<template #extra>
|
||||||
<Space>
|
<Space wrap size="small">
|
||||||
|
<template v-if="currentCompany">
|
||||||
|
<Tag :color="currentCompany.status === 1 ? 'green' : 'red'">
|
||||||
|
{{ currentCompany.status === 1 ? '启用' : '禁用' }}
|
||||||
|
</Tag>
|
||||||
|
<span class="text-xs text-muted-foreground">
|
||||||
|
系统菜单 {{ stats.total }} · 已配置
|
||||||
|
<strong class="text-green-600">{{ stats.company }}</strong> · 当前
|
||||||
|
<strong class="text-blue-600">{{ stats.selected }}</strong>
|
||||||
|
<span v-if="stats.changed" class="text-orange-500">(未保存)</span>
|
||||||
|
</span>
|
||||||
|
</template>
|
||||||
<Button :disabled="!currentCompany" @click="selectNone">取消全选</Button>
|
<Button :disabled="!currentCompany" @click="selectNone">取消全选</Button>
|
||||||
<Button type="primary" :disabled="!currentCompany" @click="selectAll">
|
<Button type="primary" :disabled="!currentCompany" @click="selectAll">
|
||||||
一键全选
|
一键全选
|
||||||
@@ -263,160 +210,6 @@ onMounted(() => {
|
|||||||
</Space>
|
</Space>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<Flex gap="middle" class="h-full min-h-0 overflow-hidden">
|
|
||||||
<!-- 左:公司 -->
|
|
||||||
<Card
|
|
||||||
class="flex h-full w-[320px] shrink-0 flex-col overflow-hidden"
|
|
||||||
:body-style="{
|
|
||||||
height: '100%',
|
|
||||||
display: 'flex',
|
|
||||||
flexDirection: 'column',
|
|
||||||
gap: '8px',
|
|
||||||
minHeight: 0,
|
|
||||||
minWidth: 0,
|
|
||||||
overflow: 'hidden',
|
|
||||||
padding: '12px',
|
|
||||||
}"
|
|
||||||
>
|
|
||||||
<template #title>
|
|
||||||
<span class="flex items-center gap-2 text-base font-semibold">
|
|
||||||
<BuildingIcon class="h-4 w-4" />
|
|
||||||
公司
|
|
||||||
</span>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<div class="flex min-w-0 shrink-0 flex-col gap-2">
|
|
||||||
<Input
|
|
||||||
v-model:value="companySearchForm.name"
|
|
||||||
placeholder="公司名称"
|
|
||||||
allow-clear
|
|
||||||
class="w-full min-w-0"
|
|
||||||
@press-enter="searchCompanies"
|
|
||||||
/>
|
|
||||||
<div class="flex min-w-0 items-center gap-2">
|
|
||||||
<Select
|
|
||||||
v-model:value="companySearchForm.status"
|
|
||||||
placeholder="状态"
|
|
||||||
allow-clear
|
|
||||||
class="min-w-0 flex-1"
|
|
||||||
:options="[
|
|
||||||
{ label: '启用', value: 1 },
|
|
||||||
{ label: '禁用', value: 0 },
|
|
||||||
]"
|
|
||||||
/>
|
|
||||||
<Button type="primary" class="shrink-0" @click="searchCompanies">
|
|
||||||
搜索
|
|
||||||
</Button>
|
|
||||||
<Button class="shrink-0" @click="resetCompanySearch">重置</Button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden">
|
|
||||||
<div class="min-h-0 flex-1 overflow-y-auto">
|
|
||||||
<Spin :spinning="companyLoading">
|
|
||||||
<Empty
|
|
||||||
v-if="!companyLoading && companyList.length === 0"
|
|
||||||
class="py-8"
|
|
||||||
description="暂无公司"
|
|
||||||
/>
|
|
||||||
<template v-else>
|
|
||||||
<Card
|
|
||||||
v-for="company in companyList"
|
|
||||||
:key="company.id"
|
|
||||||
size="small"
|
|
||||||
:body-style="{ padding: '10px 12px' }"
|
|
||||||
class="mb-2 cursor-pointer !shadow-none last:mb-0 hover:border-primary"
|
|
||||||
:class="
|
|
||||||
currentCompany?.id === company.id
|
|
||||||
? 'border-primary bg-primary/5'
|
|
||||||
: undefined
|
|
||||||
"
|
|
||||||
@click="selectCompany(company)"
|
|
||||||
>
|
|
||||||
<div class="flex items-center justify-between gap-2">
|
|
||||||
<span class="min-w-0 truncate text-sm font-medium">
|
|
||||||
{{ company.name }}
|
|
||||||
</span>
|
|
||||||
<Tag
|
|
||||||
class="m-0 shrink-0"
|
|
||||||
:color="company.status === 1 ? 'green' : 'red'"
|
|
||||||
>
|
|
||||||
{{ company.status === 1 ? '启用' : '禁用' }}
|
|
||||||
</Tag>
|
|
||||||
</div>
|
|
||||||
</Card>
|
|
||||||
</template>
|
|
||||||
</Spin>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div
|
|
||||||
class="mt-2 flex w-full min-w-0 shrink-0 items-center justify-between gap-2"
|
|
||||||
>
|
|
||||||
<Button
|
|
||||||
size="small"
|
|
||||||
class="shrink-0"
|
|
||||||
:disabled="companyPagination.current <= 1 || companyLoading"
|
|
||||||
@click="goCompanyPage(companyPagination.current - 1)"
|
|
||||||
>
|
|
||||||
上一页
|
|
||||||
</Button>
|
|
||||||
<span
|
|
||||||
class="min-w-0 flex-1 truncate text-center text-xs text-muted-foreground"
|
|
||||||
>
|
|
||||||
{{ companyPagination.current }} / {{ companyTotalPages }}
|
|
||||||
<span class="ml-1 opacity-70"
|
|
||||||
>({{ companyPagination.total }})</span
|
|
||||||
>
|
|
||||||
</span>
|
|
||||||
<Button
|
|
||||||
size="small"
|
|
||||||
class="shrink-0"
|
|
||||||
:disabled="
|
|
||||||
companyPagination.current >= companyTotalPages || companyLoading
|
|
||||||
"
|
|
||||||
@click="goCompanyPage(companyPagination.current + 1)"
|
|
||||||
>
|
|
||||||
下一页
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</Card>
|
|
||||||
|
|
||||||
<!-- 右:菜单分配 -->
|
|
||||||
<Card
|
|
||||||
class="flex h-full min-h-0 min-w-0 flex-1 flex-col"
|
|
||||||
:body-style="{
|
|
||||||
height: '100%',
|
|
||||||
minHeight: 0,
|
|
||||||
padding: 0,
|
|
||||||
display: 'flex',
|
|
||||||
flexDirection: 'column',
|
|
||||||
}"
|
|
||||||
>
|
|
||||||
<template #title>
|
|
||||||
<span class="text-base font-semibold">菜单分配</span>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<div
|
|
||||||
class="shrink-0 border-t border-border px-4 py-2 text-xs text-muted-foreground"
|
|
||||||
>
|
|
||||||
当前:{{ selectedCompanyLabel }}
|
|
||||||
<template v-if="currentCompany">
|
|
||||||
<Tag
|
|
||||||
class="ml-2"
|
|
||||||
:color="currentCompany.status === 1 ? 'green' : 'red'"
|
|
||||||
>
|
|
||||||
{{ currentCompany.status === 1 ? '启用' : '禁用' }}
|
|
||||||
</Tag>
|
|
||||||
<span class="ml-3">
|
|
||||||
系统菜单 {{ stats.total }} · 已配置
|
|
||||||
<strong class="text-green-600">{{ stats.company }}</strong> · 当前选择
|
|
||||||
<strong class="text-blue-600">{{ stats.selected }}</strong>
|
|
||||||
<span v-if="stats.changed" class="text-orange-500">(有未保存更改)</span>
|
|
||||||
</span>
|
|
||||||
</template>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div
|
<div
|
||||||
v-if="!currentCompany"
|
v-if="!currentCompany"
|
||||||
class="flex min-h-0 flex-1 items-center justify-center"
|
class="flex min-h-0 flex-1 items-center justify-center"
|
||||||
@@ -451,6 +244,5 @@ onMounted(() => {
|
|||||||
</Spin>
|
</Spin>
|
||||||
</div>
|
</div>
|
||||||
</Card>
|
</Card>
|
||||||
</Flex>
|
</CompanyColPage>
|
||||||
</Page>
|
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -4,17 +4,11 @@ import type { PermissionVO } from '#/api/sys/permission/types';
|
|||||||
|
|
||||||
import { computed, onMounted, ref } from 'vue';
|
import { computed, onMounted, ref } from 'vue';
|
||||||
|
|
||||||
import { Page } from '@vben/common-ui';
|
|
||||||
import { createIconifyIcon } from '@vben/icons';
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
Button,
|
Button,
|
||||||
Card,
|
Card,
|
||||||
Empty,
|
Empty,
|
||||||
Flex,
|
|
||||||
Input,
|
|
||||||
message,
|
message,
|
||||||
Select,
|
|
||||||
Space,
|
Space,
|
||||||
Spin,
|
Spin,
|
||||||
Tag,
|
Tag,
|
||||||
@@ -25,13 +19,11 @@ import {
|
|||||||
batchUpdateCompanyPermissionsApi,
|
batchUpdateCompanyPermissionsApi,
|
||||||
getCompanyPermissionIdsApi,
|
getCompanyPermissionIdsApi,
|
||||||
} from '#/api/company/permission/apis';
|
} from '#/api/company/permission/apis';
|
||||||
import { getCompanyPageApi } from '#/api/company';
|
|
||||||
import { getPermissionTreeApi } from '#/api/sys/permission';
|
import { getPermissionTreeApi } from '#/api/sys/permission';
|
||||||
|
import CompanyColPage from '#/views/company/components/CompanyColPage.vue';
|
||||||
|
|
||||||
defineOptions({ name: 'CompanyPermissionManagePage' });
|
defineOptions({ name: 'CompanyPermissionManagePage' });
|
||||||
|
|
||||||
const BuildingIcon = createIconifyIcon('lucide:building-2');
|
|
||||||
|
|
||||||
type PermissionTreeNode = {
|
type PermissionTreeNode = {
|
||||||
key: number;
|
key: number;
|
||||||
title: string;
|
title: string;
|
||||||
@@ -40,15 +32,7 @@ type PermissionTreeNode = {
|
|||||||
children?: PermissionTreeNode[];
|
children?: PermissionTreeNode[];
|
||||||
};
|
};
|
||||||
|
|
||||||
const companySearchForm = ref({
|
const selectedCompanyId = ref<number | undefined>(undefined);
|
||||||
name: '',
|
|
||||||
status: undefined as number | undefined,
|
|
||||||
});
|
|
||||||
|
|
||||||
const companyList = ref<CompanyVO.CompanyInfoVO[]>([]);
|
|
||||||
const companyLoading = ref(false);
|
|
||||||
const companyPagination = ref({ current: 1, pageSize: 20, total: 0 });
|
|
||||||
|
|
||||||
const currentCompany = ref<CompanyVO.CompanyInfoVO | null>(null);
|
const currentCompany = ref<CompanyVO.CompanyInfoVO | null>(null);
|
||||||
|
|
||||||
const permissionTree = ref<PermissionVO.PermissionInfoVO[]>([]);
|
const permissionTree = ref<PermissionVO.PermissionInfoVO[]>([]);
|
||||||
@@ -57,13 +41,6 @@ const companyPermissionIds = ref<number[]>([]);
|
|||||||
const selectedPermissionIds = ref<number[]>([]);
|
const selectedPermissionIds = ref<number[]>([]);
|
||||||
const expandedKeys = ref<number[]>([]);
|
const expandedKeys = ref<number[]>([]);
|
||||||
|
|
||||||
const selectedCompanyLabel = computed(() => {
|
|
||||||
if (!currentCompany.value) {
|
|
||||||
return '请先选择公司';
|
|
||||||
}
|
|
||||||
return currentCompany.value.name;
|
|
||||||
});
|
|
||||||
|
|
||||||
const permissionTreeData = computed(() =>
|
const permissionTreeData = computed(() =>
|
||||||
mapPermissionToTreeData(permissionTree.value),
|
mapPermissionToTreeData(permissionTree.value),
|
||||||
);
|
);
|
||||||
@@ -118,29 +95,10 @@ function collectExpandableKeys(nodes: PermissionVO.PermissionInfoVO[]): number[]
|
|||||||
return keys;
|
return keys;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function searchCompanies() {
|
function onCompanySelect(company: CompanyVO.CompanyInfoVO) {
|
||||||
companyLoading.value = true;
|
|
||||||
try {
|
|
||||||
const result = await getCompanyPageApi({
|
|
||||||
page: companyPagination.value.current,
|
|
||||||
pageSize: companyPagination.value.pageSize,
|
|
||||||
filters: {
|
|
||||||
name: companySearchForm.value.name || undefined,
|
|
||||||
status: companySearchForm.value.status,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
companyList.value = result.records;
|
|
||||||
companyPagination.value.total = result.total;
|
|
||||||
} catch (error: any) {
|
|
||||||
message.error(error?.message || '获取公司列表失败');
|
|
||||||
} finally {
|
|
||||||
companyLoading.value = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function selectCompany(company: CompanyVO.CompanyInfoVO) {
|
|
||||||
currentCompany.value = company;
|
currentCompany.value = company;
|
||||||
await loadCompanyPermissions();
|
selectedCompanyId.value = company.id;
|
||||||
|
void loadCompanyPermissions();
|
||||||
}
|
}
|
||||||
|
|
||||||
async function loadCompanyPermissions() {
|
async function loadCompanyPermissions() {
|
||||||
@@ -191,31 +149,6 @@ async function handleSave() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function resetCompanySearch() {
|
|
||||||
companySearchForm.value = { name: '', status: undefined };
|
|
||||||
companyPagination.value.current = 1;
|
|
||||||
searchCompanies();
|
|
||||||
}
|
|
||||||
|
|
||||||
function handleCompanyPageChange(page: number, pageSize: number) {
|
|
||||||
companyPagination.value.current = page;
|
|
||||||
companyPagination.value.pageSize = pageSize;
|
|
||||||
searchCompanies();
|
|
||||||
}
|
|
||||||
|
|
||||||
const companyTotalPages = computed(() => {
|
|
||||||
const { total, pageSize } = companyPagination.value;
|
|
||||||
return Math.max(1, Math.ceil(total / pageSize) || 1);
|
|
||||||
});
|
|
||||||
|
|
||||||
function goCompanyPage(page: number) {
|
|
||||||
const next = Math.min(companyTotalPages.value, Math.max(1, page));
|
|
||||||
if (next === companyPagination.value.current) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
handleCompanyPageChange(next, companyPagination.value.pageSize);
|
|
||||||
}
|
|
||||||
|
|
||||||
function countLeafPermissions(nodes: PermissionVO.PermissionInfoVO[]): number {
|
function countLeafPermissions(nodes: PermissionVO.PermissionInfoVO[]): number {
|
||||||
let count = 0;
|
let count = 0;
|
||||||
for (const node of nodes) {
|
for (const node of nodes) {
|
||||||
@@ -246,21 +179,42 @@ function selectNone() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
searchCompanies();
|
void loadPermissionTree();
|
||||||
loadPermissionTree();
|
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<Page title="公司权限管理" :auto-content-height="true">
|
<CompanyColPage
|
||||||
<template #description>
|
:selected-company-id="selectedCompanyId"
|
||||||
<div class="text-foreground/80 mt-2">
|
@select="onCompanySelect"
|
||||||
左侧选择公司,右侧勾选并保存该公司可分配的权限。
|
>
|
||||||
</div>
|
<Card
|
||||||
|
class="ml-1 flex h-full min-h-0 min-w-0 flex-1 flex-col sm:ml-2"
|
||||||
|
:body-style="{
|
||||||
|
height: '100%',
|
||||||
|
minHeight: 0,
|
||||||
|
padding: 0,
|
||||||
|
display: 'flex',
|
||||||
|
flexDirection: 'column',
|
||||||
|
}"
|
||||||
|
>
|
||||||
|
<template #title>
|
||||||
|
<span class="text-base font-semibold">权限分配</span>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<template #extra>
|
<template #extra>
|
||||||
<Space>
|
<Space wrap size="small">
|
||||||
|
<template v-if="currentCompany">
|
||||||
|
<Tag :color="currentCompany.status === 1 ? 'green' : 'red'">
|
||||||
|
{{ currentCompany.status === 1 ? '启用' : '禁用' }}
|
||||||
|
</Tag>
|
||||||
|
<span class="text-xs text-muted-foreground">
|
||||||
|
叶子权限 {{ stats.total }} · 已配置
|
||||||
|
<strong class="text-green-600">{{ stats.company }}</strong> · 当前
|
||||||
|
<strong class="text-blue-600">{{ stats.selected }}</strong>
|
||||||
|
<span v-if="stats.changed" class="text-orange-500">(未保存)</span>
|
||||||
|
</span>
|
||||||
|
</template>
|
||||||
<Button :disabled="!currentCompany" @click="selectNone">取消全选</Button>
|
<Button :disabled="!currentCompany" @click="selectNone">取消全选</Button>
|
||||||
<Button type="primary" :disabled="!currentCompany" @click="selectAll">
|
<Button type="primary" :disabled="!currentCompany" @click="selectAll">
|
||||||
一键全选
|
一键全选
|
||||||
@@ -275,162 +229,6 @@ onMounted(() => {
|
|||||||
</Space>
|
</Space>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<Flex gap="middle" class="h-full min-h-0 overflow-hidden">
|
|
||||||
<!-- 左:公司 -->
|
|
||||||
<Card
|
|
||||||
class="flex h-full w-[320px] shrink-0 flex-col overflow-hidden"
|
|
||||||
:body-style="{
|
|
||||||
height: '100%',
|
|
||||||
display: 'flex',
|
|
||||||
flexDirection: 'column',
|
|
||||||
gap: '8px',
|
|
||||||
minHeight: 0,
|
|
||||||
minWidth: 0,
|
|
||||||
overflow: 'hidden',
|
|
||||||
padding: '12px',
|
|
||||||
}"
|
|
||||||
>
|
|
||||||
<template #title>
|
|
||||||
<span class="flex items-center gap-2 text-base font-semibold">
|
|
||||||
<BuildingIcon class="h-4 w-4" />
|
|
||||||
公司
|
|
||||||
</span>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<div class="flex min-w-0 shrink-0 flex-col gap-2">
|
|
||||||
<Input
|
|
||||||
v-model:value="companySearchForm.name"
|
|
||||||
placeholder="公司名称"
|
|
||||||
allow-clear
|
|
||||||
class="w-full min-w-0"
|
|
||||||
@press-enter="searchCompanies"
|
|
||||||
/>
|
|
||||||
<div class="flex min-w-0 items-center gap-2">
|
|
||||||
<Select
|
|
||||||
v-model:value="companySearchForm.status"
|
|
||||||
placeholder="状态"
|
|
||||||
allow-clear
|
|
||||||
class="min-w-0 flex-1"
|
|
||||||
:options="[
|
|
||||||
{ label: '启用', value: 1 },
|
|
||||||
{ label: '禁用', value: 0 },
|
|
||||||
]"
|
|
||||||
/>
|
|
||||||
<Button type="primary" class="shrink-0" @click="searchCompanies">
|
|
||||||
搜索
|
|
||||||
</Button>
|
|
||||||
<Button class="shrink-0" @click="resetCompanySearch">重置</Button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden">
|
|
||||||
<div class="min-h-0 flex-1 overflow-y-auto">
|
|
||||||
<Spin :spinning="companyLoading">
|
|
||||||
<Empty
|
|
||||||
v-if="!companyLoading && companyList.length === 0"
|
|
||||||
class="py-8"
|
|
||||||
description="暂无公司"
|
|
||||||
/>
|
|
||||||
<template v-else>
|
|
||||||
<Card
|
|
||||||
v-for="company in companyList"
|
|
||||||
:key="company.id"
|
|
||||||
size="small"
|
|
||||||
:body-style="{ padding: '10px 12px' }"
|
|
||||||
class="mb-2 cursor-pointer !shadow-none last:mb-0 hover:border-primary"
|
|
||||||
:class="
|
|
||||||
currentCompany?.id === company.id
|
|
||||||
? 'border-primary bg-primary/5'
|
|
||||||
: undefined
|
|
||||||
"
|
|
||||||
@click="selectCompany(company)"
|
|
||||||
>
|
|
||||||
<div class="flex items-center justify-between gap-2">
|
|
||||||
<span class="min-w-0 truncate text-sm font-medium">
|
|
||||||
{{ company.name }}
|
|
||||||
</span>
|
|
||||||
<Tag
|
|
||||||
class="m-0 shrink-0"
|
|
||||||
:color="company.status === 1 ? 'green' : 'red'"
|
|
||||||
>
|
|
||||||
{{ company.status === 1 ? '启用' : '禁用' }}
|
|
||||||
</Tag>
|
|
||||||
</div>
|
|
||||||
</Card>
|
|
||||||
</template>
|
|
||||||
</Spin>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div
|
|
||||||
class="mt-2 flex w-full min-w-0 shrink-0 items-center justify-between gap-2"
|
|
||||||
>
|
|
||||||
<Button
|
|
||||||
size="small"
|
|
||||||
class="shrink-0"
|
|
||||||
:disabled="companyPagination.current <= 1 || companyLoading"
|
|
||||||
@click="goCompanyPage(companyPagination.current - 1)"
|
|
||||||
>
|
|
||||||
上一页
|
|
||||||
</Button>
|
|
||||||
<span
|
|
||||||
class="min-w-0 flex-1 truncate text-center text-xs text-muted-foreground"
|
|
||||||
>
|
|
||||||
{{ companyPagination.current }} / {{ companyTotalPages }}
|
|
||||||
<span class="ml-1 opacity-70"
|
|
||||||
>({{ companyPagination.total }})</span
|
|
||||||
>
|
|
||||||
</span>
|
|
||||||
<Button
|
|
||||||
size="small"
|
|
||||||
class="shrink-0"
|
|
||||||
:disabled="
|
|
||||||
companyPagination.current >= companyTotalPages || companyLoading
|
|
||||||
"
|
|
||||||
@click="goCompanyPage(companyPagination.current + 1)"
|
|
||||||
>
|
|
||||||
下一页
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</Card>
|
|
||||||
|
|
||||||
<!-- 右:权限分配 -->
|
|
||||||
<Card
|
|
||||||
class="flex h-full min-h-0 min-w-0 flex-1 flex-col"
|
|
||||||
:body-style="{
|
|
||||||
height: '100%',
|
|
||||||
minHeight: 0,
|
|
||||||
padding: 0,
|
|
||||||
display: 'flex',
|
|
||||||
flexDirection: 'column',
|
|
||||||
}"
|
|
||||||
>
|
|
||||||
<template #title>
|
|
||||||
<span class="text-base font-semibold">权限分配</span>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<div
|
|
||||||
class="shrink-0 border-t border-border px-4 py-2 text-xs text-muted-foreground"
|
|
||||||
>
|
|
||||||
当前:{{ selectedCompanyLabel }}
|
|
||||||
<template v-if="currentCompany">
|
|
||||||
<Tag
|
|
||||||
class="ml-2"
|
|
||||||
:color="currentCompany.status === 1 ? 'green' : 'red'"
|
|
||||||
>
|
|
||||||
{{ currentCompany.status === 1 ? '启用' : '禁用' }}
|
|
||||||
</Tag>
|
|
||||||
<span class="ml-3">
|
|
||||||
全部叶子权限 {{ stats.total }} · 已配置
|
|
||||||
<strong class="text-green-600">{{ stats.company }}</strong> · 当前选择
|
|
||||||
<strong class="text-blue-600">{{ stats.selected }}</strong>
|
|
||||||
<span v-if="stats.changed" class="text-orange-500"
|
|
||||||
>(有未保存更改)</span
|
|
||||||
>
|
|
||||||
</span>
|
|
||||||
</template>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div
|
<div
|
||||||
v-if="!currentCompany"
|
v-if="!currentCompany"
|
||||||
class="flex min-h-0 flex-1 items-center justify-center"
|
class="flex min-h-0 flex-1 items-center justify-center"
|
||||||
@@ -477,6 +275,5 @@ onMounted(() => {
|
|||||||
</Spin>
|
</Spin>
|
||||||
</div>
|
</div>
|
||||||
</Card>
|
</Card>
|
||||||
</Flex>
|
</CompanyColPage>
|
||||||
</Page>
|
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -1,32 +1,25 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import type { VxeGridProps } from '#/adapter/vxe-table';
|
import type { VxeGridProps } from '#/adapter/vxe-table';
|
||||||
import type {
|
import type { AdFeeDTO, AdFeeVO } from '#/api/ec/ad-fee/types';
|
||||||
AdFeeDTO,
|
import type { ShopVO } from '#/api/ec/shop/types';
|
||||||
AdFeeVO,
|
|
||||||
} from '#/api/ec/ad-fee/types';
|
|
||||||
import type { PageQueryDTO } from '#/types/common';
|
import type { PageQueryDTO } from '#/types/common';
|
||||||
|
|
||||||
import { computed, ref, watch } from 'vue';
|
import { ref, watch } from 'vue';
|
||||||
|
|
||||||
import { Page } from '@vben/common-ui';
|
|
||||||
import { createIconifyIcon } from '@vben/icons';
|
import { createIconifyIcon } from '@vben/icons';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
Button,
|
Button,
|
||||||
Card,
|
Card,
|
||||||
DatePicker,
|
DatePicker,
|
||||||
Flex,
|
|
||||||
message,
|
message,
|
||||||
Popconfirm,
|
Popconfirm,
|
||||||
Space,
|
Space,
|
||||||
} from 'ant-design-vue';
|
} from 'ant-design-vue';
|
||||||
|
|
||||||
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||||
import {
|
import { deleteAdFeeApi, getAdFeePageApi } from '#/api/ec/ad-fee';
|
||||||
deleteAdFeeApi,
|
import EcShopColPage from '#/views/ec/components/EcShopColPage.vue';
|
||||||
getAdFeePageApi,
|
|
||||||
} from '#/api/ec/ad-fee';
|
|
||||||
import ShopSidebarList from '#/views/ec/components/ShopSidebarList.vue';
|
|
||||||
|
|
||||||
import AdFeeFormModal from './components/AdFeeFormModal.vue';
|
import AdFeeFormModal from './components/AdFeeFormModal.vue';
|
||||||
|
|
||||||
@@ -35,10 +28,7 @@ defineOptions({ name: 'AdFeeManagement' });
|
|||||||
const PlusIcon = createIconifyIcon('lucide:plus');
|
const PlusIcon = createIconifyIcon('lucide:plus');
|
||||||
|
|
||||||
const loading = ref(false);
|
const loading = ref(false);
|
||||||
|
|
||||||
/** 未选择具体店铺:undefined 表示全部店铺 */
|
|
||||||
const selectedShopId = ref<number | undefined>(undefined);
|
const selectedShopId = ref<number | undefined>(undefined);
|
||||||
const selectedShopName = ref<string | undefined>(undefined);
|
|
||||||
|
|
||||||
const formModalVisible = ref(false);
|
const formModalVisible = ref(false);
|
||||||
const currentAdFeeData = ref<null | AdFeeVO.Info>(null);
|
const currentAdFeeData = ref<null | AdFeeVO.Info>(null);
|
||||||
@@ -49,21 +39,8 @@ const searchForm = ref({
|
|||||||
feeDateEnd: undefined as string | undefined,
|
feeDateEnd: undefined as string | undefined,
|
||||||
});
|
});
|
||||||
|
|
||||||
const selectedShopLabel = computed(() => {
|
function onShopSelect(shop: ShopVO.Info | null) {
|
||||||
if (selectedShopId.value == null) {
|
selectedShopId.value = shop?.id;
|
||||||
return '全部店铺';
|
|
||||||
}
|
|
||||||
return selectedShopName.value || `店铺 #${selectedShopId.value}`;
|
|
||||||
});
|
|
||||||
|
|
||||||
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 handleAddForShop(shopId: number) {
|
function handleAddForShop(shopId: number) {
|
||||||
@@ -74,11 +51,7 @@ function handleAddForShop(shopId: number) {
|
|||||||
|
|
||||||
const gridOptions: VxeGridProps<AdFeeVO.Info> = {
|
const gridOptions: VxeGridProps<AdFeeVO.Info> = {
|
||||||
columns: [
|
columns: [
|
||||||
{
|
{ type: 'seq' as const, minWidth: 56, title: '序号' },
|
||||||
type: 'seq' as const,
|
|
||||||
minWidth: 56,
|
|
||||||
title: '序号',
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
field: 'shopName',
|
field: 'shopName',
|
||||||
title: '店铺',
|
title: '店铺',
|
||||||
@@ -103,11 +76,7 @@ const gridOptions: VxeGridProps<AdFeeVO.Info> = {
|
|||||||
minWidth: 110,
|
minWidth: 110,
|
||||||
slots: { default: 'feeAmount' },
|
slots: { default: 'feeAmount' },
|
||||||
},
|
},
|
||||||
{
|
{ field: 'feeDate', title: '发生日期', minWidth: 110 },
|
||||||
field: 'feeDate',
|
|
||||||
title: '发生日期',
|
|
||||||
minWidth: 110,
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
title: '操作',
|
title: '操作',
|
||||||
minWidth: 140,
|
minWidth: 140,
|
||||||
@@ -121,11 +90,7 @@ const gridOptions: VxeGridProps<AdFeeVO.Info> = {
|
|||||||
rowConfig: { isHover: true },
|
rowConfig: { isHover: true },
|
||||||
showOverflow: true,
|
showOverflow: true,
|
||||||
size: 'small',
|
size: 'small',
|
||||||
toolbarConfig: {
|
toolbarConfig: { custom: true, refresh: true, zoom: true },
|
||||||
custom: true,
|
|
||||||
refresh: true,
|
|
||||||
zoom: true,
|
|
||||||
},
|
|
||||||
data: [],
|
data: [],
|
||||||
pagerConfig: {
|
pagerConfig: {
|
||||||
enabled: true,
|
enabled: true,
|
||||||
@@ -184,7 +149,7 @@ function refreshTable() {
|
|||||||
const [Grid, gridApi] = useVbenVxeGrid({
|
const [Grid, gridApi] = useVbenVxeGrid({
|
||||||
gridOptions,
|
gridOptions,
|
||||||
showSearchForm: false,
|
showSearchForm: false,
|
||||||
tableTitle: '推广记录',
|
tableTitle: '',
|
||||||
});
|
});
|
||||||
|
|
||||||
watch(selectedShopId, () => {
|
watch(selectedShopId, () => {
|
||||||
@@ -195,17 +160,17 @@ function resetModalPreset() {
|
|||||||
presetShopIdForModal.value = null;
|
presetShopIdForModal.value = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleAdd = () => {
|
function handleAdd() {
|
||||||
currentAdFeeData.value = null;
|
currentAdFeeData.value = null;
|
||||||
resetModalPreset();
|
resetModalPreset();
|
||||||
formModalVisible.value = true;
|
formModalVisible.value = true;
|
||||||
};
|
}
|
||||||
|
|
||||||
const handleEdit = (record: AdFeeVO.Info) => {
|
function handleEdit(record: AdFeeVO.Info) {
|
||||||
resetModalPreset();
|
resetModalPreset();
|
||||||
currentAdFeeData.value = record;
|
currentAdFeeData.value = record;
|
||||||
formModalVisible.value = true;
|
formModalVisible.value = true;
|
||||||
};
|
}
|
||||||
|
|
||||||
async function handleDelete(id: number) {
|
async function handleDelete(id: number) {
|
||||||
try {
|
try {
|
||||||
@@ -217,45 +182,28 @@ async function handleDelete(id: number) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleFormSuccess = () => {
|
function handleFormSuccess() {
|
||||||
resetModalPreset();
|
resetModalPreset();
|
||||||
refreshTable();
|
refreshTable();
|
||||||
};
|
}
|
||||||
|
|
||||||
const handleFormCancel = () => {
|
function handleFormCancel() {
|
||||||
resetModalPreset();
|
resetModalPreset();
|
||||||
formModalVisible.value = false;
|
formModalVisible.value = false;
|
||||||
};
|
}
|
||||||
|
|
||||||
const formatAmount = (amount: number) => `¥${amount.toFixed(2)}`;
|
const formatAmount = (amount: number) => `¥${amount.toFixed(2)}`;
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<Page title="广告费管理" :auto-content-height="true">
|
<EcShopColPage
|
||||||
<template #description>
|
show-add-action
|
||||||
<div class="text-foreground/80 mt-2">
|
|
||||||
左侧选择店铺筛选右侧推广记录;未选店铺时展示全部记录。可在店铺行快捷新增该店铺广告费。
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<template #extra>
|
|
||||||
<Space>
|
|
||||||
<Button type="primary" @click="handleAdd">
|
|
||||||
<PlusIcon class="mr-2 h-4 w-4" />
|
|
||||||
新增广告费
|
|
||||||
</Button>
|
|
||||||
</Space>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<Flex gap="middle" class="h-full min-h-0 overflow-hidden">
|
|
||||||
<ShopSidebarList
|
|
||||||
:selected-shop-id="selectedShopId"
|
:selected-shop-id="selectedShopId"
|
||||||
@select="onShopSelect"
|
@select="onShopSelect"
|
||||||
@add-for-shop="handleAddForShop"
|
@add-for-shop="handleAddForShop"
|
||||||
/>
|
>
|
||||||
|
|
||||||
<Card
|
<Card
|
||||||
class="flex h-full min-h-0 min-w-0 flex-1 flex-col"
|
class="ml-1 flex h-full min-h-0 min-w-0 flex-1 flex-col sm:ml-2"
|
||||||
:body-style="{
|
:body-style="{
|
||||||
height: '100%',
|
height: '100%',
|
||||||
minHeight: 0,
|
minHeight: 0,
|
||||||
@@ -267,8 +215,9 @@ const formatAmount = (amount: number) => `¥${amount.toFixed(2)}`;
|
|||||||
<template #title>
|
<template #title>
|
||||||
<span class="text-base font-semibold">推广记录</span>
|
<span class="text-base font-semibold">推广记录</span>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<template #extra>
|
<template #extra>
|
||||||
<Space wrap size="small" class="max-w-[min(100%,42rem)]">
|
<Space wrap size="small" class="max-w-[min(100%,48rem)]">
|
||||||
<DatePicker
|
<DatePicker
|
||||||
v-model:value="searchForm.feeDateStart"
|
v-model:value="searchForm.feeDateStart"
|
||||||
value-format="YYYY-MM-DD"
|
value-format="YYYY-MM-DD"
|
||||||
@@ -286,25 +235,17 @@ const formatAmount = (amount: number) => `¥${amount.toFixed(2)}`;
|
|||||||
allow-clear
|
allow-clear
|
||||||
@change="() => refreshTable()"
|
@change="() => refreshTable()"
|
||||||
/>
|
/>
|
||||||
|
<Button type="primary" @click="handleAdd">
|
||||||
|
<PlusIcon class="mr-1 h-4 w-4" />
|
||||||
|
新增广告费
|
||||||
|
</Button>
|
||||||
</Space>
|
</Space>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<div
|
<div
|
||||||
class="shrink-0 border-t border-border px-4 py-2 text-xs text-muted-foreground"
|
class="min-h-0 flex-1 overflow-hidden px-2 pb-2 pt-2 sm:px-3 sm:pb-3"
|
||||||
>
|
|
||||||
当前:{{ selectedShopLabel }}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<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">
|
<Grid :loading="loading" class="h-full min-h-0">
|
||||||
<template #toolbar-tools>
|
|
||||||
<span class="text-xs text-muted-foreground">
|
|
||||||
使用上方日期筛选;表格在区域内滚动
|
|
||||||
</span>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<template #feeAmount="{ row }">
|
<template #feeAmount="{ row }">
|
||||||
<span class="font-semibold text-red-600">
|
<span class="font-semibold text-red-600">
|
||||||
{{ formatAmount(row.feeAmount) }}
|
{{ formatAmount(row.feeAmount) }}
|
||||||
@@ -337,7 +278,6 @@ const formatAmount = (amount: number) => `¥${amount.toFixed(2)}`;
|
|||||||
</Grid>
|
</Grid>
|
||||||
</div>
|
</div>
|
||||||
</Card>
|
</Card>
|
||||||
</Flex>
|
|
||||||
|
|
||||||
<AdFeeFormModal
|
<AdFeeFormModal
|
||||||
v-model:open="formModalVisible"
|
v-model:open="formModalVisible"
|
||||||
@@ -346,5 +286,5 @@ const formatAmount = (amount: number) => `¥${amount.toFixed(2)}`;
|
|||||||
@success="handleFormSuccess"
|
@success="handleFormSuccess"
|
||||||
@cancel="handleFormCancel"
|
@cancel="handleFormCancel"
|
||||||
/>
|
/>
|
||||||
</Page>
|
</EcShopColPage>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -2,18 +2,17 @@
|
|||||||
import type { VxeGridProps } from '#/adapter/vxe-table';
|
import type { VxeGridProps } from '#/adapter/vxe-table';
|
||||||
import type { BrushOrderDTO, BrushOrderVO } from '#/api/ec/brush-order';
|
import type { BrushOrderDTO, BrushOrderVO } from '#/api/ec/brush-order';
|
||||||
import type { ProductDTO, ProductVO } from '#/api/ec/product/types';
|
import type { ProductDTO, ProductVO } from '#/api/ec/product/types';
|
||||||
|
import type { ShopVO } from '#/api/ec/shop/types';
|
||||||
import type { PageQueryDTO } from '#/types/common';
|
import type { PageQueryDTO } from '#/types/common';
|
||||||
|
|
||||||
import { computed, ref, watch } from 'vue';
|
import { ref, watch } from 'vue';
|
||||||
|
|
||||||
import { Page } from '@vben/common-ui';
|
|
||||||
import { createIconifyIcon } from '@vben/icons';
|
import { createIconifyIcon } from '@vben/icons';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
Button,
|
Button,
|
||||||
Card,
|
Card,
|
||||||
DatePicker,
|
DatePicker,
|
||||||
Flex,
|
|
||||||
InputNumber,
|
InputNumber,
|
||||||
message,
|
message,
|
||||||
Popconfirm,
|
Popconfirm,
|
||||||
@@ -27,7 +26,7 @@ import {
|
|||||||
getBrushOrderPageApi,
|
getBrushOrderPageApi,
|
||||||
} from '#/api/ec/brush-order';
|
} from '#/api/ec/brush-order';
|
||||||
import { getProductPageApi } from '#/api/ec/product';
|
import { getProductPageApi } from '#/api/ec/product';
|
||||||
import ShopSidebarList from '#/views/ec/components/ShopSidebarList.vue';
|
import EcShopColPage from '#/views/ec/components/EcShopColPage.vue';
|
||||||
|
|
||||||
import BrushOrderFormModal from './components/BrushOrderFormModal.vue';
|
import BrushOrderFormModal from './components/BrushOrderFormModal.vue';
|
||||||
|
|
||||||
@@ -39,7 +38,6 @@ const loading = ref(false);
|
|||||||
|
|
||||||
/** 未选店铺:undefined 表示全部 */
|
/** 未选店铺:undefined 表示全部 */
|
||||||
const selectedShopId = ref<number | undefined>(undefined);
|
const selectedShopId = ref<number | undefined>(undefined);
|
||||||
const selectedShopName = ref<string | undefined>(undefined);
|
|
||||||
|
|
||||||
const formModalVisible = ref(false);
|
const formModalVisible = ref(false);
|
||||||
const currentBrushOrderData = ref<BrushOrderVO.Info | null>(null);
|
const currentBrushOrderData = ref<BrushOrderVO.Info | null>(null);
|
||||||
@@ -114,21 +112,8 @@ function handleProductPopupScroll(e: Event) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const selectedShopLabel = computed(() => {
|
function onShopSelect(shop: ShopVO.Info | null) {
|
||||||
if (selectedShopId.value == null) {
|
selectedShopId.value = shop?.id;
|
||||||
return '全部店铺';
|
|
||||||
}
|
|
||||||
return selectedShopName.value || `店铺 #${selectedShopId.value}`;
|
|
||||||
});
|
|
||||||
|
|
||||||
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 handleAddForShop(shopId: number) {
|
function handleAddForShop(shopId: number) {
|
||||||
@@ -254,7 +239,7 @@ function refreshTable() {
|
|||||||
const [Grid, gridApi] = useVbenVxeGrid({
|
const [Grid, gridApi] = useVbenVxeGrid({
|
||||||
gridOptions,
|
gridOptions,
|
||||||
showSearchForm: false,
|
showSearchForm: false,
|
||||||
tableTitle: '刷单记录',
|
tableTitle: '',
|
||||||
});
|
});
|
||||||
|
|
||||||
watch(selectedShopId, () => {
|
watch(selectedShopId, () => {
|
||||||
@@ -301,31 +286,14 @@ const formatAmount = (amount: number) => `¥${amount.toFixed(2)}`;
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<Page title="刷单记录管理" :auto-content-height="true">
|
<EcShopColPage
|
||||||
<template #description>
|
show-add-action
|
||||||
<div class="text-foreground/80 mt-2">
|
|
||||||
左侧选择店铺筛选右侧记录;未选店铺时展示全部。可在店铺行快捷新增该店铺刷单记录。
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<template #extra>
|
|
||||||
<Space>
|
|
||||||
<Button type="primary" @click="handleAdd">
|
|
||||||
<PlusIcon class="mr-2 h-4 w-4" />
|
|
||||||
新增刷单记录
|
|
||||||
</Button>
|
|
||||||
</Space>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<Flex gap="middle" class="h-full min-h-0 overflow-hidden">
|
|
||||||
<ShopSidebarList
|
|
||||||
:selected-shop-id="selectedShopId"
|
:selected-shop-id="selectedShopId"
|
||||||
@select="onShopSelect"
|
@select="onShopSelect"
|
||||||
@add-for-shop="handleAddForShop"
|
@add-for-shop="handleAddForShop"
|
||||||
/>
|
>
|
||||||
|
|
||||||
<Card
|
<Card
|
||||||
class="flex h-full min-h-0 min-w-0 flex-1 flex-col"
|
class="ml-1 flex h-full min-h-0 min-w-0 flex-1 flex-col sm:ml-2"
|
||||||
:body-style="{
|
:body-style="{
|
||||||
height: '100%',
|
height: '100%',
|
||||||
minHeight: 0,
|
minHeight: 0,
|
||||||
@@ -338,6 +306,13 @@ const formatAmount = (amount: number) => `¥${amount.toFixed(2)}`;
|
|||||||
<span class="text-base font-semibold">刷单记录</span>
|
<span class="text-base font-semibold">刷单记录</span>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
<template #extra>
|
||||||
|
<Button type="primary" @click="handleAdd">
|
||||||
|
<PlusIcon class="mr-1 h-4 w-4" />
|
||||||
|
新增刷单记录
|
||||||
|
</Button>
|
||||||
|
</template>
|
||||||
|
|
||||||
<div class="shrink-0 space-y-2 border-t border-border px-4 py-3">
|
<div class="shrink-0 space-y-2 border-t border-border px-4 py-3">
|
||||||
<div class="flex flex-wrap items-end gap-2">
|
<div class="flex flex-wrap items-end gap-2">
|
||||||
<div class="flex min-w-0 flex-col gap-0.5">
|
<div class="flex min-w-0 flex-col gap-0.5">
|
||||||
@@ -419,18 +394,10 @@ const formatAmount = (amount: number) => `¥${amount.toFixed(2)}`;
|
|||||||
查询
|
查询
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
<div class="text-xs text-muted-foreground">
|
|
||||||
当前:{{ selectedShopLabel }}
|
|
||||||
</div>
|
|
||||||
</div>
|
</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">
|
<Grid :loading="loading" class="h-full min-h-0">
|
||||||
<template #toolbar-tools>
|
|
||||||
<span class="text-xs text-muted-foreground">
|
|
||||||
修改筛选后点击「查询」或失焦/回车刷新;左侧切换店铺立即刷新
|
|
||||||
</span>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<template #productInfo="{ row }">
|
<template #productInfo="{ row }">
|
||||||
<div v-if="row.productName">
|
<div v-if="row.productName">
|
||||||
@@ -465,7 +432,6 @@ const formatAmount = (amount: number) => `¥${amount.toFixed(2)}`;
|
|||||||
</Grid>
|
</Grid>
|
||||||
</div>
|
</div>
|
||||||
</Card>
|
</Card>
|
||||||
</Flex>
|
|
||||||
|
|
||||||
<BrushOrderFormModal
|
<BrushOrderFormModal
|
||||||
v-model:open="formModalVisible"
|
v-model:open="formModalVisible"
|
||||||
@@ -474,5 +440,5 @@ const formatAmount = (amount: number) => `¥${amount.toFixed(2)}`;
|
|||||||
@success="handleFormSuccess"
|
@success="handleFormSuccess"
|
||||||
@cancel="handleFormCancel"
|
@cancel="handleFormCancel"
|
||||||
/>
|
/>
|
||||||
</Page>
|
</EcShopColPage>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -4,18 +4,17 @@ import type {
|
|||||||
ShopMonthlyTargetDTO,
|
ShopMonthlyTargetDTO,
|
||||||
ShopMonthlyTargetVO,
|
ShopMonthlyTargetVO,
|
||||||
} from '#/api/ec/shop/monthly-target';
|
} from '#/api/ec/shop/monthly-target';
|
||||||
|
import type { ShopVO } from '#/api/ec/shop/types';
|
||||||
import type { PageQueryDTO } from '#/types/common';
|
import type { PageQueryDTO } from '#/types/common';
|
||||||
|
|
||||||
import { computed, ref, watch } from 'vue';
|
import { ref, watch } from 'vue';
|
||||||
|
|
||||||
import { Page } from '@vben/common-ui';
|
|
||||||
import { createIconifyIcon } from '@vben/icons';
|
import { createIconifyIcon } from '@vben/icons';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
Button,
|
Button,
|
||||||
Card,
|
Card,
|
||||||
DatePicker,
|
DatePicker,
|
||||||
Flex,
|
|
||||||
message,
|
message,
|
||||||
Popconfirm,
|
Popconfirm,
|
||||||
Space,
|
Space,
|
||||||
@@ -26,7 +25,7 @@ import {
|
|||||||
deleteShopMonthlyTargetApi,
|
deleteShopMonthlyTargetApi,
|
||||||
getShopMonthlyTargetPageApi,
|
getShopMonthlyTargetPageApi,
|
||||||
} from '#/api/ec/shop/monthly-target';
|
} from '#/api/ec/shop/monthly-target';
|
||||||
import ShopSidebarList from '#/views/ec/components/ShopSidebarList.vue';
|
import EcShopColPage from '#/views/ec/components/EcShopColPage.vue';
|
||||||
|
|
||||||
import ShopMonthlyTargetFormModal from './components/ShopMonthlyTargetFormModal.vue';
|
import ShopMonthlyTargetFormModal from './components/ShopMonthlyTargetFormModal.vue';
|
||||||
|
|
||||||
@@ -35,10 +34,7 @@ defineOptions({ name: 'ShopMonthlyTargetManagement' });
|
|||||||
const PlusIcon = createIconifyIcon('lucide:plus');
|
const PlusIcon = createIconifyIcon('lucide:plus');
|
||||||
|
|
||||||
const loading = ref(false);
|
const loading = ref(false);
|
||||||
|
|
||||||
/** 未选择具体店铺:undefined 表示全部店铺 */
|
|
||||||
const selectedShopId = ref<number | undefined>(undefined);
|
const selectedShopId = ref<number | undefined>(undefined);
|
||||||
const selectedShopName = ref<string | undefined>(undefined);
|
|
||||||
|
|
||||||
const formModalVisible = ref(false);
|
const formModalVisible = ref(false);
|
||||||
const currentShopMonthlyTargetData = ref<null | ShopMonthlyTargetVO.Info>(null);
|
const currentShopMonthlyTargetData = ref<null | ShopMonthlyTargetVO.Info>(null);
|
||||||
@@ -49,21 +45,8 @@ const searchForm = ref({
|
|||||||
endTargetMonth: undefined as string | undefined,
|
endTargetMonth: undefined as string | undefined,
|
||||||
});
|
});
|
||||||
|
|
||||||
const selectedShopLabel = computed(() => {
|
function onShopSelect(shop: ShopVO.Info | null) {
|
||||||
if (selectedShopId.value == null) {
|
selectedShopId.value = shop?.id;
|
||||||
return '全部店铺';
|
|
||||||
}
|
|
||||||
return selectedShopName.value || `店铺 #${selectedShopId.value}`;
|
|
||||||
});
|
|
||||||
|
|
||||||
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 handleAddForShop(shopId: number) {
|
function handleAddForShop(shopId: number) {
|
||||||
@@ -74,43 +57,27 @@ function handleAddForShop(shopId: number) {
|
|||||||
|
|
||||||
const gridOptions: VxeGridProps<ShopMonthlyTargetVO.Info> = {
|
const gridOptions: VxeGridProps<ShopMonthlyTargetVO.Info> = {
|
||||||
columns: [
|
columns: [
|
||||||
{
|
{ type: 'seq' as const, minWidth: 56, title: '序号' },
|
||||||
type: 'seq' as const,
|
|
||||||
minWidth: 56,
|
|
||||||
title: '序号',
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
field: 'shopName',
|
field: 'shopName',
|
||||||
title: '店铺名称',
|
title: '店铺名称',
|
||||||
minWidth: 120,
|
minWidth: 120,
|
||||||
showOverflow: 'tooltip' as const,
|
showOverflow: 'tooltip' as const,
|
||||||
},
|
},
|
||||||
{
|
{ field: 'targetMonth', title: '目标月份', minWidth: 110 },
|
||||||
field: 'targetMonth',
|
|
||||||
title: '目标月份',
|
|
||||||
minWidth: 110,
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
title: '目标销售额',
|
title: '目标销售额',
|
||||||
minWidth: 120,
|
minWidth: 120,
|
||||||
slots: { default: 'targetAmount' },
|
slots: { default: 'targetAmount' },
|
||||||
},
|
},
|
||||||
{
|
{ field: 'targetOrderCount', title: '目标订单数', minWidth: 100 },
|
||||||
field: 'targetOrderCount',
|
|
||||||
title: '目标订单数',
|
|
||||||
minWidth: 100,
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
field: 'remark',
|
field: 'remark',
|
||||||
title: '备注',
|
title: '备注',
|
||||||
minWidth: 140,
|
minWidth: 140,
|
||||||
showOverflow: 'tooltip' as const,
|
showOverflow: 'tooltip' as const,
|
||||||
},
|
},
|
||||||
{
|
{ field: 'createTime', title: '创建时间', minWidth: 160 },
|
||||||
field: 'createTime',
|
|
||||||
title: '创建时间',
|
|
||||||
minWidth: 160,
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
title: '操作',
|
title: '操作',
|
||||||
minWidth: 140,
|
minWidth: 140,
|
||||||
@@ -124,11 +91,7 @@ const gridOptions: VxeGridProps<ShopMonthlyTargetVO.Info> = {
|
|||||||
rowConfig: { isHover: true },
|
rowConfig: { isHover: true },
|
||||||
showOverflow: true,
|
showOverflow: true,
|
||||||
size: 'small',
|
size: 'small',
|
||||||
toolbarConfig: {
|
toolbarConfig: { custom: true, refresh: true, zoom: true },
|
||||||
custom: true,
|
|
||||||
refresh: true,
|
|
||||||
zoom: true,
|
|
||||||
},
|
|
||||||
data: [],
|
data: [],
|
||||||
pagerConfig: {
|
pagerConfig: {
|
||||||
enabled: true,
|
enabled: true,
|
||||||
@@ -187,7 +150,7 @@ function refreshTable() {
|
|||||||
const [Grid, gridApi] = useVbenVxeGrid({
|
const [Grid, gridApi] = useVbenVxeGrid({
|
||||||
gridOptions,
|
gridOptions,
|
||||||
showSearchForm: false,
|
showSearchForm: false,
|
||||||
tableTitle: '月销量目标',
|
tableTitle: '',
|
||||||
});
|
});
|
||||||
|
|
||||||
watch(selectedShopId, () => {
|
watch(selectedShopId, () => {
|
||||||
@@ -198,17 +161,17 @@ function resetModalPreset() {
|
|||||||
presetShopIdForModal.value = null;
|
presetShopIdForModal.value = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleAdd = () => {
|
function handleAdd() {
|
||||||
currentShopMonthlyTargetData.value = null;
|
currentShopMonthlyTargetData.value = null;
|
||||||
resetModalPreset();
|
resetModalPreset();
|
||||||
formModalVisible.value = true;
|
formModalVisible.value = true;
|
||||||
};
|
}
|
||||||
|
|
||||||
const handleEdit = (record: ShopMonthlyTargetVO.Info) => {
|
function handleEdit(record: ShopMonthlyTargetVO.Info) {
|
||||||
resetModalPreset();
|
resetModalPreset();
|
||||||
currentShopMonthlyTargetData.value = record;
|
currentShopMonthlyTargetData.value = record;
|
||||||
formModalVisible.value = true;
|
formModalVisible.value = true;
|
||||||
};
|
}
|
||||||
|
|
||||||
async function handleDelete(id: number) {
|
async function handleDelete(id: number) {
|
||||||
try {
|
try {
|
||||||
@@ -220,45 +183,28 @@ async function handleDelete(id: number) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleFormSuccess = () => {
|
function handleFormSuccess() {
|
||||||
resetModalPreset();
|
resetModalPreset();
|
||||||
refreshTable();
|
refreshTable();
|
||||||
};
|
}
|
||||||
|
|
||||||
const handleFormCancel = () => {
|
function handleFormCancel() {
|
||||||
resetModalPreset();
|
resetModalPreset();
|
||||||
formModalVisible.value = false;
|
formModalVisible.value = false;
|
||||||
};
|
}
|
||||||
|
|
||||||
const formatAmount = (amount: number) => `¥${amount.toFixed(2)}`;
|
const formatAmount = (amount: number) => `¥${amount.toFixed(2)}`;
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<Page title="店铺月销量目标管理" :auto-content-height="true">
|
<EcShopColPage
|
||||||
<template #description>
|
show-add-action
|
||||||
<div class="text-foreground/80 mt-2">
|
|
||||||
左侧选择店铺筛选右侧月销量目标记录;未选店铺时展示全部记录。可在店铺行快捷新增该店铺月销量目标。
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<template #extra>
|
|
||||||
<Space>
|
|
||||||
<Button type="primary" @click="handleAdd">
|
|
||||||
<PlusIcon class="mr-2 h-4 w-4" />
|
|
||||||
新增月销量目标
|
|
||||||
</Button>
|
|
||||||
</Space>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<Flex gap="middle" class="h-full min-h-0 overflow-hidden">
|
|
||||||
<ShopSidebarList
|
|
||||||
:selected-shop-id="selectedShopId"
|
:selected-shop-id="selectedShopId"
|
||||||
@select="onShopSelect"
|
@select="onShopSelect"
|
||||||
@add-for-shop="handleAddForShop"
|
@add-for-shop="handleAddForShop"
|
||||||
/>
|
>
|
||||||
|
|
||||||
<Card
|
<Card
|
||||||
class="flex h-full min-h-0 min-w-0 flex-1 flex-col"
|
class="ml-1 flex h-full min-h-0 min-w-0 flex-1 flex-col sm:ml-2"
|
||||||
:body-style="{
|
:body-style="{
|
||||||
height: '100%',
|
height: '100%',
|
||||||
minHeight: 0,
|
minHeight: 0,
|
||||||
@@ -270,8 +216,9 @@ const formatAmount = (amount: number) => `¥${amount.toFixed(2)}`;
|
|||||||
<template #title>
|
<template #title>
|
||||||
<span class="text-base font-semibold">月销量目标</span>
|
<span class="text-base font-semibold">月销量目标</span>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<template #extra>
|
<template #extra>
|
||||||
<Space wrap size="small" class="max-w-[min(100%,42rem)]">
|
<Space wrap size="small" class="max-w-[min(100%,48rem)]">
|
||||||
<DatePicker
|
<DatePicker
|
||||||
v-model:value="searchForm.startTargetMonth"
|
v-model:value="searchForm.startTargetMonth"
|
||||||
picker="month"
|
picker="month"
|
||||||
@@ -291,23 +238,17 @@ const formatAmount = (amount: number) => `¥${amount.toFixed(2)}`;
|
|||||||
allow-clear
|
allow-clear
|
||||||
@change="() => refreshTable()"
|
@change="() => refreshTable()"
|
||||||
/>
|
/>
|
||||||
|
<Button type="primary" @click="handleAdd">
|
||||||
|
<PlusIcon class="mr-1 h-4 w-4" />
|
||||||
|
新增月销量目标
|
||||||
|
</Button>
|
||||||
</Space>
|
</Space>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<div
|
<div
|
||||||
class="shrink-0 border-t border-border px-4 py-2 text-xs text-muted-foreground"
|
class="min-h-0 flex-1 overflow-hidden px-2 pb-2 pt-2 sm:px-3 sm:pb-3"
|
||||||
>
|
>
|
||||||
当前:{{ selectedShopLabel }}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<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">
|
<Grid :loading="loading" class="h-full min-h-0">
|
||||||
<template #toolbar-tools>
|
|
||||||
<span class="text-xs text-muted-foreground">
|
|
||||||
使用上方月份筛选;表格在区域内滚动
|
|
||||||
</span>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<template #targetAmount="{ row }">
|
<template #targetAmount="{ row }">
|
||||||
<span class="font-semibold text-red-600">
|
<span class="font-semibold text-red-600">
|
||||||
{{ formatAmount(row.targetAmount) }}
|
{{ formatAmount(row.targetAmount) }}
|
||||||
@@ -328,7 +269,6 @@ const formatAmount = (amount: number) => `¥${amount.toFixed(2)}`;
|
|||||||
</Grid>
|
</Grid>
|
||||||
</div>
|
</div>
|
||||||
</Card>
|
</Card>
|
||||||
</Flex>
|
|
||||||
|
|
||||||
<ShopMonthlyTargetFormModal
|
<ShopMonthlyTargetFormModal
|
||||||
v-model:open="formModalVisible"
|
v-model:open="formModalVisible"
|
||||||
@@ -337,5 +277,5 @@ const formatAmount = (amount: number) => `¥${amount.toFixed(2)}`;
|
|||||||
@success="handleFormSuccess"
|
@success="handleFormSuccess"
|
||||||
@cancel="handleFormCancel"
|
@cancel="handleFormCancel"
|
||||||
/>
|
/>
|
||||||
</Page>
|
</EcShopColPage>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ import {
|
|||||||
} from '#/api/company';
|
} from '#/api/company';
|
||||||
import CompanyMenuDrawer from '#/components/CompanyMenuDrawer.vue';
|
import CompanyMenuDrawer from '#/components/CompanyMenuDrawer.vue';
|
||||||
import CompanyPermissionDrawer from '#/components/CompanyPermissionDrawer.vue';
|
import CompanyPermissionDrawer from '#/components/CompanyPermissionDrawer.vue';
|
||||||
|
import CompanyLogoAvatar from '#/views/company/components/CompanyLogoAvatar.vue';
|
||||||
|
|
||||||
import CompanyFormModal from './components/CompanyFormModal.vue';
|
import CompanyFormModal from './components/CompanyFormModal.vue';
|
||||||
|
|
||||||
@@ -53,6 +54,12 @@ const gridOptions: VxeGridProps<any> = {
|
|||||||
minWidth: 'auto',
|
minWidth: 'auto',
|
||||||
title: '序号',
|
title: '序号',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
title: 'Logo',
|
||||||
|
width: 72,
|
||||||
|
align: 'center' as const,
|
||||||
|
slots: { default: 'logo' },
|
||||||
|
},
|
||||||
{
|
{
|
||||||
field: 'name',
|
field: 'name',
|
||||||
title: '公司名称',
|
title: '公司名称',
|
||||||
@@ -81,11 +88,6 @@ const gridOptions: VxeGridProps<any> = {
|
|||||||
minWidth: 200,
|
minWidth: 200,
|
||||||
showOverflow: 'tooltip' as const,
|
showOverflow: 'tooltip' as const,
|
||||||
},
|
},
|
||||||
{
|
|
||||||
title: 'Logo',
|
|
||||||
minWidth: 100,
|
|
||||||
slots: { default: 'logo' },
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
title: '状态',
|
title: '状态',
|
||||||
minWidth: 100,
|
minWidth: 100,
|
||||||
@@ -341,20 +343,10 @@ gridReloadRef.value = () => gridApi.reload();
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<!-- Logo列 -->
|
<!-- Logo列 -->
|
||||||
<template #logo="{ row }: { row: any }">
|
<template #logo="{ row }: { row: CompanyVO.CompanyInfoVO }">
|
||||||
<div v-if="row.logo">
|
<div class="flex items-center justify-center">
|
||||||
<img
|
<CompanyLogoAvatar :logo="row.logo" :name="row.name" :size="40" />
|
||||||
:src="row.logo"
|
|
||||||
:alt="row.name"
|
|
||||||
style="
|
|
||||||
width: 40px;
|
|
||||||
height: 40px;
|
|
||||||
object-fit: cover;
|
|
||||||
border-radius: 4px;
|
|
||||||
"
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
<span v-else style="color: #999">暂无Logo</span>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<!-- 状态列 -->
|
<!-- 状态列 -->
|
||||||
|
|||||||
Reference in New Issue
Block a user