Files
cz-web/src/api/demand.ts
2026-09-24 09:09:47 +08:00

26 lines
965 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import type { Demand } from '@/types/business/demand'
import { storage } from '@/utils/storage'
// TODO(api): 待接口文档到位后,将以下 mock 替换为 request<T> 调用(页面 → store → api 数据流不变)
const DRAFT_KEY = 'demand-draft'
/** 提交需求(mock:返回提报单 id) */
export function submitDemand(demand: Demand): Promise<{ id: string }> {
if (!demand.businessType || !demand.projectName || !demand.coreDescription) {
return Promise.reject(new Error('需求信息不完整,无法提交'))
}
return Promise.resolve({ id: `demand-${Date.now()}` })
}
/** 读取本地草稿(无草稿返回 null) */
export function getDraftDemand(): Promise<Demand | null> {
return Promise.resolve(storage.sessionGet<Demand>(DRAFT_KEY))
}
/** 保存草稿到本地 */
export function saveDraft(demand: Demand): Promise<void> {
storage.sessionSet(DRAFT_KEY, { ...demand, status: 'draft' })
return Promise.resolve()
}