feat: 添加投标信息按日期范围更新功能及AI推荐持久化
添加按日期范围更新投标信息的功能,支持日期范围选择和数据更新 实现AI推荐结果的持久化存储和加载功能 优化日期范围选择器的本地存储功能
This commit is contained in:
@@ -56,6 +56,10 @@
|
||||
/>
|
||||
<el-button type="primary" @click="setLast3Days">3天</el-button>
|
||||
<el-button type="primary" @click="setLast7Days">7天</el-button>
|
||||
<el-button type="success" :loading="updating" @click="updateBidsByDateRange">
|
||||
<el-icon style="margin-right: 5px"><Refresh /></el-icon>
|
||||
更新
|
||||
</el-button>
|
||||
<el-select
|
||||
v-model="selectedKeywords"
|
||||
multiple
|
||||
@@ -107,14 +111,33 @@ const props = defineProps<Props>()
|
||||
const emit = defineEmits<{
|
||||
crawl: []
|
||||
refresh: []
|
||||
updateBids: [startDate: string, endDate?: string]
|
||||
}>()
|
||||
|
||||
const selectedKeywords = ref<string[]>([])
|
||||
const dateRange = ref<[string, string] | null>(null)
|
||||
const crawling = ref(false)
|
||||
const updating = ref(false)
|
||||
const highPriorityCollapsed = ref(false)
|
||||
const isInitialized = ref(false)
|
||||
|
||||
// 从 localStorage 加载保存的日期范围
|
||||
const loadSavedDateRange = () => {
|
||||
const saved = localStorage.getItem('dashboard_dateRange')
|
||||
if (saved) {
|
||||
try {
|
||||
dateRange.value = JSON.parse(saved)
|
||||
} catch (e) {
|
||||
console.error('Failed to parse saved date range:', e)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 监听日期范围变化并保存到 localStorage
|
||||
watch(dateRange, (newDateRange) => {
|
||||
localStorage.setItem('dashboard_dateRange', JSON.stringify(newDateRange))
|
||||
}, { deep: true })
|
||||
|
||||
// 切换 High Priority Bids 的折叠状态
|
||||
const toggleHighPriority = () => {
|
||||
highPriorityCollapsed.value = !highPriorityCollapsed.value
|
||||
@@ -274,6 +297,36 @@ const setLast7Days = () => {
|
||||
// 只在手动点击按钮时显示提示,初始化时不显示
|
||||
}
|
||||
|
||||
// 根据日期范围更新投标信息
|
||||
const updateBidsByDateRange = async () => {
|
||||
if (!dateRange.value || dateRange.value.length !== 2) {
|
||||
ElMessage.warning('请先选择日期范围')
|
||||
return
|
||||
}
|
||||
|
||||
updating.value = true
|
||||
try {
|
||||
const [startDate, endDate] = dateRange.value
|
||||
|
||||
// 检查 endDate 是否是今天
|
||||
const today = new Date()
|
||||
const todayStr = `${today.getFullYear()}-${String(today.getMonth() + 1).padStart(2, '0')}-${String(today.getDate()).padStart(2, '0')}`
|
||||
|
||||
// 如果 endDate 是今天,则不传递 endDate 参数(不限制截止时间)
|
||||
if (endDate === todayStr) {
|
||||
emit('updateBids', startDate)
|
||||
} else {
|
||||
emit('updateBids', startDate, endDate)
|
||||
}
|
||||
|
||||
ElMessage.success('更新成功')
|
||||
} catch (error) {
|
||||
ElMessage.error('更新失败')
|
||||
} finally {
|
||||
updating.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const handleCrawl = async () => {
|
||||
if (props.isCrawling) {
|
||||
ElMessage.warning('Crawl is already running')
|
||||
@@ -291,11 +344,14 @@ const handleCrawl = async () => {
|
||||
}
|
||||
}
|
||||
|
||||
// 初始化时加载保存的关键字
|
||||
// 初始化时加载保存的关键字和日期范围
|
||||
loadSavedKeywords()
|
||||
loadSavedDateRange()
|
||||
|
||||
// 初始化时设置默认日期范围为最近3天
|
||||
setLast3Days()
|
||||
// 如果没有保存的日期范围,则设置默认为最近3天
|
||||
if (!dateRange.value) {
|
||||
setLast3Days()
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
Reference in New Issue
Block a user