fix: 编辑error状态账号时保存报Status验证失败
后端UpdateAccountRequest.Status的oneof验证缺少error状态, 前端编辑表单也未处理error状态,导致编辑异常账号时无法保存
This commit is contained in:
@@ -122,7 +122,7 @@ type UpdateAccountRequest struct {
|
||||
Priority *int `json:"priority"`
|
||||
RateMultiplier *float64 `json:"rate_multiplier"`
|
||||
LoadFactor *int `json:"load_factor"`
|
||||
Status string `json:"status" binding:"omitempty,oneof=active inactive"`
|
||||
Status string `json:"status" binding:"omitempty,oneof=active inactive error"`
|
||||
GroupIDs *[]int64 `json:"group_ids"`
|
||||
ExpiresAt *int64 `json:"expires_at"`
|
||||
AutoPauseOnExpired *bool `json:"auto_pause_on_expired"`
|
||||
|
||||
@@ -1617,15 +1617,21 @@ const form = reactive({
|
||||
load_factor: null as number | null,
|
||||
priority: 1,
|
||||
rate_multiplier: 1,
|
||||
status: 'active' as 'active' | 'inactive',
|
||||
status: 'active' as 'active' | 'inactive' | 'error',
|
||||
group_ids: [] as number[],
|
||||
expires_at: null as number | null
|
||||
})
|
||||
|
||||
const statusOptions = computed(() => [
|
||||
const statusOptions = computed(() => {
|
||||
const options = [
|
||||
{ value: 'active', label: t('common.active') },
|
||||
{ value: 'inactive', label: t('common.inactive') }
|
||||
])
|
||||
]
|
||||
if (form.status === 'error') {
|
||||
options.push({ value: 'error', label: t('admin.accounts.status.error') })
|
||||
}
|
||||
return options
|
||||
})
|
||||
|
||||
const expiresAtInput = computed({
|
||||
get: () => formatDateTimeLocal(form.expires_at),
|
||||
@@ -1651,7 +1657,7 @@ watch(
|
||||
form.load_factor = newAccount.load_factor ?? null
|
||||
form.priority = newAccount.priority
|
||||
form.rate_multiplier = newAccount.rate_multiplier ?? 1
|
||||
form.status = (newAccount.status === 'active' || newAccount.status === 'inactive')
|
||||
form.status = (newAccount.status === 'active' || newAccount.status === 'inactive' || newAccount.status === 'error')
|
||||
? newAccount.status
|
||||
: 'active'
|
||||
form.group_ids = newAccount.group_ids || []
|
||||
@@ -2225,7 +2231,7 @@ const handleSubmit = async () => {
|
||||
if (!props.account) return
|
||||
const accountID = props.account.id
|
||||
|
||||
if (form.status !== 'active' && form.status !== 'inactive') {
|
||||
if (form.status !== 'active' && form.status !== 'inactive' && form.status !== 'error') {
|
||||
appStore.showError(t('admin.accounts.pleaseSelectStatus'))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -809,7 +809,7 @@ export interface UpdateAccountRequest {
|
||||
priority?: number
|
||||
rate_multiplier?: number // Account billing multiplier (>=0, 0 means free)
|
||||
schedulable?: boolean
|
||||
status?: 'active' | 'inactive'
|
||||
status?: 'active' | 'inactive' | 'error'
|
||||
group_ids?: number[]
|
||||
expires_at?: number | null
|
||||
auto_pause_on_expired?: boolean
|
||||
|
||||
Reference in New Issue
Block a user