diff --git a/packages/amis-editor/src/renderer/event-control/actions.tsx b/packages/amis-editor/src/renderer/event-control/actions.tsx index fbcf70e0e..a286bdc2f 100644 --- a/packages/amis-editor/src/renderer/event-control/actions.tsx +++ b/packages/amis-editor/src/renderer/event-control/actions.tsx @@ -15,7 +15,7 @@ import { renderCmptSelect, SUPPORT_DISABLED_CMPTS } from './helper'; - +import {BaseLabelMark} from '../../component/BaseControl'; const MSG_TYPES: {[key: string]: string} = { info: '提示', warning: '警告', @@ -450,16 +450,16 @@ const ACTION_TYPE_TREE = (manager: any): RendererPluginAction[] => { type: 'checkbox', name: 'silent', option: '静默模式', + mode: 'inline', + className: 'm-r-none', + value: false, remark: { className: 'ae-BaseRemark', icon: 'fa fa-question-circle', - trigger: ['hover', 'click'], - placement: 'left', + shape: "circle", + placement: "left", content: '勾选后,服务请求将以静默模式发送,即不会弹出成功或报错提示。' - }, - mode: 'inline', - className: 'm-r-none', - value: false + } } ] } @@ -477,7 +477,26 @@ const ACTION_TYPE_TREE = (manager: any): RendererPluginAction[] => { required: true } ] - } + }, + outputVarDataSchema: [ + { + type: 'object', + properties: { + 'event.data.${outputVar}.responseData': { + type: 'object', + title: '数据' + }, + 'event.data.${outputVar}.responseStatus': { + type: 'number', + title: '状态标识' + }, + 'event.data.${outputVar}.responseMsg': { + type: 'string', + title: '提示信息' + } + } + } + ] }, { actionLabel: '下载文件', @@ -490,7 +509,11 @@ const ACTION_TYPE_TREE = (manager: any): RendererPluginAction[] => { body: [ getArgsWrapper( getSchemaTpl('apiControl', { - name: 'api' + name: 'api', + label: '配置请求', + mode: 'horizontal', + size: 'lg', + required: true }) ) ] diff --git a/packages/amis-editor/src/renderer/event-control/helper.tsx b/packages/amis-editor/src/renderer/event-control/helper.tsx index 95d264e90..d1718c3d2 100644 --- a/packages/amis-editor/src/renderer/event-control/helper.tsx +++ b/packages/amis-editor/src/renderer/event-control/helper.tsx @@ -984,7 +984,7 @@ export const getEventControlConfig = ( true ); const checkComponent = (node: any, action: RendererPluginAction) => { - const actionType = action.actionType; + const actionType = action.actionType!; const actions = manager?.pluginActions[node.type]; const haveChild = !!node.children?.length; let isSupport = false; diff --git a/packages/amis-editor/src/renderer/event-control/index.tsx b/packages/amis-editor/src/renderer/event-control/index.tsx index 28b2448ef..05a18b23b 100644 --- a/packages/amis-editor/src/renderer/event-control/index.tsx +++ b/packages/amis-editor/src/renderer/event-control/index.tsx @@ -2,7 +2,7 @@ import React from 'react'; import {findDOMNode} from 'react-dom'; import cx from 'classnames'; import Sortable from 'sortablejs'; -import {DataSchema, FormItem, Icon, TooltipWrapper} from 'amis'; +import {DataSchema, FormItem, Button, Icon, TooltipWrapper} from 'amis'; import cloneDeep from 'lodash/cloneDeep'; import { FormControlProps, @@ -446,7 +446,8 @@ export class EventControl extends React.Component< // 收集当前事件已有ajax动作的请求返回结果作为事件变量 let oldActions = onEvent[activeData.actionData!.eventKey].actions; if (activeData.type === 'update') { - oldActions = oldActions.slice(0, activeData.actionData!.actionIndex || oldActions?.length); + // 编辑的时候只能拿到当前动作前面动作的事件变量 + oldActions = oldActions.slice(0, activeData.actionData!.actionIndex); } const withOutputVarActions = oldActions?.filter(item => item.outputVar); @@ -458,11 +459,21 @@ export class EventControl extends React.Component< pluginActions, commonActions ); + const dataSchemaJson = getPropOfAcion( + item, + 'outputVarDataSchema', + actionTree, + pluginActions, + commonActions + ); + const dataSchema = new DataSchema(dataSchemaJson || []); return { label: `${item.outputVar ? item.outputVar + `(${actionLabel}结果)` : `${actionLabel}结果`}`, tag: 'object', - type: 'object', - value: `${item.outputVar ? ('event.data.' + item.outputVar) : 'event.data'}` + children: dataSchema.getDataPropsAsOptions()?.map(variable => ({ + ...variable, + value: variable.value.replace('${outputVar}', item.outputVar) + })) }; }); const eventVariables: ContextVariables[] = [