test-alarm.html 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>测试告警处理</title>
  6. <script>
  7. function handleAlarm() {
  8. alert("处理按钮被点击了!");
  9. document.getElementById('result').innerText = '点击成功 - ' + new Date().toLocaleTimeString();
  10. return false;
  11. }
  12. </script>
  13. </head>
  14. <body>
  15. <h1>测试按钮点击</h1>
  16. <button onclick="handleAlarm()">测试处理告警</button>
  17. <div id="result" style="margin-top: 20px; padding: 10px; background-color: #f0f0f0;"></div>
  18. <script>
  19. // 尝试在页面加载后直接给原告警页面的按钮添加处理函数
  20. document.addEventListener('DOMContentLoaded', function() {
  21. console.log("页面加载完成,准备注入函数");
  22. // 定义一个全局函数,可以在任何页面中调用
  23. window.fixAlarmButtons = function() {
  24. alert("开始修复告警按钮");
  25. var buttons = document.querySelectorAll('.handle-btn');
  26. console.log("找到处理按钮:", buttons.length, "个");
  27. buttons.forEach(function(btn) {
  28. btn.onclick = function() {
  29. alert("处理按钮被点击!");
  30. console.log("处理按钮点击", this.getAttribute('data-id'));
  31. // 获取当前行数据和填充模态框的代码...
  32. // (此处为简化代码)
  33. // 显示模态框
  34. document.getElementById('alarmHandleModal').style.display = 'flex';
  35. return false;
  36. };
  37. console.log("已为按钮设置新的点击处理函数:", btn);
  38. });
  39. return "修复完成,共处理了" + buttons.length + "个按钮";
  40. };
  41. });
  42. </script>
  43. <div style="margin-top: 20px;">
  44. <p>请在设备告警页面的控制台中运行以下代码:</p>
  45. <pre style="background-color: #f0f0f0; padding: 10px;">
  46. fixAlarmButtons();
  47. </pre>
  48. </div>
  49. </body>
  50. </html>