fix: make advanced filters work
Co-authored-by: aider (openai/DeepSeek-V3.2-Thinking) <aider@aider.chat>
This commit is contained in:
@ -209,6 +209,26 @@ class MaterialBaseService:
|
||||
column = getattr(MaterialBase, db_field, None)
|
||||
if column is None:
|
||||
continue
|
||||
# 处理操作符
|
||||
# 对于数值型列(聚合字段)只支持 eq, ne, ge, le
|
||||
if isinstance(column, type(total_inv)):
|
||||
# 数值型列
|
||||
try:
|
||||
num_val = float(value)
|
||||
except ValueError:
|
||||
# 转换失败则跳过该条件
|
||||
continue
|
||||
if operator == 'eq':
|
||||
filter_conditions.append(column == num_val)
|
||||
elif operator == 'ne':
|
||||
filter_conditions.append(column != num_val)
|
||||
elif operator == 'ge':
|
||||
filter_conditions.append(column >= num_val)
|
||||
elif operator == 'le':
|
||||
filter_conditions.append(column <= num_val)
|
||||
# 对于 contains 操作符,数值型列不支持,忽略
|
||||
else:
|
||||
# 字符串型列
|
||||
if operator == 'eq':
|
||||
filter_conditions.append(column == value)
|
||||
elif operator == 'ne':
|
||||
|
||||
@ -736,7 +736,12 @@ const querySearchType = (queryString: string, cb: any) => {
|
||||
|
||||
const getList = () => {
|
||||
loading.value = true;
|
||||
listMaterialBase(queryParams)
|
||||
// Stringify advancedFilters to JSON string as backend expects
|
||||
const params = {
|
||||
...queryParams,
|
||||
advancedFilters: JSON.stringify(queryParams.advancedFilters || [])
|
||||
};
|
||||
listMaterialBase(params)
|
||||
.then((response: any) => {
|
||||
if (response && response.data) {
|
||||
tableData.value = response.data.items;
|
||||
|
||||
Reference in New Issue
Block a user