yf_zd 4 년 전
부모
커밋
4ff6b634b3

+ 1 - 1
config/index.js

@@ -21,7 +21,7 @@ module.exports = {
     },
 
     // Various Dev Server settings
-    host: '192.168.1.3', // can be overwritten by process.env.HOST
+    host: '192.168.1.101', // can be overwritten by process.env.HOST
     port: 8000, // can be overwritten by process.env.PORT, if port is in use, a free one will be determined
     autoOpenBrowser: false,
     errorOverlay: true,

BIN
dist.zip


+ 3 - 1
index.html

@@ -11,7 +11,9 @@
     <!-- IOS中禁用将数字识别为电话号码/忽略Android平台中对邮箱地址的识别 -->
     <meta name="format-detection" content="telephone=no, email=no"/>
     <script src="./static/js/ezuikit.js"></script>
-    <script src="https://webapi.amap.com/maps?v=2.0&key=3939967b919a8003377dd113fc445a3d&plugin=AMap.PolygonEditor"></script>
+    <script src="https://webapi.amap.com/maps?v=2.0&key=3939967b919a8003377dd113fc445a3d&plugin=AMap.PolygonEditor,AMap.DistrictSearch"></script>
+    <!-- UI组件库 1.0 -->
+    <script src="//webapi.amap.com/ui/1.1/main.js?v=1.1.1"></script>
   </head>
   <body>
     <div id="app"></div>

+ 45 - 0
src/assets/css/form.css

@@ -0,0 +1,45 @@
+/* 这里注意:我当前将css样式加载全局上,如果单页添加样式需要每个样式前添加 ‘/deep/’ 修饰符 */
+/*  dialog*/
+.el-dialog__header {
+  padding: 15px 20px 15px;
+}
+.el-dialog__headerbtn{
+  top: 18px;
+}
+
+/*dialog header*/
+.el-dialog__header{
+  background: #e3eaed;
+}
+.avue-crud__dialog__header {
+  display: -webkit-box;
+  display: -ms-flexbox;
+  display: flex;
+  -webkit-box-align: center;
+  -ms-flex-align: center;
+  align-items: center;
+  -webkit-box-pack: justify;
+  -ms-flex-pack: justify;
+  justify-content: space-between;
+}
+.el-dialog__title {
+  color: rgba(0,0,0,.85);
+  font-weight: 500;
+  word-wrap: break-word;
+}
+.avue-crud__dialog__menu {
+  padding-right: 25px;
+  float: left;
+  font-size: 12px;
+}
+.avue-crud__dialog__menu i {
+  color: #909399;
+  font-size: 15px;
+}
+.el-icon-full-screen{
+  cursor: pointer;
+}
+.el-icon-full-screen:before {
+  content: "\e719";
+}
+

+ 13 - 13
src/components/highStand/equipList.vue

