完善后台接口字段
This commit is contained in:
@@ -37,6 +37,7 @@
|
||||
<div class="country-pref-checks">
|
||||
<label v-for="row in countryCheckboxRows" :key="row.code" class="country-check-row">
|
||||
<input type="checkbox" class="country-check-input" :checked="isCountrySelected(row.code)"
|
||||
:disabled="isCountrySelectionLocked(row.code)"
|
||||
@change="onCountryNativeChange(row.code, $event)" />
|
||||
<span class="country-check-text">{{ row.label }}({{ row.code }})</span>
|
||||
</label>
|
||||
@@ -278,9 +279,18 @@ function isCountrySelected(code: string) {
|
||||
return orderedCountryCodes.value.includes(code)
|
||||
}
|
||||
|
||||
function isCountrySelectionLocked(code: string) {
|
||||
return orderedCountryCodes.value.length === 1 && orderedCountryCodes.value[0] === code
|
||||
}
|
||||
|
||||
function onCountryNativeChange(code: string, e: Event) {
|
||||
const el = e.target as HTMLInputElement | null
|
||||
if (!el) return
|
||||
if (!el.checked && isCountrySelectionLocked(code)) {
|
||||
el.checked = true
|
||||
ElMessage.warning('至少保留 1 个国家')
|
||||
return
|
||||
}
|
||||
onCountryToggle(code, el.checked)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user