zhujindu hai 1 semana
pai
achega
f9a2a2531f

+ 43 - 5
src/store/modules/user.js

@@ -1,4 +1,4 @@
-import { getMobileUserInfo, getDictOption, loginLog } from '@/api/index';
+import { getMobileUserInfo, getDictOption, loginLog, getReportInfo } from '@/api/index';
 
 const user = {
   state: {
@@ -6,6 +6,7 @@ const user = {
     activaTypeStore: null, //未拜访门店
     activaCreateTypeStore: null, //建店未完工、未结案门店
     storeType: [],
+    reportInfo: null,
   },
 
   mutations: {
@@ -21,6 +22,9 @@ const user = {
     SET_ACTIVA_CREATE_TYPE_STORE: (state, value) => {
       state.activaCreateTypeStore = value;
     },
+    SET_REPORT_INFO: (state, reportInfo) => {
+      state.reportInfo = reportInfo;
+    },
   },
 
   actions: {
@@ -41,10 +45,22 @@ const user = {
             localStorage.setItem('getRequestFlage', 'true');
             // userDeptLevel用户部门等级字段,0-总部,1-公司,2-大区,3-销售部,4-业务员
             localStorage.setItem('userDeptLevel', res.data.userDeptLevel);
-            // 门店类型
-            getDictOption({}, 'sfa_store_type').then((res) => {
-              commit('SET_STORE_TYPE', res.data);
-              resolve();
+            getReportInfo({ isContent: false }).then((res) => {
+              if (res.code == 200) {
+                commit('SET_REPORT_INFO', res.data);
+                localStorage.setItem('powerGrade', res.data.positionId);
+                localStorage.setItem('isDiy', res.data.diy);
+                localStorage.setItem('uType', res.data.userType);
+                localStorage.setItem('jzType', res.data.jzType);
+                localStorage.setItem('customerVisits', res.data.customerManagerVisits);
+                localStorage.setItem('postType', res.data.postType);
+                localStorage.setItem('reportType', res.data.reportType);
+                // 门店类型
+                getDictOption({}, 'sfa_store_type').then((res) => {
+                  commit('SET_STORE_TYPE', res.data);
+                  resolve();
+                });
+              }
             });
             // 登录日志
             var appVersion = navigator.appVersion;
@@ -80,6 +96,28 @@ const user = {
     activaCreateTypeStore({ commit }, value) {
       commit('SET_ACTIVA_CREATE_TYPE_STORE', value);
     },
+    // 获取用户ReportInfo
+    getReportInfoDeta({ dispatch, commit, state }) {
+      return new Promise((resolve, reject) => {
+        getReportInfo({ isContent: false })
+          .then((res) => {
+            if (res.code == 200) {
+              commit('SET_REPORT_INFO', res.data);
+              localStorage.setItem('powerGrade', res.data.positionId);
+              localStorage.setItem('isDiy', res.data.diy);
+              localStorage.setItem('uType', res.data.userType);
+              localStorage.setItem('jzType', res.data.jzType);
+              localStorage.setItem('customerVisits', res.data.customerManagerVisits);
+              localStorage.setItem('postType', res.data.postType);
+              localStorage.setItem('reportType', res.data.reportType);
+              resolve();
+            }
+          })
+          .catch((error) => {
+            reject(error);
+          });
+      });
+    },
   },
 };
 

+ 22 - 3
src/views/home/HomeTarget.vue

@@ -115,8 +115,14 @@
 <script>
 import store from '@/store';
 import { userTodayPlanNum, getReportInfo } from '@/api/index';
+import { mapState } from 'vuex';
 export default {
   name: 'home',
+  computed: {
+    ...mapState({
+      reportInfo: (state) => state.user.reportInfo,
+    }),
+  },
   props: {
     tabVal: {
       type: [String, Number],
@@ -195,10 +201,18 @@ export default {
     };
   },
   watch: {
-    tabVal: {
+    // tabVal: {
+    //   handler(val) {
+    //     if (val == 2) {
+    //       // keep-alive 模式watch执行了两次
+    //       this.initData();
+    //     }
+    //   },
+    //   immediate: true,
+    // },
+    reportInfo: {
       handler(val) {
-        if (val == 2) {
-          // keep-alive 模式watch执行了两次
+        if (val) {
           this.initData();
         }
       },
@@ -225,6 +239,11 @@ export default {
       this.userTodayPlanNum();
     },
     getReportInfo() {
+      if (this.reportInfo && this.reportInfo.homePageIndicatorList != null) {
+        this.homePageIndicatorList = this.reportInfo.homePageIndicatorList;
+        this.updataTime = this.reportInfo.homePageIndicatorUpdateTime;
+      }
+      return;
       let loading1 = this.$toast.loading({
         duration: 0,
         message: '加载中...',

+ 42 - 1
src/views/home/bottomBtn.vue

@@ -105,7 +105,13 @@
 </template>
 <script>
 import { getReportInfo } from '@/api/index';
+import { mapState } from 'vuex';
 export default {
+  computed: {
+    ...mapState({
+      reportInfo: (state) => state.user.reportInfo,
+    }),
+  },
   props: {
     tabVal: {
       type: [String, Number],
@@ -130,11 +136,46 @@ export default {
       reportType: null,
     };
   },
+  watch: {
+    reportInfo: {
+      handler(val) {
+        if (val) {
+          this.getReportInfo();
+        }
+      },
+      immediate: true,
+    },
+  },
   activated() {
-    this.getReportInfo();
+    // this.getReportInfo();
   },
   methods: {
     getReportInfo() {
+      if (this.reportInfo) {
+        let reportInfo = this.reportInfo;
+        if (reportInfo.postType == 'GZ') {
+          this.GZdata = true;
+        } else {
+          this.GZdata = false;
+        }
+        this.proccessPendingNum = reportInfo.proccessPendingNum;
+        this.reportInfoData = reportInfo;
+        this.approvalButton = reportInfo.approvalButton;
+        this.powerGrade = reportInfo.positionId;
+        this.showButton = reportInfo.showButton;
+        this.reportType = reportInfo.reportType;
+        if (reportInfo.reportTargetAll != null) {
+          this.updataTime = reportInfo.reportTargetAll.updateTime;
+        }
+        this.approvalPendingNum = reportInfo.approvalPendingNum;
+        this.type = reportInfo.userType;
+        // 金牌店老板生日提醒
+        if (reportInfo.ownerBirthdayReminds && reportInfo.ownerBirthdayReminds.length) {
+          this.ownerBirthdayBoxFlag = true;
+          this.ownerBirthdayReminds = reportInfo.ownerBirthdayReminds.join(',');
+        }
+      }
+      return;
       getReportInfo({ isContent: false }).then((res) => {
         if (res.code == 200) {
           if (res.data.postType == 'GZ') {

+ 31 - 29
src/views/home/index.vue

@@ -47,12 +47,14 @@ import HomeTarget from './HomeTarget.vue';
 import { mapState } from 'vuex';
 import bottomBtn from './bottomBtn.vue';
 import { WXdigest } from '@/utils/digest';
+import store from '@/store';
 export default {
   name: 'home',
   components: { tabBar, hintTabPage, ABtarget, HomeTarget, bottomBtn },
   computed: {
     ...mapState({
       userInfo: (state) => state.user.userInfo,
+      reportInfo: (state) => state.user.reportInfo,
     }),
   },
   data() {
@@ -81,15 +83,8 @@ export default {
     },
   },
   activated() {
+    this.getReportInfo();
     WXdigest();
-    if (this.tabVal == '-1') {
-      // 从其他页面跳转过来如果;要重新获取对应tab数据
-      // if (this.$refs.hintTabPage) this.$refs.hintTabPage.initData();
-    } else if (this.tabVal == '0') {
-      // if (this.$refs.Atarget) this.$refs.Atarget.initData();
-    } else if (this.tabVal == '1') {
-      // if (this.$refs.Btarget) this.$refs.Btarget.initData();
-    }
   },
   created() {
     this.getDict();
@@ -110,17 +105,27 @@ export default {
     async getDict(isRefresh) {
       let postType = this.userInfo.postType;
       let postName = this.userInfo.postName;
-      if (postName == '质感销售负责人' || postName == '质感销售专员' || postType == 'GZ') {
+      if (postName == '质感销售负责人' || postName == '质感销售专员') {
         this.onlyShowHomeTarget = true;
       } else {
-        this.onlyShowHomeTarget = false;
-        // postType:人员类型,JZ(家装)、GZ(公装)、YF(应服)、DIY(DIY)
-        if (postType == 'JZ') {
-          localStorage.setItem('isGZorJZ', 'true');
-          this.isGZorJZ = 'true';
+        // <!-- 0-历史指标  1-动态指标,String类型 -->
+        if (postType == 'GZ') {
+          if (this.reportInfo.targetType == '0') {
+            localStorage.setItem('isGZorJZ', 'true');
+            this.isGZorJZ = 'true';
+          } else if (this.reportInfo.targetType == '1') {
+            this.onlyShowHomeTarget = true;
+          }
         } else {
-          localStorage.setItem('isGZorJZ', 'false');
-          this.isGZorJZ = 'false';
+          this.onlyShowHomeTarget = false;
+          // postType:人员类型,JZ(家装)、GZ(公装)、YF(应服)、DIY(DIY)
+          if (postType == 'JZ') {
+            localStorage.setItem('isGZorJZ', 'true');
+            this.isGZorJZ = 'true';
+          } else {
+            localStorage.setItem('isGZorJZ', 'false');
+            this.isGZorJZ = 'false';
+          }
         }
       }
       // 家装或工装不显示提示类tab
@@ -164,19 +169,16 @@ export default {
       // window.location.href = process.env.VUE_APP_SSB_LINK + "/homeIndex"
     },
     getReportInfo() {
-      getReportInfo({ isContent: false }).then((res) => {
-        if (res.code == 200) {
-          localStorage.setItem('powerGrade', res.data.positionId);
-          localStorage.setItem('userDeptLevel', res.data.userDeptLevel);
-          localStorage.setItem('isDiy', res.data.diy);
-          localStorage.setItem('uType', res.data.userType);
-          localStorage.setItem('jzType', res.data.jzType);
-          localStorage.setItem('customerVisits', res.data.customerManagerVisits);
-          localStorage.setItem('postType', res.data.postType);
-        } else {
-          this.$toast(res.msg);
-        }
-      });
+      this.toastLoading(0, '加载中...', true);
+      // 获取移动端获取用户信息接口
+      store
+        .dispatch('getReportInfoDeta')
+        .then(() => {
+          this.toastLoading().clear();
+        })
+        .catch(() => {
+          this.toastLoading().clear();
+        });
     },
     deepseek() {
       buryingPoint({

+ 3 - 4
src/views/week/weeklyApprovalDetils.vue

@@ -19,12 +19,11 @@
             <target :homePageIndicatorDate="homePageIndicatorList"></target>
           </template>
           <template v-else-if="GZdata">
-            <!--  -->
-            <template v-if="true">
+            <!-- 0-历史指标  1-动态指标,String类型 -->
+            <template v-if="reportTarget.targetType == '1'">
               <target :homePageIndicatorDate="homePageIndicatorList"></target>
             </template>
-            <!-- 旧 -->
-            <template v-else>
+            <template v-if="reportTarget.targetType == '0'">
               <Atarget :reportInfo="reportTarget"></Atarget>
               <Btarget :reportInfo="reportTarget"></Btarget>
             </template>