LOGIC.vue.ftl 16.9 KB
Newer Older
tony001's avatar
tony001 committed
1 2 3
<#ibizinclude>
../../../@MACRO/LANG_FUN.ftl
</#ibizinclude>
4 5
    <#macro getres tempView>
    <#compress>
6 7
    <#if tempView.getPSAppDataEntity?? && tempView.getPSAppDataEntity()?? && tempView.getPSAppDataEntity().getMajorPSAppDERSs?? && tempView.getPSAppDataEntity().getMajorPSAppDERSs()??>
    <#assign appDataEneity = tempView.getPSAppDataEntity() />
8
    <#if appDataEneity.getMajorPSAppDERSs?? && appDataEneity.getMajorPSAppDERSs()??>
9
    [<#list appDataEneity.getMajorPSAppDERSs() as psDes><#if !P.exists("importService", psDes.getMajorPSAppDataEntity().getId(), "")>'${psDes.getMajorPSAppDataEntity().getCodeName()}'</#if></#list>]
10 11 12 13
    </#if>
    </#if>
    </#compress>
    </#macro>
14 15 16 17
    <#macro getreskey appEntity curEntity>
    <#compress>
    <#if appEntity.getMajorPSAppDERSs()??>
    <#list appEntity.getMajorPSAppDERSs() as appDeRs>
18
    <#if appDeRs.getMinorPSAppDataEntity().getCodeName() == curEntity.getCodeName()>
19 20 21 22 23 24
    ${appDeRs.getPSDER1N().getPSPickupDEField().getCodeName()?lower_case}
    </#if>
    </#list>
    </#if>
    </#compress>
    </#macro>
tony001's avatar
tony001 committed
25 26 27 28 29 30 31 32 33 34 35 36
    <#if item.getPSViewLogic?? && item.getPSViewLogic()??>
    <#assign viewlogic = item.getPSViewLogic()/>
    /**
     * 打开新建数据视图
     *
     * @param {any[]} args
     * @param {*} [params]
     * @param {*} [fullargs]
     * @param {*} [$event]
     * @param {*} [xData]
     * @memberof ${srfclassname('${view.name}')}
     */
37
    public newdata(args: any[],fullargs?:any[], params?: any, $event?: any, xData?: any) {
tony001's avatar
tony001 committed
38 39 40 41 42 43 44
    <#if viewlogic.getPSAppUILogicRefViews?? && viewlogic.getPSAppUILogicRefViews()??>
    <#list viewlogic.getPSAppUILogicRefViews() as appUILogicRefView>
    <#if appUILogicRefView_index == 0><#assign curNewLogicRefView = appUILogicRefView /></#if>
    </#list>
    </#if>
        let localContext:any = <#if curNewLogicRefView?? && curNewLogicRefView.getPSNavigateContexts?? && curNewLogicRefView.getPSNavigateContexts()??><@getNavigateContext curNewLogicRefView /><#else>null</#if>;
        let localViewParam:any =<#if curNewLogicRefView?? && curNewLogicRefView.getPSNavigateParams?? && curNewLogicRefView.getPSNavigateParams()??><@getNavigateParams curNewLogicRefView /><#else>null</#if>;
tony001's avatar
tony001 committed
45
    <#if viewlogic.isEnableWizardAdd()>
46 47 48 49 50 51 52 53
        <#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.$appmodal.openModal(wizardAppView, JSON.parse(JSON.stringify(this.context)), args[0]);
        container.subscribe((result: any) => {
            if (!result || !Object.is(result.ret, 'OK')) {
                return;
            }
54 55 56 57 58
            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>
59
                <#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>
60 61 62 63 64 65 66 67 68 69 70 71 72 73
                </#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);
            }
74 75 76 77
        })
        <#else>
        this.$Notice.warning({ title: '错误', desc: '请添加新建数据向导视图' });
        </#if>
tony001's avatar
tony001 committed
78
    <#elseif viewlogic.isEnableBatchAdd()>
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94
        let tempContext:any = this.$util.deepCopy(this.context);
        let data:any = this.$util.deepCopy(args[0]);
        <#-- BEGIN:导航参数 -->
        <#if curNewLogicRefView?? && curNewLogicRefView.getPSNavigateContexts?? && curNewLogicRefView.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);
        }
        </#if>
        <#if curNewLogicRefView?? && curNewLogicRefView.getPSNavigateParams?? && curNewLogicRefView.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:导航参数 -->
