Browse Source

计划外列表页面刷新优化

zhujindu 11 months ago
parent
commit
ac9547df45
3 changed files with 174 additions and 111 deletions
  1. 1 0
      src/store/getters.js
  2. 8 1
      src/store/modules/isRefreshPage.js
  3. 165 110
      src/views/deviceOutside/index.vue

+ 1 - 0
src/store/getters.js

@@ -1,5 +1,6 @@
 const getters = {
   userInfo: (state) => state.user.userInfo,
   refreshClewPage: (state) => state.isRefreshPage.refreshClewPage,
+  deviceOutsidePage: (state) => state.isRefreshPage.deviceOutsidePage,
 };
 export default getters;

+ 8 - 1
src/store/modules/isRefreshPage.js

@@ -1,18 +1,25 @@
 const isRefreshPage = {
   state: {
-    refreshClewPage: false,
+    refreshClewPage: false, //刷新客资页面
+    deviceOutsidePage: false, //刷新计划外页面
   },
 
   mutations: {
     SET_REFRESH_CLEW_PAGE: (state, value) => {
       state.refreshClewPage = value;
     },
+    SET_DEVICE_OUTSIDE_PAGE: (state, value) => {
+      state.deviceOutsidePage = value;
+    },
   },
 
   actions: {
     setRefreshClewPage({ commit }, value) {
       commit('SET_REFRESH_CLEW_PAGE', value);
     },
+    setDeviceOutsidePage({ commit }, value) {
+      commit('SET_DEVICE_OUTSIDE_PAGE', value);
+    },
   },
 };
 

+ 165 - 110
src/views/deviceOutside/index.vue

@@ -511,9 +511,16 @@ import xmgj from '@/assets/xmgj.png';
 import { getOrderUrlByStoreId } from '@/api/inventory';
 import { checkStoreAddressByStoreCode } from '@/api/visitstore';
 import { getPosition, getMapPoi, getkeywordPoi, getTicketFun } from '@/utils/TXApiFun';
