归档结转无用量行时保留待完善错误文案,前端按计划齐备状态只提醒完善证件。 Co-authored-by: Cursor <cursoragent@cursor.com>
28 lines
1008 B
TypeScript
28 lines
1008 B
TypeScript
/** 归档用证拦截弹窗:已齐备/待完善只提醒,未齐备旧规则才可再点证书齐备。 */
|
|
|
|
export type ArchiveQuotaBlockMode = 'alert-pending' | 'alert-plain' | 'confirm-ready'
|
|
|
|
export type ArchiveQuotaBlockPlanFlags = {
|
|
quotaCertPendingFulfill?: number | boolean | null
|
|
quotaCertWaived?: number | boolean | null
|
|
}
|
|
|
|
function flagOn(value: number | boolean | null | undefined) {
|
|
return value === true || Number(value || 0) === 1
|
|
}
|
|
|
|
export function resolveArchiveQuotaBlockMode(
|
|
message: string,
|
|
title: string,
|
|
plan?: ArchiveQuotaBlockPlanFlags | null
|
|
): ArchiveQuotaBlockMode {
|
|
const pendingByMessage =
|
|
message.includes('待完善') ||
|
|
message.includes('完善并关闭') ||
|
|
message.includes('证书齐备待完善')
|
|
const pendingByPlan = flagOn(plan?.quotaCertPendingFulfill) || flagOn(plan?.quotaCertWaived)
|
|
if (title !== '用证没有完成') return 'alert-plain'
|
|
if (pendingByPlan || pendingByMessage) return 'alert-pending'
|
|
return 'confirm-ready'
|
|
}
|