import { Verify } from '@/utils/verify/verify';


/**
 * 根据父获取草稿
 *
 * @export
 * @class DraftByParentLogicBase
 */
export default class DraftByParentLogicBase {

    /**
     * 名称
     * 
     * @memberof  DraftByParentLogicBase
     */
    private name:string ="DraftByParent";

    /**
     * 唯一标识
     * 
     * @memberof  DraftByParentLogicBase
     */
    private id:string = "353407EB-4915-406A-90B8-E6CAB8338687";

    /**
     * 默认参数名称
     * 
     * @memberof  DraftByParentLogicBase
     */
    private defaultParamName:string = "Default";

    /**
     * 参数集合
     * 
     * @memberof  DraftByParentLogicBase
     */
    private paramsMap:Map<string,any> = new Map();

    /**
     * Creates an instance of  DraftByParentLogicBase.
     * 
     * @param {*} [opts={}]
     * @memberof  DraftByParentLogicBase
     */
    constructor(opts: any = {}) {
        this.initParams(opts);
    }

    /**
     * 初始化参数集合
     * 
     * @param {*} [opts={}]
     * @memberof  DraftByParentLogicBase
     */
    public initParams(opts:any){
        this.paramsMap.set('Default',opts);
    }


    /**
     * 计算0节点结果
     * 
     * @param params 传入参数
     */
    public compute0Cond(params:any):boolean{
        return true;
    }

    /**
     * 执行逻辑
     * 
     * @param context 应用上下文
     * @param params 传入参数
     */
    public onExecute(context:any,params:any,isloading:boolean){
        return this.executeBegin(context,params,isloading);
    }


    /**
    * 获取父数据
    * 
    * @param context 应用上下文
    * @param params 传入参数
    */
    private async executePrepareparam1(context:any,params:any,isloading:boolean){
        // 准备参数节点
    let tempDstParam0Context:any = this.paramsMap.get('Default').context?this.paramsMap.get('Default').context:{};
    let tempDstParam0Data:any = this.paramsMap.get('Default').data?this.paramsMap.get('Default').data:{};
    this.paramsMap.set('Default',{data:tempDstParam0Data,context:tempDstParam0Context});
        return this.paramsMap.get(this.defaultParamName).data;
    }

    /**
    * 开始
    * 
    * @param params 传入参数
    */
    private async executeBegin(context:any,params:any,isloading:boolean){
        //开始节点
        if(this.compute0Cond(params)){
            return this.executePrepareparam1(context,params,isloading);   
        }
    }


}