+import { mapState } from 'vuex';
+import store from '@/store';
 export default {
   name: 'outsidelist',
   components: { tabBar, mapmarker },
+  computed: {
+    ...mapState({
+      deviceOutsidePage: (state) => state.isRefreshPage.deviceOutsidePage,
+    }),
+  },
   data() {
     return {
       yichang: yichang,
@@ -599,123 +606,164 @@ export default {
     };
   },
   watch: {
-    $route(to, from) {
-      this.storeName = localStorage.getItem('outvstoreName');
-      this.chainName = localStorage.getItem('outvchainName');
-      if (localStorage.getItem('lat') != null) {
-        this.lat = localStorage.getItem('lat');
-        this.lon = localStorage.getItem('lon');
-      } else {
-        this.lat = '';
-        this.lon = '';
-      }
+    deviceOutsidePage: {
+      handler(val) {
+        if (val) this.initData();
+        store.dispatch('setDeviceOutsidePage', false);
+      },
+      immediate: true,
+    },
+    // $route(to, from) {
+    //   this.storeName = localStorage.getItem('outvstoreName');
+    //   this.chainName = localStorage.getItem('outvchainName');
+    //   if (localStorage.getItem('lat') != null) {
+    //     this.lat = localStorage.getItem('lat');
+    //     this.lon = localStorage.getItem('lon');
+    //   } else {
+    //     this.lat = '';
+    //     this.lon = '';
+    //   }
+
+    //   if (localStorage.getItem('outvstoreLabelTypes') != null) {
+    //     this.storeLabelTypes = localStorage.getItem('outvstoreLabelTypes').split(',');
+    //   } else {
+    //     this.storeLabelTypes = [];
+    //   }
 
+    //   if (localStorage.getItem('outvstoreCategoryList') != null) {
+    //     this.result = localStorage.getItem('outvstoreCategoryList').split(',');
+    //     this.storeLabelTypes = [];
+    //     this.storeCategoryList = this.result.join(',');
+    //   } else {
+    //     this.result = [];
+    //     this.storeCategoryList = this.result.join(',');
+    //   }
+    //   this.chainCode = localStorage.getItem('outvchainCode');
+    //   this.storeName = localStorage.getItem('outvstoreName');
+    //   if (
+    //     (from.path == '/My/index' && to.path == '/outsidelist/index') ||
+    //     (from.path == '/home' && to.path == '/outsidelist/index') ||
+    //     (from.path == '/deviceWithin/index' && to.path == '/outsidelist/index') ||
+    //     (from.path == '/storemanagement/index' && to.path == '/outsidelist/index')
+    //   ) {
+    //     this.tabVal = '1';
+    //   } else {
+    //     if (localStorage.getItem('tabVal') != null) {
+    //       this.tabVal = localStorage.getItem('tabVal');
+    //     }
+    //   }
+    //   if (
+    //     (from.path == '/storeDetail' && to.path == '/outsidelist/index') ||
+    //     (from.path == '/storeGroup' && to.path == '/outsidelist/index') ||
+    //     (from.path == '/suishenbangOutstoreVisit' && to.path == '/outsidelist/index') ||
+    //     (from.path == '/outabnormalVisit' && to.path == '/outsidelist/index') ||
+    //     (from.path == '/home' && to.path == '/outsidelist/index') ||
+    //     (from.path == '/deviceWithin/index' && to.path == '/outsidelist/index') ||
+    //     (from.path == '/storemanagement/index' && to.path == '/outsidelist/index') ||
+    //     (from.path == '/My/index' && to.path == '/outsidelist/index')
+    //   ) {
+    //     this.onSearch();
+    //   }
+    //   var postType = localStorage.getItem('postType');
+    //   if (postType == 'GZ') {
+    //     this.addShow1 = false;
+    //     this.otherShow = true;
+    //   } else {
+    //     this.addShow1 = true;
+    //     this.otherShow = false;
+    //   }
+    //   if (localStorage.getItem('postType') == 'JZ' || localStorage.getItem('postType') == 'GZ') {
+    //     this.mapShows = false;
+    //   } else {
+    //     this.mapShows = true;
+    //   }
+    //   this.getMonth();
+    // },
+  },
+  created() {
+    // this.storeName = localStorage.getItem('outvstoreName');
+    // this.chainName = localStorage.getItem('outvchainName');
+    // if (localStorage.getItem('outvstoreLabelTypes') != null) {
+    //   this.storeLabelTypes = localStorage.getItem('outvstoreLabelTypes').split(',');
+    // } else {
+    //   this.storeLabelTypes = [];
+    // }
+    // if (localStorage.getItem('outvstoreCategoryList') != null) {
+    //   this.result = localStorage.getItem('outvstoreCategoryList').split(',');
+    //   this.storeCategoryList = this.result.join(',');
+    // } else {
+    //   this.result = [];
+    //   this.storeCategoryList = this.result.join(',');
+    // }
+    // this.chainCode = localStorage.getItem('outvchainCode');
+    // this.storeName = localStorage.getItem('outvstoreName');
+    // if (localStorage.getItem('tabVal') == null || this.$route.query.info != 'y') {
+    //   if (this.$route.query.info != undefined) {
+    //     if (this.$route.query.info.indexOf('y') != -1) {
+    //       this.tabVal = localStorage.getItem('tabVal');
+    //     } else {
+    //       this.tabVal = '1';
+    //     }
+    //   } else {
+    //     this.tabVal = localStorage.getItem('tabVal');
+    //   }
+    // } else {
+    //   this.tabVal = localStorage.getItem('tabVal');
+    // }
+    // if (localStorage.getItem('postType') == 'JZ' || localStorage.getItem('postType') == 'GZ') {
+    //   this.mapShows = false;
+    // } else {
+    //   this.mapShows = true;
+    // }
+    // this.query = this.$route.query;
+    // localStorage.removeItem('visitId');
+    // this.getStoreTypeList();
+    // this.getStoreLabels();
+    var postType = localStorage.getItem('postType');
+    if (postType == 'GZ') {
+      this.addShow1 = false;
+      this.otherShow = true;
+    } else {
+      this.addShow1 = true;
+      this.otherShow = false;
+    }
+    this.getMonth();
+  },
+  methods: {
+    initData() {
+      // 筛选-门店标签
       if (localStorage.getItem('outvstoreLabelTypes') != null) {
         this.storeLabelTypes = localStorage.getItem('outvstoreLabelTypes').split(',');
       } else {
         this.storeLabelTypes = [];
       }
-
+      this.storeName = localStorage.getItem('outvstoreName'); //搜索框内容
+      this.chainName = localStorage.getItem('outvchainName'); //筛选-经销商名称搜索
+      this.chainCode = localStorage.getItem('outvchainCode'); //筛选-经销商Code
+      // 地图是否显示 家装和工装不显示
+      if (localStorage.getItem('postType') == 'JZ' || localStorage.getItem('postType') == 'GZ') {
+        this.mapShows = false;
+      } else {
+        this.mapShows = true;
+      }
+      // 筛选-店型选择
       if (localStorage.getItem('outvstoreCategoryList') != null) {
         this.result = localStorage.getItem('outvstoreCategoryList').split(',');
-        this.storeLabelTypes = [];
         this.storeCategoryList = this.result.join(',');
       } else {
         this.result = [];
         this.storeCategoryList = this.result.join(',');
       }
-      this.chainCode = localStorage.getItem('outvchainCode');
-      this.storeName = localStorage.getItem('outvstoreName');
-      if (
-        (from.path == '/My/index' && to.path == '/outsidelist/index') ||
-        (from.path == '/home' && to.path == '/outsidelist/index') ||
-        (from.path == '/deviceWithin/index' && to.path == '/outsidelist/index') ||
-        (from.path == '/storemanagement/index' && to.path == '/outsidelist/index')
-      ) {
-        this.tabVal = '1';
-      } else {
-        if (localStorage.getItem('tabVal') != null) {
-          this.tabVal = localStorage.getItem('tabVal');
-        }
-      }
-      if (
-        (from.path == '/storeDetail' && to.path == '/outsidelist/index') ||
-        (from.path == '/storeGroup' && to.path == '/outsidelist/index') ||
-        (from.path == '/suishenbangOutstoreVisit' && to.path == '/outsidelist/index') ||
-        (from.path == '/outabnormalVisit' && to.path == '/outsidelist/index') ||
-        (from.path == '/home' && to.path == '/outsidelist/index') ||
-        (from.path == '/deviceWithin/index' && to.path == '/outsidelist/index') ||
-        (from.path == '/storemanagement/index' && to.path == '/outsidelist/index') ||
-        (from.path == '/My/index' && to.path == '/outsidelist/index')
-      ) {
-        this.onSearch();
-      }
-      var postType = localStorage.getItem('postType');
-      if (postType == 'GZ') {
-        this.addShow1 = false;
-        this.otherShow = true;
-      } else {
-        this.addShow1 = true;
-        this.otherShow = false;
-      }
-      if (localStorage.getItem('postType') == 'JZ' || localStorage.getItem('postType') == 'GZ') {
-        this.mapShows = false;
+      // 当前tabs,0:销售部;1:我的
+      if (localStorage.getItem('tabVal')) {
+        this.tabVal = localStorage.getItem('tabVal');
       } else {
-        this.mapShows = true;
+        this.tabVal = '1';
       }
-      this.getMonth();
+      this.query = this.$route.query; // 路由参数
+      localStorage.removeItem('visitId');
+      this.onSearch();
     },
-  },
-  created() {
-    this.storeName = localStorage.getItem('outvstoreName');
-    this.chainName = localStorage.getItem('outvchainName');
-    if (localStorage.getItem('outvstoreLabelTypes') != null) {
-      this.storeLabelTypes = localStorage.getItem('outvstoreLabelTypes').split(',');
-    } else {
-      this.storeLabelTypes = [];
-    }
-    if (localStorage.getItem('outvstoreCategoryList') != null) {
-      this.result = localStorage.getItem('outvstoreCategoryList').split(',');
-      this.storeCategoryList = this.result.join(',');
-    } else {
-      this.result = [];
-      this.storeCategoryList = this.result.join(',');
-    }
-    this.chainCode = localStorage.getItem('outvchainCode');
-    this.storeName = localStorage.getItem('outvstoreName');
-    if (localStorage.getItem('tabVal') == null || this.$route.query.info != 'y') {
-      if (this.$route.query.info != undefined) {
-        if (this.$route.query.info.indexOf('y') != -1) {
-          this.tabVal = localStorage.getItem('tabVal');
-        } else {
-          this.tabVal = '1';
-        }
-      } else {
-        this.tabVal = localStorage.getItem('tabVal');
-      }
-    } else {
-      this.tabVal = localStorage.getItem('tabVal');
-    }
-    if (localStorage.getItem('postType') == 'JZ' || localStorage.getItem('postType') == 'GZ') {
-      this.mapShows = false;
-    } else {
-      this.mapShows = true;
-    }
-    this.query = this.$route.query;
-    localStorage.removeItem('visitId');
-    this.getStoreTypeList();
-    this.getStoreLabels();
-    var postType = localStorage.getItem('postType');
-    if (postType == 'GZ') {
-      this.addShow1 = false;
-      this.otherShow = true;
-    } else {
-      this.addShow1 = true;
-      this.otherShow = false;
-    }
-    this.getMonth();
-  },
-  methods: {
     setStroeNameStyle(item) {
       // 家装或工装 approvalStatus:是否结案 0:未结案,1:已结案
       if (
@@ -902,9 +950,11 @@ export default {
       this.moreTypeShow = false;
     },
     getStoreLabels() {
-      getStoreLabels().then((res) => {
-        this.StoreLabels = res.data;
-      });
+      if (this.StoreLabels.length == 0) {
+        getStoreLabels().then((res) => {
+          this.StoreLabels = res.data;
+        });
+      }
     },
     searchType(val) {
       this.storeTypeLists = [];
@@ -943,10 +993,12 @@ export default {
       this.onSearch();
     },
     getStoreTypeList() {
-      getStoreTypeListlp({}).then((res) => {
-        this.storeTypeLists = res.data;
-        this.storeTypeList = res.data;
-      });
+      if (this.storeTypeLists.length == 0) {
+        getStoreTypeListlp({}).then((res) => {
+          this.storeTypeLists = res.data;
+          this.storeTypeList = res.data;
+        });
+      }
     },
     buryingPointFn(val) {
       this.buryingPoint({
@@ -1005,8 +1057,11 @@ export default {
       });
     },
     searchFn() {
-      this.showPicker = true;
-      this.CustomerName = '';
+      //获取门店类型  //获取门店标签
+      Promise.all([this.getStoreTypeList(), this.getStoreLabels()]).then(() => {
+        this.showPicker = true;
+        this.CustomerName = '';
+      });
     },
     moreSearch() {
       this.onSearch();