From 616d4a1b45ac9e1442a5541e21c8c755cde2c78f Mon Sep 17 00:00:00 2001
From: WXL <1785969728@qq.com>
Date: 星期六, 05 七月 2025 14:40:56 +0800
Subject: [PATCH] 11

---
 public/integration.html      |   36 +++++----
 public/ConsultationRoom.html |  201 +++++++++++++++++++++++++++-----------------------
 2 files changed, 128 insertions(+), 109 deletions(-)

diff --git a/public/ConsultationRoom.html b/public/ConsultationRoom.html
index dd138ec..d01ec88 100644
--- a/public/ConsultationRoom.html
+++ b/public/ConsultationRoom.html
@@ -265,8 +265,10 @@
     .control-btn {
       padding: 8px 5px;
       background: rgba(91, 140, 255, 0.1);
-       flex: 1; /* 骞冲潎鍒嗛厤瀹藉害 */
-  min-width: 0; /* 闃叉鍐呭婧㈠嚭 */
+      flex: 1;
+      /* 骞冲潎鍒嗛厤瀹藉害 */
+      min-width: 0;
+      /* 闃叉鍐呭婧㈠嚭 */
       border: none;
       border-radius: 12px;
       color: #4a7dff;
@@ -457,16 +459,20 @@
       roomId: 1,
       timer: null,
       speechSynthesis: window.speechSynthesis || null,
-      apiBaseUrl: 'http://10.0.2.193/admin-api' // 鏍规嵁瀹為檯鎯呭喌淇敼
+      apiBaseUrl: 'http://10.0.2.193/admin-api' 
+      // apiBaseUrl: 'http://localhost:48080/admin-api' 
     };
 
     // 椤甸潰鍔犺浇瀹屾垚鍚庡垵濮嬪寲
