Explorar o código

fix:分页列表滚动到第一条数据

Signed-off-by: tangshizhe <48740614+tangshizhe@users.noreply.github.com>
tangshizhe hai 11 meses
pai
achega
c191ddcf78

+ 4 - 1
apps/bigmember_pc/src/components/push-list/PotentialList.vue

@@ -418,8 +418,11 @@ export default {
       }
     },
     onPageChange(p) {
-      scrollTargetView('.info-list')
       this.listState.pageNum = p
+      this.$nextTick(() => {
+        const forMain = document.querySelector('.for_main')?.offsetTop || 0
+        scrollTargetView('.info-list', forMain)
+      })
       // this.getList()
     },
     onSizeChange(size) {

+ 1 - 1
apps/bigmember_pc/src/components/push-list/PushList.vue

@@ -1050,7 +1050,7 @@ export default {
       this.getNewData()
       this.listState.pageNum = p
       this.getList()
-      scrollTargetView('.info-list')
+      scrollTargetView('.info-list-card')
     },
     onSizeChange(size) {
       this.listState.pageSize = size

+ 2 - 2
apps/bigmember_pc/src/utils/globalFunctions.js

@@ -794,7 +794,7 @@ export function  extractKeywords(text, keywords, n = 10) {
  * 应用场景:1.翻页后页面滚动到列表第一条的位置
  * @param targetEvent 页面要滚动到的目标元素
  */
-export function scrollTargetView (targetEvent) {
+export function scrollTargetView (targetEvent, custom) {
   if (!targetEvent) return
   let scrollWrapper
   let targetTop
@@ -824,7 +824,7 @@ export function scrollTargetView (targetEvent) {
     // scrollingElement可获取页面滚动元素
     console.log(targetTop, 'targetTop');
     scrollWrapper = document.scrollingElement
-    scrollWrapper.scrollTop = targetTop
+    scrollWrapper.scrollTop = targetTop + custom
     // console.log(`非工作桌面---滚动元素:${scrollWrapper.className ? scrollWrapper.className : scrollWrapper.tagName}, 滚动距离:${targetTop}`)
   }
 }

+ 0 - 1
apps/bigmember_pc/src/views/search/layout/search-list.vue

@@ -72,7 +72,6 @@ const canShowPagination = computed(() => {
 const emit = defineEmits(['current-change'])
 function onCurrentChange($event) {
   // 点分页定位到第一条
-  scrollTargetView('.search-result-container')
   emit('current-change', $event)
 }
 

+ 5 - 3
apps/bigmember_pc/src/views/search/purchase/model/base.js

@@ -1,4 +1,4 @@
-import { computed, reactive, ref, provide, getCurrentInstance } from 'vue'
+import { computed, reactive, ref, provide, getCurrentInstance, nextTick } from 'vue'
 import useQuickSearchModel from '@jy/data-models/modules/quick-search/model'
 import { useStore } from '@/store'
 import { useRoute } from 'vue-router/composables'
@@ -6,7 +6,7 @@ import { useRoute } from 'vue-router/composables'
 import useSearchHistoryModel from '@jy/data-models/modules/quick-search-history/model'
 import { getBuyerAssociation } from '@/api/modules'
 import { debounce } from 'lodash'
-import { InContainer, openLinkInWorkspace } from '@/utils'
+import { InContainer, openLinkInWorkspace, scrollTargetView } from '@/utils'
 import { randomBgc, getShortName } from '@/utils/globalFunctions'
 import { ajaxEmployInfo, ajaxEmployOperate, getStatusCustomer, setStatusCustomer, renLingCustomerAddTags } from '@/api/modules/'
 import { dataCollectActionModel } from './modules/data-tags-actions'
@@ -178,7 +178,9 @@ export default function () {
   // 分页事件
   function doChangePageNum(page) {
     listState.pageNum = page
-    doQuery()
+    doQuery().then(() => {
+      scrollTargetView('.search-purchase-main')
+    })
   }
 
   // 分页大小事件