fix: 高级筛选-筛选条件过滤掉自定义字段不存在的

--bug=1046677 --user=吕梦园
https://www.tapd.cn/55049933/bugtrace/bugs/view/1155049933001046677
This commit is contained in:
teukkk 2024-09-19 15:00:45 +08:00 committed by Craftsman
parent dece1a8751
commit a62943c314

View File

@ -289,13 +289,16 @@
if (res?.id === 'all_data') {
res.conditions = [...getAllDataDefaultConditions(props.viewType)];
}
const list: FilterFormItem[] = (res.conditions ?? [])?.map((item: ConditionsItem) => {
const list: FilterFormItem[] = [];
(res.conditions ?? [])?.forEach((item: ConditionsItem) => {
const listItem = getListItemByDataIndex(item.name ?? '') as FilterFormItem;
return {
...listItem,
operator: item.operator,
value: item.value,
};
if (listItem) {
list.push({
...listItem,
operator: item.operator,
value: item.value,
});
}
});
formModel.value = { ...res, list };
savedFormModel.value = cloneDeep(formModel.value);
@ -341,6 +344,19 @@
.map((item) => ({ ...item, label: t(item.title as string) }));
};
});
// //
function getDefaultOperator(list: string[]) {
if (list.includes(OperatorEnum.CONTAINS)) {
return OperatorEnum.CONTAINS;
}
if (list.includes(OperatorEnum.BELONG_TO)) {
return OperatorEnum.BELONG_TO;
}
if (list.includes(OperatorEnum.EQUAL)) {
return OperatorEnum.EQUAL;
}
return OperatorEnum.BETWEEN; //
}
//
function dataIndexChange(dataIndex: SelectValue, index: number) {
const listItem = getListItemByDataIndex(dataIndex as string);
@ -353,15 +369,7 @@
const optionsValueList = operatorOptionsMap[formModel.value.list[index].type].map(
(optionItem) => optionItem.value
);
if (optionsValueList.includes(OperatorEnum.CONTAINS)) {
formModel.value.list[index].operator = OperatorEnum.CONTAINS;
} else if (optionsValueList.includes(OperatorEnum.BELONG_TO)) {
formModel.value.list[index].operator = OperatorEnum.BELONG_TO;
} else if (optionsValueList.includes(OperatorEnum.EQUAL)) {
formModel.value.list[index].operator = OperatorEnum.EQUAL;
} else {
formModel.value.list[index].operator = OperatorEnum.BETWEEN; //
}
formModel.value.list[index].operator = getDefaultOperator(optionsValueList);
}
}
//