LOGIC.vue.ftl 12.1 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
    <#if viewlogic.isEnableWizardAdd()>
        this.$Notice.warning({ title: '错误', desc: '向导添加未实现' });
    <#elseif viewlogic.isEnableBatchAdd()>
41 42 43 44 45 46
        <#--  批量添加  -->
        <#if viewlogic.getBatchAddPSAppViews??  &&  viewlogic.getBatchAddPSAppViews()??>
        <#assign batchAddPSAppViews = viewlogic.getBatchAddPSAppViews()/>
        const batchAddPSAppViews=[
        <#list batchAddPSAppViews as batchAddPSAppView>
            {view:{viewname:'${srffilepath2(batchAddPSAppView.getCodeName())}',height: ${batchAddPSAppView.getHeight()?c},width: ${batchAddPSAppView.getWidth()?c},title: '${batchAddPSAppView.title}'},
47
            res:<@getres tempView=batchAddPSAppView /><#if batchAddPSAppView.getPSAppDataEntity()??><#assign appDataEntity= batchAddPSAppView.getPSAppDataEntity()/>,
48
            'resAppKey':'<@getreskey appEntity=appDataEntity curEntity=view.getPSAppDataEntity() />'</#if>}<#if batchAddPSAppView_has_next>,</#if>
49 50 51
        </#list>
        ];
        </#if>
52
        if(batchAddPSAppViews.length == 0 || !this.context.srfparentdename){
53 54 55
            this.$Notice.warning({ title: '错误', desc: '批量添加需添加N:N关系' });
            return;
        }
56 57
        let openViewModel:any = batchAddPSAppViews.find((item:any) =>{
            return (item.res && (item.res[0] !== this.context.srfparentdename));
58
        })
59 60 61
        let otherViewModel:any = batchAddPSAppViews.find((item:any) =>{
            return (item.res && (item.res[0] == this.context.srfparentdename));
        })
62 63 64 65
        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;
66
            }
67 68 69
            if(result.datas && result.datas.length == 0){
                return;
            }
70
            let requestParam:Array<any> = [];
71
            result.datas.forEach((record:any) => {
72 73 74 75
                let tempParam:any = {};
                tempParam[otherViewModel.resAppKey] = this.context['srfparentkey'];
                tempParam[openViewModel.resAppKey] = record.srfkey;
                requestParam.push(tempParam);
76 77 78 79 80 81 82 83 84 85
            });
            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);
86 87
            });
        });
tony001's avatar
tony001 committed
88 89 90 91 92
    <#elseif viewlogic.isBatchAddOnly()>
        this.$Notice.warning({ title: '错误', desc: '只支持批添加未实现' });
    <#elseif viewlogic.getNewDataPSAppView()??>
        <#assign dataview = viewlogic.getNewDataPSAppView()/>
        const data: any = {};
WodahsOrez's avatar
WodahsOrez committed
93 94 95
        if(args[0].srfsourcekey){
            data.srfsourcekey = args[0].srfsourcekey;
        }
tony001's avatar
tony001 committed
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 160 161 162 163 164 165 166 167 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 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259
        let curViewParam = JSON.parse(JSON.stringify(this.context));
        if(args.length >0){
            Object.assign(curViewParam,args[0]);
        }
        <#--  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()/>
                <#assign condition>${condition}curViewParam.${_dataEntity.getCodeName()?lower_case} && </#assign>
            </#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);
            const routePath = this.$viewTool.buildUpRoutePath(this.$route, curViewParam, deResParameters, parameters, args, _data);
            this.$router.push(routePath);
        }
        openIndexViewTab(data);
        <#elseif dataview.getOpenMode() == 'POPUPAPP'>
        <#--  打开独立程序弹出  -->
        const _this: any = this;
        const routePath = this.$viewTool.buildUpRoutePath(this.$route, curViewParam, deResParameters, parameters, args, data);
        window.open('./#'+routePath, '_blank');
        <#elseif dataview.getOpenMode() = 'POPUPMODAL'>
        <#--  打开模态  -->
        const _this: any = this;
        const openPopupModal = (view: any, data: any) => {
            let container: Subject<any> = this.$appmodal.openModal(view, curViewParam, data);
            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) => {
            let container: Subject<any> = this.$appdrawer.openDrawer(view, curViewParam, data);
            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) => {
            let container: Subject<any> = this.$apppopover.openPop($event, view, curViewParam,data);
            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>