Skip to content

Commit

Permalink
列表搜索时,如果在变更搜索条件后立即回车会触发重复请求
Browse files Browse the repository at this point in the history
列表视图上 “筛选”按钮部分字段保留边改边搜,其它的字段启用失去焦点才搜索;
“搜索此列表”搜索框去掉边输边搜,启用失去焦点才搜索;
列表视图API设置缓存3s。
#504
  • Loading branch information
Flyingliao committed Nov 24, 2023
1 parent 19ac5bd commit fc0658b
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -796,9 +796,38 @@ export async function getFieldSearchable(perField, permissionFields, ctx){

const amisField = await Fields.convertSFieldToAmisField(_field, false, Object.assign({}, ctx, {fieldNamePrefix: fieldNamePrefix, required: false, showSystemFields: true, inFilterForm: true}));
if(amisField){
return Object.assign({}, amisField,{
submitOnChange: true
});
const changeActionsFields = ['select', 'boolean', 'toggle', 'date', 'datetime', 'time', 'number', 'currency', 'lookup', 'master_detail'];
const isChangeActions = changeActionsFields.indexOf(field.type) > -1;
let additionalProps = {
submitOnChange: false
}
if (isChangeActions) {
additionalProps.submitOnChange = true
} else {
additionalProps.onEvent = {
blur: {
actions: [
{
actionType: "custom",
script: `
try {
const scope = event.context.scoped;
const filterForm = scope.parent.parent.parent.getComponents().find(function(n) {
return n.props.type === "form";
});
if (filterForm && typeof filterForm.handleFormSubmit === 'function') {
filterForm.handleFormSubmit(event);
}
} catch (error) {
console.error('An error occurred:', error);
}
`
}
]
}
}
}
return Object.assign({}, amisField, additionalProps);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1093,6 +1093,7 @@ export async function getTableApi(mainObject, fields, options){
if(options.isRelated){
api.url += "&recordId=${_master.recordId}";
}
api.cache = 3000;

api.data.$term = "$term";
api.data.term = "$term";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,30 @@ function getObjectHeaderQuickSearchBox(mainObject, fields, formFactor, { isLooku
"value": crudKeywords,
"clearable": true,
"clearAndSubmit": true,
"searchImediately": false
"searchImediately": false,
"onEvent": {
"blur": {
"actions": [
{
"actionType": "custom",
"script": `
try {
const scope = event.context.scoped;
const filterCrud = scope.parent.getComponents().find(function(n) {
return n.props.type === "crud";
});
if (filterCrud && typeof filterCrud.reload === 'function') {
const keyWords = { '${keywordsSearchBoxName}': event.data.value };
filterCrud.reload(null, keyWords);
}
} catch (error) {
console.error('An error occurred:', error);
}
`
}
]
}
}
}
]
}
Expand Down

0 comments on commit fc0658b

Please sign in to comment.