|
@@ -33,7 +33,6 @@
|
|
|
<button @click="removeItem(item)" class="">
|
|
<button @click="removeItem(item)" class="">
|
|
|
<i class="fa fa-trash"></i> 删除
|
|
<i class="fa fa-trash"></i> 删除
|
|
|
</button>
|
|
</button>
|
|
|
- {{ item.syncStatus == 1 ? "已同步" : "未同步" }}
|
|
|
|
|
</div>
|
|
</div>
|
|
|
</div>
|
|
</div>
|
|
|
</div>
|
|
</div>
|
|
@@ -41,13 +40,13 @@
|
|
|
<div class="info-group">
|
|
<div class="info-group">
|
|
|
<h3 class="setting-title">操作</h3>
|
|
<h3 class="setting-title">操作</h3>
|
|
|
<div class="actions">
|
|
<div class="actions">
|
|
|
- <button @click="finishCurrentPolygon" class="action-btn primary-btn" :disabled="taskId == null || pointId == null">
|
|
|
|
|
|
|
+ <button @click="finishCurrentPolygon" class="action-btn primary-btn" :disabled="pointId == null || pointId == ''">
|
|
|
<i class="fa fa-check"></i> 完成当前多边形
|
|
<i class="fa fa-check"></i> 完成当前多边形
|
|
|
</button>
|
|
</button>
|
|
|
- <button @click="clearCanvas" class="action-btn danger-btn" :disabled="taskId == null || pointId == null">
|
|
|
|
|
|
|
+ <button @click="clearCanvas" class="action-btn danger-btn" :disabled="pointId == null || pointId == ''">
|
|
|
<i class="fa fa-trash"></i> 清空画布
|
|
<i class="fa fa-trash"></i> 清空画布
|
|
|
</button>
|
|
</button>
|
|
|
- <button @click="savePolygons" class="action-btn secondary-btn" :disabled="taskId == null || pointId == null">
|
|
|
|
|
|
|
+ <button @click="savePolygons" class="action-btn secondary-btn" :disabled="pointId == null || pointId == ''">
|
|
|
<i class="fa fa-download"></i> 保存多边形
|
|
<i class="fa fa-download"></i> 保存多边形
|
|
|
</button>
|
|
</button>
|
|
|
</div>
|
|
</div>
|
|
@@ -63,43 +62,19 @@
|
|
|
</div>
|
|
</div>
|
|
|
|
|
|
|
|
<div>
|
|
<div>
|
|
|
- <!-- 中间内容部分 -->
|
|
|
|
|
- <div class="container" style="z-index: 1;display: none">
|
|
|
|
|
- <div class="real-container">
|
|
|
|
|
- <div class="has-success">
|
|
|
|
|
- <label class="form-label mt-4" for="real-rtsp">请输入实时预览 rtsp 地址: </label>
|
|
|
|
|
- <input id="real-rtsp" value="rtsp://10.10.10.10:9100/dss/monitor/param/cameraid=1000000%240%26substream=1?token=1" type="text" class="form-control">
|
|
|
|
|
- <button type="button" @click="playReal" class="btn btn-outline-primary" id="real-btn">实时预览</button>
|
|
|
|
|
- </div>
|
|
|
|
|
|
|
+ <!-- 中间内容部分 -->
|
|
|
|
|
+ <div class="container" style="z-index: 1;display: none">
|
|
|
|
|
+ <div class="real-container">
|
|
|
|
|
+ <div class="has-success">
|
|
|
|
|
+ <label class="form-label mt-4" for="real-rtsp">请输入实时预览 rtsp 地址: </label>
|
|
|
|
|
+ <input id="real-rtsp" value="rtsp://10.10.10.10:9100/dss/monitor/param/cameraid=1000000%240%26substream=1?token=1" type="text" class="form-control">
|
|
|
|
|
+ <button type="button" @click="playReal" class="btn btn-outline-primary" id="real-btn">实时预览</button>
|
|
|
</div>
|
|
</div>
|
|
|
</div>
|
|
</div>
|
|
|
|
|
+ </div>
|
|
|
|
|
|
|
|
- <!-- 画布区域 -->
|
|
|
|
|
- <div class="canvas-section">
|
|
|
|
|
- <div id="ws-real-player" class="preview-container" ref="previewContainer"></div>
|
|
|
|
|
- <div id="canvas-container" class="canvas-container" ref="canvasContainer">
|
|
|
|
|
- <canvas
|
|
|
|
|
- ref="polygonCanvas"
|
|
|
|
|
- @click="handleCanvasClick"
|
|
|
|
|
- @dblclick="handleCanvasDblClick"
|
|
|
|
|
- @mousemove="handleMouseMove"
|
|
|
|
|
- @mouseenter="handleMouseEnter"
|
|
|
|
|
- @mouseleave="handleMouseLeave"
|
|
|
|
|
- class="polygon-canvas"
|
|
|
|
|
- ></canvas>
|
|
|
|
|
- <!-- <div class="canvas-info" :class="{ 'highlight': highlightInfo }">
|
|
|
|
|
- {{ canvasInfo }}
|
|
|
|
|
- </div> -->
|
|
|
|
|
- </div>
|
|
|
|
|
-
|
|
|
|
|
- <!-- <div class="polygon-info">
|
|
|
|
|
- <h3 class="info-title">多边形信息</h3>
|
|
|
|
|
- <div class="info-text">
|
|
|
|
|
- 已绘制: <span class="polygon-count">{{ polygons.length }}</span> 个多边形
|
|
|
|
|
- </div>
|
|
|
|
|
- </div> -->
|
|
|
|
|
- </div>
|
|
|
|
|
-
|
|
|
|
|
|
|
+ <!-- 画布区域 -->
|
|
|
|
|
+ <div id="ws-real-player" class="preview-container" ref="previewContainer"></div>
|
|
|
</div>
|
|
</div>
|
|
|
</div>
|
|
</div>
|
|
|
</template>
|
|
</template>
|
|
@@ -114,7 +89,7 @@ export default {
|
|
|
props: {
|
|
props: {
|
|
|
url: {
|
|
url: {
|
|
|
type: String,
|
|
type: String,
|
|
|
- default: null,
|
|
|
|
|
|
|
+ default: "",
|
|
|
},
|
|
},
|
|
|
channelId: {
|
|
channelId: {
|
|
|
type: String,
|
|
type: String,
|
|
@@ -136,13 +111,15 @@ export default {
|
|
|
type: String,
|
|
type: String,
|
|
|
default: null,
|
|
default: null,
|
|
|
},
|
|
},
|
|
|
- tasks: {
|
|
|
|
|
- type: Array,
|
|
|
|
|
- default: [],
|
|
|
|
|
|
|
+ info: {
|
|
|
|
|
+ type: String,
|
|
|
|
|
+ default: null,
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
data() {
|
|
data() {
|
|
|
return {
|
|
return {
|
|
|
|
|
+ canvasElem: null,
|
|
|
|
|
+ canvasContext: null,
|
|
|
realPlayer: null,
|
|
realPlayer: null,
|
|
|
|
|
|
|
|
// 多边形数据
|
|
// 多边形数据
|
|
@@ -176,15 +153,15 @@ export default {
|
|
|
this.initCanvas()
|
|
this.initCanvas()
|
|
|
|
|
|
|
|
// 初始化预览容器大小
|
|
// 初始化预览容器大小
|
|
|
- this.resizePreviewContainer()
|
|
|
|
|
|
|
+ // this.resizePreviewContainer()
|
|
|
|
|
|
|
|
// 监听窗口大小变化
|
|
// 监听窗口大小变化
|
|
|
- window.addEventListener('resize', this.resizePreviewContainer)
|
|
|
|
|
- },
|
|
|
|
|
- beforeUnmount() {
|
|
|
|
|
- // 移除事件监听器
|
|
|
|
|
- window.removeEventListener('resize', this.resizePreviewContainer)
|
|
|
|
|
|
|
+ // window.addEventListener('resize', this.resizePreviewContainer)
|
|
|
},
|
|
},
|
|
|
|
|
+ // beforeUnmount() {
|
|
|
|
|
+ // // 移除事件监听器
|
|
|
|
|
+ // window.removeEventListener('resize', this.resizePreviewContainer)
|
|
|
|
|
+ // },
|
|
|
methods: {
|
|
methods: {
|
|
|
initRealPlayer() {
|
|
initRealPlayer() {
|
|
|
|
|
|
|
@@ -202,10 +179,7 @@ export default {
|
|
|
switch(methods) {
|
|
switch(methods) {
|
|
|
case 'initializationCompleted':
|
|
case 'initializationCompleted':
|
|
|
console.log('初始化完成')
|
|
console.log('初始化完成')
|
|
|
- that.realPlayer.setPlayerAdapter("stretching")
|
|
|
|
|
- // 初始化完成,可调用播放方法(适用于动态加载解码库)
|
|
|
|
|
- // 若回调未触发时就使用实时预览/录像回放,则无法播放。
|
|
|
|
|
- // 此时我们可以调用一个
|
|
|
|
|
|
|
+ this.initCanvas();
|
|
|
break;
|
|
break;
|
|
|
case "changeStreamType": // 主/辅码流切换回调
|
|
case "changeStreamType": // 主/辅码流切换回调
|
|
|
console.log(data.channelData) // 通道数据
|
|
console.log(data.channelData) // 通道数据
|
|
@@ -247,9 +221,9 @@ export default {
|
|
|
}
|
|
}
|
|
|
})
|
|
})
|
|
|
},
|
|
},
|
|
|
- getDom(selector) {
|
|
|
|
|
- return document.querySelector(selector)
|
|
|
|
|
- },
|
|
|
|
|
|
|
+ // getDom(selector) {
|
|
|
|
|
+ // return document.querySelector(selector)
|
|
|
|
|
+ // },
|
|
|
playReal(url) {
|
|
playReal(url) {
|
|
|
let that = this
|
|
let that = this
|
|
|
let wsURL = that.url
|
|
let wsURL = that.url
|
|
@@ -257,24 +231,24 @@ export default {
|
|
|
let streamType = 1
|
|
let streamType = 1
|
|
|
let channelId = that.channelId
|
|
let channelId = that.channelId
|
|
|
that.realPlayer.realByUrl({
|
|
that.realPlayer.realByUrl({
|
|
|
- rtspURL, // 必传
|
|
|
|
|
- wsURL, // 必传
|
|
|
|
|
- selectIndex: 0, // 必传, 播放窗口号
|
|
|
|
|
- channelId, // 必传, 通道id
|
|
|
|
|
- streamType, // 必传, 码流类型,
|
|
|
|
|
- playerAdapter: 'stretching', // 选传, selfAdaption 自适应 | stretching 拉伸
|
|
|
|
|
- channelData: { // 建议传, 通道树信息
|
|
|
|
|
- // id: channelCode, // {String} 通道编码
|
|
|
|
|
- // deviceCode: deviceCode, // {String} 设备编码
|
|
|
|
|
- // deviceType: deviceType, // {String} 设备类型
|
|
|
|
|
- // channelSeq: channelSeq, // {String|Number} 通道序号
|
|
|
|
|
- }, // 选传
|
|
|
|
|
|
|
+ rtspURL, // 必传
|
|
|
|
|
+ wsURL, // 必传
|
|
|
|
|
+ selectIndex: 0, // 必传, 播放窗口号
|
|
|
|
|
+ channelId, // 必传, 通道id
|
|
|
|
|
+ streamType, // 必传, 码流类型,
|
|
|
|
|
+ playerAdapter: 'stretching', // 选传, selfAdaption 自适应 | stretching 拉伸
|
|
|
|
|
+ channelData: { // 建议传, 通道树信息
|
|
|
|
|
+ // id: channelCode, // {String} 通道编码
|
|
|
|
|
+ // deviceCode: deviceCode, // {String} 设备编码
|
|
|
|
|
+ // deviceType: deviceType, // {String} 设备类型
|
|
|
|
|
+ // channelSeq: channelSeq, // {String|Number} 通道序号
|
|
|
|
|
+ }, // 选传
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
- let myDiv = that.getDom('.player-control');
|
|
|
|
|
- that.$nextTick(() => {
|
|
|
|
|
- myDiv.classList.add('hidden');
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ // let myDiv = that.getDom('.player-control');
|
|
|
|
|
+ // that.$nextTick(() => {
|
|
|
|
|
+ // myDiv.classList.add('hidden');
|
|
|
|
|
+ // });
|
|
|
},
|
|
},
|
|
|
// 初始化画布
|
|
// 初始化画布
|
|
|
initCanvas() {
|
|
initCanvas() {
|
|
@@ -283,52 +257,60 @@ export default {
|
|
|
},
|
|
},
|
|
|
// 调整画布大小
|
|
// 调整画布大小
|
|
|
resizeCanvas() {
|
|
resizeCanvas() {
|
|
|
- const container = this.$refs.canvasContainer
|
|
|
|
|
|
|
+ // const container = this.$refs.canvasContainer
|
|
|
const previewContainer = this.$refs.previewContainer
|
|
const previewContainer = this.$refs.previewContainer
|
|
|
- const canvas = this.$refs.polygonCanvas
|
|
|
|
|
-
|
|
|
|
|
- if (container && previewContainer && canvas) {
|
|
|
|
|
- // 确保两个容器大小一致
|
|
|
|
|
- const width = previewContainer.clientWidth
|
|
|
|
|
- const height = previewContainer.clientHeight
|
|
|
|
|
-
|
|
|
|
|
- // 设置canvas容器大小
|
|
|
|
|
- container.style.width = `${width}px`
|
|
|
|
|
- container.style.height = `${height}px`
|
|
|
|
|
-
|
|
|
|
|
- // 设置画布尺寸以匹配显示尺寸
|
|
|
|
|
- canvas.width = width
|
|
|
|
|
- canvas.height = height
|
|
|
|
|
-
|
|
|
|
|
- // 重绘所有多边形
|
|
|
|
|
- this.redrawAllPolygons()
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ // const canvas = this.$refs.polygonCanvas
|
|
|
|
|
+ this.canvasElem = previewContainer.querySelector('#ws-real-player-0-pzt-livecanvas');
|
|
|
|
|
+ this.canvasElem.style.display = 'block';
|
|
|
|
|
+
|
|
|
|
|
+ this.canvasElem.addEventListener('click', this.handleCanvasClick);
|
|
|
|
|
+ this.canvasElem.addEventListener('dblclick', this.handleCanvasDblClick);
|
|
|
|
|
+ this.canvasElem.addEventListener('mousemove', this.handleMouseMove);
|
|
|
|
|
+ this.canvasElem.addEventListener('mouseenter', this.handleMouseEnter);
|
|
|
|
|
+ this.canvasElem.addEventListener('mouseleave', this.handleMouseLeave);
|
|
|
|
|
+
|
|
|
|
|
+ // if (container && previewContainer && canvas) {
|
|
|
|
|
+ // // 确保两个容器大小一致
|
|
|
|
|
+ // const width = previewContainer.clientWidth
|
|
|
|
|
+ // const height = previewContainer.clientHeight
|
|
|
|
|
+ //
|
|
|
|
|
+ // // 设置canvas容器大小
|
|
|
|
|
+ // container.style.width = `${width}px`
|
|
|
|
|
+ // container.style.height = `${height}px`
|
|
|
|
|
+ //
|
|
|
|
|
+ // // 设置画布尺寸以匹配显示尺寸
|
|
|
|
|
+ // canvas.width = width
|
|
|
|
|
+ // canvas.height = height
|
|
|
|
|
+ //
|
|
|
|
|
+ // // 重绘所有多边形
|
|
|
|
|
+ // this.redrawAllPolygons()
|
|
|
|
|
+ // }
|
|
|
},
|
|
},
|
|
|
// 调整预览窗口大小
|
|
// 调整预览窗口大小
|
|
|
- resizePreviewContainer() {
|
|
|
|
|
- const container = this.$refs.canvasContainer
|
|
|
|
|
- const previewContainer = this.$refs.previewContainer
|
|
|
|
|
-
|
|
|
|
|
- if (container && previewContainer) {
|
|
|
|
|
- // 获取父容器的尺寸
|
|
|
|
|
- const parent = this.$refs.canvasContainer.parentElement
|
|
|
|
|
- const parentWidth = parent.clientWidth
|
|
|
|
|
-
|
|
|
|
|
- // 设置预览容器大小
|
|
|
|
|
- previewContainer.style.width = `${parentWidth}px`
|
|
|
|
|
- // 设置一个合适的高度,比如宽高比16:9
|
|
|
|
|
- const height = Math.floor(parentWidth * 9 / 16)
|
|
|
|
|
- previewContainer.style.height = `${height}px`
|
|
|
|
|
-
|
|
|
|
|
- // 调整画布大小以匹配
|
|
|
|
|
- this.resizeCanvas()
|
|
|
|
|
- }
|
|
|
|
|
- },
|
|
|
|
|
|
|
+ // resizePreviewContainer() {
|
|
|
|
|
+ // const container = this.$refs.canvasContainer
|
|
|
|
|
+ // const previewContainer = this.$refs.previewContainer
|
|
|
|
|
+ //
|
|
|
|
|
+ // if (container && previewContainer) {
|
|
|
|
|
+ // // 获取父容器的尺寸
|
|
|
|
|
+ // const parent = this.$refs.canvasContainer.parentElement
|
|
|
|
|
+ // const parentWidth = parent.clientWidth
|
|
|
|
|
+ //
|
|
|
|
|
+ // // 设置预览容器大小
|
|
|
|
|
+ // previewContainer.style.width = `${parentWidth}px`
|
|
|
|
|
+ // // 设置一个合适的高度,比如宽高比16:9
|
|
|
|
|
+ // const height = Math.floor(parentWidth * 9 / 16)
|
|
|
|
|
+ // previewContainer.style.height = `${height}px`
|
|
|
|
|
+ //
|
|
|
|
|
+ // // 调整画布大小以匹配
|
|
|
|
|
+ // this.resizeCanvas()
|
|
|
|
|
+ // }
|
|
|
|
|
+ // },
|
|
|
|
|
|
|
|
// 处理画布点击事件 - 添加顶点
|
|
// 处理画布点击事件 - 添加顶点
|
|
|
handleCanvasClick(event) {
|
|
handleCanvasClick(event) {
|
|
|
- const canvas = this.$refs.polygonCanvas
|
|
|
|
|
- const rect = canvas.getBoundingClientRect()
|
|
|
|
|
|
|
+ // const canvas = this.$refs.polygonCanvas
|
|
|
|
|
+ const rect = this.canvasElem.getBoundingClientRect()
|
|
|
|
|
|
|
|
// 计算相对于画布的坐标
|
|
// 计算相对于画布的坐标
|
|
|
let x = event.clientX - rect.left
|
|
let x = event.clientX - rect.left
|
|
@@ -349,8 +331,8 @@ export default {
|
|
|
},
|
|
},
|
|
|
// 处理鼠标移动事件
|
|
// 处理鼠标移动事件
|
|
|
handleMouseMove(event) {
|
|
handleMouseMove(event) {
|
|
|
- const canvas = this.$refs.polygonCanvas
|
|
|
|
|
- const rect = canvas.getBoundingClientRect()
|
|
|
|
|
|
|
+ // const canvas = this.$refs.polygonCanvas
|
|
|
|
|
+ const rect = this.canvasElem.getBoundingClientRect()
|
|
|
// 计算相对于画布的坐标
|
|
// 计算相对于画布的坐标
|
|
|
let x = event.clientX - rect.left
|
|
let x = event.clientX - rect.left
|
|
|
let y = event.clientY - rect.top
|
|
let y = event.clientY - rect.top
|
|
@@ -423,8 +405,7 @@ export default {
|
|
|
lineColor: this.lineColor,
|
|
lineColor: this.lineColor,
|
|
|
fillColor: this.fillColor,
|
|
fillColor: this.fillColor,
|
|
|
lineWidth: this.lineWidth,
|
|
lineWidth: this.lineWidth,
|
|
|
- index: this.polygons.length == 0 ? 1 : this.polygons[this.polygons.length - 1].index + 1,
|
|
|
|
|
- syncStatus: 0
|
|
|
|
|
|
|
+ index: this.polygons.length == 0 ? 1 : this.polygons[this.polygons.length - 1].index + 1
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
// 重置当前多边形
|
|
// 重置当前多边形
|
|
@@ -466,13 +447,13 @@ export default {
|
|
|
// 转换为JSON字符串
|
|
// 转换为JSON字符串
|
|
|
const jsonData = JSON.stringify(data, null, 2)
|
|
const jsonData = JSON.stringify(data, null, 2)
|
|
|
|
|
|
|
|
- let param = {channelId: this.channelId, taskId: this.taskId, pointId: this.pointId, pointName: this.pointName, type: this.type, jsonData: jsonData, info: JSON.stringify(this.tasks.find(task => task.id == this.taskId))};
|
|
|
|
|
|
|
+ let param = {channelId: this.channelId, taskId: this.taskId, pointId: this.pointId, pointName: this.pointName, type: this.type, jsonData: jsonData, info: this.info};
|
|
|
addRail(param).then(response => {
|
|
addRail(param).then(response => {
|
|
|
alert("成功")
|
|
alert("成功")
|
|
|
let json = {channelId: this.channelId, taskId: this.taskId, pointId: this.pointId, pointName: this.pointName, type: this.type};
|
|
let json = {channelId: this.channelId, taskId: this.taskId, pointId: this.pointId, pointName: this.pointName, type: this.type};
|
|
|
getRail(json).then(response => {
|
|
getRail(json).then(response => {
|
|
|
if (response.data && response.data.jsonData) {
|
|
if (response.data && response.data.jsonData) {
|
|
|
- this.redrawAllPolygons(response.data.jsonData, response.data.syncStatus)
|
|
|
|
|
|
|
+ this.redrawAllPolygons(response.data.jsonData)
|
|
|
} else {
|
|
} else {
|
|
|
this.clearCanvas()
|
|
this.clearCanvas()
|
|
|
}
|
|
}
|
|
@@ -506,19 +487,18 @@ export default {
|
|
|
}, 1000)
|
|
}, 1000)
|
|
|
},
|
|
},
|
|
|
// 重绘所有多边形
|
|
// 重绘所有多边形
|
|
|
- redrawAllPolygons(data, status) {
|
|
|
|
|
|
|
+ redrawAllPolygons(data) {
|
|
|
if (data) {
|
|
if (data) {
|
|
|
this.polygons = JSON.parse(data).polygons
|
|
this.polygons = JSON.parse(data).polygons
|
|
|
- this.polygons.forEach(item => item.syncStatus = status)
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- const canvas = this.$refs.polygonCanvas
|
|
|
|
|
- if (!canvas) return
|
|
|
|
|
|
|
+ // const canvas = this.$refs.polygonCanvas
|
|
|
|
|
+ // if (!canvas) return
|
|
|
|
|
|
|
|
- const ctx = canvas.getContext('2d')
|
|
|
|
|
|
|
+ const ctx = this.canvasElem.getContext('2d')
|
|
|
|
|
|
|
|
// 清空画布
|
|
// 清空画布
|
|
|
- ctx.clearRect(0, 0, canvas.width, canvas.height)
|
|
|
|
|
|
|
+ ctx.clearRect(0, 0, this.canvasElem.width, this.canvasElem.height)
|
|
|
|
|
|
|
|
// 绘制所有已完成的多边形
|
|
// 绘制所有已完成的多边形
|
|
|
this.polygons.forEach(polygon => {
|
|
this.polygons.forEach(polygon => {
|
|
@@ -686,6 +666,7 @@ export default {
|
|
|
font-size: 18px;
|
|
font-size: 18px;
|
|
|
font-weight: 600;
|
|
font-weight: 600;
|
|
|
color: #1F2937;
|
|
color: #1F2937;
|
|
|
|
|
+ margin-top: 0px;
|
|
|
margin-bottom: 16px;
|
|
margin-bottom: 16px;
|
|
|
}
|
|
}
|
|
|
|
|
|