Skip to content

Commit

Permalink
releases 4.9.21
Browse files Browse the repository at this point in the history
  • Loading branch information
xuliangzhan committed Dec 11, 2024
1 parent 3554208 commit 995fc61
Show file tree
Hide file tree
Showing 10 changed files with 113 additions and 29 deletions.
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.9.20",
"version": "4.9.21",
"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.24"
"vxe-pc-ui": "^4.3.26"
},
"devDependencies": {
"@types/resize-observer-browser": "^0.1.11",
Expand Down
2 changes: 1 addition & 1 deletion packages/grid/src/grid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const { getConfig, getI18n, commands, hooks, useFns, createEvent, globalEvents,

const tableComponentPropKeys = Object.keys(tableComponentProps as any)

const tableComponentMethodKeys: (keyof VxeTableMethods)[] = ['clearAll', 'syncData', 'updateData', 'loadData', 'reloadData', 'reloadRow', 'loadColumn', 'reloadColumn', 'getRowNode', 'getColumnNode', 'getRowIndex', 'getVTRowIndex', 'getVMRowIndex', 'getColumnIndex', 'getVTColumnIndex', 'getVMColumnIndex', 'setRow', 'createData', 'createRow', 'revertData', 'clearData', 'isInsertByRow', 'isUpdateByRow', 'getColumns', 'getColumnById', 'getColumnByField', 'getTableColumn', 'getFullColumns', 'getData', 'getCheckboxRecords', 'getParentRow', 'getTreeParentRow', 'getRowSeq', 'getRowById', 'getRowid', 'getTableData', 'getFullData', 'setColumnFixed', 'clearColumnFixed', 'setColumnWidth', 'getColumnWidth', 'hideColumn', 'showColumn', 'resetColumn', 'refreshColumn', 'refreshScroll', 'recalculate', 'closeTooltip', 'isAllCheckboxChecked', 'isAllCheckboxIndeterminate', 'getCheckboxIndeterminateRecords', 'setCheckboxRow', 'isCheckedByCheckboxRow', 'isIndeterminateByCheckboxRow', 'toggleCheckboxRow', 'setAllCheckboxRow', 'getRadioReserveRecord', 'clearRadioReserve', 'getCheckboxReserveRecords', 'clearCheckboxReserve', 'toggleAllCheckboxRow', 'clearCheckboxRow', 'setCurrentRow', 'isCheckedByRadioRow', 'setRadioRow', 'clearCurrentRow', 'clearRadioRow', 'getCurrentRecord', 'getRadioRecord', 'getCurrentColumn', 'setCurrentColumn', 'clearCurrentColumn', 'setPendingRow', 'togglePendingRow', 'getPendingRecords', 'clearPendingRow', 'sort', 'clearSort', 'isSort', 'getSortColumns', 'closeFilter', 'isFilter', 'isActiveFilterByColumn', 'isRowExpandLoaded', 'clearRowExpandLoaded', 'reloadRowExpand', 'reloadRowExpand', 'toggleRowExpand', 'setAllRowExpand', 'setRowExpand', 'isExpandByRow', 'isRowExpandByRow', 'clearRowExpand', 'clearRowExpandReserve', 'getRowExpandRecords', 'getTreeExpandRecords', 'isTreeExpandLoaded', 'clearTreeExpandLoaded', 'reloadTreeExpand', 'reloadTreeChilds', 'toggleTreeExpand', 'setAllTreeExpand', 'setTreeExpand', 'isTreeExpandByRow', 'clearTreeExpand', 'clearTreeExpandReserve', 'getScroll', 'scrollTo', 'scrollToRow', 'scrollToColumn', 'clearScroll', 'updateFooter', 'updateStatus', 'setMergeCells', 'removeInsertRow', 'removeMergeCells', 'getMergeCells', 'clearMergeCells', 'setMergeFooterItems', 'removeMergeFooterItems', 'getMergeFooterItems', 'clearMergeFooterItems', 'getCustomStoreData', 'openTooltip', 'getCellLabel', 'getCellElement', 'focus', 'blur', 'connect']
const tableComponentMethodKeys: (keyof VxeTableMethods)[] = ['clearAll', 'syncData', 'updateData', 'loadData', 'reloadData', 'reloadRow', 'loadColumn', 'reloadColumn', 'getRowNode', 'getColumnNode', 'getRowIndex', 'getVTRowIndex', 'getVMRowIndex', 'getColumnIndex', 'getVTColumnIndex', 'getVMColumnIndex', 'setRow', 'createData', 'createRow', 'revertData', 'clearData', 'isInsertByRow', 'isUpdateByRow', 'getColumns', 'getColumnById', 'getColumnByField', 'getTableColumn', 'getFullColumns', 'getData', 'getCheckboxRecords', 'getParentRow', 'getTreeParentRow', 'getRowSeq', 'getRowById', 'getRowid', 'getTableData', 'getFullData', 'setColumnFixed', 'clearColumnFixed', 'setColumnWidth', 'getColumnWidth', 'hideColumn', 'showColumn', 'resetColumn', 'refreshColumn', 'refreshScroll', 'recalculate', 'closeTooltip', 'isAllCheckboxChecked', 'isAllCheckboxIndeterminate', 'getCheckboxIndeterminateRecords', 'setCheckboxRow', 'isCheckedByCheckboxRow', 'isIndeterminateByCheckboxRow', 'toggleCheckboxRow', 'setAllCheckboxRow', 'getRadioReserveRecord', 'clearRadioReserve', 'getCheckboxReserveRecords', 'clearCheckboxReserve', 'toggleAllCheckboxRow', 'clearCheckboxRow', 'setCurrentRow', 'isCheckedByRadioRow', 'setRadioRow', 'clearCurrentRow', 'clearRadioRow', 'getCurrentRecord', 'getRadioRecord', 'getCurrentColumn', 'setCurrentColumn', 'clearCurrentColumn', 'setPendingRow', 'togglePendingRow', 'getPendingRecords', 'clearPendingRow', 'sort', 'setSort', 'clearSort', 'isSort', 'getSortColumns', 'closeFilter', 'isFilter', 'isActiveFilterByColumn', 'isRowExpandLoaded', 'clearRowExpandLoaded', 'reloadRowExpand', 'reloadRowExpand', 'toggleRowExpand', 'setAllRowExpand', 'setRowExpand', 'isExpandByRow', 'isRowExpandByRow', 'clearRowExpand', 'clearRowExpandReserve', 'getRowExpandRecords', 'getTreeExpandRecords', 'isTreeExpandLoaded', 'clearTreeExpandLoaded', 'reloadTreeExpand', 'reloadTreeChilds', 'toggleTreeExpand', 'setAllTreeExpand', 'setTreeExpand', 'isTreeExpandByRow', 'clearTreeExpand', 'clearTreeExpandReserve', 'getScroll', 'scrollTo', 'scrollToRow', 'scrollToColumn', 'clearScroll', 'updateFooter', 'updateStatus', 'setMergeCells', 'removeInsertRow', 'removeMergeCells', 'getMergeCells', 'clearMergeCells', 'setMergeFooterItems', 'removeMergeFooterItems', 'getMergeFooterItems', 'clearMergeFooterItems', 'getCustomStoreData', 'openTooltip', 'getCellLabel', 'getCellElement', 'focus', 'blur', 'connect']

const gridComponentEmits: VxeGridEmits = [
...tableComponentEmits,
Expand Down
31 changes: 19 additions & 12 deletions packages/table/module/filter/hook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,17 +174,11 @@ hooks.add('tableFilterModule', {
}
}
},
/**
* 确认筛选
* 当筛选面板中的确定按钮被按下时触发
* @param {Event} evnt 事件
*/
confirmFilterEvent (evnt: Event) {
handleColumnConfirmFilter (column, evnt) {
const { mouseConfig } = props
const { filterStore, scrollXLoad: oldScrollXLoad, scrollYLoad: oldScrollYLoad } = reactData
const { scrollXLoad: oldScrollXLoad, scrollYLoad: oldScrollYLoad } = reactData
const filterOpts = computeFilterOpts.value
const mouseOpts = computeMouseOpts.value
const { column } = filterStore
const { field } = column
const values: any[] = []
const datas: any[] = []
Expand All @@ -195,20 +189,20 @@ hooks.add('tableFilterModule', {
}
})
const filterList = $xeTable.getCheckedFilters()
const params = { $table: $xeTable, $event: evnt, column, field, property: field, values, datas, filters: filterList, filterList }
const params = { $table: $xeTable, $event: evnt as Event, column, field, property: field, values, datas, filters: filterList, filterList }
// 如果是服务端筛选,则跳过本地筛选处理
if (!filterOpts.remote) {
$xeTable.handleTableData(true)
$xeTable.checkSelectionStatus()
}
if (mouseConfig && mouseOpts.area && $xeTable.handleFilterEvent) {
$xeTable.handleFilterEvent(evnt, params)
$xeTable.handleFilterEvent(evnt as Event, params)
}
if (evnt) {
$xeTable.dispatchEvent('filter-change', params, evnt)
}
$xeTable.closeFilter()
$xeTable.updateFooter().then(() => {
return $xeTable.updateFooter().then(() => {
const { scrollXLoad, scrollYLoad } = reactData
if ((oldScrollXLoad || scrollXLoad) || (oldScrollYLoad || scrollYLoad)) {
if (oldScrollXLoad || scrollXLoad) {
Expand All @@ -227,6 +221,16 @@ hooks.add('tableFilterModule', {
setTimeout(() => $xeTable.recalculate(), 50)
})
},
/**
* 确认筛选
* 当筛选面板中的确定按钮被按下时触发
* @param {Event} evnt 事件
*/
confirmFilterEvent (evnt: Event) {
const { filterStore } = reactData
const { column } = filterStore
$xeTable.handleColumnConfirmFilter(column, evnt)
},
handleFilterChangeRadioOption: changeRadioOption,
handleFilterChangeMultipleOption: changeMultipleOption,
// 筛选发生改变
Expand Down Expand Up @@ -267,10 +271,13 @@ hooks.add('tableFilterModule', {
* @param {ColumnInfo} fieldOrColumn 列或字段名
* @param {Array} options 选项
*/
setFilter (fieldOrColumn, options) {
setFilter (fieldOrColumn, options, isUpdate) {
const column = handleFieldOrColumn($xeTable, fieldOrColumn)
if (column && column.filters) {
column.filters = toFilters(options || [])
if (isUpdate) {
return $xeTable.handleColumnConfirmFilter(column, new Event('click'))
}
}
return nextTick()
},
Expand Down
85 changes: 73 additions & 12 deletions packages/table/src/table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4555,6 +4555,50 @@ export default defineComponent({
}
return nextTick()
},
setSort (sortConfs, isUpdate) {
const sortOpts = computeSortOpts.value
const { multiple, remote, orders } = sortOpts
if (!XEUtils.isArray(sortConfs)) {
sortConfs = [sortConfs]
}
if (sortConfs && sortConfs.length) {
if (!multiple) {
sortConfs = [sortConfs[0]]
clearAllSort()
}
let firstColumn: any = null
sortConfs.forEach((confs: any, index: number) => {
let { field, order } = confs
let column = field
if (XEUtils.isString(field)) {
column = tableMethods.getColumnByField(field)
}
if (!firstColumn) {
firstColumn = column
}
if (column && column.sortable) {
if (orders.indexOf(order) === -1) {
order = getNextSortOrder(column)
}
if (column.order !== order) {
column.order = order
}
column.sortTime = Date.now() + index
}
})
if (isUpdate) {
if (!remote) {
tablePrivateMethods.handleTableData(true)
}
$xeTable.handleColumnSortEvent(new Event('click'), firstColumn)
}
return nextTick().then(() => {
tableMethods.updateCellAreas()
return updateStyle()
})
}
return nextTick()
},
/**
* 清空指定列的排序条件
* 如果为空则清空所有列的排序条件
Expand Down Expand Up @@ -5977,6 +6021,7 @@ export default defineComponent({
return
}
const { scrollbarWidth, scrollbarHeight } = reactData
const { prevDragToChild } = internalData
const wrapperRect = el.getBoundingClientRect()
if (trEl) {
const rdLineEl = refDragRowLineElem.value
Expand All @@ -5988,6 +6033,7 @@ export default defineComponent({
rdLineEl.style.height = `${trRect.height}px`
rdLineEl.style.width = `${wrapperRect.width - scrollbarWidth}px`
rdLineEl.setAttribute('drag-pos', dragPos)
rdLineEl.setAttribute('drag-to-child', prevDragToChild ? 'y' : 'n')
} else {
rdLineEl.style.display = ''
}
Expand All @@ -6012,7 +6058,7 @@ export default defineComponent({
rdTipEl.style.display = 'block'
rdTipEl.style.top = `${Math.min(el.clientHeight - el.scrollTop - rdTipEl.clientHeight, evnt.clientY - wrapperRect.y)}px`
rdTipEl.style.left = `${Math.min(el.clientWidth - el.scrollLeft - rdTipEl.clientWidth - 16, evnt.clientX - wrapperRect.x)}px`
rdTipEl.setAttribute('drag-status', showLine ? 'normal' : 'disabled')
rdTipEl.setAttribute('drag-status', showLine ? (prevDragToChild ? 'sub' : 'normal') : 'disabled')
}
}

Expand Down Expand Up @@ -7068,25 +7114,31 @@ export default defineComponent({
dispatchEvent('toggle-tree-expand', { expanded, column, columnIndex, $columnIndex, row }, evnt)
}
},
handleColumnSortEvent (evnt, column) {
const { mouseConfig } = props
const mouseOpts = computeMouseOpts.value
const { field, sortable } = column
if (sortable) {
const params = { $table: $xeTable, $event: evnt, column, field, property: field, order: column.order, sortList: tableMethods.getSortColumns(), sortTime: column.sortTime }
if (mouseConfig && mouseOpts.area && $xeTable.handleSortEvent) {
$xeTable.handleSortEvent(evnt, params)
}
dispatchEvent('sort-change', params, evnt)
}
},
/**
* 点击排序事件
*/
triggerSortEvent (evnt, column, order) {
const { mouseConfig } = props
const sortOpts = computeSortOpts.value
const mouseOpts = computeMouseOpts.value
const { field, sortable } = column
if (sortable) {
if (!order || column.order === order) {
tableMethods.clearSort(sortOpts.multiple ? column : null)
} else {
tableMethods.sort({ field, order })
}
const params = { $table: $xeTable, $event: evnt, column, field, property: field, order: column.order, sortList: tableMethods.getSortColumns(), sortTime: column.sortTime }
if (mouseConfig && mouseOpts.area && $xeTable.handleSortEvent) {
$xeTable.handleSortEvent(evnt, params)
}
dispatchEvent('sort-change', params, evnt)
$xeTable.handleColumnSortEvent(evnt, column)
}
},
/**
Expand All @@ -7101,15 +7153,16 @@ export default defineComponent({
handleRowDragDragendEvent (evnt) {
const { treeConfig, dragConfig } = props
const rowDragOpts = computeRowDragOpts.value
const { fullAllDataRowIdData } = internalData
const { fullAllDataRowIdData, prevDragToChild } = internalData
const { isCrossDrag, isSelfToChildDrag, dragEndMethod } = rowDragOpts
const treeOpts = computeTreeOpts.value
const { transform, mapChildrenField, parentField } = treeOpts
const { transform, rowField, mapChildrenField, parentField } = treeOpts
const childrenField = treeOpts.children || treeOpts.childrenField
const { dragRow } = reactData
const { afterFullData, tableFullData, prevDragRow, prevDragPos } = internalData
const dEndMethod = dragEndMethod || (dragConfig ? dragConfig.dragEndMethod : null)
const dragOffsetIndex = prevDragPos === 'bottom' ? 1 : 0
console.log(evnt.ctrlKey)
if (prevDragRow && dragRow) {
// 判断是否有拖动
if (prevDragRow !== dragRow) {
Expand Down Expand Up @@ -7211,7 +7264,7 @@ export default defineComponent({
childRow[parentField] = dragRow[parentField]
})
}
dragRow[parentField] = prevDragRow[parentField]
dragRow[parentField] = prevDragToChild ? prevDragRow[rowField] : prevDragRow[parentField]

internalData.tableFullTreeData = XEUtils.toArrayTree(fullList, {
key: treeOpts.rowField,
Expand Down Expand Up @@ -7278,12 +7331,15 @@ export default defineComponent({
const { treeConfig } = props
const { fullAllDataRowIdData } = internalData
const { dragRow } = reactData
const treeOpts = computeTreeOpts.value
const { transform } = treeOpts
const rowDragOpts = computeRowDragOpts.value
const { isCrossDrag } = rowDragOpts
const { isCrossDrag, isToChildDrag } = rowDragOpts
if (!dragRow) {
evnt.preventDefault()
return
}
const hasCtrlKey = evnt.ctrlKey
const trEl = evnt.currentTarget as HTMLElement
const rowid = trEl.getAttribute('rowid') || ''
const rest = fullAllDataRowIdData[rowid]
Expand All @@ -7297,6 +7353,7 @@ export default defineComponent({
showDropTip(evnt, trEl, null, false, dragPos)
return
}
internalData.prevDragToChild = !!(treeConfig && transform && isToChildDrag && hasCtrlKey)
internalData.prevDragRow = row
internalData.prevDragPos = dragPos
showDropTip(evnt, trEl, null, true, dragPos)
Expand Down Expand Up @@ -7451,6 +7508,7 @@ export default defineComponent({
showDropTip(evnt, null, thEl, false, dragPos)
return
}
internalData.prevDragToChild = false
internalData.prevDragCol = column
internalData.prevDragPos = dragPos
showDropTip(evnt, null, thEl, true, dragPos)
Expand Down Expand Up @@ -7956,6 +8014,9 @@ export default defineComponent({
h('span', {
class: ['vxe-table--drag-sort-tip-normal-status', dragRow ? getIcon().TABLE_DRAG_STATUS_ROW : getIcon().TABLE_DRAG_STATUS_COLUMN]
}),
h('span', {
class: ['vxe-table--drag-sort-tip-sub-status', getIcon().TABLE_DRAG_STATUS_SUB_ROW]
}),
h('span', {
class: ['vxe-table--drag-sort-tip-disabled-status', getIcon().TABLE_DRAG_DISABLED]
})
Expand Down
1 change: 1 addition & 0 deletions packages/ui/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@ VxeUI.setIcon({
TABLE_DRAG_ROW: iconPrefix + 'drag-handle',
TABLE_DRAG_COLUMN: iconPrefix + 'drag-handle',
TABLE_DRAG_STATUS_ROW: iconPrefix + 'sort',
TABLE_DRAG_STATUS_SUB_ROW: iconPrefix + 'add-sub',
TABLE_DRAG_STATUS_COLUMN: iconPrefix + 'swap',
TABLE_DRAG_DISABLED: iconPrefix + 'no-drop',

Expand Down
Loading

0 comments on commit 995fc61

Please sign in to comment.