zhangzengfei
2021-02-04 0175cda6150656bc74b34c6f6c71edd1e1fc653c
src/pages/panoramicView/components/LabelMark.vue
@@ -117,24 +117,27 @@
                v-if="panoramaPath"
                :style="{width:fixedW+'px',height:fixedH+'px'}"
              >
                <img
                  v-if="panoramaPath"
                  :style="{width:imgW+'px',height:imgH+'px'}"
                  :src="panoramaPath"
                  @mousemove="showCurPos"
                  @mouseout="isShowCurPos=false"
                />
                <div
                  class="label"
                  @mouseover="labelOver(item)"
                  @mouseout="item.isShow=false"
                  v-for="item in curCameraData.panoramaCoords"
                  :key="item.id"
                  :style="{left:`${item.x}px`, top:`${item.y}px`, backgroundColor: colorPick, width: `${dotSize}px`, height: `${dotSize}px` }"
                >
                  <span class="text" v-show="item.isShow">
                    <b>{{item.x}},</b>&nbsp;<b>{{item.y}}</b>
                  </span>
                <div class="img-area" :style="{width:imgW+'px',height:imgH+'px'}">
                  <img
                    v-if="panoramaPath"
                    :style="{width:imgW+'px',height:imgH+'px'}"
                    :src="panoramaPath"
                    @mousemove="showCurPos"
                    @mouseout="isShowCurPos=false"
                  />
                  <div
                    class="label"
                    @mouseover="labelOver(item)"
                    @mouseout="item.isShow=false"
                    v-for="item in curCameraData.panoramaCoords"
                    :key="item.id"
                    :style="{left:`${item.x}px`, top:`${item.y}px`, backgroundColor: colorPick, width: `${dotSize}px`, height: `${dotSize}px` }"
                  >
                    <span class="text" v-show="item.isShow">
                      <b>{{item.x}},</b>&nbsp;
                      <b>{{item.y}}</b>
                    </span>
                  </div>
                </div>
              </div>
              <div class="pos" v-show="isShowCurPos">
@@ -217,10 +220,9 @@
import LeftNav from "@/components/LeftNav";
export default {
  components: { LeftNav },
  data () {
  data() {
    return {
      screenHeight: 0,
      actPage: 1,
      labels: [],
      colorPick: '#79f2fb',
      dotSize: 3,
@@ -264,7 +266,7 @@
      },
    }
  },
  mounted () {
  mounted() {
    this.getAllCameraData();
    this.getPanorama();
    this.screenHeight = document.documentElement.clientHeight - 20;
@@ -277,7 +279,7 @@
  watch: {
    'TreeDataPool.selectedNode': {
      handler (n, o) {
      handler(n, o) {
        let curCamera = this.cameraData.find(item => item.id == n.id);
        //设置摄像机底图
        this.snapshot_url = curCamera.snapshot_url;
@@ -285,7 +287,7 @@
      },
      deep: true
    },
    isEdit (n, o) {
    isEdit(n, o) {
      if (n) {
        this.$refs['editBoard'].addEventListener('click', this.bindListen);
      } else {
@@ -294,16 +296,16 @@
    }
  },
  methods: {
    labelOver (item) {
    labelOver(item) {
      debugger
      this.$nextTick(() => {
        item.isShow = true;
      })
    },
    labelout (item) {
    labelout(item) {
      item.isShow = false;
    },
    getAllCameraData () {
    getAllCameraData() {
      let _this = this;
      getCamerasByServer().then(res => {
        if (res.success) {
@@ -314,7 +316,7 @@
        console.log(e)
      })
    },
    sure () {
    sure() {
      let _this = this;
      this.$refs['labelForm'].validate(valid => {
        console.log(valid)
@@ -332,7 +334,7 @@
      });
    },
    //获取摄像机标注
    findCameraMarks (id) {
    findCameraMarks(id) {
      getCameraMarks({ cameraId: id }).then(res => {
        if (res.success) {
          this.curCameraData.cameraId = id;
@@ -346,7 +348,7 @@
        console.log(e)
      });
    },
    editCameraData () {
    editCameraData() {
      if (!this.TreeDataPool.selectedNode.id) {
        this.$notify({
          message: '请先选择摄像机',
@@ -356,14 +358,14 @@
      }
      this.isEdit = !this.isEdit;
    },
    async submitInfo () {
    async submitInfo() {
      this.isEdit = false;
      let res = await updateCameraMarks(this.curCameraData);
      if (res.success) {
        this.findCameraMarks(this.curCameraData.cameraId);
      }
    },
    getPanorama () {
    getPanorama() {
      let _this = this;
      getPanoramaPic().then(res => {
        //判断长宽比
@@ -378,20 +380,20 @@
        _this.panoramaPath = res.data.panoramaPath + '?' + Math.random();
      })
    },
    showCurPos (e) {
    showCurPos(e) {
      console.log(e);
      this.isShowCurPos = true;
      this.traceX = e.offsetX;
      this.traceY = e.offsetY;
    },
    onChange (file, fileList) {
    onChange(file, fileList) {
      if (file.raw.type == "image/jpeg") {
        fileList = [file]
        this.isShowCurPos = false;
      }
    },
    definedUpload (params) {
    definedUpload(params) {
      let _this = this;
      let _file = params.file;
      let param = new FormData();
@@ -405,10 +407,10 @@
    },
    bindListen (e) {
    bindListen(e) {
      this.newLabel(e);
    },
    newLabel (e) {
    newLabel(e) {
      console.log('点击了画板')
      if (this.isShowPop) return;
      //获取鼠标相对于画板的定位
@@ -428,14 +430,14 @@
      this.isShowPop = true;
      this.isNewLabel = true;
    },
    editLabel (label) {
    editLabel(label) {
      if (!this.isEdit) return;
      this.isShowPop = true;
      this.$refs['labelForm'].clearValidate();
      this.curLabel = JSON.parse(JSON.stringify(label));
    },
    cancle () {
    cancle() {
      this.isShowPop = false;
      //如果是未保存过的label直接删除(未保存的就是labels数组中最后一个)
      if (this.curLabel.id.startsWith('n')) {
@@ -443,7 +445,7 @@
        this.curCameraData.coords.pop();
      }
    },
    deleteLabel () {
    deleteLabel() {
      if (this.curLabel.id) {
        let index = this.curCameraData.coords.findIndex(item => item.id == this.curLabel.id);
        this.curCameraData.coords.splice(index, 1);
@@ -505,7 +507,7 @@
  }
  .resize-bar:hover ~ .resize-line::after,
  .resize-bar:active ~ .resize-line::after {
    content: '';
    content: "";
    position: absolute;
    width: 16px;
    height: 16px;
@@ -682,7 +684,9 @@
    display: flex;
    padding-bottom: 30px;
    .img-wrap {
      position: relative;
      .img-area {
        position: relative;
      }
      .label {
        position: absolute;
        border-radius: 50%;