VIEW_CONTENT-BASE.vue.ftl 24.8 KB
Newer Older
1 2 3 4 5 6 7 8 9
<#ibizinclude>
./WF_VIEW_CONTENT.vue.ftl
</#ibizinclude>

    <#if view.getPSAppViewEngines()??>
    <#list view.getPSAppViewEngines() as engine>
    /**
     * 视图引擎
     *
10
     * @public
11 12 13
     * @type {Engine}
     * @memberof ${srfclassname('${view.name}')}Base
     */
14
    public ${engine.getName()?lower_case}: ${engine.getEngineType()}Engine = new ${engine.getEngineType()}Engine();
15 16 17 18 19 20
    </#list>
    </#if>

    /**
     * 引擎初始化
     *
21
     * @public
22 23
     * @memberof ${srfclassname('${view.name}')}Base
     */
24
    public engineInit(): void {
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
    <#if view.getPSAppViewEngines()??>
    <#list view.getPSAppViewEngines() as engine>
        this.${engine.getName()?lower_case}.init({
            view: this,
        <#if engine.getPSAppViewEngineParams()??>
            <#list engine.getPSAppViewEngineParams() as param>
            <#if param.getParamType() == "LOGIC" && param.getPSAppViewLogic()??>
            ${param.getName()?lower_case}: (args: any[],fullargs?:any[],params?: any, $event?: any, xData?: any) => {
                this.${param.getPSAppViewLogic().getName()}(args,fullargs, params, $event, xData);
            },
            </#if>
            <#if param.getParamType() == "CTRL" && param.getPSControl()??>
            ${param.getName()?lower_case}: this.$refs.${param.getPSControl().getName()},
            </#if>
            <#if param.getParamType() == "VALUE" && param.getValue()??>
            ${param.getName()?lower_case}: '${param.getValue()?c}',
            </#if>
            </#list>
        </#if>
        <#if de??>
            keyPSDEField: '${appde.getCodeName()?lower_case}',
            <#if appde.getMajorPSAppDEField()??>
            majorPSDEField: '${appde.getMajorPSAppDEField().getCodeName()?lower_case}',
            </#if>
        </#if>
            isLoadDefault: <#if view.isLoadDefault?? && !view.isLoadDefault()>false<#else>true</#if>,
        });
    </#list>
    </#if>
    }

56 57 58 59 60 61
    /**
     * 应用导航服务
     *
     * @type {*}
     * @memberof ${srfclassname('${view.name}')}Base
     */
RedPig97's avatar
RedPig97 committed
62
    public  navDataService = NavDataService.getInstance();
63

64 65 66 67 68 69 70 71 72
    /**
    * 导航服务事件
    *
    * @public
    * @type {(Subscription | undefined)}
    * @memberof ${srfclassname('${view.name}')}Base
    */
    public serviceStateEvent: Subscription | undefined;

73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
    /**
     * 门户部件状态对象
     *
     * @type {*}
     * @memberof ${srfclassname('${view.name}')}Base
     */
    @Prop() public portletState?: any;

   /**
   * 门户部件状态事件
   *
   * @public
   * @type {(Subscription | undefined)}
   * @memberof ${srfclassname('${view.name}')}Base
   */
    public portletStateEvent: Subscription | undefined;

RedPig97's avatar
RedPig97 committed
90 91 92 93 94 95 96 97 98
    /**
    * 门户部件状态事件
    *
    * @public
    * @type {(Subscription | undefined)}
    * @memberof ${srfclassname('${view.name}')}Base
    */
    public formDruipartEvent: Subscription | undefined;

99 100 101 102 103 104
    /**
     * 应用上下文
     *
     * @type {*}
     * @memberof ${srfclassname('${view.name}')}Base
     */
105
    public context:any = {};
106 107 108 109 110 111 112

    /**
     * 视图参数
     *
     * @type {*}
     * @memberof ${srfclassname('${view.name}')}Base
     */
113
    public viewparams:any = {};
114

