Merge pull request #6856 from miaoxinyu01/feat-event-action-stop

fix:发送请求动作,阻断条件支持获取请求结果数据
This commit is contained in:
hsm-lv 2023-05-11 20:36:55 +08:00 committed by GitHub
commit c9eb69eacc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 16 deletions

View File

@ -232,14 +232,6 @@ export const runAction = async (
false false
); );
} }
let stopPropagation = false;
if (actionConfig.stopPropagation) {
stopPropagation = await evalExpressionWithConditionBuilder(
actionConfig.stopPropagation,
mergeData,
false
);
}
// 动作配置 // 动作配置
const args = dataMapping(actionConfig.args, mergeData, key => const args = dataMapping(actionConfig.args, mergeData, key =>
@ -249,9 +241,7 @@ export const runAction = async (
'requestAdaptor', 'requestAdaptor',
'responseData', 'responseData',
'condition' 'condition'
].includes( ].includes(key)
key
)
); );
const afterMappingData = dataMapping(actionConfig.data, mergeData); const afterMappingData = dataMapping(actionConfig.data, mergeData);
@ -278,7 +268,7 @@ export const runAction = async (
console.group?.(`run action ${actionConfig.actionType}`); console.group?.(`run action ${actionConfig.actionType}`);
console.debug(`[${actionConfig.actionType}] action args, data`, args, data); console.debug(`[${actionConfig.actionType}] action args, data`, args, data);
let stoped = false; let stopped = false;
const actionResult = await actionInstrance.run( const actionResult = await actionInstrance.run(
{ {
...actionConfig, ...actionConfig,
@ -291,7 +281,16 @@ export const runAction = async (
); );
// 二次确认弹窗如果取消,则终止后续动作 // 二次确认弹窗如果取消,则终止后续动作
if (actionConfig?.actionType === 'confirmDialog' && !actionResult) { if (actionConfig?.actionType === 'confirmDialog' && !actionResult) {
stoped = true; stopped = true;
}
let stopPropagation = false;
if (actionConfig.stopPropagation) {
stopPropagation = await evalExpressionWithConditionBuilder(
actionConfig.stopPropagation,
mergeData,
false
);
} }
console.debug(`[${actionConfig.actionType}] action end event`, event); console.debug(`[${actionConfig.actionType}] action end event`, event);
console.groupEnd?.(); console.groupEnd?.();
@ -299,5 +298,5 @@ export const runAction = async (
// 阻止原有动作执行 // 阻止原有动作执行
preventDefault && event.preventDefault(); preventDefault && event.preventDefault();
// 阻止后续动作执行 // 阻止后续动作执行
(stopPropagation || stoped) && event.stopPropagation(); (stopPropagation || stopped) && event.stopPropagation();
}; };

View File

@ -511,8 +511,13 @@ export class EventControl extends React.Component<
// 收集当前事件已有ajax动作的请求返回结果作为事件变量 // 收集当前事件已有ajax动作的请求返回结果作为事件变量
let oldActions = onEvent[activeData.actionData!.eventKey].actions; let oldActions = onEvent[activeData.actionData!.eventKey].actions;
if (activeData.type === 'update') { if (activeData.type === 'update') {
// 编辑的时候只能拿到当前动作前面动作的事件变量 // 编辑的时候只能拿到当前动作前面动作的事件变量以及当前动作事件
oldActions = oldActions.slice(0, activeData.actionData!.actionIndex); oldActions = oldActions.slice(
0,
activeData.actionData!.actionIndex !== undefined
? activeData.actionData!.actionIndex + 1
: 0
);
} }
const withOutputVarActions = oldActions?.filter(item => item.outputVar); const withOutputVarActions = oldActions?.filter(item => item.outputVar);