CONTROL-BASE.vue.ftl 6.3 KB
Newer Older
ibizdev's avatar
ibizdev committed
1 2 3 4
<#ibizinclude>
./CONTROL-BASE.template.ftl
</#ibizinclude>

5 6 7 8 9 10 11 12 13 14 15 16
<#assign import_block>
<#--  计数器服务  -->
<#if ctrl.getPSAppCounterRefs?? && ctrl.getPSAppCounterRefs()??>
<#list ctrl.getPSAppCounterRefs() as singleCounterRef>
<#if singleCounterRef.getPSAppCounter()??>
<#assign appCounter = singleCounterRef.getPSAppCounter()/>
import  ${srfclassname('${appCounter.getCodeName()}')}CounterService  from '@/app-core/counter/${srffilepath2(appCounter.getCodeName())}/${srffilepath2(appCounter.getCodeName())}-counter';
</#if>
</#list>
</#if>
</#assign>

ibizdev's avatar
ibizdev committed
17 18 19
<#ibizinclude>
../@MACRO/CONTROL/CONTROL_HEADER-BASE.vue.ftl
</#ibizinclude>
20
<#assign counterRefs = ''/>
KK's avatar
KK committed
21
<#if ctrl.getPSAppCounterRefs?? && ctrl.getPSAppCounterRefs()??>
22 23 24 25 26 27 28 29 30 31 32
<#list ctrl.getPSAppCounterRefs() as singleCounterRef>
<#if singleCounterRef.getPSAppCounter()??>
<#assign appCounter = singleCounterRef.getPSAppCounter()/>
    <#assign counterRefs>${counterRefs}this.${srfclassname('${appCounter.getCodeName()}')}counterservice<#if singleCounterRef_has_next>,</#if></#assign>
    
    /**
     * ${srfclassname('${appCounter.getCodeName()}')}CounterService计数器服务对象
     *
     * @type {${srfclassname('${appCounter.getCodeName()}')}CounterService}
     * @memberof ${srfclassname('${ctrl.codeName}')}
     */
KK's avatar
KK committed
33
    protected ${srfclassname('${appCounter.getCodeName()}')}counterservice: ${srfclassname('${appCounter.getCodeName()}')}CounterService = new ${srfclassname('${appCounter.getCodeName()}')}CounterService({$store: this.$store,context:this.context,viewparams:this.viewparams});
34 35
</#if>
</#list>
KK's avatar
KK committed
36
</#if>
37 38 39 40 41 42 43 44 45

    /**
     * 计数器服务对象集合
     *
     * @type {Array<*>}
     * @memberof ${srfclassname('${ctrl.codeName}')}
     */    
    protected counterServiceArray:Array<any> = [${counterRefs}];

KK's avatar
KK committed
46 47 48 49 50 51 52 53 54
    /**
     * 加载计数器数据
     *
     * @param {any[]} args
     * @memberof ProdMobTabExpViewtabexppanel
     */
    public async loadCounterData() {
       this.$emit("counterInit",this.counterServiceArray[0]);
    }
KK's avatar
KK committed
55 56 57 58 59 60 61 62 63 64 65 66

    /**
     * 销毁计数器服务
     *
     * @memberof ${srfclassname('${view.name}')}
     */   
    public counterserviceDestroy(){
        this.counterServiceArray.forEach((item:any)=>{
            item.destroyCounter();
        });
    }

ibizdev's avatar
ibizdev committed
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101
    /**
     * 获取多项数据
     *
     * @returns {any[]}
     * @memberof ${srfclassname('${ctrl.codeName}')}
     */
    public getDatas(): any[] {
        return [];
    }

    /**
     * 获取单项树
     *
     * @returns {*}
     * @memberof ${srfclassname('${ctrl.codeName}')}
     */
    public getData(): any {
        return null;
    }

    /**
     * 行为参数
     *
     * @protected
     * @type {*}
     * @memberof ${srfclassname('${ctrl.codeName}')}
     */
    protected action:any = '';

    /**
     * 被激活的分页面板
     *
     * @type {string}
     * @memberof ${srfclassname('${ctrl.codeName}')}
     */
