import { IParam, UIServiceBase } from '@core';
import { AppFrontAction, AppBackendAction } from '@core';
/**
 * {{appEntity.logicName}}UI服务对象基类
 *
 * @export
 * @class {{pascalCase appEntity.codeName}}UIServiceBase
 * @extends {UIServiceBase}
 */
export class {{pascalCase appEntity.codeName}}UIServiceBase extends UIServiceBase {

  /**
    * Creates an instance of {{pascalCase appEntity.codeName}}UIServiceBase
    * 
    * @param {*} [opts={}]
    * @memberof {{pascalCase appEntity.codeName}}UIServiceBase
    */
  constructor(opts: IParam = {}) {
      super(opts);
  }


{{!--  遍历界面行为   --}}

   public uiActionModes = {
   {{~#each appEntity.appDEUIActions as | appDEUIAction | }}
       "{{appDEUIAction.codeName}}":{
             codeName:'{{appDEUIAction.codeName}}',
             uIActionMode:'{{appDEUIAction.UIActionMode}}',
             actionTarget:'{{upperCase appDEUIAction.actionTarget}}',
             uIActionTag:'{{upperCase appDEUIAction.uIActionTag}}',
             frontPSAppView:'{{appDEUIAction.frontPSAppView}}',
             caption:'{{appDEUIAction.caption}}',
             entityCodeName:'{{appEntity.codeName}}',
             methodCodeName:'{{appDEUIAction.methodCodeName}}',
             frontProcessType:'{{appDEUIAction.frontProcessType}}',
             refreshMode:'{{appDEUIAction.refreshMode}}',
             htmlPageUrl:'{{appDEUIAction.htmlPageUrl}}',
             uILogicAttachMode:'{{appDEUIAction.uILogicAttachMode}}',
             nextActionCodeName:'{{appDEUIAction.nextActionCodeName}}',
             navContexts:{{appDEUIAction.navContexts}},
             navParams:{{appDEUIAction.navParams}}
         },
   {{/each}}
     };

  {{~#each appEntity.appDEUIActions as | appDEUIAction | }}
    /**
     * {{appDEUIAction.caption}}
     *
     * @param {*} params
     * @memberof {{pascalCase appEntity.codeName}}UIServiceBase
     */
    public async {{appDEUIAction.codeName}}(uiAction:any, params:any){
        const actionModel =  this.getUIActionModel('{{appDEUIAction.codeName}}');
      {{#eq appDEUIAction.UIActionMode 'FRONT'}}
        AppFrontAction.doAction(actionModel, params);
      {{/eq}}
      {{#eq appDEUIAction.UIActionMode 'BACKEND'}}
        AppBackendAction.doAction(actionModel, params);
      {{/eq}}
    }

  {{/each}}


}