CONTROL_PORTLET-HEADER-BASE.vue.ftl 7.9 KB
Newer Older
1
<script lang='tsx'>
tony001's avatar
tony001 committed
2
import { Vue, Component, Prop, Provide, Emit, Watch, Model,Inject } from 'vue-property-decorator';
3 4 5
import { CreateElement } from 'vue';
import { Subject, Subscription } from 'rxjs';
import { ControlInterface } from '@/interface/control';
6
import { UIActionTool,Util, ViewTool } from '@/utils';
tony001's avatar
tony001 committed
7
import NavDataService from '@/service/app/navdata-service';
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
<#if ctrl.getPSAppCounterRefs?? && ctrl.getPSAppCounterRefs()??>
<#list ctrl.getPSAppCounterRefs() as singleCounterRef>
<#if singleCounterRef.getPSAppCounter()??>
<#assign appCounter = singleCounterRef.getPSAppCounter()/>
import  ${srfclassname('${appCounter.getCodeName()}')}CounterService  from '@/counter/${srffilepath2(appCounter.getCodeName())}/${srffilepath2(appCounter.getCodeName())}-counter';
</#if>
</#list>
</#if>
<#if appde??>
import ${srfclassname('${appde.getCodeName()}')}Service from '@/service/${srffilepath2(appde.getCodeName())}/${srffilepath2(appde.getCodeName())}-service';
</#if>
import ${srfclassname('${ctrl.codeName}')}Service from './${srffilepath2(ctrl.codeName)}-${ctrl.getControlType()?lower_case}-service';

<#if ctrl.getPSUIActions?? && ctrl.getPSUIActions()??>
<#list ctrl.getPSUIActions() as uiAction>
<#if uiAction.getPSAppDataEntity()??>
<#assign curAppEntity = uiAction.getPSAppDataEntity()/>
25
<#if !P.exists("importService", curAppEntity.getId(), "") >
26
import ${srfclassname('${curAppEntity.getCodeName()}')}UIService from '@/uiservice/${srffilepath2(curAppEntity.getCodeName())}/${srffilepath2(curAppEntity.getCodeName())}-ui-service';
27
<#if appde?? && (curAppEntity.getId() == appde.getId())><#assign hasAppDE = true /></#if>
28 29 30 31
</#if>
</#if>
</#list>
</#if>
32 33 34
<#if appde?? && !hasAppDE??>
import ${srfclassname('${appde.getCodeName()}')}UIService from '@/uiservice/${srffilepath2(appde.getCodeName())}/${srffilepath2(appde.getCodeName())}-ui-service';
</#if>
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
<#--  语言资源入口  -->
<#ibizinclude>
./LANGBASE.vue.ftl
</#ibizinclude>
<#if import_block??>${import_block}</#if>

@Component({
    components: {
      <#if component_block??>${component_block}</#if>
    }
})
export default class <#if ctrl.getPSAppDataEntity()??>${srfclassname('${ctrl.getPSAppDataEntity().getCodeName()}')}</#if>${srfclassname('${ctrl.codeName}')}Base extends Vue implements ControlInterface {

    /**
     * 名称
     *
     * @type {string}
KK's avatar
KK committed
52
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
53
     */
54
    @Prop() public name?: string;
55 56 57 58 59

    /**
     * 视图通讯对象
     *
     * @type {Subject<ViewState>}
KK's avatar
KK committed
60
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
61
     */
62
    @Prop() public viewState!: Subject<ViewState>;
63 64 65 66 67

    /**
     * 应用上下文
     *
     * @type {*}
KK's avatar
KK committed
68
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
69
     */
70
    @Prop() public context: any;
71 72 73 74 75

    /**
     * 视图参数
     *
     * @type {*}
KK's avatar
KK committed
76
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
77
     */
78
    @Prop() public viewparams: any;
79 80 81 82

    /**
     * 视图状态事件
     *
83
     * @public
84
     * @type {(Subscription | undefined)}
KK's avatar
KK committed
85
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
86
     */
87
    public viewStateEvent: Subscription | undefined;
88 89 90 91 92

    /**
     * 获取部件类型
     *
     * @returns {string}
KK's avatar
KK committed
93
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
94
     */
95
    public getControlType(): string {
96 97 98 99 100 101 102 103 104
        return '${ctrl.getControlType()}'
    }


<#if ctrl.getPSAppCounterRefs?? && ctrl.getPSAppCounterRefs()??>
<#assign counterRefs = ''/>
<#list ctrl.getPSAppCounterRefs() as singleCounterRef>
<#if singleCounterRef.getPSAppCounter()??>
<#assign appCounter = singleCounterRef.getPSAppCounter()/>
105
    <#assign counterRefs>${counterRefs}this.${appCounter.getCodeName()?lower_case}counterservice<#if singleCounterRef_has_next>,</#if></#assign>
106 107 108 109 110
    
    /**
     * ${srfclassname('${appCounter.getCodeName()}')}CounterService计数器服务对象
     *
     * @type {${srfclassname('${appCounter.getCodeName()}')}CounterService}
KK's avatar
KK committed
111
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
112
     */
