panhui пре 7 година
родитељ
комит
ac4e62c25c

+ 118 - 17
src/main/vue/src/components/DrugArea.vue

@@ -38,20 +38,20 @@
         </el-form>
       </el-row>
       <div class="dragContent" ref="dragContent" :style="{cursor:isDown&&bgMove?'move':(bgMove?'default':'crosshair'),top:bgPosition.top+'px',left:bgPosition.left+'px'}" @mousedown="isDown=true" @mousemove="bgMouseMove" @mouseup="isDown=false">
-        <img :src="mapImage+'?x-oss-process=image/resize,m_lfit,h_'+areaHeight+',w_'+areaWidth" ref="bgImg" class="bgImg" alt>
-        <div class="gridInfo" style="z-index:2">
+        <img draggable="false" :src="mapImage"  :style="{height:areaHeight+'px'}" ref="bgImg" class="bgImg" alt>
+        <!-- <div class="gridInfo" style="z-index:2">
           <div class="grid-item" v-for="(item,index) in oldMapInfo" :style="{width:100/width/rate+'%',height:100/height/rate+'%',backgroundColor:color[item]}"></div>
-        </div>
-        <div class="gridInfo">
+        </div>-->
+        <!-- <div class="gridInfo">
           <div class="grid-item" v-for="(item,index) in mapInfo" @click="choosePoint(index)" :style="{width:100/width/rate+'%',height:100/height/rate+'%',backgroundColor:colorArea[canAdd(item)?0:(parseInt(item)!=0?2:1)],color:canAdd(item)?'#fff':'#666'}">
             <template v-if="chooseIdex===index">
-              <!-- <span>{{index}}</span> -->
               <img src="../assets/location.png" v-if="!isAreaShowPoint" alt>
               <img src="../assets/door.png" v-else-if='doorFlag' alt="">
               <img src="../assets/location2.png" v-else alt="">
             </template>
           </div>
-        </div>
+        </div>-->
+        <canvas ref="canvas" class="gridCanvas" @mousedown="drawStart"></canvas>
       </div>
     </el-main>
   </el-container>
