分配 \'' + sourceName + '\' 到设备
';
+ 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 = '
分配 "' + sourceName + '" 到设备
' +
+ '
';
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 += '
' + dname + ' ' + (ip || did) + '
';
+ 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 + '
' + (ip || did) + ' ';
+ 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();
+ });
+ box.querySelector('div:last-child').appendChild(item);
});
- html += '
取消
';
- var div = document.createElement('div');
- div.innerHTML = html;
- document.body.appendChild(div.firstElementChild);
+ box.innerHTML += '