fix: 修复crud2切换搜索时jsonql未更新问题

This commit is contained in:
zhangtao07 2024-10-11 14:03:43 +08:00
parent eaea15af30
commit 04c9487bf2

View File

@ -18,7 +18,7 @@ import {
autobind
} from 'amis';
import {TooltipWrapper} from 'amis-ui';
import {DSFeatureEnum} from '../../builder/constants';
import {DSFeatureEnum, ModelDSBuilderKey} from '../../builder/constants';
import {traverseSchemaDeep} from '../../builder/utils';
import {deepRemove} from '../../plugin/CRUD2/utils';
@ -650,7 +650,8 @@ export class CRUDFiltersControl extends React.Component<
@autobind
async handleToggle(checked: boolean) {
const {feat, builder} = this.props;
const {manager, nodeId, feat, builder} = this.props;
const store = manager.store;
this.setState({loading: true, checked});
try {
@ -665,6 +666,23 @@ export class CRUDFiltersControl extends React.Component<
if (feat === DSFeatureEnum.FuzzyQuery && builder.filterByFeat(feat)) {
await this.updateFuzzyQuery(checked);
}
// crud模型实体每次都需要重新生成jsonql的筛选条件
if (builder.key === ModelDSBuilderKey) {
const node = store.getNodeById(nodeId);
const crudSchema = node?.schema;
if (crudSchema) {
let schema = await builder.buildApiSchema({
schema: node.schema,
renderer: 'crud',
sourceKey: 'api',
feat: DSFeatureEnum.List
});
node.updateSchema({
api: schema.api
});
}
}
} catch (error) {}
this.setState({loading: false, checked});