tony001's avatar
tony001 committed
115 116 117 118 119 120 121 122
    /**
     * 视图缓存数据
     *
     * @type {*}
     * @memberof ${srfclassname('${view.name}')}Base
     */
    public viewCacheData:any;

tony001's avatar
tony001 committed
123 124 125 126 127 128 129 130 131 132 133 134 135
<#if view.getPSAppCounterRefs()??>
<#assign counterRefs = ''/>
<#list view.getPSAppCounterRefs() as singleCounterRef>
<#if singleCounterRef.getPSAppCounter()??>
<#assign appCounter = singleCounterRef.getPSAppCounter()/>
<#assign counterRefs>${counterRefs}this.${appCounter.getCodeName()?lower_case}counterservice<#if singleCounterRef_has_next>,</#if></#assign>

    /**
     * ${srfclassname('${appCounter.getCodeName()}')}CounterService计数器服务对象
     *
     * @type {${srfclassname('${appCounter.getCodeName()}')}CounterService}
     * @memberof ${srfclassname('${view.name}')}Base
     */
RedPig97's avatar
RedPig97 committed
136
    public ${appCounter.getCodeName()?lower_case}counterservice: ${srfclassname('${appCounter.getCodeName()}')}CounterService = new ${srfclassname('${appCounter.getCodeName()}')}CounterService({context:this.context,viewparams:this.viewparams});
tony001's avatar
tony001 committed
137 138 139 140 141 142 143 144 145 146 147 148
</#if>
</#list>

    /**
     * 计数器服务对象集合
     *
     * @type {Array<*>}
     * @memberof ${srfclassname('${view.name}')}Base
     */    
    public counterServiceArray:Array<any> = [${counterRefs}];
</#if>

149 150 151
    /**
     * 解析视图参数
     *
152
     * @public
153 154
     * @memberof ${srfclassname('${view.name}')}Base
     */
