fix: 优化供应商授权弹窗的标签和默认值

- 标签根据类型动态显示"分类"或"商品"
- 默认值改为undefined,显示placeholder而非0
- 切换类型时清空选择

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-06-02 20:40:37 +08:00
parent ac6119a0ba
commit 5e1ab2cf4c
+4 -4
View File
@@ -44,7 +44,7 @@
<el-option value="product" label="商品" />
</el-select>
</el-form-item>
<el-form-item label="关联项">
<el-form-item :label="authForm.type === 'category' ? '分类' : '商品'">
<el-select v-model="authForm.ref_id" filterable placeholder="请选择" :loading="loadingOptions">
<el-option
v-for="item in optionsList"
@@ -80,7 +80,7 @@ const paginatedSuppliers = computed(() => {
return suppliers.value.slice(start, start + pageSize)
})
const form = reactive({ username: '', email: '', password: '' })
const authForm = reactive({ type: 'category', ref_id: 0 })
const authForm = reactive<{ type: string; ref_id: number | undefined }>({ type: 'category', ref_id: undefined })
const optionsList = ref<{ id: number; name: string }[]>([])
const loadingOptions = ref(false)
@@ -103,13 +103,13 @@ async function addSupplier() {
async function authorize(id: number) {
authSupplierId.value = id
authForm.type = 'category'
authForm.ref_id = 0
authForm.ref_id = undefined
await loadOptions()
showAuth.value = true
}
async function handleTypeChange() {
authForm.ref_id = 0
authForm.ref_id = undefined
await loadOptions()
}