From a62943c314aa906ad0ecca4f645d98b1d7754b44 Mon Sep 17 00:00:00 2001 From: teukkk Date: Thu, 19 Sep 2024 15:00:45 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E9=AB=98=E7=BA=A7=E7=AD=9B=E9=80=89-?= =?UTF-8?q?=E7=AD=9B=E9=80=89=E6=9D=A1=E4=BB=B6=E8=BF=87=E6=BB=A4=E6=8E=89?= =?UTF-8?q?=E8=87=AA=E5=AE=9A=E4=B9=89=E5=AD=97=E6=AE=B5=E4=B8=8D=E5=AD=98?= =?UTF-8?q?=E5=9C=A8=E7=9A=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1046677 --user=吕梦园 https://www.tapd.cn/55049933/bugtrace/bugs/view/1155049933001046677 --- .../pure/ms-advance-filter/filterDrawer.vue | 38 +++++++++++-------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/frontend/src/components/pure/ms-advance-filter/filterDrawer.vue b/frontend/src/components/pure/ms-advance-filter/filterDrawer.vue index 163492fa84..23d424ce47 100644 --- a/frontend/src/components/pure/ms-advance-filter/filterDrawer.vue +++ b/frontend/src/components/pure/ms-advance-filter/filterDrawer.vue @@ -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); } } // 改变第二列值