<template> <div id="HistoricalFault"> <div id="HFTopSearchBox"> <span class="SelectTitle">项目:</span> <el-select clearable class="widthinput" v-model="Project" filterable placeholder="请选择项目" @change="loadProjectUser(Project)" > <el-option v-for="item in allPlatSite" :key="item.index" :label="item.platformName" :value="item.platformCode" ></el-option> </el-select> <span class="SelectTitle">站点:</span> <el-select clearable v-model="Site" filterable placeholder="请选择站点" class="widthinput" > <el-option v-for="item in SiteOptions" :key="item.index" :label="item.siteName" :value="item.siteNo" ></el-option> </el-select> <span class="SelectTitle">时间选择:</span> <el-date-picker class="data" v-model="TimeValue" type="datetimerange" align="right" unlink-panels range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期" :picker-options="pickerOptions" value-format="yyyy-MM-dd HH:mm:ss" ></el-date-picker> <el-button type="primary" icon="el-icon-search" @click="loadDataGridData" v-has="'Search'" >搜索</el-button > </div> <div id="HFCertent"> <el-table :data="HistoryTableData" style="width: 100%;height:calc(100% - 45px)" v-loading="loading" element-loading-text="拼命加载中" element-loading-spinner="el-icon-loading" element-loading-background="rgba(255, 255, 255, 0.3)" > <el-table-column prop="siteNo" width="150" label="站点编号"></el-table-column> <el-table-column prop="siteName" label="站点名称"></el-table-column> <el-table-column prop="platformName" label="所属项目"> <template slot-scope="scope"> <span :class="[(scope.row.siteName && !scope.row.platformName) ? 'red' : '']"> {{scope.row.siteName && !scope.row.platformName ? "未关联项目" : scope.row.platformName}} </span> </template> </el-table-column> <el-table-column prop="fromType" width="150" label="上报类型"></el-table-column> <el-table-column prop="faultTime" label="上报时间"></el-table-column> <el-table-column prop="faultValueName" label="故障因子" ></el-table-column> </el-table> <el-pagination @size-change="SizeChange" @current-change="CurrentChange" :current-page="Page" :page-sizes="[10, 20, 50, 100]" :page-size="Size" layout="total, sizes, prev, pager, next, jumper" :total="DataLength" style="margin-top:10px;" ></el-pagination> </div> </div> </template> <script> import { mapGetters } from "vuex"; export default { name: "HistoricalFault", data: function() { return { condition: "", platCode: "", userNo: "", HistoryTableData: [], //历史数据表格数据 Page: 1, //分页默认显示页 DataLength: 0, //分页上显示的数据总条数 Size: 10, //分页上显示的每页的条数 loading: false, TimeValue: [ this.moment() .subtract("days", 3) .format("YYYY-MM-DD HH:mm:ss"), this.moment().format("YYYY-MM-DD HH:mm:ss") ], //时间 pickerOptions: { shortcuts: [ { text: "最近一周", onClick(picker) { const end = new Date(); const start = new Date(); start.setTime(start.getTime() - 3600 * 1000 * 24 * 7); picker.$emit("pick", [start, end]); } }, { text: "最近一个月", onClick(picker) { const end = new Date(); const start = new Date(); start.setTime(start.getTime() - 3600 * 1000 * 24 * 30); picker.$emit("pick", [start, end]); } }, { text: "最近三个月", onClick(picker) { const end = new Date(); const start = new Date(); start.setTime(start.getTime() - 3600 * 1000 * 24 * 90); picker.$emit("pick", [start, end]); } } ] }, //时间快捷选项 Project: "", //平台 Site: "", //平台 SiteOptions: [] //平台的数据源 }; }, computed: { ...mapGetters(["allPlatSite"]) }, methods: { SizeChange(val) { // 改变每页的条数 this.Size = val; this.loadDataGridData(); }, CurrentChange(val) { //改变页数 this.Page = val; this.loadDataGridData(); }, loadDataGridData() { this.loading = true; this.$http .post(this.nozzle.faultInfoGetHisInfo, { platCode: this.Project, siteNo: this.Site, st: this.TimeValue[0], et: this.TimeValue[1], pageNo: this.Page, pageSize: this.Size, userNo: this.userNo }) .then(response => { this.loading = false; this.HistoryTableData = response.data.data; this.DataLength = response.data.total; }) .catch(response => { this.loading = false; this.$message({ showClose: true, message: "请求日志失败", type: "warning" }); }); }, // 获取平台的站点 loadProjectUser(CODE) { this.Site = ""; this.SiteOptions = []; for (var i = 0; i < this.allPlatSite.length; i++) { if (this.allPlatSite[i].platformCode === CODE) { this.SiteOptions = this.allPlatSite[i].dropSiteList; return; } } } }, mounted: function() { this.userNo = window.localStorage.getItem("USERNO"); this.loadDataGridData(); } }; </script> <style scoped> #HistoricalFault { width: 100%; height: 100%; } /* 顶部搜索 */ #HFTopSearchBox { width: 100%; height: 60px; line-height: 60px; text-align: left; color: var(--white); } #HFTopSearchBox .el-input { width: 200px; margin: 0 10px; } .SelectTitle { display: inline-block; margin-left: 5px; text-align: center; height: 60px; line-height: 60px; } .widthinput { width: 15%; } .data { width: 28%; } /* 主体内容 */ #HFCertent { width: 100%; height: calc(100% - 70px); margin-top: 10px; /* background: rgba(53, 53, 53, 0.5); */ } </style>