<template> <div id="MessageStatistics"> <div id="MQTopSearchBox"> <span class="SelectTitle">来源:</span> <el-select v-model="LaiYuan" filterable placeholder="请选择" class="MiniSel"> <el-option v-for="item in LaiYuanOptions" :key="item.LaiYuanNo" :label="item.LaiYuanName" :value="item.LaiYuanNo" ></el-option> </el-select> <span class="SelectTitle">平台:</span> <el-select v-model="Project" filterable placeholder="请选择" @change="loadProjectUser(Project)"> <el-option v-for="item in ProjectOptions" :key="item.platform_code" :label="item.name" :value="item.platform_code" ></el-option> </el-select> <span class="SelectTitle">用户:</span> <el-select v-model="User" filterable placeholder="请选择"> <el-option v-for="item in UserOptions" :key="item.openId" :label="item.nickName" :value="item.openId" ></el-option> </el-select> <span class="SelectTitle">类型:</span> <el-select v-model="LeiXing" filterable placeholder="请选择" class="MiniSel"> <el-option v-for="item in LeiXingOptions" :key="item.LeiXingNo" :label="item.LeiXingName" :value="item.LeiXingNo" ></el-option> </el-select> <span class="SelectTitle">时间选择:</span> <el-date-picker 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">搜索</el-button> </div> <div id="MQCertent"> <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(0, 0, 0, 0.8)" stripe > <el-table-column prop="source" label="信息来源"></el-table-column> <el-table-column prop="platFrom" label="推送平台"></el-table-column> <el-table-column prop="phoneNum" label="用户手机"></el-table-column> <el-table-column prop="nick_name" label="用户昵称"></el-table-column> <el-table-column prop="browse" label="已浏览"></el-table-column> <el-table-column prop="notBrowse" label="未浏览"></el-table-column> <el-table-column prop="total" label="总推送次数"></el-table-column> <el-table-column prop="scanRate" label="浏览率" :formatter="NumForB"></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 { message } from "./../../util/item"; export default { name: "MessageStatistics", data: function() { return { LaiYuan: "", //来源 LaiYuanOptions: [ { LaiYuanName: "全部", LaiYuanNo: "" }, { LaiYuanName: "微信公众号", LaiYuanNo: "1" }, { LaiYuanName: "短信", LaiYuanNo: "2" } ], //来源的数据源 LeiXing: "", //类型 LeiXingOptions: [ { LeiXingName: "全部", LeiXingNo: "" }, { LeiXingName: "预警", LeiXingNo: "预警" }, { LeiXingName: "报警", LeiXingNo: "报警" }, { LeiXingName: "离线", LeiXingNo: "离线" }, { LeiXingName: "站点设备故障", LeiXingNo: "站点设备故障" } ], //类型的数据源 Project: "", //平台 ProjectOptions: [ { name: "全部", platform_code: "" } ], //平台的数据源 User: "", //用户 UserOptions: [ { nickName: "全部", openId: "" } ], //用户的数据源 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]); } } ] }, //时间快捷选项 HistoryTableData: [], //历史数据表格数据 Page: 1, //分页默认显示页 DataLength: 0, //分页上显示的数据总条数 Size: 10, //分页上显示的每页的条数 dialogVisible: false, //dialog状态 DIalogTableData: [], //dialog表格数据 loading: false }; }, methods: { // 获取所有平台 loadAllProject() { this.$http .get(this.nozzle.StationBaseControllerQueryPlatform) .then(response => { if (response.data.result.list.length > 0) { this.ProjectOptions = this.ProjectOptions.concat( response.data.result.list ); this.Project = this.ProjectOptions[0].platform_code; this.loadProjectUser(this.ProjectOptions[0].platform_code); } else { this.$message({ showClose: true, message: "无项目", type: "warning" }); } }) .catch(response => { this.$message({ showClose: true, message: "请求平台失败", type: "warning" }); }); }, // 获取平台的人员 loadProjectUser(CODE) { this.UserOptions = [ { nickName: "全部", openId: "" } ]; this.$http .get( this.nozzle.StationBaseControllerGetUsers + "?platFromCode=" + CODE ) .then(response => { // if (response.data.length > 0) { this.UserOptions = this.UserOptions.concat(response.data); this.User = this.UserOptions[0].openId; this.loadDataGridData(); // } else { // this.$message({ // showClose: true, // message: "无分配人员", // type: "warning" // }); // } }) .catch(response => { this.$message({ showClose: true, message: "请求人员失败", type: "warning" }); }); }, //分页 SizeChange(val) { // 改变每页的条数 this.Size = val; this.loadDataGridData(); }, CurrentChange(val) { //改变页数 this.Page = val; this.loadDataGridData(); }, // 获取表格数据 loadDataGridData() { this.loading = true; this.$http .get( this.nozzle.alarmLogStatistical + "?source=" + this.LaiYuan + "&platFromCode=" + this.Project + "&alarmType=" + this.LeiXing + "&openId=" + this.User + "&st=" + this.TimeValue[0] + "&et=" + this.TimeValue[1] + "&pageNo=" + this.Page + "&pageSize=" + this.Size ) .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" }); }); }, // 小数转百分数 NumForB(row, column, cellValue, index) { return row.scanRate + "%"; } }, mounted: function() { this.loadAllProject(); } }; </script> <style scoped> #MessageStatistics { width: 100%; height: 100%; } /* 顶部搜索 */ #MQTopSearchBox { width: 100%; height: 60px; line-height: 60px; text-align: left; color: white; } #MQTopSearchBox .el-input { width: 200px; margin: 0 10px; } .SelectTitle { display: inline-block; margin-left: 5px; text-align: center; height: 60px; line-height: 60px; } .MiniSel { width: 140px; } /* 主体内容 */ #MQCertent { width: 100%; height: calc(100% - 70px); margin-top: 10px; background: rgba(53,53,53,.5); } </style>