From afbfd382fc2d23a94e597c58f8aedf9afb1b7d92 Mon Sep 17 00:00:00 2001 From: lurunze1226 Date: Thu, 23 Feb 2023 11:50:12 +0800 Subject: [PATCH] =?UTF-8?q?amis-saas-9796=20fix:=20=E4=BA=8B=E4=BB=B6?= =?UTF-8?q?=E5=8A=A8=E4=BD=9C=E6=95=B0=E6=8D=AE=E8=AE=BE=E7=BD=AE=E6=8E=A7?= =?UTF-8?q?=E4=BB=B6=E7=BC=BA=E5=B0=91=E5=BA=94=E7=94=A8=E5=8F=98=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Iaf98787bd579d4f3c23350e3488e0aaf9181f2ee --- packages/amis-editor/package.json | 2 +- .../src/renderer/event-control/index.tsx | 25 ++++++++++++++++++- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/packages/amis-editor/package.json b/packages/amis-editor/package.json index 918baa20f..20e71868a 100644 --- a/packages/amis-editor/package.json +++ b/packages/amis-editor/package.json @@ -1,6 +1,6 @@ { "name": "amis-editor", - "version": "5.2.1-alpha.5", + "version": "5.2.1-alpha.6", "description": "amis 可视化编辑器", "main": "lib/index.js", "module": "esm/index.js", diff --git a/packages/amis-editor/src/renderer/event-control/index.tsx b/packages/amis-editor/src/renderer/event-control/index.tsx index 4a9ff75d4..104d6e8d0 100644 --- a/packages/amis-editor/src/renderer/event-control/index.tsx +++ b/packages/amis-editor/src/renderer/event-control/index.tsx @@ -38,6 +38,7 @@ import { } from 'amis-editor-core'; export * from './helper'; import {i18n as _i18n} from 'i18n-runtime'; +import type {VariableItem} from 'amis-ui/lib/components/formula/Editor'; interface EventControlProps extends FormControlProps { actions: PluginActions; // 组件的动作列表 @@ -556,7 +557,8 @@ export class EventControl extends React.Component< actionConfigInitFormatter, getComponents, actionTree, - allComponents + allComponents, + manager } = this.props; let rawVariables = []; @@ -568,7 +570,28 @@ export class EventControl extends React.Component< // 收集事件变量 const eventVariables = this.getEventVariables(data); + const appVariables: VariableItem[] = + manager?.variableManager?.getVariableFormulaOptions() || []; const variables = [...eventVariables, ...rawVariables]; + const systemVarIndex = variables.findIndex( + item => item.label === '系统变量' + ); + + // 插入应用变量 + if (!!~systemVarIndex) { + appVariables.forEach(item => { + if (Array.isArray(item?.children) && item.children.length) { + variables.splice(systemVarIndex, 0, item); + } + }); + } else { + appVariables.forEach(item => { + if (Array.isArray(item?.children) && item.children.length) { + variables.push(item); + } + }); + } + // 编辑操作,需要格式化动作配置 if (data.type === 'update') { const action = data.actionData!.action!;