zhangliang2 il y a 3 ans
Parent
commit
562a19f522

+ 13 - 1
src/api/mainPage.js

@@ -1,6 +1,11 @@
 const basePart = '/simulation/resource/server';
 
-const queryAllNum = basePart + '/homePage/queryAllNum'; // 首页数据概览(前四个)
+const selectHardware = basePart + '/homePage/selectHardware'; // 首页系统监控-硬件监控
+const selectService = basePart + '/homePage/selectService'; // 首页系统监控-服务监控
+const selectAccess = basePart + '/homePage/selectAccess'; // 首页系统监控-日访问人数
+const selectServer = basePart + '/homePage/selectServer'; // 首页系统监控-服务器监控
+
+const queryAllNum = basePart + '/homePage/queryAllNum'; // 首页数据概览
 
 const selectRunProjectBySy = basePart + '/homePage/selectRunProjectBySy'; // 近一周运行运行项目数量
 const selectRunTaskBySy = basePart + '/homePage/selectRunTaskBySy'; // 近一周运行任务数量
@@ -10,7 +15,14 @@ const selectRunTaskByState = basePart + '/homePage/selectRunTaskByState'; // 任
 const selectEvaluationLevel = basePart + '/homePage/selectEvaluationLevel'; // 评测等级分布-饼图
 
 
