From 0b803f46bffb4b59b5618c49eb81f1c16db672cf Mon Sep 17 00:00:00 2001 From: zhanghua <314079846@qq.com> Date: 星期日, 12 十一月 2023 10:09:46 +0800 Subject: [PATCH] 油烟统计 --- src/views/smoke/judgment/index.vue | 243 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 240 insertions(+), 3 deletions(-) diff --git a/src/views/smoke/judgment/index.vue b/src/views/smoke/judgment/index.vue index 9278ea7..74d5df2 100644 --- a/src/views/smoke/judgment/index.vue +++ b/src/views/smoke/judgment/index.vue @@ -1,13 +1,250 @@ <template> - <div>棰勮鐮斿垽</div> + <div> + <MyHeader @getList="getAlarmList" @exportTable="exportAlarm"></MyHeader> + <!-- 鏁版嵁灞曠ず --> + <div style="width: 100%; overflow-x: scroll"> + <el-table + border + stripe + ref="multipleTable" + :header-cell-style="{ + background: '#F5F5F5', + 'font-weight': '650', + 'line-height': '45px', + }" + :data="tableData" + :row-class-name="tableRowClassName" + > + <el-table-column label="搴忓彿" type="index" width="60px"> + </el-table-column> + <el-table-column prop="Addr" label="鐐逛綅鍚嶇О" min-width="2"> + </el-table-column> + <el-table-column prop="MsgTypeStr" label="浜嬩欢绫诲瀷" min-width="3"> + </el-table-column> + <el-table-column prop="Content" label="娑堟伅鍐呭" min-width="8"> + </el-table-column> + <el-table-column prop="AcquitAtStr" label="鏃堕棿" min-width="2"> + </el-table-column> + + <el-table-column prop="operation" label="鎿嶄綔" min-width="3"> + <template slot-scope="scope"> + <div class="operation"> + <span @click="handleLearn(scope.row)">澶勭悊</span> + </div> + </template> + </el-table-column> + </el-table> + </div> + <div class="tools"> + <div class="pagination"> + <el-pagination + background + @prev-click="handlePrev" + @next-click="handleNext" + :current-page="currentPage" + layout="prev, pager, next" + :total="totalNum" + :page-size="pageSize" + @current-change="changeCurrentPage" + > + </el-pagination> + </div> + </div> + <el-dialog + :visible.sync="dialogAdd" + width="90%" + title="棰勮鐮斿垽" + v-if="dialogAdd" + :before-close="handleClose" + > + <JudgeIndex :info="videoInspection" ></JudgeIndex> + </el-dialog> + </div> </template> <script> +import MyHeader from "./header"; +import realTimeApi from "@/api/smoke/alarm"; +import JudgeIndex from "./components/index.vue"; export default { + data() { + return { + dialogAdd:false, + tableData: [], + totalNum: 0, + pageSize: 10, + currentPage: 1, + params: {}, + videoInspection:{} + }; + }, + components: { MyHeader ,JudgeIndex}, + created() { + this.getAlarmList(); + }, + methods: { + getAlarmList(seachData) { + if (seachData) { + this.params = this.getParam(seachData); + } else { + this.params = { + pageNum: this.currentPage, + pageSize: this.pageSize, + }; + } -} + realTimeApi + .findAlarmList(this.params) + .then(({ list, total }) => { + list.forEach((e) => { + e.AcquitAtStr = this.dateFormat( + "YYYY-mm-dd HH:MM", + new Date(e.AcquitAt*1000) + ); + e.MsgTypeStr = this.MsgTypeStr(e.MsgType); + }); + this.tableData = list; + this.totalNum = total; + }) + .catch((err) => this.$message.error(err)); + }, + exportAlarm(seachData) { + let params; + if (seachData) { + params = this.getParam(seachData); + } + realTimeApi + .exportAlarm(params) + .then((res) => { + 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 || seachData; + params = { + msgType: + seachParams.msgType == undefined ? null : seachParams.msgType, + 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] + ), + }; + params.pageNum = this.currentPage; + params.pageSize = this.pageSize; + } + return params; + }, + + MsgTypeStr(Status) { + switch (Status) { + case "ExceedStandard": + return "瓒呮爣"; + case "AbnormalOffline": + return "寮傚父绂荤嚎"; + default: + return "寮傚父绂荤嚎"; + } + }, + // 璁剧疆琛ㄦ牸鏂戦┈绾� + tableRowClassName({ row, rowIndex }) { + if ((rowIndex + 1) % 2 === 0) { + return "warning-row"; + } else { + return "success-row"; + } + }, + // 褰撳墠椤垫敼鍙樿Е鍙戜簨浠� + changeCurrentPage(page) { + this.currentPage = page; + this.getAlarmList(this.params); + }, + // 涓婁竴椤电偣鍑讳簨浠� + handlePrev(page) { + this.currentPage = page; + this.getAlarmList(this.params); + }, + // 涓嬩竴椤电偣鍑讳簨浠� + handleNext(page) { + this.currentPage = page; + this.getAlarmList(this.params); + }, + 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(), // 绉� + // 鏈夊叾浠栨牸寮忓寲瀛楃闇�姹傚彲浠ョ户缁坊鍔狅紝蹇呴』杞寲鎴愬瓧绗︿覆 + }; + 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; + }, + handleLearn(row) { + this.dialogAdd = true; + this.videoInspection = row; + + }, + handleClose(done) { + this.changeCurrentPage(1); + done(); + }, + }, +}; </script> -<style> +<style lang="scss" scoped> +.el-table { + .operation { + display: flex; + color: var(--operation-color); + .line { + padding: 0 5px; + } + span:hover { + cursor: pointer; + } + } +} </style> \ No newline at end of file -- Gitblit v1.8.0