拖拽修复

openf12 V2.1.6
yujialong 1 year ago
parent e58f0cc376
commit 350f74feb9
  1. 42
      src/components/TestPanel.vue

@ -2,9 +2,11 @@
<div :class="['panel', {active: pannelVisible}]" <div :class="['panel', {active: pannelVisible}]"
id="panel"> id="panel">
<el-container class="scrollbar" <el-container class="scrollbar"
id="container"
v-show="pannelVisible"> v-show="pannelVisible">
<el-header id="header"> <el-header id="header">
<div class="panel-header"> <div class="panel-header"
id="panelHeader">
<div class="project"> <div class="project">
<div class="inline-center"> <div class="inline-center">
<p>实训项目</p> <p>实训项目</p>
@ -93,8 +95,10 @@
</el-table-column> </el-table-column>
</el-table> </el-table>
</div> </div>
<el-container v-else> <el-container id="infoContainer"
<el-aside width="30%"> v-else>
<el-aside id="aside"
width="30%">
<div class="aside-header"> <div class="aside-header">
<div :class="['p-title color', 'system' + systemId]"> <div :class="['p-title color', 'system' + systemId]">
<i class="el-icon-s-order"></i> <i class="el-icon-s-order"></i>
@ -158,7 +162,7 @@
</div> </div>
</div> </div>
</el-aside> </el-aside>
<el-main> <el-main id="main">
<el-tabs class="info-tab" <el-tabs class="info-tab"
v-model="pannelTab" v-model="pannelTab"
type="card"> type="card">
@ -335,7 +339,8 @@ export default {
reportTab: '', reportTab: '',
reportPoints: [], reportPoints: [],
reportVisible: false, reportVisible: false,
tableHeight: 0 tableHeight: 0,
dragIds: ['panelHeader', 'aside', 'main', 'infoContainer']
}; };
}, },
components: { components: {
@ -934,9 +939,8 @@ export default {
// //
drag () { drag () {
const el = document.querySelector('#panel') const el = document.querySelector('#panel')
let gap = 10 //
let parent = document.body
const drag = e => { const drag = e => {
if (this.dragIds.includes(e.target.id)) {
e.stopPropagation && e.stopPropagation() e.stopPropagation && e.stopPropagation()
e.preventDefault && e.preventDefault() e.preventDefault && e.preventDefault()
e.cancelBubble = true e.cancelBubble = true
@ -949,16 +953,6 @@ export default {
document.onmousemove = function (eve) { document.onmousemove = function (eve) {
left = eve.clientX - x left = eve.clientX - x
top = eve.clientY - y top = eve.clientY - y
// //
// if (left <= gap) {
// left = 0
// }
// if (left >= parent.offsetWidth - el.offsetWidth - gap - 35) { //-
// left = parent.offsetWidth - el.offsetWidth - 35
// }
// //
// if (top <= gap) top = 0
el.style.left = left + 'px' el.style.left = left + 'px'
el.style.top = top + 'px' el.style.top = top + 'px'
} }
@ -967,10 +961,11 @@ export default {
document.onmouseup = null document.onmouseup = null
} }
} }
document.querySelector('#header').onmousedown = drag }
// document.querySelector('#header').onmousedown = drag
document.querySelector('.scrollbar').onmousedown = drag
const toggle = document.querySelector('#toggle')
const drag1 = e => { const drag1 = e => {
e.stopPropagation && e.stopPropagation() e.stopPropagation && e.stopPropagation()
e.preventDefault && e.preventDefault() e.preventDefault && e.preventDefault()
@ -989,15 +984,6 @@ export default {
clearTimeout(timer) clearTimeout(timer)
left = eve.clientX - x left = eve.clientX - x
top = eve.clientY - y top = eve.clientY - y
//
// if (left <= gap) left = 0
// const offsetWidth = this.pannelVisible ? el.offsetWidth : 0
// if (left >= parent.offsetWidth - offsetWidth - gap - 35) { //-
// left = parent.offsetWidth - offsetWidth - 35
// }
//
// if (top <= gap) top = 0
el.style.left = left + 'px' el.style.left = left + 'px'
el.style.top = top + 'px' el.style.top = top + 'px'
} }

Loading…
Cancel
Save