zhangzengfei
2021-06-25 cce5e625e8870248081302513b9cb38e676a04e5
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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
<template>
  <div class="swiper-box">
    <p class="task-tip" v-if="cameras.length == 0 "></p>
    <swiper
      ref="cameraSwiper"
      v-if="cameras.length>=1"
      :options="swiperOption"
      class="swiper-box-container"
    >
      <swiper-slide v-for="camera in cameras" :key="camera.id+'c'">
        <div class="swiper-draw-box-title">
          <div class="left-fixed">
            <b style="margin-left:14px;">绘制区域</b>
            <span
              class="el-dropdown-link"
              @click="drawBaseImg(camera.id)"
              style="position: relative;top: 5px; cursor:pointer"
            >
              <i class="iconfont iconbianji1" style="font-size: 28px; "></i>
            </span>
          </div>
          <b>{{camera.name}}</b>
        </div>
        <polygon-canvas
          class="polygon-canvas"
          :ref="`polygonCanvas_${camera.id}`"
          :currentCameraId="camera.id"
          :snapshot_url="camera.canvasData.snapshot_url"
          :canvasDataShow="camera.canvasData"
          :canvasWidth="576"
          :canvasHeight="324"
          @fromCanvas="getCanvasData"
          @refresh="refresh"
        ></polygon-canvas>
      </swiper-slide>
    </swiper>
    <div class="swiper-pre-border" slot="button-prev" @click="pre">
      <div class="icon-btn">
        <i class="iconfont iconzuo"></i>
      </div>
    </div>
    <div class="swiper-next-border" slot="button-next" @click="next">
      <div class="icon-btn">
        <i class="iconfont iconyou1"></i>
      </div>
    </div>
  </div>
</template>
 
<script>
import { chunkArr } from '@/scripts/util';
import PolygonCanvas from '@/components/canvas';
import { savePolygon } from "@/api/polygon";
export default {
  //cameras: [{ id: '',snapshot_url:'', canvasData: {} }]
  props: [
    'cameras',
    //'swiperOption'
  ],
  watch: {
    cameras: {
      handler(n, o) {
        console.log('slidecanvas cameras', n)
      },
      deep: true
    }
  },
  components: { PolygonCanvas },
  data() {
    return {
      swiperOption: this.newOption(),
      //mySwiper: {}
    }
  },
  computed: {
    swiper() {
      return this.$refs['cameraSwiper'].swiper
    }
  },
  mounted() {
    //this.mySwiper = this.$refs.sceneSwiper.swiper;
    // console.log(this.swiper)
  },
  methods: {
    refresh(url, cameraId) {
      this.$emit('polygonDataUpdate')
    },
    getCanvasData(data) {
      let _this = this;
      savePolygon(data).then(rsp => {
        _this.$emit('polygonDataUpdate')
      });
    },
    newOption() {
      return {
        slidesPerView: 1,
        spaceBetween: 0,
        pagination: {
          el: ".swiper-pagination",
          clickable: true
        },
        observer: true,//修改swiper自己或子元素时,自动初始化swiper
        observeParents: true,//修改swiper的父元素时,自动初始化swiper
      }
    },
 
    pre() {
      this.swiper.activeIndex--;
      if (this.swiper.activeIndex == -1) {
        this.swiper.activeIndex = this.cameras.length - 1;
      }
      this.swiper.slideTo(this.swiper.activeIndex);
    },
    next() {
      this.swiper.activeIndex++;
      if (this.swiper.activeIndex == this.cameras.length) {
        this.swiper.activeIndex = 0;
      }
      this.swiper.slideTo(this.swiper.activeIndex);
    },
    drawBaseImg(id) {
      this.$refs[`polygonCanvas_${id}`][0].showModal();
    }
  }
};
</script>
 
<style lang="scss">
.icon {
  width: 1em;
  height: 1em;
  vertical-align: -0.15em;
  fill: currentColor;
  overflow: hidden;
}
.task-tip {
  font-family: PingFangSC-Regular;
  font-size: 12px;
  color: #cccccc;
  margin-top: 10%;
}
.swiper-box {
  position: relative;
}
.swiper-pre-border,
.swiper-next-border {
  width: 40px;
  height: 40px;
  position: absolute;
  background: #8888;
  top: 50%;
  margin-top: -20px;
  z-index: 99;
  border-radius: 4em;
  outline: none;
  .icon-btn {
    color: rgb(255, 255, 255);
    text-align: center;
    line-height: 38px;
    cursor: pointer;
  }
}
.swiper-pre-border {
  left: 10px;
}
.swiper-pre-border:hover {
  background: #666;
}
.swiper-next-border {
  right: 10px;
}
.swiper-next-border:hover {
  background: #666;
}
.swiper-draw-box-title {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  height: 24px;
  b {
    font-size: 14px;
  }
  .left-fixed {
    position: absolute;
    left: 0;
    top: -6px;
  }
}
.wrap-box {
  width: 100%;
  display: inline-block;
  .inner {
    width: 90%;
    box-sizing: border-box;
    position: relative;
    font-size: 14px;
    padding: 7px 0 48px;
    transition: all 1s;
    background: #ffffff;
    border: 1px solid #e2e2e2;
    box-shadow: 0 5px 12px 0 rgba(0, 0, 0, 0.07);
    border-radius: 4px;
    margin: auto;
    &:hover {
      .mask {
        display: block;
      }
    }
    .mask {
      position: absolute;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      background: rgba(0, 0, 0, 0.65);
      backdrop-filter: blur(1px) brightness(100%);
      text-align: center;
      z-index: 1;
      border-radius: 3px;
      display: none;
      .tool {
        position: absolute;
        top: 49%;
        left: 50%;
        transform: translate(-50%, -50%);
        i {
          font-size: 50px;
        }
        i:nth-of-type(1) {
          margin-right: 30px;
        }
        i:nth-of-type(2) {
          color: red;
        }
      }
    }
  }
}
</style>