<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>
|