Commit f402273d authored by 王蔡翾's avatar 王蔡翾
Browse files

兼容性补充

parent b14b9ba9
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
"lint": "eslint .", "lint": "eslint .",
"preview": "vite preview", "preview": "vite preview",
"test:prototype": "node --experimental-strip-types scripts/verify-prototype.mjs", "test:prototype": "node --experimental-strip-types scripts/verify-prototype.mjs",
"test:search": "node --experimental-strip-types scripts/verify-search.mjs",
"test:uuid": "node --experimental-strip-types scripts/verify-uuid.mjs" "test:uuid": "node --experimental-strip-types scripts/verify-uuid.mjs"
}, },
"dependencies": { "dependencies": {
......
import assert from 'node:assert/strict'
import { asSearchQuery, initialQuery, publicationRange } from '../src/lib/day2.ts'
const originalNow = Date.now
try {
// UTC 仍为前一天时,北京已到 11 月 3 日;快捷范围必须以北京日期为准,且包含当天。
Date.now = () => Date.parse('2026-11-02T16:15:00Z')
for (const [days, beginDate] of [[7, '2026-10-28'], [30, '2026-10-05'], [90, '2026-08-06'], [365, '2025-11-04']]) {
assert.deepEqual(publicationRange(days), { beginDate, endDate: '2026-11-03' })
}
// 复现用户条件及旧方案:地区/预算进入硬条件,关键词与日期不因模式转换丢失。
const legacy = {
...initialQuery(), ...publicationRange(30), keywords: ['智慧水务监测'],
preferredRegions: ['江苏'], budgetMinWan: 50, budgetMaxWan: 200,
}
const frozen = JSON.stringify(legacy)
const search = asSearchQuery(legacy)
assert.equal(search.mode, 'SEARCH')
assert.deepEqual(search.hardRegions, ['江苏'])
assert.equal(search.hardMinWan, 50)
assert.equal(search.hardMaxWan, 200)
assert.deepEqual(search.keywords, ['智慧水务监测'])
assert.equal(search.beginDate, '2026-10-05')
assert.equal(search.endDate, '2026-11-03')
assert.deepEqual(search.preferredRegions, [])
assert.equal(search.budgetMinWan, null)
assert.equal(search.budgetMaxWan, null)
assert.equal(JSON.stringify(legacy), frozen)
assert.deepEqual(asSearchQuery(search), search)
// 零金额、单边金额和其他业务模式须保留;清空条件后不能复用上次筛选。
const open = asSearchQuery({ ...legacy, preferredRegions: [], budgetMinWan: 0, budgetMaxWan: null })
assert.deepEqual(open.hardRegions, [])
assert.equal(open.hardMinWan, 0)
assert.equal(open.hardMaxWan, null)
const market = { ...initialQuery(), mode: 'MARKET', hardRegions: ['江苏'] }
assert.deepEqual(asSearchQuery(market), market)
Date.now = () => Date.parse('2026-11-02T15:59:00Z')
assert.deepEqual(publicationRange(30), { beginDate: '2026-10-04', endDate: '2026-11-02' })
Date.now = () => Date.parse('2024-02-29T04:00:00Z')
assert.deepEqual(publicationRange(7), { beginDate: '2024-02-23', endDate: '2024-02-29' })
} finally {
Date.now = originalNow
}
console.log('检索条件检查通过(地区/金额硬筛选、旧方案兼容、北京时间与发布时间范围)')
...@@ -56,6 +56,28 @@ export function beijingDate(offset = 0) { ...@@ -56,6 +56,28 @@ export function beijingDate(offset = 0) {
export function initialQuery(): SearchQuery { export function initialQuery(): SearchQuery {
return { keywords: [], beginDate: beijingDate(89), endDate: beijingDate(), stages: [1, 2, 4, 7, 8], preference: 'COMPREHENSIVE', preferredRegions: [], budgetMinWan: null, budgetMaxWan: null, mode: 'LEADS', keywordMode: 'ANY', hardRegions: [], hardMinWan: null, hardMaxWan: null } return { keywords: [], beginDate: beijingDate(89), endDate: beijingDate(), stages: [1, 2, 4, 7, 8], preference: 'COMPREHENSIVE', preferredRegions: [], budgetMinWan: null, budgetMaxWan: null, mode: 'LEADS', keywordMode: 'ANY', hardRegions: [], hardMinWan: null, hardMaxWan: null }
} }
/**
* 发现商机表单中的地区和预算是用户明确填写的筛选条件。
* 旧版页面误用了获客偏好字段;载入后转换为普通检索的硬条件,并原样保留日期和关键词逻辑。
* 返回新对象,避免编辑表单时改写已保存方案或历史任务;市场查询仍保留自身模式。
*/
export function asSearchQuery(query: SearchQuery): SearchQuery {
if (query.mode !== 'LEADS') return { ...query }
return {
...query, mode: 'SEARCH', preference: 'COMPREHENSIVE',
hardRegions: [...query.preferredRegions], hardMinWan: query.budgetMinWan, hardMaxWan: query.budgetMaxWan,
preferredRegions: [], budgetMinWan: null, budgetMaxWan: null,
}
}
/** 快捷范围包含今天;先固定北京时间的结束日期,避免午夜跨天造成起止日期相差一天。 */
export function publicationRange(days: number) {
const endDate = beijingDate()
const begin = new Date(`${endDate}T00:00:00Z`)
begin.setUTCDate(begin.getUTCDate() - days + 1)
return { beginDate: begin.toISOString().slice(0, 10), endDate }
}
export function words(value: string) { return value.split(/[、,,;;\n]+/).map(s => s.trim()).filter(Boolean) } export function words(value: string) { return value.split(/[、,,;;\n]+/).map(s => s.trim()).filter(Boolean) }
export function message(error: unknown) { return error instanceof Error ? error.message : '请求失败,请重试' } export function message(error: unknown) { return error instanceof Error ? error.message : '请求失败,请重试' }
export function time(value: string) { return new Date(value).toLocaleString('zh-CN', { timeZone: 'Asia/Shanghai', hour12: false }) } export function time(value: string) { return new Date(value).toLocaleString('zh-CN', { timeZone: 'Asia/Shanghai', hour12: false }) }
......
...@@ -7,7 +7,7 @@ import { useStore } from '../lib/store' ...@@ -7,7 +7,7 @@ import { useStore } from '../lib/store'
import { useTaskEvents } from '../hooks/useTaskEvents' import { useTaskEvents } from '../hooks/useTaskEvents'
import type { AgentTask } from '../hooks/useTaskEvents' import type { AgentTask } from '../hooks/useTaskEvents'
import type { SearchQuery, SearchReport, SearchHistory, SearchScheme } from '../lib/day2' import type { SearchQuery, SearchReport, SearchHistory, SearchScheme } from '../lib/day2'
import { initialQuery, beijingDate, registrationDate, inputClass, words, message, time } from '../lib/day2' import { initialQuery, asSearchQuery, publicationRange, beijingDate, registrationDate, inputClass, words, message, time } from '../lib/day2'
import { PrimaryButton, GhostButton } from '../components/ui-ext/AiButton' import { PrimaryButton, GhostButton } from '../components/ui-ext/AiButton'
import { BEE_IMG } from '../lib/assets' import { BEE_IMG } from '../lib/assets'
...@@ -19,11 +19,14 @@ import type { WatchItem } from '../lib/day2' ...@@ -19,11 +19,14 @@ import type { WatchItem } from '../lib/day2'
import { taskStates } from '../lib/day3' import { taskStates } from '../lib/day3'
import { RESULT_STATUSES } from '../types' import { RESULT_STATUSES } from '../types'
// 后端最多允许一年范围,选项文案必须与实际发送的日期一致,不能把近 365 天称为全部时间。
const publicationDays = ['7', '30', '90', '365']
/** D2 页面只读服务端事实和匹配度;切换历史 Tab 不执行供应商请求。 */ /** D2 页面只读服务端事实和匹配度;切换历史 Tab 不执行供应商请求。 */
export function DiscoverPage({ onOpenPanel }: { onOpenPanel: (state: AnalysisPanelState) => void }) { export function DiscoverPage({ onOpenPanel }: { onOpenPanel: (state: AnalysisPanelState) => void }) {
const { profile, watch } = useStore() const { profile, watch } = useStore()
const [params, setParams] = useSearchParams() const [params, setParams] = useSearchParams()
const [query, setQuery] = useState<SearchQuery>(() => ({ ...initialQuery(), beginDate: beijingDate(29) })) const [query, setQuery] = useState<SearchQuery>(() => ({ ...asSearchQuery(initialQuery()), ...publicationRange(30) }))
const [keyword, setKeyword] = useState('') const [keyword, setKeyword] = useState('')
const [range, setRange] = useState('30') const [range, setRange] = useState('30')
const [regionText, setRegionText] = useState('') const [regionText, setRegionText] = useState('')
...@@ -57,6 +60,11 @@ export function DiscoverPage({ onOpenPanel }: { onOpenPanel: (state: AnalysisPan ...@@ -57,6 +60,11 @@ export function DiscoverPage({ onOpenPanel }: { onOpenPanel: (state: AnalysisPan
}, []) }, [])
useEffect(() => { void reload().catch(e => setError(message(e))) }, [reload]) useEffect(() => { void reload().catch(e => setError(message(e))) }, [reload])
const update = <K extends keyof SearchQuery>(key: K, value: SearchQuery[K]) => setQuery(current => ({ ...current, [key]: value })) const update = <K extends keyof SearchQuery>(key: K, value: SearchQuery[K]) => setQuery(current => ({ ...current, [key]: value }))
// 主表单与方案编辑共用日期赋值,确保选择的区间进入提交和保存的 conditions 快照。
const updateRange = (value: string) => {
setRange(value)
if (value !== 'custom') setQuery(current => ({ ...current, ...publicationRange(Number(value)) }))
}
const runAction = async (action: () => Promise<void>) => { const runAction = async (action: () => Promise<void>) => {
if (busy) return if (busy) return
setBusy(true); setError('') setBusy(true); setError('')
...@@ -104,7 +112,7 @@ export function DiscoverPage({ onOpenPanel }: { onOpenPanel: (state: AnalysisPan ...@@ -104,7 +112,7 @@ export function DiscoverPage({ onOpenPanel }: { onOpenPanel: (state: AnalysisPan
const schemeRuns = history.filter((run, index) => run.schemeId && history.findIndex(other => other.schemeId === run.schemeId) === index) const schemeRuns = history.filter((run, index) => run.schemeId && history.findIndex(other => other.schemeId === run.schemeId) === index)
const manualRun = history.find(run => !run.schemeId) const manualRun = history.find(run => !run.schemeId)
const conditions = report?.conditions const conditions = report?.conditions
const conditionLabel = conditions ? [conditions.keywords.length ? `关键词「${conditions.keywords.join(' ')}」` : '', (conditions.mode === 'LEADS' ? conditions.preferredRegions : conditions.hardRegions).length ? `地区「${(conditions.mode === 'LEADS' ? conditions.preferredRegions : conditions.hardRegions).join('、')}」` : '', `发布于${Math.round((Date.parse(conditions.endDate) - Date.parse(conditions.beginDate)) / 86400000) + 1}天内`].filter(Boolean).join(' · ') : '' const conditionLabel = conditions ? [conditions.keywords.length ? `关键词「${conditions.keywords.join(' ')}」` : '', (conditions.mode === 'LEADS' ? conditions.preferredRegions : conditions.hardRegions).length ? `地区「${(conditions.mode === 'LEADS' ? conditions.preferredRegions : conditions.hardRegions).join('、')}」` : '', `发布时间 ${conditions.beginDate} 至 ${conditions.endDate}`].filter(Boolean).join(' · ') : ''
return <div className="mx-auto max-w-[1120px] px-4 py-4 sm:px-5 sm:py-5 xl:px-6"> return <div className="mx-auto max-w-[1120px] px-4 py-4 sm:px-5 sm:py-5 xl:px-6">
{profile.completed ? <div className="relative overflow-hidden rounded-card p-6 shadow-card fade-up" style={{ background: 'linear-gradient(115deg, #1D19DC 0%, #2E54E8 52%, #3F8BF0 100%)' }}> {profile.completed ? <div className="relative overflow-hidden rounded-card p-6 shadow-card fade-up" style={{ background: 'linear-gradient(115deg, #1D19DC 0%, #2E54E8 52%, #3F8BF0 100%)' }}>
<div className="pointer-events-none absolute -top-24 right-40 h-52 w-52 rounded-full border border-white/15" /><div className="pointer-events-none absolute -top-12 right-52 h-28 w-28 rounded-full border border-white/10" /><div className="pointer-events-none absolute -bottom-16 right-72 h-32 w-32 rounded-full bg-white/5" /> <div className="pointer-events-none absolute -top-24 right-40 h-52 w-52 rounded-full border border-white/15" /><div className="pointer-events-none absolute -top-12 right-52 h-28 w-28 rounded-full border border-white/10" /><div className="pointer-events-none absolute -bottom-16 right-72 h-32 w-32 rounded-full bg-white/5" />
...@@ -118,7 +126,7 @@ export function DiscoverPage({ onOpenPanel }: { onOpenPanel: (state: AnalysisPan ...@@ -118,7 +126,7 @@ export function DiscoverPage({ onOpenPanel }: { onOpenPanel: (state: AnalysisPan
<input aria-label="关键词" value={keyword} onChange={e => setKeyword(e.target.value)} placeholder="关键词(空格分隔多个,如:智慧水务 监测)" className={`${inputClass} col-span-12 lg:col-span-4`} /> <input aria-label="关键词" value={keyword} onChange={e => setKeyword(e.target.value)} placeholder="关键词(空格分隔多个,如:智慧水务 监测)" className={`${inputClass} col-span-12 lg:col-span-4`} />
<input aria-label="地区" value={regionText} onChange={e => { setRegionText(e.target.value); update(query.mode === 'LEADS' ? 'preferredRegions' : 'hardRegions', words(e.target.value)) }} placeholder="地区(如:浙江)" className={`${inputClass} col-span-6 lg:col-span-2`} /> <input aria-label="地区" value={regionText} onChange={e => { setRegionText(e.target.value); update(query.mode === 'LEADS' ? 'preferredRegions' : 'hardRegions', words(e.target.value)) }} placeholder="地区(如:浙江)" className={`${inputClass} col-span-6 lg:col-span-2`} />
<div className="col-span-6 flex items-center gap-1.5 lg:col-span-3">{(['Min', 'Max'] as const).map((bound, i) => { const key = (query.mode === 'LEADS' ? `budget${bound}Wan` : `hard${bound}Wan`) as 'budgetMinWan' | 'budgetMaxWan' | 'hardMinWan' | 'hardMaxWan'; return <div key={bound} className="flex min-w-0 items-center gap-1.5">{i > 0 && <span className="text-ink-400">~</span>}<input aria-label={i ? '预算上限' : '预算下限'} type="number" min={0} step="any" value={query[key] ?? ''} onChange={e => update(key, e.target.value === '' ? null : Number(e.target.value))} placeholder={i ? '上限(万元)' : '预算下限'} className={`${inputClass} min-w-0 font-num`} /></div> })}</div> <div className="col-span-6 flex items-center gap-1.5 lg:col-span-3">{(['Min', 'Max'] as const).map((bound, i) => { const key = (query.mode === 'LEADS' ? `budget${bound}Wan` : `hard${bound}Wan`) as 'budgetMinWan' | 'budgetMaxWan' | 'hardMinWan' | 'hardMaxWan'; return <div key={bound} className="flex min-w-0 items-center gap-1.5">{i > 0 && <span className="text-ink-400">~</span>}<input aria-label={i ? '预算上限' : '预算下限'} type="number" min={0} step="any" value={query[key] ?? ''} onChange={e => update(key, e.target.value === '' ? null : Number(e.target.value))} placeholder={i ? '上限(万元)' : '预算下限'} className={`${inputClass} min-w-0 font-num`} /></div> })}</div>
<select aria-label="发布时间" value={range} onChange={e => { setRange(e.target.value); if (e.target.value !== 'custom') setQuery(q => ({ ...q, beginDate: beijingDate(Number(e.target.value) - 1), endDate: beijingDate() })) }} className={`${inputClass} col-span-9 lg:col-span-2`}>{[['7','发布于近 7 天'], ['30','发布于近 30 天'], ['90','发布于近 90 天'], ['365','全部时间']].map(([v,n]) => <option key={v} value={v}>{n}</option>)}</select> <select aria-label="发布时间" value={range} onChange={e => updateRange(e.target.value)} className={`${inputClass} col-span-9 lg:col-span-2`}>{publicationDays.map(days => <option key={days} value={days}>发布于近 {days} 天</option>)}{range === 'custom' && <option value="custom">{query.beginDate} 至 {query.endDate}</option>}</select>
<PrimaryButton type="submit" disabled={busy} className="col-span-3 !px-2 lg:col-span-1"><Search size={15} /> 检索</PrimaryButton> <PrimaryButton type="submit" disabled={busy} className="col-span-3 !px-2 lg:col-span-1"><Search size={15} /> 检索</PrimaryButton>
</div> </div>
</form> </form>
...@@ -131,8 +139,8 @@ export function DiscoverPage({ onOpenPanel }: { onOpenPanel: (state: AnalysisPan ...@@ -131,8 +139,8 @@ export function DiscoverPage({ onOpenPanel }: { onOpenPanel: (state: AnalysisPan
{!schemes.length ? <p className="px-0 py-10 text-center text-[13px] text-ink-400">还没有检索方案,点右上角「新建方案」,把常用的检索条件存下来一键复用</p> : <ul className="-mx-5 mt-4 divide-y divide-line-soft/70">{schemes.map(scheme => <li key={scheme.id} className="flex items-center gap-3 px-5 py-2.5"> {!schemes.length ? <p className="px-0 py-10 text-center text-[13px] text-ink-400">还没有检索方案,点右上角「新建方案」,把常用的检索条件存下来一键复用</p> : <ul className="-mx-5 mt-4 divide-y divide-line-soft/70">{schemes.map(scheme => <li key={scheme.id} className="flex items-center gap-3 px-5 py-2.5">
<span className="shrink-0 text-[13px] font-medium text-ink-900">{scheme.name}</span><span className="min-w-0 flex-1 truncate text-xs text-ink-400">{scheme.conditions.keywords.join(' ')} · {scheme.conditions.mode === 'LEADS' ? scheme.conditions.preferredRegions.join('、') : scheme.conditions.hardRegions.join('、')}</span> <span className="shrink-0 text-[13px] font-medium text-ink-900">{scheme.name}</span><span className="min-w-0 flex-1 truncate text-xs text-ink-400">{scheme.conditions.keywords.join(' ')} · {scheme.conditions.mode === 'LEADS' ? scheme.conditions.preferredRegions.join('、') : scheme.conditions.hardRegions.join('、')}</span>
<span className="shrink-0 whitespace-nowrap text-xs text-ink-400">{history.find(run => run.schemeId === scheme.id) ? `最近执行 ${time(history.find(run => run.schemeId === scheme.id)!.createdAt)}` : '尚未执行'}</span> <span className="shrink-0 whitespace-nowrap text-xs text-ink-400">{history.find(run => run.schemeId === scheme.id) ? `最近执行 ${time(history.find(run => run.schemeId === scheme.id)!.createdAt)}` : '尚未执行'}</span>
<button aria-label={`执行${scheme.name}`} disabled={busy} title="按这组条件立即执行一次" className="shrink-0 rounded-full p-1.5 text-brand-500 hover:bg-brand-50" onClick={() => void runAction(async () => { const next = await api<AgentTask>(`/search-schemes/${scheme.id}/runs`, { method: 'POST', headers: { 'Idempotency-Key': keyFor({ scheme: scheme.id }) } }); pending.current = null; choose(next.id); setRevision(v => v + 1); await reload(); setShowSchemes(false) })}><Play size={14} /></button> <button aria-label={`执行${scheme.name}`} disabled={busy} title="按这组条件立即执行一次" className="shrink-0 rounded-full p-1.5 text-brand-500 hover:bg-brand-50" onClick={() => void runAction(async () => { const next = await api<AgentTask>(`/search-schemes/${scheme.id}/runs?strictFilters=true`, { method: 'POST', headers: { 'Idempotency-Key': keyFor({ scheme: scheme.id, strictFilters: true }) } }); pending.current = null; choose(next.id); setRevision(v => v + 1); await reload(); setShowSchemes(false) })}><Play size={14} /></button>
<button aria-label={`编辑${scheme.name}`} title="编辑" className="shrink-0 rounded-full p-1.5 text-ink-400 hover:bg-canvas hover:text-brand-500" onClick={() => { setQuery(scheme.conditions); setRegionText((scheme.conditions.mode === 'LEADS' ? scheme.conditions.preferredRegions : scheme.conditions.hardRegions).join(',')); setKeyword(scheme.conditions.keywords.join(' ')); const days = Math.round((Date.parse(scheme.conditions.endDate) - Date.parse(scheme.conditions.beginDate)) / 86400000) + 1; setRange(['7', '30', '90'].includes(String(days)) ? String(days) : '365'); setSchemeName(scheme.name); setEditing(scheme); setShowSchemeForm(true) }}><Pencil size={14} /></button> <button aria-label={`编辑${scheme.name}`} title="编辑" className="shrink-0 rounded-full p-1.5 text-ink-400 hover:bg-canvas hover:text-brand-500" onClick={() => { const next = asSearchQuery(scheme.conditions); setQuery(next); setRegionText(next.hardRegions.join(',')); setKeyword(next.keywords.join(' ')); const days = String(Math.round((Date.parse(next.endDate) - Date.parse(next.beginDate)) / 86400000) + 1); setRange(publicationDays.includes(days) && next.endDate === beijingDate() ? days : 'custom'); setSchemeName(scheme.name); setEditing(scheme); setShowSchemeForm(true) }}><Pencil size={14} /></button>
<button aria-label={`删除${scheme.name}`} title="删除" className="shrink-0 rounded-full p-1.5 text-ink-400 hover:bg-bad-500/10 hover:text-bad-500" onClick={() => setDeleteScheme(scheme)}><Trash2 size={14} /></button> <button aria-label={`删除${scheme.name}`} title="删除" className="shrink-0 rounded-full p-1.5 text-ink-400 hover:bg-bad-500/10 hover:text-bad-500" onClick={() => setDeleteScheme(scheme)}><Trash2 size={14} /></button>
</li>)}</ul>} </li>)}</ul>}
{error && <p role="alert" className="mt-3 text-xs text-bad-500">{error}</p>} {error && <p role="alert" className="mt-3 text-xs text-bad-500">{error}</p>}
...@@ -144,7 +152,7 @@ export function DiscoverPage({ onOpenPanel }: { onOpenPanel: (state: AnalysisPan ...@@ -144,7 +152,7 @@ export function DiscoverPage({ onOpenPanel }: { onOpenPanel: (state: AnalysisPan
<input aria-label="方案关键词" placeholder="关键词" value={keyword} onChange={e => setKeyword(e.target.value)} className={`${inputClass} !py-1.5 text-[13px]`} /> <input aria-label="方案关键词" placeholder="关键词" value={keyword} onChange={e => setKeyword(e.target.value)} className={`${inputClass} !py-1.5 text-[13px]`} />
<input aria-label="方案地区" placeholder="地区(如:浙江)" value={regionText} onChange={e => { setRegionText(e.target.value); update(query.mode === 'LEADS' ? 'preferredRegions' : 'hardRegions', words(e.target.value)) }} className={`${inputClass} !py-1.5 text-[13px]`} /> <input aria-label="方案地区" placeholder="地区(如:浙江)" value={regionText} onChange={e => { setRegionText(e.target.value); update(query.mode === 'LEADS' ? 'preferredRegions' : 'hardRegions', words(e.target.value)) }} className={`${inputClass} !py-1.5 text-[13px]`} />
{(['Min', 'Max'] as const).map((bound, i) => { const key = (query.mode === 'LEADS' ? `budget${bound}Wan` : `hard${bound}Wan`) as 'budgetMinWan' | 'budgetMaxWan' | 'hardMinWan' | 'hardMaxWan'; return <input key={bound} aria-label={i ? '方案预算上限' : '方案预算下限'} placeholder={i ? '预算上限(万元)' : '预算下限(万元)'} type="number" min={0} step="any" value={query[key] ?? ''} onChange={e => update(key, e.target.value === '' ? null : Number(e.target.value))} className={`${inputClass} !py-1.5 font-num text-[13px]`} /> })} {(['Min', 'Max'] as const).map((bound, i) => { const key = (query.mode === 'LEADS' ? `budget${bound}Wan` : `hard${bound}Wan`) as 'budgetMinWan' | 'budgetMaxWan' | 'hardMinWan' | 'hardMaxWan'; return <input key={bound} aria-label={i ? '方案预算上限' : '方案预算下限'} placeholder={i ? '预算上限(万元)' : '预算下限(万元)'} type="number" min={0} step="any" value={query[key] ?? ''} onChange={e => update(key, e.target.value === '' ? null : Number(e.target.value))} className={`${inputClass} !py-1.5 font-num text-[13px]`} /> })}
<select aria-label="方案发布时间" value={range} onChange={e => { setRange(e.target.value); setQuery(q => ({ ...q, beginDate: beijingDate(Number(e.target.value) - 1), endDate: beijingDate() })) }} className={`${inputClass} col-span-2 !py-1.5 text-[13px]`}>{[['7', '发布于近 7 天'], ['30', '发布于近 30 天'], ['90', '发布于近 90 天'], ['365', '全部时间']].map(([value, label]) => <option key={value} value={value}>{label}</option>)}</select> <select aria-label="方案发布时间" value={range} onChange={e => updateRange(e.target.value)} className={`${inputClass} col-span-2 !py-1.5 text-[13px]`}>{publicationDays.map(days => <option key={days} value={days}>发布于近 {days} 天</option>)}{range === 'custom' && <option value="custom">{query.beginDate} 至 {query.endDate}</option>}</select>
</div></div> </div></div>
{error && <p role="alert" className="text-xs text-bad-500">{error}</p>} {error && <p role="alert" className="text-xs text-bad-500">{error}</p>}
<div className="!mt-4 flex justify-end gap-2"><GhostButton onClick={() => setShowSchemeForm(false)}>取消</GhostButton><PrimaryButton type="submit" disabled={busy}>{editing ? '保存修改' : '保存方案'}</PrimaryButton></div> <div className="!mt-4 flex justify-end gap-2"><GhostButton onClick={() => setShowSchemeForm(false)}>取消</GhostButton><PrimaryButton type="submit" disabled={busy}>{editing ? '保存修改' : '保存方案'}</PrimaryButton></div>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment