fix: 算法对比-锚点

This commit is contained in:
guoyue 2022-06-28 10:32:28 +08:00
parent d2423b751d
commit dff7bc51e7
1 changed files with 63 additions and 76 deletions

View File

@ -10,12 +10,10 @@
</a-breadcrumb> </a-breadcrumb>
</div> </div>
<div class="content"> <div class="content">
<div class="left"> <a-anchor :affix="false" class="left" :getContainer="getId" @click="handleClickTab">
<div class="left-item" v-for="(data, i) in leftNav" :key="i" :data-title="data" <a-anchor-link class="left-item" :href="`#${data}`" :title="data" v-for="(data, i) in leftNav"
:class="activeNameIndex == i ? 'active' : ''" @click="changeTab(i, data)"> :key="i" :data-title="data" />
{{ data }} </a-anchor>
</div>
</div>
<div class="right"> <div class="right">
<div class="top no-border-right"> <div class="top no-border-right">
<div class="td-name"> <div class="td-name">
@ -31,9 +29,10 @@
</span> </span>
</div> </div>
</div> </div>
<div class="bottom bottomRef" ref="bottomRef" @scroll="(event) => scrollAction(event)"> <div class="bottom bottomRef" id="bottomRef" ref="bottomRef">
<div class="bottom-item" v-for="(data, i) in tableData" :key="i"> <div class="bottom-item" v-for="(data, i) in tableData" :key="i">
<div class="title" :title="data.title" :ref="data.title">{{ data.title }}</div> <div class="title" :id="data.title" :title="data.title" :ref="data.title">{{ data.title }}
</div>
<!-- 算法优势 --> <!-- 算法优势 -->
<div class="group-data" v-if="data.groupName"> <div class="group-data" v-if="data.groupName">
<!-- <compare-group-view :dataList="data.groupList"></compare-group-view> --> <!-- <compare-group-view :dataList="data.groupList"></compare-group-view> -->
@ -98,7 +97,7 @@ import HomeFooter from '@/views/newHome/components/Footer'
import HomeHeader from '@/views/home/components/header' import HomeHeader from '@/views/home/components/header'
import CompareGroupView from '@/views/home/components/CompareGroupView' import CompareGroupView from '@/views/home/components/CompareGroupView'
import { pageWithAttrs } from '@/api/abilityStatistics' import { pageWithAttrs } from '@/api/abilityStatistics'
import { defineComponent, ref, onMounted, getCurrentInstance, computed, unref, reactive, nextTick } from 'vue'; import { defineComponent, ref, onMounted, getCurrentInstance, computed, unref, reactive, nextTick, onCreated } from 'vue';
import { selectOne } from '@/api/home' import { selectOne } from '@/api/home'
import { message, Tooltip, Table, Spin } from 'ant-design-vue' import { message, Tooltip, Table, Spin } from 'ant-design-vue'
import { useRouter } from 'vue-router'; import { useRouter } from 'vue-router';
@ -261,13 +260,25 @@ let textObj = {
}, },
} }
const activeNameIndex = ref(0)
const showAddModal = ref(false) const showAddModal = ref(false)
const dataList = ref([]) const dataList = ref([])
const selectedRowKeys = ref([]); const selectedRowKeys = ref([]);
let tableData = ref([]) let tableData = ref([])
const loadingPage = ref(false) const loadingPage = ref(false)
const getId = () => {
return window.document.getElementById('bottomRef')
}
const handleClickTab = (e, link) => {
//
e.preventDefault();
if (link.href) {
let ele = document.getElementById(link.href);
ele && ele.scrollIntoView({ block: 'start', behavior: 'smooth' });
}
}
// //
onMounted(() => { onMounted(() => {
selectedRowKeys.value.push(queryId) selectedRowKeys.value.push(queryId)
@ -278,64 +289,6 @@ onMounted(() => {
}) })
}) })
//
const scrollAction = (event) => {
isScrollFlag.value = true;
if (!isScrollFlag.value) {
rrturn
}
const _scrollTop = event.target.scrollTop
nextTick(() => {
let len = navScrollTopArray.value.length;
let min = navScrollTopArray.value[1].scrollTop
let max = navScrollTopArray.value[len - 2].scrollTop;
for (let index = 0; index < navScrollTopArray.value.length; index++) {
const item = navScrollTopArray.value[index];
if (index < len - 1) {
if (_scrollTop > item.scrollTop && _scrollTop <= navScrollTopArray.value[index + 1].scrollTop) {
activeNameIndex.value = index + 1;
break;
}
}
if (_scrollTop >= max) {
activeNameIndex.value = len - 1;
break;
}
if (_scrollTop <= min) {
activeNameIndex.value = 0;
break;
}
}
})
}
let navScrollTopArray = ref([])
//
const getNavscrollTop = () => {
navScrollTopArray = ref([])
leftNav.value.map((title, index) => {
let realTop = ctx.refs[title][0].offsetTop;
navScrollTopArray.value.push({
scrollTop: realTop - 240,
index: index
})
})
}
let isScrollFlag = ref(false)
//
const changeTab = (n, data) => {
isScrollFlag.value = false;
activeNameIndex.value = n;
//
let realTop = ctx.refs[data][0].offsetTop;
if (realTop || realTop === 0) {
ctx.refs.bottomRef.scrollTo({
'top': realTop - 240,
'behavior': 'smooth'
})
}
}
const initData = () => { const initData = () => {
loadingPage.value = true; loadingPage.value = true;
@ -350,11 +303,10 @@ const initData = () => {
detailArray.value.push(formatterData(data[index])) detailArray.value.push(formatterData(data[index]))
} }
} }
//
getNewData()
nextTick(() => { nextTick(() => {
getNavscrollTop() //
getNewData()
}) })
loadingPage.value = false loadingPage.value = false
@ -588,6 +540,8 @@ const formatterData = (obj) => {
<style lang="less" scoped> <style lang="less" scoped>
.bg { .bg {
background: #fff; background: #fff;
height: 100vh;
width: 100%;
} }
// @font-face { // @font-face {
@ -618,15 +572,18 @@ const formatterData = (obj) => {
.box-container { .box-container {
width: 1592px; width: 1592px;
height: 900px;
margin: 0 auto; margin: 0 auto;
padding-top: 60px; padding-top: 60px;
height: 100vh;
box-sizing: border-box;
.content { .content {
display: flex; display: flex;
justify-content: flex-start; justify-content: flex-start;
align-items: flex-start; align-items: flex-start;
padding-top: 10px; padding-top: 10px;
height: calc(100% - 60px);
width: 100%;
} }
.nav-box { .nav-box {
@ -662,15 +619,15 @@ const formatterData = (obj) => {
.active { .active {
background: #0058e1; background: #0058e1;
color: #fff; color: #fff !important;
margin: 0; margin: 0;
} }
} }
.right { .right {
width: 1370px; width: 1370px;
height: 780px;
margin-left: 32px; margin-left: 32px;
height: 100%;
.top { .top {
width: 100%; width: 100%;
@ -713,8 +670,7 @@ const formatterData = (obj) => {
.bottom { .bottom {
width: 100%; width: 100%;
overflow-y: auto; overflow-y: auto;
// height: 7rem; height: calc(100% - 130px);
height: calc(100vh - 300px);
padding-bottom: 10px; padding-bottom: 10px;
box-sizing: border-box; box-sizing: border-box;
} }
@ -798,6 +754,7 @@ const formatterData = (obj) => {
.no-data { .no-data {
height: 100px; height: 100px;
width: 100%; width: 100%;
;
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
@ -817,4 +774,34 @@ const formatterData = (obj) => {
height: 140px; height: 140px;
width: 240px; width: 240px;
} }
.ant-anchor-wrapper {
width: 200px;
height: 600px;
background: rgba(244, 245, 248, 0.8);
padding-left: 0;
position: static;
}
.ant-anchor-ink::before {
content: ' ';
width: 0 !important;
}
/deep/ .ant-anchor {
position: static;
padding-left: 0;
}
.ant-anchor-link {
padding: 0;
margin: 0 14px;
height: 60px;
display: flex;
align-items: center;
justify-content: center;
font-size: 16px;
color: #212121;
border-bottom: 1px solid #dddee1;
}
</style> </style>