From 350f74feb9fc2d3ddea1ebb03741f95d1a52b5f5 Mon Sep 17 00:00:00 2001 From: yujialong <479214531@qq.com> Date: Thu, 10 Aug 2023 10:02:43 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8B=96=E6=8B=BD=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/TestPanel.vue | 76 +++++++++++++++--------------------- 1 file changed, 31 insertions(+), 45 deletions(-) diff --git a/src/components/TestPanel.vue b/src/components/TestPanel.vue index 0af8900..9e895fe 100644 --- a/src/components/TestPanel.vue +++ b/src/components/TestPanel.vue @@ -2,9 +2,11 @@
-
+

实训项目

@@ -93,8 +95,10 @@
- - + +
@@ -158,7 +162,7 @@
- + @@ -335,7 +339,8 @@ export default { reportTab: '', reportPoints: [], reportVisible: false, - tableHeight: 0 + tableHeight: 0, + dragIds: ['panelHeader', 'aside', 'main', 'infoContainer'] }; }, components: { @@ -934,43 +939,33 @@ export default { // 拖拽面板 drag () { const el = document.querySelector('#panel') - let gap = 10 // 缝隙:小于缝隙时,则吸附 - let parent = document.body const drag = e => { - e.stopPropagation && e.stopPropagation() - e.preventDefault && e.preventDefault() - e.cancelBubble = true - e.returnValue = false - let x = e.clientX - el.offsetLeft - let y = e.clientY - el.offsetTop - let left = 0 - let top = 0 + if (this.dragIds.includes(e.target.id)) { + e.stopPropagation && e.stopPropagation() + e.preventDefault && e.preventDefault() + e.cancelBubble = true + e.returnValue = false + let x = e.clientX - el.offsetLeft + let y = e.clientY - el.offsetTop + let left = 0 + let top = 0 - document.onmousemove = function (eve) { - left = eve.clientX - x - 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.top = top + 'px' - } - document.onmouseup = e => { - document.onmousemove = null - document.onmouseup = null + document.onmousemove = function (eve) { + left = eve.clientX - x + top = eve.clientY - y + el.style.left = left + 'px' + el.style.top = top + 'px' + } + document.onmouseup = e => { + document.onmousemove = 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 => { e.stopPropagation && e.stopPropagation() e.preventDefault && e.preventDefault() @@ -989,15 +984,6 @@ export default { clearTimeout(timer) left = eve.clientX - x 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.top = top + 'px' }