Browse Source

在线excle编辑地址动态修改

duy 6 ngày trước cách đây
mục cha
commit
591ee5d859
2 tập tin đã thay đổi với 43 bổ sung7 xóa
  1. 29 5
      public/index.html
  2. 14 2
      src/views/exctab/excelmodel/excelmodel.vue

+ 29 - 5
public/index.html

@@ -16,11 +16,8 @@
   <link rel="stylesheet" href="<%= BASE_URL %>cdn/iconfont/avue/iconfont.css">
   <link rel="stylesheet" href="<%= BASE_URL %>cdn/iconfont/saber/iconfont.css">
   <link rel="stylesheet" href="<%= BASE_URL %>cdn/avue/2.9.5/index.css">
- <!-- <script type='text/javascript' src='http://127.0.0.1:6831/web-apps/apps/api/documents/api.js'></script> -->
-  <!-- <script type='text/javascript' src='http://192.168.0.109:8088/web-apps//api/documents/api.js'></script> -->
-  <!-- <script type='text/javascript' src='http://47.110.251.215:8088/web-apps/apps/api/documents/api.js'></script> -->
-  <!-- <script type='text/javascript' src='http://39.108.216.210:6831/web-apps/apps/api/documents/api.js'></script> -->
-  <script type='text/javascript' src='http://192.168.0.109:8088/web-apps/apps/api/documents/api.js'></script>
+
+
   <script src="<%= BASE_URL %>cdn/xlsx/FileSaver.min.js"></script>
   <script src="<%= BASE_URL %>cdn/xlsx/xlsx.full.min.js"></script>
   <link rel="icon" href="<%= BASE_URL %>favicon.png">
@@ -119,6 +116,33 @@
 <script src="<%= BASE_URL %>cdn/nutflow/wf-design-base/index.umd.min.js" charset="utf-8"></script>
 <script type="text/javascript" src='https://webapi.amap.com/maps?v=1.4.11&key=dfd9c521e218fb29772123a488e68c80&plugin=AMap.PlaceSearch'></script>
 <script src="https://webapi.amap.com/ui/1.0/main.js?v=1.0.11"></script>
+<script>
+  // 根据当前主机地址动态设置 API 脚本路径
+  (function() {
+    var host = window.location.hostname;
+    var apiUrl;
+    
+    // 设置不同环境下的 API 地址
+    if (host === '192.168.0.109') {
+      apiUrl = 'http://192.168.0.109:8088/web-apps/apps/api/documents/api.js';
+    } else if (host === '219.151.181.73') {
+      apiUrl = 'http://219.151.181.73:8088/web-apps/apps/api/documents/api.js';
+    }  else if (host === '183.247.216.148') {
+      apiUrl = 'http://183.247.216.148:8088/web-apps/apps/api/documents/api.js';
+    } 
+    
+    else {
+      // 默认地址或开发环境地址
+      apiUrl = 'http://192.168.0.109:8088/web-apps/apps/api/documents/api.js';
+    }
+    
+    // 动态创建 script 标签并加载
+    var script = document.createElement('script');
+    script.type = 'text/javascript';
+    script.src = apiUrl;
+    document.body.appendChild(script);
+  })();
+</script>
 </body>
 
 </html>

+ 14 - 2
src/views/exctab/excelmodel/excelmodel.vue

@@ -394,6 +394,17 @@ export default {
 
 s
     },
+    getBaseUrl () {
+      const host = window.location.hostname;
+      if (host === '192.168.0.109') {
+        return 'http://192.168.0.109:8090';
+      } else if (host === '219.151.181.73') {
+        return 'http://219.151.181.73:8090';
+      }else if(host === '183.247.216.148'){
+         return 'http://183.247.216.148:8090';
+      }
+      return 'http://192.168.0.109:8090'; // 默认值
+    },
     getFile() {
       this.excelshow = true
       this.exceloption.isEdit = true
@@ -405,8 +416,9 @@ s
       this.exceloption.user = { id: this.userInfo.id, name: this.userInfo.user_name }
       // this.exceloption.editUrl = "http://172.31.222.127:8090/blade-manager/exceltab/callbackSave";
       // this.exceloption.editUrl = "http://47.110.251.215:8090/blade-manager/exceltab/callbackSave";
-      // this.exceloption.editUrl = "http://39.108.216.210:8090/blade-manager/exceltab/callbackSave";
-          this.exceloption.editUrl =  "http://192.168.0.109:8090/blade-manager/exceltab/callbackSave";
+     // this.exceloption.editUrl = "http://219.151.181.73:8090/blade-manager/exceltab/callbackSave";
+          // this.exceloption.editUrl =  "http://192.168.0.109:8090/blade-manager/exceltab/callbackSave";
+          this.exceloption.editUrl = `${this.getBaseUrl()}/blade-manager/exceltab/callbackSave`;
       this.exceloption.key = this.from.id + "_" + Math.random() + "";
     },
     //刷新左边树形数据