|
@@ -0,0 +1,221 @@
|
|
|
+<template>
|
|
|
+ <div class="RealOnline">
|
|
|
+ <el-breadcrumb separator-class="el-icon-arrow-right">
|
|
|
+ <el-breadcrumb-item>新媒体</el-breadcrumb-item>
|
|
|
+ <el-breadcrumb-item>用户分析</el-breadcrumb-item>
|
|
|
+ <el-breadcrumb-item>实时访客</el-breadcrumb-item>
|
|
|
+ </el-breadcrumb>
|
|
|
+ <el-card class="box-card">
|
|
|
+ <el-form
|
|
|
+ ref="form"
|
|
|
+ :model="form"
|
|
|
+ size="small"
|
|
|
+ :inline="true"
|
|
|
+ label-width="120px"
|
|
|
+ class="demo-form-inline"
|
|
|
+ >
|
|
|
+ <el-form-item label="应用">
|
|
|
+ <el-select v-model="form.app" placeholder="请选择时段">
|
|
|
+ <el-option
|
|
|
+ v-for="item in cycle"
|
|
|
+ :key="item.value"
|
|
|
+ :label="item.label"
|
|
|
+ :value="item.value"
|
|
|
+ :disabled="item.disabled"
|
|
|
+ >
|
|
|
+ </el-option>
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item style="float: right">
|
|
|
+ <el-button type="primary" @click="onSubmit">查询</el-button>
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+ </el-card>
|
|
|
+ <br />
|
|
|
+ <el-card class="box-card">
|
|
|
+ <div class="realLineChart" ref="realLineChart"></div>
|
|
|
+ </el-card>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+// @ is an alias to /src
|
|
|
+import { getRealAppOnline, getRule, getAppList } from "@/api/index";
|
|
|
+
|
|
|
+import * as echarts from "echarts/core";
|
|
|
+import { LineChart } from "echarts/charts";
|
|
|
+import {
|
|
|
+ TitleComponent,
|
|
|
+ TooltipComponent,
|
|
|
+ GridComponent,
|
|
|
+} from "echarts/components";
|
|
|
+import { CanvasRenderer } from "echarts/renderers";
|
|
|
+echarts.use([
|
|
|
+ TitleComponent,
|
|
|
+ TooltipComponent,
|
|
|
+ GridComponent,
|
|
|
+ LineChart,
|
|
|
+ CanvasRenderer,
|
|
|
+]);
|
|
|
+
|
|
|
+// import config from "@/config/index";
|
|
|
+let chart = undefined,
|
|
|
+ time = undefined;
|
|
|
+export default {
|
|
|
+ name: "RealOnline",
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ form: {
|
|
|
+ app: "2",
|
|
|
+ },
|
|
|
+ tableData: [],
|
|
|
+ cycle: [],
|
|
|
+ };
|
|
|
+ },
|
|
|
+ mounted() {
|
|
|
+ this.init();
|
|
|
+ },
|
|
|
+ computed: {},
|
|
|
+ methods: {
|
|
|
+ init() {
|
|
|
+ if (time) clearInterval(time);
|
|
|
+ if (chart && chart.dispose) chart.dispose();
|
|
|
+ getRule({
|
|
|
+ db: "authplat",
|
|
|
+ exportMark: "0",
|
|
|
+ menuid: 221,
|
|
|
+ roleid: 9999,
|
|
|
+ }).then(r => {
|
|
|
+ console.log(r);
|
|
|
+ getAppList({
|
|
|
+ exportMark: "0",
|
|
|
+ gcode: "SOURCE",
|
|
|
+ pageid: 1,
|
|
|
+ pagesize: 1000,
|
|
|
+ }).then(li => {
|
|
|
+ if (li.status !== "0") return;
|
|
|
+ const l = li.output.data || [];
|
|
|
+ this.form = {
|
|
|
+ app: (l[0] || { mname: "" }).mname,
|
|
|
+ };
|
|
|
+ this.onSubmit();
|
|
|
+ time = setInterval(() => this.onSubmit(), 60000);
|
|
|
+ this.cycle = (l || []).map(v => {
|
|
|
+ return {
|
|
|
+ value: v.mname,
|
|
|
+ label: v.mname,
|
|
|
+ };
|
|
|
+ });
|
|
|
+ });
|
|
|
+ });
|
|
|
+ },
|
|
|
+ onSubmit() {
|
|
|
+ getRealAppOnline({ appName: this.form.app })
|
|
|
+ .then(r => {
|
|
|
+ if (!this.$refs.realLineChart) return;
|
|
|
+ !chart && (chart = echarts.init(this.$refs.realLineChart));
|
|
|
+ chart.resize({
|
|
|
+ height: (this.$refs.realLineChart.offsetWidth * 6) / 16,
|
|
|
+ });
|
|
|
+ const keyList = [],
|
|
|
+ valueList = [];
|
|
|
+ (r || []).map(v => {
|
|
|
+ const key = v.recMinute.split(" ")[1] || "";
|
|
|
+ keyList.push(key);
|
|
|
+ valueList.push(v.total);
|
|
|
+ });
|
|
|
+ chart.setOption({
|
|
|
+ tooltip: {
|
|
|
+ trigger: "axis",
|
|
|
+ },
|
|
|
+ grid: {
|
|
|
+ left: "3%",
|
|
|
+ right: "4%",
|
|
|
+ bottom: "3%",
|
|
|
+ containLabel: true,
|
|
|
+ },
|
|
|
+ xAxis: {
|
|
|
+ type: "category",
|
|
|
+ boundaryGap: false,
|
|
|
+ data: keyList,
|
|
|
+ },
|
|
|
+ yAxis: {
|
|
|
+ type: "value",
|
|
|
+ },
|
|
|
+ series: [
|
|
|
+ {
|
|
|
+ data: valueList,
|
|
|
+ symbolSize: 0,
|
|
|
+ lineStyle: {
|
|
|
+ width: 1,
|
|
|
+ },
|
|
|
+ type: "line",
|
|
|
+ smooth: true,
|
|
|
+ color: "rgba(58,132,255,.9)",
|
|
|
+ areaStyle: {
|
|
|
+ color: {
|
|
|
+ type: "linear",
|
|
|
+ x: 0,
|
|
|
+ y: 0,
|
|
|
+ x2: 0,
|
|
|
+ y2: 1,
|
|
|
+ colorStops: [
|
|
|
+ {
|
|
|
+ offset: 0,
|
|
|
+ color: "rgba(58,132,255, 0.8)", // 0% 处的颜色
|
|
|
+ },
|
|
|
+ {
|
|
|
+ offset: 1,
|
|
|
+ color: "rgba(58,132,255, 0.1)", // 100% 处的颜色
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ global: false, // 缺省为 false
|
|
|
+ },
|
|
|
+ },
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ });
|
|
|
+ })
|
|
|
+ .catch(err => {
|
|
|
+ console.log(err);
|
|
|
+ chart.clear();
|
|
|
+ });
|
|
|
+ },
|
|
|
+ formatListData() {
|
|
|
+ let time = "";
|
|
|
+ if (this.form.rangeTime.length) {
|
|
|
+ let start = new Date(this.form.rangeTime[0]);
|
|
|
+ let end = new Date(this.form.rangeTime[1]);
|
|
|
+ let start_hour = start.getHours();
|
|
|
+ let start_min = start.getMinutes();
|
|
|
+ let end_hour = end.getHours();
|
|
|
+ let end_min = end.getMinutes();
|
|
|
+ start_hour = start_hour > 9 ? start_hour + "" : "0" + start_hour;
|
|
|
+ start_min = start_min > 9 ? start_min + "" : "0" + start_min;
|
|
|
+ end_hour = end_hour > 9 ? end_hour + "" : "0" + end_hour;
|
|
|
+ end_min = end_min > 9 ? end_min + "" : "0" + end_min;
|
|
|
+ if (end_hour + end_min === "2359") {
|
|
|
+ end_hour = "24";
|
|
|
+ end_min = "00";
|
|
|
+ }
|
|
|
+ time = start_hour + start_min + "_" + end_hour + end_min;
|
|
|
+ } else {
|
|
|
+ time = "0000_2400";
|
|
|
+ }
|
|
|
+ return {
|
|
|
+ time_range: time,
|
|
|
+ };
|
|
|
+ },
|
|
|
+ },
|
|
|
+ components: {},
|
|
|
+};
|
|
|
+</script>
|
|
|
+
|
|
|
+<style>
|
|
|
+.RealOnline {
|
|
|
+ margin: 10px 15px;
|
|
|
+}
|
|
|
+.RealOnline .has-seconds .el-time-spinner__wrapper:last-child {
|
|
|
+ display: none;
|
|
|
+}
|
|
|
+</style>
|