Commit fa096810 authored by 罗超's avatar 罗超

修复缩放滚动问题

parent 29123da1
...@@ -40,9 +40,9 @@ export default { ...@@ -40,9 +40,9 @@ export default {
const box = document.querySelector('#scrollBox') const box = document.querySelector('#scrollBox')
const tb = document.querySelector(`#${this.targetBox}`) const tb = document.querySelector(`#${this.targetBox}`)
const tw = document.querySelector(`#${this.targetWrap}`) const tw = document.querySelector(`#${this.targetWrap}`)
const zoom = tw.style.zoom?tw.style.zoom:1
if(box && tb && tw){ if(box && tb && tw){
this.ratio = tw.offsetWidth/tb.offsetWidth this.ratio = (tw.offsetWidth*zoom)/tb.offsetWidth
this.innerW = `${this.ratio * box.offsetWidth}px` this.innerW = `${this.ratio * box.offsetWidth}px`
this.boxRatio = tb.offsetWidth/box.offsetWidth this.boxRatio = tb.offsetWidth/box.offsetWidth
} }
......
<template> <template>
<!-- <div class="page-body" style="height:calc(100% - 30px);"> --> <!-- <div class="page-body" style="height:calc(100% - 30px);"> -->
<div class="sptable-box" id="sptable"> <div class="sptable-box" id="sptable">
<div class="sptable-wrap" id="sptableWrap" v-loading="loading" :style="{'zoom':zoom}"> <div class="sptable-wrap" v-loading="loading">
<table class="sptable"> <table class="sptable" id="sptableWrap" :style="{'zoom':zoom}">
<thead> <thead>
<tr class="sticky-header"> <tr class="sticky-header">
<th class="sticky-column stubg">学员</th> <th class="sticky-column stubg">学员</th>
...@@ -80,7 +80,12 @@ ...@@ -80,7 +80,12 @@
targetBox="sptable" targetBox="sptable"
targetWrap="sptableWrap" targetWrap="sptableWrap"
@scrollChange="scrollHandle" @scrollChange="scrollHandle"
ref="scrollBar"
></scroll-bar> ></scroll-bar>
<div class="q-ml-md row items-center">
<span>{{ Math.ceil(zoom*100) }}%</span>
<q-btn @click="resetZoom" color="primary" v-show="zoom!=1" style="padding: 0; font-size: 11px !important;font-family: microsoft yahei !important; font-weight: 400;" flat label="重置" />
</div>
</div> </div>
</div> </div>
<!-- </div> --> <!-- </div> -->
...@@ -120,7 +125,6 @@ export default { ...@@ -120,7 +125,6 @@ export default {
}, },
methods: { methods: {
scrollHandle(e) { scrollHandle(e) {
console.log(e);
const box = document.querySelector("#sptable"); const box = document.querySelector("#sptable");
box.scrollLeft = e; box.scrollLeft = e;
}, },
...@@ -161,7 +165,6 @@ export default { ...@@ -161,7 +165,6 @@ export default {
if(!this.currentCourse || !this.currentCourse.CourseId) return if(!this.currentCourse || !this.currentCourse.CourseId) return
this.loading = true; this.loading = true;
queryScheduleCourseStu({CourseRate:this.currentCourse.CourseRate}).then(r=>{ queryScheduleCourseStu({CourseRate:this.currentCourse.CourseRate}).then(r=>{
console.log(r.Data)
this.students = r.Data this.students = r.Data
this.loading = false; this.loading = false;
this.assembleHandler() this.assembleHandler()
...@@ -178,6 +181,9 @@ export default { ...@@ -178,6 +181,9 @@ export default {
x.assemble.push(r) x.assemble.push(r)
}) })
}) })
this.$nextTick(()=>{
this.$refs.scrollBar.calcHandle()
})
}, },
handleWheel(event) { handleWheel(event) {
if(event.ctrlKey === true || event.metaKey === true){ if(event.ctrlKey === true || event.metaKey === true){
...@@ -186,6 +192,7 @@ export default { ...@@ -186,6 +192,7 @@ export default {
} else { } else {
this.zoomIn(); this.zoomIn();
} }
this.$refs.scrollBar.calcHandle()
event.preventDefault(); event.preventDefault();
return false return false
} }
...@@ -198,6 +205,10 @@ export default { ...@@ -198,6 +205,10 @@ export default {
zoomOut() { zoomOut() {
// 缩小逻辑 // 缩小逻辑
if(this.zoom>0.1) this.zoom-=0.05 if(this.zoom>0.1) this.zoom-=0.05
},
resetZoom(){
this.zoom=1
this.$refs.scrollBar.calcHandle()
} }
}, },
created() { created() {
...@@ -218,7 +229,7 @@ export default { ...@@ -218,7 +229,7 @@ export default {
height: 100%; height: 100%;
overflow-y: auto; overflow-y: auto;
padding-bottom: 20px; padding-bottom: 20px;
user-select: none; /* user-select: none; */
background: #fff; background: #fff;
} }
.sptable-box .sptable-wrap { .sptable-box .sptable-wrap {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment