fix: 修复多选排它异常
- 修复options 获取的数据源
This commit is contained in:
@@ -156,12 +156,26 @@ function handleChange(names) {
|
||||
const newOption = names[names.length - 1];
|
||||
// 如果names 长度小于1,直接返回,不处理
|
||||
if (names.length < 1) return;
|
||||
// 如果不存在 options 和 list 属性,直接返回
|
||||
if (!element.value.options || !element.value.list) return;
|
||||
|
||||
const options = element.value.options[0] ?? element.value.list[0];
|
||||
// 如果新增的结果是排它项, 对结果进行处理
|
||||
if (options[newOption - 1]?.is_remove_other === 1) {
|
||||
let options;
|
||||
|
||||
try {
|
||||
options = element.value.options[0].options ?? element.value.list[0];
|
||||
} catch (e) {
|
||||
options = element.value.options[0];
|
||||
}
|
||||
|
||||
// 如果不存在 options 和 list 属性,直接返回
|
||||
if (!options) return;
|
||||
|
||||
// 如果 names 里面有其他的排它项,就把排它项的值去除
|
||||
for (const option of options) {
|
||||
if (option.is_remove_other === 1 && newOption !== option.option_index) {
|
||||
value.value = value.value.filter((item) => item !== option.option_index);
|
||||
}
|
||||
}
|
||||
|
||||
if (options[Number(newOption) - 1]?.is_remove_other === 1) {
|
||||
value.value = [newOption];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user