
<template>
<div class="view-container deredirectview ormerporgredirect-view">
    <app-studioaction :viewTitle="$t(model.srfTitle)" viewName="ormerporgredirectview"></app-studioaction>
</div>
</template>

<script lang='tsx'>
import { Vue, Component, Prop, Provide, Emit, Watch } from 'vue-property-decorator';
import { Subject } from 'rxjs';
import { UIActionTool, Util } from '@/utils';
import { VueLifeCycleProcessing, WizardViewBase } from '@/crm-core';
import OrmErporgService from '@/service/orm-erporg/orm-erporg-service';


import UIService from '@/uiservice/ui-service';


/**
 * ERP组织中间表数据重定向视图基类
 *
 * @export
 * @class ORMERPORGRedirectViewBase
 * @extends {WizardViewBase}
 */
@Component({})
@VueLifeCycleProcessing
export default class ORMERPORGRedirectViewBase extends WizardViewBase {

    /**
     * 实体服务对象
     *
     * @type {OrmErporgService}
     * @memberof ORMERPORGRedirectViewBase
     */
    public appEntityService: OrmErporgService = new OrmErporgService;


    /**
     * 计数器服务对象集合
     *
     * @type {Array<*>}
     * @memberof ORMERPORGRedirectViewBase
     */    
    public counterServiceArray:Array<any> = [];
    
    /**
     * 数据变化
     *
     * @param {*} val
     * @returns {*}
     * @memberof ORMERPORGRedirectViewBase
     */
    @Emit() 
    public viewDatasChange(val: any):any {
        return val;
    }

	/**
	 * 视图标识
	 *
	 * @type {string}
	 * @memberof ORMERPORGRedirectViewBase
	 */
	public viewtag: string = '1fef71f1e23036a7e81221e7265773c0';

    /**
     * 父数据对象
     *
     * @protected
     * @type {*}
     * @memberof ORMERPORGRedirectViewBase
     */
    protected srfparentdata: any = {};

	/**
	 * 自定义视图导航上下文集合
	 *
	 * @type {*}
	 * @memberof ORMERPORGRedirectViewBase
	 */
    public customViewNavContexts:any ={
    };

	/**
	 * 自定义视图导航参数集合
	 *
	 * @type {*}
	 * @memberof ORMERPORGRedirectViewBase
	 */
    public customViewParams:any ={
    };

    /**
     * 视图模型数据
     *
     * @type {*}
     * @memberof ORMERPORGRedirectViewBase
     */
    public model: any = {
        srfCaption: 'entities.ormerporg.views.redirectview.caption',
        srfTitle: 'entities.ormerporg.views.redirectview.title',
        srfSubTitle: 'entities.ormerporg.views.redirectview.subtitle',
        dataInfo: ''
    }

    /**
     * 容器模型
     *
     * @type {*}
     * @memberof ORMERPORGRedirectViewBase
     */
    public containerModel: any = {
    };

    /**
     * 视图状态订阅对象
     *
     * @public
     * @type {Subject<{action: string, data: any}>}
     * @memberof ORMERPORGRedirectViewBase
     */
    public viewState: Subject<ViewState> = new Subject();


	

    /**
     * 引擎初始化
     *
     * @public
     * @memberof ORMERPORGRedirectViewBase
     */
    public engineInit(): void {
    }





    /**
     * 销毁视图回调
     *
     * @memberof ORMERPORGRedirectViewBase
     */
    public destroyed(){
        if(this.viewDefaultUsage){
            let localStoreLength = Object.keys(localStorage);
            if(localStoreLength.length > 0){
                localStoreLength.forEach((item:string) =>{
                if(item.startsWith(this.context.srfsessionid)){
                    localStorage.removeItem(item);
                }
                })
            }
        }
    }
        /**
     * 初始化视图
     *
     * @memberof ORMERPORGRedirectViewBase
     */    
    public async viewInit(){
        const {srfkey:srfkey,srfappde:srfappde} = this.viewparams;
        const uiService:UIService = new UIService();
        const targetService:any = await uiService.getService(srfappde.toLowerCase());
        targetService.getRDAppView(srfkey,true).then((res:any) =>{
            if(res && res.viewname && res.srfappde){
                const path:string =`/${res.srfappde}/${srfkey}/${res.viewname}`;
                this.$router.push({path:path});
            }else{
                console.error("未查找到重定向视图")
            }
        })
    }


}
</script>

<style lang='less'>
@import './ormerporgredirect-view.less';
</style>