From a2750e71a4b0298835a7f7f4c10777f4f20797a8 Mon Sep 17 00:00:00 2001 From: fanluyan <754122931@qq.com> Date: Wed, 17 Jan 2024 09:55:12 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E9=A2=84=E4=BC=B0=E6=97=B6?= =?UTF-8?q?=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Sidebar.vue | 8 +-- src/views/homePage/components/tableMain.vue | 22 +++++--- src/views/homePage/index.vue | 23 +++++++-- src/views/report/index.vue | 56 +++++++++++++++++++-- 4 files changed, 91 insertions(+), 18 deletions(-) diff --git a/src/components/Sidebar.vue b/src/components/Sidebar.vue index d92f45b..9938c08 100644 --- a/src/components/Sidebar.vue +++ b/src/components/Sidebar.vue @@ -33,10 +33,10 @@ export default { path: "/activity", name: "活动列表", }, - { - path: "/userlist", - name: "用户列表", - }, + // { + // path: "/userlist", + // name: "用户列表", + // }, ], }; }, diff --git a/src/views/homePage/components/tableMain.vue b/src/views/homePage/components/tableMain.vue index e2c15b5..4aeca59 100644 --- a/src/views/homePage/components/tableMain.vue +++ b/src/views/homePage/components/tableMain.vue @@ -392,11 +392,14 @@ - + {}); }, + changeActive(val) { + console.log(val); + localStorage.setItem("activeId", JSON.stringify(val)); + }, onSubmit() { this.tableLoaidng = true; this.dataList = []; diff --git a/src/views/report/index.vue b/src/views/report/index.vue index 1e27981..87cdc57 100644 --- a/src/views/report/index.vue +++ b/src/views/report/index.vue @@ -52,8 +52,19 @@ >时间:{{ item.createTime }} 设备ID:{{ item.cmdid }} apk版本:{{ item.cmd.fileName }} - 命令:{{ cmdCn[item.cmdName] }} + 命令:{{ cmdCn[item.cmdName] }}命令:{{ item.cmdDesc }} + 命令预计拿走时间: + + {{ + $moment(item.estimatedPublishTime * 1000).format( + "MM-DD HH:mm:ss" + ) + }} + {{ remainingTime(item) }} + +

@@ -174,6 +185,7 @@ export default { cmdtimer: null, endtimer: null, updateTime: null, + newupdatatime: null, //运维操作列表 operateOptions: [ { id: 0, name: "全部" }, @@ -192,19 +204,52 @@ export default { operateR: 0, leftcmdVal: "", rightcmdVal: "", + intervalId: null, // 用于存储setInterval返回的ID }; }, computed: {}, created() { - this.cmdtimer = setInterval(this.getCmdList, 60000); // 每10秒刷新数据 - this.endtimer = setInterval(this.getEndList, 60000); // 每10秒刷新数据 + this.cmdtimer = setInterval(this.getCmdList, 60000); // 每60秒刷新数据 + this.endtimer = setInterval(this.getEndList, 60000); // 每60秒刷新数据 }, mounted() { this.getCmdList(); this.getEndList(); + this.startCountdown(); // 在组件挂载后开始倒计时 }, methods: { + startCountdown() { + // 清空之前可能存在的定时器 + if (this.intervalId) { + clearInterval(this.intervalId); + } + // 开始倒计时,每秒执行一次remainingTime方法 + this.intervalId = setInterval(() => { + this.newupdatatime = new Date().getTime(); // 更新当前时间 + this.leftCommand.forEach((item) => { + this.remainingTime(item); // 重新计算每个项目的剩余时间 + }); + }, 1000); // 每秒执行一次 + }, + remainingTime(item) { + if (!this.newupdatatime) { + // 更新时间尚未设置,返回默认的倒计时时间或者不执行任何操作 + return "计算中..."; + } + + const estimatedPublishTime = item.estimatedPublishTime * 1000; + const difference = estimatedPublishTime - this.newupdatatime; + const minutes = Math.floor(difference / 60000); + const seconds = Math.floor((difference % 60000) / 1000); + if (minutes == 0 && seconds == 0) { + this.getCmdList(); + this.getEndList(); + return `命令已下发`; + } else { + return ` 预估剩余:${minutes} 分钟 ${seconds} 秒`; + } + }, getCmdList() { //this.leftComLoading = true; getqueryCmdsApi({ p: 1, ps: 10000 }) @@ -461,6 +506,9 @@ export default { clearInterval(this.endtimer); this.cmdtimer = null; this.endtimer = null; + if (this.intervalId) { + clearInterval(this.intervalId); + } }, };