155
    public parseViewParam(inputvalue:any = null): void {
156 157 158
        for(let key in this.context){
            delete this.context[key];
        }
159 160 161
        if(this.$store.getters.getAppData() && this.$store.getters.getAppData().context){
            Object.assign(this.context,this.$store.getters.getAppData().context);
        }
162
        if (!this.viewDefaultUsage && this.viewdata && !Object.is(this.viewdata, '')) {
JunZai's avatar
JunZai committed
163 164 165
            if(typeof this.viewdata == 'string') {
                Object.assign(this.context, JSON.parse(this.viewdata));
            }
166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183
            if(this.context && this.context.srfparentdename){
                Object.assign(this.viewparams,{srfparentdename:this.context.srfparentdename});
            }
            if(this.context && this.context.srfparentkey){
                Object.assign(this.viewparams,{srfparentkey:this.context.srfparentkey});
            }
            this.handleCustomViewData();
            <#if self_viewparam??>
            ${self_viewparam}
            </#if>
            return;
        }
        const path = (this.$route.matched[this.$route.matched.length - 1]).path;
        const keys: Array<any> = [];
        const curReg = this.$pathToRegExp.pathToRegexp(path, keys);
        const matchArray = curReg.exec(this.$route.path);
        let tempValue: Object = {};
        keys.forEach((item: any, index: number) => {
RedPig97's avatar
RedPig97 committed
184 185 186 187 188 189
            if(matchArray[index + 1]){
                Object.defineProperty(tempValue, item.name, {
                    enumerable: true,
                    value: decodeURIComponent(matchArray[index + 1])
                });
            }
190 191
        });
        this.$viewTool.formatRouteParams(tempValue,this.$route,this.context,this.viewparams);
192
        <#if appde??>
193 194 195
        if(inputvalue){
            Object.assign(this.context,{'${appde.getCodeName()?lower_case}':inputvalue});
        }
196
        </#if>
197 198 199 200 201
        <#if view.isPSDEView()>
        //初始化视图唯一标识
        Object.assign(this.context,{srfsessionid:this.$util.createUUID()});
        </#if>
        this.handleCustomViewData();
202
        //初始化导航数据
tony001's avatar
tony001 committed
203
        this.initNavDataWithRoute();
204 205 206
        <#if self_viewparam??>
        ${self_viewparam}
        </#if>
207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244
    }

    /**
     * 处理自定义视图数据
     *
     * @memberof ${srfclassname('${view.name}')}Base
     */
	public handleCustomViewData(){
        <#if view.getPSDER1N?? && view.getPSDER1N()??>
        this.handleviewRes();
        </#if>
		if(Object.keys(this.customViewNavContexts).length > 0){
			Object.keys(this.customViewNavContexts).forEach((item:any) =>{
				let tempContext:any = {};
				let curNavContext:any = this.customViewNavContexts[item];
				this.handleCustomDataLogic(curNavContext,tempContext,item);
				Object.assign(this.context,tempContext);
			})
		}
		if(Object.keys(this.customViewParams).length > 0){
			Object.keys(this.customViewParams).forEach((item:any) =>{
				let tempParam:any = {};
				let curNavParam:any = this.customViewParams[item];
				this.handleCustomDataLogic(curNavParam,tempParam,item);
				Object.assign(this.viewparams,tempParam);
			})
		}
	}

    /**
     * 处理自定义视图数据逻辑
     *
     * @memberof ${srfclassname('${view.name}')}Base
     */
	public handleCustomDataLogic(curNavData:any,tempData:any,item:string){
		// 直接值直接赋值
		if(curNavData.isRawValue){
			if(Object.is(curNavData.value,"null") || Object.is(curNavData.value,"")){
245
                Object.defineProperty(tempData, item.toLowerCase(), {
246 247 248 249 250 251
                    value: null,
                    writable : true,
                    enumerable : true,
                    configurable : true
                });
            }else{
252
                Object.defineProperty(tempData, item.toLowerCase(), {
253 254 255 256 257 258 259 260
                    value: curNavData.value,
                    writable : true,
                    enumerable : true,
                    configurable : true
                });
            }
		}else{
			// 先从导航上下文取数,没有再从导航参数(URL)取数,如果导航上下文和导航参数都没有则为null
261
			if(this.context[(curNavData.value).toLowerCase()] != null){
262
				Object.defineProperty(tempData, item.toLowerCase(), {
263
					value: this.context[(curNavData.value).toLowerCase()],
264 265 266 267 268
					writable : true,
					enumerable : true,
					configurable : true
				});
			}else{
269
				if(this.viewparams[(curNavData.value).toLowerCase()] != null){
270
					Object.defineProperty(tempData, item.toLowerCase(), {
271
						value: this.viewparams[(curNavData.value).toLowerCase()],
272 273 274 275 276
						writable : true,
						enumerable : true,
						configurable : true
					});
				}else{
277
					Object.defineProperty(tempData, item.toLowerCase(), {
278 279 280 281 282 283 284 285 286
						value: null,
						writable : true,
						enumerable : true,
						configurable : true
					});
				}
			}
		}
	}
287 288

    /**
tony001's avatar
tony001 committed
289
     * 初始化导航数据(路由模式)
290 291 292
     *
     * @memberof ${srfclassname('${view.name}')}Base
     */
