| | |
| | | .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; |
| | |
| | | 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(); |
| | |
| | | |
| | | // 搜索房间 |
| | | function searchRoom() { |
| | | var searchInput = $('#searchRoomInput').val().trim(); |
| | | var searchInput = document.getElementById('searchRoomInput').value.trim(); |
| | | if (!searchInput) { |
| | | updateAnnouncement('请输入有效的房间号'); |
| | | return; |
| | |
| | | |
| | | updateAnnouncement('正在查询 ' + searchInput + ' 房间信息...'); |
| | | |
| | | // 真实API调用 |
| | | $.ajax({ |
| | | url: appState.apiBaseUrl + '/clinic/room/get-room-by-ip', |
| | | data: { roomId: searchInput }, |
| | | type: 'GET', |
| | | dataType: 'json', |
| | | success: function (response) { |
| | | 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(); // 获取该房间的患者列表 |
| | | }, |
| | | error: function (xhr, status, error) { |
| | | updateAnnouncement('查询房间失败: ' + (xhr.responseJSON?.message || error)); |
| | | console.error('查询房间失败:', error); |
| | | } catch (e) { |
| | | updateAnnouncement('解析响应数据失败'); |
| | | console.error('解析响应失败:', 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) { |
| | | 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(); |
| | | |
| | |
| | | appState.curSpeakPat = response.data; |
| | | speak('请' + response.data.patName + '到' + appState.roomProfile.roomName + '装机'); |
| | | } |
| | | }, |
| | | error: function (xhr, status, error) { |
| | | console.error('获取房间信息失败:', error); |
| | | } catch (e) { |
| | | console.error('解析响应失败:', e); |
| | | // 使用模拟数据作为后备 |
| | | appState.roomProfile = { |
| | | roomName: '心电图诊室 ' + (appState.roomId + 1), |
| | |
| | | }; |
| | | updateRoomInfo(); |
| | | } |
| | | }); |
| | | } else { |
| | | console.error('获取房间信息失败:', xhr.status); |
| | | // 使用模拟数据作为后备 |
| | | appState.roomProfile = { |
| | | roomName: '心电图诊室 ' + (appState.roomId + 1), |
| | | callingScreenType: [40, 10, 30][appState.roomId % 3] |
| | | }; |
| | | updateRoomInfo(); |
| | | } |
| | | } |
| | | }; |
| | | xhr.send(); |
| | | } |
| | | |
| | | // 更新房间信息显示 |
| | |
| | | $('#screenType').text('模式:' + screenTypeText); |
| | | } |
| | | |
| | | // 获取患者列表 |
| | | 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: [检查队列数据, 装机队列数据] } |
| | | 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) { |
| | | console.log(response.data); |
| | | console.log(response.data[1]); |
| | | |
| | | appState.checkRelatedPatientList = response.data[1] || []; |
| | | console.log(); |
| | | |
| | | } else { |
| | | // 模拟数据作为后备 |
| | | // appState.checkRelatedPatientList = generateMockPatients(); |
| | | } |
| | | updatePatientList(); |
| | | }, |
| | | error: function (xhr, status, error) { |
| | | console.error('获取患者列表失败:', error); |
| | | // 使用模拟数据作为后备 |
| | | // appState.checkRelatedPatientList = generateMockPatients(); |
| | | // updatePatientList(); |
| | | } catch (e) { |
| | | console.error('解析患者列表失败:', e); |
| | | } |
| | | }); |
| | | } else { |
| | | console.error('获取患者列表失败:', xhr.status); |
| | | } |
| | | } |
| | | }; |
| | | xhr.send(); |
| | | } |
| | | |
| | | // 开始定时刷新 |
| | |
| | | } |
| | | |
| | | // 叫号功能 |
| | | // 叫号功能(使用真实API) |
| | | function initiateSpeak() { |
| | | // 找出等待中的患者 |
| | | var waitingPatients = []; |
| | |
| | | var patient = waitingPatients[0]; |
| | | |
| | | // 调用API标记为已叫号 |
| | | $.ajax({ |
| | | url: appState.apiBaseUrl + '/ecg/screen/mark-patient-called', |
| | | method: 'POST', |
| | | data: { patientId: patient.id }, |
| | | success: function() { |
| | | 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 + '装机'); |
| | | }, |
| | | error: function(xhr, status, error) { |
| | | updateAnnouncement('叫号失败: ' + (xhr.responseJSON?.message || error)); |
| | | console.error('叫号失败:', error); |
| | | } else { |
| | | updateAnnouncement('叫号失败: ' + xhr.status); |
| | | console.error('叫号失败:', xhr.status); |
| | | } |
| | | }); |
| | | } |
| | | }; |
| | | xhr.send(JSON.stringify({ patientId: patient.id })); |
| | | } |
| | | |
| | | // 语音播报 |