feat: 重构评估流程为内存状态管理并接入真实提交与报告接口

本次重构将评估草稿改为内存状态管理,移除本地存储草稿,新增评估流程内存状态模块;接入真实的账户资料获取、头像上传接口,新增账户缓存清理逻辑;重构评估提交逻辑,接入真实提交接口并返回评估ID;新增分析页和报告页的真实状态查询、报告获取功能;更新README文档,记录开发进度和接口状态。
This commit is contained in:
hujun
2026-09-24 11:50:07 +08:00
parent dcf12a4471
commit dbfd637388
22 changed files with 1468 additions and 434 deletions
+31
View File
@@ -0,0 +1,31 @@
import { requestJson } from './api.uts'
import { wanAmountValid, wanToCents } from './money.uts'
export type FinancingPurpose = { type: string, code: string, label: string, requiresDetail: boolean }
// 用途由服务端发布;加载失败时提示重试,不用本机猜测字典后提交。
export async function fetchFinancingPurposes(): Promise<FinancingPurpose[]> {
const result = await requestJson('/dictionaries', 'GET', {})
const versions = result['assessmentInputVersions'] as number[] | null
const minimum = result['minNewAssessmentInputVersion'] as number | null
if (versions == null || !versions.includes(2) || minimum == null || minimum > 2) throw new Error('评估版本已更新,请刷新页面后重试')
const dictionary = result['financingPurposes'] as UTSJSONObject | null
if (dictionary == null) throw new Error('资金用途暂不可用,请重试')
const items = dictionary['items'] as UTSJSONObject[] | null
if (items == null) throw new Error('资金用途暂不可用,请重试')
const purposes: FinancingPurpose[] = []
items.forEach((item: UTSJSONObject) => {
if (item['enabled'] == true) purposes.push({ type: item['type'] as string, code: item['code'] as string, label: item['label'] as string, requiresDetail: item['requiresDetail'] == true } as FinancingPurpose)
})
if (purposes.length == 0) throw new Error('资金用途暂不可用,请重试')
return purposes
}
export function demandValidationMessage(amount: string, term: string, code: string, detail: string): string {
if (!wanAmountValid(amount) || wanToCents(amount) <= 0) return '请填写大于零的融资金额(万元,最多六位小数)'
if (!/^[1-9][0-9]{0,3}$/.test(term)) return '融资期限请输入1至9999的整数月'
if (code.length == 0) return '请选择资金用途'
if (code == 'other' && (detail.trim().length < 2 || detail.trim().length > 200 || /[<>\x00-\x1f\x7f]/.test(detail))) return '其他用途请填写2至200字说明,不含标签或控制字符'
if (code != 'other' && detail.length > 0) return '仅其他用途需要填写说明'
return ''
}