fix: 设备视图添加视频源弹窗可点击、可滚动

This commit is contained in:
tian 2026-07-24 14:58:04 +08:00
parent 27ce2dd4d8
commit dd40d3d93e
2 changed files with 22 additions and 6 deletions

View File

@ -241,14 +241,30 @@
}
});
if (visible.length === 0) { alert('暂无未分配视频源'); return; }
var html = '<div class="source-assign-overlay" style="position:fixed;top:0;left:0;right:0;bottom:0;background:rgba(0,0,0,0.5);z-index:9999;display:flex;align-items:center;justify-content:center" onclick="this.remove()"><div style="background:var(--surface);border-radius:8px;padding:20px;min-width:300px" onclick="event.stopPropagation()"><div style="font-size:14px;font-weight:600;margin-bottom:12px">为设备添加视频源</div>';
var overlay = document.createElement('div');
overlay.style.cssText = 'position:fixed;top:0;left:0;right:0;bottom:0;background:rgba(0,0,0,0.5);z-index:9999;display:flex;align-items:center;justify-content:center';
overlay.addEventListener('click',function(){overlay.remove()});
var box = document.createElement('div');
box.style.cssText = 'background:var(--surface);border-radius:8px;padding:20px;min-width:300px;max-width:400px';
box.addEventListener('click',function(e){e.stopPropagation()});
box.innerHTML = '<div style="font-size:14px;font-weight:600;margin-bottom:12px">为设备添加视频源 (' + visible.length + '路可用)</div>' +
'<div style="max-height:60vh;overflow-y:auto;margin-bottom:12px">';
visible.forEach(function(name) {
html += '<div style="padding:8px 12px;cursor:pointer;border-radius:4px;margin-bottom:4px" onmouseover="this.style.background=\'var(--surface-soft)\'" onmouseout="this.style.background=\'transparent\'" onclick="addSourceToDeviceForm(\'' + deviceID + '\', \'' + name + '\');this.closest(\'.source-assign-overlay\').remove()">' + name + '</div>';
var item = document.createElement('div');
item.textContent = name;
item.style.cssText = 'padding:8px 12px;cursor:pointer;border-radius:4px;margin-bottom:2px;font-size:13px';
item.addEventListener('mouseover',function(){item.style.background='var(--surface-soft)'});
item.addEventListener('mouseout',function(){item.style.background='transparent'});
item.addEventListener('click',function(){
addSourceToDeviceForm(deviceID, name);
overlay.remove();
});
box.querySelector('div:last-child').appendChild(item);
});
html += '<div style="margin-top:12px;text-align:right"><button class="btn" style="font-size:12px" onclick="this.closest(\'.source-assign-overlay\').remove()">取消</button></div></div></div>';
var div = document.createElement('div');
div.innerHTML = html;
document.body.appendChild(div.firstElementChild);
box.innerHTML += '</div><div style="text-align:right"><button class="btn" style="font-size:12px">取消</button></div>';
box.querySelector('button').addEventListener('click',function(){overlay.remove()});
overlay.appendChild(box);
document.body.appendChild(overlay);
};
function addSourceToDeviceForm(deviceID, sourceName) {

Binary file not shown.