VIEW_HEADER-BASE.vue.ftl 9.4 KB
Newer Older
1
<script lang='tsx'>
2
import { Vue, Component, Prop, Provide, Emit, Watch,Inject } from 'vue-property-decorator';
3
import { UIActionTool,Util } from '@/utils';
4
import NavDataService from '@/service/app/navdata-service';
5 6 7 8 9 10 11 12
<#if view.getPSAppCounterRefs()??>
<#list view.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>
13
import { Subject,Subscription } from 'rxjs';
14 15 16
<#if view.getPSAppDataEntity?? && view.getPSAppDataEntity()??>
<#assign appde = view.getPSAppDataEntity()/>
import ${srfclassname('${appde.getCodeName()}')}Service from '@/service/${srffilepath2(appde.getCodeName())}/${srffilepath2(appde.getCodeName())}-service';
tony001's avatar
tony001 committed
17
import ${srfclassname('${appde.getCodeName()}')}AuthService from '@/authservice/${srffilepath2(appde.getCodeName())}/${srffilepath2(appde.getCodeName())}-auth-service';
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
</#if>

<#if view.getPSAppViewEngines()??>
<#list view.getPSAppViewEngines() as engine>
import ${engine.getEngineType()}Engine from '@engine/${engine.getEngineCat()?lower_case}/${srffilepath2(engine.getEngineType())}-engine';
</#list>
</#if>


<#if view.getPSUIActions()??>
<#list view.getPSUIActions() as uiAction>
<#if uiAction.getPSAppDataEntity?? && uiAction.getPSAppDataEntity()??>
<#if uiAction.getPFLogicCodeType() == "WFBACKEND">
<#if uiAction.getPSAppWFVer?? && uiAction.getPSAppWFVer()??>
<#if !P.exists("importService", uiAction.getPSAppWFVer().getCodeName(), "")>
import ${srfclassname('${uiAction.getPSAppWFVer().getCodeName()}')}WFUIService from '@/wfuiservice/${uiAction.getPSAppWF().getCodeName()?lower_case}/${uiAction.getPSAppWFVer().getCodeName()?lower_case}-ui-service';
</#if>
</#if>
</#if>
</#if>
</#list>
</#if>
tony001's avatar
tony001 committed
40
<#if appde??>
41
import ${srfclassname('${appde.getCodeName()}')}UIService from '@/uiservice/${srffilepath2(appde.getCodeName())}/${srffilepath2(appde.getCodeName())}-ui-service';
tony001's avatar
tony001 committed
42
</#if>
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
<#if import_block??>
${import_block}
</#if>

@Component({
    components: {
    },
})
export default class ${srfclassname('${view.name}')}Base extends Vue {
<#if view.getPSAppDataEntity?? && view.getPSAppDataEntity()??>
<#assign appde = view.getPSAppDataEntity()/>

    /**
     * 实体服务对象
     *
     * @type {${srfclassname('${appde.getCodeName()}')}Service}
     * @memberof ${srfclassname('${view.name}')}Base
     */
61
    public appEntityService: ${srfclassname('${appde.getCodeName()}')}Service = new ${srfclassname('${appde.getCodeName()}')}Service;
tony001's avatar
tony001 committed
62 63

    /**
64
     * 实体UI服务对象
tony001's avatar
tony001 committed
65
     *
66
     * @type ${srfclassname('${appde.getCodeName()}')}UIService
tony001's avatar
tony001 committed
67 68
     * @memberof ${srfclassname('${view.name}')}Base
     */
69
    public appUIService: ${srfclassname('${appde.getCodeName()}')}UIService = new ${srfclassname('${appde.getCodeName()}')}UIService(this.$store);
70 71 72 73 74 75 76 77 78 79
</#if>
    
    /**
     * 数据变化
     *
     * @param {*} val
     * @returns {*}
     * @memberof ${srfclassname('${view.name}')}Base
     */
    @Emit() 
80
    public viewDatasChange(val: any):any {
81 82 83 84 85 86 87 88 89
        return val;
    }

