diff --git a/ecom-dmb-frontend/apps/web-antd/src/views/ecommerce/brush-order/components/BrushOrderFormModal.vue b/ecom-dmb-frontend/apps/web-antd/src/views/ecommerce/brush-order/components/BrushOrderFormModal.vue index 46356f28..e03f420f 100644 --- a/ecom-dmb-frontend/apps/web-antd/src/views/ecommerce/brush-order/components/BrushOrderFormModal.vue +++ b/ecom-dmb-frontend/apps/web-antd/src/views/ecommerce/brush-order/components/BrushOrderFormModal.vue @@ -35,23 +35,25 @@ import { getShopPageApi } from '#/api/ecommerce/shop'; defineOptions({ name: 'BrushOrderFormModal' }); -const props = defineProps(); - -const emit = defineEmits(); - -// Props interface Props { open: boolean; brushOrderData?: null | BrushOrderVO.Info; + /** 新增时预填店铺(编辑时忽略) */ + presetShopId?: number | null; } -// Emits interface Emits { (e: 'update:open', value: boolean): void; (e: 'success'): void; (e: 'cancel'): void; } +const props = withDefaults(defineProps(), { + presetShopId: null, +}); + +const emit = defineEmits(); + // 与父组件 v-model:open 同步:遮罩/右上角关闭时也要 emit false,否则父级一直为 true 无法二次打开 const [Modal, modalApi] = useVbenModal({ draggable: true, @@ -152,6 +154,9 @@ watch( }; } else { resetFormData(); + if (props.presetShopId != null && props.presetShopId !== undefined) { + formData.value.shopId = props.presetShopId; + } } await nextTick(); modalApi.open(); @@ -299,7 +304,6 @@ const resetFormData = () => { productSpecId: undefined, brushAmount: undefined as any, brushTime: dayjs().format('YYYY-MM-DD HH:mm:ss'), - quantity: 1, remark: undefined, }; diff --git a/ecom-dmb-frontend/apps/web-antd/src/views/ecommerce/brush-order/index.vue b/ecom-dmb-frontend/apps/web-antd/src/views/ecommerce/brush-order/index.vue index 51873fb2..8055f293 100644 --- a/ecom-dmb-frontend/apps/web-antd/src/views/ecommerce/brush-order/index.vue +++ b/ecom-dmb-frontend/apps/web-antd/src/views/ecommerce/brush-order/index.vue @@ -1,38 +1,56 @@ - - - - + +
+ + +
+
+ + +
+
+
+
+ - - - - +
+ + - - - + + + + + + +
+ + - diff --git a/ecom-dmb-frontend/apps/web-antd/src/views/ecommerce/promotion-fee/components/PromotionFeeFormModal.vue b/ecom-dmb-frontend/apps/web-antd/src/views/ecommerce/promotion-fee/components/PromotionFeeFormModal.vue index 98ce2d13..b303c41b 100644 --- a/ecom-dmb-frontend/apps/web-antd/src/views/ecommerce/promotion-fee/components/PromotionFeeFormModal.vue +++ b/ecom-dmb-frontend/apps/web-antd/src/views/ecommerce/promotion-fee/components/PromotionFeeFormModal.vue @@ -35,23 +35,25 @@ import { getShopPageApi } from '#/api/ecommerce/shop'; defineOptions({ name: 'PromotionFeeFormModal' }); -const props = defineProps(); - -const emit = defineEmits(); - -// Props interface Props { open: boolean; promotionFeeData?: null | PromotionFeeVO.Info; + /** 新增时预填店铺(编辑时忽略) */ + presetShopId?: number | null; } -// Emits +const props = withDefaults(defineProps(), { + presetShopId: null, +}); + interface Emits { (e: 'update:open', value: boolean): void; (e: 'success'): void; (e: 'cancel'): void; } +const emit = defineEmits(); + const [Modal, modalApi] = useVbenModal({ draggable: true, class: 'w-[800px]', @@ -159,6 +161,9 @@ watch( }; } else { resetFormData(); + if (props.presetShopId != null && props.presetShopId !== undefined) { + formData.value.shopId = props.presetShopId; + } } await nextTick(); modalApi.open(); diff --git a/ecom-dmb-frontend/apps/web-antd/src/views/ecommerce/promotion-fee/index.vue b/ecom-dmb-frontend/apps/web-antd/src/views/ecommerce/promotion-fee/index.vue index 1ace0279..10b0a978 100644 --- a/ecom-dmb-frontend/apps/web-antd/src/views/ecommerce/promotion-fee/index.vue +++ b/ecom-dmb-frontend/apps/web-antd/src/views/ecommerce/promotion-fee/index.vue @@ -4,14 +4,26 @@ import type { PromotionFeeDTO, PromotionFeeVO, } from '#/api/ecommerce/promotion-fee/types'; +import type { ShopVO } from '#/api/ecommerce/shop/types'; import type { PageQueryDTO } from '#/types/common'; -import { computed, ref } from 'vue'; +import { computed, onMounted, ref, watch } from 'vue'; import { Page } from '@vben/common-ui'; import { createIconifyIcon } from '@vben/icons'; -import { Button, message, Popconfirm, Space } from 'ant-design-vue'; +import { + Button, + Card, + DatePicker, + Empty, + Flex, + message, + Popconfirm, + Select, + Space, + Spin, +} from 'ant-design-vue'; import { useVbenVxeGrid } from '#/adapter/vxe-table'; import { @@ -26,34 +38,19 @@ import PromotionFeeFormModal from './components/PromotionFeeFormModal.vue'; defineOptions({ name: 'PromotionFeeManagement' }); const PlusIcon = createIconifyIcon('lucide:plus'); +const StoreIcon = createIconifyIcon('lucide:store'); const loading = ref(false); +const shopsLoading = ref(false); +const shops = ref([]); + +/** 未选择具体店铺:undefined 表示全部店铺 */ +const selectedShopId = ref(undefined); + const formModalVisible = ref(false); const currentPromotionFeeData = ref(null); +const presetShopIdForModal = ref(null); -// 店铺选择器(首次触发时加载) -const shopOptions = ref<{ label: string; value: number }[]>([]); -const shopLoading = ref(false); -const shopFetched = ref(false); - -async function fetchShopOptions() { - if (shopFetched.value || shopLoading.value) return; - shopLoading.value = true; - try { - const data = await getShopPageApi({ page: 1, pageSize: 100, filters: {} }); - shopOptions.value = (data.records || []).map((shop: any) => ({ - label: shop.name, - value: shop.id, - })); - shopFetched.value = true; - } catch (error) { - console.error('获取店铺列表失败:', error); - } finally { - shopLoading.value = false; - } -} - -// 推广费类型选择器(首次触发时加载) const feeTypeOptions = ref<{ label: string; value: number }[]>([]); const feeTypeLoading = ref(false); const feeTypeFetched = ref(false); @@ -63,38 +60,64 @@ async function fetchFeeTypeOptions() { feeTypeLoading.value = true; try { const data = await getAllPromotionFeeTypeListApi(); - feeTypeOptions.value = (data || []).map((type: any) => ({ + feeTypeOptions.value = (data || []).map((type: { id: number; typeName: string }) => ({ label: type.typeName, value: type.id, })); feeTypeFetched.value = true; - } catch (error) { - console.error('获取推广费类型列表失败:', error); + } catch { + message.error('获取推广费类型失败'); } finally { feeTypeLoading.value = false; } } -// 搜索表单 const searchForm = ref({ - shopId: undefined as number | undefined, feeTypeId: undefined as number | undefined, feeDateStart: undefined as string | undefined, feeDateEnd: undefined as string | undefined, }); -// VbenVxeGrid 表格配置 -const gridOptions: VxeGridProps = { +async function loadShops() { + shopsLoading.value = true; + try { + const data = await getShopPageApi({ page: 1, pageSize: 500, filters: {} }); + shops.value = data.records ?? []; + } catch { + message.error('获取店铺列表失败'); + shops.value = []; + } finally { + shopsLoading.value = false; + } +} + +const selectedShopLabel = computed(() => { + if (selectedShopId.value == null) { + return '全部店铺'; + } + const s = shops.value.find((x) => x.id === selectedShopId.value); + return s?.name ?? `店铺 #${selectedShopId.value}`; +}); + +function selectShopAll() { + selectedShopId.value = undefined; +} + +function selectShop(id: number) { + selectedShopId.value = id; +} + +const gridOptions: VxeGridProps = { columns: [ { type: 'seq' as const, - minWidth: 'auto', + minWidth: 56, title: '序号', }, { field: 'shopName', title: '店铺', - minWidth: 'auto', + minWidth: 120, showOverflow: 'tooltip' as const, }, { @@ -114,33 +137,33 @@ const gridOptions: VxeGridProps = { { field: 'feeTypeName', title: '推广费类型', - minWidth: 'auto', + minWidth: 110, showOverflow: 'tooltip' as const, }, { field: 'campaignName', title: '推广活动', - minWidth: 'auto', + minWidth: 120, showOverflow: 'tooltip' as const, }, { title: '推广费金额', - minWidth: 'auto', + minWidth: 110, slots: { default: 'feeAmount' }, }, { field: 'feeDate', title: '发生日期', - minWidth: 'auto', + minWidth: 110, }, { title: '操作', - minWidth: 'auto', + minWidth: 140, fixed: 'right' as const, slots: { default: 'action' }, }, ], - height: 'auto', + height: '100%', border: true, stripe: true, rowConfig: { isHover: true }, @@ -184,7 +207,7 @@ const gridOptions: VxeGridProps = { page: page.currentPage, pageSize: page.pageSize, filters: { - shopId: searchForm.value.shopId || undefined, + shopId: selectedShopId.value, feeTypeId: searchForm.value.feeTypeId || undefined, feeDateStart: searchForm.value.feeDateStart || undefined, feeDateEnd: searchForm.value.feeDateEnd || undefined, @@ -192,8 +215,7 @@ const gridOptions: VxeGridProps = { }; const data = await getPromotionFeePageApi(params); return { items: data.records, total: data.total }; - } catch (error) { - console.error('获取推广费记录列表失败:', error); + } catch { message.error('获取推广费记录列表失败'); return { items: [], total: 0 }; } finally { @@ -204,90 +226,44 @@ const gridOptions: VxeGridProps = { }, }; -// 搜索表单配置 -const gridReloadRef = ref<(() => void) | null>(null); -const formOptions = computed(() => ({ - schema: [ - { - component: 'Select', - componentProps: { - placeholder: '请选择店铺', - options: shopOptions, - allowClear: true, - showSearch: true, - filterOption: false, - loading: shopLoading, - onFocus: fetchShopOptions, - onChange: (val: any) => { - searchForm.value.shopId = val; - gridReloadRef.value?.(); - }, - }, - fieldName: 'shopId', - label: '店铺', - }, - { - component: 'Select', - componentProps: { - placeholder: '请选择推广费类型', - options: feeTypeOptions, - allowClear: true, - showSearch: true, - filterOption: false, - loading: feeTypeLoading, - onFocus: fetchFeeTypeOptions, - onChange: (val: any) => { - searchForm.value.feeTypeId = val; - gridReloadRef.value?.(); - }, - }, - fieldName: 'feeTypeId', - label: '推广费类型', - }, - { - component: 'DatePicker', - componentProps: { - placeholder: '开始日期', - style: { width: '100%' }, - onChange: () => gridReloadRef.value?.(), - }, - fieldName: 'feeDateStart', - label: '发生日期', - }, - { - component: 'DatePicker', - componentProps: { - placeholder: '结束日期', - style: { width: '100%' }, - onChange: () => gridReloadRef.value?.(), - }, - fieldName: 'feeDateEnd', - label: '至', - }, - ], - showDefaultActions: true, - collapsed: true, - collapsedRows: 1, -})); - function refreshTable() { gridApi?.reload(); } const [Grid, gridApi] = useVbenVxeGrid({ gridOptions, - formOptions: formOptions.value, - showSearchForm: true, - tableTitle: '推广费管理', + showSearchForm: false, + tableTitle: '推广记录', }); -gridReloadRef.value = () => gridApi.reload(); + +watch(selectedShopId, () => { + gridApi.reload(); +}); + +onMounted(() => { + void loadShops(); + void fetchFeeTypeOptions(); +}); + +function resetModalPreset() { + presetShopIdForModal.value = null; +} const handleAdd = () => { currentPromotionFeeData.value = null; + resetModalPreset(); formModalVisible.value = true; }; +function handleAddForShop(shopId: number) { + selectShop(shopId); + currentPromotionFeeData.value = null; + presetShopIdForModal.value = shopId; + formModalVisible.value = true; +} + const handleEdit = (record: PromotionFeeVO.Info) => { + resetModalPreset(); currentPromotionFeeData.value = record; formModalVisible.value = true; }; @@ -303,17 +279,36 @@ async function handleDelete(id: number) { } const handleFormSuccess = () => { + resetModalPreset(); refreshTable(); }; +const handleFormCancel = () => { + resetModalPreset(); + formModalVisible.value = false; +}; + const formatAmount = (amount: number) => `¥${amount.toFixed(2)}`; + +function shopRowClass(id: number | 'all') { + const active = + id === 'all' + ? selectedShopId.value === undefined + : selectedShopId.value === id; + return [ + 'flex cursor-pointer items-center gap-2 rounded-lg border px-3 py-2.5 text-sm font-semibold transition-colors', + active + ? 'border-primary bg-primary/8 text-primary' + : 'border-transparent bg-muted/30 text-foreground hover:bg-muted/60', + ].join(' '); +} - - + + - - + + + + + +
+ 当前:{{ selectedShopLabel }} +
+ +
+ + + + + + + + + + + +
+
+