hi-ucs/front/src/views/capacitySquare/components/algorithm.vue

287 lines
7.9 KiB
Vue
Raw Normal View History

2022-08-09 11:37:23 +08:00
<!-- 智能算法 -->
<template>
<div class="algorithm">
2022-09-19 10:19:31 +08:00
<div class="select">
<div class="top" @click="selectFlag2 = true">
{{ typeName2 }}
<div class="light"></div>
</div>
<div class="bottom" v-show="selectFlag2">
<span class="light"></span>
<div v-for="val in dictList" :key="val" @click="getList2(val)">
{{ val }}
</div>
</div>
</div>
2022-08-09 11:37:23 +08:00
<div class="algorithm-class">
<div
v-for="(item, index) in dataList"
:key="`algorithm-${index}`"
class="algorithm-card"
>
2022-08-09 15:23:38 +08:00
<a-image
2022-08-10 15:47:29 +08:00
:src="algorithmCardPhoto(item.infoList, item)"
2022-08-09 15:23:38 +08:00
:width="525"
:height="275"
:fallback="imgSrc"
2022-08-09 16:27:04 +08:00
:preview="false"
2022-08-09 15:23:38 +08:00
></a-image>
<a-tooltip>
<template #title>{{ item.name }}</template>
2022-08-09 16:27:04 +08:00
<div class="algorithm-card-title" @click="detailFunction(item.id)">
<span>{{ item.name }}</span>
<span>{{ item.deptName }}</span>
</div>
2022-08-09 15:23:38 +08:00
</a-tooltip>
2022-08-09 11:37:23 +08:00
</div>
</div>
</div>
</template>
<script setup>
2022-09-19 10:19:31 +08:00
import { getCategoryTreePage } from '@/api/personalCenter'
2022-08-09 11:37:23 +08:00
import { pageWithAttrs } from '@/api/abilityStatistics'
2022-08-10 10:32:50 +08:00
import { ref, onMounted, onBeforeUnmount } from 'vue'
2022-09-19 10:19:31 +08:00
const typeName2 = ref('全部')
const dictList = ref([])
2022-08-09 11:37:23 +08:00
const dataList = ref([])
2022-09-19 10:19:31 +08:00
const selectFlag2 = ref(false)
getCategoryTreePage({
page: 1,
limit: 99,
dictTypeId: '1513712507692818433',
}).then((res) => {
dictList.value = ['全部']
res.data.data.list.map((val) => {
2022-10-24 14:26:22 +08:00
// if (val.dictLabel !== '其他') {
dictList.value.push(val.dictLabel)
// }
2022-09-19 10:19:31 +08:00
})
})
2022-08-09 11:37:23 +08:00
const params = {
deptIds: [],
districtId: '',
infoList: [{ attrType: '组件类型', attrValue: '智能算法' }],
2022-08-15 18:08:12 +08:00
orderField: 'pin_top',
2022-08-09 11:37:23 +08:00
orderType: 'DESC',
pageNum: 1,
pageSize: 9,
type: '组件服务',
}
2022-09-19 10:19:31 +08:00
const getList2 = (val) => {
typeName2.value = val
if (val == '全部') {
params.infoList = [{ attrType: '组件类型', attrValue: '智能算法' }]
} else {
params.infoList = [
{ attrType: '组件类型', attrValue: '智能算法' },
{ attrType: '应用领域', attrValue: val },
]
}
selectFlag2.value = false
pageWithAttrsFunction()
}
2022-08-10 10:32:50 +08:00
let algorithmclass = null
2022-08-09 15:23:38 +08:00
const imgSrc = ref(require('@/assets/capacitySquare/algorithm-photo.jpg'))
const dataLength = ref(true)
2022-08-09 11:37:23 +08:00
const isNoMore = ref(false)
2022-08-09 15:23:38 +08:00
let url = ref('')
2022-08-09 11:37:23 +08:00
const pageWithAttrsFunction = () => {
pageWithAttrs(params).then((res) => {
dataList.value = res.data.data.records
2022-08-09 15:23:38 +08:00
if (res.data.data.records.length < 9) {
dataLength.value = false
}
2022-08-09 11:37:23 +08:00
})
}
pageWithAttrsFunction()
2022-08-09 15:23:38 +08:00
//图片显示
2022-08-10 15:47:29 +08:00
const algorithmCardPhoto = (List, item) => {
2022-08-10 14:54:45 +08:00
let obj = List.filter((item) => item.attrType === '应用场景')[0]
if (obj && obj.attrValue != '') {
2022-08-10 15:47:29 +08:00
console.log(
item.name,
item.id,
obj.attrValue,
'----------------------------'
)
2022-08-10 14:54:45 +08:00
obj = JSON.parse(obj.attrValue)[0].img
2022-08-10 10:32:50 +08:00
}
2022-08-10 14:54:45 +08:00
return obj || ''
2022-08-09 15:23:38 +08:00
}
2022-08-09 16:27:04 +08:00
//跳转详情页
const detailFunction = (id) => {
window.open(window.SITE_CONFIG.previewUrl + `#/details?id=${id}`)
}
2022-08-10 10:32:50 +08:00
const algorithmFunction = (e) => {
var scrollTop = e.currentTarget.scrollTop
var windowHeight = e.currentTarget.clientHeight
var scrollHeight = e.currentTarget.scrollHeight
console.log(scrollTop, windowHeight, scrollHeight, '123')
if (
scrollTop + windowHeight <= scrollHeight + 1 &&
scrollTop + windowHeight >= scrollHeight - 1
) {
// 当前滚动条已经触底
isNoMore.value = true
params.pageNum++
pageWithAttrs(params).then((res) => {
dataList.value.push(...res.data.data.records)
if (res.data.data.records.length < 9) {
dataLength.value = false
}
})
} else {
isNoMore.value = false
}
}
2022-08-09 15:23:38 +08:00
onMounted(() => {
2022-08-10 10:32:50 +08:00
algorithmclass = document.querySelector('.algorithm-class')
2022-08-09 15:23:38 +08:00
if (dataLength.value) {
2022-08-09 16:27:04 +08:00
//监听滚动事件
2022-08-10 10:32:50 +08:00
algorithmclass.addEventListener('scroll', algorithmFunction, true)
2022-08-09 15:23:38 +08:00
}
2022-08-09 11:37:23 +08:00
})
2022-08-10 10:32:50 +08:00
onBeforeUnmount(() => {
algorithmclass.removeEventListener('scroll', algorithmFunction, true)
})
2022-08-09 11:37:23 +08:00
</script>
<style lang="less" scoped>
.algorithm {
2022-09-19 10:19:31 +08:00
.select {
margin: 0.1rem 0 0.1rem 0.2rem;
color: #fff;
font-size: 0.2rem;
font-family: webfont;
position: relative;
.top {
cursor: pointer;
width: 3.61rem;
height: 0.85rem;
font-weight: 600;
text-align: center;
padding-top: 0.1rem;
background: url('~@/assets/capacitySquare/select-bg.png') no-repeat;
background-size: 100%;
position: relative;
.light {
width: 0.56rem;
height: 3px;
position: absolute;
top: 0.4rem;
left: 1.52rem;
background: url('~@/assets/capacitySquare/select-light1.png')
no-repeat;
background-size: 100%;
}
}
.bottom {
cursor: pointer;
position: absolute;
top: 0.5rem;
left: 0.9rem;
z-index: 1000;
background: rgba(57, 134, 239, 0.68);
border: 1px solid #aed5ff;
.light {
display: inline-block;
width: 2.39rem;
height: 5px;
position: absolute;
top: -0.08rem;
left: -0.3rem;
background: url('~@/assets/capacitySquare/select-light2.png')
no-repeat;
background-size: 100%;
}
& > div {
width: 1.8rem;
height: 0.4rem;
line-height: 0.4rem;
text-align: center;
border-top: 1px solid #aed5ff;
}
& > div:nth-of-type(1) {
border: none;
}
}
}
2022-08-09 11:37:23 +08:00
.algorithm-class {
2022-09-19 10:19:31 +08:00
// margin-top: 0.6rem;
margin-bottom: 0.18rem;
2022-08-09 11:37:23 +08:00
display: grid;
grid-template-columns: repeat(3, 33%);
height: 8.8rem;
overflow: auto;
margin-left: 1.15rem;
margin-right: 0.15rem;
.algorithm-card {
height: 2.75rem;
width: 5.25rem;
2022-08-09 11:47:06 +08:00
background: url('~@/assets/capacitySquare/algorithm-bg.png') no-repeat;
2022-08-09 18:33:31 +08:00
background-size: 100% 100%;
margin-bottom: 0.4rem;
2022-08-09 11:37:23 +08:00
margin-right: 0.65rem;
2022-08-09 11:47:06 +08:00
position: relative;
2022-08-09 15:23:38 +08:00
:deep(.ant-image) {
img {
2022-08-09 17:09:20 +08:00
margin-top: 0.15rem;
2022-08-09 18:33:31 +08:00
height: 2.45rem;
2022-08-09 17:09:20 +08:00
width: 5.05rem;
margin-left: 0.1rem;
2022-08-09 15:23:38 +08:00
}
}
.algorithm-card-photo {
height: 100%;
width: 100%;
background: url('~@/assets/capacitySquare/algorithm-photo.jpg')
no-repeat;
background-size: 100%;
}
2022-08-09 11:47:06 +08:00
.algorithm-card-title {
position: absolute;
height: 0.6rem;
2022-08-09 18:19:18 +08:00
margin-left: 0.08rem;
width: 97%;
2022-08-09 11:47:06 +08:00
color: #ffffff;
font-size: 0.22rem;
2022-08-09 15:23:38 +08:00
font-family: alibaba;
2022-08-09 18:33:31 +08:00
bottom: 0.15rem;
2022-08-09 15:23:38 +08:00
padding-left: 0.22rem;
background: url('~@/assets/capacitySquare/algorithm-title-bg.png')
no-repeat;
background-size: 100%;
2022-08-09 16:27:04 +08:00
display: flex;
flex-direction: column;
justify-content: center;
span {
line-height: 0.24rem;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
cursor: pointer;
}
span:last-child {
font-size: 0.14rem;
}
2022-08-09 11:47:06 +08:00
}
2022-08-09 11:37:23 +08:00
}
}
.algorithm-class::-webkit-scrollbar-track-piece {
background: #a5bcdb;
border-radius: 0.08rem;
}
.algorithm-class::-webkit-scrollbar-thumb {
height: 3.2rem;
background: linear-gradient(to bottom, #47d7f5, #3dc6e3);
}
.algorithm-class::-webkit-scrollbar {
height: 8.8rem;
width: 0.08rem;
border-radius: 0.08rem;
}
}
</style>