From caabac72a2db43b505db3ce89471b2db393ca685 Mon Sep 17 00:00:00 2001 From: jmal Date: Fri, 9 Apr 2021 17:08:21 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=EF=BC=9A=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E6=A8=A1=E5=BC=8F=E4=B8=8B=E6=96=87=E4=BB=B6=E9=A1=BA=E5=BA=8F?= =?UTF-8?q?=E4=B8=8D=E5=AF=B9=E7=9A=84=E9=97=AE=E9=A2=98=20=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=EF=BC=9A=E5=88=97=E8=A1=A8=E6=A8=A1=E5=BC=8F=E4=B8=8B?= =?UTF-8?q?=EF=BC=8C=E6=9C=89=E9=80=89=E4=B8=AD=E6=96=87=E4=BB=B6=E6=97=B6?= =?UTF-8?q?=EF=BC=8C=E7=82=B9=E5=87=BB=E8=A1=A8=E5=A4=B4=E6=89=A7=E8=A1=8C?= =?UTF-8?q?=E8=AE=A9=E6=8E=92=E5=BA=8F=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/ShowFile/ShowFile.vue | 47 +++++++++++++++++----------- 1 file changed, 28 insertions(+), 19 deletions(-) diff --git a/src/components/ShowFile/ShowFile.vue b/src/components/ShowFile/ShowFile.vue index 72748df..c62ce10 100644 --- a/src/components/ShowFile/ShowFile.vue +++ b/src/components/ShowFile/ShowFile.vue @@ -786,6 +786,7 @@ export default { stompClient: undefined,//websocket订阅集合 showUpdateDateItem: true,// 列表模式下是否显示修改时间 showSizeItem: true,// 列表模式下是否显示文件大小 + stopSortChange: false } }, computed: { @@ -967,8 +968,6 @@ export default { this.$refs.fileListTable.toggleRowSelection([{row: row}]) return } - this.$refs.fileListTable.clearSelection() - this.$refs.fileListTable.toggleRowSelection([{row: row}]) this.pinSelect(null, row) }, containerResize() { @@ -1019,6 +1018,17 @@ export default { } let evt = window.event || e 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 不为空就证明点到了文件 let throughRow = elPath.find(path => { 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.toggleRowSelection([{row: _this.fileList[throughRow.rowIndex], selected: true}]) } - } return } @@ -1093,6 +1102,12 @@ export default { document.onmouseup = function (e) { document.onmousemove = null; document.onmouseup = null; + if (_this.stopSortChange) { + _this.stopSortChange = false + setTimeout(()=>{ + _this.changeSelectedStyle(_this.selectRowData) + },200) + } setTimeout(function () { restoreScroll() _this.drawFlag = false @@ -1168,10 +1183,6 @@ export default { }, // 行拖拽 rowDrop() { - setTimeout(() => { - this.$refs.fileListTable.doLayout() - console.log('doLayout') - }, 500) if(this.selectFile){ return } @@ -1873,6 +1884,9 @@ export default { item.index = index }) this.$refs.fileListTable.reloadData(this.fileList) + setTimeout(() => { + this.$refs.fileListTable.reloadData(this.fileList) + }, 0) } // 数据全部加载完成 if (this.fileList.length >= res.count) { @@ -2125,6 +2139,9 @@ export default { this.changeSelectedStyle(rows) }, changeSelectedStyle(rows) { + if (this.stopSortChange){ + return + } let selectTotalSize = 0 rows.forEach(item => { selectTotalSize += item.size @@ -2231,14 +2248,7 @@ export default { this.$refs.fileListTable.toggleRowSelection([{row: row}]) return } - if (columnIndex === 0) { - 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) - } + this.pinSelect(null, row) } }, // 选取输入框部分内容 @@ -2901,14 +2911,13 @@ export default { this.$refs.fileListTable.tableSelectData = [] // 倒序 removeFileIndexList = removeFileIndexList.sort((a, b) => b - a) - const that = this - setTimeout(function () { + setTimeout(() => { // 再执行移除 for (let i = 0; i < removeFileIndexList.length; i++) { - that.fileList.splice(removeFileIndexList[i], 1) + this.splice(removeFileIndexList[i], 1) } // 改变拖拽目标 - // that.rowDrop() + this.rowDrop() }, 300) }, // 预览压缩文件