Threshold_Adjust.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. function editRow(orgin_data, index, channel_power_infro) {
  2. const current_upper = document.getElementById('current_upper');
  3. const voltage_upper = document.getElementById('voltage_upper');
  4. const voltage_lower = document.getElementById('voltage_lower');
  5. const p_upper = document.getElementById('p_upper');
  6. const c_upper = document.getElementById('c_upper');
  7. const updateRow = document.getElementById('updateRow')
  8. const closeModal = document.getElementById('closeModal')
  9. threshold = channel_power_infro
  10. c_u_val = threshold.thr.c_upper
  11. v_u_val = threshold.thr.v_upper
  12. v_l_val = threshold.thr.v_lower
  13. p_u_val = threshold.thr.p_upper
  14. w_u_val = threshold.thr.w_upper
  15. current_upper.value = c_u_val / 10.0;
  16. voltage_upper.value = v_u_val / 10.0;
  17. voltage_lower.value = v_l_val / 10.0;
  18. if (voltage_upper.value < voltage_lower.value) {
  19. alert("电压上限值不能小于电压下限值")
  20. voltage_lower.value = 0
  21. }
  22. p_upper.value = p_u_val / 1000.0;
  23. c_upper.value = w_u_val / 1000.0;
  24. document.getElementById('editModal').style.display = 'block';
  25. updateRow.addEventListener('click', function() {
  26. const current_uppers = document.getElementById('current_upper').value * 10;
  27. const voltage_uppers = document.getElementById('voltage_upper').value * 10;
  28. const voltage_lowers = document.getElementById('voltage_lower').value * 10;
  29. const p_uppers = document.getElementById('p_upper').value * 1000;
  30. const c_uppers = document.getElementById('c_upper').value * 1000;
  31. const alarm_opration = document.getElementById('mySelect').value
  32. if (alarm_opration == 'option1') {
  33. voltage_u = parseInt(voltage_uppers, 10)
  34. voltage_ls = parseInt(voltage_lowers, 10)
  35. if (voltage_u >= voltage_ls) {
  36. threshold.en = 0;
  37. threshold.thr.c_upper = Number(current_uppers);
  38. threshold.thr.v_upper = Number(voltage_uppers);
  39. threshold.thr.v_lower = Number(voltage_lowers);
  40. threshold.thr.p_upper = Number(p_uppers);
  41. threshold.thr.w_upper = Number(c_uppers);
  42. // if (current_uppers != 0) {
  43. // threshold.thr.c_upper.en = 1
  44. // }
  45. // if (voltage_uppers != 0) {
  46. // threshold.thr.v_upper.en = 1
  47. // }
  48. // if (voltage_lowers != 0) {
  49. // threshold.thr.v_lower.en = 1
  50. // }
  51. // if (p_uppers != 0) {
  52. // threshold.thr.p_upper.en = 1
  53. // }
  54. // if (c_uppers != 0) {
  55. // threshold.thr.w_upper.en = 1
  56. // }
  57. threshold_update(threshold)
  58. setInterval(quite(), 3000)
  59. } else {
  60. alert("电压上限值不能小于下限值")
  61. voltage_upper.value = 0
  62. voltage_lower.value = 0
  63. }
  64. }
  65. });
  66. closeModal.addEventListener('click', function() {
  67. document.getElementById('editModal').style.display = 'none';
  68. currentRowIndex = null;
  69. });
  70. }
  71. function quite() {
  72. document.getElementById('editModal').style.display = 'none';
  73. currentRowIndex = null;
  74. }