소스 검색

代码优化

zhujindu 11 달 전
부모
커밋
f5c52fb916
3개의 변경된 파일44개의 추가작업 그리고 40개의 파일을 삭제
  1. 0 6
      src/views/home/bottomBtn.vue
  2. 6 1
      src/views/home/hintTabPage/index.vue
  3. 38 33
      src/views/home/index.vue

+ 0 - 6
src/views/home/bottomBtn.vue

@@ -124,11 +124,6 @@ export default {
   },
   methods: {
     getReportInfo() {
-      //   let loading1 = this.$toast.loading({
-      //     duration: 0,
-      //     message: '加载中...',
-      //     forbidClick: true,
-      //   });
       getReportInfo({ isContent: false }).then((res) => {
         if (res.code == 200) {
           if (res.data.postType == 'GZ') {
@@ -141,7 +136,6 @@ export default {
           } else {
             this.JZQuota = false;
           }
-          //   loading1.clear();
           localStorage.setItem('powerGrade', res.data.positionId);
           localStorage.setItem('isDiy', res.data.diy);
           localStorage.setItem('uType', res.data.userType);

+ 6 - 1
src/views/home/hintTabPage/index.vue

@@ -438,13 +438,14 @@ export default {
         pantoneLosding: true,
         pantoneData: {},
       },
+      isLoading: false,
     };
   },
   watch: {
     tabVal: {
       handler(val) {
         if (val == -1) {
-          this.initData();
+          // this.initData();
         }
       },
       immediate: true,
@@ -452,6 +453,10 @@ export default {
   },
   activated() {},
   methods: {
+    onRefresh() {
+      this.initData();
+      this.isLoading = false;
+    },
     initData() {
       if (!this.userInfo) return;
       this.empLevel = this.userInfo.empLevel;

+ 38 - 33
src/views/home/index.vue

@@ -10,33 +10,20 @@
         @click="onClickTabs"
         v-if="isGZorJZ">
         <van-tab title="提示类" name="-1" v-if="isGZorJZ == 'false'">
-          <hintTabPage :tabVal="tabVal" ref="hintTabPage"></hintTabPage
-        ></van-tab>
-        <van-tab title="A类指标" name="0"
-          ><ABtarget :tabVal="tabVal" ref="Atarget"></ABtarget
-        ></van-tab>
-        <van-tab title="B类指标" name="1"
-          ><ABtarget :tabVal="tabVal" ref="Btarget"></ABtarget
-        ></van-tab>
+          <van-pull-refresh v-model="isLoading" @refresh="onRefresh">
+            <hintTabPage :tabVal="tabVal" ref="hintTabPage"></hintTabPage>
+          </van-pull-refresh>
+        </van-tab>
+        <van-tab title="A类指标" name="0">
+          <ABtarget :tabVal="tabVal" ref="Atarget"></ABtarget>
+        </van-tab>
+        <van-tab title="B类指标" name="1">
+          <ABtarget :tabVal="tabVal" ref="Btarget"></ABtarget>
+        </van-tab>
       </van-tabs>
       <div class="bottomBtn">
-        <bottomBtn :tabVal="tabVal"></bottomBtn>
+        <bottomBtn :tabVal="tabVal" ref="bottomBtn"></bottomBtn>
       </div>
-      <!-- <van-dialog v-model="shows" @confirm="titleconfirm">
-      <div class="tipTitleBox" style="padding: 10px">
-        <p class="p">系统提示</p>
-        <p>各位好,因五一假期,汇报提交时间有调整。</p>
-        <div style="font-size: 14px">
-          <p style="margin-bottom: 6px; line-height: 20px">1、5月1-3日,销售员无需提交日报。</p>
-          <p style="margin-bottom: 6px; line-height: 20px">
-            2、销售部主管周报提交时间改为4月27日-30日。
-          </p>
-          <p>3、大区主管半月报提交时间改为5月4日-7日。</p>
-        </div>
-        <br />
-        <p style="text-align: right">祝大家假期愉快!</p>
-      </div>
-    </van-dialog> -->
     </div>
     <tab-bar></tab-bar>
   </div>
@@ -62,6 +49,7 @@ export default {
       tabVal: '-1',
       hintTabPageIndex: 0,
       isGZorJZ: null,
+      isLoading: false,
     };
   },
   watch: {
@@ -79,21 +67,27 @@ export default {
   activated() {
     if (this.tabVal == '-1') {
       // 从其他页面跳转过来如果;要重新获取对应tab数据
-      if (this.$refs.hintTabPage) this.$refs.hintTabPage.initData();
+      // if (this.$refs.hintTabPage) this.$refs.hintTabPage.initData();
     } else if (this.tabVal == '0') {
-      if (this.$refs.Atarget) this.$refs.Atarget.initData();
+      // if (this.$refs.Atarget) this.$refs.Atarget.initData();
     } else if (this.tabVal == '1') {
-      if (this.$refs.Btarget) this.$refs.Btarget.initData();
+      // if (this.$refs.Btarget) this.$refs.Btarget.initData();
     }
   },
   created() {
     this.getDict();
   },
+  mounted() {},
   methods: {
-    async getDict() {
-      this.isGZorJZ = null;
+    onRefresh() {
+      this.getDict(true);
+      this.isLoading = false;
+    },
+    async getDict(isRefresh) {
+      this.toastLoading(0, '加载中...', true);
       let gz_Option = await getDictOption({}, 'gz_customer_post'); //公装业务员岗位
       let jz_Option = await getDictOption({}, 'jz_post_name'); //家装业务员岗位
+      this.toastLoading().clear();
       let postName = this.userInfo.postName;
       let is_gz = gz_Option.data.find((res) => res.dictLabel == postName);
       let is_jz = jz_Option.data.find((res) => res.dictLabel == postName);
@@ -106,11 +100,22 @@ export default {
       }
       // 家装或工装不显示提示类tab
       this.$nextTick(() => {
-        if (this.isGZorJZ == 'true') {
-          this.tabVal = '0';
-        } else {
-          this.tabVal = '-1';
+        // 刷新状态
+        if (!isRefresh) {
+          if (this.isGZorJZ == 'true') {
+            this.tabVal = '0';
+          } else {
+            this.tabVal = '-1';
+          }
+        }
+        if (this.tabVal == '-1') {
+          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();
         }
+        if (this.$refs.bottomBtn) this.$refs.bottomBtn.getReportInfo();
       });
     },
     onClickTabs(val) {