|
|
@ -116,7 +116,7 @@ import {mixinDevice} from '@/utils/mixin' |
|
|
|
import {JeecgListMixin} from '@/mixins/JeecgListMixin' |
|
|
|
import {JeecgListMixin} from '@/mixins/JeecgListMixin' |
|
|
|
import ZySpeechMessageModal from './modules/ZySpeechMessageModal' |
|
|
|
import ZySpeechMessageModal from './modules/ZySpeechMessageModal' |
|
|
|
import Speech from 'speak-tts' |
|
|
|
import Speech from 'speak-tts' |
|
|
|
import {getAction} from "@api/manage"; |
|
|
|
import {getAction, putAction} from "@api/manage"; |
|
|
|
|
|
|
|
|
|
|
|
export default { |
|
|
|
export default { |
|
|
|
name: 'ZySpeechMessageList', |
|
|
|
name: 'ZySpeechMessageList', |
|
|
@ -175,51 +175,57 @@ export default { |
|
|
|
], |
|
|
|
], |
|
|
|
url: { |
|
|
|
url: { |
|
|
|
list: "/org.jeecg.modules.message/zySpeechMessage/list", |
|
|
|
list: "/org.jeecg.modules.message/zySpeechMessage/list", |
|
|
|
|
|
|
|
edit: "/org.jeecg.modules.message/zySpeechMessage/edit", |
|
|
|
getMessageList: "/org.jeecg.modules.message/zySpeechMessage/getMessageList", |
|
|
|
getMessageList: "/org.jeecg.modules.message/zySpeechMessage/getMessageList", |
|
|
|
delete: "/org.jeecg.modules.message/zySpeechMessage/delete", |
|
|
|
delete: "/org.jeecg.modules.message/zySpeechMessage/delete", |
|
|
|
deleteBatch: "/org.jeecg.modules.message/zySpeechMessage/deleteBatch", |
|
|
|
deleteBatch: "/org.jeecg.modules.message/zySpeechMessage/deleteBatch", |
|
|
|
exportXlsUrl: "/org.jeecg.modules.message/zySpeechMessage/exportXls", |
|
|
|
exportXlsUrl: "/org.jeecg.modules.message/zySpeechMessage/exportXls", |
|
|
|
importExcelUrl: "org.jeecg.modules.message/zySpeechMessage/importExcel", |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}, |
|
|
|
}, |
|
|
|
dictOptions: {}, |
|
|
|
dictOptions: {}, |
|
|
|
superFieldList: [], |
|
|
|
superFieldList: [], |
|
|
|
// 本次定时获取到到语言播报消息列表 |
|
|
|
|
|
|
|
messageList: [], |
|
|
|
speech: null, |
|
|
|
// 定时器ID |
|
|
|
// 定时器ID |
|
|
|
timer: null, |
|
|
|
timer: null, |
|
|
|
// 定时器周期 |
|
|
|
// 定时器周期 |
|
|
|
millisec: 30000, |
|
|
|
millisec: 20000, |
|
|
|
|
|
|
|
/* 数据源 */ |
|
|
|
|
|
|
|
messageList: [], |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
created() { |
|
|
|
|
|
|
|
// this.getMessageList(); |
|
|
|
mounted() { |
|
|
|
// this.getSuperFieldList(); |
|
|
|
this.speechInit(); |
|
|
|
}, |
|
|
|
this.openTimer() |
|
|
|
computed: { |
|
|
|
|
|
|
|
importExcelUrl: function () { |
|
|
|
|
|
|
|
return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`; |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
}, |
|
|
|
}, |
|
|
|
// mounted() { |
|
|
|
|
|
|
|
// this.speechInit(); |
|
|
|
|
|
|
|
// this.openTimer() |
|
|
|
|
|
|
|
// }, |
|
|
|
|
|
|
|
methods: { |
|
|
|
methods: { |
|
|
|
speechInit() { |
|
|
|
speechInit() { |
|
|
|
this.speech = new Speech(); |
|
|
|
this.speech = new Speech(); |
|
|
|
this.speech.setLanguage('zh-CN'); |
|
|
|
if (this.speech.hasBrowserSupport()) { // returns a boolean |
|
|
|
this.speech.init().then(() => { |
|
|
|
console.log(">>>this browser,supported TTS") |
|
|
|
console.log('语音播报初始化完成...') |
|
|
|
} else { |
|
|
|
// this.MySpeak(); |
|
|
|
console.log("XXX----------------------sorry,this browser,not supported TTS!!!") |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
this.speech.init({ |
|
|
|
|
|
|
|
'volume': 1, |
|
|
|
|
|
|
|
'lang': 'zh-CN', |
|
|
|
|
|
|
|
'rate': 1, |
|
|
|
|
|
|
|
'pitch': 1, |
|
|
|
|
|
|
|
'splitSentences': true, |
|
|
|
|
|
|
|
}).then((conf) => { |
|
|
|
|
|
|
|
console.log('>>>语音播报初始化完成...,Speech配置参数:', conf) |
|
|
|
|
|
|
|
}).catch(e => { |
|
|
|
|
|
|
|
console.error("XXX------------------------An error occured while init : ", e) |
|
|
|
}) |
|
|
|
}) |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
//语音播报 |
|
|
|
//语音播报 |
|
|
|
MySpeak(message) { |
|
|
|
MySpeak(obj) { |
|
|
|
console.log("MySpeak()接受到的消息:" + message) |
|
|
|
let mess = obj['message']; |
|
|
|
|
|
|
|
console.log("----------speak()接受到的消息-----------【" + mess + "】"); |
|
|
|
this.speech.speak({ |
|
|
|
this.speech.speak({ |
|
|
|
text: message, |
|
|
|
text: mess, |
|
|
|
listeners: { |
|
|
|
listeners: { |
|
|
|
//开始播放 |
|
|
|
//开始播放 |
|
|
|
onstart: () => { |
|
|
|
onstart: () => { |
|
|
@ -227,7 +233,9 @@ export default { |
|
|
|
}, |
|
|
|
}, |
|
|
|
//判断播放是否完毕 |
|
|
|
//判断播放是否完毕 |
|
|
|
onend: () => { |
|
|
|
onend: () => { |
|
|
|
console.log("End utterance"); |
|
|
|
// console.log("End utterance"); |
|
|
|
|
|
|
|
console.log("------------delete----------【" + mess + "】消息播报完成,删除该消息") |
|
|
|
|
|
|
|
this.updateMessageStatus(obj['id']); |
|
|
|
}, |
|
|
|
}, |
|
|
|
//恢复播放 |
|
|
|
//恢复播放 |
|
|
|
onresume: () => { |
|
|
|
onresume: () => { |
|
|
@ -235,25 +243,22 @@ export default { |
|
|
|
}, |
|
|
|
}, |
|
|
|
}, |
|
|
|
}, |
|
|
|
}).then(() => { |
|
|
|
}).then(() => { |
|
|
|
console.log("MySpeak()播报完成...") |
|
|
|
// console.log("消息" + obj['id'] + "播报完成") |
|
|
|
}) |
|
|
|
}) |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
async getMessageList() { |
|
|
|
getMessageList() { |
|
|
|
let parma = { |
|
|
|
let parma = { |
|
|
|
"status": '0', |
|
|
|
"status": '0', |
|
|
|
} |
|
|
|
} |
|
|
|
let messageIds = []; |
|
|
|
|
|
|
|
getAction(this.url.list, parma).then((res) => { |
|
|
|
getAction(this.url.list, parma).then((res) => { |
|
|
|
if (res.success) { |
|
|
|
if (res.success) { |
|
|
|
console.log("文字转语音消息列表>:" + JSON.stringify(res.result)); |
|
|
|
console.log("------------getMessageList----------文字转语音消息列表>>>:" + JSON.stringify(res.result.records)); |
|
|
|
res.result.records.forEach(obj => { |
|
|
|
this.messageList = res.result.records; |
|
|
|
// this.MySpeak(obj['message']); |
|
|
|
this.messageList.forEach(obj => { |
|
|
|
// messageIds.push(obj['id']); |
|
|
|
if (obj['status'] === '0') { |
|
|
|
this.speech.speak({text: obj['message']}).then(() => { |
|
|
|
this.MySpeak(obj); |
|
|
|
// alert("MySpeak()播报完成..."); |
|
|
|
} |
|
|
|
console.log("MySpeak()播报完成...") |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
}) |
|
|
|
}) |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
this.$message.warning(res.message) |
|
|
|
this.$message.warning(res.message) |
|
|
@ -264,14 +269,39 @@ export default { |
|
|
|
}) |
|
|
|
}) |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
updateMessageStatus(id) { |
|
|
|
|
|
|
|
// console.log("删除已播报消息:" + id); |
|
|
|
|
|
|
|
let parma = { |
|
|
|
|
|
|
|
"id": id, |
|
|
|
|
|
|
|
"status": '1', |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
putAction(this.url.edit, parma).then((res) => { |
|
|
|
|
|
|
|
if (res.success) { |
|
|
|
|
|
|
|
for (let i = 0; i < this.messageList.length; i++) { |
|
|
|
|
|
|
|
if (this.messageList[i].id === id) { |
|
|
|
|
|
|
|
//消息删除成功,从datasource队列中删除消息 |
|
|
|
|
|
|
|
this.messageList.splice(i, 1); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
this.$message.warning(res.message) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
openTimer() { |
|
|
|
openTimer() { |
|
|
|
this.closeTimer() |
|
|
|
this.closeTimer() |
|
|
|
|
|
|
|
console.log(">>>timer初始化完成【" + new Date().toLocaleString() + "】,---执行周期: " + this.millisec + " 毫秒") |
|
|
|
|
|
|
|
//上次播报列表播报完后,再获取新数据 |
|
|
|
this.timer = setInterval(() => { |
|
|
|
this.timer = setInterval(() => { |
|
|
|
// if (this.$route.path === this.path) { |
|
|
|
console.log("---未播报消息数量:", this.messageList.length) |
|
|
|
// this.loadData() |
|
|
|
// console.log("the messageList:", JSON.stringify(this.messageList)); |
|
|
|
// } |
|
|
|
if (this.messageList.length === 0) { |
|
|
|
|
|
|
|
console.log("--------timer is exec,the current time:" + new Date().toLocaleString()) |
|
|
|
this.getMessageList(); |
|
|
|
this.getMessageList(); |
|
|
|
console.log("the time is running,the current time:" + new Date().toLocaleString()) |
|
|
|
} else { |
|
|
|
|
|
|
|
console.log("-------上次消息列表未处理完---HOLD DOWN") |
|
|
|
|
|
|
|
} |
|
|
|
}, this.millisec) |
|
|
|
}, this.millisec) |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
@ -279,7 +309,25 @@ export default { |
|
|
|
closeTimer() { |
|
|
|
closeTimer() { |
|
|
|
if (this.timer) clearInterval(this.timer) |
|
|
|
if (this.timer) clearInterval(this.timer) |
|
|
|
}, |
|
|
|
}, |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//暂停 |
|
|
|
|
|
|
|
paused() { |
|
|
|
|
|
|
|
this.speech.pause(); |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
//从暂停处继续播放 |
|
|
|
|
|
|
|
goahead() { |
|
|
|
|
|
|
|
this.speech.resume(); |
|
|
|
|
|
|
|
console.log("继续播放-----------------------------") |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//离开页面取消语音 |
|
|
|
|
|
|
|
destroyed() { |
|
|
|
|
|
|
|
console.log("-----------关闭Timer、Speech---------------") |
|
|
|
|
|
|
|
this.closeTimer(); |
|
|
|
|
|
|
|
this.speech.cancel(); |
|
|
|
|
|
|
|
}, |
|
|
|
} |
|
|
|
} |
|
|
|
</script> |
|
|
|
</script> |
|
|
|
<style scoped> |
|
|
|
<style scoped> |
|
|
|