This commit is contained in:
@@ -2,7 +2,7 @@ type BusinessFailure = {
|
||||
code?: number | string
|
||||
msg?: string
|
||||
message?: string
|
||||
data?: { phone?: unknown }
|
||||
data?: { phone?: unknown } | null
|
||||
}
|
||||
|
||||
const getBusinessFailure = (value: unknown): BusinessFailure | undefined => {
|
||||
@@ -14,8 +14,8 @@ const getBusinessFailure = (value: unknown): BusinessFailure | undefined => {
|
||||
export const getExchangePhoneConflictMessage = (value: unknown): string | undefined => {
|
||||
const failure = getBusinessFailure(value)
|
||||
if (Number(failure?.code) !== 1202) return undefined
|
||||
const phone = typeof failure?.data?.phone === 'string' ? failure.data.phone.trim() : ''
|
||||
return `新资产已绑定手机号${phone ? ` ${phone}` : ''},请先到『手机号资产关联』解除后再提交`
|
||||
// 1202 同时用于旧资产已换货等业务拒绝,必须原样展示后端文案。
|
||||
return failure?.msg || failure?.message || '换货申请未完成,请检查当前资产是否符合换货条件'
|
||||
}
|
||||
|
||||
export const getExchangeBusinessErrorMessage = (value: unknown): string | undefined => {
|
||||
@@ -37,11 +37,6 @@ export const getExchangePhoneAssociationQuery = (
|
||||
if (Number(response?.code) !== 1202) return undefined
|
||||
const asset_identifier = newAsset.asset_identifier?.trim() || ''
|
||||
const responsePhone = typeof response?.data?.phone === 'string' ? response.data.phone.trim() : ''
|
||||
const phone =
|
||||
responsePhone ||
|
||||
newAsset.associated_phones
|
||||
?.find((value) => typeof value === 'string' && value.trim())
|
||||
?.trim() ||
|
||||
''
|
||||
return asset_identifier && phone ? { asset_identifier, phone } : undefined
|
||||
// 仅响应明确包含 phone 才能视为手机号冲突;不能凭资产历史关联给其他 1202 添加解绑入口。
|
||||
return asset_identifier && responsePhone ? { asset_identifier, phone: responsePhone } : undefined
|
||||
}
|
||||
|
||||
@@ -472,22 +472,25 @@
|
||||
)
|
||||
return
|
||||
}
|
||||
const canManageAssociations = hasAuth(AUGUST_PERMISSIONS.phoneAssetAssociation.list)
|
||||
const associationQuery = getExchangePhoneAssociationQuery(failure, newAsset)
|
||||
const canManageAssociations =
|
||||
!!associationQuery && hasAuth(AUGUST_PERMISSIONS.phoneAssetAssociation.list)
|
||||
try {
|
||||
await ElMessageBox.confirm(
|
||||
canManageAssociations
|
||||
? conflictMessage
|
||||
: `${conflictMessage}。您暂无管理权限,请联系管理员解除。`,
|
||||
'新资产手机号绑定冲突',
|
||||
{
|
||||
if (!canManageAssociations) {
|
||||
await ElMessageBox.alert(conflictMessage, '换货提示', {
|
||||
type: 'warning',
|
||||
confirmButtonText: canManageAssociations ? '前往手机号资产关联' : '知道了',
|
||||
cancelButtonText: '暂不处理',
|
||||
showCancelButton: canManageAssociations,
|
||||
confirmButtonText: '知道了',
|
||||
dangerouslyUseHTMLString: false
|
||||
}
|
||||
)
|
||||
})
|
||||
return
|
||||
}
|
||||
await ElMessageBox.confirm(conflictMessage, '新资产手机号绑定冲突', {
|
||||
type: 'warning',
|
||||
confirmButtonText: '前往手机号资产关联',
|
||||
cancelButtonText: '暂不处理',
|
||||
showCancelButton: true,
|
||||
dangerouslyUseHTMLString: false
|
||||
})
|
||||
if (canManageAssociations)
|
||||
await router.push({ path: RoutesAlias.PhoneAssetAssociation, query: associationQuery })
|
||||
} catch {
|
||||
|
||||
Reference in New Issue
Block a user