vue2+TS获取到数据后自动叫号写法
1.父组件写法
初始化:
//引入子组件 <odialog ref="odialogRef" @onSure="onSurea"></odialog> //子传父private onSurea() {// 初始化信息/重新叫号来的数据this.initTabelData()setTimeout(() => {// 播放声音的数据this.searchCallInfo()}, 2000)}activated() {// 初始化信息/重新叫号来的数据this.initTabelData()// 播放声音的数据this.searchCallInfo()}// 一开始进入的时候激活一下,表格的数据private async initTabelData() {let res = await getCallInfo()this.tableData = res}// 一开始进入的时候激活一下private async searchCallInfo() {try {//需要播报的文字数据let res = await getALLCallText()// 如果有数据if (res.data !== '') {clearTimeout(this.timer)// 打开弹窗播放数据;(this.$refs.odialogRef as any).openDialog(res)} else {// 如果没有数据,5秒后获取一次表格所有数据this.timer = setTimeout(() => {this.initTabelData()console.log('(((((((((((((((((((((((((((((获取数据)))))))))))))))))))))))))))))')// 播放声音的数据this.searchCallInfo()}, 10000)}} catch (error) {this.$message({message: error,type: 'error'})}}
2.子组件写法
template写法:
<template><el-dialog :show-close="false" title="叫号显示" :visible.sync="customerDialogVisible" top="200px" width="40%" center :close-on-click-modal="false"destroy-on-close append-to-body><div class="details"><div style="font-size:50px" @click="playVoice" id="playVoiceButton">{{carName}}</div><div style="font-size:50px" @click="playVoice" id="playVoiceButton">{{detail}}</div><!-- <div v-else>没有叫号数据!</div> --><!-- <div style="font-size:50px" v-if="this.text==''">没有叫号数据!</div> --></div></el-dialog></template>
方法:
// 车牌号private carName: string = ''// 鹤位地点private detail: string = ''// dialog打开后携带需要播报的数据private async openDialog(data) {this.callTextInfo = data// 截取文字let str = data.split(' ')this.detail = str[str.length - 1]this.carName = str[str.length - 3]this.customerDialogVisible = trueawait this.$nextTick()// 播放声音await this.playVoice()}//播放声音private async playVoice() {// 四秒后播放一次声音this.handleSpeak(this.callTextInfo)await setTimeout(() => {this.handleSpeak(this.callTextInfo)}, 4000)// 播放声音十秒后关闭await setTimeout(() => {this.customerDialogVisible = falsethis.onSure(null)}, 10000)}//刷新@Emit('onSure')private onSure(row: any) {}
3.全部写法:
//父组件:
<template><div class="fullScreenBox"><!-- <el-button type="primary" v-if="fullScreenSwitch" @click="fullScreenFn">全 屏</el-button><el-button type="primary" v-else @click="goBack">退 出</el-button> --><xTable ref="xtable" :tableData="tableData" :tablePage="tablePage" :showSearchBox="false" :isShowPage="false" :showOperationBtn="true" :tableConfigure="tableConfigure" :showClearSearchInfoBtn="false"><template #optionBtns><div class="operationBtnBox"><el-row><el-button type="primary" v-if="fullScreenSwitch" @click="fullScreenFn"><div><p style="color:#fff">全 屏</p></div></el-button><el-button type="primary" v-else @click="goBack"><div><p style="color:#fff">退 出</p></div></el-button></el-row></div></template><template v-slot:columns><vxe-column type="seq" width="50px" align="center"></vxe-column><vxe-column field="carNumber" title="车牌号" width="6.6%" align="center"></vxe-column><vxe-column field="driverName" title="驾驶员姓名" width="6.6%" align="center"></vxe-column><vxe-column field="pickUpNo" title="提货单号" width="6.6%" align="center"></vxe-column><vxe-column field="createTime" title="入场时间" width="6.6%" align="center"></vxe-column><vxe-column field="equDao" title="岛" width="6.6%" align="center"></vxe-column><vxe-column field="equName" title="鹤位名称" width="6.6%" align="center"></vxe-column><vxe-column field="state" title="状态" width="6.6%" align="center"></vxe-column></template></xTable><odialog ref="odialogRef" @onSure="onSurea"></odialog></div>
</template><script lang="ts">
import { Component, Prop, Vue, Emit, Watch } from 'vue-property-decorator'
import PageBase from '@src/views/PageBase'
import { Route } from 'vue-router'
import { getCallInfo, getALLCallText } from '../../../deliverPetroleum_apis/index_api'
import odialog from './opendialog.vue'
import dateRangePicker from '@src/components/TimePickr/dateRangePicker.vue'
import moment from 'moment'
import xTable from '@src/components/TableBase/baseTable.vue'
/***贮运厂总览 */
@Component({// previewDialog,components: { xTable, dateRangePicker, odialog },name: 'mapView'
})
export default class Index extends PageBase {mounted() {// this.time()}activated() {// 初始化信息/重新叫号来的数据this.initTabelData()// 播放声音的数据this.searchCallInfo()}private timer: any = nulldeactivated() {clearTimeout(this.timer)}// private async searchCallInfo() {// try {// let res = await getALLCallText()// // 如果有数据// if (res) {// // clearTimeout(this.timer)// // 打开弹窗播放数据// ;(this.$refs.odialogRef as any).openDialog(res)// } else {// // // 如果没有数据,每隔十秒获取一次所有数据// // this.timer = setTimeout(() => {// // this.initTabelData()// // // 播放声音的数据// // this.searchCallInfo()// // }, 10000)// }// } catch (error) {// this.$message({// message: error,// type: 'error'// })// }// }private fullScreenSwitch: boolean = true// 全屏private async fullScreenFn() {$('.fullScreenBox').css({ position: 'fixed', top: '0px', left: '0px' })this.fullScreenSwitch = !this.fullScreenSwitch}private async goBack() {$('.fullScreenBox').css({ position: 'relative' })this.fullScreenSwitch = !this.fullScreenSwitch}// 一开始进入的时候激活一下private async initTabelData() {let res = await getCallInfo()this.tableData = res// 处理一下状态this.tableData.forEach((item1) => {this.options.forEach((item2) => {if (item1.state == item2.value) {item1.state = item2.label}})})}// 一开始进入的时候激活一下private async searchCallInfo() {try {let res = await getALLCallText()// 如果有数据if (res.data !== '') {clearTimeout(this.timer)// 打开弹窗播放数据;(this.$refs.odialogRef as any).openDialog(res)} else {// 如果没有数据,5秒后获取一次所有数据this.timer = setTimeout(() => {this.initTabelData()console.log('(((((((((((((((((((((((((((((获取数据)))))))))))))))))))))))))))))')// 播放声音的数据this.searchCallInfo()}, 10000)}} catch (error) {this.$message({message: error,type: 'error'})}}private tablePage: any = {total: 0,currentPage: 1,pageSize: 10}private onSurea() {// 初始化信息/重新叫号来的数据this.initTabelData()setTimeout(() => {// 播放声音的数据this.searchCallInfo()}, 2000)}private tableData: any[] = []private printName: string = ''private tableConfigure: any = {tableTitle: '叫号信息',imgSrc: 'queuing'}private queryCondition: any = {time: [moment(new Date()).format('YYYY-MM-DD HH:mm:ss'),moment(new Date()).add(1, 'days').format('YYYY-MM-DD HH:mm:ss')],carNumber: '',start: '全部'}private options: any[] = [{value: '全部',label: '全部'},{value: 2,label: '已入库'},{value: 0,label: '待呼叫'},{value: 1,label: '呼叫中'},{value: -1,label: '已取消'}]// 初始化数据
}
</script>
<style lang="less" scoped>
/deep/.vxe-table--body-wrapper.body--wrapper {height: calc(95% - 0px);
}
/deep/span.span_button {cursor: pointer;text-decoration: underline;color: var(--lyl_addBtnAndLogoColor) !important;
}
/deep/.input-box.el-row {padding-left: 1%;
}
/deep/.table-box {height: calc(100% - 44px) !important;
}
/deep/.el-col.el-col-8 {padding-left: 20px;
}
.fullScreenBox {height: 100%;width: 100%;
}
</style>
//子组件
<template><el-dialog :show-close="false" title="叫号显示" :visible.sync="customerDialogVisible" top="200px" width="40%" center :close-on-click-modal="false"destroy-on-close append-to-body><div class="details"><div style="font-size:50px" @click="playVoice" id="playVoiceButton">{{carName}}</div><div style="font-size:50px" @click="playVoice" id="playVoiceButton">{{detail}}</div><!-- <div v-else>没有叫号数据!</div> --><!-- <div style="font-size:50px" v-if="this.text==''">没有叫号数据!</div> --></div></el-dialog></template>
<script lang="ts">
import { Component, Prop, Vue, Emit, Watch } from 'vue-property-decorator'
import PageBase from '@src/views/PageBase'
import { Route } from 'vue-router'
import dialog from './dialog.vue'
import dateRangePicker from '@src/components/TimePickr/dateRangePicker.vue'
import moment from 'moment'
import xTable from '@src/components/TableBase/baseTable.vue'
// import { setInterval } from 'timers/promises'
const synth = window.speechSynthesis
const msg = new SpeechSynthesisUtterance()
/***贮运厂总览 */
@Component({// previewDialog,components: { xTable, dateRangePicker }
})
export default class Index extends PageBase {// dialog开关private customerDialogVisible: boolean = falsemounted() {}// 车牌号private carName: string = ''// 鹤位地点private detail: string = ''// 呼叫文本信息private callTextInfo: string = ''// dialog打开后携带需要播报的数据private async openDialog(data) {this.callTextInfo = data// 一打开弹窗获得的数据// await this.getALLCallText()// 截取文字let str = data.split(' ')this.detail = str[str.length - 1]this.carName = str[str.length - 3]this.customerDialogVisible = trueawait this.$nextTick()// 播放声音await this.playVoice()}//播放声音private async playVoice() {// 四秒后播放一次声音this.handleSpeak(this.callTextInfo)await setTimeout(() => {this.handleSpeak(this.callTextInfo)}, 4000)// 播放声音六秒后刷新显示数据,两秒后获取新的需要播放的数据await setTimeout(() => {this.customerDialogVisible = falsethis.onSure(null)}, 10000)}//刷新@Emit('onSure')private onSure(row: any) {}// 语音播报的函数private handleSpeak(text) {msg.text = text // 文字内容: 小朋友,你是否有很多问号msg.lang = 'zh-CN' // 使用的语言:中文msg.volume = 1 // 声音音量:1msg.rate = 1 // 语速:1msg.pitch = 1 // 音高:1synth.speak(msg) // 播放}
}
</script>
<style lang="less" scoped>
/deep/ .el-dialog--center .el-dialog__body {text-align: initial;padding: 25px 25px 30px;height: 30%;
}
.details {position: absolute;top: 50%;left: 50%;transform: translate(-50%, -50%);
}
</style>
相关文章:
vue2+TS获取到数据后自动叫号写法
1.父组件写法 初始化: //引入子组件 <odialog ref"odialogRef" onSure"onSurea"></odialog> //子传父private onSurea() {// 初始化信息/重新叫号来的数据this.initTabelData()setTimeout(() > {// 播放声音的数据this.search…...
28、架构-边界:微服务的粒度
微服务的粒度 在设计微服务架构时,确定微服务的粒度是一个关键问题。粒度过大或过小都会带来不同的问题,因此需要找到合理的粒度来划分微服务。下面详细探讨微服务粒度的合理范围及其影响因素。 1. 微服务粒度的上下界 微服务的粒度不应该只有唯一正确…...
开源API网关-ApacheShenYu首次按照启动遇到的问题
一.背景 公司有API网关产品需求,希望有图形化的后台管理功能。看到了ApacheShenYu,作为Apache的顶级项目,直接认可了。首先,感谢各位大神的付出,初步看这个项目是国内大厂中的大神创立的,在此表示膜拜&…...
uniapp获取证书秘钥、Android App备案获取公钥、签名MD5值
一、 uniapp获取证书秘钥 打开uniapp开发者中心下载证书打开cmd输入以下这段代码,下载提供查看到的密钥证书密码就可以了!下载证书在 java 环境下运行才可以 // your_alias 换成 证书详情中的别名,your_keystore.keystore 改成自己的证书文件…...
QT 如何储存多种数据类型(QVariant )
QVariant 是 Qt 框架中用于存储各种数据类型的类。它提供了一个强大的类型系统,允许你在运行时存储和检索多种类型的数据,而不需要在编译时确定类型。QVariant 的主要优点在于它的灵活性和通用性,这使得它在 Qt 的很多组件和机制中都被广泛使…...
持续总结中!2024年面试必问的操作系统面试题(九)
上一篇地址:持续总结中!2024年面试必问的操作系统面试题(八)-CSDN博客 十七、解释什么是操作系统的安全性和它的重要性。 操作系统的安全性(Operating System Security)是指操作系统采取的一系列措施来保…...
操作系统入门 -- 文件管理
操作系统入门 – 文件管理 1.文件管理概述 1.1 文件系统基本功能 目前,计算机内存的容量依然有限,并且其特性决定了数据无法长时间保存,因此把执行的数据以文件形式保存在外存中,等到需要使用时再调入内存。所以,操…...
由浅入深,走进深度学习(2)
今天分享的学习内容主要就是神经网络里面的知识啦,用到的框架就是torch 在这里我也是对自己做一个学习记录,如果不符合大家的口味,大家划走就可以啦 可能没有什么文字或者原理上的讲解,基本上都是代码,但是我还是想说…...
【Python Tips】创建自己的函数包并安装进Anaconda,像引入标准包一样直接import导入
目录 一、引言 二、方法步骤 步骤一:创建包目录结构 步骤二:配置__init__.py文件 步骤三:文件夹外配置setup.py文件 步骤四:终端Pip安装 三、结尾 一、引言 在编写项目代码的时候,有些自定义功能的函数是可以复用的。…...
【Python机器学习实战】 | 基于支持向量机(Support Vector Machine, SVM)进行分类和回归任务分析
🎩 欢迎来到技术探索的奇幻世界👨💻 📜 个人主页:一伦明悦-CSDN博客 ✍🏻 作者简介: C软件开发、Python机器学习爱好者 🗣️ 互动与支持:💬评论 &…...
备份和还原
stai和dnta snat:源地址转换 内网---外网 内网ip转换成可以访问外网的ip 内网的多个主机可以使用一个有效的公网ip地址访问外部网络 DNAT:目的地址转发 外部用户,可以通过一个公网地址访问服务内部的私网服务。 私网的ip和公网ip做一个…...
Java数组的初始化方法
Java数组的初始化方法 大家好,我是免费搭建查券返利机器人省钱赚佣金就用微赚淘客系统3.0的小编,也是冬天不穿秋裤,天冷也要风度的程序猿!在Java编程中,数组是一种非常基础也非常重要的数据结构,它能够存储…...
通过分离有色和无色pdf页面减少打印费
前言 该工具是我认识的一位中科大的大佬在本科毕业的时候做的一个小工具,去打印店打印全彩的毕业论文的话会比较贵,他想到有没有一种方案可以实现有彩色页面的pdf和没有彩色页面的pdf分开打印,前者打印彩色,后者打印黑白…...
c语言--指针
前言 欢迎来到我的博客 个人主页:北岭敲键盘的荒漠猫-CSDN博客 本文整理c语言中指针的相关知识点。 指针概念 指针存储的就是数据的地址。 直观理解: 李华家是北洋路130号1单元101 用变量处理数据: 我们去李华家拿数据。 用指针处理数据: 我们去北洋路130号1单元101拿数据…...
python-九九乘法表(对齐式1)
[题目描述] 输出九九乘法表,输出格式见样例。输入格式: 无输出格式: 输出乘法表,对齐方式见样例输出。样例输入 无样例输出 来源/分类(难度系数:一星) 完整代码展示: #对齐式1 a[] …...
thinkphp单独为某个接口设置缓存
参考 官方文档 $this->request->cache(__URL__,600);只需要在接口方法的开头添加这个代码即可...
OpenCV视觉--视频人脸微笑检测(超详细,附带检测资源)
目录 概述 具体实现 1.加载分类器 2.打开摄像头并识别人脸 3.处理人脸并检测是否微笑 效果 总结 概述 OpenCV(Open Source Computer Vision Library)是一个开源的计算机视觉和机器学习库,广泛应用于图像处理和视频分析等领…...
docker 搭建 AI大数据模型 --- 使用GPU
docker 搭建 AI大数据模型 — 使用GPU方式 搭建本地大模型,最简单的方法!效果直逼GPT 服务器GPU系统HP580 G8P40Rocky9.2 安装程序AnythingLLM前端界面Open WebUIChatOllamaollama 一、AnythingLLM 介绍 AnythingLLM 是 Mintplex Labs Inc. 开发的一…...
面向对象, 常用类, 集合, 异常, JDBC, mysql数据库 复习
1.面向对象 (1)面向过程和面向对象 ● 面向过程的程序设计思想 (procedure -Oriented Programming),简称POP ● 关注的焦点是过程:过程就是操作数据的步骤。如果某个过程的实现代码重复出 现,那么就可…...
js取数组最大值之Math.max、Math.max.apply
js取数组最大值之Math.max、Math.max.apply Math.maxMath.max.applyapply()第一个参数为什么可以是null 最小值同理 Math.max Math.max(n1,n2,n3,…,nX) 支持传递多个参数,带有较大的值的那个数 Math.max(2,5,3,6,2,4,2,15,9,6,0,1)Math.max.apply apply() 语法&a…...
为机械臂视觉抓取做准备:在Ubuntu 18.04上配置ROS+YOLOv5运行环境的完整避坑清单
为机械臂视觉抓取做准备:在Ubuntu 18.04上配置ROSYOLOv5运行环境的完整避坑清单 当机械臂遇上YOLOv5,视觉抓取的能力边界将被重新定义。但在这之前,开发者需要跨越环境配置的"死亡之谷"——特别是当Ubuntu 18.04、ROS Melodic和PyT…...
C语言基础:Anything to RealCharacters 2.5D引擎核心算法解析
C语言基础:Anything to RealCharacters 2.5D引擎核心算法解析 1. 引言 如果你对图像处理感兴趣,特别是想把卡通或二次元角色转换成逼真的真人形象,那么Anything to RealCharacters 2.5D引擎绝对值得深入了解。这个引擎背后的算法原理其实并…...
Z-Image-Turbo-辉夜巫女开发者案例:对接Stable Diffusion WebUI插件生态的兼容方案
Z-Image-Turbo-辉夜巫女开发者案例:对接Stable Diffusion WebUI插件生态的兼容方案 1. 引言:当定制模型遇上主流生态 如果你是一位AI绘画的开发者或爱好者,手里有一个精心调校的、专门生成“辉夜巫女”风格的文生图模型,你可能会…...
Dgraph索引选择终极指南:查询模式与索引类型完美匹配
Dgraph索引选择终极指南:查询模式与索引类型完美匹配 【免费下载链接】dgraph The high-performance database for modern applications 项目地址: https://gitcode.com/gh_mirrors/dg/dgraph Dgraph作为现代应用的高性能图数据库,其索引系统是查…...
开源音效引擎:用Equalizer APO打造专业级音频体验
开源音效引擎:用Equalizer APO打造专业级音频体验 【免费下载链接】equalizerapo Equalizer APO mirror 项目地址: https://gitcode.com/gh_mirrors/eq/equalizerapo 在数字音频处理领域,音效调节、音频优化一直是专业用户和发烧友追求的核心目标…...
OpenClaw从入门到应用——安装:更新OpenClaw
通过OpenClaw实现副业收入:《OpenClaw赚钱实录:从“养龙虾“到可持续变现的实践指南》 推荐方式:重新运行网站安装程序(原地升级) 首选的更新方式是重新运行官网提供的安装脚本。该脚本会自动检测现有安装࿰…...
LinuxMint 22.1(Ubuntu24.04)下通过Wine完美运行同花顺远航版的实战指南
1. 为什么要在LinuxMint上运行同花顺远航版 作为一个长期使用Linux系统的投资者,我深知在Linux平台上找到一款功能完善的行情软件有多难。同花顺Linux原生版虽然能用,但功能停留在基础行情展示,而且自2022年起就停止了更新。这对于习惯使用Wi…...
Emergency Mode Troubleshooting: A Comprehensive Guide to Fixing System Boot Failures with journalctl
1. 紧急模式入门:当系统启动失败时该怎么办 那天早上我正准备部署一个关键服务,结果服务器突然卡在启动界面,屏幕上赫然显示"Welcome to emergency mode!"。作为运维老手,我立刻意识到这是Linux系统最后的自我保护机制…...
基于FPGA与DDS IP核的线性调频信号优化设计
1. DDS技术核心原理与FPGA实现优势 直接数字频率合成(DDS)技术就像一台精密的数字式信号发生器,它通过相位累加器和波形查找表这两个核心部件来生成任意频率的波形。想象一下钟表的分针转动:相位累加器相当于记录分针位置的齿轮&…...
三相LCL型并网逆变器:电容电流反馈与全前馈电网电压控制策略研究,谐波THD优化至5%以下的相...
三相lcl型并网逆变器控制策略 电容电流反馈和电网电压全前馈,加入5.7.11.13次谐波thd<5。 相关方面电力电气工程,电子信息工程等等都可以。最近在调试三相LCL并网逆变器时发现个有意思的现象:当电网背景谐波严重时,常规…...
