ErrorShowNewVer

This commit is contained in:
wtl
2024-02-06 15:33:47 +09:00
parent 3e73799532
commit a614d754f4
2 changed files with 16 additions and 13 deletions

View File

@@ -2,7 +2,9 @@
import { actionAddins } from "."; import { actionAddins } from ".";
import { IAction, IActionProperty, IActionNode, IContext, IActionResult } from "../types/ActionTypes"; import { IAction, IActionProperty, IActionNode, IContext, IActionResult } from "../types/ActionTypes";
import { ConditionTree } from '../types/Conditions'; import { ConditionTree } from '../types/Conditions';
/**
* アクションの属性定義
*/
interface IErrorShowProps { interface IErrorShowProps {
message: string; message: string;
condition: string; condition: string;
@@ -10,16 +12,16 @@ interface IErrorShowProps {
export class ErrorShowAction implements IAction { export class ErrorShowAction implements IAction {
name: string; name: string;
actionProps: IActionProperty[]; actionProps: IActionProperty[]; //调用从import导入关于显示类的定义
props: IErrorShowProps; props: IErrorShowProps;//从上方的interface 定义这个props所需要接受的属性
constructor() { constructor() { //解构函数定义需要的类名
this.name = "エラー表示"; this.name = "エラー表示";
this.actionProps = []; this.actionProps = [];
this.props = { this.props = {
message: '', message: '',
condition: '' condition: ''
} }
this.register(); this.register(); //重置以上注册表
} }
/** /**
@@ -28,17 +30,17 @@ export class ErrorShowAction implements IAction {
* @param event * @param event
* @returns * @returns
*/ */
async process(actionNode: IActionNode, event: any, context: IContext): Promise<IActionResult> { async process(actionNode: IActionNode, event: any, context: IContext): Promise<IActionResult> { //异步处理某函数下的xx属性
let result = { let result = { //定义一个能否继续往下实行的开关
canNext: true, canNext: true,
result: false result: false
}; };
try { try { //尝试执行以下代码部分
this.actionProps = actionNode.actionProps; this.actionProps = actionNode.actionProps;
if (!('message' in actionNode.ActionValue) && !('condition' in actionNode.ActionValue)) { if (!('message' in actionNode.ActionValue) && !('condition' in actionNode.ActionValue)) { //如果message以及condition两者都不存在的情况下return
return result return result
} }
this.props = actionNode.ActionValue as IErrorShowProps; this.props = actionNode.ActionValue as IErrorShowProps; //将TS的action.actionvalue as转换为interface需要且定义的js部分
const conditionResult = this.getConditionResult(context); const conditionResult = this.getConditionResult(context);
if (conditionResult) { if (conditionResult) {
event.error = this.props.message event.error = this.props.message

View File

@@ -3,6 +3,7 @@ import { actionAddins } from "../actions";
import '../actions/must-input'; import '../actions/must-input';
import '../actions/auto-numbering'; import '../actions/auto-numbering';
import '../actions/field-shown'; import '../actions/field-shown';
import '../actions/error-show';
import { ActionFlow,IActionFlow, IActionResult,IContext } from "./ActionTypes"; import { ActionFlow,IActionFlow, IActionResult,IContext } from "./ActionTypes";
export class ActionProcess{ export class ActionProcess{