修改:文件拖拽
This commit is contained in:
parent
fa8b0fc548
commit
37fb371987
@ -1,6 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
<div class="dashboard-container" v-resize="containerResize">
|
<div class="dashboard-container" v-resize="containerResize" onselectstart="return false">
|
||||||
<v-contextmenu ref="homeContextmenu" :disabled="contextmenuDisabled">
|
<v-contextmenu ref="homeContextmenu" :disabled="contextmenuDisabled">
|
||||||
<div v-for="item of contextMenus" :key="item.operation">
|
<div v-for="item of contextMenus" :key="item.operation">
|
||||||
<!-- 一级菜单 -->
|
<!-- 一级菜单 -->
|
||||||
@ -190,7 +190,7 @@
|
|||||||
:height-change="false"
|
:height-change="false"
|
||||||
:row-class-name="tableRowClassName"
|
:row-class-name="tableRowClassName"
|
||||||
element-loading-text="文件加载中"
|
element-loading-text="文件加载中"
|
||||||
element-loading-spinner="el-icon-loading"collapse
|
element-loading-spinner="el-icon-loading"
|
||||||
element-loading-background="#f6f7fa88"
|
element-loading-background="#f6f7fa88"
|
||||||
@selection-change="handleSelectionChange"
|
@selection-change="handleSelectionChange"
|
||||||
@row-contextmenu="rowContextmenu"
|
@row-contextmenu="rowContextmenu"
|
||||||
@ -249,9 +249,7 @@
|
|||||||
>
|
>
|
||||||
</el-button>
|
</el-button>
|
||||||
</el-col>
|
</el-col>
|
||||||
<a v-else @click.stop="fileClick(scope.row)" class="table-file-name"><span>{{
|
<span v-else class="table-file-name">{{scope.row.name}}</span>
|
||||||
scope.row.name
|
|
||||||
}}</span></a>
|
|
||||||
</template>
|
</template>
|
||||||
</pl-table-column>
|
</pl-table-column>
|
||||||
<!--分享-->
|
<!--分享-->
|
||||||
@ -969,9 +967,6 @@ export default {
|
|||||||
this.$refs.fileListTable.toggleRowSelection([{row: row}])
|
this.$refs.fileListTable.toggleRowSelection([{row: row}])
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (!this.drawFlag) {
|
|
||||||
// this.fileClick(row)
|
|
||||||
}
|
|
||||||
this.$refs.fileListTable.clearSelection()
|
this.$refs.fileListTable.clearSelection()
|
||||||
this.$refs.fileListTable.toggleRowSelection([{row: row}])
|
this.$refs.fileListTable.toggleRowSelection([{row: row}])
|
||||||
this.pinSelect(null, row)
|
this.pinSelect(null, row)
|
||||||
@ -996,6 +991,7 @@ export default {
|
|||||||
} else {
|
} else {
|
||||||
this.showSizeItem = true
|
this.showSizeItem = true
|
||||||
}
|
}
|
||||||
|
// 使列表可拖拽
|
||||||
this.rowDrop()
|
this.rowDrop()
|
||||||
},
|
},
|
||||||
// 画矩形选区
|
// 画矩形选区
|
||||||
@ -1013,34 +1009,38 @@ export default {
|
|||||||
let retcLeft = 0, retcTop = 0, retcHeight = 0, retcWidth = 0
|
let retcLeft = 0, retcTop = 0, retcHeight = 0, retcWidth = 0
|
||||||
_this.drawFlag = false
|
_this.drawFlag = false
|
||||||
let itemClassName = 'el-table__row'
|
let itemClassName = 'el-table__row'
|
||||||
|
if (_this.grid) {
|
||||||
|
itemClassName = 'grid-time van-grid-item__content van-grid-item__content--center van-grid-item__content--square'
|
||||||
|
}
|
||||||
draw.onmousedown = null
|
draw.onmousedown = null
|
||||||
draw.onmousedown = function (e) {
|
draw.onmousedown = function (e) {
|
||||||
if (_this.fileListScrollTop > 0) {
|
if (_this.fileListScrollTop > 0) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
let evt = window.event || e
|
let evt = window.event || e
|
||||||
if (_this.grid) {
|
|
||||||
itemClassName = 'grid-time van-grid-item__content van-grid-item__content--center van-grid-item__content--square'
|
|
||||||
}
|
|
||||||
const elPath = e.path || (e.composedPath && e.composedPath())
|
const elPath = e.path || (e.composedPath && e.composedPath())
|
||||||
|
// 点击的区域是否为文件, throughRow 不为空就证明点到了文件
|
||||||
let throughRow = elPath.find(path => {
|
let throughRow = elPath.find(path => {
|
||||||
if (path.className === itemClassName || path.className === 'el-table__row el-table__row--striped') {
|
if (path.className === itemClassName || path.className === 'el-table__row el-table__row--striped') {
|
||||||
return path
|
return path
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
if (throughRow && _this.selectRowData.includes(_this.fileList[throughRow.rowIndex])) {
|
if (throughRow) {
|
||||||
|
// 鼠标按下时就选中文件
|
||||||
|
if (!_this.selectRowData.includes(_this.fileList[throughRow.rowIndex])){
|
||||||
|
if (!_this.isCmd && !_this.selectPin) {
|
||||||
|
_this.$refs.fileListTable.clearSelection()
|
||||||
|
_this.$refs.fileListTable.toggleRowSelection([{row: _this.fileList[throughRow.rowIndex], selected: true}])
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (evt.button !== 0) {
|
if (evt.button !== 0) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (!_this.isCmd && !_this.selectPin) {
|
if (!_this.isCmd && !_this.selectPin) {
|
||||||
let index = -1
|
const index = elPath.findIndex(el => el.className === itemClassName || el.className === 'el-table__row el-table__row--striped')
|
||||||
if (_this.grid) {
|
|
||||||
index = elPath.findIndex(el => el.className === 'grid-time van-grid-item__content van-grid-item__content--center van-grid-item__content--square')
|
|
||||||
} else {
|
|
||||||
index = elPath.findIndex(el => el.className === 'plTableBox')
|
|
||||||
}
|
|
||||||
if(index < 0){
|
if(index < 0){
|
||||||
_this.$refs.fileListTable.clearSelection()
|
_this.$refs.fileListTable.clearSelection()
|
||||||
}
|
}
|
||||||
@ -1168,6 +1168,10 @@ export default {
|
|||||||
},
|
},
|
||||||
// 行拖拽
|
// 行拖拽
|
||||||
rowDrop() {
|
rowDrop() {
|
||||||
|
setTimeout(() => {
|
||||||
|
this.$refs.fileListTable.doLayout()
|
||||||
|
console.log('doLayout')
|
||||||
|
}, 500)
|
||||||
if(this.selectFile){
|
if(this.selectFile){
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -1185,8 +1189,12 @@ export default {
|
|||||||
let draggedIndex = -1;
|
let draggedIndex = -1;
|
||||||
|
|
||||||
let parentClassName = 'van-grid'
|
let parentClassName = 'van-grid'
|
||||||
let gridItemClassName = 'van-grid-item van-grid-item--square'
|
let itemClassName = 'van-grid-item van-grid-item--square'
|
||||||
let gridItemChildenClassName = 'grid-time van-grid-item__content van-grid-item__content--center van-grid-item__content--square'
|
let gridItemChildenClassName = 'grid-time van-grid-item__content van-grid-item__content--center van-grid-item__content--square'
|
||||||
|
if (!_this.grid) {
|
||||||
|
itemClassName = 'el-table__row'
|
||||||
|
parentClassName = 'el-table__body'
|
||||||
|
}
|
||||||
|
|
||||||
// 正在拖动的元素
|
// 正在拖动的元素
|
||||||
let dragingDiv = null
|
let dragingDiv = null
|
||||||
@ -1249,8 +1257,47 @@ export default {
|
|||||||
|
|
||||||
// 判断经过了那个元素
|
// 判断经过了那个元素
|
||||||
let judgThroughDom = function (e, d) {
|
let judgThroughDom = function (e, d) {
|
||||||
let throughRow = null
|
|
||||||
const elPath = e.path || (e.composedPath && e.composedPath())
|
const elPath = e.path || (e.composedPath && e.composedPath())
|
||||||
|
if (d === 'enter') {
|
||||||
|
// 这里进入其他容器后 清除上次进入的容器的状态
|
||||||
|
let node = null
|
||||||
|
const className = e.toElement.className
|
||||||
|
if (_this.grid){
|
||||||
|
if (e.toElement.className === itemClassName) {
|
||||||
|
node = e.toElement
|
||||||
|
}
|
||||||
|
if (e.toElement.className === parentClassName) {
|
||||||
|
node = e.fromElement
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// 列表模式
|
||||||
|
if (elPath[0].id === 'v-draw-rectangle' || elPath[0].className === 'el-table__virtual-wrapper') {
|
||||||
|
// 超出列表底部
|
||||||
|
node = e.toElement
|
||||||
|
} else {
|
||||||
|
// 超出列表顶部
|
||||||
|
node = elPath.find(path => {
|
||||||
|
if (path.className === 'el-table__header-wrapper') {
|
||||||
|
return path
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (node) {
|
||||||
|
// console.log(d,e,node,node.rowIndex)
|
||||||
|
if (dragIndex > -1) {
|
||||||
|
// 清除上次进入的容器的状态
|
||||||
|
const last = target.children[dragIndex];
|
||||||
|
clearClass(last)
|
||||||
|
}
|
||||||
|
// console.log("离开了",leaveIndex,"dragIndex:",dragIndex)
|
||||||
|
// leaveIndex = node.rowIndex
|
||||||
|
// const leave = target.children[leaveIndex];
|
||||||
|
// clearClass(leave)
|
||||||
|
dragIndex = -1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let throughRow = null
|
||||||
if (_this.grid) {
|
if (_this.grid) {
|
||||||
if (elPath[0].className === gridItemChildenClassName) {
|
if (elPath[0].className === gridItemChildenClassName) {
|
||||||
// throughRow 表示被拖动的元素正在哪一行上
|
// throughRow 表示被拖动的元素正在哪一行上
|
||||||
@ -1262,28 +1309,6 @@ export default {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
if (d === 'enter') {
|
|
||||||
let node = null
|
|
||||||
if (e.toElement.className === gridItemClassName) {
|
|
||||||
node = e.toElement
|
|
||||||
}
|
|
||||||
if (e.toElement.className === parentClassName) {
|
|
||||||
node = e.fromElement
|
|
||||||
}
|
|
||||||
if (node) {
|
|
||||||
// console.log(d,e,node,node.rowIndex)
|
|
||||||
leaveIndex = node.rowIndex
|
|
||||||
if (dragIndex > -1) {
|
|
||||||
// 清除上次进入的容器的状态
|
|
||||||
const last = target.children[dragIndex];
|
|
||||||
clearClass(last)
|
|
||||||
}
|
|
||||||
// console.log("离开了",leaveIndex,"dragIndex:",dragIndex)
|
|
||||||
const leave = target.children[leaveIndex];
|
|
||||||
clearClass(leave)
|
|
||||||
dragIndex = -1
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return throughRow
|
return throughRow
|
||||||
} else {
|
} else {
|
||||||
if (elPath[0].tagName === 'TD') {
|
if (elPath[0].tagName === 'TD') {
|
||||||
@ -1298,6 +1323,27 @@ export default {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 复原拖拽的dom
|
||||||
|
let recover = function (animation) {
|
||||||
|
if (animation) {
|
||||||
|
_this.selectRowData.forEach(row => {
|
||||||
|
let dragingDiv = document.getElementById('dragingDiv' + row.index)
|
||||||
|
dragingDiv.style.transition = 'all 0.3s'
|
||||||
|
dragingDiv.style.top = dragingDiv.original.top
|
||||||
|
dragingDiv.style.left = dragingDiv.original.left
|
||||||
|
})
|
||||||
|
setTimeout(()=> {
|
||||||
|
_this.selectRowData.forEach(row => {
|
||||||
|
draw.removeChild(document.getElementById('dragingDiv' + row.index))
|
||||||
|
})
|
||||||
|
}, 300)
|
||||||
|
} else {
|
||||||
|
_this.selectRowData.forEach(row => {
|
||||||
|
draw.removeChild(document.getElementById('dragingDiv' + row.index))
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
container.ondragend = function (e) {
|
container.ondragend = function (e) {
|
||||||
Bus.$emit('onDragStart', false)
|
Bus.$emit('onDragStart', false)
|
||||||
// console.log('child'+dragIndex+'拖拽结束');
|
// console.log('child'+dragIndex+'拖拽结束');
|
||||||
@ -1306,28 +1352,17 @@ export default {
|
|||||||
clearClass(last)
|
clearClass(last)
|
||||||
dragged.style.cursor = 'default'
|
dragged.style.cursor = 'default'
|
||||||
e.target.parentNode.parentNode.title = moveTitle
|
e.target.parentNode.parentNode.title = moveTitle
|
||||||
_this.selectRowData.forEach(row => {
|
|
||||||
let dragingDiv = document.getElementById('dragingDiv' + row.index)
|
|
||||||
dragingDiv.style.transition = 'all 0.3s'
|
|
||||||
dragingDiv.style.top = dragingDiv.original.top
|
|
||||||
dragingDiv.style.left = dragingDiv.original.left
|
|
||||||
})
|
|
||||||
// setTimeout(()=> {
|
|
||||||
// _this.selectRowData.forEach(row => {
|
|
||||||
// draw.removeChild(document.getElementById('dragingDiv' + row.index))
|
|
||||||
// })
|
|
||||||
// }, 300)
|
|
||||||
}
|
}
|
||||||
// 开始拖拽
|
// 开始拖拽
|
||||||
container.ondragstart = (e) => {
|
container.ondragstart = (e) => {
|
||||||
// 正在选区时禁止拖拽
|
// 正在选区获取按住关键键时禁止拖拽
|
||||||
// if (_this.drawFlag) {
|
if (_this.drawFlag || _this.isCmd || _this.selectPin) {
|
||||||
// e.preventDefault()
|
e.preventDefault()
|
||||||
// e.stopPropagation()
|
e.stopPropagation()
|
||||||
// return
|
return
|
||||||
// }
|
}
|
||||||
// 判断被拖拽dom是否有slot属性并且等于'jmal'
|
// 判断被拖拽dom是否有slot属性并且等于'jmal'
|
||||||
if (e.target.slot && e.target.slot !== 'jmal'){
|
if (!e.target.slot || e.target.slot !== 'jmal'){
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
// 当滚动条滚动后禁止拖拽
|
// 当滚动条滚动后禁止拖拽
|
||||||
@ -1396,9 +1431,9 @@ export default {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
container.ondragenter = function (e) {
|
container.ondragenter = function (e) {
|
||||||
// console.log('ondragenter')
|
// console.log('ondragenter', e.target)
|
||||||
clearTimeout(loop)
|
clearTimeout(loop)
|
||||||
// 由于被拖动的元素 经过tbody中的每一元素都会触发该事件, 但是我们只需要它正在那一行上就行了
|
// 由于被拖动的元素 经过区域内中的每一元素都会触发该事件, 但是我们只需要它正在那一行上就行了
|
||||||
let throughRow = judgThroughDom(e, 'enter')
|
let throughRow = judgThroughDom(e, 'enter')
|
||||||
if (throughRow) {
|
if (throughRow) {
|
||||||
if (dragIndex !== throughRow.rowIndex) {
|
if (dragIndex !== throughRow.rowIndex) {
|
||||||
@ -1480,7 +1515,6 @@ export default {
|
|||||||
}
|
}
|
||||||
container.ondrop = function () {
|
container.ondrop = function () {
|
||||||
// console.log('放下了'+draggedIndex);
|
// console.log('放下了'+draggedIndex);
|
||||||
|
|
||||||
const form = _this.fileList[draggedIndex]
|
const form = _this.fileList[draggedIndex]
|
||||||
const to = _this.fileList[dragIndex]
|
const to = _this.fileList[dragIndex]
|
||||||
if (form && to && form.id !== to.id && to.isFolder && !_this.selectRowData.includes(to)) {
|
if (form && to && form.id !== to.id && to.isFolder && !_this.selectRowData.includes(to)) {
|
||||||
@ -1495,7 +1529,12 @@ export default {
|
|||||||
type: 'info'
|
type: 'info'
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
_this.copyOrMoveApi('move', forms, to.id)
|
_this.copyOrMoveApi('move', forms, to.id)
|
||||||
}).catch()
|
recover(false)
|
||||||
|
}).catch(() => {
|
||||||
|
recover(true)
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
recover(true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 清除之前的样式
|
// 清除之前的样式
|
||||||
@ -1847,8 +1886,6 @@ export default {
|
|||||||
this.containerResize()
|
this.containerResize()
|
||||||
this.tableLoading = false
|
this.tableLoading = false
|
||||||
})
|
})
|
||||||
// 使列表可拖拽
|
|
||||||
this.rowDrop()
|
|
||||||
// 加载菜单状态
|
// 加载菜单状态
|
||||||
this.loadContextMenus()
|
this.loadContextMenus()
|
||||||
// 使列表滑到顶部
|
// 使列表滑到顶部
|
||||||
@ -2003,7 +2040,6 @@ export default {
|
|||||||
},
|
},
|
||||||
sortChange(column) {
|
sortChange(column) {
|
||||||
let {prop, order} = column
|
let {prop, order} = column
|
||||||
this.rowDrop()
|
|
||||||
if (this.orderCustom || this.listModeSearch) {
|
if (this.orderCustom || this.listModeSearch) {
|
||||||
this.sortable.prop = prop
|
this.sortable.prop = prop
|
||||||
this.sortable.order = order
|
this.sortable.order = order
|
||||||
@ -2872,7 +2908,7 @@ export default {
|
|||||||
that.fileList.splice(removeFileIndexList[i], 1)
|
that.fileList.splice(removeFileIndexList[i], 1)
|
||||||
}
|
}
|
||||||
// 改变拖拽目标
|
// 改变拖拽目标
|
||||||
that.rowDrop()
|
// that.rowDrop()
|
||||||
}, 300)
|
}, 300)
|
||||||
},
|
},
|
||||||
// 预览压缩文件
|
// 预览压缩文件
|
||||||
@ -3102,8 +3138,7 @@ export default {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.table-file-name:hover {
|
.table-file-name:hover {
|
||||||
color: #19ACF9;
|
cursor: default;
|
||||||
cursor: pointer;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/deep/ .plTableBox .el-table .el-table__header {
|
/deep/ .plTableBox .el-table .el-table__header {
|
||||||
@ -3252,5 +3287,11 @@ export default {
|
|||||||
/deep/ .el-table::before {
|
/deep/ .el-table::before {
|
||||||
height: 0;
|
height: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/deep/.el-table {
|
||||||
|
th.gutter{
|
||||||
|
display: table-cell!important;
|
||||||
|
}
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
|||||||
@ -187,8 +187,8 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
/deep/ .el-table__row /deep/.table-file-name:hover {
|
/deep/ .el-table__row /deep/.table-file-name:hover {
|
||||||
cursor: 'pointer';
|
cursor: pointer;
|
||||||
color: "#19ACF9"
|
color: #19ACF9
|
||||||
}
|
}
|
||||||
|
|
||||||
.search-class{
|
.search-class{
|
||||||
@ -288,6 +288,7 @@
|
|||||||
font-size: 5rem;
|
font-size: 5rem;
|
||||||
}
|
}
|
||||||
/deep/ .grid-item-text {
|
/deep/ .grid-item-text {
|
||||||
|
cursor: default;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
color: #606266;
|
color: #606266;
|
||||||
font-size: smaller;
|
font-size: smaller;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user