    /**
     * 传入视图上下文
     *
     * @type {string}
     * @memberof ${srfclassname('${view.name}')}Base
     */
90
    @Prop() public viewdata!: string;
91 92 93 94 95 96 97

    /**
     * 传入视图参数
     *
     * @type {string}
     * @memberof ${srfclassname('${view.name}')}Base
     */
98
    @Prop() public viewparam!: string;
99 100 101 102 103 104 105

    /**
     * 视图默认使用
     *
     * @type {boolean}
     * @memberof ${srfclassname('${view.name}')}Base
     */
106
    @Prop({ default: true }) public viewDefaultUsage!: boolean;
107

tony001's avatar
tony001 committed
108
    <#if view.getViewType() != "APPINDEXVIEW">
109 110 111 112 113 114
    /**
     * 视图默认使用
     *
     * @type {string}
     * @memberof ${srfclassname('${view.name}')}Base
     */
115
    @Inject({from:'navModel',default: 'tab'})
116
    public navModel!:string;
tony001's avatar
tony001 committed
117
    </#if>
118

119 120 121 122 123 124
	/**
	 * 视图标识
	 *
	 * @type {string}
	 * @memberof ${srfclassname('${view.name}')}Base
	 */
125
	public viewtag: string = '${view.getId()}';
126 127 128 129 130 131 132

	/**
	 * 自定义视图导航上下文集合
	 *
	 * @type {*}
	 * @memberof ${srfclassname('${view.name}')}Base
	 */
133
    public customViewNavContexts:any ={
134 135
    <#if view.getPSAppViewNavContexts()??>
    <#list view.getPSAppViewNavContexts() as viewNavContext>
136
    "${viewNavContext.getKey()}":{"isRawValue":${viewNavContext.isRawValue()?c},"value":"${viewNavContext.getValue()}"}<#if viewNavContext_has_next>,</#if>
137 138 139 140 141 142 143 144 145 146
    </#list>
    </#if>
    };

	/**
	 * 自定义视图导航参数集合
	 *
	 * @type {*}
	 * @memberof ${srfclassname('${view.name}')}Base
	 */
147
    public customViewParams:any ={
148 149
    <#if view.getPSAppViewNavParams()??>
    <#list view.getPSAppViewNavParams() as viewNavParam>
150
    "${viewNavParam.getKey()}":{"isRawValue":${viewNavParam.isRawValue()?c},"value":"${viewNavParam.getValue()}"}<#if viewNavParam_has_next>,</#if>
151 152 153 154 155 156 157 158 159 160
    </#list>
    </#if>
    };

    /**
     * 视图模型数据
     *
     * @type {*}
     * @memberof ${srfclassname('${view.name}')}Base
     */
161
    public model: any = {
162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180
        srfCaption: '<#if view.getPSAppDataEntity()??>entities.${view.getPSAppDataEntity().getCodeName()?lower_case}.views.${view.getPSDEViewCodeName()?lower_case}.caption<#else>app.views.${view.getCodeName()?lower_case}.caption</#if>',
        srfTitle: '<#if view.getPSAppDataEntity()??>entities.${view.getPSAppDataEntity().getCodeName()?lower_case}.views.${view.getPSDEViewCodeName()?lower_case}.title<#else>app.views.${view.getCodeName()?lower_case}.title</#if>',
        srfSubTitle: '<#if view.getPSAppDataEntity()??>entities.${view.getPSAppDataEntity().getCodeName()?lower_case}.views.${view.getPSDEViewCodeName()?lower_case}.subtitle<#else>app.views.${view.getCodeName()?lower_case}.subtitle</#if>',
        dataInfo: ''
    }