113
    public ${appCounter.getCodeName()?lower_case}counterservice: ${srfclassname('${appCounter.getCodeName()}')}CounterService = new ${srfclassname('${appCounter.getCodeName()}')}CounterService({$store: this.$store,context:this.context,viewparams:this.viewparams});
114 115 116 117 118 119 120
</#if>
</#list>

    /**
     * 计数器服务对象集合
     *
     * @type {Array<*>}
KK's avatar
KK committed
121
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
122
     */    
123
    public counterServiceArray:Array<any> = [${counterRefs}];
124 125 126 127 128 129
</#if>

    /**
     * 建构部件服务对象
     *
     * @type {${srfclassname('${ctrl.codeName}')}Service}
KK's avatar
KK committed
130
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
131
     */
132
    public service: ${srfclassname('${ctrl.codeName}')}Service = new ${srfclassname('${ctrl.codeName}')}Service({ $store: this.$store });
133 134 135 136 137 138
<#if appde??>

    /**
     * 实体服务对象
     *
     * @type {${srfclassname('${appde.getCodeName()}')}Service}
KK's avatar
KK committed
139
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
140
     */
141
    public appEntityService: ${srfclassname('${appde.getCodeName()}')}Service = new ${srfclassname('${appde.getCodeName()}')}Service({ $store: this.$store });
142 143 144 145 146 147 148 149

    /**
     * 界面UI服务对象
     *
     * @type {${srfclassname('${appde.getCodeName()}')}UIService}
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
     */  
    public appUIService:${srfclassname('${appde.getCodeName()}')}UIService = new ${srfclassname('${appde.getCodeName()}')}UIService(this.$store);
150 151 152 153 154 155 156 157 158 159 160 161
</#if>
    <#if ctrl.getPSControls?? && ctrl.getPSControls()??>
    <#list ctrl.getPSControls() as childCtrl>
    <#if childCtrl.getControlType()??>
    <#if childCtrl.getHookEventNames()??>
    <#list childCtrl.getHookEventNames() as eventName>

    /**
     * ${childCtrl.name} 部件 ${eventName?lower_case} 事件
     *
     * @param {*} [args={}]
     * @param {*} $event
KK's avatar
KK committed
162
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
163
     */
164
    public ${childCtrl.name}_${eventName?lower_case}($event: any, $event2?: any) {
165 166 167 168 169 170 171
    <#if childCtrl.getPSControlLogics(eventName)??>
    <#list childCtrl.getPSControlLogics(eventName) as ctrlLogic>
    <#if ctrlLogic.getLogicType?? && ctrlLogic.getLogicType() == "APPVIEWENGINE" && ctrlLogic.getPSAppViewEngine()??>
        this.${ctrlLogic.getPSAppViewEngine().getName()}.onCtrlEvent('${childCtrl.name}', '${eventName?lower_case}', $event);
    <#else>
        <#if ctrlLogic.getEventArg()?? && ctrlLogic.getEventArg()?length gt 0>
        if (Object.is($event.tag, '${ctrlLogic.getEventArg()}')) {
172
            this.${ctrlLogic.name}(null, '<#if ctrlLogic.getLogicTag()?length gt 0>${ctrlLogic.getLogicTag()}</#if>', $event2);
173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207
        }
        <#else>
        this.${ctrlLogic.name}($event, '<#if ctrlLogic.getLogicTag()?length gt 0>${ctrlLogic.getLogicTag()}</#if>', $event2);
        </#if>
    </#if>
    </#list>
    </#if>
    }
    </#list>
    </#if>
    </#if>
    </#list>
    </#if>
    
<#if ctrl.getPSAppViewLogics?? && ctrl.getPSAppViewLogics()??>
<#list ctrl.getPSAppViewLogics() as logic>
<#if logic.getLogicTrigger() == "CUSTOM" || logic.getLogicTrigger() == "CTRLEVENT">

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

<#if ctrl.getPSUIActions?? && ctrl.getPSUIActions()??>
<#list ctrl.getPSUIActions() as uiAction>
<#if !uiAction.getPSAppDataEntity()??>
${P.getLogicCode(uiAction, "LOGIC.vue").code}
</#if>
</#list>
</#if>

    /**
     * 关闭视图
     *
     * @param {any} args
KK's avatar
KK committed
208
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
209
     */
210
    public closeView(args: any): void {
211 212 213 214 215 216 217
        let _this: any = this;
        _this.$emit('closeview', [args]);
    }

    /**
     *  计数器刷新
     *
KK's avatar
KK committed
218
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
219 220 221 222 223 224 225 226 227 228 229
     */
    public counterRefresh(){
        const _this:any =this;
        if(_this.counterServiceArray && _this.counterServiceArray.length >0){
            _this.counterServiceArray.forEach((item:any) =>{
                if(item.refreshData && item.refreshData instanceof Function){
                    item.refreshData();
                }
            })
        }
    }