fix: 设备选择器弹窗可点击、可滚动、显示IP
This commit is contained in:
parent
dd40d3d93e
commit
c6c8978ea3
@ -288,19 +288,35 @@
|
||||
function showDevicePicker(sourceName) {
|
||||
var rows = document.querySelectorAll('.console-device-row');
|
||||
if (rows.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;max-width:400px" onclick="event.stopPropagation()"><div style="font-size:14px;font-weight:600;margin-bottom:12px">分配 \'' + sourceName + '\' 到设备</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">分配 "' + sourceName + '" 到设备</div>' +
|
||||
'<div style="max-height:60vh;overflow-y:auto;margin-bottom:12px">';
|
||||
rows.forEach(function(row) {
|
||||
var did = row.getAttribute('data-device-id');
|
||||
var nameEl = row.querySelector('.console-device-name');
|
||||
var dname = nameEl ? nameEl.textContent : did;
|
||||
var metaEl = row.querySelector('.console-device-meta');
|
||||
var ip = metaEl ? (metaEl.textContent.match(/[\d.]+/) || [''])[0] : '';
|
||||
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(\'' + did + '\', \'' + sourceName + '\');this.closest(\'.source-assign-overlay\').remove()">' + dname + ' <span style="font-size:11px;color:var(--muted)">' + (ip || did) + '</span></div>';
|
||||
var item = document.createElement('div');
|
||||
item.style.cssText = 'padding:8px 12px;cursor:pointer;border-radius:4px;margin-bottom:2px;font-size:13px';
|
||||
item.innerHTML = dname + ' <span style="font-size:11px;color:var(--muted)">' + (ip || did) + '</span>';
|
||||
item.addEventListener('mouseover',function(){item.style.background='var(--surface-soft)'});
|
||||
item.addEventListener('mouseout',function(){item.style.background='transparent'});
|
||||
item.addEventListener('click',function(){
|
||||
addSourceToDeviceForm(did, sourceName);
|
||||
overlay.remove();
|
||||
});
|
||||
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.querySelector('div:last-child').appendChild(item);
|
||||
});
|
||||
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);
|
||||
}
|
||||
|
||||
// ---- dirty state tracking ----
|
||||
|
||||
Binary file not shown.
Loading…
Reference in New Issue
Block a user