修复:列表模式下文件顺序不对的问题

修复:列表模式下,有选中文件时,点击表头执行让排序的问题
This commit is contained in:
jmal 2021-04-09 17:08:21 +08:00
parent 37fb371987
commit caabac72a2

View File

@ -786,6 +786,7 @@ export default {
stompClient: undefined,//websocket订阅集合 stompClient: undefined,//websocket订阅集合
showUpdateDateItem: true,// 列表模式下是否显示修改时间 showUpdateDateItem: true,// 列表模式下是否显示修改时间
showSizeItem: true,// 列表模式下是否显示文件大小 showSizeItem: true,// 列表模式下是否显示文件大小
stopSortChange: false
} }
}, },
computed: { computed: {
@ -967,8 +968,6 @@ export default {
this.$refs.fileListTable.toggleRowSelection([{row: row}]) this.$refs.fileListTable.toggleRowSelection([{row: row}])
return return
} }
this.$refs.fileListTable.clearSelection()
this.$refs.fileListTable.toggleRowSelection([{row: row}])
this.pinSelect(null, row) this.pinSelect(null, row)
}, },
containerResize() { containerResize() {
@ -1019,6 +1018,17 @@ export default {
} }
let evt = window.event || e let evt = window.event || e
const elPath = e.path || (e.composedPath && e.composedPath()) const elPath = e.path || (e.composedPath && e.composedPath())
// 列表模式下点击表头,阻止点击事件
if (!_this.grid && _this.selectRowData.length > 0) {
const findIndex = elPath.findIndex(path => {
if (path.className === 'el-table__header-wrapper') {
return path
}
})
if (findIndex > -1){
_this.stopSortChange = true
}
}
// 点击的区域是否为文件, throughRow 不为空就证明点到了文件 // 点击的区域是否为文件, 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') {
@ -1032,7 +1042,6 @@ export default {
_this.$refs.fileListTable.clearSelection() _this.$refs.fileListTable.clearSelection()
_this.$refs.fileListTable.toggleRowSelection([{row: _this.fileList[throughRow.rowIndex], selected: true}]) _this.$refs.fileListTable.toggleRowSelection([{row: _this.fileList[throughRow.rowIndex], selected: true}])
} }
} }
return return
} }
@ -1093,6 +1102,12 @@ export default {
document.onmouseup = function (e) { document.onmouseup = function (e) {
document.onmousemove = null; document.onmousemove = null;
document.onmouseup = null; document.onmouseup = null;
if (_this.stopSortChange) {
_this.stopSortChange = false
setTimeout(()=>{
_this.changeSelectedStyle(_this.selectRowData)
},200)
}
setTimeout(function () { setTimeout(function () {
restoreScroll() restoreScroll()
_this.drawFlag = false _this.drawFlag = false
@ -1168,10 +1183,6 @@ export default {
}, },
// 行拖拽 // 行拖拽
rowDrop() { rowDrop() {
setTimeout(() => {
this.$refs.fileListTable.doLayout()
console.log('doLayout')
}, 500)
if(this.selectFile){ if(this.selectFile){
return return
} }
@ -1873,6 +1884,9 @@ export default {
item.index = index item.index = index
}) })
this.$refs.fileListTable.reloadData(this.fileList) this.$refs.fileListTable.reloadData(this.fileList)
setTimeout(() => {
this.$refs.fileListTable.reloadData(this.fileList)
}, 0)
} }
// 数据全部加载完成 // 数据全部加载完成
if (this.fileList.length >= res.count) { if (this.fileList.length >= res.count) {
@ -2125,6 +2139,9 @@ export default {
this.changeSelectedStyle(rows) this.changeSelectedStyle(rows)
}, },
changeSelectedStyle(rows) { changeSelectedStyle(rows) {
if (this.stopSortChange){
return
}
let selectTotalSize = 0 let selectTotalSize = 0
rows.forEach(item => { rows.forEach(item => {
selectTotalSize += item.size selectTotalSize += item.size
@ -2231,14 +2248,7 @@ export default {
this.$refs.fileListTable.toggleRowSelection([{row: row}]) this.$refs.fileListTable.toggleRowSelection([{row: row}])
return return
} }
if (columnIndex === 0) { this.pinSelect(null, row)
this.pinSelect(null, row)
this.$refs.fileListTable.toggleRowSelection([{row: row}])
} else {
this.$refs.fileListTable.clearSelection()
this.$refs.fileListTable.toggleRowSelection([{row: row}])
this.pinSelect(null, row)
}
} }
}, },
// 选取输入框部分内容 // 选取输入框部分内容
@ -2901,14 +2911,13 @@ export default {
this.$refs.fileListTable.tableSelectData = [] this.$refs.fileListTable.tableSelectData = []
// 倒序 // 倒序
removeFileIndexList = removeFileIndexList.sort((a, b) => b - a) removeFileIndexList = removeFileIndexList.sort((a, b) => b - a)
const that = this setTimeout(() => {
setTimeout(function () {
// 再执行移除 // 再执行移除
for (let i = 0; i < removeFileIndexList.length; i++) { for (let i = 0; i < removeFileIndexList.length; i++) {
that.fileList.splice(removeFileIndexList[i], 1) this.splice(removeFileIndexList[i], 1)
} }
// 改变拖拽目标 // 改变拖拽目标
// that.rowDrop() this.rowDrop()
}, 300) }, 300)
}, },
// 预览压缩文件 // 预览压缩文件