Sfoglia il codice sorgente

云模管理系统地图修改

sunyadv 5 anni fa
parent
commit
a2c7cd03f4
2 ha cambiato i file con 15 aggiunte e 236 eliminazioni
  1. 11 2
      ys_int/config/index.js
  2. 4 234
      ys_int/src/views/map/map.vue

+ 11 - 2
ys_int/config/index.js

@@ -1,4 +1,13 @@
 var path = require('path')
+var os = require('os'), ip = '', ifaces = os.networkInterfaces() // 获取本机ip
+for (var i in ifaces) {
+    for (var j in ifaces[i]) {
+        var val = ifaces[i][j]
+        if (val.family === 'IPv4' && val.address !== '127.0.0.1') {
+            ip = val.address
+        }
+    }
+}
 
 module.exports = {
   build: {
@@ -20,7 +29,7 @@ module.exports = {
     assetsPublicPath: '/',
     proxyTable: {
         '/api': {    
-            target: 'http://192.168.101.166:8099',  // 接口域名 开发
+            target: 'http://'+ ip +':8099',  // 接口域名 开发
             secure: true,  // 如果是https接口,需要配置这个参数
             changeOrigin: true,  //是否跨域
             pathRewrite: { // 如果接口本身没有api的路径,那么这里将发送到后端的请求重写为没有api的路径
@@ -28,7 +37,7 @@ module.exports = {
             }
         },
         '/ips': {    
-            target: 'http://192.168.101.166:8080',  // 接口域名 开发
+            target: 'http://'+ ip +':8080',  // 接口域名 开发
             secure: true,  // 如果是https接口,需要配置这个参数
             changeOrigin: true,  //是否跨域
             pathRewrite: { // 如果接口本身没有api的路径,那么这里将发送到后端的请求重写为没有api的路径

+ 4 - 234
ys_int/src/views/map/map.vue

@@ -245,13 +245,14 @@
                             marker.content = str;
                             marker.id = data[i].id;
                             marker.on('click', jumpTo);
-                            marker.on('mouseover', openInfo);
-                            marker.on('mouseout', closeInfo);
+                            // marker.on('mouseover', openInfo);
+                            // marker.on('mouseout', closeInfo);
                         }
                     }
 
                     function jumpTo(e) {
-                        _this.$router.push("/moldList/" + e.target.id + "/0");
+                        // _this.$router.push("/moldList/" + e.target.id + "/0");
+                        _this.$router.push("/moldList");
                     }
 
                     function openInfo(e) {
@@ -304,237 +305,6 @@
 
             that.setMap();
         },
-        // mounted() {
-        //     this.$el.style.height = (window.innerHeight - 100) + "px";
-        //     const that = this;
-        //     window.onresize = function temp() {
-        //         that.$el.style.height = (window.innerHeight - 100) + "px";
-        //     };
-
-        //     //新地图
-        //     var map = new AMap.Map('container', {
-        //         zoom: 4,
-        //         mapStyle: "amap://styles/8016abec658e1132508723183f848f14",
-        //         features: ['bg']
-        //     });
-
-        //     var _this = this;
-        //     //加载相关组件
-        //     AMapUI.load(['ui/geo/DistrictCluster', 'ui/misc/PointSimplifier', 'lib/$' ,  'lib/utils'], function(DistrictCluster, PointSimplifier , $ , utils) {
-
-        //         window.DistrictCluster = DistrictCluster;
-
-        //         //启动页面
-        //         var pointSimplifierIns = new PointSimplifier({
-        //             map: map, //所属的地图实例
-        //             autoSetFitView: false, //禁止自动更新地图视野
-        //             zIndex: 110,
-        //             getPosition: function(item) {
-        //                 if (!item) {
-        //                     return null;
-        //                 }
-        //                 console.log(item)
-        //                 //返回经纬度
-        //                 // return [parseFloat(item.lng), parseFloat(item.lat)];
-        //                 return [item.lng, item.lat];
-        //             },
-        //             getHoverTitle: function(dataItem, idx) {
-        //                 var state = "";
-        //                 if(dataItem.state == '0'){
-        //                     state = '<span style="color:#909399">'+_this.$t('base.static')+'</span>'//_this.$t('base.static') // 静止
-        //                 } else if(dataItem.state == '1'){
-        //                     state = '<span style="color:#00CD66">'+_this.$t('base.run')+'</span>'
-        //                     // state = _this.$t('base.run') // 运行
-        //                 } else if(dataItem.state == '2'){
-        //                     state = '<span style="color:#F56C6C">'+_this.$t('base.warning')+'</span>'
-        //                     // state = _this.$t('base.warning') // 告警
-        //                 } else if(dataItem.state == '3'){
-        //                     state = '<span style="color:#909399">'+_this.$t('base.beScrapped')+'</span>'
-        //                     // state = _this.$t('base.scrap') // 报废
-        //                 } else if(dataItem.state == '4'){
-        //                     state = '<span style="color:#909399">'+_this.$t('base.scraped')+'</span>'
-        //                 } else if(dataItem.state == '5'){
-        //                     state = '<span style="color:#F56C6C">'+_this.$t('base.abnormal')+'</span>'
-        //                 } else if(dataItem.state == '6'){
-        //                     state = '<span style="color:#F56C6C">'+_this.$t('base.dropped')+'</span>'
-        //                 }
-
-        //                 var str = "<div>模具名称:&nbsp;&nbsp;&nbsp;"+ dataItem.modelName +"</div><div>运行状态:&nbsp;&nbsp;&nbsp;"+ state +"</div>"
-                        
-        //                 return  str;
-        //             },
-        //             renderOptions: {
-        //                 //点的样式
-        //                 pointStyle: {
-        //                     width: 6,
-        //                     height: 6,
-        //                     // fillStyle:'rgba(0, 236, 252, 0.9)'
-        //                     fillStyle:'rgba(255, 0, 0, 1)',
-        //                 },
-        //                 //鼠标hover时的title信息
-        //                 hoverTitleStyle: {
-        //                     position: 'top'
-        //                 },
-        //             }
-        //         });
-
-        //         function MyRender(distClusterIns, opts) {
-        //             //直接调用父类的构造函数
-        //             MyRender.__super__.constructor.apply(this, arguments);
-        //         }
-
-        //         //继承默认引擎
-        //         utils.inherit(MyRender, DistrictCluster.Render.Default);
-
-        //         utils.extend(MyRender.prototype, {
-        //             drawFeaturePolygons: function(ctx, polygons, styleOptions, feature, dataItems) {
-        //                 //调用父类方法
-        //                 MyRender.__super__.drawFeaturePolygons.apply(this, arguments);
-
-        //                 //直接绘制聚合信息
-        //                 this.drawMyLabel(feature, dataItems);
-        //             },
-        //             _initContainter: function() {
-        //                 //调用父类方法
-        //                 MyRender.__super__._initContainter.apply(this, arguments);
-
-        //                 //创建一个新的canvas
-        //                 this._createCanvas('mylabel', this._container);
-        //             },
-        //             /**
-        //              * 绘制一个蓝底白字的label替代聚合标注
-        //              */
-        //             drawMyLabel: function(feature, dataItems) {
-        //                 var pixelRatio = this.getPixelRatio(); //高清下存在比例放大
-
-        //                 var containerPos = map.lngLatToContainer(feature.properties.centroid || feature.properties.center);
-
-        //                 var labelCtx = this._getCanvasCxt('mylabel');
-
-        //                 //文字的中心点
-        //                 var centerX = containerPos.getX() * pixelRatio,
-        //                     centerY = containerPos.getY() * pixelRatio;
-
-        //                 labelCtx.save();
-
-        //                 labelCtx.font = 12 * pixelRatio + 'px 微软雅黑';
-                        
-        //                 var name = feature.properties.name;
-        //                 if(feature.properties.level == "province") {
-        //                     if(name == "黑龙江省" || name == "内蒙古自治区"){
-        //                         name = name.substring(0,3)
-        //                     } else {
-        //                         name = name.substring(0,2)
-        //                     }
-        //                 }
-        //                 var text = name;//feature.properties.name ;//+ '\n' + dataItems.length;
-        //                 var textMetrics = labelCtx.measureText(text);
-        //                 var halfTxtWidth = textMetrics.width / 2;
-
-        //                 var num = dataItems.length;
-        //                 var numMetrics = labelCtx.measureText(num);
-        //                 var halfNumWidth = numMetrics.width / 2;
-
-        //                 // labelCtx.fillStyle = 'rgba(3 , 94 , 255 , 0.5)';//'#3366cc';
-                        
-        //                 labelCtx.beginPath();
-        //                 labelCtx.fillStyle = 'rgba(12 , 239 , 231 , 0.8)';//'#3366cc';
-
-        //                 //绘制一个蓝色背景
-        //                 labelCtx.strokeStyle= "rgba(12 , 239 , 231 , 0.65)"
-        //                 labelCtx.fillStyle = 'rgba(12 , 239 , 231 , 0.65)';
-                        
-        //                 var radius = 0;
-        //                 if(textMetrics.width > numMetrics.width) {
-        //                     radius = (textMetrics.width + 6 * pixelRatio) / 2;
-        //                 } else {
-        //                     radius = (numMetrics.width + 6 * pixelRatio) / 2;
-        //                 }
-
-        //                 labelCtx.arc(centerX , centerY, radius + 6,
-        //                     0*Math.PI, 2*Math.PI, false);
-
-        //                 labelCtx.closePath();
-        //                 labelCtx.fill();
-
-        //                 labelCtx.fillStyle = '#ffffff';
-        //                 labelCtx.textBaseline = 'middle';
-
-        //                 labelCtx.fillText(text, centerX - halfTxtWidth, centerY - 5);
-        //                 labelCtx.fillText(num , centerX - halfNumWidth, centerY + 12);
-
-        //                 labelCtx.stroke();
-        //                 labelCtx.restore();
-        //             }
-        //         });
-
-        //         var distCluster = new DistrictCluster({
-        //             zIndex: 100,
-        //             map: map, //所属的地图实例
-        //             getPosition: function(item) {
-        //                 if (!item) {
-        //                     return null;
-        //                 }
-        //                 //返回经纬度
-        //                 // return [parseFloat(item.lng), parseFloat(item.lat)];
-        //                 return [item.lng, item.lat];
-        //             },
-        //             renderConstructor: MyRender,
-        //             //特定区划级别的默认样式
-        //             renderOptions: {
-        //                 getClusterMarker: null,
-        //                 featureClickToShowSub: true,
-        //                 featureStyle: {
-        //                     lineWidth: 2, //描边线宽
-        //                     // strokeStyle: 'rgba(0, 119, 180, 0.5)', //描边色
-        //                     strokeStyle: 'rgba(75, 143, 239, 0.5)', //描边色
-        //                     //鼠标Hover后的样式
-        //                     hoverOptions: {
-        //                         fillStyle: 'rgba(255,255,255,0.2)'
-        //                     }
-        //                 },
-        //                 getFeatureStyle: function(feature, dataItems) {
-        //                     return {
-        //                         fillStyle: ''
-        //                     };
-        //                 }
-        //             },
-        //         });
-
-        //         window.distCluster = distCluster;
-
-        //         map.on('zoomend', function() {
-        //             var zoom = map.getZoom();
-        //             //获取 pointStyle
-        //             var pointStyle = pointSimplifierIns.getRenderOptions().pointStyle;
-        //             //根据当前zoom调整点的尺寸
-        //             pointStyle.width = pointStyle.height = 2 * Math.pow(1.2, map.getZoom() - 3);
-        //         });
-
-        //         var zoom = map.getZoom();
-        //         //获取 pointStyle
-        //         var pointStyle = pointSimplifierIns.getRenderOptions().pointStyle;
-        //         //根据当前zoom调整点的尺寸
-        //         pointStyle.width = pointStyle.height = 2 * Math.pow(1.2, map.getZoom() - 3);
-
-        //         $('<div id="loadingTip">加载数据,请稍候...</div>').appendTo(document.body);
-        //         _this.http.post( _this.port.map.newMap, {},
-        //         res => {
-        //             $('#loadingTip').remove();
-        //             var data = res.data;
-        //             _this.moldList = data;
-        //             distCluster.setData(data);
-        //             pointSimplifierIns.setData(data);
-        //             map.setZoomAndCenter(5, [105.205467, 34.907761]);
-        //         },
-        //         error => {
-        //             _this.$message({
-        //                 message: error,
-        //                 type: "error"
-        //             });
-        //         })
-        //     });
-        // }
 	}
 
 </script>