From 4b90690fc6715504b9df5f9e4d76a7aea849ed7d Mon Sep 17 00:00:00 2001
From: zhangzengfei <zhangzengfei@smartai.com>
Date: 星期日, 28 八月 2022 23:14:50 +0800
Subject: [PATCH] 添加排查标记. 修正饼图提示
---
src/components/canvas/index.vue | 531 +++++++++++++++++++++++++---------------------------------
1 files changed, 229 insertions(+), 302 deletions(-)
diff --git a/src/components/canvas/index.vue b/src/components/canvas/index.vue
index d3672d5..cc706af 100644
--- a/src/components/canvas/index.vue
+++ b/src/components/canvas/index.vue
@@ -1,32 +1,21 @@
<template>
- <div
- class="s-cavas"
- :style="{ width: canvasWidth + 'px', height: canvasHeight + 'px' }"
- >
+ <div class="s-cavas" :style="{ width: canvasWidth + 'px', height: canvasHeight + 'px' }">
<canvas
ref="myCanvas"
:width="canvasWidth"
:height="canvasHeight"
- :style="`background:url(${canvasBg}) center / ${canvasWidth}px ${canvasHeight}px no-repeat; background-size: contain;`"
+ :style="
+ `background:url(${canvasBg}) center / ${canvasWidth}px ${canvasHeight}px no-repeat; background-size: contain;`
+ "
></canvas>
- <el-tooltip
- content="鍒锋柊搴曞浘"
- placement="bottom"
- popper-class="atooltip"
- v-if="isShowRefresh"
- >
+ <el-tooltip content="鍒锋柊搴曞浘" placement="bottom" popper-class="atooltip" v-if="isShowRefresh">
<span class="iconfont icongengxin" @click="refresh"></span>
</el-tooltip>
<p class="tip" :style="disabled ? `display:block;` : `display:none;`">
鎵归噺閰嶇疆鏂瑰紡涓嶅厑璁哥粯鍒跺尯鍩燂紝璇烽�夋嫨鎽勫儚鏈鸿繘琛屽尯鍩熺粯鍒�
</p>
- <el-dialog
- :visible.sync="visible"
- width="1150px"
- append-to-body
- :before-close="cancelFunc"
- >
+ <el-dialog :visible.sync="visible" width="1150px" append-to-body :before-close="cancelFunc">
<canvas-dialog
ref="bigCanvas"
:canvasDataToChild="canvasData"
@@ -41,94 +30,94 @@
</div>
</template>
<script>
-import canvasDialog from "./Dialog";
-import { updateSnapshot } from "@/api/camera";
+import canvasDialog from "./Dialog"
+import { updateSnapshot, updategb28181 } from "@/api/camera"
export default {
name: "myCanvas",
components: {
- canvasDialog,
+ canvasDialog
},
props: {
divId: {
default: "my-canvas",
- type: String,
+ type: String
},
isGB28181: {
default: false,
- type: Boolean,
+ type: Boolean
},
isShowRefresh: {
default: true,
- type: Boolean,
+ type: Boolean
},
sourceType: {
default: 1,
- type: Number,
+ type: Number
},
isShowDrawArrow: {
default: false,
- type: Boolean,
+ type: Boolean
},
disabled: {
default: false,
- type: Boolean,
+ type: Boolean
},
canvasDataShow: {
default: () => {
- return { line: [], rect: [], arrow: [], polygon: [] };
+ return { line: [], rect: [], arrow: [], polygon: [] }
},
- type: Object,
+ type: Object
},
currentCamera: {
- type: Object,
+ type: Object
},
snapshot_url: {
type: String,
- default: "",
+ default: ""
},
isLink: {
type: Boolean,
- default: false,
+ default: false
},
loading: {
type: Boolean,
- default: false,
+ default: false
},
canvasWidth: {
type: Number,
- default: 576,
+ default: 576
},
canvasHeight: {
type: Number,
- default: 324,
+ default: 324
},
showProportion: {
type: Number,
- default: 1.666,
- },
+ default: 1.666
+ }
},
computed: {
canvasBg() {
if (this.snapshot_url) {
// 鏁版嵁鏍堣嚜鍔ㄤ笂浼犲鐞�
if (this.snapshot_url.indexOf("/opt/vasystem") == 0) {
- return this.snapshot_url.replace("/opt/vasystem", "");
+ return this.snapshot_url.replace("/opt/vasystem", "")
}
if (this.snapshot_url.indexOf("data:image/png;base64,") != -1) {
- return `${this.snapshot_url}`;
+ return `${this.snapshot_url}`
}
if (this.sourceType == 2) {
- return `${this.snapshot_url}`;
+ return `${this.snapshot_url}`
} else {
- console.log(this.snapshot_url);
- return `http://${this.snapshot_url}`;
+ console.log(this.snapshot_url)
+ return `/httpImage/${this.snapshot_url}`
}
} else {
- return this.blackImg;
+ return this.blackImg
}
- },
+ }
},
data() {
return {
@@ -137,7 +126,7 @@
line: [],
rect: [],
arrow: [],
- polygon: [],
+ polygon: []
}, // 鏈�缁堣緭鍑虹殑鐢诲竷鍧愭爣鏁版嵁
canvasPic: new Image(), // 鎾ら攢鐢ㄧ殑鍥剧墖
canvasHistory: [], // 鍘嗗彶鏁版嵁锛屼互渚涙挙閿�浣跨敤
@@ -145,230 +134,188 @@
c: null,
ctx: null,
visible: false,
- baseImg: undefined,
+ baseImg: undefined
//showProportion: 1.666
- };
+ }
},
watch: {
loading: {
handler(newVal, oldVal) {
if (newVal) {
- this.baseImg = "";
- this.refresh();
+ this.baseImg = ""
+ this.refresh()
}
},
- deep: true,
+ deep: true
},
canvasDataShow: {
handler(newVal, oldVal) {
// console.log(newVal, "canvasDataShow newVal");
- this.canvasData.line = newVal.line;
- this.canvasData.rect = newVal.rect;
- this.canvasData.arrow = newVal.arrow;
- this.canvasData.polygon = newVal.polygon;
- this.clickSelect(this.canvasData);
+ this.canvasData.line = newVal.line
+ this.canvasData.rect = newVal.rect
+ this.canvasData.arrow = newVal.arrow
+ this.canvasData.polygon = newVal.polygon
+ this.clickSelect(this.canvasData)
},
- deep: true,
- },
+ deep: true
+ }
},
mounted() {
this.$nextTick(() => {
// this.c = document.querySelector("#" + this.divId);
- this.c = this.$refs.myCanvas;
- this.ctx = this.c.getContext("2d");
- this.canvasData = JSON.parse(JSON.stringify(this.canvasDataShow));
- this.clickSelect(this.canvasData);
- });
+ this.c = this.$refs.myCanvas
+ this.ctx = this.c.getContext("2d")
+ this.canvasData = JSON.parse(JSON.stringify(this.canvasDataShow))
+ this.clickSelect(this.canvasData)
+ })
},
methods: {
// 鑾峰彇canvas搴曞浘
async getCanvasPic() {
// this.$emit('changeBaseImg',this.currentCameraId)
- this.$emit("changeLoading", true);
+ this.$emit("changeLoading", true)
if (this.currentCamera.cameraId) {
- let _this = this;
+ let _this = this
+
+ if (_this.currentCamera.type === 1) {
+ await updategb28181({
+ id: _this.currentCamera.cameraId
+ }).then((res) => {
+ if (res.data.cameraId === _this.currentCamera.cameraId) {
+ _this.baseImg = "data:image/png;base64," + res.data.base64
+ _this.$emit("refresh", _this.baseImg, _this.currentCamera.cameraName)
+ _this.$forceUpdate()
+ _this.$notify({
+ type: "success",
+ message: "搴曞浘宸插埛鏂�"
+ })
+ }
+ })
+
+ this.$emit("changeLoading", false)
+
+ return
+ }
await updateSnapshot({
id: _this.currentCamera.cameraId,
name: _this.currentCamera.cameraName,
type: _this.currentCamera.type,
- rtsp: _this.currentCamera.rtsp,
+ rtsp: _this.currentCamera.rtsp
}).then((res) => {
if (res.data.cameraId === _this.currentCamera.cameraId) {
- _this.baseImg = "data:image/png;base64," + res.data.base64;
- _this.$emit(
- "refresh",
- _this.baseImg,
- _this.currentCamera.cameraName
- );
- _this.$forceUpdate();
+ _this.baseImg = "data:image/png;base64," + res.data.base64
+ _this.$emit("refresh", _this.baseImg, _this.currentCamera.cameraName)
+ _this.$forceUpdate()
_this.$notify({
type: "success",
- message: "搴曞浘宸插埛鏂�",
- });
+ message: "搴曞浘宸插埛鏂�"
+ })
}
- });
+ })
- this.$emit("changeLoading", false);
+ this.$emit("changeLoading", false)
}
},
showModal() {
// console.log(this.canvasData, "鐐瑰嚮缁樺埗鐨勬椂鍊欎紶閫掕繃鍘荤殑鏁版嵁");
- this.visible = true;
+ this.visible = true
this.$nextTick(() => {
// this.$refs.bigCanvas.delCursor = {}
- });
+ })
},
cancelFunc() {
- this.visible = false;
- this.$refs.bigCanvas.cancel();
+ this.visible = false
+ this.$refs.bigCanvas.cancel()
// console.log("鍏抽棴浜�");
},
handleOk() {
// 鍒ゆ柇鍥惧舰鐨勫悕瀛楁槸鍚﹂噸澶�
// console.log("ok");
- this.$refs.bigCanvas.changeType("0");
- let repeatName = this.isRepeat();
+ this.$refs.bigCanvas.changeType("0")
+ let repeatName = this.isRepeat()
if (repeatName !== "") {
this.$notify({
type: "error",
- message: repeatName + "鍥惧舰鍚嶇О閲嶅锛岃鏇存锛�",
- });
- return;
+ message: repeatName + "鍥惧舰鍚嶇О閲嶅锛岃鏇存锛�"
+ })
+ return
}
this.$notify({
type: "success",
- message: "宸蹭繚瀛樼粯鍒讹紒",
- });
+ message: "宸蹭繚瀛樼粯鍒讹紒"
+ })
// 姣忔淇濆瓨鍏抽棴妯℃�佺獥鏃堕兘瑕佹妸妯℃�佺獥鐨勬暟鎹啓鍒扮埗缁勪欢閲屾潵
- this.canvasData = this.$refs.bigCanvas.canvasData;
+ this.canvasData = this.$refs.bigCanvas.canvasData
// 椤轰究鐢╁埌鏇村灞傚幓
- this.$emit("fromCanvas", this.$refs.bigCanvas.canvasData);
+ this.$emit("fromCanvas", this.$refs.bigCanvas.canvasData)
// console.log("浣犲ソ", this.canvasData);
- this.clickSelect(this.canvasData);
- this.visible = false;
+ this.clickSelect(this.canvasData)
+ this.visible = false
},
// 鍥炴樉cavas鏁版嵁
// 鐐瑰嚮閫変腑鍙樿壊 灏嗗綋鍓嶉〉闈㈡墍鏈夎矾寰勯噸缁樺垽鏂綋鍓嶉紶鏍囩殑鍧愭爣鍦ㄥ摢涓浘褰㈠唴 濡傛灉涓嶄紶鍧愭爣鍙傛暟灏辨槸鍥炴樉鐨勬柟娉�
clickSelect(e) {
- this.ctx.clearRect(0, 0, this.c.width, this.c.height);
- let _this = this; // 闆嗗悎涓亶鍘嗛渶瑕佸皢this杞瓨涓�涓嬩娇鐢�
- _this.canvasData.line.forEach(function (v, i) {
- _this.ctx.strokeStyle = "yellow";
- _this.ctx.beginPath();
- _this.ctx.moveTo(
- v.location[0].x / _this.showProportion,
- v.location[0].y / _this.showProportion
- );
- _this.ctx.lineTo(
- v.location[1].x / _this.showProportion,
- v.location[1].y / _this.showProportion
- );
- _this.ctx.stroke();
- _this.showRemarks(
- v.location[0].x / _this.showProportion,
- v.location[0].y / _this.showProportion,
- v.name
- );
- _this.c.style.cursor = "default";
+ this.ctx.clearRect(0, 0, this.c.width, this.c.height)
+ let _this = this // 闆嗗悎涓亶鍘嗛渶瑕佸皢this杞瓨涓�涓嬩娇鐢�
+ _this.canvasData.line.forEach(function(v, i) {
+ _this.ctx.strokeStyle = "yellow"
+ _this.ctx.beginPath()
+ _this.ctx.moveTo(v.location[0].x / _this.showProportion, v.location[0].y / _this.showProportion)
+ _this.ctx.lineTo(v.location[1].x / _this.showProportion, v.location[1].y / _this.showProportion)
+ _this.ctx.stroke()
+ _this.showRemarks(v.location[0].x / _this.showProportion, v.location[0].y / _this.showProportion, v.name)
+ _this.c.style.cursor = "default"
if (e && _this.ctx.isPointInStroke(e.offsetX, e.offsetY)) {
// 濡傛灉浼犲叆浜嗕簨浠跺潗鏍囷紝灏辩敤isPointInStroke鍒ゆ柇涓�涓�
// 濡傛灉褰撳墠鐜瑕嗙洊浜嗚鍧愭爣锛屽氨灏嗗浘褰㈢殑index鏀惧埌鏁扮粍閲�
// 褰撻紶鏍囩Щ鍏ヤ箣鍚庡皢褰撳墠鐨勬ā寮忓垏鎹负閫変腑妯″紡
- _this.type = "0";
- _this.delCursor.type = "1";
- _this.delCursor.index = i;
+ _this.type = "0"
+ _this.delCursor.type = "1"
+ _this.delCursor.index = i
// 灏嗗綋鍓嶅厓绱犳爣绾�
- _this.ctx.strokeStyle = "red";
- _this.ctx.beginPath();
- _this.ctx.moveTo(
- v.location[0].x / _this.showProportion,
- v.location[0].y / _this.showProportion
- );
- _this.ctx.lineTo(
- v.location[1].x / _this.showProportion,
- v.location[1].y / _this.showProportion
- );
- _this.ctx.stroke();
- _this.showRemarks(
- v.location[0].x / _this.showProportion,
- v.location[0].y / _this.showProportion,
- v.name
- );
- _this.c.style.cursor = "pointer";
+ _this.ctx.strokeStyle = "red"
+ _this.ctx.beginPath()
+ _this.ctx.moveTo(v.location[0].x / _this.showProportion, v.location[0].y / _this.showProportion)
+ _this.ctx.lineTo(v.location[1].x / _this.showProportion, v.location[1].y / _this.showProportion)
+ _this.ctx.stroke()
+ _this.showRemarks(v.location[0].x / _this.showProportion, v.location[0].y / _this.showProportion, v.name)
+ _this.c.style.cursor = "pointer"
}
- });
- _this.canvasData.rect.forEach(function (v, i) {
- _this.ctx.strokeStyle = "yellow";
- _this.ctx.beginPath();
- _this.ctx.moveTo(
- v.location[0].x / _this.showProportion,
- v.location[0].y / _this.showProportion
- );
- _this.ctx.lineTo(
- v.location[1].x / _this.showProportion,
- v.location[1].y / _this.showProportion
- );
- _this.ctx.lineTo(
- v.location[2].x / _this.showProportion,
- v.location[2].y / _this.showProportion
- );
- _this.ctx.lineTo(
- v.location[3].x / _this.showProportion,
- v.location[3].y / _this.showProportion
- );
- _this.ctx.lineTo(
- v.location[0].x / _this.showProportion,
- v.location[0].y / _this.showProportion
- );
- _this.ctx.stroke();
- _this.showRemarks(
- v.location[0].x / _this.showProportion,
- v.location[0].y / _this.showProportion,
- v.name
- );
- _this.c.style.cursor = "default";
+ })
+ _this.canvasData.rect.forEach(function(v, i) {
+ _this.ctx.strokeStyle = "yellow"
+ _this.ctx.beginPath()
+ _this.ctx.moveTo(v.location[0].x / _this.showProportion, v.location[0].y / _this.showProportion)
+ _this.ctx.lineTo(v.location[1].x / _this.showProportion, v.location[1].y / _this.showProportion)
+ _this.ctx.lineTo(v.location[2].x / _this.showProportion, v.location[2].y / _this.showProportion)
+ _this.ctx.lineTo(v.location[3].x / _this.showProportion, v.location[3].y / _this.showProportion)
+ _this.ctx.lineTo(v.location[0].x / _this.showProportion, v.location[0].y / _this.showProportion)
+ _this.ctx.stroke()
+ _this.showRemarks(v.location[0].x / _this.showProportion, v.location[0].y / _this.showProportion, v.name)
+ _this.c.style.cursor = "default"
if (e && _this.ctx.isPointInPath(e.offsetX, e.offsetY)) {
// 濡傛灉浼犲叆浜嗕簨浠跺潗鏍囷紝灏辩敤isPointInStroke鍒ゆ柇涓�涓�
// 褰撻紶鏍囩Щ鍏ヤ箣鍚庡皢褰撳墠鐨勬ā寮忓垏鎹负閫変腑妯″紡
- _this.type = "0";
- _this.delCursor.type = "2";
- _this.delCursor.index = i;
+ _this.type = "0"
+ _this.delCursor.type = "2"
+ _this.delCursor.index = i
// 灏嗗綋鍓嶅厓绱犳爣绾�
- _this.ctx.strokeStyle = "red";
- _this.ctx.beginPath();
- _this.ctx.moveTo(
- v.location[0].x / _this.showProportion,
- v.location[0].y / _this.showProportion
- );
- _this.ctx.lineTo(
- v.location[1].x / _this.showProportion,
- v.location[1].y / _this.showProportion
- );
- _this.ctx.lineTo(
- v.location[2].x / _this.showProportion,
- v.location[2].y / _this.showProportion
- );
- _this.ctx.lineTo(
- v.location[3].x / _this.showProportion,
- v.location[3].y / _this.showProportion
- );
- _this.ctx.lineTo(
- v.location[0].x / _this.showProportion,
- v.location[0].y / _this.showProportion
- );
- _this.ctx.stroke();
- _this.showRemarks(
- v.location[0].x / _this.showProportion,
- v.location[0].y / _this.showProportion,
- v.name
- );
- _this.c.style.cursor = "pointer";
+ _this.ctx.strokeStyle = "red"
+ _this.ctx.beginPath()
+ _this.ctx.moveTo(v.location[0].x / _this.showProportion, v.location[0].y / _this.showProportion)
+ _this.ctx.lineTo(v.location[1].x / _this.showProportion, v.location[1].y / _this.showProportion)
+ _this.ctx.lineTo(v.location[2].x / _this.showProportion, v.location[2].y / _this.showProportion)
+ _this.ctx.lineTo(v.location[3].x / _this.showProportion, v.location[3].y / _this.showProportion)
+ _this.ctx.lineTo(v.location[0].x / _this.showProportion, v.location[0].y / _this.showProportion)
+ _this.ctx.stroke()
+ _this.showRemarks(v.location[0].x / _this.showProportion, v.location[0].y / _this.showProportion, v.name)
+ _this.c.style.cursor = "pointer"
}
- });
- _this.canvasData.arrow.forEach(function (v, i) {
- _this.ctx.strokeStyle = "yellow";
+ })
+ _this.canvasData.arrow.forEach(function(v, i) {
+ _this.ctx.strokeStyle = "yellow"
// _this.ctx.beginPath()
// _this.ctx.moveTo(v.location[0].x / 2, v.location[0].y / 2)
// _this.ctx.lineTo(v.location[1].x / 2, v.location[1].y / 2)
@@ -382,22 +329,18 @@
20,
30,
"yellow"
- ); // 缁樺埗鏂规硶
- _this.showRemarks(
- v.location[0].x / _this.showProportion,
- v.location[0].y / _this.showProportion,
- v.name
- );
- _this.c.style.cursor = "default";
+ ) // 缁樺埗鏂规硶
+ _this.showRemarks(v.location[0].x / _this.showProportion, v.location[0].y / _this.showProportion, v.name)
+ _this.c.style.cursor = "default"
if (e && _this.ctx.isPointInStroke(e.offsetX, e.offsetY)) {
// 濡傛灉浼犲叆浜嗕簨浠跺潗鏍囷紝灏辩敤isPointInStroke鍒ゆ柇涓�涓�
// 濡傛灉褰撳墠鐜瑕嗙洊浜嗚鍧愭爣锛屽氨灏嗗浘褰㈢殑index鏀惧埌鏁扮粍閲�
// 褰撻紶鏍囩Щ鍏ヤ箣鍚庡皢褰撳墠鐨勬ā寮忓垏鎹负閫変腑妯″紡
- _this.type = "0";
- _this.delCursor.type = "4";
- _this.delCursor.index = i;
+ _this.type = "0"
+ _this.delCursor.type = "4"
+ _this.delCursor.index = i
// 灏嗗綋鍓嶅厓绱犳爣绾�
- _this.ctx.strokeStyle = "red";
+ _this.ctx.strokeStyle = "red"
// _this.ctx.beginPath()
// _this.ctx.moveTo(v.location[0].x / _this.showProportion, v.location[0].y / _this.showProportion)
// _this.ctx.lineTo(v.location[1].x / _this.showProportion, v.location[1].y / _this.showProportion)
@@ -411,78 +354,62 @@
20,
30,
"red"
- ); // 缁樺埗鏂规硶
- _this.showRemarks(
- v.location[0].x / _this.showProportion,
- v.location[0].y / _this.showProportion,
- v.name
- );
- _this.c.style.cursor = "pointer";
+ ) // 缁樺埗鏂规硶
+ _this.showRemarks(v.location[0].x / _this.showProportion, v.location[0].y / _this.showProportion, v.name)
+ _this.c.style.cursor = "pointer"
}
- });
- _this.canvasData.polygon.forEach(function (v, i) {
+ })
+ _this.canvasData.polygon.forEach(function(v, i) {
if (v.location.length === 0) {
- return;
+ return
}
- _this.ctx.strokeStyle = "yellow";
- _this.ctx.beginPath();
- _this.ctx.moveTo(
- v.location[0].x / _this.showProportion,
- v.location[0].y / _this.showProportion
- );
+ _this.ctx.strokeStyle = "yellow"
+ _this.ctx.beginPath()
+ _this.ctx.moveTo(v.location[0].x / _this.showProportion, v.location[0].y / _this.showProportion)
for (let i = 1; i < v.location.length; i++) {
- _this.ctx.lineTo(
- v.location[i].x / _this.showProportion,
- v.location[i].y / _this.showProportion
- );
+ _this.ctx.lineTo(v.location[i].x / _this.showProportion, v.location[i].y / _this.showProportion)
}
- _this.ctx.closePath();
- _this.ctx.stroke();
+ _this.ctx.closePath()
+ _this.ctx.stroke()
_this.showRemarks(
v.location[v.location.length - 1].x / _this.showProportion,
v.location[v.location.length - 1].y / _this.showProportion,
v.name
- );
- _this.c.style.cursor = "default";
+ )
+ _this.c.style.cursor = "default"
if (e && _this.ctx.isPointInPath(e.offsetX, e.offsetY)) {
// 濡傛灉浼犲叆浜嗕簨浠跺潗鏍囷紝灏辩敤isPointInStroke鍒ゆ柇涓�涓�
// 濡傛灉褰撳墠鐜瑕嗙洊浜嗚鍧愭爣锛屽氨灏嗗浘褰㈢殑index鏀惧埌鏁扮粍閲�
// 褰撻紶鏍囩Щ鍏ヤ箣鍚庡皢褰撳墠鐨勬ā寮忓垏鎹负閫変腑妯″紡
- _this.type = "0";
- _this.delCursor.type = "5";
- _this.delCursor.index = i;
+ _this.type = "0"
+ _this.delCursor.type = "5"
+ _this.delCursor.index = i
// 灏嗗綋鍓嶅厓绱犳爣绾�
- _this.ctx.strokeStyle = "red";
- _this.ctx.beginPath();
- _this.ctx.moveTo(
- v.location[0].x / _this.showProportion,
- v.location[0].y / _this.showProportion
- );
+ _this.ctx.strokeStyle = "red"
+ _this.ctx.beginPath()
+ _this.ctx.moveTo(v.location[0].x / _this.showProportion, v.location[0].y / _this.showProportion)
for (let i = 1; i < v.location.length; i++) {
- _this.ctx.lineTo(
- v.location[i].x / _this.showProportion,
- v.location[i].y / _this.showProportion
- );
+ _this.ctx.lineTo(v.location[i].x / _this.showProportion, v.location[i].y / _this.showProportion)
}
- _this.ctx.closePath();
- _this.ctx.stroke();
+ _this.ctx.closePath()
+ _this.ctx.stroke()
_this.showRemarks(
v.location[v.location.length - 1].x / _this.showProportion,
v.location[v.location.length - 1].y / _this.showProportion,
v.name
- );
- _this.c.style.cursor = "pointer";
+ )
+ _this.c.style.cursor = "pointer"
}
- });
+ })
},
// 鍥炴樉鍥惧舰澶囨敞
showRemarks(x, y, remarks) {
- this.ctx.moveTo(x, y - 10); // 鍥犱负鏀惧ぇ涔嬪悗鏄痽-20锛屾墍浠ョ缉灏忕増鐨勪负y-10
- this.ctx.fillStyle = "green"; // 璁剧疆濉厖棰滆壊涓虹豢鑹�
- this.ctx.font = '10px "寰蒋闆呴粦"'; // 璁剧疆瀛椾綋
- this.ctx.textBaseline = "bottom"; // 璁剧疆瀛椾綋搴曠嚎瀵归綈缁樺埗鍩虹嚎
- this.ctx.textAlign = "left"; // 璁剧疆瀛椾綋瀵归綈鐨勬柟寮�
- this.ctx.fillText(remarks, x, y - 10); // 濉厖鏂囧瓧
+ this.ctx.moveTo(x, y - 10) // 鍥犱负鏀惧ぇ涔嬪悗鏄痽-20锛屾墍浠ョ缉灏忕増鐨勪负y-10
+ this.ctx.fillStyle = "green" // 璁剧疆濉厖棰滆壊涓虹豢鑹�
+ this.ctx.font = '10px "寰蒋闆呴粦"' // 璁剧疆瀛椾綋
+ this.ctx.textBaseline = "bottom" // 璁剧疆瀛椾綋搴曠嚎瀵归綈缁樺埗鍩虹嚎
+ this.ctx.textAlign = "left" // 璁剧疆瀛椾綋瀵归綈鐨勬柟寮�
+ this.ctx.fillText(remarks, x, y - 10) // 濉厖鏂囧瓧
},
// 绠ご缁樺埗鍑芥暟
drawArrow(ctx, fromX, fromY, toX, toY, theta, headlen, width, color) {
@@ -493,87 +420,87 @@
// headlen锛氫笁瑙掓枩杈归暱搴�
// width锛氱澶寸嚎瀹藉害
// color锛氱澶撮鑹�
- theta = typeof theta !== "undefined" ? theta : 30;
- headlen = typeof theta !== "undefined" ? headlen : 10;
- width = typeof width !== "undefined" ? width : 1;
- color = typeof color !== "undefined" ? color : "yellow";
+ theta = typeof theta !== "undefined" ? theta : 30
+ headlen = typeof theta !== "undefined" ? headlen : 10
+ width = typeof width !== "undefined" ? width : 1
+ color = typeof color !== "undefined" ? color : "yellow"
// 璁$畻鍚勮搴﹀拰瀵瑰簲鐨凱2,P3鍧愭爣
- let angle = (Math.atan2(fromY - toY, fromX - toX) * 180) / Math.PI;
- let angle1 = ((angle + theta) * Math.PI) / 180;
- let angle2 = ((angle - theta) * Math.PI) / 180;
- let topX = headlen * Math.cos(angle1);
- let topY = headlen * Math.sin(angle1);
- let botX = headlen * Math.cos(angle2);
- let botY = headlen * Math.sin(angle2);
+ let angle = (Math.atan2(fromY - toY, fromX - toX) * 180) / Math.PI
+ let angle1 = ((angle + theta) * Math.PI) / 180
+ let angle2 = ((angle - theta) * Math.PI) / 180
+ let topX = headlen * Math.cos(angle1)
+ let topY = headlen * Math.sin(angle1)
+ let botX = headlen * Math.cos(angle2)
+ let botY = headlen * Math.sin(angle2)
- ctx.save();
- ctx.beginPath();
- let arrowX = fromX - topX;
- let arrowY = fromY - topY;
- ctx.moveTo(arrowX, arrowY);
- ctx.moveTo(fromX, fromY);
- ctx.lineTo(toX, toY);
- arrowX = toX + topX;
- arrowY = toY + topY;
- ctx.moveTo(arrowX, arrowY);
- ctx.lineTo(toX, toY);
- arrowX = toX + botX;
- arrowY = toY + botY;
- ctx.lineTo(arrowX, arrowY);
- ctx.strokeStyle = color;
- ctx.lineWidth = width;
- ctx.stroke();
- ctx.restore();
+ ctx.save()
+ ctx.beginPath()
+ let arrowX = fromX - topX
+ let arrowY = fromY - topY
+ ctx.moveTo(arrowX, arrowY)
+ ctx.moveTo(fromX, fromY)
+ ctx.lineTo(toX, toY)
+ arrowX = toX + topX
+ arrowY = toY + topY
+ ctx.moveTo(arrowX, arrowY)
+ ctx.lineTo(toX, toY)
+ arrowX = toX + botX
+ arrowY = toY + botY
+ ctx.lineTo(arrowX, arrowY)
+ ctx.strokeStyle = color
+ ctx.lineWidth = width
+ ctx.stroke()
+ ctx.restore()
},
async refresh() {
- console.log("鍒锋柊搴曞浘");
+ console.log("鍒锋柊搴曞浘")
if (!this.currentCamera.cameraId) {
- console.log("娌″埛鏂�");
- return false;
+ console.log("娌″埛鏂�")
+ return false
}
// await this.$emit('changeLoading', true)
- this.getCanvasPic();
+ this.getCanvasPic()
},
// 鍒ゆ柇鍥惧舰鍚嶇О鏄惁閲嶅
isRepeat() {
- let _this = this; // 闆嗗悎涓亶鍘嗛渶瑕佸皢this杞瓨涓�涓嬩娇鐢�
- let nameArray = [];
+ let _this = this // 闆嗗悎涓亶鍘嗛渶瑕佸皢this杞瓨涓�涓嬩娇鐢�
+ let nameArray = []
for (const v of _this.$refs.bigCanvas.canvasData.line) {
for (const item of nameArray) {
if (v.name === item) {
- return v.name;
+ return v.name
}
}
- nameArray.push(v.name);
+ nameArray.push(v.name)
}
for (const v of _this.$refs.bigCanvas.canvasData.arrow) {
for (const item of nameArray) {
if (v.name === item) {
- return v.name;
+ return v.name
}
}
- nameArray.push(v.name);
+ nameArray.push(v.name)
}
for (const v of _this.$refs.bigCanvas.canvasData.rect) {
for (const item of nameArray) {
if (v.name === item) {
- return v.name;
+ return v.name
}
}
- nameArray.push(v.name);
+ nameArray.push(v.name)
}
for (const v of _this.$refs.bigCanvas.canvasData.polygon) {
for (const item of nameArray) {
if (v.name === item) {
- return v.name;
+ return v.name
}
}
- nameArray.push(v.name);
+ nameArray.push(v.name)
}
- return "";
- },
- },
-};
+ return ""
+ }
+ }
+}
</script>
<style lang="scss" scoped>
canvas {
--
Gitblit v1.8.0