293 294
    public initNavDataWithRoute(data:any = null, isNew:boolean = false,  isAlways:boolean = false){
        if( isAlways || (this.viewDefaultUsage && Object.is(this.navModel,"route")) ){
295
            this.navDataService.addNavData({id:'${srffilepath2(view.getCodeName())}',tag:this.viewtag,srfkey:isNew ? null : <#if appde??>this.context.${appde.getCodeName()?lower_case}<#else>null</#if>,title:this.$t(this.model.srfCaption),data:data,context:this.context,viewparams:this.viewparams,path:this.$route.fullPath});
tony001's avatar
tony001 committed
296 297 298 299 300 301 302 303
        }
    }

    /**
     * 初始化导航数据(分页模式)
     *
     * @memberof ${srfclassname('${view.name}')}Base
     */
304 305
    public initNavDataWithTab(data:any = null,isOnlyAdd:boolean = true, isAlways:boolean = false){
        if( isAlways || (this.viewDefaultUsage && !Object.is(this.navModel,"route")) ){
306
            this.navDataService.addNavDataByOnly({id:'${srffilepath2(view.getCodeName())}',tag:this.viewtag,srfkey:<#if appde??>this.context.${appde.getCodeName()?lower_case}<#else>null</#if>,title:this.$t(this.model.srfCaption),data:data,context:this.context,viewparams:this.viewparams,path:this.$route.fullPath},isOnlyAdd);
307 308
        }
    }
309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331
	
    <#if view.getPSDER1N?? && view.getPSDER1N()??>
    /**
     * 处理指定视图控制关系将父键转为父实体上下文
     *
     * @memberof ${srfclassname('${view.name}')}Base
     */
    public handleviewRes(){
    <#assign viewRes = view.getPSDER1N()/>
    <#if viewRes.getMajorPSDataEntity()??>
    <#assign majorAppDataEntity = viewRes.getMajorPSDataEntity() />
    if(this.context.srfparentkey){
        Object.assign(this.context,{'${majorAppDataEntity.getCodeName()?lower_case}':this.context.srfparentkey});
    }
    </#if>
    }
    </#if>

    /**
     * Vue声明周期
     *
     * @memberof ${srfclassname('${view.name}')}Base
     */
332
    public created() {
333 334 335 336 337 338 339 340
        this.afterCreated();
    }

    /**
     * 执行created后的逻辑
     *
     * @memberof ${srfclassname('${view.name}')}Base
     */    
341
    public afterCreated(){
342
        let _this:any = this;
343 344 345 346
        const secondtag = _this.$util.createUUID();
        _this.$store.commit('viewaction/createdView', { viewtag: _this.viewtag, secondtag: secondtag });
        _this.viewtag = secondtag;
        _this.parseViewParam();
347 348 349 350
        _this.serviceStateEvent = _this.navDataService.serviceState.subscribe(({ action,name, data }:{ action:string,name:any,data:any }) => {
            if(!Object.is(name,'${srffilepath2(view.getCodeName())}')){
                return;
            }
351
            if (Object.is(action, 'viewrefresh')) {
352 353 354 355
                _this.$nextTick(()=>{
                    _this.parseViewParam(data);
                    if(_this.engine){
                        _this.engine.load();
356 357 358 359
                    }
                }); 
            }
        });
360 361
        if(_this.portletState){
            _this.portletStateEvent = _this.portletState.subscribe((res:any) =>{
362
                if(!Object.is(res.name,'${view.getName()}')){
363 364 365 366 367 368 369
                    return;
                }
                if(Object.is(res.action,'refresh') && _this.refresh && _this.refresh instanceof Function){
                    _this.refresh();
                }
            })
        }
Mosher's avatar
Mosher committed
370 371 372 373 374 375 376 377 378 379 380 381 382
        _this.initViewCtx();
<#if created_block??>
        ${created_block}
</#if>
    }

    /**
     * 初始化视图操作参数
     *
     * @memberof ${srfclassname('${view.name}')}Base
     */  
    initViewCtx() {
        Object.assign(this.viewCtx, {
Mosher's avatar
Mosher committed
383
            app: this.$root,
Mosher's avatar
Mosher committed
384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407
            view: this,
            viewGlobal: {},
            viewNavData: {},
            viewNavContext: this.context,
            viewNavParam: this.viewparams,
            messagebox: AppMessageBox.getInstance(),
        });
        Object.assign(this.viewCtx, { appGlobal: this.$store.getters.getAppGlobal() });
        if (this.$store.getters.getRouteViewGlobal(this.context.srfsessionid)) {
            Object.assign(this.viewCtx, { routeViewGlobal: this.$store.getters.getRouteViewGlobal(this.context.srfsessionid) });
        } else {
            this.$store.commit('addRouteViewGlobal', { tag: this.context.srfsessionid, param: {} });
            Object.assign(this.viewCtx, { routeViewGlobal: this.$store.getters.getRouteViewGlobal(this.context.srfsessionid) });
        }
        if (!this.viewDefaultUsage && this.viewdata && !Object.is(this.viewdata, '')) {
            //  嵌入视图
            Object.assign(this.viewCtx, {
                topview: this.$store.getters.getView(this.context.srfsessionid)
            });
        } else {
            //  顶层视图
            this.$store.commit('addView', { tag: this.context.srfsessionid, param: this });
            Object.assign(this.viewCtx, { topview: this });
        }
408 409 410 411 412 413 414
    }

    /**
     * 销毁之前
     *
     * @memberof ${srfclassname('${view.name}')}Base
     */
415
    public beforeDestroy() {
416
        this.$store.commit('viewaction/removeView', this.viewtag);
RedPig97's avatar
RedPig97 committed
417 418 419 420 421 422 423 424 425 426 427

        let _this: any = this
        if (_this.serviceStateEvent) {
            _this.serviceStateEvent.unsubscribe();
        }
        if (_this.portletStateEvent) {
            _this.portletStateEvent.unsubscribe();
        }
        if (_this.engine) {
            _this.engine.destroy();
        }
428 429 430 431 432 433 434
    }

    /**
     * Vue声明周期(组件初始化完毕)
     *
     * @memberof ${srfclassname('${view.name}')}Base
     */
435
    public mounted() {
436 437 438 439 440 441 442 443
        this.afterMounted();
    }

    /**
     * 执行mounted后的逻辑
     * 
     * @memberof ${srfclassname('${view.name}')}Base
     */
444
    public afterMounted(){
445
        const _this: any = this;
Mosher's avatar
Mosher committed
446 447 448
<#if view.getPSViewLayoutPanel()?? && !view.getPSViewLayoutPanel().isUseDefaultLayout()>
    <#assign afterMountedBlock>
        <#if view.getPSAppViewEngines()??>
Mosher's avatar
Mosher committed
449
        _this.engineInit();
Mosher's avatar
Mosher committed
450
        </#if>
Mosher's avatar
Mosher committed
451 452 453
        if (_this.loadModel && _this.loadModel instanceof Function) {
            _this.loadModel();
        }
Mosher's avatar
Mosher committed
454 455 456 457 458
        <#if mounted_block??>
        ${mounted_block}
        </#if>
    </#assign>
        _this.initLayout().then((result: any) => {
Mosher's avatar
Mosher committed
459
            _this.isLayoutLoadding = false;
Mosher's avatar
Mosher committed
460 461 462 463 464 465 466
    <#assign hasLogic = false>
    <#if view.getPSAppViewLogics?? && view.getPSAppViewLogics()??>
        <#list view.getPSAppViewLogics() as logic>
            <#if logic.getLogicTrigger?? && logic.getLogicTrigger()?? && logic.getLogicTrigger() == 'VIEWEVENT' && logic.getEventNames?? && logic.getEventNames()?? && logic.getEventNames()?index_of("onViewMounted") != -1>
                <#--  暂时只支持实体界面逻辑  -->
                <#if logic.getLogicType() == 'DEUILOGIC' && logic.getPSAppDEUILogic?? && logic.getPSAppDEUILogic()??>
                    <#assign hasLogic = true>
tony001's avatar
tony001 committed
467
            window.uiServiceRegister.getService('${logic.getPSAppDEUILogic().getPSAppDataEntity().codeName?lower_case}').then((service: any) => {
Mosher's avatar
Mosher committed
468
                service.executeUILogic('${logic.getPSAppDEUILogic().codeName}', [], this.context, this.viewparams, {}, {}, this, '${logic.getPSAppDEUILogic().getPSAppDataEntity().codeName}').then((result: any) => {
Mosher's avatar
Mosher committed
469 470 471
                    if (result && result.hasOwnProperty('srfret') && !result.srfret) {
                        return;
                    }
Mosher's avatar
Mosher committed
472
                    <@ibizindent blank=12>
Mosher's avatar
Mosher committed
473 474
                    ${afterMountedBlock}
                    </@ibizindent>
Mosher's avatar
Mosher committed
475 476
                });
            })
Mosher's avatar
Mosher committed
477 478 479 480 481
                </#if>
            </#if>
        </#list>
    </#if>
    <#if !hasLogic>
Mosher's avatar
Mosher committed
482
        <@ibizindent blank=0>
Mosher's avatar
Mosher committed
483
        ${afterMountedBlock}
Mosher's avatar
Mosher committed
484
        </@ibizindent>
Mosher's avatar
Mosher committed
485
    </#if>
486
        })
Mosher's avatar
Mosher committed
487 488 489
<#else>
    <#assign afterMountedBlock>
    <#if view.getPSAppViewEngines()??>
490
        _this.engineInit();
Mosher's avatar
Mosher committed
491
    </#if>
492 493 494
        if (_this.loadModel && _this.loadModel instanceof Function) {
            _this.loadModel();
        }
Mosher's avatar
Mosher committed
495 496 497 498 499 500 501 502 503 504 505
    <#if mounted_block??>
        ${mounted_block}
    </#if>
    </#assign>
    <#assign hasLogic = false>
    <#if view.getPSAppViewLogics?? && view.getPSAppViewLogics()??>
        <#list view.getPSAppViewLogics() as logic>
            <#if logic.getLogicTrigger?? && logic.getLogicTrigger()?? && logic.getLogicTrigger() == 'VIEWEVENT' && logic.getEventNames?? && logic.getEventNames()?? && logic.getEventNames()?index_of("onViewMounted") != -1>
                <#--  暂时只支持实体界面逻辑  -->
                <#if logic.getLogicType() == 'DEUILOGIC' && logic.getPSAppDEUILogic?? && logic.getPSAppDEUILogic()??>
                    <#assign hasLogic = true>
tony001's avatar
tony001 committed
506
            window.uiServiceRegister.getService('${logic.getPSAppDEUILogic().getPSAppDataEntity().codeName?lower_case}').then((service: any) => {
Mosher's avatar
Mosher committed
507
                service.executeUILogic('${logic.getPSAppDEUILogic().codeName}', [], this.context, this.viewparams, {}, {}, this, '${logic.getPSAppDEUILogic().getPSAppDataEntity().codeName}').then((result: any) => {
Mosher's avatar
Mosher committed
508 509 510
                    if (result && result.hasOwnProperty('srfret') && !result.srfret) {
                        return;
                    }
Mosher's avatar
Mosher committed
511
                    <@ibizindent blank=20>
Mosher's avatar
Mosher committed
512
                    ${afterMountedBlock}
Mosher's avatar
Mosher committed
513
                    </@ibizindent>
Mosher's avatar
Mosher committed
514 515
                });
            })
Mosher's avatar
Mosher committed
516 517 518 519 520
                </#if>
            </#if>
        </#list>
    </#if>
    <#if !hasLogic>
Mosher's avatar
Mosher committed
521 522 523
    <@ibizindent blank=0>
    ${afterMountedBlock}
    </@ibizindent>
Mosher's avatar
Mosher committed
524 525
    </#if>
</#if>
526 527
    }

Mosher's avatar
Mosher committed
528
<#if view.getPSControls()??>
529
    <#list view.getPSControls() as ctrl>
Mosher's avatar
Mosher committed
530 531 532
        <#if ctrl.getControlType()??>
            <#if ctrl.getHookEventNames()??>
                <#list ctrl.getHookEventNames() as eventName>
533 534 535 536 537 538 539
    /**
     * ${ctrl.name} 部件 ${eventName?lower_case} 事件
     *
     * @param {*} [args={}]
     * @param {*} $event
     * @memberof ${srfclassname('${view.name}')}Base
     */
540
    public ${ctrl.name}_${eventName?lower_case}($event: any, $event2?: any) {
Mosher's avatar
Mosher committed
541 542 543
                    <#if ctrl.getPSControlLogics(eventName)??>
                        <#list ctrl.getPSControlLogics(eventName) as ctrlLogic>
                            <#if ctrlLogic.getLogicType() == "APPVIEWENGINE" && ctrlLogic.getPSAppViewEngine()??>
544
        this.${ctrlLogic.getPSAppViewEngine().getName()}.onCtrlEvent('${ctrl.name}', '${eventName?lower_case}', $event);
Mosher's avatar
Mosher committed
545
                            <#else>
tony001's avatar
tony001 committed
546 547 548 549 550 551 552 553 554 555
                                <#assign isCtrlEvent = false>
                                <#if view.getPSAppViewLogics?? && view.getPSAppViewLogics()??>
                                    <#list view.getPSAppViewLogics() as viewLogic>
                                        <#if viewLogic.getLogicTrigger() == "CTRLEVENT" && viewLogic.name == ctrlLogic.name>
                                            <#assign isCtrlEvent = true>
                                        </#if>
                                    </#list>
                                </#if>
                                <#if isCtrlEvent>
                                    <#if ctrlLogic.getEventArg()?? && ctrlLogic.getEventArg()?length gt 0>
556
        if (Object.is($event.tag, '${ctrlLogic.getEventArg()}')) {
tony001's avatar
tony001 committed
557
            this.${ctrlLogic.name}(null, '', $event2);
558
        }
tony001's avatar
tony001 committed
559
                                    <#else>
560
        this.${ctrlLogic.name}($event, '', $event2);
tony001's avatar
tony001 committed
561
                                    </#if>
Mosher's avatar
Mosher committed
562 563 564 565
                                </#if>
                            </#if>
                        </#list>
                    </#if>
566
    }
Mosher's avatar
Mosher committed
567 568 569
                </#list>
            </#if>
        </#if>
570
    </#list>
Mosher's avatar
Mosher committed
571
</#if>
572 573 574

<#if view.getPSAppViewLogics()??>
<#list view.getPSAppViewLogics() as logic>
Mosher's avatar
Mosher committed
575
<#if logic.getLogicTrigger() == "CUSTOM" || logic.getLogicTrigger() == "CTRLEVENT">
576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602

${P.getLogicCode(logic, "LOGIC.vue").code}
</#if>
</#list>
</#if>

<#if view.getPSAppViewUIActions()??>
<#list view.getPSAppViewUIActions() as viewUIAction>
<#if viewUIAction.getPSUIAction()?? >
<#assign uiAction = viewUIAction.getPSUIAction()/>
<#if !P.exists("importService", uiAction.getFullCodeName(), "")>
<#-- 系统预置界面行为输入start -->
<#if !(uiAction.getPSAppDataEntity?? && uiAction.getPSAppDataEntity()??)>
${P.getLogicCode(uiAction, "LOGIC.vue").code}
</#if>
<#-- 系统预置界面行为输入end -->
</#if>
</#if>
</#list>
</#if>

    /**
     * 关闭视图
     *
     * @param {any[]} args
     * @memberof ${srfclassname('${view.name}')}Base
     */
603
    public closeView(args: any[]): void {
604 605
        let _view: any = this;
        if (_view.viewdata) {
606 607
            _view.$emit('viewdataschange', Array.isArray(args)?args:[args]);
            _view.$emit('close', Array.isArray(args)?args:[args]);
608 609 610 611 612 613 614 615 616 617 618 619 620 621
        } else if (_view.$tabPageExp) {
            _view.$tabPageExp.onClose(_view.$route.fullPath);
        }
    }
    <#if view.isPSDEView()>
    <#if view.getPSAppDataEntity()??>
    <#assign appDataEntity = view.getPSAppDataEntity() />
    <#if appDataEntity.isMajor()>

    /**
     * 销毁视图回调
     *
     * @memberof ${srfclassname('${view.name}')}Base
     */
622
    public destroyed(){
623 624 625 626 627 628 629 630
        this.afterDestroyed();
    }

    /**
     * 执行destroyed后的逻辑
     * 
     * @memberof ${srfclassname('${view.name}')}Base
     */
631
    public afterDestroyed(){
Mosher's avatar
Mosher committed
632 633
<#assign afterDestroyedBlock>
        if (this.viewDefaultUsage) {
634 635 636 637 638 639 640 641
            let localStoreLength = Object.keys(localStorage);
            if(localStoreLength.length > 0){
                localStoreLength.forEach((item:string) =>{
                if(item.startsWith(this.context.srfsessionid)){
                    localStorage.removeItem(item);
                }
                })
            }
642 643 644
            if(Object.is(this.navModel,"tab")){
                this.navDataService.removeNavDataByTag(this.viewtag);
            }
RedPig97's avatar
RedPig97 committed
645 646 647
        }
        if (this.serviceStateEvent) {
            this.serviceStateEvent.unsubscribe();
648
        }
649 650 651 652 653 654 655 656
        // 销毁计数器定时器
        if(this.counterServiceArray && this.counterServiceArray.length >0){
            this.counterServiceArray.forEach((item:any) =>{
                if(item.destroyCounter && item.destroyCounter instanceof Function){
                    item.destroyCounter();
                }
            })
        }
657 658 659
        if(this.portletStateEvent){
            this.portletStateEvent.unsubscribe();
        }
RedPig97's avatar
RedPig97 committed
660 661 662 663
        if (this.formDruipartEvent) {
            this.formDruipartEvent.unsubscribe();
        }
        this.viewState.complete();
Mosher's avatar
Mosher committed
664 665 666 667 668 669 670 671
</#assign>
<#assign hasLogic = false>
<#if view.getPSAppViewLogics?? && view.getPSAppViewLogics()??>
    <#list view.getPSAppViewLogics() as logic>
        <#if logic.getLogicTrigger?? && logic.getLogicTrigger()?? && logic.getLogicTrigger() == 'VIEWEVENT' && logic.getEventNames?? && logic.getEventNames()?? && logic.getEventNames()?index_of("onViewDestroyed") != -1>
            <#--  暂时只支持实体界面逻辑  -->
            <#if logic.getLogicType() == 'DEUILOGIC' && logic.getPSAppDEUILogic?? && logic.getPSAppDEUILogic()??>
                <#assign hasLogic = true>
tony001's avatar
tony001 committed
672
        window.uiServiceRegister.getService('${logic.getPSAppDEUILogic().getPSAppDataEntity().codeName?lower_case}').then((service: any) => {
Mosher's avatar
Mosher committed
673
            service.executeUILogic('${logic.getPSAppDEUILogic().codeName}', [], this.context, this.viewparams, {}, {}, this, '${logic.getPSAppDEUILogic().getPSAppDataEntity().codeName}').then((result: any) => {
Mosher's avatar
Mosher committed
674 675 676
                if (result && result.hasOwnProperty('srfret') && !result.srfret) {
                    return;
                }
Mosher's avatar
Mosher committed
677
                <@ibizindent blank=8>
Mosher's avatar
Mosher committed
678 679 680 681 682 683 684 685 686
                ${afterDestroyedBlock}
                </@ibizindent>
            });
        });
            </#if>
        </#if>
    </#list>
</#if>
<#if !hasLogic>
Mosher's avatar
Mosher committed
687 688 689
    <@ibizindent blank=0>
    ${afterDestroyedBlock}
    </@ibizindent>
Mosher's avatar
Mosher committed
690
</#if>
691 692 693 694 695 696 697 698 699
    }
    </#if>
    </#if>
    </#if>
    <#--  视图独立定义的内容start  -->
    <#if self_content??>
    ${self_content}
    </#if>
    <#--  视图独立定义的内容end  -->