张延森 5 years ago
parent
commit
9ab1ea2b76

+ 47
- 1
src/components/SelectBuilding.vue View File

@@ -1,3 +1,49 @@
1 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 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 View File

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

+ 2
- 0
src/main.js View File

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

+ 20
- 1
src/store/system.js View File

@@ -10,6 +10,7 @@ export default {
10 10
     },
11 11
     menus: [],
12 12
     user: {},
13
+    buildings: [],
13 14
   },
14 15
   mutations: {
15 16
     updateUser(state, user) {
@@ -17,6 +18,9 @@ export default {
17 18
         ...state.user,
18 19
         ...user,
19 20
       }
21
+    },
22
+    updateBuildings(state, buildings) {
23
+      state.buildings = buildings || []
20 24
     }
21 25
   },
22 26
   actions: {
@@ -54,6 +58,21 @@ export default {
54 58
         localStorage.removeItem('x-token')
55 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 View File

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

+ 1
- 1
vue.config.js View File

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