95
        <#--  批量添加  -->
tony001's avatar
tony001 committed
96
        let batchAddPSAppViews:Array<any>=[];
97 98
        <#if viewlogic.getBatchAddPSAppViews??  &&  viewlogic.getBatchAddPSAppViews()??>
        <#assign batchAddPSAppViews = viewlogic.getBatchAddPSAppViews()/>
tony001's avatar
tony001 committed
99
        batchAddPSAppViews=[
100 101
        <#list batchAddPSAppViews as batchAddPSAppView>
            {view:{viewname:'${srffilepath2(batchAddPSAppView.getCodeName())}',height: ${batchAddPSAppView.getHeight()?c},width: ${batchAddPSAppView.getWidth()?c},title: '${batchAddPSAppView.title}'},
102
            res:<@getres tempView=batchAddPSAppView /><#if batchAddPSAppView.getPSAppDataEntity()??><#assign appDataEntity= batchAddPSAppView.getPSAppDataEntity()/>,
103
            'resAppKey':'<@getreskey appEntity=appDataEntity curEntity=view.getPSAppDataEntity() />'</#if>}<#if batchAddPSAppView_has_next>,</#if>
104 105 106
        </#list>
        ];
        </#if>
107
        if(batchAddPSAppViews.length == 0 || !this.context.srfparentdename){
108 109 110
            this.$Notice.warning({ title: '错误', desc: '批量添加需添加N:N关系' });
            return;
        }
111 112
        let openViewModel:any = batchAddPSAppViews.find((item:any) =>{
            return (item.res && (item.res[0] !== this.context.srfparentdename));
113
        })
114 115 116
        let otherViewModel:any = batchAddPSAppViews.find((item:any) =>{
            return (item.res && (item.res[0] == this.context.srfparentdename));
        })
117
        let container: Subject<any> = this.$appmodal.openModal(openViewModel.view, tempContext, data);
118 119 120
        container.subscribe((result: any) => {
            if (!result || !Object.is(result.ret, 'OK')) {
                return;
121
            }
122 123 124
            if(result.datas && result.datas.length == 0){
                return;
            }
125
            let requestParam:Array<any> = [];
126
            result.datas.forEach((record:any) => {
127 128 129 130
                let tempParam:any = {};
                tempParam[otherViewModel.resAppKey] = this.context['srfparentkey'];
                tempParam[openViewModel.resAppKey] = record.srfkey;
                requestParam.push(tempParam);
131 132 133 134 135 136 137 138 139 140
            });
            this.appEntityService.createBatch(JSON.parse(JSON.stringify(this.context)),requestParam,true).then((response:any) =>{
                if (!response || response.status !== 200) {
                    this.$Notice.error({ title: '错误', desc: '批处理操作失败' });
                    return;
                }
                if (!xData || !(xData.refresh instanceof Function)) {
                    return;
                }
                xData.refresh(result.datas);
141 142
            });
        });
tony001's avatar
tony001 committed
143 144 145 146 147
    <#elseif viewlogic.isBatchAddOnly()>
        this.$Notice.warning({ title: '错误', desc: '只支持批添加未实现' });
    <#elseif viewlogic.getNewDataPSAppView()??>
        <#assign dataview = viewlogic.getNewDataPSAppView()/>
        const data: any = {};
tony001's avatar
tony001 committed
148 149 150
        if(args[0].srfsourcekey){
            data.srfsourcekey = args[0].srfsourcekey;
        }
tony001's avatar
tony001 committed
151
        let tempContext = JSON.parse(JSON.stringify(this.context));
tony001's avatar
tony001 committed
152 153
        <#if dataview.isPSDEView()>
        <#assign appDataEntity = dataview.getPSAppDataEntity()/>
tony001's avatar
tony001 committed
154
        delete tempContext.${appDataEntity.getCodeName()?lower_case};
tony001's avatar
tony001 committed
155
        </#if>
tony001's avatar
tony001 committed
156
        if(args.length >0){
tony001's avatar
tony001 committed
157 158 159 160 161
            Object.assign(tempContext,args[0]);
        }
        <#-- BEGIN:导航参数 -->
        <#if curNewLogicRefView?? && curNewLogicRefView.getPSNavigateContexts?? && curNewLogicRefView.getPSNavigateContexts()??>
        if(localContext && Object.keys(localContext).length >0){
162
            let _context:any = this.$util.computedNavData(fullargs[0],this.context,this.viewparams,localContext);
tony001's avatar
tony001 committed
163
            Object.assign(tempContext,_context);
tony001's avatar
tony001 committed
164
        }
tony001's avatar
tony001 committed
165 166 167
        </#if>
        <#if curNewLogicRefView?? && curNewLogicRefView.getPSNavigateParams?? && curNewLogicRefView.getPSNavigateParams()??>
        if(localViewParam && Object.keys(localViewParam).length >0){
168
            let _param:any = this.$util.computedNavData(fullargs[0],this.context,this.viewparams,localViewParam);
tony001's avatar
tony001 committed
169 170 171 172
            Object.assign(data,_param);
        }
        </#if>
        <#-- END:导航参数 -->
tony001's avatar
tony001 committed
173 174 175 176 177 178 179 180 181 182
        <#--  BEGIN:准备参数  -->
        <#--  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
183
                <#assign condition>${condition}tempContext.${_dataEntity.getCodeName()?lower_case} && </#assign>
tony001's avatar
tony001 committed
184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247
            </#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>
        <#--  END:准备参数  -->
        <#if dataview.getOpenMode() == 'INDEXVIEWTAB' || dataview.getOpenMode() == ''>
        <#--  打开顶级分页视图  -->
        const _this: any = this;
        const openIndexViewTab = (data: any) => {
            const _data: any = { w: (new Date().getTime()) };
            Object.assign(_data, data);
tony001's avatar
tony001 committed
248
            const routePath = this.$viewTool.buildUpRoutePath(this.$route, tempContext, deResParameters, parameters, args, _data);
tony001's avatar
tony001 committed
249 250 251 252 253 254
            this.$router.push(routePath);
        }
        openIndexViewTab(data);
        <#elseif dataview.getOpenMode() == 'POPUPAPP'>
        <#--  打开独立程序弹出  -->
        const _this: any = this;
tony001's avatar
tony001 committed
255
        const routePath = this.$viewTool.buildUpRoutePath(this.$route, tempContext, deResParameters, parameters, args, data);
tony001's avatar
tony001 committed
256 257 258 259 260
        window.open('./#'+routePath, '_blank');
        <#elseif dataview.getOpenMode() = 'POPUPMODAL'>
        <#--  打开模态  -->
        const _this: any = this;
        const openPopupModal = (view: any, data: any) => {
tony001's avatar
tony001 committed
261
            let container: Subject<any> = this.$appmodal.openModal(view, tempContext, data);
tony001's avatar
tony001 committed
262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282
            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;
        const openDrawer = (view: any, data: any) => {
tony001's avatar
tony001 committed
283
            let container: Subject<any> = this.$appdrawer.openDrawer(view, tempContext, data);
tony001's avatar
tony001 committed
284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305
            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;
        const openPopOver = (view: any, data: any) => {
tony001's avatar
tony001 committed
306
            let container: Subject<any> = this.$apppopover.openPop($event, view, tempContext,data);
tony001's avatar
tony001 committed
307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332
            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>