LOGIC.tsx.ftl 9.9 KB
Newer Older
1 2 3 4 5 6 7 8 9 10
    <#macro getres tempView>
    <#compress>
    <#if tempView.getPSAppDataEntity?? && tempView.getPSAppDataEntity()?? && tempView.getPSAppDataEntity().getPSDataEntity?? && tempView.getPSAppDataEntity().getPSDataEntity()??>
    <#assign dataeneity = tempView.getPSAppDataEntity().getPSDataEntity() />
    <#if dataeneity.getMajorPSDERs?? && dataeneity.getMajorPSDERs()??>
    [<#list dataeneity.getMajorPSDERs() as psDes>'${psDes.getName()}'<#if psDes_has_next>,</#if></#list>]
    </#if>
    </#if>
    </#compress>
    </#macro>
yanshaowei's avatar
yanshaowei committed
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
    <#if item.getPSViewLogic?? && item.getPSViewLogic()??>
    <#assign viewlogic = item.getPSViewLogic()/>
    /**
     * 打开新建数据视图
     *
     * @param {any[]} args
     * @param {*} [params]
     * @param {*} [$event]
     * @param {*} [xData]
     * @memberof ${srfclassname('${view.name}')}
     */
    public newdata(args: any[], params?: any, $event?: any, xData?: any) {
    <#if viewlogic.isEnableWizardAdd()>
        this.$Notice.warning({ title: '错误', desc: '向导添加未实现' });
    <#elseif viewlogic.isEnableBatchAdd()>
26
        <#--  批量添加  -->
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 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
        <#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}'},
            res:<@getres tempView=batchAddPSAppView />}<#if batchAddPSAppView_has_next>,</#if>
        </#list>
        ];
        </#if>
        const data: any = {};
        if (args && args.length > 0 && args[0].srfsourcekey) {
            Object.assign(data, { srfsourcekey: args[0].srfsourcekey })
        }
        const _this: any = this;
        if (_this.srfparentdata) {
            Object.assign(data, { srfparentdata: _this.srfparentdata });
        }
        if(batchAddPSAppViews.length == 0){
            this.$Notice.warning({ title: '错误', desc: '批量添加需添加N:N关系' });
            return;
        }
        batchAddPSAppViews.forEach((item:any,index:number) =>{
            if(item.res){
                item.res.forEach((curRes:any) =>{
                    if(Object.is(curRes,_this.srfparentdata.srfparentmode)){
                        item.curRes = true;
                    }
                })
            }
        })
        const openPopupModal = (view: any, data: any) => {
            let container: Subject<any> = this.$appmodal.openModal(view, data);
            container.subscribe((result: any) => {
                if (!result || !Object.is(result.ret, 'OK')) {
                    return;
                }
                // 处理参数
                if(result.datas && result.datas.length == 0){
                    return;
                }
                let keys = '';
                const viewParam:any = {};
                if (_this.srfparentdata) {
                    Object.assign(viewParam,{ srfparentdata: _this.srfparentdata});
                }
                result.datas.forEach((record:any) => {
                    let key = record.srfkey;
                    if (!Object.is(keys, '')) {
                        keys += ';';
                    }
                    keys += key;
                });
                Object.assign(viewParam,{srfkeys:keys});
                // 发送批处理请求
                const url:string ="${app.getPKGCodeName()?lower_case}/${de.getPSSystemModule().codeName?lower_case}/${de.codeName?lower_case}/addbatch";
                this.$http.post(url,viewParam).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);
                })
            });
        }
        let curView:any ={};
        batchAddPSAppViews.forEach((item:any) =>{
            if(!item.curRes){
                Object.assign(curView,item.view)
            }
        })
        const view: any = curView;
        openPopupModal(view, data);
