From 533d7b60fbf2a655a2027b1ef573298e87917083 Mon Sep 17 00:00:00 2001 From: dmy Date: Mon, 12 Jan 2026 20:24:45 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E5=85=B3=E9=94=AE?= =?UTF-8?q?=E8=AF=8D=E7=AD=9B=E9=80=89=E5=8A=9F=E8=83=BD=E5=B9=B6=E4=BC=98?= =?UTF-8?q?=E5=8C=96=E6=97=A5=E6=9C=9F=E8=8C=83=E5=9B=B4=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在 updateBidsByDateRange 中添加关键词筛选参数 - 优化日期范围更新逻辑,避免重复提示 - 添加 build:watch 脚本用于开发环境 --- frontend/package.json | 1 + frontend/src/App.vue | 5 ++- frontend/src/components/Dashboard.vue | 65 ++++++++------------------- 3 files changed, 23 insertions(+), 48 deletions(-) diff --git a/frontend/package.json b/frontend/package.json index ad98159..a23afe8 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -6,6 +6,7 @@ "scripts": { "dev": "vite", "build": "vue-tsc -b && vite build", + "build:watch": "vue-tsc -b && vite build --watch", "preview": "vite preview" }, "dependencies": { diff --git a/frontend/src/App.vue b/frontend/src/App.vue index a78715f..d9ffc94 100644 --- a/frontend/src/App.vue +++ b/frontend/src/App.vue @@ -145,13 +145,16 @@ const fetchData = async () => { } // 根据日期范围更新投标信息 -const updateBidsByDateRange = async (startDate: string, endDate?: string) => { +const updateBidsByDateRange = async (startDate: string, endDate?: string, keywords?: string[]) => { loading.value = true try { const params: any = { startDate } if (endDate) { params.endDate = endDate } + if (keywords && keywords.length > 0) { + params.keywords = keywords.join(',') + } const response = await axios.get('/api/bids/by-date-range', { params }) todayBids.value = response.data diff --git a/frontend/src/components/Dashboard.vue b/frontend/src/components/Dashboard.vue index 7f38882..013f6db 100644 --- a/frontend/src/components/Dashboard.vue +++ b/frontend/src/components/Dashboard.vue @@ -111,7 +111,7 @@ const props = defineProps() const emit = defineEmits<{ crawl: [] refresh: [] - updateBids: [startDate: string, endDate?: string] + updateBids: [startDate: string, endDate?: string, keywords?: string[]] }>() const selectedKeywords = ref([]) @@ -120,6 +120,7 @@ const crawling = ref(false) const updating = ref(false) const highPriorityCollapsed = ref(false) const isInitialized = ref(false) +const isManualClick = ref(false) // 从 localStorage 加载保存的日期范围 const loadSavedDateRange = () => { @@ -175,6 +176,12 @@ watch(dateRange, () => { return } + // 手动点击时不显示提示(避免和按钮点击重复) + if (isManualClick.value) { + isManualClick.value = false + return + } + const totalBids = props.todayBids.length const filteredCount = filteredTodayBids.value.length @@ -217,18 +224,9 @@ const filteredTodayBids = computed(() => { return result }) -// 监听筛选结果变化并显示提示 -watch(filteredTodayBids, (newFilteredBids) => { - const totalBids = props.todayBids.length - const filteredCount = newFilteredBids.length - - if (totalBids > 0 && filteredCount < totalBids) { - ElMessage.info(`筛选结果:共 ${filteredCount} 条数据(总共 ${totalBids} 条)`) - } -}, { deep: true }) - // 设置日期范围为最近3天 -const setLast3Days = () => { +const setLast3Days = async () => { + isManualClick.value = true const endDate = new Date() const startDate = new Date() startDate.setDate(startDate.getDate() - 2) // 最近3天(包括今天) @@ -244,26 +242,13 @@ const setLast3Days = () => { console.log('setLast3Days called, todayBids:', props.todayBids.length, 'dateRange:', dateRange.value) - // 直接计算筛选结果并显示提示(只限制开始时间,不限制结束时间) - const start = new Date(startDate) - start.setHours(0, 0, 0, 0) - - let result = props.todayBids - result = result.filter(bid => { - if (!bid.publishDate) return false - const bidDate = new Date(bid.publishDate) - return bidDate >= start - }) - - const totalBids = props.todayBids.length - const filteredCount = result.length - - console.log('setLast3Days result, totalBids:', totalBids, 'filteredCount:', filteredCount) - // 只在手动点击按钮时显示提示,初始化时不显示 + // 调用更新函数 + await updateBidsByDateRange() } // 设置日期范围为最近7天 -const setLast7Days = () => { +const setLast7Days = async () => { + isManualClick.value = true const endDate = new Date() const startDate = new Date() startDate.setDate(startDate.getDate() - 6) // 最近7天(包括今天) @@ -279,22 +264,8 @@ const setLast7Days = () => { console.log('setLast7Days called, todayBids:', props.todayBids.length, 'dateRange:', dateRange.value) - // 直接计算筛选结果并显示提示(只限制开始时间,不限制结束时间) - const start = new Date(startDate) - start.setHours(0, 0, 0, 0) - - let result = props.todayBids - result = result.filter(bid => { - if (!bid.publishDate) return false - const bidDate = new Date(bid.publishDate) - return bidDate >= start - }) - - const totalBids = props.todayBids.length - const filteredCount = result.length - - console.log('setLast7Days result, totalBids:', totalBids, 'filteredCount:', filteredCount) - // 只在手动点击按钮时显示提示,初始化时不显示 + // 调用更新函数 + await updateBidsByDateRange() } // 根据日期范围更新投标信息 @@ -314,9 +285,9 @@ const updateBidsByDateRange = async () => { // 如果 endDate 是今天,则不传递 endDate 参数(不限制截止时间) if (endDate === todayStr) { - emit('updateBids', startDate) + emit('updateBids', startDate, undefined, selectedKeywords.value) } else { - emit('updateBids', startDate, endDate) + emit('updateBids', startDate, endDate, selectedKeywords.value) } ElMessage.success('更新成功')