Skip to content

Commit

Permalink
[Bug]: 点击列表表头搜索表单中的搜索按钮前,如果没有改过表单内容,直接点击搜索按钮可能会有概率使用之前的过滤条件过滤
Browse files Browse the repository at this point in the history
  • Loading branch information
yinlianghui committed Jan 7, 2025
1 parent 414a1ec commit 552c530
Showing 1 changed file with 20 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,30 @@ export async function getObjectFieldsFilterBarSchema(objectSchema, ctx) {
const filterFormSchema = await getObjectFieldsFilterFormSchema(ctx);
const keywordsSearchBoxName = ctx.keywordsSearchBoxName || "__keywords";
const onSearchScript = `
// console.log("===onSearchScript=form==");
let isLookup = event.data.isLookup;
let __lookupField = event.data.__lookupField;
const scope = event.context.scoped;
let crud = SteedosUI.getClosestAmisComponentByType(scope, "crud");
var filterForm = scope.parent.parent.getComponents().find(function(n){
return n.props.type === "form";
});
// 使用filterForm.getValues()的话,并不能拿到本地存储中的过滤条件,所以需要从event.data中取,因为本地存储中的过滤条件自动填充到表单上时filterForm.getValues()拿不到。
let filterFormValues = event.data;
// 同步__changedFilterFormValues中的值
// crud && crud.setData({__changedFilterFormValues: {}});
let __changedFilterFormValuesKey = "__changedFilterFormValues";
if(isLookup && __lookupField){
let lookupTag = "__lookup__" + __lookupField.name + "__" + __lookupField.reference_to;
if(__lookupField.reference_to_field){
lookupTag += "__" + __lookupField.reference_to_field;
}
__changedFilterFormValuesKey += lookupTag;
}
if(crud){
let crudData = crud.getData();
crudData[__changedFilterFormValuesKey] = filterFormValues;
crud.setData(crudData);
}
filterForm.handleFormSubmit(event);
// var filterFormValues = filterForm.getValues();
// var listView = scope.parent.parent.parent.getComponents().find(function(n){
Expand Down Expand Up @@ -153,10 +172,7 @@ export async function getObjectFieldsFilterBarSchema(objectSchema, ctx) {
}
filterService.setData({showFieldsFilter});
// resizeWindow();//已迁移到搜索栏表单提交事件中执行,因为表单项change后也会触发表单提交了
// 使用filterForm.getValues()的话,并不能拿到本地存储中的过滤条件,所以需要从event.data中取。
let filterFormValues = event.data;
let isFieldsFilterEmpty = SteedosUI.isFilterFormValuesEmpty(filterFormValues);
let crud = SteedosUI.getClosestAmisComponentByType(scope, "crud");
let crudService = crud && SteedosUI.getClosestAmisComponentByType(crud.context, "service");
crudService && crudService.setData({isFieldsFilterEmpty, showFieldsFilter});
`;
Expand Down

0 comments on commit 552c530

Please sign in to comment.