refactor(login): move match-route logic to dedicated service and fix import
- 提取登录回跳、产品对比的路由匹配逻辑至独立的 match-route.uts 服务 - 修复登录页面导入对比服务的错误,改为导入新的 match-route 模块 - 保持原有的路由参数校验和跳转逻辑不变,仅重构代码结构
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
import { wanAmountValid, wanToCents, wanToYuan } from './money.uts'
|
||||
|
||||
// 新选项不推断历史“6个月以上”的具体月数;历史值只在修改回填时保留。
|
||||
export const contributionLabels = ['未缴纳', '不足6个月', '连续6-12个月', '连续12-24个月', '连续24个月以上', '连续6个月以上']
|
||||
export const contributionCodes = ['none', 'under_six_months', 'six_to_twelve_months', 'twelve_to_twenty_four_months', 'twenty_four_months_plus', 'six_months_plus']
|
||||
export function contributionOptions(current: string): string[] {
|
||||
return current == contributionLabels[5] ? contributionLabels.slice() : contributionLabels.slice(0, 5)
|
||||
}
|
||||
export function contributionLabel(code: string): string {
|
||||
const index = contributionCodes.indexOf(code)
|
||||
return index < 0 ? code : contributionLabels[index]
|
||||
}
|
||||
export function contributionBaseVisible(duration: string): boolean {
|
||||
return contributionLabels.includes(duration) && duration != '未缴纳'
|
||||
}
|
||||
export function contributionBaseValid(value: string): boolean {
|
||||
return wanAmountValid(value) && wanToCents(value) > 0
|
||||
}
|
||||
export function contributionBaseYuan(value: string): string {
|
||||
if (!contributionBaseValid(value)) throw new Error('缴存基数请输入大于 0 的万元金额,最多六位小数')
|
||||
return wanToYuan(value)
|
||||
}
|
||||
Reference in New Issue
Block a user