zhangyanpeng
2024-08-26 3dfe7d4be26b4b57e9848320caa8697e1f31b8e7
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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
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
<!doctype html>
<html>
    <head>
        <meta charset="utf-8"><meta http-equiv="Expires" content="0"><meta http-equiv="Pragma" content="no-cache"><meta http-equiv="Cache-control" content="no-cache"><meta http-equiv="Cache" content="no-cache">
        <title>模型容器</title>
        
        <script type="text/javascript">
            var vue_ = null;
            var pageVue = null;
            function loadJsCss(callback) {
                var jscss_urls = [];
                window.top.initJsCss(document, jscss_urls, callback);
            };
            
            function initVue() {
                vue_ = new FormVue({
                    el: "#vbody",
                    data: {
                        title: "模型容器",
                        iframe_url: "",
                        reporturl: "",
                        
                        dataRequest: [
                            {
                                name: "sys_model",
                                dataname: "sys_model",
                                filter: "",
                                isnotoption: false, //true:不是选项
                                code:"id",//是下拉选项时设置
                                label:"url",//是下拉选项时设置
                            },
                        ],
                        dataRequestObj: {},
                        
                        sys_model_map: {},
                        sys_page_model: {},
                        
                    },
                    created() {
                        if (window.top.tab.selected.option.page_id) {
                            let page_id = window.top.tab.selected.option.page_id;
                            var sys_page_model = {
                                name: "sys_page_model", // 页面对应的模型
                                dataname: "sys_page_model",
                                // url: "root/data/getEntitySet",
                                // paramsobj: {dataname: "sys_page_model", filter:"sys_page_model.page_id='" + page_id + "'"},
                                isnotoption: true, //true:不是选项
                                filter: "sys_page_model.page_id='" + page_id + "'"
                            }
                            this.dataRequest.push(sys_page_model);
                        }
                    },
                    
                    mounted() {
                        var me = this;
                        if (this.dataRequest && this.dataRequest.length) {
                            var result = {};
                            this.loadRequestData(this.dataRequest, result, function(data) {
                                me.dataRequestObj = data;
                                //预加载数据后给哪些字段设置options或formatterjson
                                
                                if (me.dataRequestObj.sys_model) {
                                    me.sys_model_map = me.dataRequestObj.sys_model.map.sys_model;
                                }
                                if (me.dataRequestObj.sys_page_model) {
                                    me.sys_page_model = me.dataRequestObj.sys_page_model[0];
                                }
                                
                                me.initData();
                                
                                // 以服务的方式调用的 Loading 需要异步关闭
                                me.$nextTick(() => { 
                                    hideLoading();
                                });
                            });
                        }
                        else {
                            // 以服务的方式调用的 Loading 需要异步关闭
                            this.$nextTick(() => { 
                                hideLoading();
                                me.initData();
                            });
                        }
                        
                    },
                    
                    methods:{
                        initData() {
                            // if (this.sys_page_model.sys_model__url.substring(0, 18) == "module/model/page/") {
                            //     this.iframe_url = "./page/" + this.sys_page_model.sys_model__url.substring(18);
                            // }
                            if(this.sys_page_model.sys_model__url.substring(0, 7) == "module/") {
                                this.iframe_url = window.top.config.url_page + this.sys_page_model.sys_model__url;
                            }
                            else {
                                this.iframe_url = this.sys_page_model.sys_model__url
                            }
                        },
                        
                        getReportToken() {
                            var me = this;
                            
                            var param_ = "";
                            if (window.top.vue.userinfo.currentactor.actor_type == "Customer") { // 经销商
                                param_ = "&actor=" + window.top.vue.userinfo.currentactor.actor_type + "&accountId=" + window.top.vue.userinfo.currentactor.target_id
                            }
                            else if (window.top.vue.userinfo.currentactor.actor_type == "Sales") { // 销售
                                param_ = "&actor=" + window.top.vue.userinfo.currentactor.actor_type + "&positionID=" + window.top.vue.userinfo.currentactor.target_id + "&level=" + window.top.vue.userinfo.position_level_field
                            }
                            else if (window.top.vue.userinfo.currentactor.actor_type == "Business" || window.top.vue.userinfo.currentactor.actor_type == "Org") { // 商务、运营
                                param_ = "&actor=" + window.top.vue.userinfo.currentactor.actor_type //+ "&positionID=" + window.top.vue.userinfo.currentactor.target_id
                            }
                            else if (window.top.vue.userinfo.currentactor.actor_type == "Admin") { // Admin
                                param_ = "&actor=" + window.top.vue.userinfo.currentactor.actor_type
                            }
                            if (param_) {
                                this.reporturl += param_
                            }
                            else {
                                this.$message({
                                    message: '该角色没有报表页面权限',
                                    type: 'warning'
                                });
                                return;
                            }
                            
                            var param = {
                                type: "get",
                            }
                            Server.call("rootreport/login/cross/domain?fine_username="+window.top.config.report_user.name+"&fine_password="+window.top.config.report_user.password+"&validity=-2", param, function(result) {
                                // 以服务的方式调用的 Loading 需要异步关闭
                                me.$nextTick(() => { 
                                    hideLoading();
                                });
                                me.iframe_url = window.top.config.url_root + "rootreport/view/form?" + me.reporturl;
                                me.iframe_url = me.sys_page_model.sys_model__url
                                // me.iframe_url = window.top.config.url_report + "/view/form?" + me.reporturl;
                            });
                        }
                    }
                });
            };
            
            loadJsCss(function () {
                initVue();
            });
        </script>
        
        <style>
            /*  在vue.js中 v-cloak 这个指令是防止页面加载时出现 vuejs 的变量名而设计的 */
            [v-cloak] {
                display: none !important;
            }
        </style>
    </head>
    
    <body style="position: absolute; top: 0; bottom: 0; left: 0; right: 0;">
        <div v-cloak id="vbody">
            <div id="page_root">
                <div style="position: absolute; top: 0px; bottom: 5px; left: 0; right: 0;">
                    <iframe :src="iframe_url" style="width: 100%; height: 100%;" frameborder="0"></iframe>
                </div>
            </div>
            
            <div id="page_loading" style="position: absolute; top:0px; width: 100vw; height: 50vh;">
                <div class="spinner">
                  <div class="cube1"></div>
                  <div class="cube2"></div>
                </div>
            </div>
        </div>    
        
    </body>
</html>