hanbaoshan
2020-10-23 f857a9130f97694c756dc8913e900bf9a74563ef
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
<template>
  <div class="right-side">
    <div class="tool-bar">
      <div>
        <!-- <input type="color" ref="colorPicker" v-model="color"> -->
        <label for>拾色器:</label>
        <el-color-picker v-model="color" show-alpha size="mini"></el-color-picker>
      </div>
      <div style="width:250px;">
        <label for>笔触:</label>
        <el-slider v-model="dotSize" :min="1" :max="20"></el-slider>
      </div>
    </div>
    <div class="action-bar">
      <el-button type size="mini" @click="newLabel">标注</el-button>
      <el-button type size="mini" @click="isEdit=!isEdit">{{isEdit?'锁定':'编辑'}}</el-button>
    </div>
    <div class="drawboard">
      <div class="mask" v-show="isEdit" ref="editBoard">
        <div class="label" v-for="(item,index) in labels" :key="index" :style="{left:`${item.x}px`, top:`${item.y}px`}"></div>
      </div>
      <img :src="baseUrl" alt />
    </div>
    <el-dialog>
      
    </el-dialog>
  </div>
</template>
 
<script>
import TreeDataPool from "@/Pool/TreeData";
export default {
  data () {
    return {
      labels: [],
      color: '#79f2fb',
      dotSize: 3,
      isEdit: false,
      isNewLabel: false,
      baseUrl: ''
    }
  },
  computed: {
    
  },
  watch:{
    isEdit(n,o){
      if(n){
        this.$refs['editBoard'].addEventListener('click',(e)=>{
          this.newLabel(e);
        })
      }
    }
  },
  methods: {
    newLabel(e){
      this.labels.push({x,y});
      this.isNewLabel = true;
    }
  }
}
</script>
 
<style lang="scss">
.right-side {
  height: 100%;
  background: #d2dcea;
  .tool-bar {
    width: 100%;
    height: 60px;
    padding: 10px 20px;
    box-sizing: border-box;
    background: rgb(250, 250, 250);
    margin-bottom: 40px;
    display: flex;
    align-items: center;
    > div {
      cursor: pointer;
      background: rgb(245, 245, 245);
      padding: 0 5px;
      height: 40px;
      margin: 7px;
      display: flex;
      align-items: center;
      label {
        margin-right: 10px;
        color: rgb(161, 161, 161);
      }
      .el-slider {
        width: 110px;
      }
    }
  }
  .action-bar{
    width: 960px;
    margin: auto;
    margin-bottom: 20px;
    text-align: right;
  }
  .drawboard {
    margin: auto;
    width: 960px;
    height: 540px;
    position: relative;
    background: #fff;
    box-shadow: 3px 3px 3px 1px rgba(0, 0, 0, 0.1);
    .mask{
      position: absolute;
      background: rgba(20, 181, 255, 0.1);
      width: 100%;
      height: 100%;
    }
    img{
      width: 960px;
      height: 540px;
      background:#f0ffca;
    }
  }
}
</style>