Compare commits

...

6 Commits

Author SHA1 Message Date
9771164cf5 Merge remote-tracking branch 'origin/feature'
Some checks failed
Lock Threads / action (push) Has been cancelled
Issue Close Require / close-issues (push) Has been cancelled
Close stale issues / stale (push) Has been cancelled
2026-04-09 10:36:27 +08:00
7e13025e3b 优化:ROI 编辑页删除边缘设备选择器
device_id 现在由后端从摄像头配置自动继承,前端不再需要手动选择。
2026-03-30 14:14:28 +08:00
ed25910679 重构:ROI选区界面改造 — 全图+自定义选区+可收起面板
RoiCanvas.vue:
- 移除矩形绘制模式,保留多边形+鼠标跟随线+闭合预览
- 键盘事件:Esc取消、Ctrl+Z撤销上一顶点
- 支持 fullscreen 类型渲染和点击检测
- 绘制中底部浮动提示条

index.vue:
- 工具栏:默认[全图][自定义选区],绘制中[完成][撤销][取消]
- 全图按钮一键创建覆盖整张图的ROI
- 初始Canvas全宽,点击ROI后右侧面板滑出(60%/40%)
- 面板关闭按钮+删除最后ROI时自动收起
- ROI标签显示全图/自定义/矩形
2026-03-27 09:21:23 +08:00
9449c48327 修复:告警操作按钮改造 — 处理弹窗+误报按钮
1. "处理"按钮改为弹窗(支持备注输入),状态直接变为已处理
2. "忽略"按钮文案改为"误报",语义更准确
3. 处理中状态(企微保安负责)无多余操作按钮
2026-03-25 15:10:58 +08:00
d16c821783 Merge branch 'feature'
Some checks failed
Lock Threads / action (push) Has been cancelled
Issue Close Require / close-issues (push) Has been cancelled
Close stale issues / stale (push) Has been cancelled
CodeQL / Analyze (javascript-typescript) (push) Has been cancelled
2026-03-05 11:26:25 +08:00
7c9b51a6de merge: 合并feature分支 - 摄像头管理、告警优化等功能
Some checks failed
Lock Threads / action (push) Has been cancelled
Issue Close Require / close-issues (push) Has been cancelled
Close stale issues / stale (push) Has been cancelled
CodeQL / Analyze (javascript-typescript) (push) Has been cancelled
2026-02-26 16:32:53 +08:00
3 changed files with 461 additions and 259 deletions

View File