+// http://10.15.12.74:7003/simulation/resource/server/homePage/selectServer
+
 export default {
+    selectHardware,
+    selectService,
+    selectAccess,
+    selectServer,
+
     queryAllNum,
 
     selectRunProjectBySy,

BIN
src/assets/common/image/others/1.png


+ 96 - 147
src/components/echarts/lineChartMainPage.vue

@@ -13,22 +13,14 @@ export default {
     name: "lineChartMainPage",
     props: {
         id: {
-            default: "lineChartMainPageA",
+            default: "lineChartMainPage",
             type: String,
         },
-        LineChartData: {
-            text: String, //标题  不需要标题可不传
-            titleSize: {
-                //标题大小
-                type: Number,
-                default: 20,
+        dataList: {
+            default: function () {
+                return [];
             },
-            download: {
-                //是否显示下载按钮
-                type: Boolean,
-                default: false,
-            },
-            data: [],
+            type: Array,
         },
     },
     data() {
@@ -36,168 +28,125 @@ export default {
             tipData: [], //线数据
             showData: [], //展示数据
             charts: "",
-            // text: this.LineChartData.text, //大标题
-            // titleSize: this.LineChartData.titleSize, //标题大小
-            // download: this.LineChartData.download,
         };
     },
-    computed: {
-        text() {
-            return this.LineChartData.text;
-        },
-        titleSize() {
-            return this.LineChartData.titleSize;
-        },
-        download() {
-            return this.LineChartData.download;
+
+    watch: {
+        dataList(val) {
+            if (val.length > 0) {
+                this.initStateList();
+            }
         },
     },
-    mounted() {
-        // this.drawLine();
-        // import * as echarts from "echarts";
-
-        // 基于准备好的dom,初始化echarts实例
-        this.charts = this.$echarts.init(document.getElementById(this.id));
 
-        let option = {
-            xAxis: {
-                data: [
-                    "星期一",
-                    "星期二",
-                    "星期三",
-                    "星期四",
-                    "星期五",
-                    "星期六",
-                    "星期日",
-                ],
-            },
-            yAxis: {},
-            series: [
-                {
-                    data: [10, 22, 28, 23, 19, 99, 81],
-                    type: "line",
-                    smooth: true,
-                    lineStyle: {
-                        normal: {
-                            color: "#3397FF",
-                        },
-                    },
-                },
-            ],
-            grid: {
-                top: '10%',
-                left: '40px',
-                right: '40px',
-                bottom: '10%',
-                containLabel: true
-            },
-        };
-        this.charts.setOption(option);
-    },
     methods: {
-        //绘制图表
-        drawLine() {
-            // 基于准备好的dom,初始化echarts实例
-            let id = "echartBar" + Math.random() * 1000;
-            this.$el.setAttribute("id", id);
-            let myChartContainer = document.getElementById(id);
-            // let myChartChina = echarts.init(myChartContainer);
-            let myChartChina = echarts.init("aa");
-            // 绘制图表
-            let optionMap = {
-                //折线图配置数据
-                color: ["#6cacaf", "#e4a526", "#e4391d", "#a1cb37", "#8c97cb"],
+        initStateList() {
+            let xData = [];
+            let yData = [];
+            for (let index = 0; index < this.dataList.length; index++) {
+                const element = this.dataList[index];
+                xData.push(element.toDate.slice(5));
+                yData.push(element.num);
+            }
+
+            let option = {
                 title: {
-                    x: "center",
-                    text: this.text,
-                    textStyle: {
-                        fontSize: this.titleSize,
-                    },
+                    text: "暂无数据",
+                    show: this.dataList.length === 0,
+                    left: "center",
+                    top: "center",
                 },
                 tooltip: {
-                    trigger: "axis",
-                },
-                legend: {
-                    top: [30],
-                    data: this.tipData,
-                },
-                grid: {
-                    left: "3%",
-                    right: "4%",
-                    bottom: "3%",
-                    containLabel: true,
-                },
-                toolbox: {
-                    show: this.download,
-                    top: [5],
-                    right: [20],
-                    feature: {
-                        saveAsImage: {},
+                    //提示框,可以在全局也可以在
+                    trigger: "item", //提示框的样式
+                    formatter: "{b}: {c}",
+                    color: "#000", //提示框的背景色
+                    textStyle: {
+                        //提示的字体样式
+                        color: "#ffffff",
                     },
+                    confine: true,
                 },
                 xAxis: {
-                    interval: ["0"], //标签显示间隔
                     type: "category",
                     boundaryGap: false,
-                    data: [
-                        "1月",
-                        "2月",
-                        "3月",
-                        "4月",
-                        "5月",
-                        "6月",
-                        "7月",
-                        "8月",
-                        "9月",
-                        "10月",
-                        "11月",
-                        "12月",
-                    ], //x轴数据
+                    data: xData,
                 },
                 yAxis: {
-                    name: "(万元)",
-                    nameGap: [10],
-                    type: "value",
+                    minInterval: 1,
+                },
+                series: [
+                    {
+                        data: yData,
+                        type: "line",
+                        smooth: true,
+                        symbol: "circle",
+                        symbolSize: 6,
+                        lineStyle: {
+                            normal: {
+                                width: 1.5,
+                                color: "#3397FF",
+                            },
+                        },
+                        areaStyle: {
+                            color: new echarts.graphic.LinearGradient(
+                                0,
+                                0,
+                                0,
+                                1,
+                                [
+                                    {
+                                        offset: 0,
+                                        color: "rgba(51, 151, 255, 0.42)",
+                                    },
+                                    {
+                                        offset: 1,
+                                        color: "rgba(170, 197, 255, 0.12)",
+                                    },
+                                ]
+                            ),
+                        },
+                        itemStyle: {
+                            normal: {
+                                color: "#3397FF",
+                            },
+                        },
+                    },
+                ],
+                grid: {
+                    top: "10%",
+                    left: "20px",
+                    right: "20px",
+                    bottom: "10%",
+                    containLabel: true,
                 },
-                series: this.showData,
-            };
-            myChartChina.setOption(optionMap);
-            window.onresize = function () {
-                myChartChina.resize();
             };
+            this.charts.setOption(option);
         },
     },
-    watch: {
-        "LineChartData.data": function (val) {
-            this.tipData = [];
-            this.showData = [];
-            for (let i = 0; i < val.length; i++) {
-                let obj = {
-                    //折线图需要的数据结构
-                    name: "",
-                    type: "line",
-                    data: [],
-                };
-                obj.name = val[i].name;
-                this.tipData.push(val[i].name);
-                for (let j = 0; j < val[i].monthlySales.length; j++) {
-                    obj.data.push(parseFloat(val[i].monthlySales[j]));
-                }
-                this.showData.push(obj);
-            }
-            this.drawLine();
-        },
+
+    mounted() {
+        this.charts = this.$echarts.init(document.getElementById(this.id));
+
+        this.initStateList();
+        
+        this.$nextTick(() => {
+            window.addEventListener("resize", () => {
+                this.charts.resize();
+            });
+        });
     },
+
     destroyed() {
-        console.log("destroyed");
+        // console.log("destroyed");
         this.charts.dispose();
     },
 };
 </script>
 
-
 <style lang='less' scoped>
 .linechart {
     margin: 0 auto;
+    overflow: hidden;
 }
-</style>
+</style>

+ 3 - 1
src/views/index.vue

@@ -27,9 +27,11 @@ export default {
             this.isFold = flag;
         },
     },
-    mounted() {
+    created() {
         let { code, ticket } = this.$route.query;
+
         if (code && ticket) {
+            localStorage.clear();
             this.$axios({
                 method: "post",
                 url: this.$api.common.single,

+ 48 - 75
src/views/mainPage.vue

@@ -16,27 +16,27 @@
                     <li class="shadowBox colorA">
                         <span></span>
                         <b>服务器数量</b>
-                        <i>120</i>
+                        <i>{{ hardware.serverNumber || 0 }}</i>
                     </li>
                     <li class="shadowBox colorB">
                         <span></span>
                         <b>内存使用率</b>
-                        <i>18%</i>
+                        <i>{{ hardware.memoryUsage || 0 }}</i>
                     </li>
                     <li class="shadowBox colorC">
                         <span></span>
                         <b>磁盘占用率</b>
-                        <i>24%</i>
+                        <i>{{ hardware.diskUsage || 0 }}</i>
                     </li>
                     <li class="shadowBox colorD">
                         <span></span>
                         <b>CPU使用率</b>
-                        <i>36%</i>
+                        <i>{{ hardware.cpuUsage || 0 }}</i>
                     </li>
                     <li class="shadowBox colorE">
                         <span></span>
                         <b>GPU使用率</b>
-                        <i>63%</i>
+                        <i>{{ hardware.gpuUsage || 0 }}</i>
                     </li>
                 </ul>
             </div>
@@ -48,23 +48,23 @@
                 <ul class="listPanel listPanelB">
                     <li class="shadowBox">
                         <b>用户数量</b>
-                        <i>369</i>
+                        <i>{{ serviceData.userNumber || 0 }}</i>
                     </li>
                     <li class="shadowBox">
                         <b>当前在线人数</b>
-                        <i>18</i>
+                        <i>{{ serviceData.onlineNumber || 0 }}</i>
                     </li>
                     <li class="shadowBox">
                         <b>仿真节点数量</b>
-                        <i>819</i>
+                        <i>{{ serviceData.simulationNodeNumber || 0 }}</i>
                     </li>
                     <li class="shadowBox">
                         <b>仿真软件license占用数量</b>
-                        <i>612</i>
+                        <i>{{ serviceData.simulationLicenseNumber || 0 }}</i>
                     </li>
                     <li class="shadowBox">
                         <b>动力学软件license占用数量</b>
-                        <i>423</i>
+                        <i>{{ serviceData.dynamicsLicenseNumber || 0 }}</i>
                     </li>
                 </ul>
             </div>
@@ -74,7 +74,11 @@
                     <div class="titlePanelBor">日访问人数</div>
                 </div>
                 <div class="chartABox shadowBox">
-                    <line-chart-main-page id="lineA"> </line-chart-main-page>
+                    <line-chart-main-page
+                        :dataList="dateAccessList"
+                        id="dateAccessList"
+                    >
+                    </line-chart-main-page>
                 </div>
             </div>
 
@@ -118,11 +122,11 @@
                     </li>
                     <li class="shadowBox">
                         <b>最大并发数量</b>
-                        <i>{{ dataOverview.a || 0 }}</i>
+                        <i>{{ dataOverview.maxConcurrency || 0 }}</i>
                     </li>
                     <li class="shadowBox">
                         <b>当前并发数量</b>
-                        <i>{{ dataOverview.b || 0 }}</i>
+                        <i>{{ dataOverview.currentConcurrency || 0 }}</i>
                     </li>
                 </ul>
             </div>
@@ -241,39 +245,39 @@ export default {
             columns: [
                 {
                     label: "服务器ID",
-                    prop: "id",
+                    prop: "serverId",
                 },
                 {
                     label: "服务器地址",
-                    prop: "ktName",
+                    prop: "serverAddress",
                 },
                 {
                     label: "服务器类型",
-                    prop: "jbSource",
+                    prop: "serverType",
                 },
                 {
-                    label: "CPU使用率",
-                    prop: "startDateStr",
+                    label: "CPU使用率(%)",
+                    prop: "cpuUsage",
                 },
                 {
-                    label: "内存使用率",
-                    prop: "endDateStr",
+                    label: "内存使用率(%)",
+                    prop: "memoryUsage",
                 },
                 {
                     label: "可用内存(G)",
-                    prop: "projectDateStr",
+                    prop: "memoryAvailable",
                 },
                 {
-                    label: "磁盘使用率",
-                    prop: "cgInfos",
+                    label: "磁盘使用率(%)",
+                    prop: "diskUsage",
                 },
                 {
                     label: "剩余容量(G)",
-                    prop: "endDateStr1",
+                    prop: "diskAvailable",
                 },
                 {
                     label: "执行任务数量",
-                    prop: "projectDateStr1",
+                    prop: "taskNumber",
                 },
             ],
             pagination: {
@@ -288,58 +292,16 @@ export default {
                 //加载表格数据
                 dataType: "data",
                 type: "post",
-                firstRequest: false,
-                data: [
-                    {
-                        id: 1,
-                        ktName: "127.0.0.1",
-                        jbSource: "收到就好付款时",
-                        startDateStr: "12%",
-                        endDateStr: "32%",
-                        projectDateStr: "35",
-                        cgInfos: "48%",
-                        endDateStr1: "50",
-                        projectDateStr1: "42",
-                    },
-                    {
-                        id: 2,
-                        ktName: "127.0.0.1",
-                        jbSource: "收付款时间的回复可",
-                        startDateStr: "1%",
-                        endDateStr: "2%",
-                        projectDateStr: "3",
-                        cgInfos: "24%",
-                        endDateStr1: "15",
-                        projectDateStr1: "6",
-                    },
-                    {
-                        id: 3,
-                        ktName: "127.0.0.1",
-                        jbSource: "收间的回复可",
-                        startDateStr: "12%",
-                        endDateStr: "24%",
-                        projectDateStr: "13",
-                        cgInfos: "4%",
-                        endDateStr1: "5",
-                        projectDateStr1: "16",
-                    },
-                ],
-                // data: this.$api.scientificStatistics.typeProjectStatistics,
+                data: [],
                 param: {},
             },
-            // 数据概览
-            dataOverview: {
-                SceneNum: 0,
-                ConfigTotal: 0,
-                fileNum: 0,
-                pathNum: 0,
-                a: 0,
-                b: 0,
-            },
-            // 运行项目
-            runProjectList: [],
-            // 运行任务
-            runTaskList: [],
+            hardware: {}, // 硬件监控
+            serviceData: {}, // 服务监控
+            dateAccessList: [], // 日访问人数
+            dataOverview: {}, // 数据概览
+            runProjectList: [], // 运行项目
+            runTaskList: [], // 运行任务
+            // 三个饼图
             dataListA: [],
             dataListB: [],
             dataListC: [],
@@ -382,6 +344,17 @@ export default {
             });
         },
         init() {
+            this.getData(this.$api.mainPage.selectHardware, "hardware");
+            this.getData(this.$api.mainPage.selectService, "serviceData");
+            this.getData(this.$api.mainPage.selectAccess, "dateAccessList");
+
+            this.getDataWay = {
+                dataType: "url",
+                type: "post",
+                data: this.$api.mainPage.selectServer,
+                param: {},
+            };
+
             this.getData(this.$api.mainPage.queryAllNum, "dataOverview");
             this.getData(
                 this.$api.mainPage.selectRunProjectBySy,

+ 2 - 2
vue.config.js

@@ -102,13 +102,13 @@ module.exports = {
             },
             '/simulation/resource/server': {
                 // target: 'http://10.15.12.73:7003', // 王志强
-                target: 'http://10.15.12.88:7003', // 王耀栋
+                // target: 'http://10.15.12.88:7003', // 王耀栋
                 // target: 'http://10.15.12.72:7003',  // 王晓峰
                 // target: 'http://10.15.12.87:7003',  // 赵艳
                 // target: 'http://10.15.12.70',  // windowstest
                 // target: 'http://192.168.30.75',  // gq
                 // target: 'http://47.94.105.148',  // aliyun
-                // target: 'http://10.15.12.74:7003', // 孟令鑫
+                target: 'http://10.15.12.74:7003', // 孟令鑫
                 changeOrigin: true,
                 secure: false, // 如果是https接口,需要配置这个参数
                 pathRewrite: {