import { Subject } from 'rxjs';
import { PickupGridViewBase } from '@/studio-core';
import EAMPRODUCTService from '@/service/eamproduct/eamproduct-service';
import EAMPRODUCTAuthService from '@/authservice/eamproduct/eamproduct-auth-service';
import PickupGridViewEngine from '@engine/view/pickup-grid-view-engine';
import EAMPRODUCTUIService from '@/uiservice/eamproduct/eamproduct-ui-service';

/**
 * 产品选择表格视图视图基类
 *
 * @export
 * @class EAMPRODUCTPickupGridViewBase
 * @extends {PickupGridViewBase}
 */
export class EAMPRODUCTPickupGridViewBase extends PickupGridViewBase {
    /**
     * 视图对应应用实体名称
     *
     * @protected
     * @type {string}
     * @memberof EAMPRODUCTPickupGridViewBase
     */
    protected appDeName: string = 'eamproduct';

    /**
     * 应用实体主键
     *
     * @protected
     * @type {string}
     * @memberof EAMPRODUCTPickupGridViewBase
     */
    protected appDeKey: string = 'productid';

    /**
     * 应用实体主信息
     *
     * @protected
     * @type {string}
     * @memberof EAMPRODUCTPickupGridViewBase
     */
    protected appDeMajor: string = 'productname';

    /**
     * 实体服务对象
     *
     * @type {EAMPRODUCTService}
     * @memberof EAMPRODUCTPickupGridViewBase
     */
    protected appEntityService: EAMPRODUCTService = new EAMPRODUCTService;

    /**
     * 实体权限服务对象
     *
     * @type EAMPRODUCTUIService
     * @memberof EAMPRODUCTPickupGridViewBase
     */
    public appUIService: EAMPRODUCTUIService = new EAMPRODUCTUIService(this.$store);


    /**
     * 计数器服务对象集合
     *
     * @protected
     * @type {Array<*>}
     * @memberof EAMPRODUCTPickupGridViewBase
     */    
    protected counterServiceArray: Array<any> = [];

    /**
     * 视图模型数据
     *
     * @protected
     * @type {*}
     * @memberof EAMPRODUCTPickupGridViewBase
     */
    protected model: any = {
        srfCaption: 'entities.eamproduct.views.pickupgridview.caption',
        srfTitle: 'entities.eamproduct.views.pickupgridview.title',
        srfSubTitle: 'entities.eamproduct.views.pickupgridview.subtitle',
        dataInfo: ''
    }

    /**
     * 容器模型
     *
     * @protected
     * @type {*}
     * @memberof EAMPRODUCTPickupGridViewBase
     */
    protected containerModel: any = {
        view_grid: { name: 'grid', type: 'GRID' },
        view_searchform: { name: 'searchform', type: 'SEARCHFORM' },
    };


	/**
     * 视图唯一标识
     *
     * @protected
     * @type {string}
     * @memberof ViewBase
     */
	protected viewtag: string = 'a0c0a1e17b2f207a526c5e4240267b11';


    /**
     * 视图引擎
     *
     * @public
     * @type {Engine}
     * @memberof EAMPRODUCTPickupGridViewBase
     */
    public engine: PickupGridViewEngine = new PickupGridViewEngine();

    /**
     * 引擎初始化
     *
     * @public
     * @memberof EAMPRODUCTPickupGridViewBase
     */
    public engineInit(): void {
        this.engine.init({
            view: this,
            grid: this.$refs.grid,
            searchform: this.$refs.searchform,
            keyPSDEField: 'eamproduct',
            majorPSDEField: 'productname',
            isLoadDefault: true,
        });
    }

    /**
     * grid 部件 selectionchange 事件
     *
     * @param {*} [args={}]
     * @param {*} $event
     * @memberof EAMPRODUCTPickupGridViewBase
     */
    public grid_selectionchange($event: any, $event2?: any): void {
        this.engine.onCtrlEvent('grid', 'selectionchange', $event);
    }

    /**
     * grid 部件 beforeload 事件
     *
     * @param {*} [args={}]
     * @param {*} $event
     * @memberof EAMPRODUCTPickupGridViewBase
     */
    public grid_beforeload($event: any, $event2?: any): void {
        this.engine.onCtrlEvent('grid', 'beforeload', $event);
    }

    /**
     * grid 部件 rowdblclick 事件
     *
     * @param {*} [args={}]
     * @param {*} $event
     * @memberof EAMPRODUCTPickupGridViewBase
     */
    public grid_rowdblclick($event: any, $event2?: any): void {
        this.engine.onCtrlEvent('grid', 'rowdblclick', $event);
    }

    /**
     * grid 部件 load 事件
     *
     * @param {*} [args={}]
     * @param {*} $event
     * @memberof EAMPRODUCTPickupGridViewBase
     */
    public grid_load($event: any, $event2?: any): void {
        this.engine.onCtrlEvent('grid', 'load', $event);
    }

    /**
     * searchform 部件 save 事件
     *
     * @param {*} [args={}]
     * @param {*} $event
     * @memberof EAMPRODUCTPickupGridViewBase
     */
    public searchform_save($event: any, $event2?: any): void {
        this.engine.onCtrlEvent('searchform', 'save', $event);
    }

    /**
     * searchform 部件 search 事件
     *
     * @param {*} [args={}]
     * @param {*} $event
     * @memberof EAMPRODUCTPickupGridViewBase
     */
    public searchform_search($event: any, $event2?: any): void {
        this.engine.onCtrlEvent('searchform', 'search', $event);
    }

    /**
     * searchform 部件 load 事件
     *
     * @param {*} [args={}]
     * @param {*} $event
     * @memberof EAMPRODUCTPickupGridViewBase
     */
    public searchform_load($event: any, $event2?: any): void {
        this.engine.onCtrlEvent('searchform', 'load', $event);
    }



    /**
     * 是否展开搜索表单
     *
     * @protected
     * @type {boolean}
     * @memberof EAMPRODUCTPickupGridViewBase
     */
    protected isExpandSearchForm: boolean = true;


}