Skip to content

Commit

Permalink
fix: 修复crud2切换搜索时jsonql未更新问题
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangtao07 committed Oct 11, 2024
1 parent eaea15a commit 04c9487
Showing 1 changed file with 20 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -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 {
Expand All @@ -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});
Expand Down

0 comments on commit 04c9487

Please sign in to comment.