Skip to content

Commit 4315654

Browse files
committed
releases 4.12.0
1 parent e72bc0f commit 4315654

File tree

14 files changed

+69
-36
lines changed

14 files changed

+69
-36
lines changed

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vxe-table",
3-
"version": "4.12.0-beta.26",
3+
"version": "4.12.0",
44
"description": "一个基于 vue 的 PC 端表格组件,支持增删改查、虚拟树、拖拽排序,懒加载、快捷菜单、数据校验、树形结构、打印、导入导出、自定义模板、渲染器、JSON 配置式...",
55
"scripts": {
66
"update": "npm install --legacy-peer-deps",
@@ -28,7 +28,7 @@
2828
"style": "lib/style.css",
2929
"typings": "types/index.d.ts",
3030
"dependencies": {
31-
"vxe-pc-ui": "^4.4.23"
31+
"vxe-pc-ui": "^4.4.26"
3232
},
3333
"devDependencies": {
3434
"@types/resize-observer-browser": "^0.1.11",

packages/table/module/custom/hook.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ VxeUI.hooks.add('tableCustomModule', {
1212
const { computeCustomOpts } = $xeTable.getComputeMaps()
1313
const { refElem } = $xeTable.getRefMaps()
1414

15-
const $xeGrid = $xeTable.xegrid
15+
const $xeGrid = $xeTable.xeGrid
1616

1717
const calcMaxHeight = () => {
1818
const { customStore } = reactData

packages/table/module/custom/panel.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -508,6 +508,8 @@ export default defineComponent({
508508
}
509509

510510
const renderSimplePanel = () => {
511+
const $xeGrid = $xeTable.xeGrid
512+
511513
const { customStore } = props
512514
const { isCustomStatus, customColumnList } = reactData
513515
const customOpts = computeCustomOpts.value
@@ -534,7 +536,7 @@ export default defineComponent({
534536
}
535537
const params = {
536538
$table: $xeTable,
537-
$grid: $xeTable.xegrid,
539+
$grid: $xeGrid,
538540
columns: customColumnList,
539541
isAllChecked,
540542
isAllIndeterminate,
@@ -774,6 +776,8 @@ export default defineComponent({
774776
}
775777

776778
const renderPopupPanel = () => {
779+
const $xeGrid = $xeTable.xeGrid
780+
777781
const { customStore } = props
778782
const { resizable: allResizable } = tableProps
779783
const { isCustomStatus, customColumnList } = reactData
@@ -800,7 +804,7 @@ export default defineComponent({
800804
const isAllIndeterminate = customStore.isIndeterminate
801805
const params = {
802806
$table: $xeTable,
803-
$grid: $xeTable.xegrid,
807+
$grid: $xeGrid,
804808
columns: customColumnList,
805809
isAllChecked,
806810
isAllIndeterminate,

packages/table/module/edit/hook.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,8 @@ hooks.add('tableEditModule', {
324324
}
325325

326326
const handleEditActive = (params: any, evnt: Event | null, isFocus: boolean, isPos: boolean) => {
327+
const $xeGrid = $xeTable.xeGrid
328+
327329
const { editConfig, mouseConfig } = props
328330
const { editStore, tableColumn } = reactData
329331
const editOpts = computeEditOpts.value
@@ -340,7 +342,7 @@ hooks.add('tableEditModule', {
340342
if (actived.row !== row || (mode === 'cell' ? actived.column !== column : false)) {
341343
// 判断是否禁用编辑
342344
let type: 'edit-disabled' | 'edit-activated' = 'edit-disabled'
343-
if (!beforeEditMethod || beforeEditMethod({ ...params, $table: $xeTable, $grid: $xeTable.xegrid })) {
345+
if (!beforeEditMethod || beforeEditMethod({ ...params, $table: $xeTable, $grid: $xeGrid })) {
344346
if (mouseConfig) {
345347
$xeTable.clearSelected()
346348
if ($xeTable.clearCellAreas) {
@@ -368,7 +370,7 @@ hooks.add('tableEditModule', {
368370
$xeTable.handleFocus(params, evnt)
369371
}
370372
if (afterEditMethod) {
371-
afterEditMethod({ ...params, $table: $xeTable, $grid: $xeTable.xegrid })
373+
afterEditMethod({ ...params, $table: $xeTable, $grid: $xeGrid })
372374
}
373375
})
374376
}

packages/table/module/export/export-panel.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,8 @@ export default defineComponent({
162162
}
163163

164164
const renderVN = () => {
165+
const $xeGrid = $xeTable.xeGrid
166+
165167
const { defaultOptions, storeData } = props
166168
const { isAll: isAllChecked, isIndeterminate: isAllIndeterminate } = reactData
167169
const { hasTree, hasMerge, isPrint, hasColgroup, columns } = storeData
@@ -242,7 +244,7 @@ export default defineComponent({
242244
default: () => {
243245
const params = {
244246
$table: $xeTable,
245-
$grid: $xeTable.xegrid,
247+
$grid: $xeGrid,
246248
options: defaultOptions,
247249
columns,
248250
params: defaultOptions.params as any
@@ -487,7 +489,7 @@ export default defineComponent({
487489
footer () {
488490
const params = {
489491
$table: $xeTable,
490-
$grid: $xeTable.xegrid,
492+
$grid: $xeGrid,
491493
options: defaultOptions,
492494
columns,
493495
params: defaultOptions.params as any

packages/table/module/export/import-panel.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,8 @@ export default defineComponent({
9393
}
9494

9595
const renderVN = () => {
96+
const $xeGrid = $xeTable.xeGrid
97+
9698
const { defaultOptions, storeData } = props
9799
const selectName = computeSelectName.value
98100
const hasFile = computeHasFile.value
@@ -127,7 +129,7 @@ export default defineComponent({
127129
default: () => {
128130
const params = {
129131
$table: $xeTable,
130-
$grid: $xeTable.xegrid,
132+
$grid: $xeGrid,
131133
options: defaultOptions,
132134
params: defaultOptions.params as any
133135
}
@@ -204,7 +206,7 @@ export default defineComponent({
204206
footer () {
205207
const params = {
206208
$table: $xeTable,
207-
$grid: $xeTable.xegrid,
209+
$grid: $xeGrid,
208210
options: defaultOptions,
209211
params: defaultOptions.params as any
210212
}

packages/table/module/menu/hook.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -279,10 +279,12 @@ hooks.add('tableMenuModule', {
279279
* 快捷菜单点击事件
280280
*/
281281
ctxMenuLinkEvent (evnt, menu) {
282+
const $xeGrid = $xeTable.xeGrid
283+
282284
// 如果一级菜单有配置 code 则允许点击,否则不能点击
283285
if (!menu.disabled && (menu.code || !menu.children || !menu.children.length)) {
284286
const gMenuOpts = menus.get(menu.code)
285-
const params = Object.assign({}, internalData._currMenuParams, { menu, $table: $xeTable, $grid: $xeTable.xegrid, $event: evnt })
287+
const params = Object.assign({}, internalData._currMenuParams, { menu, $table: $xeTable, $grid: $xeGrid, $event: evnt })
286288
const tmMethod = gMenuOpts ? (gMenuOpts.tableMenuMethod || gMenuOpts.menuMethod) : null
287289
if (tmMethod) {
288290
tmMethod(params, evnt)

packages/table/module/validator/hook.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,8 @@ hooks.add('tableValidatorModule', {
382382
* trigger=blur|change 触发方式(除非特殊场景,否则默认为空就行)
383383
*/
384384
validCellRules (validType, row, column, val) {
385+
const $xeGrid = $xeTable.xeGrid
386+
385387
const { editRules } = props
386388
const { field } = column
387389
const errorRules: Rule[] = []
@@ -404,7 +406,7 @@ hooks.add('tableValidatorModule', {
404406
columnIndex: $xeTable.getColumnIndex(column),
405407
field: column.field,
406408
$table: $xeTable,
407-
$grid: $xeTable.xegrid
409+
$grid: $xeGrid
408410
}
409411
let customValid: any
410412
if (XEUtils.isString(validator)) {

packages/table/src/body.ts

+15-8
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,9 @@ export default defineComponent({
101101
columns: VxeTableDefines.ColumnInfo[],
102102
items: any[]
103103
) => {
104-
const { fullAllDataRowIdData, visibleColumn } = tableInternalData
104+
const $xeGrid = $xeTable.xeGrid
105+
106+
const { fullAllDataRowIdData, fullColumnIdData, visibleColumn } = tableInternalData
105107
const { columnKey, resizable: allResizable, showOverflow: allShowOverflow, border, height, cellClassName: allCellClassName, cellStyle, align: allAlign, spanMethod, mouseConfig, editConfig, editRules, tooltipConfig, padding: allPadding } = tableProps
106108
const { tableData, dragRow, overflowX, currentColumn, scrollXLoad, scrollYLoad, calcCellHeightFlag, resizeHeightFlag, resizeWidthFlag, mergeList, editStore, isAllOverflow, validErrorMaps } = tableReactData
107109
const { afterFullData, scrollXStore, scrollYStore } = tableInternalData
@@ -125,15 +127,16 @@ export default defineComponent({
125127
const { type, cellRender, editRender, align, showOverflow, className, treeNode, rowResize, padding, verticalAlign, slots } = column
126128
const { verticalAlign: allVerticalAlign } = cellOpts
127129
const { actived } = editStore
128-
const rowRest = fullAllDataRowIdData[rowid]
130+
const rowRest = fullAllDataRowIdData[rowid] || {}
129131
const colid = column.id
132+
const colRest = fullColumnIdData[colid] || {}
130133
const renderOpts = editRender || cellRender
131134
const compConf = renderOpts ? renderer.get(renderOpts.name) : null
132135
const compCellClassName = compConf ? (compConf.tableCellClassName || compConf.cellClassName) : null
133136
const compCellStyle = compConf ? (compConf.tableCellStyle || compConf.cellStyle) : ''
134137
const showAllTip = tooltipOpts.showAll
135-
const columnIndex = $xeTable.getColumnIndex(column)
136-
const _columnIndex = $xeTable.getVTColumnIndex(column)
138+
const columnIndex = colRest.index
139+
const _columnIndex = colRest._index
137140
const isEdit = isEnableConf(editRender)
138141
const resizeHeight = resizeHeightFlag ? rowRest.resizeHeight : 0
139142
let fixedHiddenColumn = fixedType ? column.fixed !== fixedType : column.fixed && overflowX
@@ -157,7 +160,7 @@ export default defineComponent({
157160
$table: VxeTableConstructor<any> & VxeTablePrivateMethods
158161
} = {
159162
$table: $xeTable,
160-
$grid: $xeTable.xegrid,
163+
$grid: $xeGrid,
161164
isEdit: false,
162165
seq,
163166
rowid,
@@ -482,7 +485,7 @@ export default defineComponent({
482485
}
483486
}
484487
const rowid = handleGetRowId(row)
485-
const rowRest = fullAllDataRowIdData[rowid]
488+
const rowRest = fullAllDataRowIdData[rowid] || {}
486489
let rowLevel = 0
487490
let seq: string | number = -1
488491
let _rowIndex = 0
@@ -652,6 +655,7 @@ export default defineComponent({
652655

653656
const renderVN = () => {
654657
const { slots } = tableContext
658+
const $xeGrid = $xeTable.xeGrid
655659

656660
const { fixedColumn, fixedType, tableColumn } = props
657661
const { spanMethod, footerSpanMethod, mouseConfig } = tableProps
@@ -736,7 +740,7 @@ export default defineComponent({
736740
let emptyContent: string | VxeComponentSlotType | VxeComponentSlotType[]
737741
const emptySlot = slots ? slots.empty : null
738742
if (emptySlot) {
739-
emptyContent = $xeTable.callSlot(emptySlot, { $table: $xeTable, $grid: $xeTable.xegrid })
743+
emptyContent = $xeTable.callSlot(emptySlot, { $table: $xeTable, $grid: $xeGrid })
740744
} else {
741745
const compConf = emptyOpts.name ? renderer.get(emptyOpts.name) : null
742746
const rtEmptyView = compConf ? (compConf.renderTableEmpty || compConf.renderTableEmptyView || compConf.renderEmpty) : null
@@ -789,7 +793,10 @@ export default defineComponent({
789793
}, renderColumnList.map((column, $columnIndex) => {
790794
return h('col', {
791795
name: column.id,
792-
key: $columnIndex
796+
key: $columnIndex,
797+
style: {
798+
width: `${column.renderWidth}px`
799+
}
793800
})
794801
})),
795802
/**

packages/table/src/columnInfo.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,11 @@ const { getI18n, formats } = VxeUI
1010
export class ColumnInfo {
1111
/* eslint-disable @typescript-eslint/no-use-before-define */
1212
constructor ($xeTable: VxeTableConstructor & VxeTablePrivateMethods, _vm: any, { renderHeader, renderCell, renderFooter, renderData }: any = {}) {
13-
const $xeGrid = $xeTable.xegrid
13+
const tableProps = $xeTable.props
14+
const $xeGrid = $xeTable.xeGrid
15+
1416
const formatter: string | any[] = _vm.formatter
1517
const visible = XEUtils.isBoolean(_vm.visible) ? _vm.visible : true
16-
const { props: tableProps } = $xeTable
1718

1819
const types = ['seq', 'checkbox', 'radio', 'expand', 'html']
1920
if (_vm.type && types.indexOf(_vm.type) === -1) {

packages/table/src/footer.ts

+11-5
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,12 @@ export default defineComponent({
5858
const refFooterXSpace = ref() as Ref<HTMLDivElement>
5959

6060
const renderRows = (tableColumn: VxeTableDefines.ColumnInfo[], footerTableData: any[], row: any, $rowIndex: number, _rowIndex: number) => {
61+
const $xeGrid = $xeTable.xeGrid
62+
6163
const { fixedType } = props
6264
const { resizable: allResizable, border, footerCellClassName, footerCellStyle, footerAlign: allFooterAlign, footerSpanMethod, align: allAlign, columnKey, showFooterOverflow: allColumnFooterOverflow } = tableProps
6365
const { scrollXLoad, scrollYLoad, overflowX, currentColumn, mergeFooterList } = tableReactData
64-
const { scrollXStore } = tableInternalData
66+
const { fullColumnIdData, scrollXStore } = tableInternalData
6567
const tooltipOpts = computeTooltipOpts.value
6668
const resizableOpts = computeResizableOpts.value
6769
const { isAllColumnDrag } = resizableOpts
@@ -74,6 +76,7 @@ export default defineComponent({
7476
return tableColumn.map((column, $columnIndex) => {
7577
const { type, showFooterOverflow, footerAlign, align, footerClassName, editRender, cellRender } = column
7678
const colid = column.id
79+
const colRest = fullColumnIdData[colid] || {}
7780
const renderOpts = editRender || cellRender
7881
const compConf = renderOpts ? renderer.get(renderOpts.name) : null
7982
const showAllTip = tooltipOpts.showAll
@@ -89,14 +92,14 @@ export default defineComponent({
8992
const showResizable = (XEUtils.isBoolean(column.resizable) ? column.resizable : (columnOpts.resizable || allResizable))
9093
const attrs: any = { colid }
9194
const tfOns: any = {}
92-
const columnIndex = $xeTable.getColumnIndex(column)
93-
const _columnIndex = $xeTable.getVTColumnIndex(column)
95+
const columnIndex = colRest.index
96+
const _columnIndex = colRest._index
9497
const itemIndex = _columnIndex
9598
const cellParams: VxeTableDefines.CellRenderFooterParams & {
9699
$table: VxeTableConstructor<any> & VxeTablePrivateMethods
97100
} = {
98101
$table: $xeTable,
99-
$grid: $xeTable.xegrid,
102+
$grid: $xeGrid,
100103
row,
101104
rowIndex: _rowIndex,
102105
_rowIndex,
@@ -354,7 +357,10 @@ export default defineComponent({
354357
}, renderColumnList.map((column, $columnIndex) => {
355358
return h('col', {
356359
name: column.id,
357-
key: $columnIndex
360+
key: $columnIndex,
361+
style: {
362+
width: `${column.renderWidth}px`
363+
}
358364
})
359365
})),
360366
/**

packages/table/src/header.ts

+11-5
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,12 @@ export default defineComponent({
4343
}
4444

4545
const renderRows = (isGroup: boolean, isOptimizeMode: boolean, cols: VxeTableDefines.ColumnInfo[], $rowIndex: number) => {
46+
const $xeGrid = $xeTable.xeGrid
47+
4648
const { fixedType } = props
4749
const { resizable: allResizable, columnKey, headerCellClassName, headerCellStyle, showHeaderOverflow: allColumnHeaderOverflow, headerAlign: allHeaderAlign, align: allAlign, mouseConfig } = tableProps
4850
const { currentColumn, dragCol, scrollXLoad, scrollYLoad, overflowX } = tableReactData
49-
const { scrollXStore } = tableInternalData
51+
const { fullColumnIdData, scrollXStore } = tableInternalData
5052
const columnOpts = computeColumnOpts.value
5153
const columnDragOpts = computeColumnDragOpts.value
5254
const cellOpts = computeCellOpts.value
@@ -57,6 +59,7 @@ export default defineComponent({
5759
return cols.map((column, $columnIndex) => {
5860
const { type, showHeaderOverflow, headerAlign, align, filters, headerClassName, editRender, cellRender } = column
5961
const colid = column.id
62+
const colRest = fullColumnIdData[colid] || {}
6063
const renderOpts = editRender || cellRender
6164
const compConf = renderOpts ? renderer.get(renderOpts.name) : null
6265
const isColGroup = column.children && column.children.length
@@ -74,11 +77,11 @@ export default defineComponent({
7477
firstFilterOption = filters[0]
7578
hasFilter = filters.some((item) => item.checked)
7679
}
77-
const columnIndex = $xeTable.getColumnIndex(column)
78-
const _columnIndex = $xeTable.getVTColumnIndex(column)
80+
const columnIndex = colRest.index
81+
const _columnIndex = colRest._index
7982
const cellParams: VxeTableDefines.CellRenderHeaderParams & {
8083
$table: VxeTableConstructor & VxeTablePrivateMethods
81-
} = { $table: $xeTable, $grid: $xeTable.xegrid, $rowIndex, column, columnIndex, $columnIndex, _columnIndex, firstFilterOption, fixed: fixedType, type: renderType, isHidden: fixedHiddenColumn, hasFilter }
84+
} = { $table: $xeTable, $grid: $xeGrid, $rowIndex, column, columnIndex, $columnIndex, _columnIndex, firstFilterOption, fixed: fixedType, type: renderType, isHidden: fixedHiddenColumn, hasFilter }
8285
const thAttrs: Record<string, string | number | null> = {
8386
colid,
8487
colspan: column.colSpan > 1 ? column.colSpan : null,
@@ -317,7 +320,10 @@ export default defineComponent({
317320
}, renderColumnList.map((column, $columnIndex) => {
318321
return h('col', {
319322
name: column.id,
320-
key: $columnIndex
323+
key: $columnIndex,
324+
style: {
325+
width: `${column.renderWidth}px`
326+
}
321327
})
322328
})),
323329
/**

packages/table/src/table.ts

+1-3
Original file line numberDiff line numberDiff line change
@@ -3285,9 +3285,7 @@ export default defineComponent({
32853285
const { scrollYStore } = internalData
32863286
const { preloadSize, startIndex, endIndex, offsetSize } = scrollYStore
32873287
const autoOffsetYSize = isAllOverflow ? offsetSize : offsetSize + 1
3288-
console.log('--', Date.now())
3289-
const { toVisibleIndex, visibleSize } = { toVisibleIndex: 1, visibleSize: 25 }// handleVirtualYVisible()
3290-
console.log(Date.now())
3288+
const { toVisibleIndex, visibleSize } = handleVirtualYVisible()
32913289
const offsetItem = {
32923290
startIndex: Math.max(0, isScrollYBig ? toVisibleIndex - 1 : toVisibleIndex - 1 - offsetSize - preloadSize),
32933291
endIndex: isScrollYBig ? (toVisibleIndex + visibleSize) : (toVisibleIndex + visibleSize + autoOffsetYSize + preloadSize)

packages/table/src/util.ts

+1
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,7 @@ export function destroyColumn ($xeTable: VxeTableConstructor & VxeTablePrivateMe
388388

389389
export function getRootColumn ($xeTable: VxeTableConstructor & VxeTablePrivateMethods, column: ColumnInfo) {
390390
const { internalData } = $xeTable
391+
391392
const { fullColumnIdData } = internalData
392393
if (!column) {
393394
return null

0 commit comments

Comments
 (0)