Authored by 鲁尚清

Merge branch 'master' of http://192.168.1.136:82/monitor_v3/hg-monitor-web into …

…master-v32-lushangqing
@@ -35,29 +35,29 @@ global.showLoading = (callback) => { @@ -35,29 +35,29 @@ global.showLoading = (callback) => {
35 * @param type "success", "warning", "info", "error" 35 * @param type "success", "warning", "info", "error"
36 */ 36 */
37 global.showMsg = (msg, type) => { 37 global.showMsg = (msg, type) => {
38 - if(!type){ 38 + if (!type) {
39 type = 'success'; 39 type = 'success';
40 } 40 }
41 41
42 - if(type == 'success'){ 42 + if (type == 'success') {
43 ElementPlus.ElMessage.success({ 43 ElementPlus.ElMessage.success({
44 showClose: true, 44 showClose: true,
45 message: msg, 45 message: msg,
46 type: type, 46 type: type,
47 }) 47 })
48 - } else if(type == 'warning'){ 48 + } else if (type == 'warning') {
49 ElementPlus.ElMessage.warning({ 49 ElementPlus.ElMessage.warning({
50 showClose: true, 50 showClose: true,
51 message: msg, 51 message: msg,
52 type: type, 52 type: type,
53 }) 53 })
54 - } else if(type == 'info'){ 54 + } else if (type == 'info') {
55 ElementPlus.ElMessage.info({ 55 ElementPlus.ElMessage.info({
56 showClose: true, 56 showClose: true,
57 message: msg, 57 message: msg,
58 type: type, 58 type: type,
59 }) 59 })
60 - }else if(type == 'error'){ 60 + } else if (type == 'error') {
61 ElementPlus.ElMessage.error({ 61 ElementPlus.ElMessage.error({
62 showClose: true, 62 showClose: true,
63 message: msg, 63 message: msg,
@@ -66,7 +66,7 @@ global.showMsg = (msg, type) => { @@ -66,7 +66,7 @@ global.showMsg = (msg, type) => {
66 } 66 }
67 67
68 } 68 }
69 -global.confirm = (msg,okFunc,cancelFunc) =>{ 69 +global.confirm = (msg, okFunc, cancelFunc) => {
70 ElementPlus.ElMessageBox.confirm( 70 ElementPlus.ElMessageBox.confirm(
71 msg, 71 msg,
72 '提示', 72 '提示',
@@ -76,12 +76,12 @@ global.confirm = (msg,okFunc,cancelFunc) =>{ @@ -76,12 +76,12 @@ global.confirm = (msg,okFunc,cancelFunc) =>{
76 type: 'warning', 76 type: 'warning',
77 } 77 }
78 ).then(() => { 78 ).then(() => {
79 - if(typeof(okFunc) == 'function'){ 79 + if (typeof (okFunc) == 'function') {
80 okFunc(); 80 okFunc();
81 } 81 }
82 82
83 }).catch(() => { 83 }).catch(() => {
84 - if(typeof(cancelFunc) == 'function'){ 84 + if (typeof (cancelFunc) == 'function') {
85 cancelFunc(); 85 cancelFunc();
86 } 86 }
87 }) 87 })
@@ -94,11 +94,11 @@ global.confirm = (msg,okFunc,cancelFunc) =>{ @@ -94,11 +94,11 @@ global.confirm = (msg,okFunc,cancelFunc) =>{
94 */ 94 */
95 global.getQueryVariable = (variable) => { 95 global.getQueryVariable = (variable) => {
96 var query = window.location.search.substring(1); 96 var query = window.location.search.substring(1);
97 - if(query == ''){ 97 + if (query == '') {
98 query = document.location.href 98 query = document.location.href
99 let args = query.split('?'); 99 let args = query.split('?');
100 let arr = []; 100 let arr = [];
101 - if(args && args.length > 1){ 101 + if (args && args.length > 1) {
102 arr = args[1].split('&') 102 arr = args[1].split('&')
103 } 103 }
104 for (var i = 0; i < arr.length; i++) { 104 for (var i = 0; i < arr.length; i++) {
@@ -118,17 +118,33 @@ global.getQueryVariable = (variable) => { @@ -118,17 +118,33 @@ global.getQueryVariable = (variable) => {
118 } 118 }
119 return (false); 119 return (false);
120 } 120 }
  121 +global.openBlankWindow = (url, width, height) => {
  122 + // width = window.innerWidth;
  123 + // height = window.innerHeight;
  124 + var features = "toolbar=no, location=no, directories=no, status=no, menubar=yes, scrollbars=yes, resizable=no, copyhistory=no";
  125 + if (width) {
  126 + features += "width=" + width;
  127 + }
  128 +
  129 + if (height) {
  130 + features += "height=" + height;
  131 + }
  132 +
  133 + if (url) {
  134 + window.open(url, "_blank", features);
  135 + }
  136 +}
121 137
122 /** 138 /**
123 * 文件预览 139 * 文件预览
124 * @param path 140 * @param path
125 */ 141 */
126 -global.viewer = (path,proxy) =>{ 142 +global.viewer = (path, proxy) => {
127 proxy.$http.get(`/api-web/openoffice/convertPdf/?path=${encodeURIComponent(path)}`, {}, function (res) { 143 proxy.$http.get(`/api-web/openoffice/convertPdf/?path=${encodeURIComponent(path)}`, {}, function (res) {
128 if (res && res.success) { 144 if (res && res.success) {
129 - window.open("/src/lib/extend/pdfjs/web/viewer.html?test=" + encodeURIComponent(res.str)); 145 + global.openBlankWindow("/src/lib/extend/pdfjs/web/viewer.html?test=" + encodeURIComponent(res.str));
130 } else { 146 } else {
131 - global.showMsg((res.msg == undefined || res.msg == '' || res.msg == null) ? "该文档不支持预览!" : res.msg,"error") 147 + global.showMsg((res.msg == undefined || res.msg == '' || res.msg == null) ? "该文档不支持预览!" : res.msg, "error")
132 } 148 }
133 }) 149 })
134 } 150 }
@@ -137,11 +153,12 @@ global.viewer = (path,proxy) =>{ @@ -137,11 +153,12 @@ global.viewer = (path,proxy) =>{
137 * 拓扑 153 * 拓扑
138 * @param path 154 * @param path
139 */ 155 */
140 -global.openGraphEditor = (topoId) =>{ 156 +global.openGraphEditor = (topoId) => {
141 let url = `${sessionStorage.getItem('graphEditorOrigin')}/jgraph/grapheditor/index.html?access_token=${localStorage.getItem('access_token')}&id=${topoId}`; 157 let url = `${sessionStorage.getItem('graphEditorOrigin')}/jgraph/grapheditor/index.html?access_token=${localStorage.getItem('access_token')}&id=${topoId}`;
142 let height = window.innerHeight; 158 let height = window.innerHeight;
143 let width = window.innerWidth; 159 let width = window.innerWidth;
144 - window.open(url,"_blank",`toolbar=no, location=no, directories=no, status=no, menubar=yes, scrollbars=yes, resizable=no, copyhistory=no, width=${width}, height=${height}`); 160 + //window.open(url,"_blank",`toolbar=no, location=no, directories=no, status=no, menubar=yes, scrollbars=yes, resizable=no, copyhistory=no, width=${width}, height=${height}`);
  161 + global.openBlankWindow(url, width, height);
145 } 162 }
146 163
147 /** 164 /**
@@ -151,8 +168,8 @@ global.openGraphEditor = (topoId) =>{ @@ -151,8 +168,8 @@ global.openGraphEditor = (topoId) =>{
151 global.openCmdbAssets = (resTypeId, resId, proxy) => { 168 global.openCmdbAssets = (resTypeId, resId, proxy) => {
152 169
153 let preUrl = sessionStorage.getItem('cmdbWeb'); 170 let preUrl = sessionStorage.getItem('cmdbWeb');
154 - if(!preUrl){  
155 - global.showMsg("获取CMDB系统地址失败,请配置!","error"); 171 + if (!preUrl) {
  172 + global.showMsg("获取CMDB系统地址失败,请配置!", "error");
156 return; 173 return;
157 } 174 }
158 175
@@ -164,39 +181,44 @@ global.openCmdbAssets = (resTypeId, resId, proxy) => { @@ -164,39 +181,44 @@ global.openCmdbAssets = (resTypeId, resId, proxy) => {
164 let obj = res.object; 181 let obj = res.object;
165 let cmdVal = obj.cmdbValue; 182 let cmdVal = obj.cmdbValue;
166 183
167 - let url =`${preUrl}/#/CI/configuration-item/detail?objId=${cmdVal}&id=${resId}` 184 + let url = `${preUrl}/#/CI/configuration-item/detail?objId=${cmdVal}&id=${resId}`
168 185
169 - window.open(url,"_blank",`left=100,fullscreen,toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, copyhistory=no, width=${width}, height=${height}`); 186 + //window.open(url, "_blank", `left=100,fullscreen,toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, copyhistory=no, width=${width}, height=${height}`);
  187 + global.openBlankWindow(url, width, height);
170 } else { 188 } else {
171 proxy.$global.showMsg('没有查询到关联数据,请配置!', "error"); 189 proxy.$global.showMsg('没有查询到关联数据,请配置!', "error");
172 } 190 }
173 }); 191 });
174 } 192 }
175 193
  194 +global.openDetail = (resId, resType, title) => {
  195 + let url = window.top.location.href.split('/#')[0] + `/#/res/resDetail/resId=${resId}/resType=${resType}/title=${title}`;
  196 + global.openBlankWindow(url);
  197 +}
  198 +
176 /** 199 /**
177 * 将文件转成base64 200 * 将文件转成base64
178 * @param file 201 * @param file
179 * @returns {Promise<String>} 202 * @returns {Promise<String>}
180 */ 203 */
181 -global.getBase64 = (file) =>{  
182 - return new Promise(function(resolve, reject) { 204 +global.getBase64 = (file) => {
  205 + return new Promise(function (resolve, reject) {
183 let reader = new FileReader(); 206 let reader = new FileReader();
184 let imgResult = ""; 207 let imgResult = "";
185 reader.readAsDataURL(file); 208 reader.readAsDataURL(file);
186 - reader.onload = function() { 209 + reader.onload = function () {
187 imgResult = reader.result; 210 imgResult = reader.result;
188 }; 211 };
189 - reader.onerror = function(error) { 212 + reader.onerror = function (error) {
190 reject(error); 213 reject(error);
191 }; 214 };
192 - reader.onloadend = function() { 215 + reader.onloadend = function () {
193 resolve(imgResult); 216 resolve(imgResult);
194 }; 217 };
195 }); 218 });
196 } 219 }
197 220
198 221
199 -  
200 // 组件默认大小 medium / small / mini 222 // 组件默认大小 medium / small / mini
201 global.elementSize = ''; 223 global.elementSize = '';
202 global.height = window.innerHeight - 20; 224 global.height = window.innerHeight - 20;
  1 +<script type="text/javascript">
  2 + //资源指标列表
  3 + layui.define(['table', 'form','sessions','common'], function (exports) {
  4 + var commonDetail = layui.commonDetail;
  5 +
  6 + //对外暴露的接口
  7 + commonDetail.openDetail(resId,resType,"详情页",true,function(data){
  8 + if(data){
  9 + console.log(111);
  10 + }
  11 + });
  12 + });
  13 +</script>