当前位置: 首页 > news >正文

大屏使用dv-digital-flop定时刷新显示总人数

本文在基础上进行改进,后端使用若依后端IofTV-Screen: 🔥一个基于 vue、datav、Echart 框架的物联网可视化(大屏展示)模板,提供数据动态刷新渲染、屏幕适应、数据滚动配置,内部图表自由替换、Mixins注入等功能,持续更新.... - Gitee.com

1.效果:将系统总人数统计显示到大屏

1. 使用dv-digital-flop组件

 <dv-digital-flop :config="config1" style="width:100%;height:100%;" />

number中的元素将被用于替换content内容模版中的{nt}标记,其替换顺序与模版标记的顺序一一对应:

 config1: {
          number: [],
          content: '{nt}',
          style: {
            ...style,
            fill: "#00fdfa",
          },
        }

2. 获取数据并显示

 //统计人数
        countUsers().then(res=> {

          if (!this.timer) {
            console.log("统计人数", res);
          }
          if (res.code == 200) {
          this.countUsers = res.countUsers;
          this.config1 = {
            ...this.config1,
            number: [this.countUsers]
          } }
        })

3. 使用定时器轮询刷新

      //轮询
      switper() {
        if (this.timer) {
          return
        }
        let looper = (a) => {
           this.getData()
        };
        this.timer = setInterval(looper, this.$store.state.settings.echartsAutoTime);
      }

其中this.$store.state.settings.echartsAutoTime可替换成3000

4. user.js增加api

// 查询用户数
export function countUsers() {return request({url: '/system/user/countUsers',method: 'get'})
}

5. 增加controller后端方法

/*** 获取用户数*/@GetMapping("/countUsers")
public AjaxResult countUsers()
{AjaxResult ajax = AjaxResult.success();Integer count = userService.countUsers();ajax.put("countUsers", count);return ajax;
}

6. mapper.xml

<select id="countUsers"  resultType="Integer">select count(1) from sys_user where del_flag='0'
</select>

7. 最终代码

<template><ul class="user_Overview flex" v-if="pageflag"><li class="user_Overview-item" style="color: #00fdfa"><div class="user_Overview_nums allnum "><dv-digital-flop :config="config1" style="width:100%;height:100%;" /></div><p>总人数</p></li></ul><Reacquire v-else @onclick="getData" line-height="200px">重新获取</Reacquire>
</template><script>
import { countUsers } from "@/api/system/user";let style = {fontSize: 24}export default {data() {return {// 人员总数countUsers: 0,pageflag: true,timer: null,config1: {number: [],content: '{nt}',style: {...style,fill: "#00fdfa",},}};},created() {this.getData()},mounted() {},beforeDestroy() {this.clearData()},methods: {clearData() {if (this.timer) {clearInterval(this.timer)this.timer = null}},getData() {this.pageflag = true;//统计人数countUsers().then(res=> {if (!this.timer) {console.log("统计人数", res);}if (res.code == 200) {this.countUsers = res.countUsers;this.config1 = {...this.config1,number: [this.countUsers]} }})this.switper()},//轮询switper() {if (this.timer) {return}let looper = (a) => {this.getData()};this.timer = setInterval(looper, this.$store.state.settings.echartsAutoTime);},},};</script>
<style lang='scss' scoped>.user_Overview {li {flex: 1;p {text-align: center;height: 16px;font-size: 16px;}.user_Overview_nums {width: 100px;height: 100px;text-align: center;line-height: 100px;font-size: 22px;margin: 50px auto 30px;background-size: cover;background-position: center center;position: relative;&::before {content: '';position: absolute;width: 100%;height: 100%;top: 0;left: 0;}&.bgdonghua::before {animation: rotating 14s linear infinite;}}.allnum {// background-image: url("../../assets/img/left_top_lan.png");&::before {background-image: url("../../../assets/bigScreen/img/left_top_lan.png");}}}}</style>

 

 

http://www.lryc.cn/news/45571.html

相关文章:

  • Java面向对象部分 个人学习记录
  • MySQL数据库——对Linux MySQL软件包的一些说明
  • 【JavaEE进阶】——第二节.Spring核心和设计思想
  • twitter开源算法(1)For You推荐系统架构
  • A General Framework for Uncertainty Estimation in Deep Learning源码阅读(二)
  • 串行通信协议---HART协议
  • 【独家】华为OD机试 - 寻找密码(C 语言解题)
  • FPGA有哪些优质的带源码的IP开源网站?
  • 基于模型预测控制(MPC)的微电网调度优化的研究(Matlab代码实现)
  • Postman接口测试之Mock快速入门
  • 分享一个国内可用的免费ChatGPT网站
  • 15. 三数之和(Java)
  • Navicat Premium 16安装教程
  • 蓝桥杯刷题冲刺 | 倒计时8天
  • 四.JAVA基础面试题:重要知识
  • 某面试官分享经验:看求职者第一眼,开口说第一句话,面试结果就差不多定了,准确率高达90%以上...
  • Java开发 - 消息队列之RabbitMQ初体验
  • 蓝桥杯入职项目(HTML + springBoot)
  • 【IAR工程】STM8S208RB基于ST标准库下按键检测
  • 【5】深度学习之Pytorch——如何使用张量处理文本数据集(语料库数据集)
  • 《Spring系列》第5章 refresh()
  • ThreeJS-缩放、旋转(四)
  • 数据更新 | CnOpenData法拍房数据
  • 【Spring从成神到升仙系列 五】从根上剖析 Spring 循环依赖
  • 设计模式之代理模式(C++)
  • c++11 标准模板(STL)(std::unordered_multimap)(三)
  • Linux进程控制-2
  • 快速排序算法
  • 中华好诗词大学季第二季(四)
  • 分布式系统容灾部署方案