LOGIC.vue.ftl 12.0 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
<#ibizinclude>
../../../@MACRO/LANG_FUN.ftl
</#ibizinclude>
<#if item.getPSViewLogic?? && item.getPSViewLogic()??>
<#assign viewlogic = item.getPSViewLogic()/>
    /**
     * 打开编辑数据视图
     *
     * @param {any[]} args
     * @param {*} [params]
     * @param {*} [fullargs]
     * @param {*} [$event]
     * @param {*} [xData]
     * @memberof ${srfclassname('${view.name}')}
     */
tony001's avatar
tony001 committed
16
    public ${item.name}(args: any[],fullargs?:any,params?: any, $event?: any, xData?: any) {
17
    <#if item.getPSControlContainer().getViewType??>
18 19 20 21 22 23 24
        if(!this.viewDefaultUsage){
            if(Object.is(this.navModel,"route")){
                this.initNavDataWithRoute(this.viewCacheData, false, true);
            }else{
                this.initNavDataWithTab(this.viewCacheData, false, true);
            }
        }
25
    </#if>
tony001's avatar
tony001 committed
26 27 28 29 30 31 32
    <#if viewlogic.getPSAppUILogicRefViews?? && viewlogic.getPSAppUILogicRefViews()??>
    <#list viewlogic.getPSAppUILogicRefViews() as appUILogicRefView>
    <#if appUILogicRefView_index == 0><#assign curOPenLogicRefView = appUILogicRefView /></#if>
    </#list>
    </#if>
        let localContext:any = <#if curOPenLogicRefView?? && curOPenLogicRefView.getPSNavigateContexts?? && curOPenLogicRefView.getPSNavigateContexts()??><@getNavigateContext curOPenLogicRefView /><#else>null</#if>;
        let localViewParam:any =<#if curOPenLogicRefView?? && curOPenLogicRefView.getPSNavigateParams?? && curOPenLogicRefView.getPSNavigateParams()??><@getNavigateParams curOPenLogicRefView /><#else>null</#if>;
33 34 35
    <#if viewlogic.getOpenDataPSAppView()??>
        <#assign dataview = viewlogic.getOpenDataPSAppView()/>
        const data: any = {};
tony001's avatar
tony001 committed
36
        let tempContext = JSON.parse(JSON.stringify(this.context));
37
        if(args.length >0){
tony001's avatar
tony001 committed
38 39 40 41 42 43 44
            Object.assign(tempContext,args[0]);
        }
        <#-- BEGIN:导航参数 -->
        <#if curOPenLogicRefView?? && curOPenLogicRefView.getPSNavigateContexts?? && curOPenLogicRefView.getPSNavigateContexts()??>
        if(localContext && Object.keys(localContext).length >0){
            let _context:any = this.$util.computedNavData(args[0],this.context,this.viewparams,localContext);
            Object.assign(tempContext,_context);
45
        }
tony001's avatar
tony001 committed
46 47 48 49 50 51 52 53
        </#if>
        <#if curOPenLogicRefView?? && curOPenLogicRefView.getPSNavigateParams?? && curOPenLogicRefView.getPSNavigateParams()??>
        if(localViewParam && Object.keys(localViewParam).length >0){
            let _param:any = this.$util.computedNavData(args[0],this.context,this.viewparams,localViewParam);
            Object.assign(data,_param);
        }
        </#if>
        <#-- END:导航参数 -->
54 55 56 57 58 59 60
        <#-- BEGIN:工作流传递userTaskId -->
        <#if dataview.getViewType() == "DEWFDYNAEDITVIEW" >
        if(this.viewparams && this.viewparams.userTaskId){
            Object.assign(data,{'userTaskId':this.viewparams.userTaskId})
        }
        </#if>
        <#-- END:工作流传递userTaskId -->
61
        <#--  BEGIN:准备参数  -->
62
        <#if dataview.isRedirectView() && dataview.getViewType() != "DEREDIRECTVIEW">
63 64 65 66 67 68 69 70 71 72 73 74
        const deResParameters: any[] = [];
        const parameters: any[] = [];
        <#else>
        <#--  BEGIN:是否应用实体视图  -->
        <#if dataview.isPSDEView()>
        <#-- 存在关系start -->
        <#if dataview.getPSAppDERSPathCount() gt 0>
        <#list 1..dataview.getPSAppDERSPathCount() as count>
        <#assign condition = ''/>
        <#list dataview.getPSAppDERSPath(count_index)  as deRSPath>
            <#if deRSPath.getMajorPSAppDataEntity?? && deRSPath.getMajorPSAppDataEntity()??>
                <#assign _dataEntity = deRSPath.getMajorPSAppDataEntity()/>
tony001's avatar
tony001 committed
75
                <#assign condition>${condition}tempContext.${_dataEntity.getCodeName()?lower_case} && </#assign>
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159
            </#if>
        </#list>
        </#list>
        let deResParameters: any[] = [];
        <#-- 如果是主实体需对context判断start -->
        <#if dataview.getPSAppDataEntity().isMajor()>
        if(${condition}true){
            deResParameters = [
            <#list dataview.getPSAppDERSPath(dataview.getPSAppDERSPathCount() - 1) as deRSPath>
            <#assign majorPSAppDataEntity = deRSPath.getMajorPSAppDataEntity()/>
            { pathName: '${srfpluralize(majorPSAppDataEntity.codeName)?lower_case}', parameterName: '${majorPSAppDataEntity.getCodeName()?lower_case}' },
            </#list>
            ]
        }
        <#else>
        deResParameters = [
            <#list dataview.getPSAppDERSPath(dataview.getPSAppDERSPathCount() - 1) as deRSPath>
            <#assign majorPSAppDataEntity = deRSPath.getMajorPSAppDataEntity()/>
            { pathName: '${srfpluralize(majorPSAppDataEntity.codeName)?lower_case}', parameterName: '${majorPSAppDataEntity.getCodeName()?lower_case}' },
            </#list>
        ];
        </#if>
        <#-- 如果是主实体需对context判断end -->
        <#else>
        const deResParameters: any[] = [];
        </#if>
        <#-- 存在关系end -->
        <#else>
        const deResParameters: any[] = [];
        </#if>
        <#--  END:是否应用实体视图  -->
        <#if dataview.getOpenMode() == 'INDEXVIEWTAB' || dataview.getOpenMode() == ''>
        <#--  BEGIN:是否应用实体视图  -->
        <#if dataview.isPSDEView()>
        <#assign appDataEntity = dataview.getPSAppDataEntity()/>
        const parameters: any[] = [
            { pathName: '${srfpluralize(appDataEntity.codeName)?lower_case}', parameterName: '${appDataEntity.getCodeName()?lower_case}' },
            { pathName: '${dataview.getPSDEViewCodeName()?lower_case}', parameterName: '${dataview.getPSDEViewCodeName()?lower_case}' },
        ];
        <#else>
        const parameters: any[] = [
            { pathName: '${dataview.getCodeName()?lower_case}', parameterName: '${dataview.getCodeName()?lower_case}' },
        ];
        </#if>
        <#--  END:是否应用实体视图  -->
        <#else>
        <#--  BEGIN:是否应用实体视图  -->
        <#if dataview.isPSDEView()>
        <#assign appDataEntity = dataview.getPSAppDataEntity()/>
        const parameters: any[] = [
            { pathName: '${srfpluralize(appDataEntity.codeName)?lower_case}', parameterName: '${appDataEntity.getCodeName()?lower_case}' },
        ];
        <#else>
        const parameters: any[] = [];
        </#if>
        <#--  END:是否应用实体视图  -->
        </#if>
        </#if>
        <#--  END:准备参数  -->
        <#if dataview.isRedirectView()>
        <#if dataview.getViewType() == "DEWFDATAREDIRECTVIEW" || dataview.getViewType() == "APPWFREDIRECTVIEW">
        <#-- 应用全局流程工作重定向视图and实体全局流程数据重定向视图start -->
        if(fullargs && fullargs.length >0){
           <#noparse>window.open(`${fullargs[0].viewurl}srfworklist=${fullargs[0].wfworklistid}`);</#noparse>
           window.addEventListener("message",(event:any) =>{
            const data:any = event.data;
            if (Object.is(data.identification,'WF')){
                return ;
            }
            if(Object.is(data.status,'OK')){
                let xData:any = this.$refs.grid;
                if (xData.refresh && xData.refresh instanceof Function) {
                    setTimeout(() => {
                        xData.refresh();
                    }, 1000);
                }
            }
           })
        }else{
           console.error("重定向地址有误");
        }
        <#-- 应用全局流程工作重定向视图and实体全局流程数据重定向视图end -->
        <#else>
        <#-- 实体数据重定向视图start -->
160 161
        const routePath = this.$viewTool.buildUpRoutePath(this.$route, tempContext, deResParameters, parameters, args, data);
        this.$router.push(routePath);
162 163 164 165 166
        <#-- 实体数据重定向视图end -->
        </#if>
        <#elseif dataview.getOpenMode() == 'INDEXVIEWTAB' || dataview.getOpenMode() == ''>
        <#--  打开顶级分页视图 -->
        const _this: any = this;
tony001's avatar
tony001 committed
167 168 169
        if(fullargs && fullargs.copymode){
            Object.assign(data,{copymode:true});
        }
170
        const openIndexViewTab = (data: any) => {
tony001's avatar
tony001 committed
171
            const routePath = this.$viewTool.buildUpRoutePath(this.$route, tempContext, deResParameters, parameters, args, data);
172 173 174 175 176 177
            this.$router.push(routePath);
        }
        openIndexViewTab(data);
        <#elseif dataview.getOpenMode() == 'POPUPAPP'>
        <#--  打开独立程序弹出  -->
        const _this: any = this;
tony001's avatar
tony001 committed
178 179 180
        if(fullargs && fullargs.copymode){
            Object.assign(data,{copymode:true});
        }
tony001's avatar
tony001 committed
181
        const routePath = this.$viewTool.buildUpRoutePath(this.$route, tempContext, deResParameters, parameters, args, data);
182 183 184 185
        window.open('./#'+routePath, '_blank');
        <#elseif dataview.getOpenMode() = 'POPUPMODAL'>
        <#--  打开模态  -->
        const _this: any = this;
tony001's avatar
tony001 committed
186 187 188
        if(fullargs && fullargs.copymode){
            Object.assign(data,{copymode:true});
        }
189
        const openPopupModal = (view: any, data: any) => {
tony001's avatar
tony001 committed
190
            let container: Subject<any> = this.$appmodal.openModal(view, tempContext, data);
191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210
            container.subscribe((result: any) => {
                if (!result || !Object.is(result.ret, 'OK')) {
                    return;
                }
                if (!xData || !(xData.refresh instanceof Function)) {
                    return;
                }
                xData.refresh(result.datas);
            });
        }
        const view: any = {
            viewname: '${srffilepath2(dataview.getCodeName())}', 
            height: ${dataview.getHeight()?c}, 
            width: ${dataview.getWidth()?c},  
            title: this.<@getViewLanguageTitle dataview />,
        };
        openPopupModal(view, data);
        <#elseif dataview.getOpenMode()?index_of('DRAWER') == 0>
        <#--  打开抽屉  -->
        const _this: any = this;
tony001's avatar
tony001 committed
211 212 213
        if(fullargs && fullargs.copymode){
            Object.assign(data,{copymode:true});
        }
214
        const openDrawer = (view: any, data: any) => {
tony001's avatar
tony001 committed
215
            let container: Subject<any> = this.$appdrawer.openDrawer(view, tempContext, data);
216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236
            container.subscribe((result: any) => {
                if (!result || !Object.is(result.ret, 'OK')) {
                    return;
                }
                if (!xData || !(xData.refresh instanceof Function)) {
                    return;
                }
                xData.refresh(result.datas);
            });
        }
        const view: any = {
            viewname: '${srffilepath2(dataview.getCodeName())}', 
            height: ${dataview.getHeight()?c}, 
            width: ${dataview.getWidth()?c},  
            title: this.<@getViewLanguageTitle dataview />,
            placement: '${dataview.getOpenMode()}',
        };
        openDrawer(view, data);
        <#elseif dataview.getOpenMode() == 'POPOVER'>
        <#--  打开气泡卡片  -->
        const _this: any = this;
tony001's avatar
tony001 committed
237 238 239
        if(fullargs && fullargs.copymode){
            Object.assign(data,{copymode:true});
        }
240
        const openPopOver = (view: any, data: any) => {
tony001's avatar
tony001 committed
241
            let container: Subject<any> = this.$apppopover.openPop($event, view, tempContext, data);
242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267
            container.subscribe((result: any) => {
                if (!result || !Object.is(result.ret, 'OK')) {
                    return;
                }
                if (!xData || !(xData.refresh instanceof Function)) {
                    return;
                }
                xData.refresh(result.datas);
            });
        }
        const view: any = {
            viewname: '${srffilepath2(dataview.getCodeName())}', 
            height: ${dataview.getHeight()?c}, 
            width: ${dataview.getWidth()?c},  
            title: this.<@getViewLanguageTitle dataview />,
            placement: '${dataview.getOpenMode()}',
        };
        openPopOver(view, data);
        <#else>
        this.$Notice.warning({ title: '错误', desc: this.<@getViewLanguageTitle dataview />+'不支持该模式打开' });
        </#if>
    <#else>
    this.$Notice.warning({ title: '错误', desc: '未指定关系视图' });
    </#if>
    }
</#if>