<template>
|
<div class="CameraBox" v-if="cameras">
|
<div v-for="(camera, index) in cameraArr" :key="index" class="boxItem">
|
<div class="header">
|
<i class="iconfont"></i>
|
<div class="name">{{ camera.cameraName }}</div>
|
<el-switch
|
v-model="camera.analytics"
|
@change="pollEnable($event, index)"
|
active-color="#D4E3FA"
|
inactive-color="#E9EBEE"
|
:width="56"
|
>
|
</el-switch>
|
</div>
|
|
<div class="body">
|
<div class="row" v-if="camera.analytics">
|
<div class="label">处理方式:</div>
|
<div
|
class="button pollingBtn"
|
:class="{ active: !camera.dealWay }"
|
@click="changePoll(false, index)"
|
>
|
轮询
|
</div>
|
<div
|
class="button realtimeBtn"
|
:class="{ active: camera.dealWay }"
|
@click="changePoll(true, index)"
|
>
|
实时
|
</div>
|
</div>
|
<div class="row">
|
<div class="label">分辨率:</div>
|
<div class="data">
|
{{
|
!camera.camearInfo.resolutionWidth ||
|
!camera.camearInfo.resolutionHeight ||
|
camera.camearInfo.resolutionWidth == 0 ||
|
camera.camearInfo.resolutionHeight == 0
|
? "本机分辨率"
|
: `${camera.camearInfo.resolutionWidth} * ${camera.camearInfo.resolutionHeight}`
|
}}
|
</div>
|
</div>
|
</div>
|
</div>
|
<div class="footer">
|
<!-- <div class="button addModel">添加到模板</div> -->
|
<div class="button addRule" @click="addRule">添加新场景</div>
|
</div>
|
</div>
|
</template>
|
|
<script>
|
import { changeRunType } from "@/api/pollConfig";
|
import { getCameraInfo } from "@/api/camera";
|
|
export default {
|
props: {
|
cameras: {
|
type: Array,
|
},
|
},
|
|
data() {
|
return {
|
cameraArr: [],
|
};
|
},
|
created() {
|
this.getCameraInfo();
|
},
|
computed: {},
|
methods: {
|
//是否进行视频分析处理
|
pollEnable(row, index) {
|
let val = 0;
|
if (row) {
|
if (this.PollData.RealTimeSum < this.PollData.channelTotal) {
|
this.cameraArr[index].dealWay = true;
|
val = 1;
|
} else {
|
this.cameraArr[index].dealWay = false;
|
val = 0;
|
}
|
} else {
|
this.cameraArr[index].dealWay = false;
|
val = -1;
|
}
|
if (
|
this.cameraArr[index].cameraId &&
|
this.cameraArr[index].cameraId !== undefined
|
) {
|
changeRunType({
|
camera_ids: [this.cameraArr[index].cameraId],
|
run_type: val,
|
}).then((rsp) => {
|
if (rsp && rsp.success) {
|
this.$notify({
|
type: "success",
|
message: "配置成功",
|
});
|
} else {
|
this.$notify({
|
type: "error",
|
message: "配置失败",
|
});
|
}
|
});
|
}
|
// this.PollData.statisticTaskInfo();
|
},
|
|
//实时、轮询切换
|
changePoll(row, index) {
|
//判断是新增还是更新
|
console.log(this.cameraArr[index]);
|
|
if (
|
this.cameraArr[index].cameraId &&
|
this.cameraArr[index].cameraId !== undefined
|
) {
|
if (this.PollData.RealTimeSum < this.PollData.channelTotal) {
|
if (row) {
|
this.cameraArr[index].dealWay = true;
|
} else {
|
this.cameraArr[index].dealWay = false;
|
}
|
changeRunType({
|
camera_ids: [this.cameraArr[index].cameraId],
|
run_type: this.cameraArr[index].dealWay ? 1 : 0,
|
}).then((rsp) => {
|
if (rsp && rsp.success) {
|
this.$notify({
|
type: "success",
|
message: "配置成功",
|
});
|
} else {
|
this.$notify({
|
type: "error",
|
message: "配置失败",
|
});
|
}
|
});
|
} else {
|
if (this.cameraArr[index].dealWay) {
|
this.cameraArr[index].dealWay = false;
|
changeRunType({
|
camera_ids: [this.cameraArr[index].cameraId],
|
run_type: this.cameraArr[index].dealWay ? 1 : 0,
|
}).then((rsp) => {
|
if (rsp && rsp.success) {
|
this.$notify({
|
type: "success",
|
message: "配置成功",
|
});
|
} else {
|
this.$notify({
|
type: "error",
|
message: "配置失败",
|
});
|
}
|
});
|
}
|
}
|
// this.TreeDataPool.fetchTreeData();
|
// this.PollData.statisticTaskInfo();
|
}
|
},
|
|
// 显示新增弹窗
|
addRule() {
|
this.$emit("addLinkageRule");
|
},
|
|
getCameraInfo() {
|
if (this.cameras.length <= 0) {
|
return;
|
}
|
|
let arr = [];
|
|
this.cameras.forEach(async (id) => {
|
if (!id) {
|
return;
|
}
|
const rsp = await getCameraInfo(id);
|
if (rsp.success) {
|
arr.push({
|
cameraId: rsp.data.id,
|
cameraName: rsp.data.name ? rsp.data.name : "",
|
analytics: rsp.data.runType !== -1 ? true : false,
|
dealWay: rsp.data.runType == 1 ? true : false,
|
camearInfo: {
|
resolutionWidth: rsp.data.resolutionWidth,
|
resolutionHeight: rsp.data.resolutionHeight,
|
},
|
});
|
}
|
});
|
|
this.cameraArr = arr;
|
this.$forceUpdate();
|
},
|
},
|
watch: {
|
cameras() {
|
this.getCameraInfo();
|
},
|
},
|
};
|
</script>
|
|
<style lang="scss" scoped>
|
.CameraBox {
|
margin-bottom: 20px;
|
width: 236px;
|
border-radius: 5px;
|
background-color: #fff;
|
filter: drop-shadow(0px 2px 16px rgba(0, 43, 106, 0.25));
|
|
.boxItem {
|
height: 156px;
|
}
|
|
.header {
|
display: flex;
|
box-sizing: border-box;
|
padding: 0 10px;
|
height: 44px;
|
background: #f0f5fa;
|
align-items: center;
|
|
i {
|
font-size: 18px;
|
margin-right: 6px;
|
color: #0065ff;
|
}
|
|
.name {
|
width: 136px;
|
font-size: 14px;
|
color: #5f5f5f;
|
}
|
|
.el-switch ::v-deep {
|
height: 24px;
|
.el-switch__core {
|
height: 24px;
|
border-radius: 16px;
|
}
|
.el-switch__core::after {
|
margin-top: 2px;
|
margin-left: 3px;
|
width: 16px;
|
height: 16px;
|
background: #999999;
|
}
|
}
|
.el-switch.is-checked ::v-deep {
|
.el-switch__core::after {
|
margin-left: -20px;
|
|
background-color: #0065ff;
|
}
|
}
|
}
|
|
.body {
|
box-sizing: border-box;
|
padding: 0 10px 20px 10px;
|
.row {
|
margin-top: 20px;
|
display: flex;
|
align-items: center;
|
|
.label {
|
width: 70px;
|
font-size: 12px;
|
color: #666;
|
}
|
|
.button {
|
position: relative;
|
width: 73px;
|
height: 24px;
|
text-align: center;
|
border: 1px solid #c0c5cc;
|
font-size: 12px;
|
color: #999;
|
border-radius: 5px;
|
line-height: 24px;
|
|
&.pollingBtn {
|
&.active {
|
z-index: 1;
|
background: #ff6a00;
|
border: 1px solid #ff6a00;
|
color: #fff;
|
}
|
}
|
|
&.realtimeBtn {
|
margin-left: -5px;
|
background-color: #fff;
|
|
&.active {
|
z-index: 1;
|
background: #0065ff;
|
border: 1px solid #0065ff;
|
color: #fff;
|
}
|
}
|
}
|
}
|
}
|
|
.footer {
|
box-sizing: border-box;
|
padding: 10px;
|
display: flex;
|
align-items: center;
|
border-top: 1px solid #e9ebee;
|
|
.addModel {
|
margin-right: 10px;
|
width: 102px;
|
height: 32px;
|
text-align: center;
|
line-height: 32px;
|
border: 1px solid #0065ff;
|
color: #0065ff;
|
}
|
|
.addRule {
|
width: 102px;
|
height: 32px;
|
text-align: center;
|
line-height: 32px;
|
border: 1px solid #0065ff;
|
background-color: #0065ff;
|
color: #fff;
|
}
|
}
|
}
|
|
.empty {
|
box-sizing: border-box;
|
padding-top: 80px;
|
text-align: center;
|
color: #ccc;
|
}
|
</style>
|