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
|
preScript: string
|
||||||
isActive: number
|
isActive: number
|
||||||
remoteAreaId?: number | null
|
remoteAreaId?: number | null
|
||||||
|
blacklistAreaId?: number | null
|
||||||
|
weightRuleId?: number | null
|
||||||
|
weightRoundingId?: number | null
|
||||||
}
|
}
|
||||||
|
|
||||||
export function buildServiceChannelUpdatePayload(
|
export function buildServiceChannelUpdatePayload(
|
||||||
@ -112,6 +115,9 @@ export function buildServiceChannelUpdatePayload(
|
|||||||
| 'preScript'
|
| 'preScript'
|
||||||
| 'isActive'
|
| 'isActive'
|
||||||
| 'remoteAreaId'
|
| 'remoteAreaId'
|
||||||
|
| 'blacklistAreaId'
|
||||||
|
| 'weightRuleId'
|
||||||
|
| 'weightRoundingId'
|
||||||
>
|
>
|
||||||
> & { groupId?: number }
|
> & { groupId?: number }
|
||||||
): ServiceChannelUpdatePayload {
|
): ServiceChannelUpdatePayload {
|
||||||
@ -132,13 +138,17 @@ export function buildServiceChannelUpdatePayload(
|
|||||||
: isEnableStatusEnabled(activeRaw)
|
: isEnableStatusEnabled(activeRaw)
|
||||||
? ENABLE_STATUS.enabled
|
? ENABLE_STATUS.enabled
|
||||||
: ENABLE_STATUS.disabled
|
: ENABLE_STATUS.disabled
|
||||||
const resolveRemoteAreaId = (): number | null => {
|
const resolveOptionalPositiveId = (
|
||||||
if (patch.remoteAreaId !== undefined) {
|
patchVal: unknown,
|
||||||
if (patch.remoteAreaId == null || patch.remoteAreaId === ('' as any)) return null
|
detailCamel: string,
|
||||||
const n = Number(patch.remoteAreaId)
|
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
|
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
|
if (raw == null || raw === '') return null
|
||||||
const n = Number(raw)
|
const n = Number(raw)
|
||||||
return Number.isFinite(n) && n > 0 ? n : null
|
return Number.isFinite(n) && n > 0 ? n : null
|
||||||
@ -157,7 +167,26 @@ export function buildServiceChannelUpdatePayload(
|
|||||||
description: str(patch.description ?? detail.description ?? detail.Description),
|
description: str(patch.description ?? detail.description ?? detail.Description),
|
||||||
preScript: str(patch.preScript ?? detail.preScript ?? detail.PreScript),
|
preScript: str(patch.preScript ?? detail.preScript ?? detail.PreScript),
|
||||||
isActive,
|
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