Blame view

src/components/index/index-dev.vue 6.16 KB
a42b3256   wuxw   HC小区管理系统前段vue版正在开发中
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
  <template>
      <div>
          <div class="vc-index-nav">
              <span><i class="fa fa-home margin-right-sm"></i>首页</span><span
                  class="margin-left-sm margin-right-sm">/</span><span>开发中心</span>
          </div>
          <el-row :gutter="20">
              <el-col :span="4" class=" margin-bottom" v-for="(item, index) in datas" :key="index">
                  <div class="white-bg text-center padding-top border-radius" style="height:140px;border: 1px solid #e0e5eb;">
                      <div style="font-size: 38px;font-weight: 600;" class="margin-top" :style="{ 'color': item.color }">{{
                          item.value }}</div>
                      <div class="margin-top-lg" style="font-size: 20px;font-weight: 100;">{{ item.name }}</div>
                  </div>
              </el-col>
          </el-row>
          <el-row :gutter="20">
              <el-col :span="12">
                  <div class="ibox">
                      <div class="ibox-title">
                          <h5>常用功能</h5>
                      </div>
                      <div class="ibox-content">
                          <el-row class="white-bg padding margin-xs">
                              <el-col :span="6" class=" text-center  margin-top margin-bottom" style="cursor:pointer"
                                  v-for="(item, index) in pages" :key="index">
                                  <div @click="newFlow(item)">
                                      <div>
                                          <img :src="item.icon" width="60px" />
                                      </div>
                                      <div class="margin-top-sm">
                                          <span>{{ item.name }}</span>
                                      </div>
                                  </div>
                              </el-col>
                          </el-row>
                      </div>
                  </div>
              </el-col>
              <el-col :span="12">
                  <div ref="chartDom" style="height:400px;width: 96%;" class="bg-white padding border-radius">
                  </div>
              </el-col>
          </el-row>
      </div>
  </template>
    
  <script>
  import { queryDevCount, queryAppServiceData } from '@/api/user/indexApi'
  import * as echarts from 'echarts'
  export default {
      name: 'indexDev',
      components: {
  
      },
      data() {
          return {
              datas: [],
              action: '',
              pages: [{
                  name: '应用',
                  url: '/#/pages/dev/appManage?tab=应用信息',
                  icon: '/img/app.png'
              }, {
                  name: '服务',
                  url: '/#/pages/dev/serviceManage?tab=服务信息',
                  icon: '/img/api.png'
              }, {
                  name: '服务注册',
                  url: '/#/pages/dev/serviceRegisterManage?tab=服务注册',
                  icon: '/img/register.png'
              }, {
                  name: '菜单维护',
                  url: '/#/pages/dev/menuManage?tab=菜单维护',
                  icon: '/img/menu.png'
              }, {
                  name: '配置中心',
                  url: '/#/pages/dev/mappingManage?tab=配置中心',
                  icon: '/img/config.png'
              }, {
                  name: '刷新缓存',
                  url: '/#/pages/dev/cacheManage?tab=刷新缓存',
                  icon: '/img/cache.png'
              }, {
                  name: '定时任务',
                  url: '/#/pages/dev/jobManage?tab=定时任务',
                  icon: '/img/job.png'
              }],
          }
      },
      created() {
          this._loadData()
          this._loadAppServiceData()
      },
      methods: {
          newFlow(item) {
              console.log(item)
              this.$router.push(item.url)
          },
          async _loadData() {
              this.loading = true
              try {
                  const _json = await queryDevCount()
                  for (let _index = 0; _index < _json.data.length; _index++) {
                      if (_index % 4 == 0) {
                          _json.data[_index].color = "#1acda1";
                      }
                      if (_index % 4 == 1) {
                          _json.data[_index].color = "#ffae11";
                      }
                      if (_index % 4 == 2) {
                          _json.data[_index].color = "#ff7911";
                      }
                      if (_index % 4 == 3) {
                          _json.data[_index].color = "#3a68f2";
                      }
                  }
                  this.datas = _json.data;
              } catch (error) {
                  console.error('登录失败:', error)
              } finally {
                  this.loading = false
              }
          },
          async _loadAppServiceData() {
              this.loading = true
              try {
                  const _json = await queryAppServiceData()
                  this._initDevIndexAppServiceCharts(_json.data)
              } catch (error) {
                  console.error('登录失败:', error)
              } finally {
                  this.loading = false
              }
          },
          _initDevIndexAppServiceCharts: function (_data) {
              const chartDom = this.$refs.chartDom
              let _source = [
                  ['product', '接口数'],
              ];
  
              _data.forEach(item => {
                  _source.push([
                      item.name,
                      item.serviceCount,
                  ])
              });
  
              let myChart = echarts.init(chartDom);
              let option = null;
              option = {
                  legend: {},
                  tooltip: {},
                  title: {
                      show: "true",
                      text: '应用接口数'
                  },
                  color: ['#66CDAA'],
                  dataset: {
                      source: _source
                  },
                  xAxis: { type: 'category' },
                  yAxis: {},
                  series: [
                      { type: 'bar' }
                  ]
              };
  
              if (option && typeof option === "object") {
                  myChart.setOption(option, true);
              }
  
          },
      }
  }
  </script>
    
  <style lang="scss" scoped>
  .vc-index-nav {
      padding: 10px;
      font-size: 16px;
      text-align: left;
  }
  </style>