diff --git a/src/views/devicePhotoSchedule/components/adddeviceDialog copy.vue b/src/views/devicePhotoSchedule/components/adddeviceDialog copy.vue new file mode 100644 index 0000000..d559381 --- /dev/null +++ b/src/views/devicePhotoSchedule/components/adddeviceDialog copy.vue @@ -0,0 +1,260 @@ + + + diff --git a/src/views/devicePhotoSchedule/components/adddeviceDialog.vue b/src/views/devicePhotoSchedule/components/adddeviceDialog.vue index e9fc558..7ace0c5 100644 --- a/src/views/devicePhotoSchedule/components/adddeviceDialog.vue +++ b/src/views/devicePhotoSchedule/components/adddeviceDialog.vue @@ -20,12 +20,12 @@
- + @@ -54,7 +56,7 @@ icon="el-icon-plus" type="primary" @click="addModule()" - v-if="index + 1 == ruleForm.list.length" + v-if="index + 1 == ruleForm.listTime.length" >
@@ -91,25 +93,25 @@ export default { if (val == null) { return (this.ruleForm = { name: "", - list: [ + listTime: [ { - hour: "", - minute: "", - preset: "", + time: "", + span: "", }, ], + list: [], remark: "", }); } //this.ruleForm = val; this.ruleForm = JSON.parse(JSON.stringify(val)); - this.ruleForm.list.forEach((val) => { + this.ruleForm.listTime.forEach((val) => { this.$set(val, "time", [val.startTime, val.endTime]); }); }, addModule() { //新增一行 - this.ruleForm.list.push({ + this.ruleForm.listTime.push({ time: "", span: "", }); @@ -136,11 +138,39 @@ export default { this.$refs.formInfo.validate((valid) => { if (valid) { // delete this.ruleForm.time; - this.ruleForm.list.forEach((val) => { - console.log(val); + this.ruleForm.listTime.forEach((val) => { this.$set(val, "startTime", val.time[0]); this.$set(val, "endTime", val.time[1]); + // console.log(val.time[0]); + // console.log(typeof val.time[0]); + // console.log(new Date(val.time[0])); + // console.log(new Date(val.time[1])); + // 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), + minute: this.ruleForm.listTime[i].span % 60, + preset: 255, + }, + { + hour: this.ruleForm.listTime[i].startTime.getHours(), + minute: this.ruleForm.listTime[i].startTime.getMinutes(), + preset: 255, + }, + { + hour: this.ruleForm.listTime[i].endTime.getHours(), + minute: this.ruleForm.listTime[i].endTime.getMinutes(), + preset: 255, + } + ); + } + console.log(arr); + this.ruleForm.list = arr; if (this.title == "新增") { addScheduleRulel(this.ruleForm) .then((res) => { diff --git a/src/views/devicePhotoSchedule/index.vue b/src/views/devicePhotoSchedule/index.vue index 40c3a2c..331330e 100644 --- a/src/views/devicePhotoSchedule/index.vue +++ b/src/views/devicePhotoSchedule/index.vue @@ -13,7 +13,7 @@
- @@ -127,6 +106,8 @@ export default { return { title: "", //弹窗标题 deviceTableData: [], + newList: [], + listTime: [], //multipleSelection: [], //获取当前选中 page: 1, // 当前页数 pageSize: 20, // 每页数量 @@ -146,9 +127,56 @@ export default { pagesize: this.pageSize, }) .then((res) => { + this.newList = []; this.deviceTableData = res.data.list; this.total = res.data.total; 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; + obj.startTime = new Date().toISOString(); + } else if (k % 3 == 2) { + console.log("结束时间"); + obj.endTime = + this.deviceTableData[i].list[k].hour + + ":" + + this.deviceTableData[i].list[k].minute; + arr.push(obj); + console.log("2222222222222222222222222222"); + console.log(arr); + console.log("2222222222222222222222222222"); + } + 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) => {}); },