import { actionAddins } from "."; import { IAction,IActionResult, IActionNode, IActionProperty, IField, IContext, IVarName} from "../types/ActionTypes"; /** * アクションの属性定義 */ interface IGetValueProps{ field:IField;//チェックするフィールドの対象 verName:IVarName; } /** * 正規表現チェックアクション */ export class GetValueAciton implements IAction{ name: string; actionProps: IActionProperty[]; props:IGetValueProps; constructor(){ this.name="値を取得する"; this.actionProps=[]; this.props={ field:{code:''}, verName:{name:''} } //アクションを登録する this.register(); } /** * アクションの実行を呼び出す * @param actionNode * @param event * @returns */ async process(actionNode:IActionNode,event:any,context:IContext):Promise { let result={ canNext:true, result:false }; try{ //属性設定を取得する this.actionProps=actionNode.actionProps; if (!('field' in actionNode.ActionValue) && !('verName' in actionNode.ActionValue)) { return result } this.props = actionNode.ActionValue as IGetValueProps; //条件式の計算結果を取得 const record = event.record; const value = record[this.props.field.code].value; if(this.props.verName && this.props.verName.name!==''){ context.variables[this.props.verName.name] = value; } result = { canNext:true, result:true } return result; }catch(error){ // event.error=error; // console.error(error); context.errors.handleError(error,actionNode); result.canNext=false; return result; } }; register(): void { actionAddins[this.name]=this; } } new GetValueAciton();