[update] 解决标准表格调整列宽会触发排序的问题

This commit is contained in:
lideqin
2024-02-22 13:38:43 +08:00
parent eb0d945a28
commit b36195eac0
5 changed files with 21 additions and 1 deletions
+6 -1
View File
@@ -256,7 +256,8 @@ export default {
cell: this.initDrag(this.columns) cell: this.initDrag(this.columns)
} }
}, },
selfScroll: {} selfScroll: {},
resizing: false
} }
}, },
watch: { watch: {
@@ -457,6 +458,7 @@ export default {
} }
// 开始拖拽监听 // 开始拖拽监听
const onDragging = (x) => { const onDragging = (x) => {
this.resizing = true
const beforeWidth = col.width const beforeWidth = col.width
const scroll = cloneDeep(this.scroll) || {} const scroll = cloneDeep(this.scroll) || {}
draggingState[key] = 0 draggingState[key] = 0
@@ -484,6 +486,9 @@ export default {
// 停止拖拽监听 // 停止拖拽监听
const onDragstop = () => { const onDragstop = () => {
draggingState[key] = thDom.getBoundingClientRect().width draggingState[key] = thDom.getBoundingClientRect().width
setTimeout(() => {
this.resizing = false
}, 200)
} }
// 控制最小拖拽宽度 // 控制最小拖拽宽度
const onDrag = (x) => { const onDrag = (x) => {
+12
View File
@@ -225,6 +225,18 @@ export const ConfigurableTableMixin = {
}) })
}, },
tableOnChange (pagination, filters, sorter) { tableOnChange (pagination, filters, sorter) {
// debugger;
console.log(this.$refs.tableRef.resizing)
if (this.$refs.tableRef.resizing) {
const classNameOne = window.event.target.parentNode.children[0].children[0].children[1].children[0].children[0].className
const classNameTwo = window.event.target.parentNode.children[0].children[0].children[1].children[0].children[1].className
const target = window.event.target
this.$nextTick(() => {
target.parentNode.children[0].children[0].children[1].children[0].children[0].className = classNameOne
target.parentNode.children[0].children[0].children[1].children[0].children[1].className = classNameTwo
})
return
}
console.log(sorter) console.log(sorter)
if (Object.keys(sorter).length > 0) { if (Object.keys(sorter).length > 0) {
if (sorter.field.split('_')[sorter.field.split('_').length - 1] === 'dictText') { if (sorter.field.split('_')[sorter.field.split('_').length - 1] === 'dictText') {
@@ -88,6 +88,7 @@
<div> <div>
<j-table <j-table
v-if="columns && columns.length > 0" v-if="columns && columns.length > 0"
ref="tableRef"
:columns="columns" :columns="columns"
:dataSource="dataSource" :dataSource="dataSource"
:can-drag="true" :can-drag="true"
@@ -123,6 +123,7 @@
<div> <div>
<j-table <j-table
v-if="columns && columns.length > 0" v-if="columns && columns.length > 0"
ref="tableRef"
:columns="columns" :columns="columns"
:dataSource="dataSource" :dataSource="dataSource"
:can-drag="true" :can-drag="true"
@@ -124,6 +124,7 @@
<div> <div>
<j-table <j-table
v-if="columns && columns.length > 0" v-if="columns && columns.length > 0"
ref="tableRef"
:columns="columns" :columns="columns"
:dataSource="dataSource" :dataSource="dataSource"
:can-drag="true" :can-drag="true"