From 548ecb0bfcee0610988821bba8d0de2a49123736 Mon Sep 17 00:00:00 2001 From: fanluyan <754122931@qq.com> Date: Mon, 31 Jul 2023 15:57:40 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8B=8D=E7=85=A7=E8=A3=85=E7=BD=AE=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E6=96=B0=E5=A2=9E=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/adddeviceDialog.vue | 7 +- .../components/setdevice.vue | 41 ++++-- src/views/devicePhotoSchedule/index.vue | 75 ++++++++++- .../components/setschedule.vue | 123 ++++++++++++++++-- 4 files changed, 220 insertions(+), 26 deletions(-) diff --git a/src/views/devicePhotoSchedule/components/adddeviceDialog.vue b/src/views/devicePhotoSchedule/components/adddeviceDialog.vue index 7ace0c5..fb39916 100644 --- a/src/views/devicePhotoSchedule/components/adddeviceDialog.vue +++ b/src/views/devicePhotoSchedule/components/adddeviceDialog.vue @@ -138,9 +138,10 @@ export default { this.$refs.formInfo.validate((valid) => { if (valid) { // delete this.ruleForm.time; + this.ruleForm.listTime.forEach((val) => { - this.$set(val, "startTime", val.time[0]); - this.$set(val, "endTime", val.time[1]); + this.$set(val, "startTime", new Date(val.time[0])); + this.$set(val, "endTime", new Date(val.time[1])); // console.log(val.time[0]); // console.log(typeof val.time[0]); // console.log(new Date(val.time[0])); @@ -148,9 +149,11 @@ export default { // console.log(new Date(val.time[0]).getHours()); // console.log(new Date(val.time[0]).getMinutes()); }); + let arr = []; for (var i = 0; i < this.ruleForm.listTime.length; i++) { console.log(this.ruleForm.listTime); + arr.push( { hour: Math.floor(this.ruleForm.listTime[i].span / 60), diff --git a/src/views/devicePhotoSchedule/components/setdevice.vue b/src/views/devicePhotoSchedule/components/setdevice.vue index 3e6a8b4..395b457 100644 --- a/src/views/devicePhotoSchedule/components/setdevice.vue +++ b/src/views/devicePhotoSchedule/components/setdevice.vue @@ -14,13 +14,29 @@
{{ - val.startTime.substring(0, val.startTime.lastIndexOf(":")) + new Date(val.startTime).getHours() < 10 + ? "0" + new Date(val.startTime).getHours() + : new Date(val.startTime).getHours() + }}: + {{ + new Date(val.startTime).getMinutes() < 10 + ? "0" + new Date(val.startTime).getMinutes() + : new Date(val.startTime).getMinutes() }} ~ - {{ - val.endTime.substring(0, val.endTime.lastIndexOf(":")) - }} + {{ + new Date(val.endTime).getHours() < 10 + ? "0" + new Date(val.endTime).getHours() + : new Date(val.endTime).getHours() + }}: + {{ + new Date(val.endTime).getMinutes() < 10 + ? "0" + new Date(val.endTime).getMinutes() + : new Date(val.endTime).getMinutes() + }} 间隔:{{ val.span }}分钟
@@ -65,6 +81,10 @@ :max="9" > +{{ - val.startTime.substring(0, val.startTime.lastIndexOf(":")) + new Date(val.startTime).getHours() < 10 + ? "0" + new Date(val.startTime).getHours() + : new Date(val.startTime).getHours() + }}: + {{ + new Date(val.startTime).getMinutes() < 10 + ? "0" + new Date(val.startTime).getMinutes() + : new Date(val.startTime).getMinutes() }} + ~ - {{ - val.endTime.substring(0, val.endTime.lastIndexOf(":")) - }} + {{ + new Date(val.endTime).getHours() < 10 + ? "0" + new Date(val.endTime).getHours() + : new Date(val.endTime).getHours() + }}: + {{ + new Date(val.endTime).getMinutes() < 10 + ? "0" + new Date(val.endTime).getMinutes() + : new Date(val.endTime).getMinutes() + }} 间隔:{{ val.span }}分钟
@@ -259,6 +276,8 @@ export default { selaccess: "", //选中的通道 shedulenr: [], //查询的时间表 deviceTableData: [], //时间表-表格 + newList: [], + listTime: [], page: 1, // 当前页数 pageSize: 10, // 每页数量 total: 0, //总条数 @@ -416,10 +435,98 @@ export default { pagesize: this.pageSize, }) .then((res) => { + // this.deviceTableData = res.data.list; + // this.total = res.data.total; + // console.log(this.deviceTableData); + // this.loading = false; + this.newList = []; this.deviceTableData = res.data.list; this.total = res.data.total; - console.log(this.deviceTableData); this.loading = false; + // for (var i = 0; i < this.deviceTableData.list.length; i++) { + // console.log(this.deviceTableData.list[i]); + // } + // console.log(this.deviceTableData); + + for (var i = 0; i < this.deviceTableData.length; i++) { + var arr = []; + console.log(this.deviceTableData[i]); + for (var k = 0; k < this.deviceTableData[i].list.length; k++) { + if (k % 3 == 0) { + var obj = {}; + obj.span = + this.deviceTableData[i].list[k].hour * 60 + + this.deviceTableData[i].list[k].minute; + console.log("时间间隔"); + } else if (k % 3 == 1) { + console.log("开始时间"); + console.log("a"); + // obj.startTime = + // this.deviceTableData[i].list[k].hour + + // ":" + + // this.deviceTableData[i].list[k].minute; + // console.log(new Date()); + let timeDate = new Date(); + timeDate.setHours(this.deviceTableData[i].list[k].hour); + timeDate.setMinutes(this.deviceTableData[i].list[k].minute); + console.log(timeDate); + // console.log(new Date().getHours()); + // console.log( + // new Date().setHours(this.deviceTableData[i].list[k].hour) + // ); + // console.log(d.getHours() + ":" + d.getMinutes()); + // if (timeDate.getHours() < 10) { + // console.log(timeDate.getHours()); + // obj.startTime = + // "0" + timeDate.getHours() + ":" + timeDate.getMinutes(); + // } else { + + // } + + // let timeHour = + // timeDate.getHours() < 10 + // ? "0" + timeDate.getHours() + // : timeDate.getHours(); + // let timeMinute = + // timeDate.getMinutes() < 10 + // ? "0" + timeDate.getMinutes() + // : timeDate.getMinutes(); + obj.startTime = timeDate.toUTCString(); + } else if (k % 3 == 2) { + console.log("结束时间"); + obj.endTime = + this.deviceTableData[i].list[k].hour + + ":" + + this.deviceTableData[i].list[k].minute; + let timeDate = new Date(); + timeDate.setHours(this.deviceTableData[i].list[k].hour); + timeDate.setMinutes(this.deviceTableData[i].list[k].minute); + // obj.endTime = c.toJSON(); + let timeHour = + timeDate.getHours() < 10 + ? "0" + timeDate.getHours() + : timeDate.getHours(); + let timeMinute = + timeDate.getMinutes() < 10 + ? "0" + timeDate.getMinutes() + : timeDate.getMinutes(); + //obj.startTime = timeHour + ":" + timeMinute; + // obj.endTime = timeHour + ":" + timeMinute; + obj.endTime = timeDate.toUTCString(); + arr.push(obj); + } + console.log(this.deviceTableData[i].list[k]); + } + this.newList.push({ + id: this.deviceTableData[i].id, + list: this.deviceTableData[i].list, + name: this.deviceTableData[i].name, + remark: this.deviceTableData[i].remark, + listTime: arr, + }); + } + console.log("this.newList"); + console.log(this.newList); }) .catch((err) => {}); },