    /**
     * 视图参数变化
     *
     * @param {*} newVal
     * @param {*} oldVal
     * @memberof ${srfclassname('${view.name}')}Base
     */
    @Watch('viewparam',{immediate: true, deep: true})
    onParamData(newVal: any, oldVal: any) {
        if(newVal){
            for(let key in this.viewparams){
                delete this.viewparams[key];
            }
JunZai's avatar
JunZai committed
181 182 183
            if(typeof this.viewparams == 'string') {
                Object.assign(this.viewparams, JSON.parse(this.viewparam));
            }
184 185 186 187 188 189 190 191 192 193 194 195 196 197 198
            <#if watch_viewparam_block??>${watch_viewparam_block}</#if>
        } 
    }

    /**
     * 处理应用上下文变化
     *
     * @param {*} newVal
     * @param {*} oldVal
     * @memberof ${srfclassname('${view.name}')}Base
     */
    @Watch('viewdata')
    onViewData(newVal: any, oldVal: any) {
        const _this: any = this;
        if (!Object.is(newVal, oldVal) && _this.engine) {
tony001's avatar
tony001 committed
199 200 201 202 203
            this.$nextTick(()=>{
              _this.parseViewParam();
              _this.engine.load();
              <#if viewdata_block??>${viewdata_block}</#if>
            });
204
        } else if(!Object.is(newVal, oldVal) && _this.refresh && _this.refresh instanceof Function) {
205
            _this.refresh();
206 207 208 209 210 211 212 213 214
        }
    }

    /**
     * 容器模型
     *
     * @type {*}
     * @memberof ${srfclassname('${view.name}')}Base
     */
215
    public containerModel: any = {
216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233
        <#if view.getPSControls()??>
        <#list view.getPSControls() as ctrl>
        view_${ctrl.name}: { name: '${ctrl.name}', type: '${ctrl.getControlType()}' },
        </#list>
        </#if>
        <#if view.isPickupView() || (view.getViewType?? && (view.getViewType() == 'DEOPTVIEW' || view.getViewType() == 'DEWFSTARTVIEW' || view.getViewType() == 'DEWFACTIONVIEW'))>
        view_okbtn: { name: 'okbtn', type: 'button', text: '确定', disabled: true },
        view_cancelbtn: { name: 'cancelbtn', type: 'button', text: '取消', disabled: false },
        view_leftbtn: { name: 'leftbtn', type: 'button', text: '左移', disabled: true },
        view_rightbtn: { name: 'rightbtn', type: 'button', text: '右移', disabled: true },
        view_allleftbtn: { name: 'allleftbtn', type: 'button', text: '全部左移', disabled: true },
        view_allrightbtn: { name: 'allrightbtn', type: 'button', text: '全部右移', disabled: true },
        </#if>
        <#if view.getPSWorkflow?? && view.getPSWorkflow()??>
        wflinks: [],
        </#if>
    };

234 235 236 237 238 239 240 241 242 243
<#if view.getXDataPSControl?? && view.getXDataPSControl()??>
<#assign dataControl = view.getXDataPSControl()/>
    /**
     * 视图刷新
     *
     * @param {*} args
     * @memberof ${srfclassname('${view.name}')}Base
     */
    public refresh(args?: any): void {
        const refs: any = this.$refs;
244 245
        if (refs && refs.${dataControl.name}) {
            refs.${dataControl.name}.refresh();
246 247 248
        }
    }
</#if>
249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267
    /**
     *  计数器刷新
     *
     * @memberof ${srfclassname('${view.name}')}Base
     */
    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();
                }
            })
        }
    }

    /**
     * 视图状态订阅对象
     *
268
     * @public
269 270 271
     * @type {Subject<{action: string, data: any}>}
     * @memberof ${srfclassname('${view.name}')}Base
     */
272
    public viewState: Subject<ViewState> = new Subject();
273 274 275
<#if view.hasPSControl('toolbar')>
${P.getCtrlCode('toolbar', 'CONTROL.vue').code}
</#if>