@@ -49,25 +49,25 @@ export default {
 
 .legend {
   position: absolute;
-  top: 80px;
-  bottom: 10px;
-  left: 30px;
+  top: 1.2rem;
+  bottom: 20px;
+  left: .375rem;
   display: flex;
   align-items: flex-start;
   z-index: 151;
+  align-items: flex-end;
   .legend-menu {
     background: #242424;
     color: #fff;
     opacity: .7;
-    width: 23px;
-    border-top-right-radius: 4px;
-    border-bottom-right-radius: 4px;
-    font-size: 14px;
-    line-height: 20px;
+    width: .2875rem;
+    border-top-right-radius: .05rem;
+    border-bottom-right-radius: .05rem;
+    font-size: .175rem;
+    line-height: .25rem;
     text-align: center;
     cursor: pointer;
-    margin-top: calc(100vh - 277px);
-    padding: 6px;
+    padding: .075rem;
     i {
       transition: 0.5s;
     }
@@ -82,7 +82,7 @@ export default {
     height: 100%;
     overflow-x: hidden;
     overflow-y: auto;
-    border-radius: 6px;
+    border-radius: .075rem;
     color: #212121;
     .content {
       box-sizing: border-box;
@@ -93,10 +93,10 @@ export default {
 .legend.open {
   .legend-menu{
     opacity: 1;
-    border-radius: 4px;
+    border-radius: .05rem;
   }
   .legend-detail {
-    width: 380px;
+    width: 4.75rem;
   }
 }
 </style>

+ 5 - 0
src/main.js

@@ -187,6 +187,11 @@ Vue.filter('equipType', function (i) {
   }
 })
 
+// 弹框拖拽
+import './util/directives.js'
+// 弹框样式
+import '@/assets/css/form.css'
+
 router.beforeEach((to, from, next) => {
   let isLogin = JSON.parse(localStorage.getItem('isLogin'));
   if (to.path === '/login') {

+ 427 - 300
src/pages/plantGuard/baseAll.vue

@@ -1,219 +1,261 @@
-<!--  -->
+<!-- mapui-->
 <template>
-  <div class="inner">
-    <div class="mapCover">
-      <div id="map">地图</div>
+<div class='map'>
+    <div id="container">加载数据,请稍候...</div>
+    <div class="leftNavBox">
+        <div class="searchBox">
+            <el-select size="small" @change="search('province')" filterable v-model="form.province" placeholder="选择省">
+                <el-option label="--请选择--" value=""></el-option>
+                <el-option
+                    v-for="item in provinceList"
+                    :key="item.adcode"
+                    :label="item.name"
+                    :value="item.adcode">
+                </el-option>
+            </el-select>
+            <el-select size="small" @change="search('city')" filterable v-model="form.city" placeholder="选择市">
+                <el-option label="--请选择--" value=""></el-option>
+                <el-option
+                    v-for="item in cityList"
+                    :key="item.adcode"
+                    :label="item.name"
+                    :value="item.adcode">
+                </el-option>
+            </el-select>
+            <el-select size="small" @change="search('district')" filterable v-model="form.district" placeholder="选择区">
+                <el-option label="--请选择--" value=""></el-option>
+                <el-option
+                    v-for="item in districtList"
+                    :key="item.adcode"
+                    :label="item.name"
+                    :value="item.adcode">
+                </el-option>
+            </el-select>
+        </div>
+        <div class="listBox">
+            <div class="projectSearch">
+                <div>项目列表</div>
+                <div>
+                    <el-input
+                        size="small"
+                        placeholder="请输入项目名称"
+                        v-model="input"
+                        suffix-icon="el-icon-search"
+                        clearable>
+                    </el-input>
+                </div>
+            </div>
+            <div></div>
+        </div>
     </div>
-    <div class="mapTypebox">
-      <el-radio-group v-model="mapType" @change="changeMapType">
-        <el-radio :label="0">标准图</el-radio>
-        <el-radio :label="1">卫星图</el-radio>
-      </el-radio-group>
-    </div>
-  </div>
+</div>
 </template>
 
 <script>
 //这里可以导入其他文件(比如:组件,工具js,第三方插件js,json文件,图片文件等等)
 //例如:import 《组件名称》 from '《组件路径》';
-import { bd09togcj02,gcj02tobd09,wgs84togcj02,gcj02towgs84 } from "../../components/home/coordtransform_utils";  //纠偏方法
 export default {
-  //import引入的组件需要注入到对象中才能使用
-  components: {
-  },
-  data() {
-    //这里存放数据
-    return {
-      // center: [65.212881,31.279042],
-      // zoom: 8,
-      mapType: 1,
-      tileLayer1: null,
-      tileLayer2: null,
-      equipListCurr:[],
-      equipStyleObject:[
-        {
-          url: require("../../../static/images/projectIcon.png"), // 设别类型0
-          size: new AMap.Size(70, 70), // 图标大小
-          anchor: new AMap.Pixel(0,0) // 图标显示位置偏移量,基准点为图标左上角
-        },
-        {
-          url: require("@/assets/images/home/mapView/scd.png"), // 设别类型1
-          size: new AMap.Size(25, 15), // 图标大小
-          anchor: new AMap.Pixel(5, 5) // 图标显示位置偏移量,基准点为图标左上角
-        },
-        {
-          url: require("@/assets/images/home/mapView/scd.png"), // 设别类型2
-          size: new AMap.Size(25, 15), // 图标大小
-          anchor: new AMap.Pixel(5, 5) // 图标显示位置偏移量,基准点为图标左上角
-        },
-        {
-          url: require("@/assets/images/home/mapView/cbd.png"), // 设别类型3
-          size: new AMap.Size(25, 15), // 图标大小
-          anchor: new AMap.Pixel(5, 5) // 图标显示位置偏移量,基准点为图标左上角
-        },
-        {
-          url: require("@/assets/images/home/mapView/xyq.png"), // 设别类型4
-          size: new AMap.Size(25, 15), // 图标大小
-          anchor: new AMap.Pixel(5, 5) // 图标显示位置偏移量,基准点为图标左上角
-        },
-        {
-          url: require("@/assets/images/home/mapView/qxz.png"), // 设别类型5
-          size: new AMap.Size(25, 15), // 图标大小
-          anchor: new AMap.Pixel(5, 5) // 图标显示位置偏移量,基准点为图标左上角
-        },
-        {
-          url: require("@/assets/images/home/mapView/jk.png"), // 设别类型6
-          size: new AMap.Size(25, 15), // 图标大小
-          anchor: new AMap.Pixel(5, 5) // 图标显示位置偏移量,基准点为图标左上角
-        },
-        {
-          url: require("@/assets/images/home/mapView/bzy.png"), // 设别类型7
-          size: new AMap.Size(25, 15), // 图标大小
-          anchor: new AMap.Pixel(5, 5) // 图标显示位置偏移量,基准点为图标左上角
-        },
-        {
-          url: require("@/assets/images/home/mapView/bzy.png"), // 设别类型8
-          size: new AMap.Size(25, 15), // 图标大小
-          anchor: new AMap.Pixel(5, 5) // 图标显示位置偏移量,基准点为图标左上角
-        },
-        {
-          url: require("@/assets/images/home/mapView/tccb.png"), // 设别类型9
-          size: new AMap.Size(25, 15), // 图标大小
-          anchor: new AMap.Pixel(5, 5) // 图标显示位置偏移量,基准点为图标左上角
-        },
-      ],
-      icon:{
-        // 图标类型,现阶段只支持 image 类型
-        type: 'image',
-        // 图片 url
-        image: require("../../../static/images/icon5.svg"),
-        // 图片尺寸
-        size: [74, 66],
-        // 图片相对 position 的锚点,默认为 bottom-center
-        anchor: 'center',
-      },
-      // markers: [
-      //   {
-      //     addr: [121.5273285, 31.21515044],
-      //     projectname: '南阳农田项目南阳农田项目',
-      //     uid:1
-      //   },
-      // ],
-      markersStatus:{
-        iconOffset: [-70, -70],
-        textOffset: [-35, 0],
-        icon:require('../../../static/images/icon5.svg'),
-        events: {
-          click: (e) => {
-            console.log(e.target.Ce.vid)
-            console.log(this.markers[e.target.Ce.vid])
-            // this.$store.state.user_id = this.markers[e.target.Ce.vid].uid
-            this.$store.commit('setUserId',this.markers[e.target.Ce.vid].uid)
-            this.$router.push('page1')
-          },
-          dragend: (e) => {
-            console.log('---event---: dragend')
-            // this.markers[0].position = [e.lnglat.lng, e.lnglat.lat];
-          }
-        },
-        visible: true,
-        draggable: false,
-      },
-      txtLabels:[],
-      layer:null,
-      markers:[],
-    };
-  },
-  //监听属性 类似于data概念
-  computed: {},
-  //监控data中的数据变化
-  watch: {},
-  //方法集合
-  methods: {
-    // 初始化地图
-    infoMap(){
-        this.map = new AMap.Map("map", {
-            center: this.center,
-            resizeEnable: true,
-            zoom: 4,
-            lang: "en",
+//import引入的组件需要注入到对象中才能使用
+components: {},
+data() {
+//这里存放数据
+return {
+    map:null,
+    data:[],
+    topAdcodes:[100000],//全国区划编码
+    center:[116.3683244,39.915085],
+    zoom:4.5,
+    // 搜索
+    form:{
+        province:'',
+        city:'',
+        district:'',
+    },
+    provinceList:[],
+    cityList:[],
+    districtList:[],
+    district:null,
+    input:'',
+    polygons:[],
+};
+},
+//监听属性 类似于data概念
+computed: {},
+//监控data中的数据变化
+watch: {},
+//方法集合
+methods: {
+    initMap(){
+         //创建地图
+            var that = this
+            this.map = new AMap.Map('container', {
+                center:that.center,
+                zoom: that.zoom
+            });
+            AMapUI.loadUI(['control/BasicControl'], function(BasicControl) {
+                //缩放控件,显示Zoom值
+                that.map.addControl(new BasicControl.Zoom({
+                    position: 'rb',
+                    showZoomNum: true
+                }));
+            });
+                //加载相关组件
+            AMapUI.load(['ui/geo/DistrictCluster', 'lib/$'], function(DistrictCluster, $) {
+
+                //启动页面
+                that.initPage(DistrictCluster, $);
+            });
+    },
+    initPage(DistrictCluster, $) {
+        var that = this;
+        var distCluster = new DistrictCluster({
+            map: that.map, //所属的地图实例
+            zIndex:11,
+            autoSetFitView: false,
+            topAdcodes: that.topAdcodes,
+            getPosition: function(item) {
+                if (!item) {
+                    return null;
+                }
+                var parts = item.split(',');
+                //返回经纬度
+                return [parseFloat(parts[0]), parseFloat(parts[1])];
+            },
+            renderOptions: {
+                // clusterMarkerKeepConsistent: false, //marker的位置随交互变化
+                 //基础样式
+                featureStyle: {
+                    fillStyle: 'rgba(102,170,0,0.5)', //填充色
+                    lineWidth: 2, //描边线宽
+                    strokeStyle: '#4e6ef2', //描边色
+                    //鼠标Hover后的样式
+                    hoverOptions: {
+                        fillStyle: 'rgba(255,255,255,0.2)'
+                    }
+                },
+                //特定区划级别的默认样式
+                featureStyleByLevel: {
+                    //全国
+                    country: {
+                        fillStyle: 'rgba(78,110,242,0.8)'
+                    },
+                    //省
+                    province: {
+                        fillStyle: 'rgba(78,110,242,0.7)'
+                    },
+                    //市
+                    city: {
+                        fillStyle: 'rgba(78,110,242,0.6)'
+                    },
+                    //区县
+                    district: {
+                        fillStyle:'rgba(78,110,242,0.5)'
+                    }
+                },
+                getClusterMarker: function(feature, dataItems, recycledMarker) {
+
+                    //不是当前feature,直接返回null
+                    if(dataItems.length){
+                        var container, title, body, nodeClassNames = {
+                            title: 'amap-ui-district-cluster-marker-title',
+                            body: 'amap-ui-district-cluster-marker-body',
+                            container: 'amap-ui-district-cluster-marker'
+                        };
+                        
+                        console.log(recycledMarker);
+                        if (recycledMarker) {
+                        console.log(recycledMarker.getContent());
+
+                            container = recycledMarker.getContent();
+
+                            title = $(container).find('.' + nodeClassNames.title)[0];
+
+                            body = $(container).find('.' + nodeClassNames.body)[0];
+
+                        } else {
+
+                            container = document.createElement('div');
+
+                            title = document.createElement('span');
+
+                            title.className = nodeClassNames.title;
+
+                            body = document.createElement('span');
+
+                            body.className = nodeClassNames.body;
+
+                            container.appendChild(title);
+
+                            container.appendChild(body);
+                        }
+                        console.log(feature.properties);
+                        
+                        var props = feature.properties,
+                            routeNames = [];
+
+                        var classNameList = [nodeClassNames.container, 'level_' + props.level, 'adcode_' + props.adcode];
+
+                        container.className = classNameList.join(' ');
+
+                        if (routeNames.length > 0) {
+
+                            routeNames.push(props.name);
+
+                            container.setAttribute('title', routeNames.join('>'));
+
+                        } else {
+                            container.removeAttribute('title');
+                        }
+
+                        $(title).html(props.name);
+                        $(body).html(dataItems.length);
+
+                        var resultMarker = recycledMarker || new AMap.Marker({
+                            topWhenClick: true,
+                            offset: new AMap.Pixel(-20, -30),
+                            content: container
+                        });
+                        console.log(container);
+                        console.log(resultMarker);
+                        
+                        return resultMarker;
+                    }
+                }
+            },
         });
-        AMap.plugin(
-        [
-          "AMap.ToolBar",
-          "AMap.Scale",
-          "AMap.MouseTool",
-          "AMap.Geocoder",
-          "AMap.PolyEditor",
-        ],
-        () => {
-          this.map.addControl(new AMap.ToolBar());
-          this.map.addControl(new AMap.Scale());
+            //监听区划面的点击
+        distCluster.on('clusterMarkerClick', function(e, feature) {
 
-          this.geocoder = new AMap.Geocoder({
-            city: "全国",
-            radius: 1000,
-          });
+           console.log(e)
+           console.log(feature)
+           console.log(that);
+        //    that.$router.push('/plantGuard/page8')
+            //重绘
+            //distCluster.renderLater();
+        });
+        window.distCluster = distCluster;
 
-        }
-      );
-      this.tileLayer1 = new AMap.TileLayer({
-        tileUrl:
-          "http://t{0,1,2,3,4,5,6,7}.tianditu.gov.cn/DataServer?T=img_w&tk=888bc7de1a5f14aa1b335b02e558d9b3&x=[x]&y=[y]&l=[z]",
-        zIndex: 10,
-      }); //卫星图层
-      this.tileLayer2 = new AMap.TileLayer({
-        // 图块取图地址
-        tileUrl:
-          "http://t{0,1,2,3,4,5,6,7}.tianditu.gov.cn/DataServer?T=cta_w&tk=888bc7de1a5f14aa1b335b02e558d9b3&x=[x]&y=[y]&l=[z]",
-        zIndex: 101,
-      });
-      this.map.add(this.tileLayer1);
-      // this.map.add(this.tileLayer2);
-      this.getEquipList();
-    },
-    changeMapType(val){ 
-      if(val==0){
-        this.tileLayer1.hide()
-        this.tileLayer2.hide()
-      }else{
-        this.tileLayer1.show()
-        this.tileLayer2.show()
-      }
-    },
- 
-    iconFormat(equip_ip, item) {
-      switch (equip_ip + "") {
-        case "2":
-          item.icon = require("@/assets/images/home/mapView/scd.png");
-          break;
-        case "3":
-          item.icon = require("@/assets/images/home/mapView/cbd.png");
-          break;
-        case "4":
-          item.icon = require("@/assets/images/home/mapView/xyq.png");
-          break;
-        case "5":
-          item.icon = require("@/assets/images/home/mapView/qxz.png");
-          break;
-        case "6":
-          item.icon = require("@/assets/images/home/mapView/jk.png");
-          break;
-        case "7":
-          item.icon = require("@/assets/images/home/mapView/bzy.png");
-          break;
-        case "9":
-          item.icon = require("@/assets/images/home/mapView/tccb.png");
-          break;
-      }
+
+        $('<div id="loadingTip">加载数据,请稍候...</div>').appendTo(document.body);
+        $.get('https://a.amap.com/amap-ui/static/data/10w.txt', function(csv) {
+
+            $('#loadingTip').remove();
+
+        // var data = [
+        //     "113.665412,34.757975",
+        //     "113.671767,34.815528",
+        //     "113.671867,34.825528",
+        //     "113.735978,34.728131",
+        //     "120.412618,36.382612",
+        //     "112.985037,23.15046",
+        //     "126.687123,45.787618"
+        //     ]
+            var data = csv.split('\n').slice(0,1000);
+            // that.data = data
+            distCluster.setData(that.data);
+        });
     },
     getEquipList() {
-      this.layer = new AMap.LabelsLayer({
-          zooms: [3, 20],
-          zIndex: 1000,
-          collision: false,
-          allowCollision: false,
-      });
       let uid = sessionStorage.getItem("myuid");
       this.$axios({
         method: "POST",
@@ -223,113 +265,198 @@ export default {
         })
       }).then(res => {
         if (res.data.message == ""){
-          var data = res.data.data.user_project;
-          this.equipListCurr = data.map((item) => {
-            if (item.gps == 1) {
-              //GPS
-              item.lnglat = wgs84togcj02(item.lng, item.lat);
-            }
-            item.position=[item.lnglat[0],item.lnglat[1]]
-            item.text={
-                content: item.projectname,
-                direction: 'bottom',
-                offset: [-20, -5],
-                style: {
-                  // 字体大小
-                  fontSize: 16,
-                  // 字体颜色
-                  fillColor: '#ff0000',
-                  // 描边颜色
-                  strokeColor: '#ff0000',
-                  // 描边宽度
-                  strokeWidth: 1,
-                }
-            }
-            item.extData={
-              uid:item.uid
-            }
-            item.icon=this.icon
-            return item;
-              
-          });
-
-          this.equipListCurr.forEach((item)=>{
-            var labelMarker = new AMap.LabelMarker(item);
-            labelMarker.on("click", (e) => {
-              this.equipMarkerClick(e.target.getExtData().uid);
-            });
-            this.markers.push(labelMarker);
-          })
-
-          // 将 marker 添加到图层
-          this.layer.add(this.markers);
-          this.map.add(this.layer);
-          // this.massMarks.setMap(this.map);
-          // this.massMarks.on("click", (e) => {
-          //   this.equipMarkerClick(e.data);
-          // });
+            this.data = []
+            var data = res.data.data.user_project;
+            data.forEach((item,index)=>{
+                this.data.push(item.lnglat[0]+','+item.lnglat[1])
+            })
+            this.$nextTick(()=>{
+                this.initMap()
+            })
         } else {
           this.$message.error(res.data.message);
         }
       });
     },
-    equipMarkerClick(uid) {
-      this.$store.commit('setUserId',uid)
-      this.$router.push('page1')
+    districtFun(){
+        this.map = new AMap.Map('container', {
+            resizeEnable: true,
+            center: [116.30946, 39.937629],
+            zoom: 3
+        });
+        //行政区划查询
+        var opts = {
+            subdistrict: 1,   //返回下一级行政区
+            showbiz:false  //最后一级返回街道信息
+        };
+        this.district = new AMap.DistrictSearch(opts);//注意:需要使用插件同步下发功能才能这样直接使用
+        this.district.search('中国', (status, result)=>{
+            if(status=='complete'){
+                this.getData(result.districtList[0],'country');
+            }
+        });
     },
+    getData(data,level) {
+        console.log(data);
+        
+        var bounds = data.boundaries;
+        if (bounds) {
+            for (var i = 0, l = bounds.length; i < l; i++) {
+                // var polygon = new AMap.Polygon({
+                //     map: this.map,
+                //     strokeWeight: 2,
+                //     strokeColor: 'rgba(78,110,242,1)',
+                //     fillColor: 'rgba(78,110,242,1)',
+                //     fillOpacity: 0.2,
+                //     path: bounds[i]
+                // });
+                var polygon = new AMap.Polygon({
+                    map: this.map,
+                    strokeWeight: 2,
+                    strokeColor: 'red',
+                    fillColor: 'red',
+                    fillOpacity: 0.2,
+                    path: bounds[i]
+                });
+                this.polygons.push(polygon);
+            }
+            this.map.setFitView();//地图自适应
+        }
+        var subList = data.districtList;
+        //清空下一级别的下拉列表
+        if (level === 'country') {
+            console.log('country');
+            
+            this.provinceList = subList;
+            this.cityList = []
+            this.districtList = [];
+            this.form.province=''
+            this.form.city=''
+            this.form.district=''
+        } else if (level === 'province') {
+            console.log('province');
+            this.cityList = subList;
+            this.districtList = [];
+            this.form.city=''
+            this.form.district=''
+        } else if (level === 'city') {
+            console.log('city');
+            this.districtList = subList;
+            this.form.district=''
+        }
 
-  },
-  //生命周期 - 创建完成(可以访问当前this实例)
-  created() {},
-  //生命周期 - 挂载完成(可以访问DOM元素)
-  mounted() {
-    this.infoMap()
-  },
-  beforeCreate() {}, //生命周期 - 创建之前
-  beforeMount() {}, //生命周期 - 挂载之前
-  beforeUpdate() {}, //生命周期 - 更新之前
-  updated() {
-    
-  }, //生命周期 - 更新之后
-  beforeDestroy() {}, //生命周期 - 销毁之前
-  destroyed() {}, //生命周期 - 销毁完成
-  activated() {} //如果页面有keep-alive缓存功能,这个函数会触发
-};
+        console.log(subList);
+        // if (subList) {
+        //     var contentSub = new Option('--请选择--');
+        //     var curlevel = subList[0].level;
+        //     var curList =  document.querySelector('#' + curlevel);
+        //     curList.add(contentSub);
+        //     for (var i = 0, l = subList.length; i < l; i++) {
+        //         var name = subList[i].name;
+        //         var levelSub = subList[i].level;
+        //         var cityCode = subList[i].citycode;
+        //         contentSub = new Option(name);
+        //         contentSub.setAttribute("value", levelSub);
+        //         contentSub.center = subList[i].center;
+        //         contentSub.adcode = subList[i].adcode;
+        //         curList.add(contentSub);
+        //     }
+        // }
+        
+    },
+    search(levelSub) {
+        //清除地图上所有覆盖物
+        for (var i = 0, l = this.polygons.length; i < l; i++) {
+            this.polygons[i].setMap(null);
+        }
+
+        if(levelSub == 'province'){
+            var keyword = this.form.province; //关键字 
+            if(!keyword){
+                this.cityList = []
+                this.districtList = [];
+                this.form.city=''
+                this.form.district=''
+                return
+            }
+        }else if(levelSub == 'city'){
+            var keyword = this.form.city; //关键字 
+            if(!keyword){
+                this.districtList = [];
+                this.form.district=''
+                return
+            }
+        }else if(levelSub == 'district'){
+            var keyword = this.form.district; //关键字 
+            if(!keyword){
+                return
+            }
+        }
+
+        this.district.setLevel(levelSub); //行政区级别
+        this.district.setExtensions('all');
+        //行政区查询
+        //按照adcode进行查询可以保证数据返回的唯一性
+        this.district.search(keyword,(status, result)=>{
+            if(status === 'complete'){
+                this.getData(result.districtList[0],levelSub);
+            }
+        });
+    },
+},
+//生命周期 - 创建完成(可以访问当前this实例)
+created() {
+
+},
+//生命周期 - 挂载完成(可以访问DOM元素)
+mounted() {
+    this.getEquipList()
+    // setTimeout(()=>{
+        this.districtFun()
+    // },3000)
+},
+beforeCreate() {}, //生命周期 - 创建之前
+beforeMount() {}, //生命周期 - 挂载之前
+beforeUpdate() {}, //生命周期 - 更新之前
+updated() {}, //生命周期 - 更新之后
+beforeDestroy() {}, //生命周期 - 销毁之前
+destroyed() {}, //生命周期 - 销毁完成
+activated() {}, //如果页面有keep-alive缓存功能,这个函数会触发
+}
 </script>
-<style scoped lang="less">
-.inner{
+<style scoped lang='less'>
+.map,#container{
+    width: 100%;
     height: 100%;
-    position: relative;
-    .mapCover{
-        height: 100%;
-        #map{
-            width: 100%;
-            height: 100%;
-        }
+}
+.leftNavBox{
+    position: absolute;
+    left: 100px;
+    top: 160px;
+    bottom:0;
+    /deep/.el-select{
+        width: 1.4rem;
     }
-    .mapTypebox{
-        position: absolute;
-        right: 20px;
-        top:30px;
-        background: #fff;
-        padding: 5px;
-        border-radius: 5px;
+    .listBox{
+        width: 4.25rem;
+        height: 90%;
+        margin-top: 16px;
+        border-radius: 6px;
+        background: rgba(255,255,255,.58);
+        box-shadow: 0px 3px 9px 0px #a7a7a7;
+        .projectSearch{
+            display: flex;
+            justify-content: space-between;
+            align-items: center;
+            padding: .15rem;
+            background: #182037;
+            color: #fff;
+            font-size: .175rem;
+            border-radius: 6px 6px 0 0;
+            /deep/.el-input{
+                width: 2.5rem;
+            }
+        }
     }
 }
-// 标注点提示文本
-/deep/.amap-marker-label{
-      background: transparent;
-    border: none;
-    color: red;
-    font-size: 14px;
-    font-weight: 700;
-    text-shadow: #fff 1px 0 0, #fff 0 1px 0, #fff -1px 0 0, #fff 0 -1px 0;
-}
-/deep/.el-radio__input.is-checked .el-radio__inner{
-  border-color: #0195ff;
-  background: #0195ff;
-}
-/deep/.el-radio__input.is-checked + .el-radio__label {
-  color: #0195ff;
-}
 </style>

+ 314 - 0
src/pages/plantGuard/baseAll区域划分海量点展示.vue

@@ -0,0 +1,314 @@
+<!-- mapui-->
+<template>
+<div class='map'>
+  <button @click="aa">sdfsdf</button>
+    <div id="container">dsfgfsdghdf</div>
+</div>
+</template>
+
+<script>
+//这里可以导入其他文件(比如:组件,工具js,第三方插件js,json文件,图片文件等等)
+//例如:import 《组件名称》 from '《组件路径》';
+
+export default {
+//import引入的组件需要注入到对象中才能使用
+components: {},
+data() {
+//这里存放数据
+return {
+    map:null,
+    data:null,
+    topAdcodes:[100000],//全国区划编码
+    center:[116.3683244,39.915085],
+    zoom:11
+};
+},
+//监听属性 类似于data概念
+computed: {},
+//监控data中的数据变化
+watch: {},
+//方法集合
+methods: {
+    initMap(){
+         //创建地图
+            var that = this
+            this.map = new AMap.Map('container', {
+                center:that.center,
+                zoom: that.zoom
+            });
+            AMapUI.loadUI(['control/BasicControl'], function(BasicControl) {
+                //缩放控件,显示Zoom值
+                that.map.addControl(new BasicControl.Zoom({
+                    position: 'lb',
+                    showZoomNum: true
+                }));
+            });
+                //加载相关组件
+            AMapUI.load(['ui/geo/DistrictCluster', 'ui/misc/PointSimplifier', 'lib/$'], function(DistrictCluster,PointSimplifier, $) {
+
+                //启动页面
+                that.initPage(DistrictCluster,PointSimplifier, $);
+            });
+    },
+    initPage(DistrictCluster,PointSimplifier, $) {
+        var that = this;
+        var pointSimplifierIns = new PointSimplifier({
+            map: that.map, //所属的地图实例
+            // autoSetFitView: false, //禁止自动更新地图视野
+            zIndex: 110,
+            getPosition: function(item) {
+                if (!item) {
+                    return null;
+                }
+                var parts = item.split(',');
+                //返回经纬度
+                return [parseFloat(parts[0]), parseFloat(parts[1])];
+            },
+            getHoverTitle: function(dataItem, idx) {
+                console.log(dataItem);
+                console.log(that.data[idx]);
+                
+                return "<div>"+idx + ': ' + dataItem+"</div>";
+            },
+            renderOptions: {
+                 //点的样式
+                pointStyle: {
+                    //绘制点占据的矩形区域
+                    content: function(ctx, x, y, width, height) {
+
+                        //注意,这里的width和height可能不同于pointStyle里面的width/height, 高清屏幕下会存在比例缩放
+
+                        //这里绘制一个圆顶锥形
+
+                        var yPos = 1 / 3;
+
+                        var top = [x + width / 2, y],
+                            right = [x + width, y + height * yPos],
+                            bottom = [x + width / 2, y + height],
+                            left = [x, y + height * yPos];
+
+                        ctx.moveTo(left[0], left[1]);
+                        ctx.arcTo(top[0], top[1], right[0], right[1], width / 3);
+                        ctx.lineTo(right[0], right[1]);
+                        ctx.lineTo(bottom[0], bottom[1]);
+                        ctx.lineTo(left[0], left[1]);
+
+                    },
+                    //宽度
+                    width: 15,
+                    //高度
+                    height: 30,
+                    offset: ['-50%', '-100%'],
+                    fillStyle: 'red',
+                    lineWidth: 1,
+                    strokeStyle: 'red'
+                },
+                //鼠标hover时的title信息
+                hoverTitleStyle: {
+                    position: 'top'
+                }
+            }
+        });
+        var distCluster = new DistrictCluster({
+            map: that.map, //所属的地图实例
+            zIndex:11,
+            // autoSetFitView: false,
+            topAdcodes: that.topAdcodes,
+            getPosition: function(item) {
+                if (!item) {
+                    return null;
+                }
+                var parts = item.split(',');
+                //返回经纬度
+                return [parseFloat(parts[0]), parseFloat(parts[1])];
+            },
+            renderOptions: {
+                // clusterMarkerKeepConsistent: false, //marker的位置随交互变化
+                 //基础样式
+                featureStyle: {
+                    fillStyle: 'rgba(102,170,0,0.5)', //填充色
+                    lineWidth: 2, //描边线宽
+                    strokeStyle: '#4e6ef2', //描边色
+                    //鼠标Hover后的样式
+                    hoverOptions: {
+                        fillStyle: 'rgba(255,255,255,0.2)'
+                    }
+                },
+                //特定区划级别的默认样式
+                featureStyleByLevel: {
+                    //全国
+                    country: {
+                        fillStyle: 'rgba(78,110,242,0.8)'
+                    },
+                    //省
+                    province: {
+                        fillStyle: 'rgba(78,110,242,0.7)'
+                    },
+                    //市
+                    city: {
+                        fillStyle: 'rgba(78,110,242,0.6)'
+                    },
+                    //区县
+                    district: {
+                        fillStyle:'rgba(78,110,242,0.5)'
+                    }
+                },
+                getClusterMarker: function(feature, dataItems, recycledMarker) {
+
+                    //不是当前feature,直接返回null
+                    if(dataItems.length){
+                        var container, title, body, nodeClassNames = {
+                            title: 'amap-ui-district-cluster-marker-title',
+                            body: 'amap-ui-district-cluster-marker-body',
+                            container: 'amap-ui-district-cluster-marker'
+                        };
+                        
+                        console.log(recycledMarker);
+                        if (recycledMarker) {
+                        console.log(recycledMarker.getContent());
+
+                            container = recycledMarker.getContent();
+
+                            title = $(container).find('.' + nodeClassNames.title)[0];
+
+                            body = $(container).find('.' + nodeClassNames.body)[0];
+
+                        } else {
+
+                            container = document.createElement('div');
+
+                            title = document.createElement('span');
+
+                            title.className = nodeClassNames.title;
+
+                            body = document.createElement('span');
+
+                            body.className = nodeClassNames.body;
+
+                            container.appendChild(title);
+
+                            container.appendChild(body);
+                        }
+                        console.log(feature.properties);
+                        
+                        var props = feature.properties,
+                            routeNames = [];
+
+                        var classNameList = [nodeClassNames.container, 'level_' + props.level, 'adcode_' + props.adcode];
+
+                        container.className = classNameList.join(' ');
+
+                        if (routeNames.length > 0) {
+
+                            routeNames.push(props.name);
+
+                            container.setAttribute('title', routeNames.join('>'));
+
+                        } else {
+                            container.removeAttribute('title');
+                        }
+
+                        $(title).html(props.name);
+                        $(body).html(dataItems.length);
+
+                        var resultMarker = recycledMarker || new AMap.Marker({
+                            topWhenClick: true,
+                            offset: new AMap.Pixel(-20, -30),
+                            content: container
+                        });
+                        console.log(container);
+                        console.log(resultMarker);
+                        
+                        return resultMarker;
+                    }
+                }
+            },
+        });
+            //监听区划面的点击
+        distCluster.on('clusterMarkerClick', function(e, feature) {
+
+           console.log(e)
+           console.log(feature)
+           console.log(that);
+        //    that.$router.push('/plantGuard/page8')
+            //重绘
+            //distCluster.renderLater();
+        });
+        window.distCluster = distCluster;
+
+        function refresh() {
+
+            var zoom = that.map.getZoom();
+            
+            //获取 pointStyle
+            var pointStyle = pointSimplifierIns.getRenderOptions().pointStyle;
+
+            //根据当前zoom调整点的尺寸
+            pointStyle.width = pointStyle.height = 2 * Math.pow(1.2, that.map.getZoom() - 3);
+
+            // var zoom = map.getZoom();
+
+            // if (zoom < 10) {
+
+            //     pointSimplifierIns.hide();
+
+            // } else {
+
+            //     pointSimplifierIns.show();
+            // }
+        }
+
+        that.map.on('zoomend', function() {
+            refresh();
+        });
+
+        refresh();
+
+        $('<div id="loadingTip">加载数据,请稍候...</div>').appendTo(document.body);
+        $.get('https://a.amap.com/amap-ui/static/data/10w.txt', function(csv) {
+
+            $('#loadingTip').remove();
+
+        // var data = [
+        //     "113.665412,34.757975",
+        //     "113.671767,34.815528",
+        //     "113.671867,34.825528",
+        //     "113.735978,34.728131",
+        //     "120.412618,36.382612",
+        //     "112.985037,23.15046",
+        //     "126.687123,45.787618"
+        //     ]
+ var data = csv.split('\n').slice(0,100);
+            that.data = data
+            distCluster.setData(data);
+            pointSimplifierIns.setData(data);
+        });
+    },
+    aa(){
+      this.map.setZoom(11)
+      this.map.setCenter([113.671767,34.815528])
+    }
+},
+//生命周期 - 创建完成(可以访问当前this实例)
+created() {
+
+},
+//生命周期 - 挂载完成(可以访问DOM元素)
+mounted() {
+    this.initMap()
+},
+beforeCreate() {}, //生命周期 - 创建之前
+beforeMount() {}, //生命周期 - 挂载之前
+beforeUpdate() {}, //生命周期 - 更新之前
+updated() {}, //生命周期 - 更新之后
+beforeDestroy() {}, //生命周期 - 销毁之前
+destroyed() {}, //生命周期 - 销毁完成
+activated() {}, //如果页面有keep-alive缓存功能,这个函数会触发
+}
+</script>
+<style scoped>
+.map,#container{
+    width: 100%;
+    height: 100%;
+}
+</style>

+ 335 - 0
src/pages/plantGuard/baseAll海量点.vue

@@ -0,0 +1,335 @@
+<!--  -->
+<template>
+  <div class="inner">
+    <div class="mapCover">
+      <div id="map">地图</div>
+    </div>
+    <div class="mapTypebox">
+      <el-radio-group v-model="mapType" @change="changeMapType">
+        <el-radio :label="0">标准图</el-radio>
+        <el-radio :label="1">卫星图</el-radio>
+      </el-radio-group>
+    </div>
+  </div>
+</template>
+
+<script>
+//这里可以导入其他文件(比如:组件,工具js,第三方插件js,json文件,图片文件等等)
+//例如:import 《组件名称》 from '《组件路径》';
+import { bd09togcj02,gcj02tobd09,wgs84togcj02,gcj02towgs84 } from "../../components/home/coordtransform_utils";  //纠偏方法
+export default {
+  //import引入的组件需要注入到对象中才能使用
+  components: {
+  },
+  data() {
+    //这里存放数据
+    return {
+      // center: [65.212881,31.279042],
+      // zoom: 8,
+      mapType: 1,
+      tileLayer1: null,
+      tileLayer2: null,
+      equipListCurr:[],
+      equipStyleObject:[
+        {
+          url: require("../../../static/images/projectIcon.png"), // 设别类型0
+          size: new AMap.Size(70, 70), // 图标大小
+          anchor: new AMap.Pixel(0,0) // 图标显示位置偏移量,基准点为图标左上角
+        },
+        {
+          url: require("@/assets/images/home/mapView/scd.png"), // 设别类型1
+          size: new AMap.Size(25, 15), // 图标大小
+          anchor: new AMap.Pixel(5, 5) // 图标显示位置偏移量,基准点为图标左上角
+        },
+        {
+          url: require("@/assets/images/home/mapView/scd.png"), // 设别类型2
+          size: new AMap.Size(25, 15), // 图标大小
+          anchor: new AMap.Pixel(5, 5) // 图标显示位置偏移量,基准点为图标左上角
+        },
+        {
+          url: require("@/assets/images/home/mapView/cbd.png"), // 设别类型3
+          size: new AMap.Size(25, 15), // 图标大小
+          anchor: new AMap.Pixel(5, 5) // 图标显示位置偏移量,基准点为图标左上角
+        },
+        {
+          url: require("@/assets/images/home/mapView/xyq.png"), // 设别类型4
+          size: new AMap.Size(25, 15), // 图标大小
+          anchor: new AMap.Pixel(5, 5) // 图标显示位置偏移量,基准点为图标左上角
+        },
+        {
+          url: require("@/assets/images/home/mapView/qxz.png"), // 设别类型5
+          size: new AMap.Size(25, 15), // 图标大小
+          anchor: new AMap.Pixel(5, 5) // 图标显示位置偏移量,基准点为图标左上角
+        },
+        {
+          url: require("@/assets/images/home/mapView/jk.png"), // 设别类型6
+          size: new AMap.Size(25, 15), // 图标大小
+          anchor: new AMap.Pixel(5, 5) // 图标显示位置偏移量,基准点为图标左上角
+        },
+        {
+          url: require("@/assets/images/home/mapView/bzy.png"), // 设别类型7
+          size: new AMap.Size(25, 15), // 图标大小
+          anchor: new AMap.Pixel(5, 5) // 图标显示位置偏移量,基准点为图标左上角
+        },
+        {
+          url: require("@/assets/images/home/mapView/bzy.png"), // 设别类型8
+          size: new AMap.Size(25, 15), // 图标大小
+          anchor: new AMap.Pixel(5, 5) // 图标显示位置偏移量,基准点为图标左上角
+        },
+        {
+          url: require("@/assets/images/home/mapView/tccb.png"), // 设别类型9
+          size: new AMap.Size(25, 15), // 图标大小
+          anchor: new AMap.Pixel(5, 5) // 图标显示位置偏移量,基准点为图标左上角
+        },
+      ],
+      icon:{
+        // 图标类型,现阶段只支持 image 类型
+        type: 'image',
+        // 图片 url
+        image: require("../../../static/images/icon5.svg"),
+        // 图片尺寸
+        size: [74, 66],
+        // 图片相对 position 的锚点,默认为 bottom-center
+        anchor: 'center',
+      },
+      // markers: [
+      //   {
+      //     addr: [121.5273285, 31.21515044],
+      //     projectname: '南阳农田项目南阳农田项目',
+      //     uid:1
+      //   },
+      // ],
+      markersStatus:{
+        iconOffset: [-70, -70],
+        textOffset: [-35, 0],
+        icon:require('../../../static/images/icon5.svg'),
+        events: {
+          click: (e) => {
+            console.log(e.target.Ce.vid)
+            console.log(this.markers[e.target.Ce.vid])
+            // this.$store.state.user_id = this.markers[e.target.Ce.vid].uid
+            this.$store.commit('setUserId',this.markers[e.target.Ce.vid].uid)
+            this.$router.push('page1')
+          },
+          dragend: (e) => {
+            console.log('---event---: dragend')
+            // this.markers[0].position = [e.lnglat.lng, e.lnglat.lat];
+          }
+        },
+        visible: true,
+        draggable: false,
+      },
+      txtLabels:[],
+      layer:null,
+      markers:[],
+    };
+  },
+  //监听属性 类似于data概念
+  computed: {},
+  //监控data中的数据变化
+  watch: {},
+  //方法集合
+  methods: {
+    // 初始化地图
+    infoMap(){
+        this.map = new AMap.Map("map", {
+            center: this.center,
+            resizeEnable: true,
+            zoom: 4,
+            lang: "en",
+        });
+        AMap.plugin(
+        [
+          "AMap.ToolBar",
+          "AMap.Scale",
+          "AMap.MouseTool",
+          "AMap.Geocoder",
+          "AMap.PolyEditor",
+        ],
+        () => {
+          this.map.addControl(new AMap.ToolBar());
+          this.map.addControl(new AMap.Scale());
+
+          this.geocoder = new AMap.Geocoder({
+            city: "全国",
+            radius: 1000,
+          });
+
+        }
+      );
+      this.tileLayer1 = new AMap.TileLayer({
+        tileUrl:
+          "http://t{0,1,2,3,4,5,6,7}.tianditu.gov.cn/DataServer?T=img_w&tk=888bc7de1a5f14aa1b335b02e558d9b3&x=[x]&y=[y]&l=[z]",
+        zIndex: 10,
+      }); //卫星图层
+      this.tileLayer2 = new AMap.TileLayer({
+        // 图块取图地址
+        tileUrl:
+          "http://t{0,1,2,3,4,5,6,7}.tianditu.gov.cn/DataServer?T=cta_w&tk=888bc7de1a5f14aa1b335b02e558d9b3&x=[x]&y=[y]&l=[z]",
+        zIndex: 101,
+      });
+      this.map.add(this.tileLayer1);
+      // this.map.add(this.tileLayer2);
+      this.getEquipList();
+    },
+    changeMapType(val){ 
+      if(val==0){
+        this.tileLayer1.hide()
+        this.tileLayer2.hide()
+      }else{
+        this.tileLayer1.show()
+        this.tileLayer2.show()
+      }
+    },
+ 
+    iconFormat(equip_ip, item) {
+      switch (equip_ip + "") {
+        case "2":
+          item.icon = require("@/assets/images/home/mapView/scd.png");
+          break;
+        case "3":
+          item.icon = require("@/assets/images/home/mapView/cbd.png");
+          break;
+        case "4":
+          item.icon = require("@/assets/images/home/mapView/xyq.png");
+          break;
+        case "5":
+          item.icon = require("@/assets/images/home/mapView/qxz.png");
+          break;
+        case "6":
+          item.icon = require("@/assets/images/home/mapView/jk.png");
+          break;
+        case "7":
+          item.icon = require("@/assets/images/home/mapView/bzy.png");
+          break;
+        case "9":
+          item.icon = require("@/assets/images/home/mapView/tccb.png");
+          break;
+      }
+    },
+    getEquipList() {
+      this.layer = new AMap.LabelsLayer({
+          zooms: [3, 20],
+          zIndex: 1000,
+          collision: false,
+          allowCollision: false,
+      });
+      let uid = sessionStorage.getItem("myuid");
+      this.$axios({
+        method: "POST",
+        url: "/api/api_gateway?method=user.login.user_project_addr",
+        data: this.qs.stringify({
+          // uid:uid
+        })
+      }).then(res => {
+        if (res.data.message == ""){
+          var data = res.data.data.user_project;
+          this.equipListCurr = data.map((item) => {
+            if (item.gps == 1) {
+              //GPS
+              item.lnglat = wgs84togcj02(item.lng, item.lat);
+            }
+            item.position=[item.lnglat[0],item.lnglat[1]]
+            item.text={
+                content: item.projectname,
+                direction: 'bottom',
+                offset: [-20, -5],
+                style: {
+                  // 字体大小
+                  fontSize: 16,
+                  // 字体颜色
+                  fillColor: '#ff0000',
+                  // 描边颜色
+                  strokeColor: '#ff0000',
+                  // 描边宽度
+                  strokeWidth: 1,
+                }
+            }
+            item.extData={
+              uid:item.uid
+            }
+            item.icon=this.icon
+            return item;
+              
+          });
+
+          this.equipListCurr.forEach((item)=>{
+            var labelMarker = new AMap.LabelMarker(item);
+            labelMarker.on("click", (e) => {
+              this.equipMarkerClick(e.target.getExtData().uid);
+            });
+            this.markers.push(labelMarker);
+          })
+
+          // 将 marker 添加到图层
+          this.layer.add(this.markers);
+          this.map.add(this.layer);
+          // this.massMarks.setMap(this.map);
+          // this.massMarks.on("click", (e) => {
+          //   this.equipMarkerClick(e.data);
+          // });
+        } else {
+          this.$message.error(res.data.message);
+        }
+      });
+    },
+    equipMarkerClick(uid) {
+      this.$store.commit('setUserId',uid)
+      this.$router.push('page1')
+    },
+
+  },
+  //生命周期 - 创建完成(可以访问当前this实例)
+  created() {},
+  //生命周期 - 挂载完成(可以访问DOM元素)
+  mounted() {
+    this.infoMap()
+  },
+  beforeCreate() {}, //生命周期 - 创建之前
+  beforeMount() {}, //生命周期 - 挂载之前
+  beforeUpdate() {}, //生命周期 - 更新之前
+  updated() {
+    
+  }, //生命周期 - 更新之后
+  beforeDestroy() {}, //生命周期 - 销毁之前
+  destroyed() {}, //生命周期 - 销毁完成
+  activated() {} //如果页面有keep-alive缓存功能,这个函数会触发
+};
+</script>
+<style scoped lang="less">
+.inner{
+    height: 100%;
+    position: relative;
+    .mapCover{
+        height: 100%;
+        #map{
+            width: 100%;
+            height: 100%;
+        }
+    }
+    .mapTypebox{
+        position: absolute;
+        right: 20px;
+        top:30px;
+        background: #fff;
+        padding: 5px;
+        border-radius: 5px;
+    }
+}
+// 标注点提示文本
+/deep/.amap-marker-label{
+      background: transparent;
+    border: none;
+    color: red;
+    font-size: 14px;
+    font-weight: 700;
+    text-shadow: #fff 1px 0 0, #fff 0 1px 0, #fff -1px 0 0, #fff 0 -1px 0;
+}
+/deep/.el-radio__input.is-checked .el-radio__inner{
+  border-color: #0195ff;
+  background: #0195ff;
+}
+/deep/.el-radio__input.is-checked + .el-radio__label {
+  color: #0195ff;
+}
+</style>

+ 7 - 3
src/pages/plantGuard/cbdPhoto/cbdPhoto.vue

@@ -106,8 +106,6 @@
                           v-lazy="item.addr"
                           @error="errImg"
                           alt
-                          width="100%"
-                          height="250px"
                         />
                       </div>
                       <div class="photoTime" v-if="radio1==''">
@@ -735,7 +733,7 @@ export default {
       let that = this;
       let postData = that.qs.stringify({
         device_id: that.id,
-        page_number: 8,
+        page_number: 6,
         page: that.page,
         ret: 'list',
         rets: that.radio1,
@@ -1125,8 +1123,14 @@ export default {
     border-radius: 5px;
     margin-bottom: 11px;
     .imgBox{
+      height: 315px;
+      background: #000;
+      text-align: center;
       cursor: pointer;
       position: relative;
+      img{
+        height: 100%;
+      }
       .uptime{
         position: absolute;
         left: 0;

+ 5 - 5
src/pages/plantGuard/equipState.vue

@@ -63,10 +63,10 @@ export default {
     return {
         equipState_dict,
         showState: {
-            "2": ["ds","ws","rps","tps","dps","tt","ct","at","ah","cv","bv","csq","dver","addtime"],
-            "3": ["ds","ws","tt","hs","at","ah","upds","dnds","vbat","rps","tps","lps","csq","dver","addtime"],
-            "4": ["proj","ds","ws","at","ah","cv","bv","cs","bs","infr_ct","csq","dver","addtime"],
-            "7": ["at","ah","set_temp","pre_temp","bs","usb_sta","vbat","csq","dver","addtime"],
+            "2": ["ds","ws","rps","tps","dps","tt","ct","at","ah","cv","bv","csq","dver"],
+            "3": ["ds","ws","tt","hs","at","ah","upds","dnds","vbat","rps","tps","lps","csq","dver"],
+            "4": ["proj","ds","ws","at","ah","cv","bv","cs","bs","infr_ct","csq","dver"],
+            "7": ["at","ah","set_temp","pre_temp","bs","usb_sta","vbat","csq","dver"],
         },
         equipData:{},
         equipDataState:false,
@@ -142,7 +142,7 @@ export default {
         border-right: 5px solid #f1faff;
         margin-bottom: 10px;
         padding: 0 9px;
-        font-size: 13px;
+        font-size: .1625rem;
         .elementValue{
             color: #0195ff;
         }

+ 105 - 21
src/pages/plantGuard/page1.vue

@@ -60,13 +60,13 @@
             <div>
               <div class="equipId">
                 <span :class="item.device_status?'online':'offline'"></span>
-                {{item.device_id}}
+                {{item.device_name || item.device_id}}
               </div>
               <div class="equipCity">{{item.city}}</div>
             </div>
             <div>
               <div class="equipType">{{item.device_type_id | equipType}}</div>
-              <div>{{item.addtime*1000 | formatTime}}</div>
+              <div class="equipTime">{{item.addtime*1000 | formatTime}}</div>
 
             </div>
           </div>
@@ -262,6 +262,45 @@
       </div>
     </transition>
     <!-- 孢子仪数据框 -->
+     <el-dialog
+      class="figEldialog"
+      :visible.sync="setTimeDialogVisible"
+      width="50%"
+      :fullscreen="dialogFull"
+      v-dialogDrag
+    >
+      <template slot="title">
+          <div class="avue-crud__dialog__header">
+              <span class="el-dialog__title">
+              <span style="display:inline-block;background-color: #3478f5;width:3px;height:20px;margin-right:5px; float: left;margin-top:2px"></span>
+                孢子仪数据框
+              </span>
+            <div class="avue-crud__dialog__menu" @click="dialogFullFun()">
+              <i class="el-icon-full-screen"></i>
+            </div>
+          </div>
+        </template>
+        <equip-info v-if="hackReset" @child-event="setTimeDialogShow" @getNowState='getNowState' :d_id="queryInfo.d_id" :equipId='queryInfo.equip_id' :equipType='detailsShow'>
+          <template v-solt:equipStateInner></template>
+        </equip-info>
+        <div class="equipData">
+          <div class="more" @click="lookmore()">设备控制</div>
+          <template>
+            <el-tabs v-model="activeName" @tab-click="tabshandleClick">
+              <el-tab-pane
+                v-for="(pages, index) in pages['7']"
+                v-bind:key="index"
+                :label="pages.label"
+                :name="pages.name"
+              > 
+                <!-- <keep-alive> -->
+                  <components :is="pages.name" :equipId="queryInfo.equip_id" :d_id="queryInfo.d_id" :equipType='detailsShow' ref="child7" v-if="pages.name == nowPage && hackReset"></components>
+                <!-- </keep-alive> -->
+              </el-tab-pane>
+            </el-tabs>
+          </template>
+        </div>
+    </el-dialog>
     <transition
         enter-active-class="animate__animated animate__zoomIn" 
         leave-active-class="animate__animated animate__zoomOut"
@@ -298,11 +337,24 @@
       </dialog-box>
     </transition>
     <!-- 设置孢子仪载玻片、培养液更换时间配置弹框 -->
-    <el-dialog
-      title="配置(请及时填写)"
+    <!-- <el-dialog
+      class="figEldialog"
       :visible.sync="setTimeDialogVisible"
       width="420px"
+      :fullscreen="dialogFull"
+      v-dialogDrag
     >
+      <template slot="title">
+          <div class="avue-crud__dialog__header">
+              <span class="el-dialog__title">
+              <span style="display:inline-block;background-color: #3478f5;width:3px;height:20px;margin-right:5px; float: left;margin-top:2px"></span>
+                配置(请及时填写)
+              </span>
+            <div class="avue-crud__dialog__menu" @click="dialogFullFun()">
+              <i class="el-icon-full-screen"></i>
+            </div>
+          </div>
+        </template>
       <el-form ref="form" :model="time" label-width="130px">
         <el-form-item label="载玻片更换时间: ">
           <el-date-picker
@@ -323,7 +375,7 @@
         <el-button type="grayInfo" @click="setTimeDialogVisible = false">取 消</el-button>
         <el-button type="blueInfo" @click="setTimeSubm()">确 定</el-button>
       </span>
-    </el-dialog>
+    </el-dialog> -->
   </div>
 </template>
 
@@ -604,6 +656,7 @@ export default {
       equipListActive:'',
       hackReset:false,
       equipListloading: false,
+      dialogFull:false,
     };
   },
   //监听属性 类似于data概念
@@ -994,6 +1047,13 @@ export default {
       
       this.player.stop()
     },
+    // 弹框放大
+    dialogFullFun(){
+      this.dialogFull = !this.dialogFull
+      
+      document.querySelector(".figEldialog").children[0].style.top = 0;
+      document.querySelector(".figEldialog").children[0].style.left = 0;
+    },
      //载玻片、培养液更换时间展示
     setTimeDialogShow(data){
       this.setTimeDialogVisible = true;
@@ -1085,11 +1145,11 @@ export default {
     }
     .mapTypebox{
         position: absolute;
-        right: 20px;
-        top:30px;
+        right: .25rem;
+        top:.375rem;
         background: #fff;
-        padding: 5px;
-        border-radius: 5px;
+        padding: .0625rem;
+        border-radius: .0625rem;
     }
 }
 // tabs设备类型
@@ -1194,33 +1254,40 @@ export default {
 .equipListBox{
     position: absolute;
     left: 0;
-    right: 35px;
-    top: 69px;
+    right: .4375rem;
+    top: 70px;
     bottom: 0;
     overflow: auto;
   .equipList{
     // padding: 20px;
     .equipItem{
-      padding: 10px 7px;
+      padding: .125rem .0875rem;
       cursor: pointer;
       display: flex;
       justify-content: space-between;
-      margin: 15px;
+      margin: .1875rem;
       border: 1px dashed transparent;
       border-bottom: 1px dashed #ddd;
-      padding-bottom: 10px;
+      padding-bottom: .125rem;
       color: #8b8b8b;
+      >div{
+        flex: 1;
+        overflow: hidden;
+      }
       .equipId{
-        line-height: 34px;
-        font-size: 14px;
+        line-height: .425rem;
+        font-size: .175rem;
         color: #000;
         font-weight: 700;
+        text-overflow: ellipsis;
+        white-space: nowrap;
+        overflow: hidden;
         span{
           display: inline-block;
-          width: 9px;
-          height: 9px;
+          width: .1125rem;
+          height: .1125rem;
           border-radius: 50%;
-          margin-right: 3px;
+          margin-right: .0375rem;
         }
         span.online{
           background: #0195ff;
@@ -1231,13 +1298,25 @@ export default {
       }
       .equipCity{
         text-indent: .2rem;
+        text-overflow: ellipsis;
+        white-space: nowrap;
+        overflow: hidden;
       }
       .equipType{
-        line-height: 34px;
-        font-size: 14px;
+        line-height: .425rem;
+        font-size: .175rem;
         color: #0195ff;
         font-weight: 700;
         text-align: right;
+        text-overflow: ellipsis;
+        white-space: nowrap;
+        overflow: hidden;
+      }
+      .equipTime{
+        text-align: right;
+        text-overflow: ellipsis;
+        white-space: nowrap;
+        overflow: hidden;
       }
     }
     .equipItem.active{
@@ -1264,4 +1343,9 @@ export default {
     cursor: pointer;
   }
 }
+// 弹框样式覆盖
+/deep/.el-dialog__wrapper{
+  // top: 135px;
+  // left: 85px;
+}
 </style>

+ 402 - 0
src/util/directives.js

@@ -0,0 +1,402 @@
+import Vue from 'vue'
+
+// 自定义元素实现弹框拖拽[重点]
+Vue.directive('draw', {
+  inserted: function (el, binding, vNode) {
+    el.setAttribute('style', 'position: fixed; z-index: 9999')
+  },
+  bind: function (el, bindding, vNode) {
+    el.setAttribute('draggable', true)
+    let left, top, width, height
+    el._dragstart = function (event) {
+      event.stopPropagation()
+      left = event.clientX - el.offsetLeft
+      top = event.clientY - el.offsetTop
+      width = el.offsetWidth
+      height = el.offsetHeight
+    }
+    el._checkPosition = function () { // 防止被拖出边界
+      let width = el.offsetWidth
+      let height = el.offsetHeight
+      let left = Math.min(el.offsetLeft, document.body.clientWidth - width)
+      left = Math.max(0, left)
+      let top = Math.min(el.offsetTop, document.body.clientHeight - height)
+      top = Math.max(0, top)
+      el.style.left = left + 'px'
+      el.style.top = top + 'px'
+      el.style.width = width + 'px'
+      el.style.height = height + 'px'
+    }
+    el._dragEnd = function (event) {
+      event.stopPropagation()
+      left = event.clientX - left
+      top = event.clientY - top
+      el.style.left = left + 'px'
+      el.style.top = top + 'px'
+      el.style.width = width + 'px'
+      el.style.height = height + 'px'
+      el._checkPosition()
+    }
+    el._documentAllowDraop = function (event) {
+      event.preventDefault()
+    }
+    document.body.addEventListener('dragover', el._documentAllowDraop)
+    el.addEventListener('dragstart', el._dragstart)
+    el.addEventListener('dragend', el._dragEnd)
+    window.addEventListener('resize', el._checkPosition)
+  },
+
+  unbind: function (el, bindding, vNode) {
+    document.body.removeEventListener('dragover', el._documentAllowDraop)
+    el.removeEventListener('dragstart', el._dragstart)
+    el.removeEventListener('dragend', el._dragEnd)
+    window.removeEventListener('resize', el._checkPosition)
+    delete el._documentAllowDraop
+    delete el._dragstart
+    delete el._dragEnd
+    delete el._checkPosition
+  }
+})
+
+// v-dialogDrag: 弹窗拖拽
+Vue.directive('dialogDrag',{
+  bind(el, binding, vnode, oldVnode) {
+      let _this = this;
+      //弹框可拉伸最小宽高
+      let minWidth = 820;
+
+      let minHeight = 420;
+
+      //初始非全屏
+
+      let isFullScreen = false;
+
+      //当前宽高
+
+      let nowWidth = 0;
+
+      let nowHight = 0;
+
+      //当前顶部高度
+
+      let nowMarginTop = 0;
+
+      //获取弹框头部(这部分可双击全屏)
+
+      const dialogHeaderEl = el.querySelector('.el-dialog__header');
+
+
+      //弹窗
+
+      const dragDom = el.querySelector('.el-dialog');
+
+      //获取当前dialog id
+      const dialogID = el.id;
+
+      //给弹窗加上overflow auto;不然缩小时框内的标签可能超出dialog;
+
+      dragDom.style.overflow = "hidden";
+
+      //清除选择头部文字效果
+
+      //dialogHeaderEl.onselectstart = new Function("return false");
+      //头部加上可拖动cursor
+
+      dialogHeaderEl.style.cursor = 'move';
+
+      dialogHeaderEl.style.cssText += ';cursor:move;';
+      dragDom.style.cssText += ';top:0px;';
+
+      // 获取原有属性 ie dom元素.currentStyle 火狐谷歌 window.getComputedStyle(dom元素, null);
+      const sty = (function() {
+          if (window.document.currentStyle) {
+              return (dom, attr) => dom.currentStyle[attr];
+          } else {
+              return (dom, attr) => getComputedStyle(dom, null)[attr];
+          }
+      })();
+      //拖拽边界优化
+      let moveDown = (e) => {
+          // 鼠标按下,计算当前元素距离可视区的距离
+          const disX = e.clientX - dialogHeaderEl.offsetLeft;
+          const disY = e.clientY - dialogHeaderEl.offsetTop;
+          const screenWidth = document.body.clientWidth; // body当前宽度
+          const screenHeight = document.documentElement.clientHeight; // 可见区域高度(应为body高度,可某些环境下无法获取)
+          const dragDomWidth = dragDom.offsetWidth; // 对话框宽度
+          const dragDomheight = dragDom.offsetHeight; // 对话框高度
+          const minDragDomLeft = dragDom.offsetLeft;
+          const maxDragDomLeft = screenWidth - dragDom.offsetLeft - dragDomWidth;
+          const minDragDomTop = dragDom.offsetTop;
+          const maxDragDomTop = screenHeight - dragDom.offsetTop - dragDomheight;
+          // 获取到的值带px 正则匹配替换
+          let styL = sty(dragDom, 'left');
+          let styT = sty(dragDom, 'top');
+          // 注意在ie中 第一次获取到的值为组件自带50% 移动之后赋值为px
+          if (styL.includes('%')) {
+              // eslint-disable-next-line no-useless-escape
+              styL = +document.body.clientWidth * (+styL.replace(/\%/g, '') / 100);
+              // eslint-disable-next-line no-useless-escape
+              styT = +document.body.clientHeight * (+styT.replace(/\%/g, '') / 100);
+          } else {
+              styL = +styL.replace(/\px/g, '');
+              styT = +styT.replace(/\px/g, '');
+          }
+
+          document.onmousemove = function (e) {
+              // 通过事件委托,计算移动的距离
+              let left = e.clientX - disX;
+              let top = e.clientY - disY;
+
+              // 边界处理
+              if (-left > minDragDomLeft) {
+                  left = -minDragDomLeft;
+              } else if (left > maxDragDomLeft) {
+                  left = maxDragDomLeft;
+              }
+              if (-top > minDragDomTop) {
+                  top = -minDragDomTop;
+              } else if (top > maxDragDomTop) {
+                  top = maxDragDomTop;
+              }
+
+              // 移动当前元素
+              dragDom.style.cssText += `;left:${left + styL}px;top:${top + styT}px;`;
+          };
+
+          document.onmouseup = function(e) {
+              document.onmousemove = null;
+              document.onmouseup = null;
+          };
+          return false;
+      };
+
+      dialogHeaderEl.onmousedown = moveDown;
+
+      //双击头部全屏效果
+
+      dialogHeaderEl.ondblclick = (e) => {
+
+        //   if (isFullScreen == false) {
+
+        //       nowHight = dragDom.clientHeight;
+
+        //       nowWidth = dragDom.clientWidth;
+
+        //       nowMarginTop = dragDom.style.marginTop;
+
+        //       dragDom.style.left = 0;
+
+        //       dragDom.style.top = 0;
+
+        //       dragDom.style.height = "100VH";
+
+        //       dragDom.style.width = "100VW";
+
+        //       dragDom.style.marginTop = 0;
+              
+        //       dragDom.style.marginBottom = 0;
+
+        //       isFullScreen = true;
+
+        //       dialogHeaderEl.style.cursor = 'initial';
+
+        //       dialogHeaderEl.onmousedown = null;
+
+        //   } else {
+
+        //       dragDom.style.height = "auto";
+
+        //       dragDom.style.width = nowWidth + 'px';
+
+        //       dragDom.style.marginTop = nowMarginTop;
+
+        //       dragDom.style.marginBottom = 0;
+
+        //       isFullScreen = false;
+
+        //       dialogHeaderEl.style.cursor = 'move';
+
+        //       dialogHeaderEl.onmousedown = moveDown;
+
+        //   }
+
+      }
+
+      dragDom.onmousemove = function (e) {
+
+        //   let moveE = e;
+
+        //   if (e.clientX > dragDom.offsetLeft + dragDom.clientWidth - 10 || dragDom.offsetLeft + 10 > e.clientX) {
+
+        //       dragDom.style.cursor = 'w-resize';
+
+        //   } else if (el.scrollTop + e.clientY > dragDom.offsetTop + dragDom.clientHeight - 10) {
+        //       dragDom.style.cursor = 's-resize';
+        //  } else {
+
+        //       dragDom.style.cursor = 'default';
+
+        //       dragDom.onmousedown = null;
+
+        //   }
+
+        //   dragDom.onmousedown = (e) => {
+
+        //       const clientX = e.clientX;
+
+        //       const clientY = e.clientY;
+
+        //       let elW = dragDom.clientWidth;
+
+        //       let elH = dragDom.clientHeight;
+
+        //       let EloffsetLeft = dragDom.offsetLeft;
+
+        //       let EloffsetTop = dragDom.offsetTop;
+
+        //       let EloffsetBottom = dragDom.offsetBottom;
+
+        //       // dragDom.style.userSelect = 'none';
+
+        //       let ELscrollTop = el.scrollTop;
+
+        //       //判断点击的位置是不是为头部
+
+        //       if (clientX > EloffsetLeft && clientX < EloffsetLeft + elW && clientY > EloffsetTop && clientY < EloffsetTop + 100) {
+
+        //           //如果是头部在此就不做任何动作,以上有绑定dialogHeaderEl.onmousedown = moveDown;
+
+        //       }else{
+
+        //           document.onmousemove = function (e) {
+
+        //               // e.preventDefault(); // 移动时禁用默认事件
+
+        //               //左侧鼠标拖拽位置
+
+        //               if (clientX > EloffsetLeft && clientX < EloffsetLeft + 10) {
+
+        //                   //往左拖拽
+
+        //                   if (clientX > e.clientX) {
+
+        //                       dragDom.style.width = elW + (clientX - e.clientX) * 2 + 'px';
+
+        //                   }
+
+        //                   //往右拖拽
+
+        //                   if (clientX < e.clientX) {
+
+        //                       if(dragDom.clientWidth < minWidth){
+
+        //                       }else{
+
+        //                           dragDom.style.width = elW - (e.clientX - clientX) * 2 + 'px';
+
+        //                       }
+
+        //                   }
+
+        //               }
+
+        //               //右侧鼠标拖拽位置
+
+        //               if (clientX > EloffsetLeft + elW - 10 && clientX < EloffsetLeft + elW) {
+
+
+        //                   //往左拖拽
+
+        //                   if (clientX > e.clientX) {
+
+        //                       if (dragDom.clientWidth < minWidth) {
+
+        //                       } else {
+
+        //                           dragDom.style.width = elW - (clientX - e.clientX) * 2 + 'px';
+
+        //                       }
+
+        //                   }
+
+        //                   //往右拖拽
+
+        //                   if (clientX < e.clientX) {
+
+        //                       dragDom.style.width = elW + (e.clientX - clientX) * 2 + 'px';
+
+        //                   }
+
+        //               }
+
+        //               //底部鼠标拖拽位置
+
+        //               if (ELscrollTop + clientY > EloffsetTop + elH - 20 && ELscrollTop + clientY < EloffsetTop + elH) {
+
+        //                   // 往上拖拽
+                          
+        //                   if (clientY > e.clientY) {
+
+        //                       if (dragDom.clientHeight < minHeight) {
+
+        //                       } else {
+
+        //                           dragDom.style.height = elH - (clientY - e.clientY) * 2 + 'px';
+        //                           let  changeHeightSize = elH - (clientY - e.clientY) * 2;
+        //                       }
+
+        //                   }
+
+        //                   //往下拖拽
+
+        //                   if (clientY < e.clientY) {
+        //                       dragDom.style.height = elH + (e.clientY - clientY) * 2 + 'px';
+        //                       let  changeHeightSize = elH - (clientY - e.clientY) * 2;
+        //                   }
+
+        //               }
+
+        //           };
+
+        //           //拉伸结束
+
+        //           document.onmouseup = function (e) {
+
+        //               document.onmousemove = null;
+
+        //               document.onmouseup = null;
+
+        //           };
+
+        //       }
+
+        //   }
+
+      }
+  }
+}),
+
+// v-dialogDragWidth: 弹窗宽度拖大 拖小
+Vue.directive('dialogDragWidth', {
+  bind (el, binding, vnode, oldVnode) {
+    const dragDom = binding.value.$el.querySelector('.el-dialog')
+
+    el.onmousedown = (e) => {
+      // 鼠标按下,计算当前元素距离可视区的距离
+      const disX = e.clientX - el.offsetLeft
+
+      document.onmousemove = function (e) {
+        e.preventDefault() // 移动时禁用默认事件
+
+        // 通过事件委托,计算移动的距离
+        const l = e.clientX - disX
+        dragDom.style.width = `${l}px`
+      }
+
+      document.onmouseup = function (e) {
+        document.onmousemove = null
+        document.onmouseup = null
+      }
+    }
+  }
+})