fix(channel): 渠道表单校验增强 — 空模型定价报错 + 必填标记
- 保存时校验:定价条目有但模型列表为空时报错并跳转到对应平台 tab, 不再静默跳过导致数据丢失 - 保存时校验:启用的平台必须至少选择一个分组 - 分组关联标签增加红色 * 必填标记
This commit is contained in:
@@ -261,7 +261,7 @@
|
||||
<!-- Groups -->
|
||||
<div>
|
||||
<label class="input-label text-xs">
|
||||
{{ t('admin.channels.form.groups', 'Associated Groups') }}
|
||||
{{ t('admin.channels.form.groups', 'Associated Groups') }} <span class="text-red-500">*</span>
|
||||
<span v-if="section.group_ids.length > 0" class="ml-1 font-normal text-gray-400">
|
||||
({{ t('admin.channels.form.selectedCount', { count: section.group_ids.length }, `已选 ${section.group_ids.length} 个`) }})
|
||||
</span>
|
||||
@@ -859,6 +859,24 @@ async function handleSubmit() {
|
||||
return
|
||||
}
|
||||
|
||||
// Check for pricing entries with empty models (would be silently skipped)
|
||||
for (const section of form.platforms.filter(s => s.enabled)) {
|
||||
if (section.group_ids.length === 0) {
|
||||
const platformLabel = t('admin.groups.platforms.' + section.platform, section.platform)
|
||||
appStore.showError(t('admin.channels.noGroupsSelected', { platform: platformLabel }, `${platformLabel} 平台未选择分组,请至少选择一个分组或禁用该平台`))
|
||||
activeTab.value = section.platform
|
||||
return
|
||||
}
|
||||
for (const entry of section.model_pricing) {
|
||||
if (entry.models.length === 0) {
|
||||
const platformLabel = t('admin.groups.platforms.' + section.platform, section.platform)
|
||||
appStore.showError(t('admin.channels.emptyModelsInPricing', { platform: platformLabel }, `${platformLabel} 平台下有定价条目未添加模型,请添加模型或删除该条目`))
|
||||
activeTab.value = section.platform
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Check duplicate models across all enabled platform sections
|
||||
const allModels = form.platforms.filter(s => s.enabled).flatMap(s => s.model_pricing.flatMap(e => e.models.map(m => m.toLowerCase())))
|
||||
const duplicates = allModels.filter((m, i) => allModels.indexOf(m) !== i)
|
||||
|
||||
Reference in New Issue
Block a user