LOGIC.vue.ftl 5.8 KB
Newer Older
ibizdev's avatar
ibizdev committed
1 2
<#ibizinclude>../../@MACRO/View.ftl</#ibizinclude>
<#ibizinclude>../../@MACRO/RouteParameters.ftl</#ibizinclude>
KK's avatar
KK committed
3
<#ibizinclude>../../../@NAVPARAMS/FUNC/PUBLIC.vue.ftl</#ibizinclude>
ibizdev's avatar
ibizdev committed
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
<#if item.getPSViewLogic?? && item.getPSViewLogic()??>
<#assign viewlogic = item.getPSViewLogic()/>
    /**
     * 打开新建数据视图
     *
     * @param {any[]} args
     * @param {*} [contextJO={}]
     * @param {*} [paramJO={}]
     * @param {*} [$event]
     * @param {*} [xData]
     * @param {*} [container]
     * @param {string} [srfParentDeName]
     * @returns {Promise<any>}
     * @memberof ${srfclassname('${view.name}')}
     */
    public async ${item.name}(args: any[], contextJO: any = {}, paramJO: any = {}, $event?: any, xData?: any, container?: any, srfParentDeName?: string): Promise<any> {
    <#if viewlogic.isEnableWizardAdd()>
KK's avatar
KK committed
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 48 49
        <#if viewlogic.getWizardPSAppView?? && viewlogic.getWizardPSAppView()??>
        <#assign wizardAppView = viewlogic.getWizardPSAppView() />
        let wizardAppView:any = {viewname:'${srffilepath2(wizardAppView.getCodeName())}',height: ${wizardAppView.getHeight()?c},width: ${wizardAppView.getWidth()?c},title: '${wizardAppView.title}'};
        let container: Subject<any> = this.globaluiservice.openService.openModal(wizardAppView, JSON.parse(JSON.stringify(this.context)), args[0]);
        container.subscribe((result: any) => {
            if (!result || !Object.is(result.ret, 'OK')) {
                return;
            }
            if(result && result.datas && result.datas.length >0 ){
                let targetkey:string = result.datas[0].srfkey;
                <#if viewlogic.getNewDataPSAppViews?? && viewlogic.getNewDataPSAppViews()??>
                let newDataAppViews:any ={
                <#list viewlogic.getNewDataPSAppViews() as newDataAppView>
                <#compress>${newDataAppView.getRefMode()}:<#if newDataAppView.isPSDEView()><#assign appDataEntity = newDataAppView.getPSAppDataEntity() />[{ pathName: '${srfpluralize(appDataEntity.codeName)?lower_case}', parameterName: '${appDataEntity.getCodeName()?lower_case}' },{ pathName: '${newDataAppView.getPSDEViewCodeName()?lower_case}', parameterName: '${newDataAppView.getPSDEViewCodeName()?lower_case}' }]<#else>[]</#if><#if newDataAppView_has_next>,</#if></#compress>
                </#list>
                };
                </#if>
                const data: any = {};
                if(args[0].srfsourcekey) data.srfsourcekey = args[0].srfsourcekey;
                let tempContext = JSON.parse(JSON.stringify(this.context));
                const openIndexViewTab = (data: any) => {
                    const _data: any = { w: (new Date().getTime()) };
                    Object.assign(_data, data);
                    const routePath = this.$viewTool.buildUpRoutePath(this.$route, tempContext, [], newDataAppViews[targetkey], args, _data);
                    this.$router.push(routePath);
                }
                openIndexViewTab(data);
            }
        })
KK's avatar
KK committed
50
        <#else>
KK's avatar
KK committed
51
        this.$notice.warning('请添加新建数据向导视图');
KK's avatar
KK committed
52
        </#if>
ibizdev's avatar
ibizdev committed
53 54 55 56 57 58
    <#elseif viewlogic.isEnableBatchAdd()>
        this.$notice.warning('支持批添加未实现');
    <#elseif viewlogic.isBatchAddOnly()>
        this.$notice.warning('只支持批添加未实现');
    <#elseif viewlogic.getNewDataPSAppView()??>
        <#assign dataview = viewlogic.getNewDataPSAppView()/>
59 60
        const params: any = { ...paramJO };
        let context = { ...this.context, ...contextJO };
ibizdev's avatar
ibizdev committed
61 62 63 64
        if (args.length > 0) {
            Object.assign(context, args[0]);
        }
        let response: any = null;
65 66
        <#if view.getPSAppViewRefs?? && view.getPSAppViewRefs()??>
        <#list view.getPSAppViewRefs() as refItem>
KK's avatar
KK committed
67
        <#if refItem.getName() == 'NEWDATA'>
68 69 70 71 72 73 74
        let panelNavParam = <@getNavigateParams refItem />;
        let panelNavContext = <@getNavigateContext refItem />;
        //导航参数处理
        const { context: _context, param: _params } = this.$viewTool.formatNavigateParam( panelNavContext, panelNavParam, context, params, {});
        </#if>
        </#list>
        </#if>
ibizdev's avatar
ibizdev committed
75 76 77 78 79 80 81 82 83 84
<#--  BEGIN: 输出视图数据  -->
<#if !(dataview.isRedirectView()) && (dataview.getOpenMode() == 'POPUPMODAL' || dataview.getOpenMode()?index_of('DRAWER') == 0 || dataview.getOpenMode() =='POPOVER')>
<@outPutViewInfo dataview/>
</#if>
<#--  END: 输出视图数据  -->
        <#if dataview.getOpenMode() == 'INDEXVIEWTAB' || dataview.getOpenMode() == ''>
        <#--  打开顶级分页视图  -->
            <#--  BEGIN:准备参数  -->
            <@outPutRouteParameters dataview/>
            <#--  END:准备参数  -->
85
        const routeParam: any = this.globaluiservice.openService.formatRouteParam(_context, deResParameters, parameters, args, _params);
ibizdev's avatar
ibizdev committed
86 87 88
        response = await this.globaluiservice.openService.openView(routeParam);
        <#elseif dataview.getOpenMode() = 'POPUPMODAL'>
        <#--  打开模态  -->
89
        response = await this.globaluiservice.openService.openModal(view, _context, _params);
ibizdev's avatar
ibizdev committed
90 91
        <#elseif dataview.getOpenMode()?index_of('DRAWER') == 0>
        <#--  打开抽屉  -->
92
        response = await this.globaluiservice.openService.openDrawer(view, _context, _params);
ibizdev's avatar
ibizdev committed
93 94
        <#elseif dataview.getOpenMode() == 'POPOVER'>
        <#--  打开气泡卡片  -->
95
        response = await this.globaluiservice.openService.openPopOver(view, _context, _params);
ibizdev's avatar
ibizdev committed
96 97 98 99 100 101 102 103 104 105 106 107 108
        <#else>
        this.$notice.warning('${dataview.title} 不支持该模式打开');
        </#if>
        if (response) {
            if (!response || !Object.is(response.ret, 'OK')) {
                return;
            }
            if (!xData || !(xData.refresh instanceof Function)) {
                return;
            }
            xData.refresh(response.datas);
        }
    <#else>
KK's avatar
KK committed
109
        //this.$notice.warning('未指定关系视图');
ibizdev's avatar
ibizdev committed
110 111 112
    </#if>
    }
    </#if>