yanshaowei's avatar
yanshaowei committed
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116
    <#elseif viewlogic.isBatchAddOnly()>
        this.$Notice.warning({ title: '错误', desc: '只支持批添加未实现' });
    <#elseif viewlogic.getNewDataPSAppView()??>
        <#assign dataview = viewlogic.getNewDataPSAppView()/>
        const data: any = {};
        if (args && args.length > 0 && args[0].srfsourcekey) {
            Object.assign(data, { srfsourcekey: args[0].srfsourcekey })
        }
        <#if dataview.getOpenMode() == 'INDEXVIEWTAB' || dataview.getOpenMode() == ''>
        <#--  打开顶级分页视图  -->
        const _this: any = this;
        if (_this.srfparentdata) {
            Object.assign(data, _this.srfparentdata);
        }
        const openIndexViewTab = (viewpath: string, data: any) => {
117 118 119 120 121 122 123 124 125 126 127 128
            if(this.isModal){
              this.$Notice.error({ title: '错误', desc: '父视图是非路由方式打开,子视图无法进行路由跳转' });
            }else{
                Object.assign(data, { w: (new Date().getTime()) });
                const _params = this.$util.prepareRouteParmas({
                    route: this.$route,
                    sourceNode: this.$route.name,
                    targetNode: viewpath,
                    data: data,
                });
                this.$router.push({ name: viewpath, params: _params });
            }
yanshaowei's avatar
yanshaowei committed
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
        }
        openIndexViewTab('${dataview.getPSAppModule().codeName?lower_case}_${dataview.codeName?lower_case}', data);
        <#elseif dataview.getOpenMode() = 'POPUPMODAL'>
        <#--  打开模态  -->
        const _this: any = this;
        if (_this.srfparentdata) {
            Object.assign(data, { srfparentdata: _this.srfparentdata });
        }
        const openPopupModal = (view: any, data: any) => {
            let container: Subject<any> = this.$appmodal.openModal(view, 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: '${dataview.title}', 
        };
        openPopupModal(view, data);
        <#elseif dataview.getOpenMode()?index_of('DRAWER') == 0>
        <#--  打开抽屉  -->
        const _this: any = this;
        if (_this.srfparentdata) {
            Object.assign(data, { srfparentdata: _this.srfparentdata });
        }
        const openDrawer = (view: any, data: any) => {
            let container: Subject<any> = this.$appdrawer.openDrawer(view, 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: '${dataview.title}', 
            placement: '${dataview.getOpenMode()}',
        };
        openDrawer(view, data);
        <#elseif dataview.getOpenMode() == 'POPOVER'>
        <#--  打开气泡卡片  -->
        const _this: any = this;
        if (_this.srfparentdata) {
            Object.assign(data, { srfparentdata: _this.srfparentdata });
        }
        const openPopOver = (view: any, data: any) => {
            let container: Subject<any> = this.$apppopover.openPop($event, view, 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: '${dataview.title}', 
            placement: '${dataview.getOpenMode()}',
        };
        openPopOver(view, data);
208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225
        <#elseif dataview.getOpenMode() == 'POPUPAPP'>
        <#--  打开独立程序弹出  -->
        const openPopupApp = (viewpath: string, data: any) => {
            const _params = this.$util.prepareRouteParmas({
                route: this.$route,
                sourceNode: this.$route.name,
                targetNode: viewpath,
                data: data,
            });
            let targetViewPath:string = "";
            if(Object.keys(_params).length > 0){
                Object.keys(_params).forEach((item:string) =>{
                    <#noparse>targetViewPath += _params[item]?`/${item}/${_params[item]}`:`/${item}`;</#noparse>
                })
            }
            window.open('./#'+targetViewPath, '_blank');
        }
        openPopupApp('${dataview.getPSAppModule().codeName?lower_case}_${dataview.codeName?lower_case}', data);
yanshaowei's avatar
yanshaowei committed
226 227 228 229 230 231 232 233
        <#else>
        this.$Notice.warning({ title: '错误', desc: '${dataview.title} 不支持该模式打开' });
        </#if>
    <#else>
    this.$Notice.warning({ title: '错误', desc: '未指定关系视图' });
    </#if>
    }
    </#if>