From f1950ac1e0998c149aab0480830c60f871332726 Mon Sep 17 00:00:00 2001
From: eight <641137800@qq.com>
Date: 星期四, 05 九月 2024 18:19:31 +0800
Subject: [PATCH] 叫号功能
---
src/api/ecg/screen/index.ts | 5 +++++
src/views/ecg/callingscreen/bigscreen.vue | 52 +++++++++++++++++++++++++++++++++++++---------------
2 files changed, 42 insertions(+), 15 deletions(-)
diff --git a/src/api/ecg/screen/index.ts b/src/api/ecg/screen/index.ts
index 664bcc0..30cb7ff 100644
--- a/src/api/ecg/screen/index.ts
+++ b/src/api/ecg/screen/index.ts
@@ -16,6 +16,7 @@
status: number // 10:鎺掗槦涓� 20:鍊欒瘖鍑嗗 30:灏辫瘖涓� 40:灏辫瘖瀹屾垚 50:杩囧彿 60:杩囨湡
passed: number // 杩囧彿鏍囪
expired: number // 棰勭害杩囨湡鏍囪
+ called: number
jumpFlag: number //鎻掗槦鏍囪
roomId: number // 璇婂缂栧彿
roomName: string // 璇婂鍚嶇О
@@ -31,5 +32,9 @@
getBigScreenData: async () => {
return await request.get({ url: `/ecg/screen/calling-data` })
+ },
+
+ markCalled: async (patId : string) => {
+ return await request.get({ url: `/ecg/screen/mark-called?patId=` + patId })
}
}
diff --git a/src/views/ecg/callingscreen/bigscreen.vue b/src/views/ecg/callingscreen/bigscreen.vue
index c9095e4..93a9be7 100644
--- a/src/views/ecg/callingscreen/bigscreen.vue
+++ b/src/views/ecg/callingscreen/bigscreen.vue
@@ -8,6 +8,8 @@
const listWaiting = ref<CallingVO[]>([]) // 鍒楄〃鐨勬暟鎹�
const listPassed = ref<CallingVO[]>([]) //
+let curSpeakPat : CallingVO | undefined = undefined;
+
const getList = async () => {
const data = await ScreenApi.getBigScreenData()
listReady.value = data[1]
@@ -17,18 +19,47 @@
const startScrolling = () => {
setInterval(() => {
- // console.info("...")
getList();
- }, 3000); // 姣忎袱绉掓粴鍔ㄤ竴娆�
+ console.info("..." + curSpeakPat)
+ if ( curSpeakPat === undefined ) {
+ const queuePat = getNextSpeak()
+ if (queuePat !== undefined) {
+ console.info("...2" + queuePat)
+ curSpeakPat = queuePat
+ speak(queuePat.patName + queuePat.roomName);
+ } else {
+ console.info("...3" )
+ curSpeakPat = undefined
+ }
+ }
+ }, 10000); // 姣廥绉掓粴鍔ㄤ竴娆�
+}
+
+const getNextSpeak = () => {
+ if (curSpeakPat === undefined || curSpeakPat === null) {
+ return listReady.value.find( item => item.status === 30 && item.called === 0)
+ } else {
+ return listReady.value.find( item => item.status === 30 && item.called === 0 && item.seqNum > curSpeakPat!.seqNum)
+ }
}
onMounted( () => {
startScrolling()
})
+const onSpeachEndEvent = async (event) => {
+ console.log("Speech ended 3" + event);
+ await ScreenApi.markCalled(curSpeakPat!.patId)
+ const queuePat = getNextSpeak()
+ if (queuePat !== undefined) {
+ curSpeakPat = queuePat
+ speak(queuePat.patName + queuePat.roomName);
+ } else {
+ curSpeakPat = undefined
+ }
+}
+
const speak = (msg) => {
- //const msg = new SpeechSynthesisUtterance(`璇�${this.currentNumber}鍙峰氨璇奰);
- const repeatNum = 3
var speech = new SpeechSynthesisUtterance()
speech.text = msg
speech.pitch = 1 // 鑾峰彇骞惰缃瘽璇殑闊宠皟(0-2 榛樿1锛屽�艰秺澶ц秺灏栭攼,瓒婁綆瓒婁綆娌�)
@@ -36,17 +67,8 @@
speech.volume = 100 // 鑾峰彇骞惰缃璇濈殑闊抽噺
speech.lang = 'zh-CN' // 璁剧疆鎾斁璇█
- utterance.onend = function() {
- console.log("Speech ended");
- };
-
- // 澧炲姞鎺у埗鎾斁娆℃暟
- let count = 1
+ speech.onend = onSpeachEndEvent
speechSynthesis.speak(speech)
- while (count < repeatNum) {
- speechSynthesis.speak(speech)
- count++
- }
}
</script>
@@ -90,7 +112,7 @@
</el-table-column>
</el-table>
</el-main>
- <el-footer>
+ <el-footer height="100px">
<el-table
:data="listPassed"
stripe
--
Gitblit v1.9.3