| | |
| | | <template> |
| | | <div> |
| | | <MyHeader @getList="getRealTimeList"></MyHeader> |
| | | <MyHeader |
| | | @getList="getRealTimeList" |
| | | @exportTable="exportInTime" |
| | | ></MyHeader> |
| | | <!-- 数据展示 --> |
| | | <div style="width: 100%; overflow-x: scroll"> |
| | | <el-table |
| | |
| | | getRealTimeList(seachData) { |
| | | let params; |
| | | if (seachData) { |
| | | params = { |
| | | pageNum: this.currentPage, |
| | | pageSize: this.pageSize, |
| | | resource: |
| | | seachData.seachData.resource == undefined |
| | | ? null |
| | | : seachData.seachData.resource, |
| | | region: |
| | | seachData.seachData.region == undefined |
| | | ? null |
| | | : seachData.seachData.region, |
| | | type: this.statusArr[1] ?? null, |
| | | code: |
| | | seachData.seachData.code == undefined |
| | | ? null |
| | | : seachData.seachData.code, |
| | | categoryBig: |
| | | seachData.seachData.categoryBig == undefined |
| | | ? null |
| | | : seachData.seachData.categoryBig, |
| | | categorySmall: |
| | | seachData.seachData.categorySmall == undefined |
| | | ? null |
| | | : seachData.seachData.categorySmall, |
| | | site: |
| | | seachData.seachData.site == undefined |
| | | ? null |
| | | : seachData.seachData.site, |
| | | street: |
| | | seachData.seachData.street == undefined |
| | | ? null |
| | | : seachData.seachData.street, |
| | | alarmTime: |
| | | seachData.seachData.alarmTime == undefined |
| | | ? null |
| | | : seachData.seachData.alarmTime, |
| | | }; |
| | | params = this.getParam(seachData) |
| | | } else { |
| | | params = { |
| | | pageNum: this.currentPage, |
| | |
| | | .findInTimeList(params) |
| | | .then(({ list, total }) => { |
| | | list.forEach(e => { |
| | | e.AcquitAtStr = this.Dateformat(e.AcquitAt); |
| | | e.AcquitAtStr = this.dateFormat("YYYY-mm-dd HH:MM", new Date(e.AcquitAt)); |
| | | e.FanStatusStr = this.FanStatusStr(e.FanStatus) |
| | | e.FilterStatusStr = this.FanStatusStr(e.FilterStatus) |
| | | e.OnlineStatusStr = this.OnlineStatusStr(e.OnlineStatus) |
| | |
| | | }) |
| | | .catch((err) => this.$message.error(err)); |
| | | }, |
| | | exportInTime(seachData) { |
| | | let params; |
| | | if (seachData) { |
| | | params = this.getParam(seachData) |
| | | } |
| | | realTimeApi |
| | | .exportInTime(params) |
| | | .then((res) => { |
| | | debugger |
| | | let time = new Date(); |
| | | let deathdate = time.toLocaleDateString(); |
| | | const blob = new Blob([res.data], { |
| | | type: "application/vnd.ms-excel;charset=utf-8", |
| | | }); |
| | | if (window.navigator.msSaveBlob) { |
| | | window.navigator.msSaveBlob( |
| | | blob, |
| | | deathdate + "实时数据" + ".xls" |
| | | ); |
| | | } else { |
| | | const url = window.URL.createObjectURL(blob); |
| | | const link = document.createElement("a"); |
| | | link.style.display = "none"; |
| | | link.href = url; |
| | | link.download = deathdate + "实时数据" + ".xls"; |
| | | document.body.appendChild(link); |
| | | link.click(); |
| | | document.body.removeChild(link); |
| | | } |
| | | this.$message.success("操作成功"); |
| | | }) |
| | | .catch((err) => this.$message.error(err)); |
| | | }, |
| | | getParam(seachData) { |
| | | let params; |
| | | if (seachData) { |
| | | const seachParams = seachData.seachData |
| | | params = { |
| | | owner: |
| | | seachParams.owner == undefined |
| | | ? null |
| | | : seachParams.owner, |
| | | onlineStatus: |
| | | seachParams.onlineStatus == undefined |
| | | ? null |
| | | : seachParams.onlineStatus, |
| | | status: seachParams.status == undefined |
| | | ? null |
| | | : seachParams.status, |
| | | type: |
| | | seachParams.type == undefined |
| | | ? null |
| | | : seachParams.type, |
| | | startTime: |
| | | seachParams.alarmTime == undefined |
| | | ? null |
| | | : this.dateFormat("YYYY-mm-dd HH:MM:SS", seachParams.alarmTime[0]), |
| | | endTime: |
| | | seachParams.alarmTime == undefined |
| | | ? null |
| | | : this.dateFormat("YYYY-mm-dd HH:MM:SS", seachParams.alarmTime[1]), |
| | | }; |
| | | } |
| | | return params; |
| | | }, |
| | | |
| | | FanStatusStr(FanStatus) { |
| | | switch (FanStatus) { |
| | | case 1: |
| | |
| | | this.currentPage = page; |
| | | this.getRealTimeList(); |
| | | }, |
| | | Dateformat(fmt) { |
| | | var fmtdate = new Date(fmt) |
| | | var o = { |
| | | "M+": fmtdate.getMonth() + 1, //月份 |
| | | "d+": fmtdate.getDate(), //日 |
| | | "h+": fmtdate.getHours(), //小时 |
| | | "m+": fmtdate.getMinutes(), //分 |
| | | "s+": fmtdate.getSeconds(), //秒 |
| | | "q+": Math.floor((fmtdate.getMonth() + 3) / 3), //季度 |
| | | "S": fmtdate.getMilliseconds() //毫秒 |
| | | dateFormat(fmt, date) { |
| | | let ret; |
| | | const opt = { |
| | | "Y+": date.getFullYear().toString(), // 年 |
| | | "m+": (date.getMonth() + 1).toString(), // 月 |
| | | "d+": date.getDate().toString(), // 日 |
| | | "H+": date.getHours().toString(), // 时 |
| | | "M+": date.getMinutes().toString(), // 分 |
| | | "S+": date.getSeconds().toString() // 秒 |
| | | // 有其他格式化字符需求可以继续添加,必须转化成字符串 |
| | | }; |
| | | if (/(y+)/.test(fmt)) { |
| | | fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length)); |
| | | } |
| | | for (var k in o) { |
| | | if (new RegExp("(" + k + ")").test(fmt)) { |
| | | fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length))); |
| | | } |
| | | } |
| | | for (let k in opt) { |
| | | ret = new RegExp("(" + k + ")").exec(fmt); |
| | | if (ret) { |
| | | fmt = fmt.replace(ret[1], (ret[1].length == 1) ? (opt[k]) : (opt[k].padStart(ret[1].length, "0"))) |
| | | }; |
| | | }; |
| | | return fmt; |
| | | } |
| | | }, |
| | | } |
| | | }; |
| | | </script> |
| | | |