Skip to content

Commit

Permalink
releases 4.10.2
Browse files Browse the repository at this point in the history
  • Loading branch information
xuliangzhan committed Jan 7, 2025
1 parent f73e3b5 commit a34a3b9
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 30 deletions.
15 changes: 8 additions & 7 deletions examples/views/table/TableTest2.vue
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,15 @@ const exportModes = ref([
])
const customConfig = reactive<VxeTablePropTypes.CustomConfig>({
immediate: false,
storage: true
// immediate: false,
// storage: true,
checkMethod ({ column }) {
return column.type !== 'seq'
},
visibleMethod ({ column }) {
return column.field !== 'address'
}
// checkMethod ({ column }) {
// return column.type !== 'seq'
// },
// visibleMethod ({ column }) {
// return column.field !== 'address'
// }
})
const demo1 = reactive({
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vxe-table",
"version": "4.10.1",
"version": "4.10.2",
"description": "一个基于 vue 的 PC 端表格组件,支持增删改查、虚拟树、拖拽排序,懒加载、快捷菜单、数据校验、树形结构、打印、导入导出、自定义模板、渲染器、JSON 配置式...",
"scripts": {
"update": "npm install --legacy-peer-deps",
Expand Down Expand Up @@ -28,7 +28,7 @@
"style": "lib/style.css",
"typings": "types/index.d.ts",
"dependencies": {
"vxe-pc-ui": "^4.3.65"
"vxe-pc-ui": "^4.3.66"
},
"devDependencies": {
"@types/resize-observer-browser": "^0.1.11",
Expand Down
6 changes: 3 additions & 3 deletions packages/table/module/custom/hook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,10 @@ VxeUI.hooks.add('tableCustomModule', {
const { customColumnList } = reactData
const customOpts = computeCustomOpts.value
const { allowVisible, allowSort, allowFixed, allowResizable } = customOpts
XEUtils.eachTree(customColumnList, (column, index, items, path, parent) => {
if (parent) {
XEUtils.eachTree(customColumnList, (column, index, items, path, parentColumn) => {
if (parentColumn) {
// 更新子列信息
column.fixed = parent.fixed
column.fixed = parentColumn.fixed
} else {
if (allowSort) {
const sortIndex = index + 1
Expand Down
3 changes: 2 additions & 1 deletion packages/table/src/cell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,7 @@ export const Cell = {
$table.triggerTreeExpandEvent(evnt, params)
}
}
console.log(row.name, hasChild)
return [
h('div', {
class: ['vxe-cell--tree-node', {
Expand All @@ -471,7 +472,7 @@ export const Cell = {
paddingLeft: `${level * indent}px`
}
}, [
showIcon && (lazy ? (isLazyLoaded ? hasChild : hasLazyChilds) : hasChild)
showIcon && (lazy ? (isLazyLoaded ? hasChild : (hasChild || hasLazyChilds)) : hasChild)
? [
h('div', {
class: 'vxe-tree--btn-wrapper',
Expand Down
66 changes: 49 additions & 17 deletions packages/table/src/table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1122,6 +1122,8 @@ export default defineComponent({
const columnOpts = computeColumnOpts.value
const columnDragOpts = computeColumnDragOpts.value
const { isCrossDrag, isSelfToChildDrag } = columnDragOpts
const customOpts = computeCustomOpts.value
const { storage } = customOpts
const rowOpts = computeRowOpts.value
const isGroup = collectColumn.some(hasChildrenList)
let isAllOverflow = !!props.showOverflow
Expand All @@ -1140,8 +1142,8 @@ export default defineComponent({
}
fullColumnFieldData[field] = rest
} else {
if (isCrossDrag || isSelfToChildDrag) {
errLog('vxe.error.emptyProp', ['column.field'])
if (storage || isCrossDrag || isSelfToChildDrag) {
errLog('vxe.error.reqProp', [`${column.getTitle() || type || ''} -> column.field`])
}
}
if (!hasFixed && fixed) {
Expand Down Expand Up @@ -5424,7 +5426,7 @@ export default defineComponent({
}
let hasResizable = 0
let hasSort = 0
let hasFixedt = 0
let hasFixed = 0
let hasVisible = 0
XEUtils.eachTree(collectColumn, (column, index, items, path, parentColumn) => {
// 只支持一级
Expand All @@ -5439,7 +5441,7 @@ export default defineComponent({
if (column.fixed !== column.defaultFixed) {
const colKey = column.getKey()
if (colKey) {
hasFixedt = 1
hasFixed = 1
fixedData[colKey] = column.fixed
}
}
Expand Down Expand Up @@ -5473,7 +5475,7 @@ export default defineComponent({
if (hasSort) {
storeData.sortData = sortData
}
if (hasFixedt) {
if (hasFixed) {
storeData.fixedData = fixedData
}
if (hasVisible) {
Expand Down Expand Up @@ -7380,22 +7382,21 @@ export default defineComponent({
evnt.dataTransfer.setDragImage(getTpImg(), 0, 0)
}
},
handleRowDragDragendEvent (evnt) {
handleRowDragSwapEvent (evnt, isSyncRow, dragRow, prevDragRow, prevDragPos, prevDragToChild) {
const { treeConfig, dragConfig } = props
const rowDragOpts = computeRowDragOpts.value
const { fullAllDataRowIdData, prevDragToChild } = internalData
const { fullAllDataRowIdData } = internalData
const { isPeerDrag, isCrossDrag, isSelfToChildDrag, dragEndMethod } = rowDragOpts
const treeOpts = computeTreeOpts.value
const { transform, rowField, mapChildrenField, parentField } = treeOpts
const childrenField = treeOpts.children || treeOpts.childrenField
const { dragRow } = reactData
const { afterFullData, tableFullData, prevDragRow, prevDragPos } = internalData
const { afterFullData, tableFullData } = internalData
const dEndMethod = dragEndMethod || (dragConfig ? dragConfig.dragEndMethod : null)
const dragOffsetIndex = prevDragPos === 'bottom' ? 1 : 0
if (prevDragRow && dragRow) {
// 判断是否有拖动
if (prevDragRow !== dragRow) {
Promise.resolve(
return Promise.resolve(
dEndMethod
? dEndMethod({
oldRow: dragRow,
Expand All @@ -7420,6 +7421,7 @@ export default defineComponent({
const oldRest = fullAllDataRowIdData[oldRowid]
const newRowid = getRowid($xeTable, prevDragRow)
const newRest = fullAllDataRowIdData[newRowid]

if (oldRest && newRest) {
const { level: oldLevel } = oldRest
const { level: newLevel } = newRest
Expand Down Expand Up @@ -7557,6 +7559,32 @@ export default defineComponent({
})
}
}
return Promise.resolve()
},
handleRowDragDragendEvent (evnt) {
const { treeConfig } = props
const { fullAllDataRowIdData, prevDragToChild } = internalData
const { dragRow } = reactData
const treeOpts = computeTreeOpts.value
const { lazy } = treeOpts
const hasChildField = treeOpts.hasChild || treeOpts.hasChildField
const { prevDragRow, prevDragPos } = internalData
if (treeConfig && prevDragToChild) {
// 懒加载
if (lazy) {
const newRowid = getRowid($xeTable, prevDragRow)
const rowRest = fullAllDataRowIdData[newRowid]
if (prevDragRow[hasChildField]) {
if (rowRest && rowRest.treeLoaded) {
$xeTable.handleRowDragSwapEvent(evnt, true, dragRow, prevDragRow, prevDragPos, prevDragToChild)
}
} else {
$xeTable.handleRowDragSwapEvent(evnt, true, dragRow, prevDragRow, prevDragPos, prevDragToChild)
}
}
} else {
$xeTable.handleRowDragSwapEvent(evnt, true, dragRow, prevDragRow, prevDragPos, prevDragToChild)
}
hideDropTip()
clearRowDropOrigin()
internalData.prevDragToChild = false
Expand All @@ -7571,7 +7599,8 @@ export default defineComponent({
const { fullAllDataRowIdData } = internalData
const { dragRow } = reactData
const treeOpts = computeTreeOpts.value
const { transform, parentField } = treeOpts
const { lazy, transform, parentField } = treeOpts
const hasChildField = treeOpts.hasChild || treeOpts.hasChildField
const rowDragOpts = computeRowDragOpts.value
const { isPeerDrag, isCrossDrag, isToChildDrag } = rowDragOpts
if (!dragRow) {
Expand All @@ -7584,19 +7613,22 @@ export default defineComponent({
const rest = fullAllDataRowIdData[rowid]
if (rest) {
const row = rest.row
const rowid = getRowid($xeTable, row)
const rowRest = fullAllDataRowIdData[rowid]
evnt.preventDefault()
const { dragRow } = reactData
const offsetY = evnt.clientY - trEl.getBoundingClientRect().y
const dragPos = offsetY < trEl.clientHeight / 2 ? 'top' : 'bottom'
internalData.prevDragToChild = !!(treeConfig && transform && (isCrossDrag && isToChildDrag) && hasCtrlKey)
internalData.prevDragRow = row
internalData.prevDragPos = dragPos
if ($xeTable.eqRow(dragRow, row) ||
(hasCtrlKey && treeConfig && lazy && row[hasChildField] && rowRest && !rowRest.treeLoaded) ||
(!isCrossDrag && treeConfig && transform && (isPeerDrag ? dragRow[parentField] !== row[parentField] : rest.level))
) {
showDropTip(evnt, trEl, null, false, dragPos)
return
}
internalData.prevDragToChild = !!(treeConfig && transform && (isCrossDrag && isToChildDrag) && hasCtrlKey)
internalData.prevDragRow = row
internalData.prevDragPos = dragPos
showDropTip(evnt, trEl, null, true, dragPos)
dispatchEvent('row-dragover', {
oldRow: dragRow,
Expand Down Expand Up @@ -7849,16 +7881,16 @@ export default defineComponent({
const { clientX } = evnt
const offsetX = clientX - thEl.getBoundingClientRect().x
const dragPos = offsetX < thEl.clientWidth / 2 ? 'left' : 'right'
internalData.prevDragToChild = !!((isCrossDrag && isToChildDrag) && hasCtrlKey)
internalData.prevDragCol = column
internalData.prevDragPos = dragPos
if (column.fixed ||
(dragCol && dragCol.id === column.id) ||
(!isCrossDrag && (isPeerDrag ? dragCol.parentId !== column.parentId : column.parentId))
) {
showDropTip(evnt, null, thEl, false, dragPos)
return
}
internalData.prevDragToChild = !!((isCrossDrag && isToChildDrag) && hasCtrlKey)
internalData.prevDragCol = column
internalData.prevDragPos = dragPos
showDropTip(evnt, null, thEl, true, dragPos)
dispatchEvent('column-dragover', {
oldColumn: dragCol,
Expand Down

0 comments on commit a34a3b9

Please sign in to comment.