fix: 渠道更新 payload 带上黑名单与计重字段,保存后可回显
All checks were successful
Build and Deploy Front / deploy (push) Successful in 14m56s
All checks were successful
Build and Deploy Front / deploy (push) Successful in 14m56s
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
443032620b
commit
3e7d895253
@ -95,6 +95,9 @@ export type ServiceChannelUpdatePayload = {
|
||||
preScript: string
|
||||
isActive: number
|
||||
remoteAreaId?: number | null
|
||||
blacklistAreaId?: number | null
|
||||
weightRuleId?: number | null
|
||||
weightRoundingId?: number | null
|
||||
}
|
||||
|
||||
export function buildServiceChannelUpdatePayload(
|
||||
@ -112,6 +115,9 @@ export function buildServiceChannelUpdatePayload(
|
||||
| 'preScript'
|
||||
| 'isActive'
|
||||
| 'remoteAreaId'
|
||||
| 'blacklistAreaId'
|
||||
| 'weightRuleId'
|
||||
| 'weightRoundingId'
|
||||
>
|
||||
> & { groupId?: number }
|
||||
): ServiceChannelUpdatePayload {
|
||||
@ -132,13 +138,17 @@ export function buildServiceChannelUpdatePayload(
|
||||
: isEnableStatusEnabled(activeRaw)
|
||||
? ENABLE_STATUS.enabled
|
||||
: ENABLE_STATUS.disabled
|
||||
const resolveRemoteAreaId = (): number | null => {
|
||||
if (patch.remoteAreaId !== undefined) {
|
||||
if (patch.remoteAreaId == null || patch.remoteAreaId === ('' as any)) return null
|
||||
const n = Number(patch.remoteAreaId)
|
||||
const resolveOptionalPositiveId = (
|
||||
patchVal: unknown,
|
||||
detailCamel: string,
|
||||
detailPascal: string
|
||||
): number | null => {
|
||||
if (patchVal !== undefined) {
|
||||
if (patchVal == null || patchVal === '') return null
|
||||
const n = Number(patchVal)
|
||||
return Number.isFinite(n) && n > 0 ? n : null
|
||||
}
|
||||
const raw = detail.remoteAreaId ?? detail.RemoteAreaId
|
||||
const raw = detail[detailCamel] ?? detail[detailPascal]
|
||||
if (raw == null || raw === '') return null
|
||||
const n = Number(raw)
|
||||
return Number.isFinite(n) && n > 0 ? n : null
|
||||
@ -157,7 +167,26 @@ export function buildServiceChannelUpdatePayload(
|
||||
description: str(patch.description ?? detail.description ?? detail.Description),
|
||||
preScript: str(patch.preScript ?? detail.preScript ?? detail.PreScript),
|
||||
isActive,
|
||||
remoteAreaId: resolveRemoteAreaId(),
|
||||
remoteAreaId: resolveOptionalPositiveId(
|
||||
patch.remoteAreaId,
|
||||
'remoteAreaId',
|
||||
'RemoteAreaId'
|
||||
),
|
||||
blacklistAreaId: resolveOptionalPositiveId(
|
||||
patch.blacklistAreaId,
|
||||
'blacklistAreaId',
|
||||
'BlacklistAreaId'
|
||||
),
|
||||
weightRuleId: resolveOptionalPositiveId(
|
||||
patch.weightRuleId,
|
||||
'weightRuleId',
|
||||
'WeightRuleId'
|
||||
),
|
||||
weightRoundingId: resolveOptionalPositiveId(
|
||||
patch.weightRoundingId,
|
||||
'weightRoundingId',
|
||||
'WeightRoundingId'
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user