From 04c9487bf20e5ca452f41a8aa52be9a2e3f153e0 Mon Sep 17 00:00:00 2001 From: zhangtao07 Date: Fri, 11 Oct 2024 14:03:43 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8Dcrud2=E5=88=87?= =?UTF-8?q?=E6=8D=A2=E6=90=9C=E7=B4=A2=E6=97=B6jsonql=E6=9C=AA=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../crud2-control/CRUDFiltersControl.tsx | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/packages/amis-editor/src/renderer/crud2-control/CRUDFiltersControl.tsx b/packages/amis-editor/src/renderer/crud2-control/CRUDFiltersControl.tsx index 22dde2519..bec0a59e8 100644 --- a/packages/amis-editor/src/renderer/crud2-control/CRUDFiltersControl.tsx +++ b/packages/amis-editor/src/renderer/crud2-control/CRUDFiltersControl.tsx @@ -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});