Skip to content

Commit 26e6fb9

Browse files
committed
releases 4.13.30
1 parent 4db7a4e commit 26e6fb9

File tree

6 files changed

+167
-141
lines changed

6 files changed

+167
-141
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vxe-table",
3-
"version": "4.13.29",
3+
"version": "4.13.30",
44
"description": "一个基于 vue 的 PC 端表格组件,支持增删改查、虚拟树、拖拽排序,懒加载、快捷菜单、数据校验、树形结构、打印、导入导出、自定义模板、渲染器、JSON 配置式...",
55
"scripts": {
66
"update": "npm install --legacy-peer-deps",

packages/grid/src/grid.ts

Lines changed: 25 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1228,32 +1228,6 @@ export default defineComponent({
12281228
// }
12291229
}
12301230

1231-
// 检查插槽
1232-
if (process.env.VUE_APP_VXE_ENV === 'development') {
1233-
(gridMethods as any).loadColumn = (columns: any[]): Promise<any> => {
1234-
const $xeTable = refTable.value
1235-
XEUtils.eachTree(columns, (column) => {
1236-
if (column.slots) {
1237-
XEUtils.each(column.slots, (func) => {
1238-
if (!XEUtils.isFunction(func)) {
1239-
if (!slots[func]) {
1240-
errLog('vxe.error.notSlot', [func])
1241-
}
1242-
}
1243-
})
1244-
}
1245-
})
1246-
if ($xeTable) {
1247-
return $xeTable.loadColumn(columns)
1248-
}
1249-
return nextTick()
1250-
}
1251-
(gridMethods as any).reloadColumn = (columns: any[]): Promise<any> => {
1252-
gridExtendTableMethods.clearAll()
1253-
return (gridMethods as any).loadColumn(columns)
1254-
}
1255-
}
1256-
12571231
const gridPrivateMethods: GridPrivateMethods = {
12581232
extendTableMethods,
12591233
callSlot (slotFunc, params) {
@@ -1315,7 +1289,31 @@ export default defineComponent({
13151289
}
13161290
}
13171291

1318-
Object.assign($xeGrid, gridExtendTableMethods, gridMethods, gridPrivateMethods)
1292+
Object.assign($xeGrid, gridExtendTableMethods, gridMethods, gridPrivateMethods, {
1293+
// 检查插槽
1294+
loadColumn (columns: any[]) {
1295+
const $xeTable = refTable.value
1296+
XEUtils.eachTree(columns, (column) => {
1297+
if (column.slots) {
1298+
XEUtils.each(column.slots, (func) => {
1299+
if (!XEUtils.isFunction(func)) {
1300+
if (!slots[func]) {
1301+
errLog('vxe.error.notSlot', [func])
1302+
}
1303+
}
1304+
})
1305+
}
1306+
})
1307+
if ($xeTable) {
1308+
return $xeTable.loadColumn(columns)
1309+
}
1310+
return nextTick()
1311+
},
1312+
reloadColumn (columns: any[]) {
1313+
$xeGrid.clearAll()
1314+
return $xeGrid.loadColumn(columns)
1315+
}
1316+
})
13191317

13201318
const columnFlag = ref(0)
13211319
watch(() => props.columns ? props.columns.length : -1, () => {

packages/table/module/edit/hook.ts

Lines changed: 11 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,8 @@ hooks.add('tableEditModule', {
9292
fullDataRowIdData[rowid] = rest
9393
fullAllDataRowIdData[rowid] = rest
9494
} else {
95-
if (process.env.VUE_APP_VXE_ENV === 'development') {
96-
if (parentRowId) {
97-
warnLog('vxe.error.unableInsert')
98-
}
95+
if (parentRowId) {
96+
warnLog('vxe.error.unableInsert')
9997
}
10098
afterFullData[funcName](item)
10199
tableFullTreeData[funcName](item)
@@ -170,11 +168,9 @@ hooks.add('tableEditModule', {
170168
const parentLevel = parentRest ? parentRest.level : 0
171169
newRecords.forEach((item, i) => {
172170
const rowid = getRowid($xeTable, item)
173-
if (process.env.VUE_APP_VXE_ENV === 'development') {
174-
if (item[treeOpts.parentField]) {
175-
if (parentRow && item[treeOpts.parentField] !== parentRow[rowField]) {
176-
errLog('vxe.error.errProp', [`${treeOpts.parentField}=${item[treeOpts.parentField]}`, `${treeOpts.parentField}=${parentRow[rowField]}`])
177-
}
171+
if (item[treeOpts.parentField]) {
172+
if (parentRow && item[treeOpts.parentField] !== parentRow[rowField]) {
173+
errLog('vxe.error.errProp', [`${treeOpts.parentField}=${item[treeOpts.parentField]}`, `${treeOpts.parentField}=${parentRow[rowField]}`])
178174
}
179175
}
180176
if (parentRow) {
@@ -203,9 +199,7 @@ hooks.add('tableEditModule', {
203199
}
204200
}
205201
} else {
206-
if (process.env.VUE_APP_VXE_ENV === 'development') {
207-
warnLog('vxe.error.unableInsert')
208-
}
202+
warnLog('vxe.error.unableInsert')
209203
insertTreeRow(newRecords, true)
210204
}
211205
} else {
@@ -698,9 +692,7 @@ hooks.add('tableEditModule', {
698692
return []
699693
},
700694
getActiveRecord () {
701-
if (process.env.VUE_APP_VXE_ENV === 'development') {
702-
warnLog('vxe.error.delFunc', ['getActiveRecord', 'getEditRecord'])
703-
}
695+
warnLog('vxe.error.delFunc', ['getActiveRecord', 'getEditRecord'])
704696
return $xeTable.getEditRecord()
705697
},
706698
getEditRecord () {
@@ -726,9 +718,7 @@ hooks.add('tableEditModule', {
726718
},
727719
clearActived (row) {
728720
// 即将废弃
729-
if (process.env.VUE_APP_VXE_ENV === 'development') {
730-
warnLog('vxe.error.delFunc', ['clearActived', 'clearEdit'])
731-
}
721+
warnLog('vxe.error.delFunc', ['clearActived', 'clearEdit'])
732722
return $xeTable.clearEdit(row)
733723
},
734724
/**
@@ -749,9 +739,7 @@ hooks.add('tableEditModule', {
749739
return nextTick()
750740
},
751741
isActiveByRow (row) {
752-
if (process.env.VUE_APP_VXE_ENV === 'development') {
753-
warnLog('vxe.error.delFunc', ['isActiveByRow', 'isEditByRow'])
754-
}
742+
warnLog('vxe.error.delFunc', ['isActiveByRow', 'isEditByRow'])
755743
// 即将废弃
756744
return $xeTable.isEditByRow(row)
757745
},
@@ -764,9 +752,7 @@ hooks.add('tableEditModule', {
764752
return editStore.actived.row === row
765753
},
766754
setActiveRow (row) {
767-
if (process.env.VUE_APP_VXE_ENV === 'development') {
768-
warnLog('vxe.error.delFunc', ['setActiveRow', 'setEditRow'])
769-
}
755+
warnLog('vxe.error.delFunc', ['setActiveRow', 'setEditRow'])
770756
// 即将废弃
771757
return editMethods.setEditRow(row)
772758
},
@@ -786,9 +772,7 @@ hooks.add('tableEditModule', {
786772
return handleEditCell(row, column, isPos)
787773
},
788774
setActiveCell (row, fieldOrColumn) {
789-
if (process.env.VUE_APP_VXE_ENV === 'development') {
790-
warnLog('vxe.error.delFunc', ['setActiveCell', 'setEditCell'])
791-
}
775+
warnLog('vxe.error.delFunc', ['setActiveCell', 'setEditCell'])
792776
// 即将废弃
793777
return editMethods.setEditCell(row, fieldOrColumn)
794778
},

packages/table/module/export/hook.ts

Lines changed: 17 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ let htmlCellElem: any
1616
const csvBOM = '\ufeff'
1717
const enterSymbol = '\r\n'
1818

19-
function defaultFilterExportColumn (column: any) {
20-
return column.field || ['seq', 'checkbox', 'radio'].indexOf(column.type) > -1
19+
function defaultFilterExportColumn (column: VxeTableDefines.ColumnInfo) {
20+
return !!column.field || ['seq', 'checkbox', 'radio'].indexOf(column.type || '') > -1
2121
}
2222

2323
const getConvertColumns = (columns: any) => {
@@ -78,7 +78,7 @@ const convertToRows = (originColumns: any): any[][] => {
7878
return rows
7979
}
8080

81-
function toTableBorder (border: any) {
81+
function toTableBorder (border: VxeTablePropTypes.Border | undefined) {
8282
if (border === true) {
8383
return 'full'
8484
}
@@ -1012,7 +1012,7 @@ hooks.add('tableExportModule', {
10121012
}
10131013
return false
10141014
}
1015-
return exportOpts.original ? column.field : defaultFilterExportColumn(column)
1015+
return exportOpts.original ? !!column.field : defaultFilterExportColumn(column)
10161016
}
10171017

10181018
const handleExportAndPrint = (options: VxeTablePropTypes.ExportOpts | VxeTablePropTypes.ExportConfig, isPrint?: boolean) => {
@@ -1063,7 +1063,7 @@ hooks.add('tableExportModule', {
10631063
})
10641064
// 默认选中
10651065
XEUtils.eachTree(exportColumns, (column, index, items, path, parent) => {
1066-
const isColGroup = column.children && column.children.length
1066+
const isColGroup = column.children && column.children.length > 0
10671067
let isChecked = false
10681068
if (columns && columns.length) {
10691069
isChecked = handleFilterColumns(defOpts, column, columns)
@@ -1181,7 +1181,7 @@ hooks.add('tableExportModule', {
11811181
const customCols = columns && columns.length
11821182
? columns
11831183
: XEUtils.searchTree(collectColumn, column => {
1184-
const isColGroup = column.children && column.children.length
1184+
const isColGroup = column.children && column.children.length > 0
11851185
let isChecked = false
11861186
if (columns && columns.length) {
11871187
isChecked = handleFilterColumns(opts, column, columns)
@@ -1195,7 +1195,7 @@ hooks.add('tableExportModule', {
11951195
const handleOptions: VxeTablePropTypes.ExportHandleOptions = Object.assign({ } as { data: any[], colgroups: any[], columns: any[] }, opts, { filename: '', sheetName: '' })
11961196
// 如果设置源数据,则默认导出设置了字段的列
11971197
if (!customCols && !columnFilterMethod) {
1198-
handleOptions.columnFilterMethod = ({ column }) => {
1198+
columnFilterMethod = ({ column }) => {
11991199
if (excludeFields) {
12001200
if (XEUtils.includes(excludeFields, column.field)) {
12011201
return false
@@ -1207,8 +1207,9 @@ hooks.add('tableExportModule', {
12071207
}
12081208
return false
12091209
}
1210-
return original ? column.field : defaultFilterExportColumn(column)
1210+
return original ? !!column.field : defaultFilterExportColumn(column)
12111211
}
1212+
handleOptions.columnFilterMethod = columnFilterMethod
12121213
}
12131214
if (customCols) {
12141215
handleOptions._isCustomColumn = true
@@ -1294,10 +1295,8 @@ hooks.add('tableExportModule', {
12941295
// 检查类型,如果为自定义导出,则不需要校验类型
12951296
if (!handleOptions.exportMethod && !XEUtils.includes(XEUtils.keys(exportOpts._typeMaps), type)) {
12961297
errLog('vxe.error.notType', [type])
1297-
if (process.env.VUE_APP_VXE_ENV === 'development') {
1298-
if (['xlsx', 'pdf'].includes(type)) {
1299-
warnLog('vxe.error.reqPlugin', [4, 'plugin-export-xlsx'])
1300-
}
1298+
if (['xlsx', 'pdf'].includes(type)) {
1299+
warnLog('vxe.error.reqPlugin', [4, 'plugin-export-xlsx'])
13011300
}
13021301
const params = { status: false }
13031302
return Promise.reject(params)
@@ -1317,10 +1316,8 @@ hooks.add('tableExportModule', {
13171316
handleOptions.data = selectRecords
13181317
}
13191318
} else if (mode === 'all') {
1320-
if (process.env.VUE_APP_VXE_ENV === 'development') {
1321-
if (!$xeGrid) {
1322-
warnLog('vxe.error.errProp', ['all', 'mode=current,selected'])
1323-
}
1319+
if (!$xeGrid) {
1320+
errLog('vxe.error.errProp', ['all', 'mode=current,selected'])
13241321
}
13251322

13261323
if ($xeGrid && !handleOptions.remote) {
@@ -1334,10 +1331,8 @@ hooks.add('tableExportModule', {
13341331
const queryAllSuccessMethods = ajax.queryAllSuccess
13351332
const queryAllErrorMethods = ajax.queryAllError
13361333

1337-
if (process.env.VUE_APP_VXE_ENV === 'development') {
1338-
if (!ajaxMethods) {
1339-
warnLog('vxe.error.notFunc', ['proxy-config.ajax.queryAll'])
1340-
}
1334+
if (!ajaxMethods) {
1335+
errLog('vxe.error.notFunc', ['proxy-config.ajax.queryAll'])
13411336
}
13421337

13431338
if (ajaxMethods) {
@@ -1578,7 +1573,7 @@ hooks.add('tableExportModule', {
15781573
if (!props.exportConfig) {
15791574
errLog('vxe.error.reqProp', ['export-config'])
15801575
}
1581-
handleExportAndPrint(defOpts)
1576+
return handleExportAndPrint(defOpts)
15821577
},
15831578
closePrint: handleCloseExport,
15841579
openPrint (options) {
@@ -1589,7 +1584,7 @@ hooks.add('tableExportModule', {
15891584
if (!props.printConfig) {
15901585
errLog('vxe.error.reqProp', ['print-config'])
15911586
}
1592-
handleExportAndPrint(defOpts, true)
1587+
return handleExportAndPrint(defOpts, true)
15931588
}
15941589
}
15951590

0 commit comments

Comments
 (0)