张延森 5 年之前
父節點
當前提交
9ab1ea2b76
共有 6 個文件被更改,包括 73 次插入5 次删除
  1. 47
    1
      src/components/SelectBuilding.vue
  2. 2
    2
      src/components/charts/XLine.vue
  3. 2
    0
      src/main.js
  4. 20
    1
      src/store/system.js
  5. 1
    0
      src/views/indexEcharts/index.vue
  6. 1
    1
      vue.config.js

+ 47
- 1
src/components/SelectBuilding.vue 查看文件

1
 <template>
1
 <template>
2
-  
2
+  <el-select v-model="val" filterable placeholder="请选择">
3
+    <el-option
4
+      v-for="item in buildings"
5
+      :key="item.buildingId"
6
+      :label="item.buildingName"
7
+      :value="item.buildingId">
8
+    </el-option>
9
+  </el-select>
3
 </template>
10
 </template>
11
+
12
+<script>
13
+import { mapState, mapActions } from 'vuex'
14
+
15
+export default {
16
+  name: 'SelectBuilding',
17
+  props: [ 'value' ],
18
+  data () {
19
+    return {
20
+      cacheVal: null,
21
+    }
22
+  },
23
+  computed: {
24
+    ...mapState({
25
+      buildings: s => s.buildings || [],
26
+    }),
27
+    val: {
28
+      get() {
29
+        return this.value || this.cacheVal
30
+      },
31
+      set (nw) {
32
+        this.cacheVal = nw
33
+        this.$emit('input', nw)
34
+      }
35
+    },
36
+  },
37
+  created () {
38
+    if (!this.buildings || !this.buildings.length) {
39
+      this.getBuildings()
40
+    }
41
+  },
42
+  methods: {
43
+    ...mapActions([
44
+      'getBuildings',
45
+    ]),
46
+  },
47
+}
48
+</script>
49
+

+ 2
- 2
src/components/charts/XLine.vue 查看文件

1
 <template>
1
 <template>
2
-   <div ref="echart" ></div>
2
+  <div ref="echart" ></div>
3
 </template>
3
 </template>
4
 <script>
4
 <script>
5
 import Echarts from "echarts";
5
 import Echarts from "echarts";
9
   props: {
9
   props: {
10
     value: {
10
     value: {
11
       type: Object,
11
       type: Object,
12
-      default: {},
12
+      default: () => {},
13
     },
13
     },
14
   },
14
   },
15
   data() {
15
   data() {

+ 2
- 0
src/main.js 查看文件

5
 import XMRightLay from '@/components/XMRightLay.vue'
5
 import XMRightLay from '@/components/XMRightLay.vue'
6
 import XMSearchForm from '@/components/XMSearchForm.vue'
6
 import XMSearchForm from '@/components/XMSearchForm.vue'
7
 import RichEditor from '@/components/RichEditor.vue'
7
 import RichEditor from '@/components/RichEditor.vue'
8
+import SelectBuilding from '@/components/SelectBuilding'
8
 
9
 
9
 import App from './App.vue'
10
 import App from './App.vue'
10
 import router from './router'
11
 import router from './router'
27
 Vue.component('xm-rtl', XMRightLay)
28
 Vue.component('xm-rtl', XMRightLay)
28
 Vue.component('xm-search', XMSearchForm)
29
 Vue.component('xm-search', XMSearchForm)
29
 Vue.component('rich-editor', RichEditor)
30
 Vue.component('rich-editor', RichEditor)
31
+Vue.component('select-building', SelectBuilding)
30
 Vue.use(VueAMap)
32
 Vue.use(VueAMap)
31
 
33
 
32
 VueAMap.initAMapApiLoader({
34
 VueAMap.initAMapApiLoader({

+ 20
- 1
src/store/system.js 查看文件

10
     },
10
     },
11
     menus: [],
11
     menus: [],
12
     user: {},
12
     user: {},
13
+    buildings: [],
13
   },
14
   },
14
   mutations: {
15
   mutations: {
15
     updateUser(state, user) {
16
     updateUser(state, user) {
17
         ...state.user,
18
         ...state.user,
18
         ...user,
19
         ...user,
19
       }
20
       }
21
+    },
22
+    updateBuildings(state, buildings) {
23
+      state.buildings = buildings || []
20
     }
24
     }
21
   },
25
   },
22
   actions: {
26
   actions: {
54
         localStorage.removeItem('x-token')
58
         localStorage.removeItem('x-token')
55
         commit('updateUser', {})
59
         commit('updateUser', {})
56
       })
60
       })
57
-    }
61
+    },
62
+    getBuildings ({ commit }) {
63
+      return new Promise((resolve, reject) => {
64
+        request({
65
+          ...apis.building.list,
66
+          params: { pageSize: 999 },
67
+        }).then((data) => {
68
+          commit('updateBuildings',  data.records)
69
+          resolve(data)
70
+        }).catch(({ message }) => {
71
+          if (typeof message === 'string') {
72
+            reject(message)
73
+          }
74
+        })
75
+      })
76
+    },
58
   }
77
   }
59
 }
78
 }

+ 1
- 0
src/views/indexEcharts/index.vue 查看文件

20
       </div>
20
       </div>
21
     </el-col>
21
     </el-col>
22
   </el-row>
22
   </el-row>
23
+  <select-building></select-building>
23
   <p class="title under-line" @click="toUserSource()">用户来源</p>
24
   <p class="title under-line" @click="toUserSource()">用户来源</p>
24
   <span class="title-desc under-line" @click="toUserSource()">最近7天</span>
25
   <span class="title-desc under-line" @click="toUserSource()">最近7天</span>
25
   <el-row :gutter="20" :style="{ height: '560px',margin:'20px 0',border:'1px solid #eee',borderRadius:'5px'}">
26
   <el-row :gutter="20" :style="{ height: '560px',margin:'20px 0',border:'1px solid #eee',borderRadius:'5px'}">

+ 1
- 1
vue.config.js 查看文件

4
     port: 8080,
4
     port: 8080,
5
     proxy: {
5
     proxy: {
6
       '/api': {
6
       '/api': {
7
-        target: 'http://192.168.0.131:8080',
7
+        target: 'http://192.168.0.11:8080',
8
         // target: 'http://localhost:8080',
8
         // target: 'http://localhost:8080',
9
         changeOrigin: true,
9
         changeOrigin: true,
10
         // pathRewrite: {
10
         // pathRewrite: {