@@ -6,10 +6,14 @@ import { h, ref } from 'vue';
import { Page } from '@vben/common-ui';
import { Button, Image, message, Modal, Tag } from 'ant-design-vue';
import { Image, message, Modal, Tag } from 'ant-design-vue';
import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
import { getAlert, getAlertPage, handleAlert } from '#/api/aiot/alarm';
import {
getAlert,
getAlertPage,
handleAlert,
} from '#/api/aiot/alarm';
import {
ALERT_LEVEL_OPTIONS,
@@ -117,37 +121,61 @@ async function handleView(row: AiotAlarmApi.Alert) {
}
}
/** 处理告警 */
async function handleProcess(row: AiotAlarmApi.Alert, status: string) {
const statusText = status === 'handled' ? '处理' : '忽略';
Modal.confirm({
title: `${statusText}告警`,
content: h('div', [
h('p', `确定要${statusText}该告警吗?`),
h('p', { class: 'text-gray-500 text-sm' }, `告警编号:${row.alertNo}`),
h('textarea', {
id: 'processRemark',
class: 'ant-input mt-2',
rows: 3,
placeholder: '请输入处理备注(可选)',
}),
]),
async onOk() {
const textarea = document.querySelector(
'#processRemark',
) as HTMLTextAreaElement;
const remark = textarea?.value || '';
/** 处理告警 — "处理"弹窗(支持备注) */
const handleModalVisible = ref(false);
const handleModalRow = ref<AiotAlarmApi.Alert | null>(null);
const handleRemark = ref('');
const handleSubmitting = ref(false);
function openHandleModal(row: AiotAlarmApi.Alert) {
handleModalRow.value = row;
handleRemark.value = '';
handleModalVisible.value = true;
}
async function submitHandle() {
const row = handleModalRow.value;
if (!row) return;
handleSubmitting.value = true;
try {
await handleAlert(
row.alarmId || row.id!,
'handled',
handleRemark.value || undefined,
);
message.success('处理成功');
handleModalVisible.value = false;
handleRefresh();
} catch (error) {
console.error('处理失败:', error);
message.error('处理失败');
} finally {
handleSubmitting.value = false;
}
}
/** 处理告警 — "误报"确认弹窗 */
function handleFalseAlarm(row: AiotAlarmApi.Alert) {
Modal.confirm({
title: '标记误报',
content: h('div', [
h('p', '确定要将该告警标记为误报吗?'),
h('p', { class: 'text-gray-500 text-sm' }, `告警编号:${row.alertNo}`),
]),
okText: '确定',
cancelText: '取消',
async onOk() {
const hideLoading = message.loading({
content: '正在处理...',
duration: 0,
});
try {
await handleAlert(row.alarmId || row.id!, status, remark);
message.success(`${statusText}成功`);
await handleAlert(row.alarmId || row.id!, 'ignored');
message.success('已标记为误报');
handleRefresh();
} catch (error) {
console.error(`${statusText}失败:`, error);
console.error('标记误报失败:', error);
throw error;
} finally {
hideLoading();
@@ -272,14 +300,14 @@ const [Grid, gridApi] = useVbenVxeGrid({
label: '处理',
type: 'link',
icon: ACTION_ICON.EDIT,
onClick: handleProcess.bind(null, row, 'handled'),
onClick: openHandleModal.bind(null, row),
ifShow: row.status === 'pending',
},
{
label: '忽略',
label: '误报',
type: 'link',
danger: true,
onClick: handleProcess.bind(null, row, 'ignored'),
onClick: handleFalseAlarm.bind(null, row),
ifShow: row.status === 'pending',
},
]"
@@ -409,5 +437,30 @@ const [Grid, gridApi] = useVbenVxeGrid({
</div>
</div>
</Modal>
<!-- 处理告警弹窗 -->
<Modal
v-model:open="handleModalVisible"
title="处理告警"
:confirm-loading="handleSubmitting"
ok-text="确认处理"
cancel-text="取消"
@ok="submitHandle"
>
<div v-if="handleModalRow" class="space-y-4">
<div class="text-gray-500 text-sm">
告警编号{{ handleModalRow.alertNo }}
</div>
<div>
<div class="mb-1 text-sm">处理备注</div>
<textarea
v-model="handleRemark"
class="ant-input w-full"
:rows="3"
placeholder="请输入处理备注(可选)"
/>
</div>
</div>
</Modal>
</Page>
</template>

View File

@@ -18,9 +18,10 @@ const props = withDefaults(defineProps<Props>(), {
});
const emit = defineEmits<{
'draw-cancelled': [];
'roi-deleted': [roiId: string];
'roi-drawn': [data: { roi_type: string; coordinates: string }];
'roi-selected': [roiId: string | null];
'roi-deleted': [roiId: string];
'snap-status': [ok: boolean];
}>();
@@ -31,19 +32,20 @@ let ctx: CanvasRenderingContext2D | null = null;
let canvasWidth = 0;
let canvasHeight = 0;
const isDrawing = ref(false);
let startPoint: { x: number; y: number } | null = null;
let currentPoint: { x: number; y: number } | null = null;
const polygonPoints = ref<{ x: number; y: number }[]>([]);
let mouseMovePoint: { x: number; y: number } | null = null;
const loading = ref(true);
const errorMsg = ref('');
watch(() => props.rois, () => redraw(), { deep: true });
watch(() => props.selectedRoiId, () => redraw());
watch(() => props.drawMode, () => {
watch(() => props.drawMode, (newVal) => {
polygonPoints.value = [];
isDrawing.value = false;
mouseMovePoint = null;
redraw();
if (newVal && wrapper.value) {
wrapper.value.focus();
}
});
watch(() => props.snapUrl, () => {
loading.value = true;
@@ -86,7 +88,6 @@ function onImageError() {
loading.value = false;
errorMsg.value = '截图加载失败,请确认摄像头拉流地址是否有效';
emit('snap-status', false);
// 关键:截图失败也初始化 canvas使 ROI 区域可见可操作
nextTick(() => initCanvas());
}
@@ -143,72 +144,88 @@ function getCanvasPoint(e: MouseEvent) {
};
}
// ---- 鼠标事件 ----
function onMouseDown(e: MouseEvent) {
if (e.button !== 0) return;
const pt = getCanvasPoint(e);
if (props.drawMode === 'rectangle') {
isDrawing.value = true;
startPoint = pt;
currentPoint = pt;
} else if (props.drawMode === 'polygon') {
if (props.drawMode === 'polygon') {
polygonPoints.value.push(pt);
redraw();
drawPolygonInProgress();
} else {
} else if (!props.drawMode) {
const clickedRoi = findRoiAtPoint(pt);
emit('roi-selected', clickedRoi?.roiId ?? null);
}
}
function onMouseMove(e: MouseEvent) {
if (!isDrawing.value || props.drawMode !== 'rectangle') return;
currentPoint = getCanvasPoint(e);
redraw();
drawRectInProgress();
}
function onMouseUp(e: MouseEvent) {
if (!isDrawing.value || props.drawMode !== 'rectangle') return;
isDrawing.value = false;
const endPoint = getCanvasPoint(e);
const x = Math.min(startPoint!.x, endPoint.x);
const y = Math.min(startPoint!.y, endPoint.y);
const w = Math.abs(endPoint.x - startPoint!.x);
const h = Math.abs(endPoint.y - startPoint!.y);
if (w > 0.01 && h > 0.01) {
emit('roi-drawn', {
roi_type: 'rectangle',
coordinates: JSON.stringify({ x, y, w, h }),
});
}
startPoint = null;
currentPoint = null;
if (props.drawMode !== 'polygon' || polygonPoints.value.length === 0) return;
mouseMovePoint = getCanvasPoint(e);
redraw();
drawPolygonInProgress();
}
function onDoubleClick() {
if (props.drawMode === 'polygon' && polygonPoints.value.length >= 3) {
emit('roi-drawn', {
roi_type: 'polygon',
coordinates: JSON.stringify(
polygonPoints.value.map((p) => ({ x: p.x, y: p.y })),
),
});
polygonPoints.value = [];
redraw();
finishPolygon();
}
}
function onContextMenu(e: MouseEvent) {
e.preventDefault();
const pt = getCanvasPoint(e);
const roi = findRoiAtPoint(pt);
if (roi?.roiId) {
emit('roi-deleted', roi.roiId);
if (props.drawMode === 'polygon' && polygonPoints.value.length >= 3) {
finishPolygon();
return;
}
if (!props.drawMode) {
const pt = getCanvasPoint(e);
const roi = findRoiAtPoint(pt);
if (roi?.roiId) {
emit('roi-deleted', roi.roiId);
}
}
}
// ---- 键盘事件 ----
function onKeyDown(e: KeyboardEvent) {
if (props.drawMode === 'polygon') {
if (e.key === 'Escape') {
polygonPoints.value = [];
mouseMovePoint = null;
emit('draw-cancelled');
redraw();
} else if ((e.ctrlKey && e.key === 'z') || e.key === 'Backspace') {
e.preventDefault();
if (polygonPoints.value.length > 0) {
polygonPoints.value.pop();
redraw();
if (polygonPoints.value.length > 0) {
drawPolygonInProgress();
}
}
}
}
}
// ---- 多边形完成(公开方法,供父组件调用) ----
function finishPolygon() {
if (polygonPoints.value.length < 3) return;
const points = polygonPoints.value.map((p) => ({ x: p.x, y: p.y }));
emit('roi-drawn', {
roi_type: 'polygon',
coordinates: JSON.stringify(points),
});
polygonPoints.value = [];
mouseMovePoint = null;
redraw();
}
// ---- ROI 查找 ----
function findRoiAtPoint(pt: { x: number; y: number }) {
for (let i = props.rois.length - 1; i >= 0; i--) {
const roi = props.rois[i]!;
@@ -217,7 +234,8 @@ function findRoiAtPoint(pt: { x: number; y: number }) {
typeof roi.coordinates === 'string'
? JSON.parse(roi.coordinates)
: roi.coordinates;
if (roi.roiType === 'rectangle') {
const type = roi.roiType;
if (type === 'rectangle' || type === 'fullscreen') {
if (
pt.x >= coords.x &&
pt.x <= coords.x + coords.w &&
@@ -226,7 +244,7 @@ function findRoiAtPoint(pt: { x: number; y: number }) {
) {
return roi;
}
} else if (roi.roiType === 'polygon') {
} else if (type === 'polygon') {
if (isPointInPolygon(pt, coords)) return roi;
}
} catch {
@@ -254,6 +272,8 @@ function isPointInPolygon(
return inside;
}
// ---- 绘制 ----
function redraw() {
if (!ctx) return;
ctx.clearRect(0, 0, canvasWidth, canvasHeight);
@@ -266,12 +286,13 @@ function redraw() {
: roi.coordinates;
const color = roi.color || '#FF0000';
const isSelected = roi.roiId === props.selectedRoiId;
const type = roi.roiType;
ctx!.strokeStyle = color;
ctx!.lineWidth = isSelected ? 3 : 2;
ctx!.fillStyle = `${color}33`;
if (roi.roiType === 'rectangle') {
if (type === 'rectangle' || type === 'fullscreen') {
const rx = coords.x * canvasWidth;
const ry = coords.y * canvasHeight;
const rw = coords.w * canvasWidth;
@@ -283,7 +304,7 @@ function redraw() {
ctx!.font = '12px Arial';
ctx!.fillText(roi.name, rx + 4, ry + 14);
}
} else if (roi.roiType === 'polygon') {
} else if (type === 'polygon') {
ctx!.beginPath();
coords.forEach((p: { x: number; y: number }, idx: number) => {
const px = p.x * canvasWidth;
@@ -310,19 +331,6 @@ function redraw() {
});
}
function drawRectInProgress() {
if (!startPoint || !currentPoint || !ctx) return;
const x = Math.min(startPoint.x, currentPoint.x) * canvasWidth;
const y = Math.min(startPoint.y, currentPoint.y) * canvasHeight;
const w = Math.abs(currentPoint.x - startPoint.x) * canvasWidth;
const h = Math.abs(currentPoint.y - startPoint.y) * canvasHeight;
ctx.strokeStyle = '#00FF00';
ctx.lineWidth = 2;
ctx.setLineDash([5, 5]);
ctx.strokeRect(x, y, w, h);
ctx.setLineDash([]);
}
function drawPolygonInProgress() {
if (polygonPoints.value.length < 1 || !ctx) return;
ctx.strokeStyle = '#00FF00';
@@ -335,15 +343,31 @@ function drawPolygonInProgress() {
if (idx === 0) ctx!.moveTo(px, py);
else ctx!.lineTo(px, py);
ctx!.fillStyle = '#00FF00';
ctx!.fillRect(px - 3, py - 3, 6, 6);
ctx!.fillRect(px - 4, py - 4, 8, 8);
});
// 鼠标跟随线
if (mouseMovePoint) {
ctx.lineTo(
mouseMovePoint.x * canvasWidth,
mouseMovePoint.y * canvasHeight,
);
}
// 首尾闭合预览线
if (polygonPoints.value.length >= 3) {
const first = polygonPoints.value[0]!;
const last = mouseMovePoint || polygonPoints.value[polygonPoints.value.length - 1]!;
ctx.moveTo(last.x * canvasWidth, last.y * canvasHeight);
ctx.lineTo(first.x * canvasWidth, first.y * canvasHeight);
}
ctx.stroke();
ctx.setLineDash([]);
}
defineExpose({ polygonPoints, finishPolygon, redraw, drawPolygonInProgress });
</script>
<template>
<div ref="wrapper" class="roi-canvas-wrapper">
<div ref="wrapper" class="roi-canvas-wrapper" tabindex="0" @keydown="onKeyDown">
<img
v-if="snapUrl"
:src="snapUrl"
@@ -358,12 +382,16 @@ function drawPolygonInProgress() {
<canvas
ref="canvas"
class="roi-overlay"
:class="{ drawing: drawMode === 'polygon' }"
@mousedown="onMouseDown"
@mousemove="onMouseMove"
@mouseup="onMouseUp"
@dblclick="onDoubleClick"
@contextmenu="onContextMenu"
/>
<!-- 绘制中浮动提示条 -->
<div v-if="drawMode === 'polygon'" class="draw-hint-bar">
单击添加顶点 | 双击或右键完成选区 | Esc取消 | Ctrl+Z撤销
</div>
</div>
</template>
@@ -374,6 +402,7 @@ function drawPolygonInProgress() {
height: 100%;
min-height: 400px;
background: #000;
outline: none;
}
.bg-image {
@@ -396,6 +425,24 @@ function drawPolygonInProgress() {
.roi-overlay {
position: absolute;
}
.roi-overlay.drawing {
cursor: crosshair;
}
.draw-hint-bar {
position: absolute;
bottom: 10px;
left: 50%;
transform: translateX(-50%);
background: rgba(0, 0, 0, 0.75);
color: #fff;
padding: 6px 16px;
border-radius: 4px;
font-size: 13px;
white-space: nowrap;
pointer-events: none;
z-index: 10;
}
</style>

View File

@@ -2,7 +2,7 @@
/**
* ROI 区域配置页面
*
* 功能摄像头截图展示、ROI 区域绘制(矩形/多边形、ROI 属性编辑、
* 功能摄像头截图展示、ROI 区域绘制(全图/自定义多边形、ROI 属性编辑、
* 算法绑定管理、配置推送到边缘端
* 后端WVP 视频平台 AiRoi / AiConfig API
*/
@@ -65,31 +65,26 @@ const selectedRoiId = ref<null | string>(null);
const selectedRoiBindings = ref<AiotDeviceApi.RoiAlgoBinding[]>([]);
const snapUrl = ref('');
const snapOk = ref(false);
const edgeDevices = ref<Array<{ deviceId: string }>>([]);
async function loadEdgeDevices() {
try {
const list = await wvpRequestClient.get<Array<{ deviceId: string }>>('/aiot/device/device/list');
edgeDevices.value = (list as any) || [];
} catch {
edgeDevices.value = [{ deviceId: 'edge' }];
}
}
const panelVisible = ref(false);
const roiCanvasRef = ref<InstanceType<typeof RoiCanvas> | null>(null);
const selectedRoi = computed(() => {
if (!selectedRoiId.value) return null;
return roiList.value.find((r) => r.roiId === selectedRoiId.value) || null;
});
const isDrawing = computed(() => drawMode.value === 'polygon');
const polygonPointCount = computed(() => {
return roiCanvasRef.value?.polygonPoints?.length ?? 0;
});
// ==================== 初始化 ====================
onMounted(async () => {
loadEdgeDevices();
const q = route.query;
if (q.cameraCode) {
cameraCode.value = String(q.cameraCode);
// 加载摄像头信息以获取应用名
await loadCurrentCamera();
await buildSnapUrl();
loadRois();
@@ -121,7 +116,7 @@ async function loadCameraOptions() {
const list = res.list || [];
cameraOptions.value = list.map((cam: AiotDeviceApi.Camera) => ({
value: cam.cameraCode || '',
label: `${cam.app || cam.stream}${cam.srcUrl ? ` (${cam.srcUrl})` : ''}`,
label: `${cam.cameraName || cam.app || cam.stream}${cam.srcUrl ? ` (${cam.srcUrl})` : ''}`,
camera: cam,
}));
} catch {
@@ -146,6 +141,20 @@ function goBack() {
router.push('/aiot/device/camera');
}
// ==================== ROI 类型标签 ====================
function getRoiTagColor(roi: AiotDeviceApi.Roi) {
if (roi.roiType === 'fullscreen') return 'orange';
if (roi.roiType === 'rectangle') return 'blue';
return 'green';
}
function getRoiTagLabel(roi: AiotDeviceApi.Roi) {
if (roi.roiType === 'fullscreen') return '全图';
if (roi.roiType === 'rectangle') return '矩形';
return '自定义';
}
// ==================== 截图 ====================
async function buildSnapUrl(force = false) {
@@ -188,42 +197,98 @@ async function loadRoiDetail() {
}
}
// ==================== ROI 绘制 ====================
// ==================== 全图 ====================
function addFullscreen() {
const hasFullscreen = roiList.value.some((r) => r.roiType === 'fullscreen');
if (hasFullscreen) {
message.warning('已存在全图选区');
return;
}
Modal.confirm({
title: '新建全图选区',
content: '将创建覆盖整张图片的选区',
async onOk() {
const newRoi: Partial<AiotDeviceApi.Roi> = {
cameraId: cameraCode.value,
name: `全图-${roiList.value.length + 1}`,
roiType: 'fullscreen',
coordinates: JSON.stringify({ x: 0, y: 0, w: 1, h: 1 }),
color: '#FF0000',
priority: 0,
enabled: 1,
description: '',
deviceId: '',
};
try {
await saveRoi(newRoi);
message.success('全图选区已创建');
loadRois();
} catch {
message.error('保存失败');
}
},
});
}
// ==================== 自定义选区(多边形绘制) ====================
function startDraw(mode: string) {
drawMode.value = mode;
}
function finishDraw() {
roiCanvasRef.value?.finishPolygon();
}
function undoPoint() {
if (roiCanvasRef.value && roiCanvasRef.value.polygonPoints.length > 0) {
roiCanvasRef.value.polygonPoints.pop();
roiCanvasRef.value.redraw();
if (roiCanvasRef.value.polygonPoints.length > 0) {
roiCanvasRef.value.drawPolygonInProgress();
}
}
}
function cancelDraw() {
drawMode.value = null;
}
function onDrawCancelled() {
drawMode.value = null;
}
async function onRoiDrawn(data: { coordinates: string; roi_type: string }) {
drawMode.value = null;
const roiName = `ROI-${roiList.value.length + 1}`;
const newRoi: Partial<AiotDeviceApi.Roi> = {
cameraId: cameraCode.value,
name: `ROI-${roiList.value.length + 1}`,
name: roiName,
roiType: data.roi_type,
coordinates: data.coordinates,
color: '#FF0000',
priority: 0,
enabled: 1,
description: '',
deviceId: edgeDevices.value[0]?.deviceId || 'edge', // 默认关联边缘设备
deviceId: '',
};
try {
await saveRoi(newRoi);
message.success('ROI已保存');
message.success('选区已保存');
loadRois();
} catch {
message.error('保存失败');
}
}
// ==================== ROI 选择 ====================
// ==================== ROI 选择与面板 ====================
function onRoiSelected(roiId: null | string) {
selectedRoiId.value = roiId;
if (roiId) {
panelVisible.value = true;
loadRoiDetail();
} else {
selectedRoiBindings.value = [];
}
}
@@ -232,6 +297,12 @@ function selectRoi(roi: AiotDeviceApi.Roi) {
loadRoiDetail();
}
function closePanel() {
panelVisible.value = false;
selectedRoiId.value = null;
selectedRoiBindings.value = [];
}
// ==================== ROI 编辑 ====================
async function updateRoiData(roi: AiotDeviceApi.Roi) {
@@ -246,7 +317,13 @@ async function updateRoiData(roi: AiotDeviceApi.Roi) {
// ==================== ROI 删除 ====================
function onRoiDeleted(roiId: string) {
doDeleteRoi(roiId);
Modal.confirm({
title: '提示',
content: '确定删除该ROI关联的算法绑定也将删除。',
async onOk() {
doDeleteRoi(roiId);
},
});
}
function handleDeleteRoi(roi: AiotDeviceApi.Roi) {
@@ -267,7 +344,10 @@ async function doDeleteRoi(roiId: string) {
selectedRoiId.value = null;
selectedRoiBindings.value = [];
}
loadRois();
await loadRois();
if (roiList.value.length === 0) {
panelVisible.value = false;
}
} catch {
message.error('删除失败');
}
@@ -316,40 +396,43 @@ function handlePush() {
<div class="page-header">
<div class="header-left">
<Button size="small" @click="goBack">返回</Button>
<h3>{{ currentCamera?.app || cameraCode }} - ROI配置</h3>
<h3>{{ currentCamera?.cameraName || currentCamera?.app || cameraCode }} - ROI配置</h3>
</div>
<div class="header-right">
<Button
size="small"
type="primary"
:disabled="drawMode === 'rectangle'"
@click="startDraw('rectangle')"
>
画矩形
</Button>
<Button
size="small"
type="primary"
:disabled="drawMode === 'polygon'"
@click="startDraw('polygon')"
>
画多边形
</Button>
<Button size="small" :disabled="!drawMode" @click="drawMode = null">
取消绘制
</Button>
<Button size="small" @click="refreshSnap">刷新截图</Button>
<Button size="small" type="default" @click="handlePush">
推送到边缘端
</Button>
<!-- 默认工具栏 -->
<template v-if="!isDrawing">
<Button size="small" type="primary" @click="addFullscreen">
全图
</Button>
<Button size="small" type="primary" @click="startDraw('polygon')">
自定义选区
</Button>
<Button size="small" @click="refreshSnap">刷新截图</Button>
<Button size="small" type="default" @click="handlePush">
推送到边缘端
</Button>
</template>
<!-- 绘制中工具栏 -->
<template v-else>
<Button size="small" type="primary" :disabled="polygonPointCount < 3" @click="finishDraw">
完成选区
</Button>
<Button size="small" :disabled="polygonPointCount === 0" @click="undoPoint">
撤销上一点
</Button>
<Button size="small" danger @click="cancelDraw">
取消绘制
</Button>
</template>
</div>
</div>
<!-- 主内容区左侧画布 + 右侧面板 -->
<div class="main-content">
<!-- 画布区域 -->
<div class="canvas-panel">
<div :class="['canvas-panel', { 'panel-open': panelVisible }]">
<RoiCanvas
ref="roiCanvasRef"
:rois="roiList"
:draw-mode="drawMode"
:selected-roi-id="selectedRoiId"
@@ -357,134 +440,126 @@ function handlePush() {
@roi-drawn="onRoiDrawn"
@roi-selected="onRoiSelected"
@roi-deleted="onRoiDeleted"
@draw-cancelled="onDrawCancelled"
@snap-status="onSnapStatus"
/>
</div>
<!-- 右侧面板 -->
<div class="side-panel">
<!-- ROI 列表 -->
<div class="section-header">
<span>ROI列表 ({{ roiList.length }})</span>
</div>
<div v-if="roiList.length === 0" class="empty-tip">
暂无ROI请在左侧画面上绘制
</div>
<div
v-for="roi in roiList"
:key="roi.roiId"
:class="['roi-item', { active: selectedRoiId === roi.roiId }]"
@click="selectRoi(roi)"
>
<div class="roi-item-header">
<span
class="roi-color"
:style="{ background: roi.color || '#FF0000' }"
/>
<span class="roi-name">{{ roi.name || '未命名' }}</span>
<Tag
:color="roi.roiType === 'rectangle' ? 'blue' : 'green'"
style="margin-right: 0"
>
{{ roi.roiType === 'rectangle' ? '矩形' : '多边形' }}
</Tag>
<Switch
:checked="roi.enabled === 1"
size="small"
style="margin-left: auto"
@change="
(val: string | number | boolean) => {
roi.enabled = val ? 1 : 0;
updateRoiData(roi);
}
"
@click.stop
/>
<Button
size="small"
type="text"
danger
style="margin-left: 4px"
@click.stop="handleDeleteRoi(roi)"
>
删除
<transition name="slide-panel">
<div v-if="panelVisible" class="side-panel">
<div class="panel-close">
<Button size="small" shape="circle" @click="closePanel">
</Button>
</div>
</div>
<Divider />
<!-- ROI 属性编辑 -->
<div v-if="selectedRoi" class="roi-detail-section">
<h4>ROI属性</h4>
<Form
layout="horizontal"
:label-col="{ span: 6 }"
:wrapper-col="{ span: 18 }"
size="small"
<!-- ROI 列表 -->
<div class="section-header">
<span>ROI列表 ({{ roiList.length }})</span>
</div>
<div v-if="roiList.length === 0" class="empty-tip">
暂无ROI请使用上方按钮添加
</div>
<div
v-for="roi in roiList"
:key="roi.roiId"
:class="['roi-item', { active: selectedRoiId === roi.roiId }]"
@click="selectRoi(roi)"
>
<Form.Item label="名称">
<Input
v-model:value="selectedRoi.name"
@blur="updateRoiData(selectedRoi!)"
<div class="roi-item-header">
<span
class="roi-color"
:style="{ background: roi.color || '#FF0000' }"
/>
</Form.Item>
<Form.Item label="边缘设备">
<Select
v-model:value="selectedRoi.deviceId"
placeholder="选择边缘设备"
@change="updateRoiData(selectedRoi!)"
<span class="roi-name">{{ roi.name || '未命名' }}</span>
<Tag
:color="getRoiTagColor(roi)"
style="margin-right: 0"
>
<Select.Option v-for="dev in edgeDevices" :key="dev.deviceId" :value="dev.deviceId">
{{ dev.deviceId }}
</Select.Option>
</Select>
<div style="margin-top: 4px; font-size: 12px; color: #999">
关联的边缘推理节点
</div>
</Form.Item>
<Form.Item label="颜色">
<Input
v-model:value="selectedRoi.color"
type="color"
style="width: 60px; padding: 2px"
@change="updateRoiData(selectedRoi!)"
{{ getRoiTagLabel(roi) }}
</Tag>
<Switch
:checked="roi.enabled === 1"
size="small"
style="margin-left: auto"
@change="
(val: string | number | boolean) => {
roi.enabled = val ? 1 : 0;
updateRoiData(roi);
}
"
@click.stop
/>
</Form.Item>
<Form.Item label="优先级">
<InputNumber
v-model:value="selectedRoi.priority"
:min="0"
:max="100"
@change="updateRoiData(selectedRoi!)"
/>
<div style="margin-top: 4px; font-size: 12px; color: #999">
数值越大优先级越高0-100多个ROI重叠时优先处理高优先级区域
</div>
</Form.Item>
<Form.Item label="描述">
<Input.TextArea
v-model:value="selectedRoi.description"
:rows="2"
@blur="updateRoiData(selectedRoi!)"
/>
</Form.Item>
</Form>
<Button
size="small"
type="text"
danger
style="margin-left: 4px"
@click.stop="handleDeleteRoi(roi)"
>
删除
</Button>
</div>
</div>
<Divider />
<!-- 算法绑定管理 -->
<RoiAlgorithmBind
:roi-id="selectedRoi.roiId || ''"
:bindings="selectedRoiBindings"
:snap-ok="snapOk"
@changed="loadRoiDetail"
/>
<!-- ROI 属性编辑 -->
<div v-if="selectedRoi" class="roi-detail-section">
<h4>ROI属性</h4>
<Form
layout="horizontal"
:label-col="{ span: 6 }"
:wrapper-col="{ span: 18 }"
size="small"
>
<Form.Item label="名称">
<Input
v-model:value="selectedRoi.name"
@blur="updateRoiData(selectedRoi!)"
/>
</Form.Item>
<Form.Item label="颜色">
<Input
v-model:value="selectedRoi.color"
type="color"
style="width: 60px; padding: 2px"
@change="updateRoiData(selectedRoi!)"
/>
</Form.Item>
<Form.Item label="优先级">
<InputNumber
v-model:value="selectedRoi.priority"
:min="0"
:max="100"
@change="updateRoiData(selectedRoi!)"
/>
</Form.Item>
<Form.Item label="描述">
<Input.TextArea
v-model:value="selectedRoi.description"
:rows="2"
@blur="updateRoiData(selectedRoi!)"
/>
</Form.Item>
</Form>
<Divider />
<!-- 算法绑定管理 -->
<RoiAlgorithmBind
:roi-id="selectedRoi.roiId || ''"
:bindings="selectedRoiBindings"
:snap-ok="snapOk"
@changed="loadRoiDetail"
/>
</div>
<div v-else class="empty-tip" style="margin-top: 20px">
点击左侧ROI区域或列表项查看详情
</div>
</div>
<div v-else class="empty-tip" style="margin-top: 20px">
点击左侧ROI区域或列表项查看详情
</div>
</div>
</transition>
</div>
</div>
</Page>
@@ -513,6 +588,7 @@ function handlePush() {
.header-left h3 {
margin: 0;
font-size: 15px;
}
.header-right {
@@ -523,15 +599,21 @@ function handlePush() {
.main-content {
display: flex;
flex: 1;
gap: 12px;
gap: 0;
overflow: hidden;
position: relative;
}
.canvas-panel {
flex: 6;
flex: 1;
background: #000;
border-radius: 4px;
overflow: hidden;
transition: flex 0.3s ease;
}
.canvas-panel.panel-open {
flex: 6;
}
.side-panel {
@@ -539,8 +621,28 @@ function handlePush() {
overflow-y: auto;
background: #fff;
border: 1px solid #f0f0f0;
border-radius: 4px;
border-radius: 0 4px 4px 0;
padding: 12px;
margin-left: 1px;
}
.panel-close {
text-align: right;
margin-bottom: 8px;
}
/* 面板滑入动画 */
.slide-panel-enter-active,
.slide-panel-leave-active {
transition: all 0.3s ease;
}
.slide-panel-enter-from,
.slide-panel-leave-to {
flex: 0 !important;
padding: 0 !important;
overflow: hidden;
opacity: 0;
}
.section-header {