|
1 | 1 | <template>
|
2 | 2 | <div class="dashboard-container">
|
3 |
| - <div class="dashboard-text">name: {{ name }}</div> |
| 3 | + |
| 4 | + <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;"> |
| 5 | + <legend>服务器信息</legend> |
| 6 | + </fieldset> |
| 7 | + <el-card class="box-card"> |
| 8 | + <el-collapse v-model="activeNames" @change="handleChange"> |
| 9 | + <el-collapse-item title="服务器配置" name="1"> |
| 10 | + <el-table :data="serve" style="width: 100%"> |
| 11 | + <el-table-column prop="name" label="名称" width="" /> |
| 12 | + <el-table-column prop="value" label="数值" width="" /> |
| 13 | + </el-table> |
| 14 | + </el-collapse-item> |
| 15 | + </el-collapse> |
| 16 | + </el-card> |
| 17 | + |
| 18 | + <el-card class="box-card"> |
| 19 | + <el-collapse v-model="activeNames" @change="handleChange"> |
| 20 | + <el-collapse-item title="服务器配置" name="2"> |
| 21 | + <el-table :data="php" style="width: 100%"> |
| 22 | + <el-table-column prop="name" label="名称" width="" /> |
| 23 | + <el-table-column prop="value" label="数值" width="" /> |
| 24 | + </el-table> |
| 25 | + </el-collapse-item> |
| 26 | + </el-collapse> |
| 27 | + </el-card> |
| 28 | + |
| 29 | + <div class="clearfix" /> |
| 30 | + <fieldset class="clearfix layui-elem-field layui-field-title" style="margin-top: 20px;"> |
| 31 | + <legend>管理员信息</legend> |
| 32 | + </fieldset> |
| 33 | + <el-card class="box-card"> |
| 34 | + <div class="dashboard-text">name:{{ name }}</div> |
| 35 | + <div class="dashboard-text">roles:<span v-for="role in roles" :key="role">{{ role }}</span></div> |
| 36 | + </el-card> |
| 37 | + <el-card class="box-card"> |
| 38 | + <div id="chartLine" style="width:100%; height:400px;" /> |
| 39 | + </el-card> |
| 40 | + <div class="clearfix" /> |
4 | 41 | </div>
|
5 | 42 | </template>
|
6 | 43 |
|
7 | 44 | <script>
|
8 | 45 | import { mapGetters } from 'vuex'
|
| 46 | +import { getList, report } from '../../api/dashboard' |
| 47 | +import echarts from 'echarts' |
9 | 48 |
|
10 | 49 | export default {
|
11 | 50 | name: 'Dashboard',
|
| 51 | + data() { |
| 52 | + return { |
| 53 | + loading: false, |
| 54 | + is_serve: true, |
| 55 | + is_php: true, |
| 56 | + serve: [], |
| 57 | + php: [], |
| 58 | + activeNames: ['1', '2'], |
| 59 | + chartLine: null, |
| 60 | + xData: ['周一', '周二', '周三', '周四', '周五', '周六', '周日'] |
| 61 | + } |
| 62 | + }, |
12 | 63 | computed: {
|
13 | 64 | ...mapGetters([
|
14 |
| - 'name' |
| 65 | + 'name', |
| 66 | + 'roles' |
15 | 67 | ])
|
| 68 | + }, |
| 69 | + created() { |
| 70 | + this.init() |
| 71 | + }, |
| 72 | + mounted() { |
| 73 | + // this.drawLineChart() |
| 74 | + }, |
| 75 | + updated() { |
| 76 | + // this.drawLineChart() |
| 77 | + }, |
| 78 | + methods: { |
| 79 | + init() { |
| 80 | + this.loading = true |
| 81 | + getList().then(response => { |
| 82 | + this.loading = false |
| 83 | + this.serve = response.data.serve |
| 84 | + this.php = response.data.php |
| 85 | + }) |
| 86 | + report({ section: 7 }).then(res => { |
| 87 | + this.xData = res.data.date |
| 88 | + this.yData = res.data.success_slide |
| 89 | + this.drawLineChart() |
| 90 | + }).catch(err => { |
| 91 | + console.log(err) |
| 92 | + this.drawLineChart() |
| 93 | + }) |
| 94 | + }, |
| 95 | + closeServe() { |
| 96 | + this.is_serve = false |
| 97 | + }, |
| 98 | + closePhp() { |
| 99 | + this.is_php = false |
| 100 | + }, |
| 101 | + handleChange(val) { |
| 102 | + console.log(val) |
| 103 | + }, |
| 104 | + drawLineChart() { |
| 105 | + this.chartLine = echarts.init(document.getElementById('chartLine')) |
| 106 | + this.chartLine.setOption({ |
| 107 | + color: ['#3398DB'], |
| 108 | + title: { |
| 109 | + text: '登录日志数据' |
| 110 | + }, |
| 111 | + tooltip: { |
| 112 | + trigger: 'axis', |
| 113 | + axisPointer: { // 坐标轴指示器,坐标轴触发有效 |
| 114 | + type: 'shadow' // 默认直线,可选 'line'|'shadow' |
| 115 | + } |
| 116 | + }, |
| 117 | + legend: { |
| 118 | + data: ['登录成功'] |
| 119 | + }, |
| 120 | + grid: { |
| 121 | + left: '3%', |
| 122 | + right: '4%', |
| 123 | + bottom: '3%', |
| 124 | + containLabel: true |
| 125 | + }, |
| 126 | + xAxis: { |
| 127 | + type: 'category', |
| 128 | + boundaryGap: false, |
| 129 | + data: this.xData, |
| 130 | + axisTick: { |
| 131 | + alignWithLabel: true |
| 132 | + } |
| 133 | + }, |
| 134 | + yAxis: { |
| 135 | + type: 'value' |
| 136 | + }, |
| 137 | + series: [ |
| 138 | + { |
| 139 | + barWidth: '60%', |
| 140 | + name: '登录成功', |
| 141 | + type: 'line', // 'bar','line' |
| 142 | + stack: '总量', |
| 143 | + data: this.yData, |
| 144 | + smooth: true |
| 145 | + } |
| 146 | + ] |
| 147 | + }) |
| 148 | + } |
16 | 149 | }
|
17 | 150 | }
|
18 | 151 | </script>
|
19 | 152 |
|
20 |
| -<style lang="scss" scoped> |
21 |
| -.dashboard { |
22 |
| - &-container { |
23 |
| - margin: 30px; |
| 153 | +<style rel="stylesheet/scss" lang="scss" scoped> |
| 154 | + .dashboard { |
| 155 | + &-container { |
| 156 | + margin: 30px; |
| 157 | + } |
| 158 | +
|
| 159 | + &-text { |
| 160 | + font-size: 30px; |
| 161 | + line-height: 46px; |
| 162 | + } |
24 | 163 | }
|
25 |
| - &-text { |
26 |
| - font-size: 30px; |
27 |
| - line-height: 46px; |
| 164 | +
|
| 165 | + .text { |
| 166 | + font-size: 14px; |
| 167 | + } |
| 168 | +
|
| 169 | + .item { |
| 170 | + margin-bottom: 18px; |
| 171 | + } |
| 172 | +
|
| 173 | + .clearfix:before, |
| 174 | + .clearfix:after { |
| 175 | + display: table; |
| 176 | + content: ""; |
| 177 | + } |
| 178 | +
|
| 179 | + .clearfix:after { |
| 180 | + clear: both |
| 181 | + } |
| 182 | +
|
| 183 | + .box-card { |
| 184 | + width: 40%; |
| 185 | + float: left; |
| 186 | + margin: 0 2%; |
28 | 187 | }
|
29 |
| -} |
30 | 188 | </style>
|
0 commit comments