102
    @Prop({ default: '<#list ctrl.getPSControls() as tabviewpanel><#if tabviewpanel_index==0>${tabviewpanel.name}</#if></#list>' }) protected activiedTabViewPanel?: string;     
103 104 105 106 107 108 109 110 111

    /**
     * 是否开启点击重新渲染
     *
     * @type {string}
     * @memberof ${srfclassname('${ctrl.codeName}')}
     */
    @Prop({ default: true }) public isEnableReRender?:boolean;    

ibizdev's avatar
ibizdev committed
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137
    /**
     * vue 生命周期
     *
     * @returns
     * @memberof ${srfclassname('${ctrl.codeName}')}
     */
    protected created() {
        this.afterCreated();
    }

    /**
     * 执行created后的逻辑
     *
     *  @memberof ${srfclassname('${ctrl.codeName}')}
     */    
    protected afterCreated(){
        if (this.viewState) {
            this.viewStateEvent = this.viewState.subscribe(({ tag, action, data }) => {
                if (!Object.is(tag, this.name)) {
                    return;
                }
                this.action = action;
                if (data.activeItem) {
                    this.tabPanelClick(data.activeItem);
                } else {
                    this.$nextTick(() => {
KK's avatar
KK committed
138 139 140 141
                     let panel:any = this.activiedTabViewPanel
                     if(panel){
                     this.viewState.next({ tag: panel, action: this.action, data: {}});
                    }
ibizdev's avatar
ibizdev committed
142 143 144 145 146 147
                    });
                }
            });
        }
    }    

KK's avatar
KK committed
148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166
    /**
     * vue 生命周期
     *
     * @returns
     * @memberof ${srfclassname('${ctrl.codeName}')}
     */
    public mounted() {
        this.afterMounted();
    }
    
    /**
     * 执行mounted后的逻辑
     *
     * @memberof ${srfclassname('${ctrl.codeName}')}
     */
    public afterMounted(){
        this.loadCounterData();
    }

ibizdev's avatar
ibizdev committed
167 168 169 170 171 172 173 174 175 176 177 178 179 180 181
    /**
     * vue 生命周期
     *
     * @memberof ${srfclassname('${ctrl.codeName}')}
     */
    protected destroyed() {
        this.afterDestroy();
    }

    /**
     * 执行destroyed后的逻辑
     *
     * @memberof ${srfclassname('${ctrl.codeName}')}
     */
    protected afterDestroy() {
KK's avatar
KK committed
182
        this.counterserviceDestroy();
ibizdev's avatar
ibizdev committed
183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204
        if (this.viewStateEvent) {
            this.viewStateEvent.unsubscribe();
        }
        <#if destroyed_block??>
        ${destroyed_block}
        </#if>
    }

    /**
     * 分页面板选中
     *
     * @param {*} $event
     * @returns
     * @memberof ${srfclassname('${ctrl.codeName}')}
     */
    protected tabPanelClick($event: any) {
        if (!$event) {
            return;
        }
        if (!this.viewState) {
            return;
        }
205
        this.$emit("changepanel",$event);
ibizdev's avatar
ibizdev committed
206
        this.$nextTick(() => {
KK's avatar
KK committed
207 208 209
            let panel:any = this.activiedTabViewPanel
            if(panel){
              this.viewState.next({ tag: panel, action: this.action, data: {}});
210
            }
211
            if (this.isEnableReRender) {         
212 213 214 215 216 217 218 219 220
              if (panel) {
                let panelarr:any = Object.keys(this.$refs);
                panelarr.splice(panelarr.findIndex((item:any) => item === panel), 1);
                panelarr.forEach((item:any,index:number)=>{
                  let tabviewpanel:any = this.$refs[item];
                  if (tabviewpanel.isActivied) {
                    tabviewpanel.isActivied = false;
                  }
                })
221
              }
222
            }
ibizdev's avatar
ibizdev committed
223 224 225 226 227 228 229 230 231 232 233 234
        });
    }



<#ibizinclude>
../@MACRO/CONTROL/CONTROL_BOTTOM-BASE.vue.ftl
</#ibizinclude>

<#ibizinclude>
../@MACRO/CONTROL/CONTROL-BASE.style.ftl
</#ibizinclude>