LOGIC.vue.ftl 16.0 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
        <#--  批量添加  -->
tony001's avatar
tony001 committed
80
        let batchAddPSAppViews:Array<any>=[];
81 82
        <#if viewlogic.getBatchAddPSAppViews??  &&  viewlogic.getBatchAddPSAppViews()??>
        <#assign batchAddPSAppViews = viewlogic.getBatchAddPSAppViews()/>
tony001's avatar
tony001 committed
83
        batchAddPSAppViews=[
84 85
        <#list batchAddPSAppViews as batchAddPSAppView>
            {view:{viewname:'${srffilepath2(batchAddPSAppView.getCodeName())}',height: ${batchAddPSAppView.getHeight()?c},width: ${batchAddPSAppView.getWidth()?c},title: '${batchAddPSAppView.title}'},
86
            res:<@getres tempView=batchAddPSAppView /><#if batchAddPSAppView.getPSAppDataEntity()??><#assign appDataEntity= batchAddPSAppView.getPSAppDataEntity()/>,
87
            'resAppKey':'<@getreskey appEntity=appDataEntity curEntity=view.getPSAppDataEntity() />'</#if>}<#if batchAddPSAppView_has_next>,</#if>
88 89 90
        </#list>
        ];
        </#if>
91
        if(batchAddPSAppViews.length == 0 || !this.context.srfparentdename){
92 93 94
            this.$Notice.warning({ title: '错误', desc: '批量添加需添加N:N关系' });
            return;
        }
95 96
        let openViewModel:any = batchAddPSAppViews.find((item:any) =>{
            return (item.res && (item.res[0] !== this.context.srfparentdename));
97
        })
98 99 100
        let otherViewModel:any = batchAddPSAppViews.find((item:any) =>{
            return (item.res && (item.res[0] == this.context.srfparentdename));
        })
101 102 103 104
        let container: Subject<any> = this.$appmodal.openModal(openViewModel.view, JSON.parse(JSON.stringify(this.context)), args[0]);
        container.subscribe((result: any) => {
            if (!result || !Object.is(result.ret, 'OK')) {
                return;
105
            }
106 107 108
            if(result.datas && result.datas.length == 0){
                return;
            }
109
            let requestParam:Array<any> = [];
110
            result.datas.forEach((record:any) => {
111 112 113 114
                let tempParam:any = {};
                tempParam[otherViewModel.resAppKey] = this.context['srfparentkey'];
                tempParam[openViewModel.resAppKey] = record.srfkey;
                requestParam.push(tempParam);
115 116 117 118 119 120 121 122 123 124
            });
            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);
125 126
            });
        });
tony001's avatar
tony001 committed
127 128 129 130 131
    <#elseif viewlogic.isBatchAddOnly()>
        this.$Notice.warning({ title: '错误', desc: '只支持批添加未实现' });
    <#elseif viewlogic.getNewDataPSAppView()??>
        <#assign dataview = viewlogic.getNewDataPSAppView()/>
        const data: any = {};
tony001's avatar
tony001 committed
132 133 134
        if(args[0].srfsourcekey){
            data.srfsourcekey = args[0].srfsourcekey;
        }
tony001's avatar
tony001 committed
135
        let tempContext = JSON.parse(JSON.stringify(this.context));
tony001's avatar
tony001 committed
136 137
        <#if dataview.isPSDEView()>
        <#assign appDataEntity = dataview.getPSAppDataEntity()/>
tony001's avatar
tony001 committed
138
        delete tempContext.${appDataEntity.getCodeName()?lower_case};
tony001's avatar
tony001 committed
139
        </#if>
tony001's avatar
tony001 committed
140
        if(args.length >0){
tony001's avatar
tony001 committed
141 142 143 144 145 146 147
            Object.assign(tempContext,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);
tony001's avatar
tony001 committed
148
        }
tony001's avatar
tony001 committed
149 150 151 152 153 154 155 156
        </#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:导航参数 -->
tony001's avatar
tony001 committed
157 158 159 160 161 162 163 164 165 166
        <#--  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
167
                <#assign condition>${condition}tempContext.${_dataEntity.getCodeName()?lower_case} && </#assign>
tony001's avatar
tony001 committed
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 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
            </#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
232
            const routePath = this.$viewTool.buildUpRoutePath(this.$route, tempContext, deResParameters, parameters, args, _data);
tony001's avatar
tony001 committed
233 234 235 236 237 238
            this.$router.push(routePath);
        }
        openIndexViewTab(data);
        <#elseif dataview.getOpenMode() == 'POPUPAPP'>
        <#--  打开独立程序弹出  -->
        const _this: any = this;
tony001's avatar
tony001 committed
239
        const routePath = this.$viewTool.buildUpRoutePath(this.$route, tempContext, deResParameters, parameters, args, data);
tony001's avatar
tony001 committed
240 241 242 243 244
        window.open('./#'+routePath, '_blank');
        <#elseif dataview.getOpenMode() = 'POPUPMODAL'>
        <#--  打开模态  -->
        const _this: any = this;
        const openPopupModal = (view: any, data: any) => {
tony001's avatar
tony001 committed
245
            let container: Subject<any> = this.$appmodal.openModal(view, tempContext, data);
tony001's avatar
tony001 committed
246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266
            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
267
            let container: Subject<any> = this.$appdrawer.openDrawer(view, tempContext, data);
tony001's avatar
tony001 committed
268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289
            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
290
            let container: Subject<any> = this.$apppopover.openPop($event, view, tempContext,data);
tony001's avatar
tony001 committed
291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316
            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>