<template>

</template>

<script>
    import ColumnEventParentRender from "./columnEventParentRender";
    export default {
        name: "new-page-render",
        extends: ColumnEventParentRender,
        props:{
            rowFieldIdData:{type:Object,default:() => ({})}
        },
        data(){
            return {
                loginUser:{},
                defaultValObj :{"id":"id","CREATE_TIME":"createTime",
                                "UPDATE_TIME":"updateTime","CREATED":
                                "created","UPDATED":"updated"},
            }
        },
        created(){
            this.loginUser = this.CACHE_GLOBAL.getLoginUser() || {};//获取当前登陆用户
        },
        methods:{
            runEvent(){
                //执行事件
                let pageUrl = this.formatObj.eventSetData["pageUrl"] || "";
                //解析 参数param
                if(pageUrl){ //外部页面跳转
                    if(pageUrl.toLowerCase().indexOf("http://") > -1 || pageUrl.toLowerCase().indexOf("https://") > -1){
                        let data = '';
                        Object.keys(this.paramObj || {}).forEach((key,index) => {
                            if(index == 0){
                                data += "?" + key + "=" + this.paramObj[key];
                            }else {
                                data += "&" + key + "=" + this.paramObj[key];
                            }
                        });
                        window.open(pageUrl+data);
                    }else { //内部页面跳转 routerPush
                        this.routerPush(pageUrl,this.paramObj);
                    }
                }
            },

            /**
             * 请求跳转
             */
            routerPush(url,param) {
                let urlPath = (url && (url.indexOf(".jsp") > -1 || url.indexOf(".html") > -1));
                if (urlPath) {
                    this.$nextTick(() => {
                        this.$router.push({
                            name: "ifmPage", query: param
                        });
                    });
                } else {
                    if(url.indexOf("/") == -1){
                        url = "/"+url;
                    }
                    this.$router.push({
                        path: url, query: param
                    });
                }
            },
        }
    }
</script>

<style scoped>

</style>
