修改:文件拖拽
This commit is contained in:
parent
5121a66fdb
commit
bf8412cf72
Binary file not shown.
|
Before Width: | Height: | Size: 3.4 KiB After Width: | Height: | Size: 3.4 KiB |
@ -90,8 +90,8 @@ export default {
|
|||||||
>>>.el-dialog__footer {
|
>>>.el-dialog__footer {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
bottom: 0px;
|
bottom: 0;
|
||||||
padding: 0px 20px 20px;
|
padding: 0 20px 20px;
|
||||||
background: linear-gradient(rgba(255,255,255,0), #fff);
|
background: linear-gradient(rgba(255,255,255,0), #fff);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -362,13 +362,13 @@
|
|||||||
</empty-file>
|
</empty-file>
|
||||||
<img id="dragImage" draggable="false" style="position: fixed;opacity: 0" src="~@/assets/img/hide.png">
|
<img id="dragImage" draggable="false" style="position: fixed;opacity: 0" src="~@/assets/img/hide.png">
|
||||||
<div id="numberFiles" class="number-files">
|
<div id="numberFiles" class="number-files">
|
||||||
<img class="icon" src="~@/assets/img/arrow1_left.png" style="display: block"/>
|
<img class="icon" src="~@/assets/img/arrow1_left.png" style="display: none"/>
|
||||||
<div class="number" style="display: none">1个文件</div>
|
<div class="number" style="display: inline">1个文件</div>
|
||||||
<div class="operate" style="display: block">
|
<div class="operate" style="display: none;white-space: nowrap;">
|
||||||
移动到:
|
移动到:
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div class="target">
|
||||||
<span class="target" style="display: block">document</span>
|
<span class="folder" style="display: none;white-space: nowrap;">document</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -1197,6 +1197,8 @@ export default {
|
|||||||
let draw = document.getElementById('v-draw-rectangle')
|
let draw = document.getElementById('v-draw-rectangle')
|
||||||
let rows = 0//行数
|
let rows = 0//行数
|
||||||
|
|
||||||
|
let drawOffsetLeft = getElementToPageLeft(draw)
|
||||||
|
|
||||||
let firstOver = 0 // 是否刚开始拖动
|
let firstOver = 0 // 是否刚开始拖动
|
||||||
let moveTitle = ''
|
let moveTitle = ''
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
@ -1212,11 +1214,8 @@ export default {
|
|||||||
}
|
}
|
||||||
// 为画矩形选取准备数据
|
// 为画矩形选取准备数据
|
||||||
let pos = getObjPos(child)
|
let pos = getObjPos(child)
|
||||||
pos.w = child.offsetWidth
|
|
||||||
pos.h = child.offsetHeight
|
|
||||||
|
|
||||||
child.w = child.offsetWidth
|
child.w = child.offsetWidth
|
||||||
child.h = child.offsetWidth
|
child.h = child.offsetHeight
|
||||||
child.x = pos.x
|
child.x = pos.x
|
||||||
child.y = pos.y
|
child.y = pos.y
|
||||||
pos.rowIndex = child.rowIndex
|
pos.rowIndex = child.rowIndex
|
||||||
@ -1276,6 +1275,7 @@ export default {
|
|||||||
dragIndex = -1
|
dragIndex = -1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
console.log(throughRow)
|
||||||
return throughRow
|
return throughRow
|
||||||
} else {
|
} else {
|
||||||
if (elPath[0].tagName === 'TD') {
|
if (elPath[0].tagName === 'TD') {
|
||||||
@ -1327,13 +1327,12 @@ export default {
|
|||||||
dragingDiv.classList.add('dragingDiv')
|
dragingDiv.classList.add('dragingDiv')
|
||||||
dragingDiv.style.transition = 'all 0.3s'
|
dragingDiv.style.transition = 'all 0.3s'
|
||||||
dragingDiv.style.zIndex = -1
|
dragingDiv.style.zIndex = -1
|
||||||
dragingDiv.style.positon = 'absolute'
|
dragingDiv.style.position = 'absolute'
|
||||||
dragingDiv.style.width = element.offsetWidth + 'px'
|
|
||||||
dragingDiv.style.height = element.offsetHeight + 'px'
|
|
||||||
dragingDiv.rowIndex = rowIndex
|
|
||||||
const pos = _this.dragElementList[rowIndex]
|
const pos = _this.dragElementList[rowIndex]
|
||||||
|
dragingDiv.style.width = pos.w + 'px'
|
||||||
|
dragingDiv.style.height = pos.h + 'px'
|
||||||
dragingDiv.style.top = pos.y - pos.h/2 + 10 + 'px'
|
dragingDiv.style.top = pos.y - pos.h/2 + 10 + 'px'
|
||||||
dragingDiv.style.left = pos.x - pos.w/2 + 6 + 'px'
|
dragingDiv.style.left = pos.x - drawOffsetLeft + 'px'
|
||||||
dragingDiv.original = {top: dragingDiv.style.top, left: dragingDiv.style.left}
|
dragingDiv.original = {top: dragingDiv.style.top, left: dragingDiv.style.left}
|
||||||
if (index === 0){
|
if (index === 0){
|
||||||
let numberFilesCopy = document.getElementById("numberFiles").cloneNode(true)
|
let numberFilesCopy = document.getElementById("numberFiles").cloneNode(true)
|
||||||
@ -1341,7 +1340,6 @@ export default {
|
|||||||
numberFilesCopy.querySelector('.number').innerHTML = _this.selectRowData.length + '个文件'
|
numberFilesCopy.querySelector('.number').innerHTML = _this.selectRowData.length + '个文件'
|
||||||
dragingDiv.appendChild(numberFilesCopy)
|
dragingDiv.appendChild(numberFilesCopy)
|
||||||
}
|
}
|
||||||
|
|
||||||
draw.appendChild(dragingDiv)
|
draw.appendChild(dragingDiv)
|
||||||
})
|
})
|
||||||
firstOver = 0
|
firstOver = 0
|
||||||
@ -1358,7 +1356,7 @@ export default {
|
|||||||
draggedIndex = dragged.rowIndex
|
draggedIndex = dragged.rowIndex
|
||||||
// 只有选中的才能拖拽
|
// 只有选中的才能拖拽
|
||||||
_this.cellMouseIndex = -1
|
_this.cellMouseIndex = -1
|
||||||
dragged.style.cursor = 'not-allowed'
|
// dragged.style.cursor = 'not-allowed'
|
||||||
dragBackCorlor = dragged.style.backgroundColor
|
dragBackCorlor = dragged.style.backgroundColor
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1381,9 +1379,14 @@ export default {
|
|||||||
dragged.style.cursor = 'copy'
|
dragged.style.cursor = 'copy'
|
||||||
|
|
||||||
let numberFilesCopy = document.getElementById('numberFilesCopy')
|
let numberFilesCopy = document.getElementById('numberFilesCopy')
|
||||||
console.log('numberFilesCopy', numberFilesCopy, numberFilesCopy.querySelector('.number'), numberFilesCopy.querySelector('.operate'))
|
numberFilesCopy.style.backgroundColor = '#40a9ffc9'
|
||||||
numberFilesCopy.querySelector('.number').style.display = 'none'
|
numberFilesCopy.querySelector('.number').style.display = 'none'
|
||||||
// numberFilesCopy.querySelector('.targer').style.display = 'block'
|
numberFilesCopy.querySelector('.icon').style.display = 'inline'
|
||||||
|
numberFilesCopy.querySelector('.operate').style.display = 'inline'
|
||||||
|
let targetFolder = numberFilesCopy.querySelector('.target .folder')
|
||||||
|
targetFolder.style.display = 'inline'
|
||||||
|
targetFolder.innerHTML = _this.fileList[throughRow.rowIndex].name
|
||||||
|
|
||||||
dragEnterBackCorlor = throughRow.style.backgroundColor
|
dragEnterBackCorlor = throughRow.style.backgroundColor
|
||||||
throughRow.style.backgroundColor = '#9fcdfc99'
|
throughRow.style.backgroundColor = '#9fcdfc99'
|
||||||
}
|
}
|
||||||
@ -1394,12 +1397,12 @@ export default {
|
|||||||
}
|
}
|
||||||
|
|
||||||
container.ondragover = function (e) {
|
container.ondragover = function (e) {
|
||||||
// console.log('draw.ondragover')
|
|
||||||
_this.selectRowData.forEach((row,index) => {
|
_this.selectRowData.forEach((row,index) => {
|
||||||
const drawRectangle = document.getElementById('dragingDiv'+row.index)
|
const drawRectangle = document.getElementById('dragingDiv'+row.index)
|
||||||
if (drawRectangle) {
|
if (drawRectangle) {
|
||||||
drawRectangle.style.left = e.clientX - 50 + index*3 + 'px'
|
drawRectangle.style.left = e.clientX - drawOffsetLeft + index*3 + 'px'
|
||||||
drawRectangle.style.top = e.clientY - 50 + index*3 + 'px'
|
drawRectangle.style.top = e.clientY - 50 + index*3 + 'px'
|
||||||
|
console.log(drawRectangle.style.top)
|
||||||
if (firstOver === 0){
|
if (firstOver === 0){
|
||||||
drawRectangle.style.zIndex = 999
|
drawRectangle.style.zIndex = 999
|
||||||
setTimeout(()=>{
|
setTimeout(()=>{
|
||||||
@ -1473,6 +1476,15 @@ export default {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
dragged.style.cursor = 'default'
|
dragged.style.cursor = 'default'
|
||||||
|
|
||||||
|
let numberFilesCopy = document.getElementById('numberFilesCopy')
|
||||||
|
if (numberFilesCopy) {
|
||||||
|
numberFilesCopy.style.backgroundColor = '#d2eefa66'
|
||||||
|
numberFilesCopy.querySelector('.number').style.display = 'inline'
|
||||||
|
numberFilesCopy.querySelector('.icon').style.display = 'none'
|
||||||
|
numberFilesCopy.querySelector('.operate').style.display = 'none'
|
||||||
|
numberFilesCopy.querySelector('.target .folder').style.display = 'none'
|
||||||
|
}
|
||||||
}
|
}
|
||||||
dragged.style.backgroundColor = dragBackCorlor
|
dragged.style.backgroundColor = dragBackCorlor
|
||||||
}
|
}
|
||||||
@ -3179,6 +3191,7 @@ export default {
|
|||||||
display: flex;
|
display: flex;
|
||||||
.icon {
|
.icon {
|
||||||
padding: 5px;
|
padding: 5px;
|
||||||
|
width: 40px;
|
||||||
}
|
}
|
||||||
span {
|
span {
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
@ -3187,9 +3200,13 @@ export default {
|
|||||||
padding: 0 15px 0 15px;
|
padding: 0 15px 0 15px;
|
||||||
}
|
}
|
||||||
.target {
|
.target {
|
||||||
background-color: #1d8cff;
|
.folder {
|
||||||
color: #f0f0f0;
|
background-color: #1d8cff;
|
||||||
padding: 8px;
|
color: #f0f0f0;
|
||||||
|
padding: 8px;
|
||||||
|
border-radius: 2px;
|
||||||
|
margin-right: 5px;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
// 获取DOM元素到页面顶部的距离
|
// 获取DOM元素到页面顶部的距离
|
||||||
export function getElementToPageTop(el) {
|
export function getElementToPageTop(el) {
|
||||||
if (el.className.indexOf('parent-grid-item') > -1) {
|
if (el.className && el.className.indexOf('parent-grid-item') > -1 || el.className.indexOf('van-grid-item van-grid-item--square') > -1) {
|
||||||
return el.offsetTop
|
return el.offsetTop
|
||||||
}
|
}
|
||||||
if (el.parentElement) {
|
if (el.parentElement) {
|
||||||
@ -10,7 +10,7 @@ export function getElementToPageTop(el) {
|
|||||||
}
|
}
|
||||||
// 获取DOM元素到页面左边的距离
|
// 获取DOM元素到页面左边的距离
|
||||||
export function getElementToPageLeft(el) {
|
export function getElementToPageLeft(el) {
|
||||||
if (el.className.indexOf('parent-grid-item') > -1) {
|
if (el.className && el.className.indexOf('parent-grid-item') > -1) {
|
||||||
return el.offsetLeft
|
return el.offsetLeft
|
||||||
}
|
}
|
||||||
if (el.offsetParent) {
|
if (el.offsetParent) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user