@@ -63,10 +63,6 @@ import zh from 'date-fns/locale/zh_cn'
 export default {
   name: 'drugArea',
   props: {
-    areaWidth: {
-      type: Number,
-      default: 100
-    },
     areaHeight: {
       type: Number,
       default: 100
@@ -89,22 +85,30 @@ export default {
         }
       }
     },
-    doorFlag:{
-      type:Boolean,
-      default:false
+    doorFlag: {
+      type: Boolean,
+      default: false
     },
-    isAreaShowPoint:{
-      type:Boolean,
-      default:false
+    isAreaShowPoint: {
+      type: Boolean,
+      default: false
     }
   },
   created() {
     if (this.landmarkId) {
       this.getInfo()
     }
+
+    setTimeout(() => {
+      this.areaWidth = this.$refs.bgImg.offsetWidth
+      this.$refs.canvas.width = this.areaWidth
+      this.$refs.canvas.height = this.areaHeight
+      this.drawContent()
+    }, 1000)
   },
   data() {
     return {
+      areaWidth: 0,
       isDown: false,
       bgMove: false,
       bgPosition: {
@@ -132,6 +136,17 @@ export default {
   watch: {
     landmarkId() {
       this.getInfo()
+    },
+    mapPointInfo() {
+      this.drawContent()
+    },
+    areaHeight(){
+       setTimeout(() => {
+      this.areaWidth = this.$refs.bgImg.offsetWidth
+      this.$refs.canvas.width = this.areaWidth
+      this.$refs.canvas.height = this.areaHeight
+      this.drawContent()
+    }, 500)
     }
   },
   computed: {
@@ -148,6 +163,85 @@ export default {
 
   },
   methods: {
+    drawContent() {
+      var width = this.areaWidth / this.width
+      var height = this.areaHeight / this.height
+      var list = [...this.oldMapInfo]
+      var ctx = this.$refs.canvas.getContext('2d')
+      ctx.clearRect(0, 0, this.areaWidth, this.areaHeight);
+      ctx.fillStyle = this.color[0];
+      ctx.fillRect(0, 0, this.areaWidth, this.areaHeight);
+      for (var i = 0; i < list.length; i++) {
+        if (list[i] > 0) {
+          ctx.clearRect(width * this.getX(i), height * this.getY(i), width, height);
+          ctx.fillStyle = this.color[list[i]];
+          ctx.fillRect(width * this.getX(i), height * this.getY(i), width, height);
+        }
+      }
+
+      ctx.fillStyle = 'rgba(0,0,0,0.2)';
+      ctx.fillRect(0, 0, this.areaWidth, this.areaHeight);
+
+      var lineWidth = 2
+      if (list.length > 1000) {
+        lineWidth = 1
+      }
+      else if (list.length > 10000) {
+        lineWidth = 0.5
+      }
+      var idList = [...this.mapInfo]
+
+      for (var i = 0; i < idList.length; i++) {
+
+        if (this.canAdd(idList[i])) {
+          ctx.clearRect(width * this.getX(i), height * this.getY(i), width, height);
+          ctx.fillStyle = this.colorArea[0];
+          ctx.fillRect(width * this.getX(i), height * this.getY(i), width, height);
+        }
+
+      }
+
+      for (var i = 0; i < this.width; i++) {
+        ctx.beginPath();
+        ctx.lineWidth = lineWidth;
+        ctx.moveTo(width * i, 0);
+        ctx.lineTo(width * i, this.areaHeight);
+        ctx.strokeStyle = 'rgb(255,255,255,255)';
+        ctx.stroke();
+      }
+
+      for (var i = 0; i < this.height; i++) {
+        ctx.beginPath();
+        ctx.lineWidth = lineWidth;
+        ctx.moveTo(0, height * i);
+        ctx.lineTo(this.areaWidth, height * i);
+        ctx.strokeStyle = 'rgb(255,255,255,255)';
+        ctx.stroke();
+      }
+
+      if (this.mapPointInfo.index) {
+        //  <img src="../assets/location.png" v-if="!isAreaShowPoint" alt>
+        //       <img src="../assets/door.png" v-else-if='doorFlag' alt="">
+        //       <img src="../assets/location2.png" v-else alt="">
+        var img = new Image();
+        if (!this.isAreaShowPoint) {
+          img.src = require('../assets/location.png');
+        }
+        else if (this.doorFlag) {
+          img.src = require('../assets/door.png');
+        }
+        else {
+          img.src = require('../assets/location2.png');
+        }
+        var x = this.mapPointInfo.x
+        var y = this.mapPointInfo.y
+        img.onload = function () {
+          ctx.drawImage(img, x * width + width / 4, y * height + height / 4, width / 2, height / 2);
+        };
+      }
+
+
+    },
     choosePoint(index) {
       if (this.bgMove) {
         return
@@ -343,7 +437,14 @@ export default {
 
         }
       })
-    }
+    },
+    drawStart(e) {
+      var width = this.areaWidth / this.width
+      var height = this.areaHeight / this.height
+      var x = parseInt(e.offsetX / width)
+      var y = parseInt(e.offsetY / height)
+      this.choosePoint(y * this.width + x)
+    },
   }
 }
 

+ 5 - 6
src/main/vue/src/pages/AimPlaceInfo.vue

@@ -372,16 +372,15 @@ export default {
         index: this.formData.mapIndex
       }
     },
-    landmarkId() {
-      return this.formData.ownedLandMarkId
+    landmarkId(){
+      return Number(this.formData.ownedLandMarkId)
     },
-    areaId() {
-      return this.formData.areaId
+    areaId(){
+      return Number(this.formData.areaId)
     }
   },
   methods: {
     choosePoint(jsonp) {
-      console.log(jsonp)
       this.formData.posX = jsonp.x;
       this.formData.posY = jsonp.y;
       this.formData.mapIndex = jsonp.index
@@ -414,7 +413,7 @@ export default {
       data.aloneFlag = this.formData.aloneFlag ? 'Y' : 'N';
       data.autoDisplay = this.formData.autoDisplay ? 'Y' : 'N';
       data.autoPlay = this.formData.autoPlay ? 'Y' : 'N';
-      
+
       this.$http.post({
         url: this.formData.id ? '/aimPlaceInfo/update' : '/aimPlaceInfo/save',
         data: data

+ 8 - 7
src/main/vue/src/pages/AreaShowPoint.vue

@@ -92,10 +92,6 @@ export default {
             res.data.mapIndex = ''
           }
           this.formData = res.data;
-
-
-
-
           if (this.$route.query.column) {
             var columnList = this.$route.query.column.split(';')
             columnList.forEach(item => {
@@ -171,7 +167,11 @@ export default {
   data() {
     return {
       saving: false,
-      formData: {},
+      formData: {
+        mapX:'',
+        mapY:'',
+        mapIndex:''
+      },
       rules: {
         pointName:
           [
@@ -197,10 +197,10 @@ export default {
       }
     },
     landmarkId() {
-      return parseInt(this.formData.landmarkId) || 0
+      return Number(this.formData.landmarkId) || 0
     },
     areaId() {
-      return parseInt(this.formData.areaId) || 0
+      return Number(this.formData.areaId) || 0
     },
     doorFlag(){
         return this.formData.doorFlag
@@ -208,6 +208,7 @@ export default {
   },
   methods: {
     choosePoint(jsonp) {
+     
       this.formData.mapX = jsonp.x;
       this.formData.mapY = jsonp.y;
       this.formData.mapIndex = jsonp.index

+ 404 - 0
src/main/vue/src/pages/DrugAreaCanvas.vue

@@ -0,0 +1,404 @@
+<template>
+  <el-container class="content">
+    <el-main>
+      <el-row style="z-index:3">
+        <el-form :inline="true" class="demo-form-inline" size="mini">
+          <el-form-item>
+            <el-button @click="bgMove=!bgMove">{{bgMove?'固定':'拖拽'}}底图</el-button>
+          </el-form-item>
+          <!-- <el-form-item label="宽">
+          <el-input-number v-model="width" :min="1" label="描述文字"></el-input-number>
+        </el-form-item>
+        <el-form-item label="高">
+          <el-input-number v-model="height" :min="1" label="描述文字"></el-input-number>
+        </el-form-item>
+        <el-form-item label="比率">
+          <el-input-number v-model="mapRate" label="描述文字"></el-input-number>
+        </el-form-item>
+        <el-form-item>
+          <el-button @click="createMap">生成网格</el-button>
+          </el-form-item>-->
+          <el-form-item>
+            <el-button type="primary" @click="nowAdd=0,bgMove=false">删除区域</el-button>
+          </el-form-item>
+          <el-form-item>
+            <el-button type="danger" @click="bgMove=true">取消添加</el-button>
+          </el-form-item>
+          <el-form-item>
+            <el-popover placement="right" width="400" trigger="hover">
+              <el-table :data="tableData" style="width: 100%" @row-click="rowClick">
+                <el-table-column prop="id" label="区域id"></el-table-column>
+                <el-table-column prop="cityId" label="城市ID"></el-table-column>
+                <el-table-column prop="areaName" label="区域名称"></el-table-column>
+              </el-table>
+              <el-button slot="reference" type="success" plain size="mini">区域表格</el-button>
+            </el-popover>
+          </el-form-item>
+          <el-form-item>
+            <el-button @click="saveMapInfo" type="warning">保存</el-button>
+          </el-form-item>
+        </el-form>
+      </el-row>
+      <div class="dragContent" :style="{cursor:isDown&&bgMove?'move':(bgMove?'default':'crosshair'),top:bgPosition.top+'px',left:bgPosition.left+'px'}" @mousedown="isDown=true" @mousemove="bgMouseMove" @mouseup="isDown=false">
+        <img :src="mapImage" ref="bgImg" class="bgImg" :style="{height:mapHeight+'px'}" alt>
+        <!-- <div class="gridInfo" style="z-index:2">
+          <div class="grid-item" v-for="(item,index) in oldMapInfo" :style="{width:100/width/rate+'%',height:100/height/rate+'%',backgroundColor:color[item]}"></div>
+        </div>
+        <div class="gridInfo">
+          <div class="grid-item" @mousedown="addStart(index)" @mouseover="changeMap(index)" v-for="(item,index) in mapInfo" :style="{width:100/width/rate+'%',height:100/height/rate+'%',backgroundColor:colorArea[0]}">{{item&&item!='0'?item:''}}</div>
+        </div>-->
+        <canvas ref="canvas" class="gridCanvas" @mousedown="drawStart" @mousemove="drawMove"></canvas>
+      </div>
+    </el-main>
+  </el-container>
+</template>
+<script>
+import { mapState } from 'vuex'
+import { format } from 'date-fns'
+import zh from 'date-fns/locale/zh_cn'
+export default {
+  created() {
+
+    var data = {}
+    if (this.$route.query.column) {
+      var columnList = this.$route.query.column.split(';')
+      columnList.forEach(item => {
+        var tempColumn = item;
+        data[tempColumn.split(',')[1]] = tempColumn.split(',')[0];
+      })
+
+    }
+    this.landmarkId = data.landmarkId
+    this.mapHeight = this.totalHeight - 100
+    if (this.$route.query.column) {
+      this.$http.get({
+        url: '/landMark/getOne',
+        data: {
+          id: data.landmarkId
+        }
+      }).then(res => {
+        if (res.success) {
+
+
+          this.width = res.data.mapWidth || 20;
+          this.height = res.data.mapHeight || 20;
+          this.mapRate = res.data.mapRate || 1;
+          if (res.data.mapInfo) {
+            this.oldMapInfo = res.data.mapInfo.split('');
+          }
+
+          if (res.data.areaMapInfo) {
+            this.mapInfo = res.data.areaMapInfo.split(',')
+          }
+          else {
+            var list = []
+            this.oldMapInfo.forEach(item => {
+              list.push(0)
+            })
+            this.mapInfo = list
+          }
+
+          this.mapImage = res.data.mapSprite || require('../assets/demo_picture.jpg');
+
+        }
+      })
+
+
+
+
+
+      this.$http.get({
+        url: '/areaInfo/all',
+        data: data
+      }).then(res => {
+        if (res.success) {
+          this.tableData = res.data
+        }
+      })
+    }
+
+
+  },
+  data() {
+    return {
+      landmarkId: 0,
+      isDown: false,
+      bgMove: false,
+      bgPosition: {
+        left: 0,
+        top: 60
+      },
+      width: 32,
+      height: 22,
+      rate: 1,
+      mapRate: 1,
+      mapInfo: [],
+      color: ['rgba(111, 189, 39,0.5)', 'rgba(227,98,100,0.4)', 'rgba(83,147,255,0.4)'],
+      colorArea: ['rgba(255,255,255,0)'],
+      nowAdd: 0,
+      startMoveIndex: 0,
+      nowMoveIndex: 0,
+      nowMapInfo: [],
+      mapImage: '',
+      mapWidth: '',
+      mapHeight: '',
+      oldMapInfo: [],
+      tableData: []
+    }
+  },
+  mounted() {
+    if (!this.mapWidth) {
+      setTimeout(() => {
+        this.mapHeight = this.totalHeight - 100
+      }, 300)
+      setTimeout(() => {
+        this.mapWidth = this.$refs.bgImg.offsetWidth
+        this.$refs.canvas.width = this.mapWidth
+        this.$refs.canvas.height = this.mapHeight
+        this.drawContent()
+      }, 1000)
+    }
+  },
+  computed: {
+    ...mapState(['totalHeight']),
+  },
+  watch: {
+    mapInfo() {
+    
+      this.drawContent()
+    }
+  },
+  methods: {
+    bgMouseMove(e) {
+      if (this.isDown) {
+        if (this.bgMove) {
+          this.bgPosition = {
+            left: this.bgPosition.left + e.movementX,
+            top: this.bgPosition.top + e.movementY
+          }
+        }
+
+      }
+    },
+    createMap() {
+      var sum = this.width * this.rate * this.height * this.rate
+      var list = []
+      for (var i = 0; i < sum; i++) {
+        list.push(0)
+      }
+      this.mapInfo = list
+      this.nowAdd = 0
+      //   this.drawContent()
+
+    },
+    drawContent() {
+        
+      var width = this.mapWidth / this.width
+      var height = this.mapHeight / this.height
+      var list = [...this.oldMapInfo]
+      var ctx = this.$refs.canvas.getContext('2d')
+      ctx.clearRect(0, 0, this.mapWidth, this.mapHeight);
+      ctx.fillStyle = this.color[0];
+      ctx.fillRect(0, 0, this.mapWidth, this.mapHeight);
+      for (var i = 0; i < list.length; i++) {
+        if (list[i] > 0) {
+          ctx.clearRect(width * this.getX(i), height * this.getY(i), width, height);
+          ctx.fillStyle = this.color[list[i]];
+          ctx.fillRect(width * this.getX(i), height * this.getY(i), width, height);
+        }
+      }
+
+      var lineWidth = 2
+      if (list.length > 1000) {
+        lineWidth = 1
+      }
+      else if (list.length > 10000) {
+        lineWidth = 0.5
+      }
+
+      for (var i = 0; i < this.width; i++) {
+        ctx.beginPath();
+        ctx.lineWidth = lineWidth;
+        ctx.moveTo(width * i, 0);
+        ctx.lineTo(width * i, this.mapHeight);
+        ctx.strokeStyle = 'rgb(255,255,255,255)';
+        ctx.stroke();
+      }
+
+      for (var i = 0; i < this.height; i++) {
+        ctx.beginPath();
+        ctx.lineWidth = lineWidth;
+        ctx.moveTo(0, height * i);
+        ctx.lineTo(this.mapWidth, height * i);
+        ctx.strokeStyle = 'rgb(255,255,255,255)';
+        ctx.stroke();
+      }
+      var idList = [...this.mapInfo]
+      var fontSize = 24
+      if (idList.length > 1000) {
+        fontSize = 12
+      }
+      if (idList.length > 10000) {
+        fontSize = 9
+      }
+      for (var i = 0; i < idList.length; i++) {
+        if (parseInt(idList[i]) > 0) {
+          ctx.fillStyle = '#fff';
+          ctx.font = "bold " + fontSize + "px '微软雅黑'";
+          ctx.textBaseline = 'middle';
+          ctx.fillText(idList[i], width * this.getX(i) + width / 2 - fontSize / 3, height * this.getY(i) + height / 2);
+        }
+      }
+    },
+    drawStart(e) {
+      var width = this.mapWidth / this.width
+      var height = this.mapHeight / this.height
+      var x = parseInt(e.offsetX / width)
+      var y = parseInt(e.offsetY / height)
+      this.addStart(y * this.width + x)
+    },
+    drawMove(e) {
+      var width = this.mapWidth / this.width
+      var height = this.mapHeight / this.height
+      var x = parseInt(e.offsetX / width)
+      var y = parseInt(e.offsetY / height)
+      this.changeMap(y * this.width + x)
+    },
+    addStart(index) {
+      if (this.bgMove) {
+        return
+      }
+      this.nowMapInfo = [...this.mapInfo]
+      this.startMoveIndex = index
+      if (parseInt(this.nowAdd) != 0 && parseInt(this.mapInfo[index]) > 0) {
+
+      }
+      else {
+        this.mapInfo.splice(index, 1, this.nowAdd)
+      }
+
+    },
+    changeMap(index) {
+      if (this.bgMove) {
+        return
+      }
+      if (this.isDown) {
+        this.nowMoveIndex = index
+        this.mapInfo = [...this.nowMapInfo]
+        this.getChangeList(this.startMoveIndex, index).forEach(item => {
+          if (parseInt(this.nowAdd) != 0 && parseInt(this.mapInfo[item]) > 0) {
+          }
+          else {
+            this.mapInfo.splice(item, 1, this.nowAdd)
+          }
+        })
+      }
+
+    },
+    getX(index) {
+      return index % (this.width * this.rate)
+    },
+    getY(index) {
+      return parseInt(index / (this.width * this.rate))
+    },
+    getChangeList(index1, index2) {
+      var list = []
+      var list1 = [this.getX(index1), this.getX(index2)].sort((a, b) => { return a - b })
+      var list2 = [this.getY(index1), this.getY(index2)].sort((a, b) => { return a - b })
+      for (var i = list1[0]; i <= list1[1]; i++) {
+        for (var j = list2[0]; j <= list2[1]; j++) {
+          if (list.indexOf(this.getIndex(i, j)) == -1) {
+            list.push(this.getIndex(i, j))
+          }
+        }
+      }
+      return list
+    },
+    getIndex(x, y) {
+      return y * (this.width * this.rate) + x
+    },
+    saveMapInfo() {
+
+      if (this.landmarkId) {
+
+
+        var data = {
+          id: this.landmarkId,
+          mapWidth: this.width,
+          mapHeight: this.height,
+          rate: this.rate,
+          areaMapInfo: this.mapInfo.join(','),
+        };
+
+        this.$http.post({
+          url: '/landMark/update',
+          data: data
+        }).then(res => {
+          if (res.success) {
+            this.$message.success('成功');
+          } else {
+            this.$message.warning('失败')
+          }
+        });
+
+      }
+    },
+    rowClick(row, event, column) {
+      this.nowAdd = row.id
+      this.bgMove = false
+    }
+
+  }
+}
+
+
+
+</script>
+<style lang="less" scoped>
+.content {
+  position: relative;
+}
+.dragContent {
+  position: absolute;
+  top: 60px;
+  left: 0;
+  border: 2px dashed #ccc;
+  // cursor: move;
+  z-index: 1;
+  .gridInfo {
+    position: absolute;
+    top: 0;
+    left: 0;
+    width: 100%;
+    height: 100%;
+    z-index: 3;
+    display: flex;
+    flex-wrap: wrap;
+
+    .grid-item {
+      background-color: rgba(0, 0, 0, 0.3);
+      box-sizing: border-box;
+      border: 1px solid rgba(255, 255, 255, 1);
+      text-align: center;
+      display: flex;
+      align-items: center;
+      justify-content: center;
+      color: #fff;
+      font-weight: bold;
+      font-size: 24px;
+    }
+  }
+
+  .gridCanvas {
+    position: absolute;
+    top: 0;
+    left: 0;
+    z-index: 3;
+  }
+}
+.bgImg {
+  position: relative;
+  width: auto;
+  z-index: 2;
+}
+</style>

+ 318 - 0
src/main/vue/src/pages/DrugContentCanvas.vue

@@ -0,0 +1,318 @@
+<template>
+  <div class="content">
+    <el-row style="z-index:3">
+      <el-form :inline="true" class="demo-form-inline" size="mini">
+        <el-form-item>
+          <el-button @click="bgMove=!bgMove">{{bgMove?'固定':'拖拽'}}底图</el-button>
+        </el-form-item>
+        <el-form-item label="宽">
+          <el-input-number v-model="width" :min="1" label="描述文字"></el-input-number>
+        </el-form-item>
+        <el-form-item label="高">
+          <el-input-number v-model="height" :min="1" label="描述文字"></el-input-number>
+        </el-form-item>
+        <el-form-item label="比率">
+          <el-input-number v-model="mapRate" label="描述文字"></el-input-number>
+        </el-form-item>
+        <el-form-item>
+          <el-button @click="createMap">生成网格</el-button>
+        </el-form-item>
+        <el-form-item>
+          <el-button type="success" @click="nowAdd=0,bgMove=false">添加可行走</el-button>
+        </el-form-item>
+        <el-form-item>
+          <el-button type="danger" @click="nowAdd=1,bgMove=false">添加不可行走</el-button>
+        </el-form-item>
+        <el-form-item>
+          <el-button type="primary" @click="nowAdd=2,bgMove=false">添加主干道</el-button>
+        </el-form-item>
+        <el-form-item>
+          <el-button @click="saveMapInfo" type="warning">保存</el-button>
+        </el-form-item>
+      </el-form>
+    </el-row>
+    <div class="dragContent" :style="{cursor:isDown&&bgMove?'move':(bgMove?'default':'crosshair'),top:bgPosition.top+'px',left:bgPosition.left+'px'}" @mousedown="isDown=true" @mousemove="bgMouseMove" @mouseup="isDown=false">
+      <img :src="mapImage" ref="bgImg" class="bgImg" :style="{height:mapHeight+'px'}" alt>
+      <!-- <div class="gridInfo">
+        <div class="grid-item" @mousedown="addStart(index)" @mouseover="changeMap(index)" v-for="(item,index) in mapInfo" :style="{width:100/width/rate+'%',height:100/height/rate+'%',backgroundColor:color[item]}"></div>
+      </div>-->
+      <canvas ref="canvas" class="gridCanvas" @mousedown="drawStart" @mousemove="drawMove"></canvas>
+    </div>
+  </div>
+</template>
+<script>
+import { mapState } from 'vuex'
+import { format } from 'date-fns'
+import zh from 'date-fns/locale/zh_cn'
+export default {
+  created() {
+
+    if (this.$route.query.id) {
+      this.$http.get({
+        url: '/landMark/getOne',
+        data: {
+          id: this.$route.query.id
+        }
+      }).then(res => {
+        if (res.success) {
+
+
+          this.width = res.data.mapWidth || 20;
+          this.height = res.data.mapHeight || 20;
+          this.mapRate = res.data.mapRate || 1;
+          if (res.data.mapInfo) {
+            this.mapInfo = res.data.mapInfo.split('');
+          }
+
+          this.mapImage = res.data.mapSprite || require('../assets/demo_picture.jpg');
+
+        }
+      })
+    }
+
+
+  },
+  data() {
+    return {
+      isDown: false,
+      bgMove: true,
+      bgPosition: {
+        left: 0,
+        top: 60
+      },
+      width: 32,
+      height: 22,
+      rate: 1,
+      mapRate: 1,
+      mapInfo: [],
+      color: ['rgba(111, 189, 39,0.5)', 'rgba(227,98,100,0.4)', 'rgba(83,147,255,0.4)'],
+      nowAdd: 0,
+      startMoveIndex: 0,
+      nowMoveIndex: 0,
+      nowMapInfo: [],
+      mapImage: '',
+      mapWidth: '',
+      mapHeight: '',
+    }
+  },
+  mounted() {
+
+    if (!this.mapWidth) {
+      setTimeout(() => {
+        this.mapHeight = this.totalHeight - 100
+      }, 300)
+      setTimeout(() => {
+        this.mapWidth = this.$refs.bgImg.offsetWidth
+        this.$refs.canvas.width = this.mapWidth
+        this.$refs.canvas.height = this.mapHeight
+        this.drawContent()
+      }, 1000)
+    }
+  },
+  computed: {
+    ...mapState(['totalHeight']),
+  },
+  watch: {
+    mapInfo() {
+      this.drawContent()
+    }
+  },
+  methods: {
+    bgMouseMove(e) {
+      if (this.isDown) {
+        if (this.bgMove) {
+          this.bgPosition = {
+            left: this.bgPosition.left + e.movementX,
+            top: this.bgPosition.top + e.movementY
+          }
+        }
+
+      }
+    },
+    createMap() {
+      var sum = this.width * this.rate * this.height * this.rate
+      var list = []
+      for (var i = 0; i < sum; i++) {
+        list.push(0)
+      }
+      this.mapInfo = list
+      this.nowAdd = 0
+      this.drawContent()
+    },
+    drawContent() {
+      var width = this.mapWidth / this.width
+      var height = this.mapHeight / this.height
+      var list = [...this.mapInfo]
+      var colors = ["blue", "green", "yellow"];
+      var ctx = this.$refs.canvas.getContext('2d')
+      ctx.clearRect(0, 0, this.mapWidth, this.mapHeight);
+      ctx.fillStyle = this.color[0];
+      ctx.fillRect(0, 0, this.mapWidth, this.mapHeight);
+      for (var i = 0; i < list.length; i++) {
+        if (list[i] > 0) {
+          ctx.clearRect(width * this.getX(i), height * this.getY(i), width, height);
+          ctx.fillStyle = this.color[list[i]];
+          ctx.fillRect(width * this.getX(i), height * this.getY(i), width, height);
+        }
+      }
+
+      var lineWidth = 2
+      if (list.length > 1000) {
+        lineWidth = 1
+      }
+      else if (list.length > 10000) {
+        lineWidth = 0.5
+      }
+
+      for (var i = 0; i < this.width; i++) {
+        ctx.beginPath();
+        ctx.lineWidth = lineWidth;
+        ctx.moveTo(width * i, 0);
+        ctx.lineTo(width * i, this.mapHeight);
+        ctx.strokeStyle = 'rgb(255,255,255,255)';
+        ctx.stroke();
+      }
+
+      for (var i = 0; i < this.height; i++) {
+        ctx.beginPath();
+        ctx.lineWidth = lineWidth;
+        ctx.moveTo(0, height * i);
+        ctx.lineTo(this.mapWidth, height * i);
+        ctx.strokeStyle = 'rgb(255,255,255,255)';
+        ctx.stroke();
+      }
+    },
+    drawStart(e) {
+      var width = this.mapWidth / this.width
+      var height = this.mapHeight / this.height
+      var x = parseInt(e.offsetX / width)
+      var y = parseInt(e.offsetY / height)
+      this.addStart(y * this.width + x)
+    },
+    addStart(index) {
+      if (this.bgMove) {
+        return
+      }
+      // console.log(index)
+      this.nowMapInfo = [...this.mapInfo]
+      this.startMoveIndex = index
+      this.mapInfo.splice(index, 1, this.nowAdd)
+    },
+    drawMove(e) {
+      var width = this.mapWidth / this.width
+      var height = this.mapHeight / this.height
+      var x = parseInt(e.offsetX / width)
+      var y = parseInt(e.offsetY / height)
+      this.changeMap(y * this.width + x)
+    },
+    changeMap(index) {
+      if (this.bgMove) {
+        return
+      }
+      if (this.isDown) {
+        this.nowMoveIndex = index
+        // console.log(this.getChangeList(this.startMoveIndex, index))
+        this.mapInfo = [...this.nowMapInfo]
+        this.getChangeList(this.startMoveIndex, index).forEach(item => {
+          this.mapInfo.splice(item, 1, this.nowAdd)
+        })
+      }
+
+    },
+    getX(index) {
+      return index % (this.width * this.rate)
+    },
+    getY(index) {
+      return parseInt(index / (this.width * this.rate))
+    },
+    getChangeList(index1, index2) {
+      var list = []
+      var list1 = [this.getX(index1), this.getX(index2)].sort((a, b) => { return a - b })
+      var list2 = [this.getY(index1), this.getY(index2)].sort((a, b) => { return a - b })
+      for (var i = list1[0]; i <= list1[1]; i++) {
+        for (var j = list2[0]; j <= list2[1]; j++) {
+          if (list.indexOf(this.getIndex(i, j)) == -1) {
+            list.push(this.getIndex(i, j))
+          }
+        }
+      }
+      return list
+    },
+    getIndex(x, y) {
+      return y * (this.width * this.rate) + x
+    },
+    saveMapInfo() {
+
+      if (this.$route.query.id) {
+
+
+        var data = {
+          id: this.$route.query.id,
+          mapWidth: this.width,
+          mapHeight: this.height,
+          rate: this.rate,
+          mapInfo: this.mapInfo.join(''),
+        };
+
+        this.$http.post({
+          url: '/landMark/update',
+          data: data
+        }).then(res => {
+          if (res.success) {
+            this.$message.success('成功');
+          } else {
+            this.$message.warning('失败')
+          }
+        });
+
+      }
+    },
+
+
+  }
+}
+
+
+
+</script>
+<style lang="less" scoped>
+.content {
+  position: relative;
+}
+.dragContent {
+  position: absolute;
+  top: 60px;
+  left: 0;
+  border: 2px dashed #ccc;
+  // cursor: move;
+  z-index: 1;
+  .gridInfo {
+    position: absolute;
+    top: 0;
+    left: 0;
+    width: 100%;
+    height: 100%;
+    z-index: 3;
+    display: flex;
+    flex-wrap: wrap;
+
+    .grid-item {
+      background-color: rgba(0, 0, 0, 0.3);
+      box-sizing: border-box;
+      border: 1px solid rgba(255, 255, 255, 1);
+    }
+  }
+
+  .gridCanvas {
+    position: absolute;
+    top: 0;
+    left: 0;
+    z-index: 3;
+  }
+}
+.bgImg {
+  position: relative;
+  width: auto;
+  z-index: 2;
+}
+</style>

+ 2 - 2
src/main/vue/src/pages/ThingInfo.vue

@@ -309,10 +309,10 @@ export default {
       }
     },
     landmarkId() {
-      return this.formData.landmarkId
+      return Number(this.formData.landmarkId)||0
     },
     areaId() {
-      return this.formData.areaId
+      return Number(this.formData.areaId)||0
     }
   },
   methods: {

+ 60 - 26
src/main/vue/src/router/index.js

@@ -216,13 +216,25 @@ const router = new Router({
                     path: '/drugArea',
                     name: 'drugArea',
                     component: () =>
-                        import ('../pages/DrugArea')
+                        import ('../pages/DrugAreaCanvas')
+                },
+                {
+                    path: '/drugAreaCanvas',
+                    name: 'drugAreaCanvas',
+                    component: () =>
+                        import ('../pages/DrugAreaCanvas')
                 },
                 {
                     path: '/drugContent',
                     name: 'drugContent',
                     component: () =>
-                        import ('../pages/DrugContent')
+                        import ('../pages/DrugContentCanvas')
+                },
+                {
+                    path: '/drugContentCanvas',
+                    name: 'drugContentCanvas',
+                    component: () =>
+                        import ('../pages/DrugContentCanvas')
                 },
                 {
                     path: '/arContentTemplate',
@@ -443,112 +455,134 @@ const router = new Router({
                 {
                     path: '/landmarkType',
                     name: 'LandmarkType',
-                    component: () => import('../pages/LandmarkType')
+                    component: () =>
+                        import ('../pages/LandmarkType')
                 },
                 {
                     path: '/landmarkTypes',
                     name: 'LandmarkTypes',
-                    component: () => import('../pages/LandmarkTypes')
+                    component: () =>
+                        import ('../pages/LandmarkTypes')
                 },
                 {
                     path: '/aimTemplate',
                     name: 'AimTemplate',
-                    component: () => import('../pages/AimTemplate')
+                    component: () =>
+                        import ('../pages/AimTemplate')
                 },
                 {
                     path: '/aimTemplates',
                     name: 'AimTemplates',
-                    component: () => import('../pages/AimTemplates')
+                    component: () =>
+                        import ('../pages/AimTemplates')
                 },
                 {
                     path: '/aimTemplateAim',
                     name: 'AimTemplateAim',
-                    component: () => import('../pages/AimTemplateAim')
+                    component: () =>
+                        import ('../pages/AimTemplateAim')
                 },
                 {
                     path: '/aimTemplateAims',
                     name: 'AimTemplateAims',
-                    component: () => import('../pages/AimTemplateAims')
+                    component: () =>
+                        import ('../pages/AimTemplateAims')
                 },
                 {
                     path: '/aimTemplateAr',
                     name: 'AimTemplateAr',
-                    component: () => import('../pages/AimTemplateAr')
+                    component: () =>
+                        import ('../pages/AimTemplateAr')
                 },
                 {
                     path: '/aimTemplateArs',
                     name: 'AimTemplateArs',
-                    component: () => import('../pages/AimTemplateArs')
+                    component: () =>
+                        import ('../pages/AimTemplateArs')
                 },
                 {
                     path: '/areaInfo',
                     name: 'AreaInfo',
-                    component: () => import('../pages/AreaInfo')
+                    component: () =>
+                        import ('../pages/AreaInfo')
                 },
                 {
                     path: '/areaInfos',
                     name: 'AreaInfos',
-                    component: () => import('../pages/AreaInfos')
+                    component: () =>
+                        import ('../pages/AreaInfos')
                 },
                 {
                     path: '/thingInfo',
                     name: 'ThingInfo',
-                    component: () => import('../pages/ThingInfo')
+                    component: () =>
+                        import ('../pages/ThingInfo')
                 },
                 {
                     path: '/thingInfos',
                     name: 'ThingInfos',
-                    component: () => import('../pages/ThingInfos')
+                    component: () =>
+                        import ('../pages/ThingInfos')
                 },
                 {
                     path: '/aimGroupInfo',
                     name: 'AimGroupInfo',
-                    component: () => import('../pages/AimGroupInfo')
+                    component: () =>
+                        import ('../pages/AimGroupInfo')
                 },
                 {
                     path: '/aimGroupInfos',
                     name: 'AimGroupInfos',
-                    component: () => import('../pages/AimGroupInfos')
+                    component: () =>
+                        import ('../pages/AimGroupInfos')
                 },
                 {
                     path: '/areaShowPoint',
                     name: 'AreaShowPoint',
-                    component: () => import('../pages/AreaShowPoint')
+                    component: () =>
+                        import ('../pages/AreaShowPoint')
                 },
                 {
                     path: '/areaShowPoints',
                     name: 'AreaShowPoints',
-                    component: () => import('../pages/AreaShowPoints')
+                    component: () =>
+                        import ('../pages/AreaShowPoints')
                 },
                 {
                     path: '/aimPlaceInfo',
-                        name: 'AimPlaceInfo',
-                    component: () => import('../pages/AimPlaceInfo')
+                    name: 'AimPlaceInfo',
+                    component: () =>
+                        import ('../pages/AimPlaceInfo')
                 },
                 {
                     path: '/aimPlaceInfos',
-                        name: 'AimPlaceInfos',
-                    component: () => import('../pages/AimPlaceInfos')
+                    name: 'AimPlaceInfos',
+                    component: () =>
+                        import ('../pages/AimPlaceInfos')
                 },
                 {
                     path: '/userFileInfo',
                     name: 'UserFileInfo',
-                    component: () => import('../pages/UserFileInfo')
+                    component: () =>
+                        import ('../pages/UserFileInfo')
                 },
                 {
                     path: '/userFileInfos',
                     name: 'UserFileInfos',
-                    component: () => import('../pages/UserFileInfos')
+                    component: () =>
+                        import ('../pages/UserFileInfos')
                 },
                 {
                     path: '/arContentType',
                     name: 'ArContentType',
-                    component: () => import('../pages/ArContentType')
+                    component: () =>
+                        import ('../pages/ArContentType')
                 },
                 {
                     path: '/arContentTypes',
                     name: 'ArContentTypes',
-                    component: () => import('../pages/ArContentTypes')
+                    component: () =>
+                        import ('../pages/ArContentTypes')
                 }
                 /**INSERT_LOCATION**/
             ]