mirror of
https://gitee.com/qqtt-ah/ecom-dmb.git
synced 2026-11-25 03:49:19 +08:00
fix: 修复月度目标筛选及重置问题
- DateTimeConfig: 新增LocalDate反序列化器,支持yyyy-MM等多种格式 - monthly-target: 修复搜索表单重置后筛选条件不重置的问题
This commit is contained in:
@@ -7,7 +7,7 @@ import type {
|
||||
import type { ShopVO } from '#/api/ecommerce/shop/types';
|
||||
import type { PageQueryDTO } from '#/types/common';
|
||||
|
||||
import { computed, onMounted, ref } from 'vue';
|
||||
import { computed, ref } from 'vue';
|
||||
|
||||
import { Page } from '@vben/common-ui';
|
||||
import { createIconifyIcon } from '@vben/icons';
|
||||
@@ -40,8 +40,10 @@ const searchForm = ref({
|
||||
endTargetMonth: undefined as string | undefined,
|
||||
});
|
||||
|
||||
// 店铺选项
|
||||
// 店铺选项(懒加载)
|
||||
const shopOptions = ref<{ label: string; value: number }[]>([]);
|
||||
const shopLoading = ref(false);
|
||||
const shopFetched = ref(false);
|
||||
|
||||
// VbenVxeGrid 表格配置
|
||||
const gridOptions: VxeGridProps<any> = {
|
||||
@@ -171,7 +173,14 @@ const formOptions = computed(() => ({
|
||||
placeholder: '请选择店铺',
|
||||
options: shopOptions,
|
||||
allowClear: true,
|
||||
onChange: () => gridReloadRef.value?.(),
|
||||
showSearch: true,
|
||||
filterOption: false,
|
||||
loading: shopLoading,
|
||||
onFocus: fetchShopOptions,
|
||||
onChange: (val: any) => {
|
||||
searchForm.value.shopId = val;
|
||||
gridReloadRef.value?.();
|
||||
},
|
||||
},
|
||||
fieldName: 'shopId',
|
||||
label: '店铺',
|
||||
@@ -182,7 +191,10 @@ const formOptions = computed(() => ({
|
||||
placeholder: '开始月份',
|
||||
picker: 'month',
|
||||
style: { width: '100%' },
|
||||
onChange: () => gridReloadRef.value?.(),
|
||||
onChange: (val: any) => {
|
||||
searchForm.value.startTargetMonth = val ? val.format('YYYY-MM') : undefined;
|
||||
gridReloadRef.value?.();
|
||||
},
|
||||
},
|
||||
fieldName: 'startTargetMonth',
|
||||
label: '目标月份',
|
||||
@@ -193,7 +205,10 @@ const formOptions = computed(() => ({
|
||||
placeholder: '结束月份',
|
||||
picker: 'month',
|
||||
style: { width: '100%' },
|
||||
onChange: () => gridReloadRef.value?.(),
|
||||
onChange: (val: any) => {
|
||||
searchForm.value.endTargetMonth = val ? val.format('YYYY-MM') : undefined;
|
||||
gridReloadRef.value?.();
|
||||
},
|
||||
},
|
||||
fieldName: 'endTargetMonth',
|
||||
label: '至',
|
||||
@@ -211,12 +226,23 @@ function refreshTable() {
|
||||
}
|
||||
}
|
||||
|
||||
// 重置搜索表单
|
||||
function handleReset() {
|
||||
searchForm.value = {
|
||||
shopId: undefined,
|
||||
startTargetMonth: undefined,
|
||||
endTargetMonth: undefined,
|
||||
};
|
||||
gridReloadRef.value?.();
|
||||
}
|
||||
|
||||
// 创建 VbenVxeGrid 实例
|
||||
const [Grid, gridApi] = useVbenVxeGrid({
|
||||
gridOptions,
|
||||
formOptions: formOptions.value,
|
||||
showSearchForm: true,
|
||||
tableTitle: '店铺月销量目标管理',
|
||||
handleReset,
|
||||
});
|
||||
gridReloadRef.value = () => gridApi.reload();
|
||||
|
||||
@@ -253,8 +279,10 @@ const formatAmount = (amount: number) => {
|
||||
return `¥${amount.toFixed(2)}`;
|
||||
};
|
||||
|
||||
// 获取店铺选项
|
||||
const fetchShopOptions = async () => {
|
||||
// 获取店铺选项(首次触发时加载)
|
||||
async function fetchShopOptions() {
|
||||
if (shopFetched.value || shopLoading.value) return;
|
||||
shopLoading.value = true;
|
||||
try {
|
||||
const response = await getShopPageApi({
|
||||
page: 1,
|
||||
@@ -265,15 +293,15 @@ const fetchShopOptions = async () => {
|
||||
label: shop.name,
|
||||
value: shop.id,
|
||||
}));
|
||||
shopFetched.value = true;
|
||||
} catch (error) {
|
||||
console.error('获取店铺列表失败:', error);
|
||||
} finally {
|
||||
shopLoading.value = false;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// 初始化
|
||||
onMounted(() => {
|
||||
fetchShopOptions();
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
||||
Reference in New Issue
Block a user