feat: 月度模式全面参数化 - 移除硬编码日期,前后端按月动态查询

This commit is contained in:
freedakgmail
2026-08-01 13:10:22 +08:00
parent a90c133578
commit dab06ba109
43 changed files with 9135 additions and 309 deletions
+18 -13
View File
@@ -4,6 +4,7 @@ import { Badge } from '@/components/Badge'
import { LineChart, Line, XAxis, YAxis, CartesianGrid, Tooltip, ResponsiveContainer } from 'recharts'
import { formatCurrency, formatPercent, formatNumber } from '@/lib/utils'
import { LoadingSpinner } from '@/components/LoadingSpinner'
import { MonthPicker } from '@/components/MonthPicker'
import { useState } from 'react'
export function StorePage() {
@@ -11,6 +12,7 @@ export function StorePage() {
const [executeText, setExecuteText] = useState('')
const [activeTaskId, setActiveTaskId] = useState<number | null>(null)
const [storeCode, setStoreCode] = useState('1111')
const [month, setMonth] = useState('2026-05')
const { data: storesData, isLoading: storesLoading } = useQuery({
queryKey: ['stores-list'],
@@ -30,12 +32,12 @@ export function StorePage() {
const { data: tasksData, isLoading: tasksLoading } = useQuery({
queryKey: ['store', storeCode, 'tasks'],
queryFn: () => api.get('/tasks', { params: { store_code: storeCode, month: '2026-05', page_size: 50 } }),
queryFn: () => api.get('/tasks', { params: { store_code: storeCode, month, page_size: 50 } }),
})
const { data: dailyData, isLoading: dailyLoading } = useQuery({
queryKey: ['store', storeCode, 'daily'],
queryFn: () => api.get(`/stores/${storeCode}/daily`, { params: { month: '2026-04' } }),
queryFn: () => api.get(`/stores/${storeCode}/daily`, { params: { month } }),
})
const { data: followupData, isLoading: followupLoading } = useQuery({
@@ -45,12 +47,12 @@ export function StorePage() {
const { data: skuData } = useQuery({
queryKey: ['sku-attach', storeCode],
queryFn: () => api.get('/sku/attach'),
queryFn: () => api.get('/sku/attach', { params: { month } }),
})
const { data: abcData } = useQuery({
queryKey: ['sku-abc'],
queryFn: () => api.get('/sku/abc'),
queryFn: () => api.get('/sku/abc', { params: { month } }),
})
const card = (cardData as any)?.data
@@ -109,15 +111,18 @@ export function StorePage() {
<div className="space-y-4">
<div className="flex items-center justify-between">
<h1 className="text-xl font-bold"></h1>
<select
value={storeCode}
onChange={(e) => setStoreCode(e.target.value)}
className="rounded-md border px-3 py-1.5 text-sm"
>
{stores.map((s: any) => (
<option key={s.code} value={s.code}>{s.name}</option>
))}
</select>
<div className="flex items-center gap-3">
<MonthPicker month={month} onChange={setMonth} />
<select
value={storeCode}
onChange={(e) => setStoreCode(e.target.value)}
className="rounded-md border px-3 py-1.5 text-sm"
>
{stores.map((s: any) => (
<option key={s.code} value={s.code}>{s.name}</option>
))}
</select>
</div>
</div>
{/* 门店概况 */}