23 lines
659 B
TypeScript
23 lines
659 B
TypeScript
//
|
|
//
|
|
import type { DictOption } from '@/types/business/demand'
|
|
|
|
const MANUAL_PATTERN = /手填|手写|自定义/
|
|
|
|
export const MANUAL_BUDGET_MAX = 30
|
|
|
|
export function isManualBudget(label: string): boolean {
|
|
return MANUAL_PATTERN.test(label)
|
|
}
|
|
|
|
export function resolveDraftBudget(
|
|
budgetRange: string | null | undefined,
|
|
dict: DictOption[],
|
|
): { manual: boolean, value: string } {
|
|
const raw = (budgetRange ?? '').trim()
|
|
if (!raw) return { manual: false, value: '' }
|
|
const hit = dict.find((item) => item.dictValue === raw || item.dictLabel === raw)
|
|
if (hit) return { manual: false, value: hit.dictValue }
|
|
return { manual: true, value: raw }
|
|
}
|