CONTROL_HEADER-BASE.vue.ftl 7.2 KB
Newer Older
1
<script lang='tsx'>
2
import { Vue, Component, Prop, Provide, Emit, Watch, Model,Inject } from 'vue-property-decorator';
3 4 5 6
import { CreateElement } from 'vue';
import { Subject, Subscription } from 'rxjs';
import { ControlInterface } from '@/interface/control';
import { UIActionTool,Util } from '@/utils';
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 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
<#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()/>
<#if !P.exists("importService", curAppEntity.getId(), "")>
import ${srfclassname('${curAppEntity.getCodeName()}')}UIService from '@/uiservice/${srffilepath2(curAppEntity.getCodeName())}/${srffilepath2(curAppEntity.getCodeName())}-ui-service';
</#if>
</#if>
</#list>
</#if>
<#--  语言资源入口  -->
<#ibizinclude>
./LANGBASE.vue.ftl
</#ibizinclude>
<#if import_block??>${import_block}</#if>

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

    /**
     * 名称
     *
     * @type {string}
48
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
49
     */
tony001's avatar
tony001 committed
50
    @Prop() public name?: string;
51 52 53 54 55

    /**
     * 视图通讯对象
     *
     * @type {Subject<ViewState>}
56
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
57
     */
tony001's avatar
tony001 committed
58
    @Prop() public viewState!: Subject<ViewState>;
59 60 61 62 63

    /**
     * 应用上下文
     *
     * @type {*}
64
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
65
     */
tony001's avatar
tony001 committed
66
    @Prop() public context: any;
67 68 69 70 71

    /**
     * 视图参数
     *
     * @type {*}
72
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
73
     */
tony001's avatar
tony001 committed
74
    @Prop() public viewparams: any;
75 76 77 78

    /**
     * 视图状态事件
     *
tony001's avatar
tony001 committed
79
     * @public
80
     * @type {(Subscription | undefined)}
81
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
82
     */
tony001's avatar
tony001 committed
83
    public viewStateEvent: Subscription | undefined;
84 85 86 87 88

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


<#if ctrl.getPSAppCounterRefs?? && ctrl.getPSAppCounterRefs()??>
<#assign counterRefs = ''/>
<#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}
107
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
108
     */
tony001's avatar
tony001 committed
109
    public ${srfclassname('${appCounter.getCodeName()}')}counterservice: ${srfclassname('${appCounter.getCodeName()}')}CounterService = new ${srfclassname('${appCounter.getCodeName()}')}CounterService();
110 111 112 113 114 115 116
</#if>
</#list>

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

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

    /**
     * 实体服务对象
     *
     * @type {${srfclassname('${appde.getCodeName()}')}Service}
135
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
136
     */
tony001's avatar
tony001 committed
137
    public appEntityService: ${srfclassname('${appde.getCodeName()}')}Service = new ${srfclassname('${appde.getCodeName()}')}Service({ $store: this.$store });
138 139 140 141 142 143 144 145 146 147 148 149
</#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
150
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
151
     */
tony001's avatar
tony001 committed
152
    public ${childCtrl.name}_${eventName?lower_case}($event: any, $event2?: any) {
153 154 155 156 157 158 159
    <#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()}')) {
tony001's avatar
tony001 committed
160
            this.${ctrlLogic.name}(null, '<#if ctrlLogic.getLogicTag()?length gt 0>${ctrlLogic.getLogicTag()}</#if>', $event2);
161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195
        }
        <#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
196
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
197
     */
tony001's avatar
tony001 committed
198
    public closeView(args: any): void {
199 200 201 202 203 204 205
        let _this: any = this;
        _this.$emit('closeview', [args]);
    }

    /**
     *  计数器刷新
     *
206
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
207 208 209 210 211 212 213 214 215 216 217
     */
    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();
                }
            })
        }
    }