liuhj преди 4 месеца
родител
ревизия
2ac5a02d07
променени са 1 файла, в които са добавени 108 реда и са изтрити 27 реда
  1. 108 27
      src/components/statistics/Statistically.vue

+ 108 - 27
src/components/statistics/Statistically.vue

@@ -355,13 +355,13 @@
                     </div>
                 </el-tab-pane>
                 <el-tab-pane label="地图" name="fifth">
-                    <el-date-picker
+                    <!-- <el-date-picker
                     v-model="mapdate"
                     style="width: 200px;margin-bottom:10px;"
                     type="date"
                     size="small"
                     placeholder="选择日期">
-                    </el-date-picker>
+                    </el-date-picker> -->
                     <div id="map" style="width:100%; height: 700px;"></div>
                 </el-tab-pane>
                 <!-- <el-tab-pane label="会务数据统计" name="third">会务数据统计</el-tab-pane> -->
@@ -496,6 +496,7 @@ export default {
                     address: "MQGH+RF 中央区 日本东京都"
                 },
             ],
+            fordata:[],
         }
     }, 
     methods: {
@@ -663,8 +664,6 @@ export default {
                     done(token);
                 },
             });
-            
-
             var CALLOUT_OFFSET = new DOMPoint(-148, -78);
             var landmarkAnnotationCallout = {
                 calloutElementForAnnotation: function(annotation) {
@@ -694,34 +693,116 @@ export default {
                 language: "zh-Hans",
                 getsUserLocation: true
             });
+            var that=this;
+            that.fordata=[];
             for (let i = 0; i < this.mapdata.length; i++) {
-                geocoder.lookup(this.mapdata[i].groupName, function (err, data) {
-                    console.log(data);
+                var listinif={}
+                geocoder.lookup(this.mapdata[i].address, function (err, data) {
+                    if (err) {
+                        console.log(err);
+                    }else{
+                        console.log(data); 
+                        listinif=data.results[0]?data.results[0]:{}
+                    }
+                    console.log(listinif);
                     
-                });
+                    that.fordata.push(
+                        {
+                            'country':listinif.country?listinif.country:'',
+                            'administrativeArea':listinif.administrativeArea?listinif.administrativeArea:'',
+                            'locality':listinif.locality?listinif.locality:'',
+                            'latitude':listinif.coordinate.latitude?listinif.coordinate.latitude:'',
+                            'longitude':listinif.coordinate.longitude?listinif.coordinate.longitude:'',
+                            'groupName':that.mapdata[i].groupName,
+                            'client':that.mapdata[i].client,
+                            'statusText':that.mapdata[i].statusText,
+                        }
+                    )
+                    if (that.fordata.length==that.mapdata.length) {
+                        console.log(that.fordata);
+                        var nonnull=[]
+                        for (let j = 0; j < that.fordata.length; j++) {
+                            if (that.fordata[j].latitude!='') {
+                                nonnull.push(that.fordata[j])
+                            }
+                        }
+                        console.log(nonnull);
+
+                       let sanFranciscoLandmarks=[];
+                       for (let k = 0; k < nonnull.length; k++) {
+                            sanFranciscoLandmarks.push(
+                                {
+                                    'coordinate':new mapkit.Coordinate(Number(nonnull[k].latitude),Number(nonnull[k].longitude)),
+                                    'title':nonnull[k].country+' '+nonnull[k].administrativeArea+' '+nonnull[k].locality,
+                                    'phone':nonnull[k].groupName+' ('+nonnull[k].statusText+') ',
+                                    'url':'http://www.transamericapyramidcenter.com/',
+                                }
+                            )
+                        
+                       }
+                        var annotations = sanFranciscoLandmarks.map(function (landmark) {
+                            var annotation = new mapkit.MarkerAnnotation(landmark.coordinate, {
+                                callout: landmarkAnnotationCallout,
+                                color: "#c969e0"
+                            });
+                            annotation.landmark = landmark;
+                            return annotation;
+                        });
+                        that.map = new mapkit.Map("map");
+                        that.map.showItems(annotations); 
+                        
+                       
+                    }
+                })
+
+                
+            }
+            
+            // var sanFranciscoLandmarks = [
+            //     { coordinate: new mapkit.Coordinate(52.2402, 13.0333), title: "波茨坦", phone: "水电费水电费<br/>asdasdasdasd<br/>tgtgtg", url: "http://www.transamericapyramidcenter.com/" },
+            //     { coordinate: new mapkit.Coordinate(30.39, 104.04), title: "成都", phone: "+1 (415) 983-8030", url: "http://www.ferrybuildingmarketplace.com" },
+            //     { coordinate: new mapkit.Coordinate(37.8083396, -122.415727), title: "Fisherman's Wharf", phone: "+1 (415) 673-3530", url: "http://visitfishermanswharf.com" },
+            //     { coordinate: new mapkit.Coordinate(52.2285426,21.0128161), title: "波兰国家农业理事会 ", phone: "+1 (415) 249-0995", url: "http://sfrecpark.org/destination/telegraph-hill-pioneer-park/coit-tower/" },
+            //     { coordinate: new mapkit.Coordinate(31.2203102, 121.4623931), title: "上海", phone: "+1 (415) 681-8850", url: "http://www.sutrotower.com" },
+            //     { coordinate: new mapkit.Coordinate(37.779267, -122.419269), title: "City Hall", phone: "+1 (415) 701-2311", url: "http://sfgsa.org/index.aspx?page=1085" },
+            //     { coordinate: new mapkit.Coordinate(37.8184493, -122.478409), title: "Golden Gate Bridge", phone: "+1 (415) 921-5858", url: "http://www.goldengatebridge.org" },
+            //     { coordinate: new mapkit.Coordinate(37.7785538, -122.514035), title: "Cliff House", phone: "+1 (415) 386-3330", url: "http://www.cliffhouse.com/" },
+            // ];
+            
+        },
+        combineAttributesByProperty(objects, property) {
+            // 检查数组是否为空或属性未指定
+            if (objects.length === 0 || !property) {
+                return {};
             }
-            var sanFranciscoLandmarks = [
-                { coordinate: new mapkit.Coordinate(52.2402, 13.0333), title: "波茨坦", phone: "水电费水电费<br/>asdasdasdasd<br/>tgtgtg", url: "http://www.transamericapyramidcenter.com/" },
-                { coordinate: new mapkit.Coordinate(30.39, 104.04), title: "成都", phone: "+1 (415) 983-8030", url: "http://www.ferrybuildingmarketplace.com" },
-                { coordinate: new mapkit.Coordinate(37.8083396, -122.415727), title: "Fisherman's Wharf", phone: "+1 (415) 673-3530", url: "http://visitfishermanswharf.com" },
-                { coordinate: new mapkit.Coordinate(52.2285426,21.0128161), title: "波兰国家农业理事会 ", phone: "+1 (415) 249-0995", url: "http://sfrecpark.org/destination/telegraph-hill-pioneer-park/coit-tower/" },
-                { coordinate: new mapkit.Coordinate(31.2203102, 121.4623931), title: "上海", phone: "+1 (415) 681-8850", url: "http://www.sutrotower.com" },
-                { coordinate: new mapkit.Coordinate(37.779267, -122.419269), title: "City Hall", phone: "+1 (415) 701-2311", url: "http://sfgsa.org/index.aspx?page=1085" },
-                { coordinate: new mapkit.Coordinate(37.8184493, -122.478409), title: "Golden Gate Bridge", phone: "+1 (415) 921-5858", url: "http://www.goldengatebridge.org" },
-                { coordinate: new mapkit.Coordinate(37.7785538, -122.514035), title: "Cliff House", phone: "+1 (415) 386-3330", url: "http://www.cliffhouse.com/" },
-            ];
-            var annotations = sanFranciscoLandmarks.map(function(landmark) {
-                var annotation = new mapkit.MarkerAnnotation(landmark.coordinate, {
-                    callout: landmarkAnnotationCallout,
-                    color: "#c969e0"
-                });
-                annotation.landmark = landmark;
-                return annotation;
+           
+            // 存储结果的对象
+            const combinedAttributes = {};
+
+            // 检查所有对象的指定属性值是否相等
+            const propertyValues = objects.map(obj => obj[property]);
+            console.log(propertyValues);
+            
+            const uniquePropertyValues = new Set(propertyValues);
+            console.log(uniquePropertyValues);
+            
+            // if (uniquePropertyValues.size !== 1) {
+            //     // 如果属性值不唯一,返回空对象
+            //     return combinedAttributes;
+            // }
+
+            // 属性值相等,遍历数组中的对象
+            objects.forEach(obj => {
+                // 跳过要检查的属性,将其他属性添加到结果对象中
+                for (const key in obj) {
+                    if (obj.hasOwnProperty(key) && key !== property) {
+                        combinedAttributes[key] = obj[key];
+                    }
+                }
             });
-            this.map = new mapkit.Map("map");
-            this.map.showItems(annotations); 
+
+            return combinedAttributes;
         },
-        
         //团组酒店
         grouphotel(){
             var hoteltopten = echarts.init(document.getElementById('hoteltopten'));