This commit is contained in:
851673013@qq.com 2022-08-10 10:32:50 +08:00
parent 469c6afd61
commit 12bee09773
2 changed files with 81 additions and 60 deletions

View File

@ -28,7 +28,7 @@
</template> </template>
<script setup> <script setup>
import { pageWithAttrs } from '@/api/abilityStatistics' import { pageWithAttrs } from '@/api/abilityStatistics'
import { ref, onMounted } from 'vue' import { ref, onMounted, onBeforeUnmount } from 'vue'
const dataList = ref([]) const dataList = ref([])
const params = { const params = {
deptIds: [], deptIds: [],
@ -40,6 +40,7 @@
pageSize: 9, pageSize: 9,
type: '组件服务', type: '组件服务',
} }
let algorithmclass = null
const imgSrc = ref(require('@/assets/capacitySquare/algorithm-photo.jpg')) const imgSrc = ref(require('@/assets/capacitySquare/algorithm-photo.jpg'))
const dataLength = ref(true) const dataLength = ref(true)
const isNoMore = ref(false) const isNoMore = ref(false)
@ -55,22 +56,23 @@
pageWithAttrsFunction() pageWithAttrsFunction()
// //
const algorithmCardPhoto = (List) => { const algorithmCardPhoto = (List) => {
let obj = List.filter((item) => item.attrType === '图层缩略图')[0]
if (obj) {
List.map((item) => { List.map((item) => {
if (item.attrType === '图层缩略图') { if (item.attrType === '图层缩略图') {
url.value = item.attrValue url.value = item.attrValue
} }
}) })
} else {
url.value = '@/assets/capacitySquare/algorithm-photo2.jpg'
}
return url.value return url.value
} }
// //
const detailFunction = (id) => { const detailFunction = (id) => {
window.open(window.SITE_CONFIG.previewUrl + `#/details?id=${id}`) window.open(window.SITE_CONFIG.previewUrl + `#/details?id=${id}`)
} }
onMounted(() => { const algorithmFunction = (e) => {
const algorithmclass = document.querySelector('.algorithm-class')
if (dataLength.value) {
//
algorithmclass.addEventListener('scroll', (e) => {
var scrollTop = e.currentTarget.scrollTop var scrollTop = e.currentTarget.scrollTop
var windowHeight = e.currentTarget.clientHeight var windowHeight = e.currentTarget.clientHeight
var scrollHeight = e.currentTarget.scrollHeight var scrollHeight = e.currentTarget.scrollHeight
@ -91,8 +93,17 @@
} else { } else {
isNoMore.value = false isNoMore.value = false
} }
})
} }
onMounted(() => {
algorithmclass = document.querySelector('.algorithm-class')
if (dataLength.value) {
//
algorithmclass.addEventListener('scroll', algorithmFunction, true)
}
})
onBeforeUnmount(() => {
algorithmclass.removeEventListener('scroll', algorithmFunction, true)
}) })
</script> </script>

View File

@ -28,8 +28,9 @@
</template> </template>
<script setup> <script setup>
import { pageWithAttrs } from '@/api/abilityStatistics' import { pageWithAttrs } from '@/api/abilityStatistics'
import { ref, onMounted } from 'vue' import { ref, onMounted, onBeforeUnmount } from 'vue'
const dataList = ref([]) const dataList = ref([])
let algorithmclass = null
const params = { const params = {
deptIds: [], deptIds: [],
districtId: '', districtId: '',
@ -55,22 +56,23 @@
pageWithAttrsFunction() pageWithAttrsFunction()
// //
const algorithmCardPhoto = (List) => { const algorithmCardPhoto = (List) => {
let obj = List.filter((item) => item.attrType === '图层缩略图')[0]
if (obj) {
List.map((item) => { List.map((item) => {
if (item.attrType === '图层缩略图') { if (item.attrType === '图层缩略图') {
url.value = item.attrValue url.value = item.attrValue
} }
}) })
} else {
url.value = '@/assets/capacitySquare/algorithm-photo2.jpg'
}
return url.value return url.value
} }
// //
const detailFunction = (id) => { const detailFunction = (id) => {
window.open(window.SITE_CONFIG.previewUrl + `#/details?id=${id}`) window.open(window.SITE_CONFIG.previewUrl + `#/details?id=${id}`)
} }
onMounted(() => { const layerFunction = (e) => {
const algorithmclass = document.querySelector('.algorithm-class')
if (dataLength.value) {
//
algorithmclass.addEventListener('scroll', (e) => {
var scrollTop = e.currentTarget.scrollTop var scrollTop = e.currentTarget.scrollTop
var windowHeight = e.currentTarget.clientHeight var windowHeight = e.currentTarget.clientHeight
var scrollHeight = e.currentTarget.scrollHeight var scrollHeight = e.currentTarget.scrollHeight
@ -91,8 +93,16 @@
} else { } else {
isNoMore.value = false isNoMore.value = false
} }
})
} }
onMounted(() => {
algorithmclass = document.querySelector('.algorithm-class')
if (dataLength.value) {
//
algorithmclass.addEventListener('scroll', layerFunction, true)
}
})
onBeforeUnmount(() => {
algorithmclass.removeEventListener('scroll', layerFunction, true)
}) })
</script> </script>