From 4fbd0e3a253ef1a8eb8d48aef6724664d9aa02ee Mon Sep 17 00:00:00 2001 From: pianruijie Date: Tue, 26 Jul 2022 10:30:13 +0800 Subject: [PATCH 1/3] =?UTF-8?q?ajax=E5=8A=A8=E4=BD=9C=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E5=8F=AF=E8=A7=86=E5=8C=96=E9=80=89=E6=8B=A9=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E3=80=81=E6=8F=90=E7=A4=BA=E3=80=81=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I1ae1c2251578b2b2ef8a3d5a7900b0d764f3502d --- .../src/renderer/event-control/actions.tsx | 12 +++------ .../src/renderer/event-control/index.tsx | 25 ++++++++++++++++--- 2 files changed, 24 insertions(+), 13 deletions(-) diff --git a/packages/amis-editor/src/renderer/event-control/actions.tsx b/packages/amis-editor/src/renderer/event-control/actions.tsx index fbcf70e0e..d3c063cb7 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,10 @@ const ACTION_TYPE_TREE = (manager: any): RendererPluginAction[] => { type: 'checkbox', name: 'silent', option: '静默模式', - remark: { - className: 'ae-BaseRemark', - icon: 'fa fa-question-circle', - trigger: ['hover', 'click'], - placement: 'left', - content: '勾选后,服务请求将以静默模式发送,即不会弹出成功或报错提示。' - }, mode: 'inline', className: 'm-r-none', - value: false + value: false, + remark: BaseLabelMark('勾选后,服务请求将以静默模式发送,即不会弹出成功或报错提示。') } ] } diff --git a/packages/amis-editor/src/renderer/event-control/index.tsx b/packages/amis-editor/src/renderer/event-control/index.tsx index 28b2448ef..5d1cdb7c9 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); @@ -461,8 +462,24 @@ export class EventControl extends React.Component< return { label: `${item.outputVar ? item.outputVar + `(${actionLabel}结果)` : `${actionLabel}结果`}`, tag: 'object', - type: 'object', - value: `${item.outputVar ? ('event.data.' + item.outputVar) : 'event.data'}` + children: [ + { + label: `请求结果数据`, + tag: 'object', + type: 'object', + value: `${item.outputVar ? ('event.data.' + item.outputVar) : 'event.data.responseResult'}.data` + }, + { + label: `请求结果状态`, + tag: 'number', + value: `${item.outputVar ? ('event.data.' + item.outputVar) : 'event.data.responseResult'}.status` + }, + { + label: `请求结果消息`, + tag: 'string', + value: `${item.outputVar ? ('event.data.' + item.outputVar) : 'event.data.responseResult'}.msg` + } + ] }; }); const eventVariables: ContextVariables[] = [ From f106e0ac4596f2aa7c671cd960a79e1425f7d0dd Mon Sep 17 00:00:00 2001 From: pianruijie Date: Tue, 26 Jul 2022 15:20:39 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E5=8F=AF=E8=A7=86=E5=8C=96=E9=80=89?= =?UTF-8?q?=E6=8B=A9=E8=AF=B7=E6=B1=82=E7=BB=93=E6=9E=9C=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E3=80=81=E7=8A=B6=E6=80=81=E3=80=81=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I048017d1772e31e20cab183f5a5ba46fcf7e9801 --- .../src/renderer/event-control/actions.tsx | 29 +++++++++++++++-- .../src/renderer/event-control/index.tsx | 32 ++++++++----------- 2 files changed, 40 insertions(+), 21 deletions(-) diff --git a/packages/amis-editor/src/renderer/event-control/actions.tsx b/packages/amis-editor/src/renderer/event-control/actions.tsx index d3c063cb7..befe0214b 100644 --- a/packages/amis-editor/src/renderer/event-control/actions.tsx +++ b/packages/amis-editor/src/renderer/event-control/actions.tsx @@ -453,7 +453,13 @@ const ACTION_TYPE_TREE = (manager: any): RendererPluginAction[] => { mode: 'inline', className: 'm-r-none', value: false, - remark: BaseLabelMark('勾选后,服务请求将以静默模式发送,即不会弹出成功或报错提示。') + remark: { + className: 'ae-BaseRemark', + icon: 'fa fa-question-circle', + shape: "circle", + placement: "left", + content: '勾选后,服务请求将以静默模式发送,即不会弹出成功或报错提示。' + } } ] } @@ -471,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: '下载文件', diff --git a/packages/amis-editor/src/renderer/event-control/index.tsx b/packages/amis-editor/src/renderer/event-control/index.tsx index 5d1cdb7c9..05a18b23b 100644 --- a/packages/amis-editor/src/renderer/event-control/index.tsx +++ b/packages/amis-editor/src/renderer/event-control/index.tsx @@ -446,7 +446,7 @@ 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); } @@ -459,27 +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', - children: [ - { - label: `请求结果数据`, - tag: 'object', - type: 'object', - value: `${item.outputVar ? ('event.data.' + item.outputVar) : 'event.data.responseResult'}.data` - }, - { - label: `请求结果状态`, - tag: 'number', - value: `${item.outputVar ? ('event.data.' + item.outputVar) : 'event.data.responseResult'}.status` - }, - { - label: `请求结果消息`, - tag: 'string', - value: `${item.outputVar ? ('event.data.' + item.outputVar) : 'event.data.responseResult'}.msg` - } - ] + children: dataSchema.getDataPropsAsOptions()?.map(variable => ({ + ...variable, + value: variable.value.replace('${outputVar}', item.outputVar) + })) }; }); const eventVariables: ContextVariables[] = [ From 0ca61174e55810b2e07c3e58e4777e801b621ee3 Mon Sep 17 00:00:00 2001 From: hsm-lv Date: Fri, 29 Jul 2022 14:36:41 +0800 Subject: [PATCH 3/3] =?UTF-8?q?fix:=E4=BF=AE=E5=A4=8D=E4=B8=8B=E8=BD=BD?= =?UTF-8?q?=E8=AF=B7=E6=B1=82=E5=8A=A8=E4=BD=9C=E6=A0=B7=E5=BC=8F&ts?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I82130adce5d0d5fa370b885b3baed7fa6e79e39e --- packages/amis-editor/src/renderer/event-control/actions.tsx | 6 +++++- packages/amis-editor/src/renderer/event-control/helper.tsx | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/amis-editor/src/renderer/event-control/actions.tsx b/packages/amis-editor/src/renderer/event-control/actions.tsx index befe0214b..a286bdc2f 100644 --- a/packages/amis-editor/src/renderer/event-control/actions.tsx +++ b/packages/amis-editor/src/renderer/event-control/actions.tsx @@ -509,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 29d9132c4..392dbc645 100644 --- a/packages/amis-editor/src/renderer/event-control/helper.tsx +++ b/packages/amis-editor/src/renderer/event-control/helper.tsx @@ -976,7 +976,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;