Browse Source

智慧调度社区资产

Shannon_mu 2 years ago
parent
commit
6e646223a7

+ 66 - 25
commandCenter/src/components/common/Header.vue

@@ -23,15 +23,17 @@
             <div class="right-imgs"></div>
             <div>
                 <span class="selectIocn"></span>
-                <el-select
-                    v-model="communityId"
-                    placeholder="所有社区"
+                <el-cascader
                     class="saveColumn-select"
-                    @change="$store.commit('setHomeCommunityAll', communityId)"
+                    ref="multipleValue"
+                    :options="scOptions"
+                    :props="{ checkStrictly: true, label: 'name' }"
+                    collapse-tags
+                    :show-all-levels="false"
                     clearable
-                >
-                    <el-option v-for="(item, index) in communityList" :label="item.communityName" :value="item.id" :key="index"></el-option>
-                </el-select>
+                    @change="selectChange"
+                    v-model="communityValue"
+                ></el-cascader>
             </div>
 
             <div class="time">
@@ -85,21 +87,22 @@ export default {
                 week: '星期一',
                 date: '00:00:00'
             },
-            communityList: [],
-            communityId: ''
+            communityValue: [],
+            scOptions: []
         };
     },
     computed: {
-        ...mapState(['homeCommunityAll']),
+        ...mapState(['globalCommunity']),
         menuList() {
             return this.$store.getters['getMenuList'] || [];
         }
     },
     watch: {
-        homeCommunityAll(val) {
-            if (!!val) {
-                this.communityId = val;
-            }
+        globalCommunity: {
+            handler(newVal, oldVal) {
+                console.log(newVal, oldVal);
+            },
+            deep: true
         }
     },
     methods: {
@@ -138,21 +141,59 @@ export default {
             this.time.week = this.$moment().format('dddd');
             this.time.thisTime = this.$moment().format('YYYY/MM/DD');
         },
+        selectChange() {
+            let thisValue = this.$refs.multipleValue.getCheckedNodes()[0];
+            // 选择是否为公司
+            if (!!thisValue && thisValue.data.type == 'org') {
+                let arrs = [];
+                let ids = [thisValue.value];
+                this.fitersValue(arrs, thisValue.data);
+                arrs.map((item) => {
+                    ids.push(item.value);
+                });
+                this.$store.commit('setGlobalCommunity', {
+                    type: 'org',
+                    value: ids
+                });
+            } else {
+                this.$store.commit('setGlobalCommunity', {
+                    value: [thisValue.value]
+                });
+            }
+        },
+        fitersValue(arrs, value) {
+            value.children.map((item) => {
+                if (item.type == 'org') {
+                    arrs.push(item);
+                    if (!!item.children) {
+                        this.fitersValue(arrs, item);
+                    }
+                }
+            });
+        },
         communityNameList() {
             this.$http.get('/sc-community/assets/tree/community/findCompanyCommunityTree').then(({ data, msg, status }) => {
                 if (status == 0) {
-                    // this.communityList = data;
-                    // this.$store.commit('setAreaSelect', data);
-                    console.log(data)
+                    this.scOptions = data;
+                    this.communityValue = [data[0].value];
+                    if (data[0].type == 'org') {
+                        let arrs = [];
+                        let ids = [data[0].value];
+                        this.fitersValue(arrs, data[0]);
+                        arrs.map((item) => {
+                            ids.push(item.value);
+                        });
+                        this.$store.commit('setGlobalCommunity', {
+                            type: 'org',
+                            value: ids
+                        });
+                    } else {
+                        this.$store.commit('setGlobalCommunity', {
+                            value: [data[0].value]
+                        });
+                    }
                 }
             });
-
-            // this.$http.get('/sc-community/assets/community/list').then(({ data, msg, status }) => {
-            //     if (status == 0) {
-            //         this.communityList = data;
-            //         this.$store.commit('setAreaSelect', data);
-            //     }
-            // });
         },
         selectTab(item, index) {
             this.tagTabIndex = index;
@@ -267,7 +308,7 @@ $colorOption: rgba(250, 250, 250, 0.6);
             height: 24px;
             background-image: url('~@/assets/img/homeTop/icon_shequ@2x.png');
             background-size: cover;
-            margin-top: 5px;
+            vertical-align: text-bottom;
         }
         .time {
             display: flex;

+ 9 - 43
commandCenter/src/store/store.js

@@ -20,27 +20,17 @@ const store = new Vuex.Store({
         thisDetai: {},
         //查询是否有未读消息
         messageNumber: false,
-        //最近消息列表集合
-        messageList: [],
-        //记录消息的状态
-        messageStatus: 2,
         // 弹窗集合
         popups: '',
         theme: 'light', //控制界面的颜色,
-        // 查询的点的坐标
-        searchPointInfo: {},
         //所有社区下拉
         areaSelect: [],
-        //所有民族
-        nationArray: [],
-        //所有籍贯
-        nativeArray: [],
         //公司部门
         companyArray: [],
-        departmentArray: [],
         communityArray: [],
         homeCommunityAll: '',
-        scale: ""
+        scale: "",
+        globalCommunity: {}
     },
     getters: {
         getTheme(state) {
@@ -52,9 +42,6 @@ const store = new Vuex.Store({
         getToken(state) {
             return state.token;
         },
-        getSearchPointInfo(state) {
-            return state.searchPointInfo;
-        },
         getCollapse(state) {
             return state.collapse;
         },
@@ -86,18 +73,9 @@ const store = new Vuex.Store({
         getAreaSelect(state) {
             return state.areaSelect;
         },
-        getNationArray(state) {
-            return state.nationArray;
-        },
-        getNativeArray(state) {
-            return state.nativeArray;
-        },
         getCompanyArray(state) {
             return state.companyArray;
         },
-        getDepartmentArray(state) {
-            return state.departmentArray;
-        },
         getCommunityArray(state) {
             return state.communityArray;
         },
@@ -107,11 +85,11 @@ const store = new Vuex.Store({
         getScale(state) {
             return state.scale;
         },
+        getGlobalCommunity(state) {
+            return state.globalCommunity;
+        }
     },
     mutations: {
-        setSearchPointInfo(state, data) {
-            state.searchPointInfo = data;
-        },
         setPopups(state, data) {
             state.popups = data;
         },
@@ -142,30 +120,15 @@ const store = new Vuex.Store({
         setmessageNumber(state, data) {
             state.messageNumber = data;
         },
-        setmessageList(state, data) {
-            state.messageList = data;
-        },
-        setmessageStatus(state, data) {
-            state.messageStatus = data;
-        },
         setTheme(state, data) {
             state.theme = data;
         },
         setAreaSelect(state, data) {
             state.areaSelect = data;
         },
-        setNationArray(state, data) {
-            state.nationArray = data;
-        },
-        setNativeArray(state, data) {
-            state.nativeArray = data;
-        },
         setCompanyArray(state, data) {
             state.companyArray = data;
         },
-        setDepartmentArray(state, data) {
-            state.departmentArray = data;
-        },
         setCommunityArray(state, data) {
             state.communityArray = data;
         },
@@ -175,6 +138,9 @@ const store = new Vuex.Store({
         setScale(state, data) {
             state.scale = data;
         },
+        setGlobalCommunity(state, data) {
+            state.globalCommunity = data;
+        }
     },
     actions: {
         tags(ctx, data) {
@@ -245,7 +211,7 @@ const store = new Vuex.Store({
                     ctx.commit('setModalParams', params);
                 })
                 .catch((err) => {
-                   this.$message.error(`${err.message},请刷新页面重试`);
+                    this.$message.error(`${err.message},请刷新页面重试`);
                 });
         },
         closeModal(ctx) {

+ 22 - 7
commandCenter/src/views/communityAssets/assembly/allcommunit.js

@@ -7,7 +7,7 @@ export default {
     },
     computed: {
         //全局社区
-        ...mapState(['homeCommunityAll']),
+        ...mapState(['globalCommunity']),
 
         resize() {
             // 通过scale值来判断窗口是变化
@@ -15,10 +15,19 @@ export default {
         }
     },
     watch: {
-        //全局社区接口调用
-        homeCommunityAll(n) {
-            this.mixins_query.communityId = n;
-            this.getData();
+        globalCommunity: {
+            handler(newVal, oldVal) {
+                if (!!newVal.type) {
+                    this.mixins_query.communityId = null;
+                    this.mixins_query.companyIds = newVal.value.join();
+                } else {
+                    this.mixins_query.companyIds = null;
+                    this.mixins_query.communityId = newVal.value.join();
+                }
+
+                this.getData();
+            },
+            deep: true
         },
         resize(va) {
             // console.log(va);
@@ -26,7 +35,13 @@ export default {
     },
     methods: {},
     created() {
-        this.mixins_query.communityId = this.homeCommunityAll;
-        // this.getData();
+        const { type, value } = this.globalCommunity
+        if (!!type) {
+            this.mixins_query.communityId = null;
+            this.mixins_query.companyIds = value.join();
+        } else {
+            this.mixins_query.companyIds = null;
+            this.mixins_query.communityId = value.join();
+        }
     }
 };