-    $(document).ready(function () {
+    // 椤甸潰鍔犺浇瀹屾垚鍚庡垵濮嬪寲
+    document.addEventListener('DOMContentLoaded', function () {
       // 鍒濆鍖栦簨浠剁洃鍚�
-      $('#searchRoomBtn').click(searchRoom);
-      $('#callBtn').click(initiateSpeak);
-      $('#testSpeakBtn').click(function () { speak('娆㈣繋浣跨敤璇婇棿鍙彿绯荤粺'); });
-      $('#changeRoomBtn').click(changeRoom);
+      document.getElementById('searchRoomBtn').addEventListener('click', searchRoom);
+      document.getElementById('callBtn').addEventListener('click', initiateSpeak);
+      document.getElementById('testSpeakBtn').addEventListener('click', function () {
+        speak('娆㈣繋浣跨敤璇婇棿鍙彿绯荤粺');
+      });
+      document.getElementById('changeRoomBtn').addEventListener('click', changeRoom);
 
       // 鍒濆鍖栨暟鎹�
       getRoomByIp();
@@ -480,7 +486,7 @@
 
     // 鎼滅储鎴块棿
     function searchRoom() {
-      var searchInput = $('#searchRoomInput').val().trim();
+      var searchInput = document.getElementById('searchRoomInput').value.trim();
       if (!searchInput) {
         updateAnnouncement('璇疯緭鍏ユ湁鏁堢殑鎴块棿鍙�');
         return;
@@ -488,55 +494,69 @@
 
       updateAnnouncement('姝e湪鏌ヨ ' + searchInput + ' 鎴块棿淇℃伅...');
 
-      // 鐪熷疄API璋冪敤
-      $.ajax({
-        url: appState.apiBaseUrl + '/clinic/room/get-room-by-ip',
-        data: { roomId: searchInput },
-        type: 'GET',
-        dataType: 'json',
-        success: function (response) {
-          appState.roomProfile = response.data || response;
-          updateRoomInfo();
-          updateAnnouncement('宸插姞杞� ' + appState.roomProfile.roomName + ' 淇℃伅');
-          getList(); // 鑾峰彇璇ユ埧闂寸殑鎮h�呭垪琛�
-        },
-        error: function (xhr, status, error) {
-          updateAnnouncement('鏌ヨ鎴块棿澶辫触: ' + (xhr.responseJSON?.message || error));
-          console.error('鏌ヨ鎴块棿澶辫触:', error);
+      var xhr = new XMLHttpRequest();
+      xhr.open('GET', appState.apiBaseUrl + '/clinic/room/get-room-by-ip?roomId=' + encodeURIComponent(searchInput), true);
+      xhr.onreadystatechange = function () {
+        if (xhr.readyState === 4) {
+          if (xhr.status === 200) {
+            try {
+              var response = JSON.parse(xhr.responseText);
+              appState.roomProfile = response.data || response;
+              updateRoomInfo();
+              updateAnnouncement('宸插姞杞� ' + appState.roomProfile.roomName + ' 淇℃伅');
+              getList(); // 鑾峰彇璇ユ埧闂寸殑鎮h�呭垪琛�
+            } catch (e) {
+              updateAnnouncement('瑙f瀽鍝嶅簲鏁版嵁澶辫触');
+              console.error('瑙f瀽鍝嶅簲澶辫触:', e);
+            }
+          } else {
+            updateAnnouncement('鏌ヨ鎴块棿澶辫触: ' + xhr.status);
+            console.error('鏌ヨ鎴块棿澶辫触:', xhr.status);
+          }
         }
-      });
+      };
+      xhr.send();
     }
 
-    // 鑾峰彇鎴块棿淇℃伅
-    // 鑾峰彇鎴块棿淇℃伅 - 浣跨敤鐪熷疄API
     function getRoomByIp() {
-      var searchInput = $('#searchRoomInput').val().trim();
+      var searchInput = document.getElementById('searchRoomInput').value.trim();
 
-      $.ajax({
-        url: appState.apiBaseUrl + '/ecg/screen/room-screen-data',
-        data: { roomId: searchInput },
-        type: 'GET',
-        dataType: 'json',
-        success: function (response) {
-          appState.roomProfile = response.data || response;
-          updateRoomInfo();
+      var xhr = new XMLHttpRequest();
+      xhr.open('GET', appState.apiBaseUrl + '/ecg/screen/room-screen-data?roomId=' + encodeURIComponent(searchInput), true);
+      xhr.onreadystatechange = function () {
+        if (xhr.readyState === 4) {
+          if (xhr.status === 200) {
+            try {
+              var response = JSON.parse(xhr.responseText);
+              appState.roomProfile = response.data || response;
+              updateRoomInfo();
 
-          // 妫�鏌ユ槸鍚︽湁闇�瑕佸彨鍙风殑鎮h��
-          if (response.data && response.data.called === 0) {
-            appState.curSpeakPat = response.data;
-            speak('璇�' + response.data.patName + '鍒�' + appState.roomProfile.roomName + '瑁呮満');
+              // 妫�鏌ユ槸鍚︽湁闇�瑕佸彨鍙风殑鎮h��
+              if (response.data && response.data.called === 0) {
+                appState.curSpeakPat = response.data;
+                speak('璇�' + response.data.patName + '鍒�' + appState.roomProfile.roomName + '瑁呮満');
+              }
+            } catch (e) {
+              console.error('瑙f瀽鍝嶅簲澶辫触:', e);
+              // 浣跨敤妯℃嫙鏁版嵁浣滀负鍚庡
+              appState.roomProfile = {
+                roomName: '蹇冪數鍥捐瘖瀹� ' + (appState.roomId + 1),
+                callingScreenType: [40, 10, 30][appState.roomId % 3]
+              };
+              updateRoomInfo();
+            }
+          } else {
+            console.error('鑾峰彇鎴块棿淇℃伅澶辫触:', xhr.status);
+            // 浣跨敤妯℃嫙鏁版嵁浣滀负鍚庡
+            appState.roomProfile = {
+              roomName: '蹇冪數鍥捐瘖瀹� ' + (appState.roomId + 1),
+              callingScreenType: [40, 10, 30][appState.roomId % 3]
+            };
+            updateRoomInfo();
           }
-        },
-        error: function (xhr, status, error) {
-          console.error('鑾峰彇鎴块棿淇℃伅澶辫触:', error);
-          // 浣跨敤妯℃嫙鏁版嵁浣滀负鍚庡
-          appState.roomProfile = {
-            roomName: '蹇冪數鍥捐瘖瀹� ' + (appState.roomId + 1),
-            callingScreenType: [40, 10, 30][appState.roomId % 3]
-          };
-          updateRoomInfo();
         }
-      });
+      };
+      xhr.send();
     }
 
     // 鏇存柊鎴块棿淇℃伅鏄剧ず
@@ -561,36 +581,30 @@
       $('#screenType').text('妯″紡锛�' + screenTypeText);
     }
 
+    // 鑾峰彇鎮h�呭垪琛�
     function getList() {
-      var searchInput = $('#searchRoomInput').val().trim();
+      var searchInput = document.getElementById('searchRoomInput').value.trim();
 
-      $.ajax({
-        url: appState.apiBaseUrl + '/ecg/screen/room-screen-data',
-        data: { roomId: searchInput },
-        type: 'GET',
-        dataType: 'json',
-        success: function (response) {
-          // 鍋囪杩斿洖鏁版嵁缁撴瀯涓� { data: [妫�鏌ラ槦鍒楁暟鎹�, 瑁呮満闃熷垪鏁版嵁] }
-          if (response.data) {
-            console.log(response.data);
-            console.log(response.data[1]);
-            
-            appState.checkRelatedPatientList = response.data[1] || [];
-            console.log();
-            
+      var xhr = new XMLHttpRequest();
+      xhr.open('GET', appState.apiBaseUrl + '/ecg/screen/room-screen-data?roomId=' + encodeURIComponent(searchInput), true);
+      xhr.onreadystatechange = function () {
+        if (xhr.readyState === 4) {
+          if (xhr.status === 200) {
+            try {
+              var response = JSON.parse(xhr.responseText);
+              if (response.data) {
+                appState.checkRelatedPatientList = response.data[1] || [];
+              }
+              updatePatientList();
+            } catch (e) {
+              console.error('瑙f瀽鎮h�呭垪琛ㄥけ璐�:', e);
+            }
           } else {
-            // 妯℃嫙鏁版嵁浣滀负鍚庡
-            // appState.checkRelatedPatientList = generateMockPatients();
+            console.error('鑾峰彇鎮h�呭垪琛ㄥけ璐�:', xhr.status);
           }
-          updatePatientList();
-        },
-        error: function (xhr, status, error) {
-          console.error('鑾峰彇鎮h�呭垪琛ㄥけ璐�:', error);
-          // 浣跨敤妯℃嫙鏁版嵁浣滀负鍚庡
-          // appState.checkRelatedPatientList = generateMockPatients();
-          // updatePatientList();
         }
-      });
+      };
+      xhr.send();
     }
 
     // 寮�濮嬪畾鏃跺埛鏂�
@@ -693,7 +707,6 @@
     }
 
     // 鍙彿鍔熻兘
-    // 鍙彿鍔熻兘锛堜娇鐢ㄧ湡瀹濧PI锛�
     function initiateSpeak() {
       // 鎵惧嚭绛夊緟涓殑鎮h��
       var waitingPatients = [];
@@ -702,31 +715,33 @@
           waitingPatients.push(appState.checkRelatedPatientList[i]);
         }
       }
-      
+
       if (waitingPatients.length === 0) {
         updateAnnouncement('褰撳墠娌℃湁绛夊緟瑁呮満鐨勬偅鑰�');
         return;
       }
 
       var patient = waitingPatients[0];
-      
+
       // 璋冪敤API鏍囪涓哄凡鍙彿
-      $.ajax({
-        url: appState.apiBaseUrl + '/ecg/screen/mark-patient-called',
-        method: 'POST',
-        data: { patientId: patient.id },
-        success: function() {
-          appState.curSpeakPat = {
-            patName: patient.patName,
-            roomName: appState.roomProfile.roomName
-          };
-          speak('璇�' + patient.patName + '鍒�' + appState.roomProfile.roomName + '瑁呮満');
-        },
-        error: function(xhr, status, error) {
-          updateAnnouncement('鍙彿澶辫触: ' + (xhr.responseJSON?.message || error));
-          console.error('鍙彿澶辫触:', error);
+      var xhr = new XMLHttpRequest();
+      xhr.open('POST', appState.apiBaseUrl + '/ecg/screen/mark-patient-called', true);
+      xhr.setRequestHeader('Content-Type', 'application/json');
+      xhr.onreadystatechange = function () {
+        if (xhr.readyState === 4) {
+          if (xhr.status === 200) {
+            appState.curSpeakPat = {
+              patName: patient.patName,
+              roomName: appState.roomProfile.roomName
+            };
+            speak('璇�' + patient.patName + '鍒�' + appState.roomProfile.roomName + '瑁呮満');
+          } else {
+            updateAnnouncement('鍙彿澶辫触: ' + xhr.status);
+            console.error('鍙彿澶辫触:', xhr.status);
+          }
         }
-      });
+      };
+      xhr.send(JSON.stringify({ patientId: patient.id }));
     }
 
     // 璇煶鎾姤
diff --git a/public/integration.html b/public/integration.html
index b822185..cc390e6 100644
--- a/public/integration.html
+++ b/public/integration.html
@@ -443,8 +443,10 @@
         appState.runningIndicator++;
         $('#runningIndicator').css('backgroundColor', appState.runningIndicator % 2 === 0 ? '#67c23a' : '#e6a23c');
         getList();
+        console.log(appState.curSpeakPat,'555');
         
         if (appState.curSpeakPat == null) {
+        console.log(appState.curSpeakPat,'666');
           initiateSpeak();
         }
       }, 5000);
@@ -474,25 +476,28 @@
     // 鍙彿鍔熻兘
     function initiateSpeak() {
       // 杩欓噷鏇挎崲涓哄疄闄呯殑API璋冪敤
-      $.ajax({
-        url: appState.apiBaseUrl + '/ecg/call/next',
-        type: 'GET',
-        dataType: 'json',
-        success: function(response) {
-          appState.curSpeakPat = response.data || response;
-          if (appState.curSpeakPat != null && appState.curSpeakPat.called === 0) {
-            speak("璇枫��" + appState.curSpeakPat.patName + "鍒�" + appState.curSpeakPat.roomName + "灏辫瘖");
-          }
-        },
-        error: function(xhr, status, error) {
-          console.error('鑾峰彇涓嬩竴涓彨鍙峰け璐�:', error);
-        }
-      });
+            speak("璇枫��" + '鍚撮緳' + "鍒�" + '搴峰绉�' + "灏辫瘖");
+
+      // $.ajax({
+      //   url: appState.apiBaseUrl + '/ecg/call/next',
+      //   type: 'GET',
+      //   dataType: 'json',
+      //   success: function(response) {
+      //     appState.curSpeakPat = response.data || response;
+      //     if (appState.curSpeakPat != null && appState.curSpeakPat.called === 0) {
+      //       console.log(111);
+            
+      //       speak("璇枫��" + appState.curSpeakPat.patName + "鍒�" + appState.curSpeakPat.roomName + "灏辫瘖");
+      //     }
+      //   },
+      //   error: function(xhr, status, error) {
+      //     console.error('鑾峰彇涓嬩竴涓彨鍙峰け璐�:', error);
+      //   }
+      // });
     }
 
     // 璇煶鎾姤
     function speak(msg) {
-      console.info("speak " + msg);
 
       if (!appState.speechSynthesis) {
         console.warn("褰撳墠娴忚鍣ㄤ笉鏀寔璇煶鍚堟垚");
@@ -509,7 +514,6 @@
       speech.volume = 100;
       speech.lang = 'zh-CN';
       speech.onend = onSpeachEndEvent;
-
       appState.speechSynthesis.speak(speech);
     }
 

--
Gitblit v1.9.3