Procházet zdrojové kódy

Merge branch 'feature_20250904_历史拜访界面缓存优化' into release

zhujindu před 2 měsíci
rodič
revize
c4723a4669

+ 7 - 0
src/api/index.js

@@ -276,6 +276,13 @@ export function getVisits(query) {
     params: query,
   });
 }
+export function getListTotal(query) {
+  return request({
+    url: 'mobile/visit/listTotal',
+    method: 'get',
+    params: query,
+  });
+}
 export function storeMyList(query) {
   return request({
     url: 'mobile/store/myList',

+ 51 - 7
src/views/historicalVisit/historAllVisit.vue

@@ -59,9 +59,11 @@
         </van-search>
       </div>
       <div class="lineGrey"></div>
+      <div v-if="refreshTotal" class="refreshBtn" @click="onSearch">检测到 {{ refreshTotal }} 条更新,点击刷新</div>
+      <div v-if="refreshTotal" class="lineGrey"></div>
     </div>
     <!--        主体内容-->
-    <div class="container" style="margin-top: 262px">
+    <div class="container" :style="{ 'margin-top': refreshTotal ? '300px' : '262px' }">
       <van-list
         class="myList1"
         v-model="loading"
@@ -198,13 +200,15 @@
 </template>
 
 <script>
-import { getVisits, getvisitDeptInfo } from '@/api/index';
+import { getVisits, getvisitDeptInfo, getListTotal } from '@/api/index';
 import timeico from '@/assets/Icon/datatims.png';
 
 export default {
   name: 'index.vue',
   data() {
     return {
+      latestUpdateTime:null,
+      refreshTotal:0,
       timeico: timeico,
       defaultDate: new Date(),
       searchValue: '',
@@ -260,14 +264,22 @@ export default {
       StaffShow: false,
       deptForm: { type: '', parentId: '' },
       pageNum: 1, // 当前页码  int类型
-      pageSize: 10, // 当前每页条数  int类型
+      pageSize: 20, // 当前每页条数  int类型
       userDeptLevel: null,
     };
   },
   activated() {
-    setTimeout(() => {
-      this.onSearch();
-    }, 1000);
+    let typeQuery = localStorage.getItem('typeQuery');
+    if(this.latestUpdateTime!=null && typeQuery == 1){ 
+      this.getListTotalFn();
+    }else{
+      setTimeout(() => {
+        this.onSearch();
+      }, 1000);
+    }
+  },
+  deactivated(){
+    localStorage.setItem('typeQuery', 1);
   },
   created() {
     this.info();
@@ -305,6 +317,22 @@ export default {
     }
   },
   methods: {
+    getListTotalFn(){
+      getListTotal({
+        startTime: this.startTime + ' 00:00:00', 
+        stopTime: this.endTime + ' 24:00:00', 
+        storeRequest: this.storeName.trim(),
+        companyId: this.companyCode,
+        regionId: this.regionCode,
+        userId: this.userCode,
+        deptId: this.deptCode,
+        queryStartTime:this.latestUpdateTime
+      }).then((res) => {
+        if (res.code == 200) {
+          this.refreshTotal = res.data;
+        }
+      });
+    },
     onLoad() {
       // this.loading = false;
       this.getVisitsListFn();
@@ -377,9 +405,13 @@ export default {
       this.onSearch();
     },
     onClickLeft() {
-      this.$router.go(-1);
+      this.$router.push({
+          path: '/My/index',
+      });
     },
     onSearch() {
+      this.refreshTotal = 0;
+      window.scrollTo(0, 0);
       this.pageNum = 1;
       this.list = [];
       this.getVisitsListFn();
@@ -408,6 +440,7 @@ export default {
         loading1.clear();
         if (res.code == 200) {
           this.loading = false;
+          this.latestUpdateTime = res.dataTime;
           this.list = this.list.concat(res.data);
           if (this.list.length >= res.total) {
             this.finished = true;
@@ -541,6 +574,17 @@ export default {
 };
 </script>
 <style lang="scss">
+.refreshBtn{
+    display: flex;
+    justify-content: center;
+    align-items: center;
+    cursor: pointer;
+    width: 100%;
+    color: #ff976a;
+    padding: 5px;
+    font-size: 14px;
+    background-color: #fff;
+}
 .searchDiv {
   .van-search {
     background: #fff;

+ 1 - 0
src/views/historicalVisit/skuRecognize.vue

@@ -102,6 +102,7 @@ export default {
   },
   activated() {
     this.visitsId = this.$route.query.visitId || '';
+    this.detail = null;
     this.getDetail();
   },
   methods: {

+ 7 - 1
src/views/week/index.vue

@@ -47,7 +47,7 @@
               <van-icon :name="storeselect" class="zicon" />
             </template>
           </van-cell>
-          <van-cell title="历史拜访" is-link to="/historAllVisit">
+          <van-cell title="历史拜访" is-link @click="historAllVisit()">
             <template #icon>
               <van-icon :name="history" class="zicon" />
             </template>
@@ -318,6 +318,12 @@ export default {
     this.getReportInfo();
   },
   methods: {
+    historAllVisit(){
+      localStorage.setItem('typeQuery', 0);
+      this.$router.push({
+        path: '/historAllVisit',
+      });
+    },
     getstoreCoverPosition() {
       getstoreCoverPosition({}).then((res) => {
         var postName = localStorage.getItem('postName');