vxe-table 3.15.29 → 3.15.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/grid/src/grid.js +39 -42
- package/es/style.css +1 -1
- package/es/table/module/edit/mixin.js +11 -27
- package/es/table/module/export/mixin.js +65 -139
- package/es/table/module/menu/mixin.js +2 -6
- package/es/table/module/validator/mixin.js +99 -41
- package/es/table/src/methods.js +12 -36
- package/es/table/src/table.js +6 -8
- package/es/ui/index.js +1 -1
- package/es/ui/src/log.js +1 -1
- package/lib/grid/src/grid.js +24 -26
- package/lib/grid/src/grid.min.js +1 -1
- package/lib/index.umd.js +248 -556
- package/lib/index.umd.min.js +1 -1
- package/lib/style.css +1 -1
- package/lib/table/module/edit/mixin.js +11 -27
- package/lib/table/module/edit/mixin.min.js +1 -1
- package/lib/table/module/export/mixin.js +78 -168
- package/lib/table/module/export/mixin.min.js +1 -1
- package/lib/table/module/menu/mixin.js +2 -6
- package/lib/table/module/menu/mixin.min.js +1 -1
- package/lib/table/module/validator/mixin.js +97 -40
- package/lib/table/module/validator/mixin.min.js +1 -1
- package/lib/table/src/methods.js +12 -36
- package/lib/table/src/methods.min.js +1 -1
- package/lib/table/src/table.js +8 -10
- package/lib/table/src/table.min.js +1 -1
- package/lib/ui/index.js +1 -1
- package/lib/ui/index.min.js +1 -1
- package/lib/ui/src/log.js +1 -1
- package/lib/ui/src/log.min.js +1 -1
- package/package.json +1 -1
- package/packages/grid/src/grid.ts +39 -41
- package/packages/table/module/edit/mixin.ts +11 -27
- package/packages/table/module/export/mixin.ts +96 -158
- package/packages/table/module/menu/mixin.ts +2 -6
- package/packages/table/module/validator/mixin.ts +101 -40
- package/packages/table/src/methods.ts +12 -36
- package/packages/table/src/table.ts +6 -8
- /package/es/{iconfont.1747286367921.ttf → iconfont.1747357311626.ttf} +0 -0
- /package/es/{iconfont.1747286367921.woff → iconfont.1747357311626.woff} +0 -0
- /package/es/{iconfont.1747286367921.woff2 → iconfont.1747357311626.woff2} +0 -0
- /package/lib/{iconfont.1747286367921.ttf → iconfont.1747357311626.ttf} +0 -0
- /package/lib/{iconfont.1747286367921.woff → iconfont.1747357311626.woff} +0 -0
- /package/lib/{iconfont.1747286367921.woff2 → iconfont.1747357311626.woff2} +0 -0
|
@@ -12,10 +12,6 @@ const { getI18n, renderer } = VxeUI
|
|
|
12
12
|
|
|
13
13
|
let htmlCellElem: any
|
|
14
14
|
|
|
15
|
-
// 导入
|
|
16
|
-
let fileForm: any
|
|
17
|
-
let fileInput: any
|
|
18
|
-
|
|
19
15
|
const csvBOM = '\ufeff'
|
|
20
16
|
const enterSymbol = '\r\n'
|
|
21
17
|
|
|
@@ -42,11 +38,11 @@ function getSeq ($xeTable: VxeTableConstructor, cellValue: any, row: any, $rowIn
|
|
|
42
38
|
return cellValue
|
|
43
39
|
}
|
|
44
40
|
|
|
45
|
-
function defaultFilterExportColumn (column:
|
|
46
|
-
return column.field || ['seq', 'checkbox', 'radio'].indexOf(column.type) > -1
|
|
41
|
+
function defaultFilterExportColumn (column: VxeTableDefines.ColumnInfo) {
|
|
42
|
+
return !!column.field || ['seq', 'checkbox', 'radio'].indexOf(column.type || '') > -1
|
|
47
43
|
}
|
|
48
44
|
|
|
49
|
-
function toTableBorder (border:
|
|
45
|
+
function toTableBorder (border: VxeTablePropTypes.Border | undefined) {
|
|
50
46
|
if (border === true) {
|
|
51
47
|
return 'full'
|
|
52
48
|
}
|
|
@@ -510,7 +506,7 @@ function toHtml ($xeTable: VxeTableConstructor & VxeTablePrivateMethods, opts: V
|
|
|
510
506
|
return isPrint ? tables.join('') : createHtmlPage(opts, tables.join(''))
|
|
511
507
|
}
|
|
512
508
|
|
|
513
|
-
function toXML ($xeTable:
|
|
509
|
+
function toXML ($xeTable: VxeTableConstructor & VxeTablePrivateMethods, opts: any, columns: any[], datas: any[]) {
|
|
514
510
|
const reactData = $xeTable as unknown as TableReactData
|
|
515
511
|
|
|
516
512
|
let xml = [
|
|
@@ -564,53 +560,21 @@ function getContent ($xeTable: VxeTableConstructor & VxeTablePrivateMethods, opt
|
|
|
564
560
|
return ''
|
|
565
561
|
}
|
|
566
562
|
|
|
567
|
-
|
|
568
|
-
* 保存文件到本地
|
|
569
|
-
* @param {*} options 参数
|
|
570
|
-
*/
|
|
571
|
-
export function saveLocalFile (options: any) {
|
|
572
|
-
const { filename, type, content } = options
|
|
573
|
-
const name = `${filename}.${type}`
|
|
574
|
-
if (window.Blob) {
|
|
575
|
-
const blob = content instanceof Blob ? content : getExportBlobByContent(XEUtils.toValueString(content), options)
|
|
576
|
-
if ((navigator as any).msSaveBlob) {
|
|
577
|
-
(navigator as any).msSaveBlob(blob, name)
|
|
578
|
-
} else {
|
|
579
|
-
const url = URL.createObjectURL(blob as any)
|
|
580
|
-
const linkElem = document.createElement('a')
|
|
581
|
-
linkElem.target = '_blank'
|
|
582
|
-
linkElem.download = name
|
|
583
|
-
linkElem.href = url
|
|
584
|
-
document.body.appendChild(linkElem)
|
|
585
|
-
linkElem.click()
|
|
586
|
-
document.body.removeChild(linkElem)
|
|
587
|
-
requestAnimationFrame(() => {
|
|
588
|
-
if (linkElem.parentNode) {
|
|
589
|
-
linkElem.parentNode.removeChild(linkElem)
|
|
590
|
-
}
|
|
591
|
-
URL.revokeObjectURL(url)
|
|
592
|
-
})
|
|
593
|
-
}
|
|
594
|
-
return Promise.resolve()
|
|
595
|
-
}
|
|
596
|
-
return Promise.reject(new Error(getI18n('vxe.error.notExp')))
|
|
597
|
-
}
|
|
598
|
-
|
|
599
|
-
function downloadFile ($xeTable: any, opts: any, content: any) {
|
|
563
|
+
function downloadFile ($xeTable: VxeTableConstructor & VxeTablePrivateMethods, opts: any, content: any) {
|
|
600
564
|
const { filename, type, download } = opts
|
|
601
565
|
if (!download) {
|
|
602
566
|
const blob = getExportBlobByContent(content, opts)
|
|
603
567
|
return Promise.resolve({ type, content, blob })
|
|
604
568
|
}
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
569
|
+
if (VxeUI.saveFile) {
|
|
570
|
+
VxeUI.saveFile({ filename, type, content }).then(() => {
|
|
571
|
+
if (opts.message !== false) {
|
|
572
|
+
if (VxeUI.modal) {
|
|
573
|
+
VxeUI.modal.message({ content: getI18n('vxe.table.expSuccess'), status: 'success' })
|
|
574
|
+
}
|
|
610
575
|
}
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
})
|
|
576
|
+
})
|
|
577
|
+
}
|
|
614
578
|
}
|
|
615
579
|
|
|
616
580
|
function clearColumnConvert (columns: any) {
|
|
@@ -623,7 +587,7 @@ function clearColumnConvert (columns: any) {
|
|
|
623
587
|
}, { children: 'children' })
|
|
624
588
|
}
|
|
625
589
|
|
|
626
|
-
function handleExport ($xeTable:
|
|
590
|
+
function handleExport ($xeTable: VxeTableConstructor & VxeTablePrivateMethods, opts: VxeTablePropTypes.ExportHandleOptions) {
|
|
627
591
|
const $xeGrid = $xeTable.$xeGrid
|
|
628
592
|
|
|
629
593
|
const { remote, columns, colgroups, exportMethod, afterExportMethod } = opts
|
|
@@ -977,58 +941,6 @@ function handleCloseExport () {
|
|
|
977
941
|
return Promise.resolve()
|
|
978
942
|
}
|
|
979
943
|
|
|
980
|
-
/**
|
|
981
|
-
* 读取本地文件
|
|
982
|
-
* @param {*} options 参数
|
|
983
|
-
*/
|
|
984
|
-
export function readLocalFile (options: any = {}) {
|
|
985
|
-
if (!fileForm) {
|
|
986
|
-
fileForm = document.createElement('form')
|
|
987
|
-
fileInput = document.createElement('input')
|
|
988
|
-
fileForm.className = 'vxe-table--file-form'
|
|
989
|
-
fileInput.name = 'file'
|
|
990
|
-
fileInput.type = 'file'
|
|
991
|
-
fileForm.appendChild(fileInput)
|
|
992
|
-
document.body.appendChild(fileForm)
|
|
993
|
-
}
|
|
994
|
-
return new Promise((resolve, reject) => {
|
|
995
|
-
const types = options.types || []
|
|
996
|
-
const isAllType = !types.length || types.some((type: any) => type === '*')
|
|
997
|
-
fileInput.multiple = !!options.multiple
|
|
998
|
-
fileInput.accept = isAllType ? '' : `.${types.join(', .')}`
|
|
999
|
-
fileInput.onchange = (evnt: any) => {
|
|
1000
|
-
const { files } = evnt.target
|
|
1001
|
-
const file = files[0]
|
|
1002
|
-
let errType
|
|
1003
|
-
// 校验类型
|
|
1004
|
-
if (!isAllType) {
|
|
1005
|
-
for (let fIndex = 0; fIndex < files.length; fIndex++) {
|
|
1006
|
-
const { type } = parseFile(files[fIndex])
|
|
1007
|
-
if (!XEUtils.includes(types, type)) {
|
|
1008
|
-
errType = type
|
|
1009
|
-
break
|
|
1010
|
-
}
|
|
1011
|
-
}
|
|
1012
|
-
}
|
|
1013
|
-
if (!errType) {
|
|
1014
|
-
resolve({ status: true, files, file })
|
|
1015
|
-
} else {
|
|
1016
|
-
if (options.message !== false) {
|
|
1017
|
-
// 检测弹窗模块
|
|
1018
|
-
if (!VxeUI.modal) {
|
|
1019
|
-
errLog('vxe.error.reqModule', ['Modal'])
|
|
1020
|
-
}
|
|
1021
|
-
VxeUI.modal.message({ content: getI18n('vxe.error.notType', [errType]), status: 'error' })
|
|
1022
|
-
}
|
|
1023
|
-
const params = { status: false, files, file }
|
|
1024
|
-
reject(params)
|
|
1025
|
-
}
|
|
1026
|
-
}
|
|
1027
|
-
fileForm.reset()
|
|
1028
|
-
fileInput.click()
|
|
1029
|
-
})
|
|
1030
|
-
}
|
|
1031
|
-
|
|
1032
944
|
function handleFilterColumns (exportOpts: VxeTablePropTypes.ExportConfig, column: VxeTableDefines.ColumnInfo, columns: VxeTableDefines.ColumnInfo[] | VxeTablePropTypes.ExportOrPrintColumnOption[]) {
|
|
1033
945
|
return columns.some((item: any) => {
|
|
1034
946
|
if (isColumnInfo(item)) {
|
|
@@ -1065,7 +977,7 @@ function handleFilterFields (exportOpts: VxeTablePropTypes.ExportConfig, column:
|
|
|
1065
977
|
}
|
|
1066
978
|
return false
|
|
1067
979
|
}
|
|
1068
|
-
return exportOpts.original ? column.field : defaultFilterExportColumn(column)
|
|
980
|
+
return exportOpts.original ? !!column.field : defaultFilterExportColumn(column)
|
|
1069
981
|
}
|
|
1070
982
|
|
|
1071
983
|
function handleExportAndPrint ($xeTable: VxeTableConstructor, options: VxeTablePropTypes.ExportOpts | VxeTablePropTypes.ExportConfig, isPrint?: any) {
|
|
@@ -1121,7 +1033,7 @@ function handleExportAndPrint ($xeTable: VxeTableConstructor, options: VxeTableP
|
|
|
1121
1033
|
})
|
|
1122
1034
|
// 默认选中
|
|
1123
1035
|
XEUtils.eachTree(exportColumns, (column, index, items, path, parent) => {
|
|
1124
|
-
const isColGroup = column.children && column.children.length
|
|
1036
|
+
const isColGroup = column.children && column.children.length > 0
|
|
1125
1037
|
let isChecked = false
|
|
1126
1038
|
if (columns && columns.length) {
|
|
1127
1039
|
isChecked = handleFilterColumns(defOpts, column, columns)
|
|
@@ -1249,16 +1161,16 @@ export default {
|
|
|
1249
1161
|
* 如果是启用了虚拟滚动,则只能导出数据源,可以配合 dataFilterMethod 函数转换数据
|
|
1250
1162
|
* @param {Object} options 参数
|
|
1251
1163
|
*/
|
|
1252
|
-
_exportData (options
|
|
1253
|
-
const $xeTable = this
|
|
1164
|
+
_exportData (options?: VxeTablePropTypes.ExportConfig) {
|
|
1165
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
1254
1166
|
const props = $xeTable
|
|
1255
|
-
const reactData = $xeTable
|
|
1256
|
-
const internalData = $xeTable
|
|
1167
|
+
const reactData = $xeTable as unknown as TableReactData
|
|
1168
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
1257
1169
|
const $xeGrid = $xeTable.$xeGrid as VxeGridConstructor
|
|
1258
1170
|
|
|
1259
1171
|
const { treeConfig, showHeader, showFooter } = props
|
|
1260
|
-
const {
|
|
1261
|
-
const { tableFullColumn, afterFullData, mergeBodyList,
|
|
1172
|
+
const { isGroup } = reactData
|
|
1173
|
+
const { tableFullColumn, afterFullData, collectColumn, mergeBodyList, mergeFooterList } = internalData
|
|
1262
1174
|
const exportOpts = $xeTable.computeExportOpts
|
|
1263
1175
|
const treeOpts = $xeTable.computeTreeOpts
|
|
1264
1176
|
const proxyOpts = $xeGrid ? $xeGrid.computeProxyOpts : {}
|
|
@@ -1297,7 +1209,7 @@ export default {
|
|
|
1297
1209
|
const customCols = columns && columns.length
|
|
1298
1210
|
? columns
|
|
1299
1211
|
: XEUtils.searchTree(collectColumn, column => {
|
|
1300
|
-
const isColGroup = column.children && column.children.length
|
|
1212
|
+
const isColGroup = column.children && column.children.length > 0
|
|
1301
1213
|
let isChecked = false
|
|
1302
1214
|
if (columns && columns.length) {
|
|
1303
1215
|
isChecked = handleFilterColumns(opts, column, columns)
|
|
@@ -1311,7 +1223,7 @@ export default {
|
|
|
1311
1223
|
const handleOptions: VxeTablePropTypes.ExportHandleOptions = Object.assign({ } as { data: any[], colgroups: any[], columns: any[] }, opts, { filename: '', sheetName: '' })
|
|
1312
1224
|
// 如果设置源数据,则默认导出设置了字段的列
|
|
1313
1225
|
if (!customCols && !columnFilterMethod) {
|
|
1314
|
-
|
|
1226
|
+
columnFilterMethod = ({ column }) => {
|
|
1315
1227
|
if (excludeFields) {
|
|
1316
1228
|
if (XEUtils.includes(excludeFields, column.field)) {
|
|
1317
1229
|
return false
|
|
@@ -1323,8 +1235,9 @@ export default {
|
|
|
1323
1235
|
}
|
|
1324
1236
|
return false
|
|
1325
1237
|
}
|
|
1326
|
-
return original ? column.field : defaultFilterExportColumn(column)
|
|
1238
|
+
return original ? !!column.field : defaultFilterExportColumn(column)
|
|
1327
1239
|
}
|
|
1240
|
+
handleOptions.columnFilterMethod = columnFilterMethod
|
|
1328
1241
|
}
|
|
1329
1242
|
if (customCols) {
|
|
1330
1243
|
handleOptions._isCustomColumn = true
|
|
@@ -1356,7 +1269,7 @@ export default {
|
|
|
1356
1269
|
children: 'childNodes',
|
|
1357
1270
|
mapChildren: '_children'
|
|
1358
1271
|
}),
|
|
1359
|
-
(column, index) => isColumnInfo(column) && (!columnFilterMethod || columnFilterMethod({ column: column as any, $columnIndex: index })),
|
|
1272
|
+
(column, index) => isColumnInfo(column) && (!columnFilterMethod || columnFilterMethod({ $table: $xeTable, column: column as any, $columnIndex: index })),
|
|
1360
1273
|
{
|
|
1361
1274
|
children: '_children',
|
|
1362
1275
|
mapChildren: 'childNodes',
|
|
@@ -1364,7 +1277,7 @@ export default {
|
|
|
1364
1277
|
}
|
|
1365
1278
|
)
|
|
1366
1279
|
} else {
|
|
1367
|
-
groups = XEUtils.searchTree(isGroup ? collectColumn : tableFullColumn, (column, index) => column.visible && (!columnFilterMethod || columnFilterMethod({ column, $columnIndex: index })), { children: 'children', mapChildren: 'childNodes', original: true })
|
|
1280
|
+
groups = XEUtils.searchTree(isGroup ? collectColumn : tableFullColumn, (column, index) => column.visible && (!columnFilterMethod || columnFilterMethod({ $table: $xeTable, column, $columnIndex: index })), { children: 'children', mapChildren: 'childNodes', original: true })
|
|
1368
1281
|
}
|
|
1369
1282
|
// 获取所有列
|
|
1370
1283
|
const cols: VxeTableDefines.ColumnInfo[] = []
|
|
@@ -1410,10 +1323,8 @@ export default {
|
|
|
1410
1323
|
// 检查类型,如果为自定义导出,则不需要校验类型
|
|
1411
1324
|
if (!handleOptions.exportMethod && !XEUtils.includes(XEUtils.keys(exportOpts._typeMaps), type)) {
|
|
1412
1325
|
errLog('vxe.error.notType', [type])
|
|
1413
|
-
if (
|
|
1414
|
-
|
|
1415
|
-
warnLog('vxe.error.reqPlugin', [4, 'plugin-export-xlsx'])
|
|
1416
|
-
}
|
|
1326
|
+
if (['xlsx', 'pdf'].includes(type)) {
|
|
1327
|
+
warnLog('vxe.error.reqPlugin', [4, 'plugin-export-xlsx'])
|
|
1417
1328
|
}
|
|
1418
1329
|
const params = { status: false }
|
|
1419
1330
|
return Promise.reject(params)
|
|
@@ -1434,10 +1345,8 @@ export default {
|
|
|
1434
1345
|
handleOptions.data = selectRecords
|
|
1435
1346
|
}
|
|
1436
1347
|
} else if (mode === 'all') {
|
|
1437
|
-
if (
|
|
1438
|
-
|
|
1439
|
-
warnLog('vxe.error.errProp', ['all', 'mode=current,selected'])
|
|
1440
|
-
}
|
|
1348
|
+
if (!$xeGrid) {
|
|
1349
|
+
errLog('vxe.error.errProp', ['all', 'mode=current,selected'])
|
|
1441
1350
|
}
|
|
1442
1351
|
|
|
1443
1352
|
if ($xeGrid && !handleOptions.remote) {
|
|
@@ -1450,10 +1359,8 @@ export default {
|
|
|
1450
1359
|
const queryAllSuccessMethods = ajax.queryAllSuccess
|
|
1451
1360
|
const queryAllErrorMethods = ajax.queryAllError
|
|
1452
1361
|
|
|
1453
|
-
if (
|
|
1454
|
-
|
|
1455
|
-
warnLog('vxe.error.notFunc', ['proxy-config.ajax.queryAll'])
|
|
1456
|
-
}
|
|
1362
|
+
if (!ajaxMethods) {
|
|
1363
|
+
errLog('vxe.error.notFunc', ['proxy-config.ajax.queryAll'])
|
|
1457
1364
|
}
|
|
1458
1365
|
|
|
1459
1366
|
if (ajaxMethods) {
|
|
@@ -1491,15 +1398,19 @@ export default {
|
|
|
1491
1398
|
}
|
|
1492
1399
|
return handleExport($xeTable, handleOptions)
|
|
1493
1400
|
},
|
|
1494
|
-
_importByFile (file:
|
|
1401
|
+
_importByFile (file: File, options: VxeTablePropTypes.ImportConfig) {
|
|
1402
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
1403
|
+
|
|
1495
1404
|
const opts = Object.assign({}, options)
|
|
1496
1405
|
const { beforeImportMethod } = opts
|
|
1497
1406
|
if (beforeImportMethod) {
|
|
1498
|
-
beforeImportMethod({ options: opts, $table:
|
|
1407
|
+
beforeImportMethod({ options: opts, $table: $xeTable })
|
|
1499
1408
|
}
|
|
1500
|
-
return handleFileImport(
|
|
1409
|
+
return handleFileImport($xeTable, file, opts)
|
|
1501
1410
|
},
|
|
1502
|
-
_importData (options
|
|
1411
|
+
_importData (options?: VxeTablePropTypes.ImportConfig) {
|
|
1412
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
1413
|
+
|
|
1503
1414
|
const { importOpts } = this
|
|
1504
1415
|
const opts = Object.assign({
|
|
1505
1416
|
types: XEUtils.keys(importOpts._typeMaps)
|
|
@@ -1510,24 +1421,32 @@ export default {
|
|
|
1510
1421
|
if (beforeImportMethod) {
|
|
1511
1422
|
beforeImportMethod({ options: opts, $table: this })
|
|
1512
1423
|
}
|
|
1513
|
-
return
|
|
1424
|
+
return VxeUI.readFile(opts).catch(e => {
|
|
1514
1425
|
if (afterImportMethod) {
|
|
1515
|
-
afterImportMethod({ status: false, options: opts, $table:
|
|
1426
|
+
afterImportMethod({ status: false, options: opts, $table: $xeTable })
|
|
1516
1427
|
}
|
|
1517
1428
|
return Promise.reject(e)
|
|
1518
|
-
}).then((params
|
|
1429
|
+
}).then((params) => {
|
|
1519
1430
|
const { file } = params
|
|
1520
|
-
return handleFileImport(
|
|
1431
|
+
return handleFileImport($xeTable, file, opts)
|
|
1521
1432
|
})
|
|
1522
1433
|
},
|
|
1523
|
-
_saveFile (options:
|
|
1524
|
-
|
|
1434
|
+
_saveFile (options: {
|
|
1435
|
+
filename: string
|
|
1436
|
+
type: string
|
|
1437
|
+
content: string | Blob
|
|
1438
|
+
}) {
|
|
1439
|
+
return VxeUI.saveFile(options)
|
|
1525
1440
|
},
|
|
1526
|
-
_readFile (options
|
|
1527
|
-
|
|
1441
|
+
_readFile (options?: {
|
|
1442
|
+
multiple?: boolean
|
|
1443
|
+
types?: string[]
|
|
1444
|
+
message?: boolean
|
|
1445
|
+
}) {
|
|
1446
|
+
return VxeUI.readFile(options)
|
|
1528
1447
|
},
|
|
1529
|
-
_print (options
|
|
1530
|
-
const $xeTable = this
|
|
1448
|
+
_print (options?: VxeTablePropTypes.PrintConfig) {
|
|
1449
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
1531
1450
|
const $xeGrid = $xeTable.$xeGrid
|
|
1532
1451
|
|
|
1533
1452
|
const opts = Object.assign({
|
|
@@ -1607,7 +1526,7 @@ export default {
|
|
|
1607
1526
|
})
|
|
1608
1527
|
},
|
|
1609
1528
|
_getPrintHtml (options: VxeTablePropTypes.PrintConfig) {
|
|
1610
|
-
const $xeTable = this
|
|
1529
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
1611
1530
|
|
|
1612
1531
|
const printOpts = $xeTable.computePrintOpts
|
|
1613
1532
|
const opts = Object.assign({
|
|
@@ -1631,24 +1550,30 @@ export default {
|
|
|
1631
1550
|
}
|
|
1632
1551
|
return Promise.resolve()
|
|
1633
1552
|
},
|
|
1634
|
-
_openImport (options
|
|
1635
|
-
const
|
|
1553
|
+
_openImport (options?: VxeTablePropTypes.ImportConfig) {
|
|
1554
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
1555
|
+
const props = $xeTable
|
|
1556
|
+
const reactData = $xeTable as unknown as TableReactData
|
|
1557
|
+
|
|
1558
|
+
const { treeConfig, importConfig } = props
|
|
1559
|
+
const { initStore, importStore, importParams } = reactData
|
|
1560
|
+
const importOpts = $xeTable.computeImportOpts
|
|
1636
1561
|
const defOpts = Object.assign({
|
|
1637
1562
|
mode: 'insertTop',
|
|
1638
1563
|
message: true,
|
|
1639
1564
|
types: XEUtils.keys(importOpts._typeMaps),
|
|
1640
1565
|
modes: ['insertTop', 'covering']
|
|
1641
|
-
},
|
|
1566
|
+
}, importOpts, options)
|
|
1642
1567
|
const types = defOpts.types || []
|
|
1643
1568
|
const modes = defOpts.modes || []
|
|
1644
|
-
const isTree = !!
|
|
1569
|
+
const isTree = !!treeConfig
|
|
1645
1570
|
if (isTree) {
|
|
1646
1571
|
if (defOpts.message) {
|
|
1647
1572
|
VxeUI.modal.message({ content: getI18n('vxe.error.treeNotImp'), status: 'error' })
|
|
1648
1573
|
}
|
|
1649
1574
|
return
|
|
1650
1575
|
}
|
|
1651
|
-
if (!
|
|
1576
|
+
if (!importConfig) {
|
|
1652
1577
|
errLog('vxe.error.reqProp', ['import-config'])
|
|
1653
1578
|
}
|
|
1654
1579
|
// 处理类型
|
|
@@ -1670,7 +1595,7 @@ export default {
|
|
|
1670
1595
|
label: getI18n(`vxe.import.modes.${item}`)
|
|
1671
1596
|
}
|
|
1672
1597
|
})
|
|
1673
|
-
Object.assign(
|
|
1598
|
+
Object.assign(importStore, {
|
|
1674
1599
|
file: null,
|
|
1675
1600
|
type: '',
|
|
1676
1601
|
filename: '',
|
|
@@ -1678,27 +1603,40 @@ export default {
|
|
|
1678
1603
|
typeList,
|
|
1679
1604
|
visible: true
|
|
1680
1605
|
})
|
|
1681
|
-
Object.assign(
|
|
1682
|
-
if (!modeList.some(
|
|
1683
|
-
|
|
1606
|
+
Object.assign(importParams, defOpts)
|
|
1607
|
+
if (!modeList.some(item => item.value === importParams.mode)) {
|
|
1608
|
+
importParams.mode = modeList[0].value
|
|
1684
1609
|
}
|
|
1685
|
-
|
|
1610
|
+
initStore.import = true
|
|
1686
1611
|
},
|
|
1687
1612
|
_closeExport: handleCloseExport,
|
|
1688
1613
|
_openExport (options: any) {
|
|
1689
|
-
const
|
|
1690
|
-
|
|
1614
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
1615
|
+
const props = $xeTable
|
|
1616
|
+
|
|
1617
|
+
const exportOpts = $xeTable.computeExportOpts
|
|
1618
|
+
const defOpts = Object.assign({
|
|
1619
|
+
message: true,
|
|
1620
|
+
types: XEUtils.keys(exportOpts._typeMaps)
|
|
1621
|
+
}, exportOpts, options)
|
|
1622
|
+
if (!props.exportConfig) {
|
|
1691
1623
|
errLog('vxe.error.reqProp', ['export-config'])
|
|
1692
1624
|
}
|
|
1693
|
-
return handleExportAndPrint(
|
|
1625
|
+
return handleExportAndPrint($xeTable, defOpts)
|
|
1694
1626
|
},
|
|
1695
1627
|
_closePrint: handleCloseExport,
|
|
1696
1628
|
_openPrint (options: any) {
|
|
1697
|
-
const
|
|
1698
|
-
|
|
1629
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
1630
|
+
const props = $xeTable
|
|
1631
|
+
|
|
1632
|
+
const printOpts = $xeTable.computePrintOpts
|
|
1633
|
+
const defOpts = Object.assign({
|
|
1634
|
+
message: true
|
|
1635
|
+
}, printOpts, options)
|
|
1636
|
+
if (!props.printConfig) {
|
|
1699
1637
|
errLog('vxe.error.reqProp', ['print-config'])
|
|
1700
1638
|
}
|
|
1701
|
-
return handleExportAndPrint(
|
|
1639
|
+
return handleExportAndPrint($xeTable, defOpts, true)
|
|
1702
1640
|
}
|
|
1703
1641
|
} as any
|
|
1704
1642
|
} as any
|
|
@@ -116,9 +116,7 @@ export default {
|
|
|
116
116
|
this.handleOpenMenuEvent(evnt, layout, params)
|
|
117
117
|
// 在 v4 中废弃事件 cell-context-menu、header-cell-context-menu、footer-cell-context-menu
|
|
118
118
|
if (this.$listeners[`${typePrefix}cell-context-menu`]) {
|
|
119
|
-
|
|
120
|
-
warnLog('vxe.error.delEvent', [`${typePrefix}cell-context-menu`, `${typePrefix}cell-menu`])
|
|
121
|
-
}
|
|
119
|
+
warnLog('vxe.error.delEvent', [`${typePrefix}cell-context-menu`, `${typePrefix}cell-menu`])
|
|
122
120
|
this.emitEvent(`${typePrefix}cell-context-menu`, params, evnt)
|
|
123
121
|
} else {
|
|
124
122
|
this.emitEvent(`${typePrefix}cell-menu`, params, evnt)
|
|
@@ -270,9 +268,7 @@ export default {
|
|
|
270
268
|
}
|
|
271
269
|
// 在 v4 中废弃事件 context-menu-click
|
|
272
270
|
if (this.$listeners['context-menu-click']) {
|
|
273
|
-
|
|
274
|
-
warnLog('vxe.error.delEvent', ['context-menu-click', 'menu-click'])
|
|
275
|
-
}
|
|
271
|
+
warnLog('vxe.error.delEvent', ['context-menu-click', 'menu-click'])
|
|
276
272
|
this.emitEvent('context-menu-click', params, evnt)
|
|
277
273
|
} else {
|
|
278
274
|
this.emitEvent('menu-click', params, evnt)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import XEUtils from 'xe-utils'
|
|
2
2
|
import { VxeUI } from '../../../ui'
|
|
3
|
-
import { getFuncText
|
|
3
|
+
import { getFuncText } from '../../../ui/src/utils'
|
|
4
4
|
import { scrollToView } from '../../../ui/src/dom'
|
|
5
5
|
import { handleFieldOrColumn, getRowid } from '../../src/util'
|
|
6
6
|
import { warnLog, errLog } from '../../../ui/src/log'
|
|
@@ -41,27 +41,104 @@ class Rule {
|
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
|
|
44
|
+
// 如果存在 pattern,判断正则
|
|
45
|
+
function validREValue (pattern: string | RegExp | undefined, val: string) {
|
|
46
|
+
if (pattern && !(XEUtils.isRegExp(pattern) ? pattern : new RegExp(pattern)).test(val)) {
|
|
47
|
+
return false
|
|
48
|
+
}
|
|
49
|
+
return true
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// 如果存在 max,判断最大值
|
|
53
|
+
function validMaxValue (max: string | number | undefined, num: number) {
|
|
54
|
+
if (!XEUtils.eqNull(max) && num > XEUtils.toNumber(max)) {
|
|
55
|
+
return false
|
|
56
|
+
}
|
|
57
|
+
return true
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// 如果存在 min,判断最小值
|
|
61
|
+
function validMinValue (min: string | number | undefined, num: number) {
|
|
62
|
+
if (!XEUtils.eqNull(min) && num < XEUtils.toNumber(min)) {
|
|
63
|
+
return false
|
|
64
|
+
}
|
|
65
|
+
return true
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function validRuleValue (rule: VxeTableDefines.ValidatorRule, val: any, required: boolean | undefined) {
|
|
45
69
|
const { type, min, max, pattern } = rule
|
|
70
|
+
const isArrType = type === 'array'
|
|
46
71
|
const isNumType = type === 'number'
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
-
if (
|
|
50
|
-
return
|
|
51
|
-
}
|
|
52
|
-
// 如果存在 min,判断最小值
|
|
53
|
-
if (!XEUtils.eqNull(min) && numVal < XEUtils.toNumber(min)) {
|
|
54
|
-
return true
|
|
72
|
+
const isStrType = type === 'string'
|
|
73
|
+
const strVal = `${val}`
|
|
74
|
+
if (!validREValue(pattern, strVal)) {
|
|
75
|
+
return false
|
|
55
76
|
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
77
|
+
if (isArrType) {
|
|
78
|
+
if (!XEUtils.isArray(val)) {
|
|
79
|
+
return false
|
|
80
|
+
}
|
|
81
|
+
if (required) {
|
|
82
|
+
if (!val.length) {
|
|
83
|
+
return false
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
if (!validMinValue(min, val.length)) {
|
|
87
|
+
return false
|
|
88
|
+
}
|
|
89
|
+
if (!validMaxValue(max, val.length)) {
|
|
90
|
+
return false
|
|
91
|
+
}
|
|
92
|
+
} else if (isNumType) {
|
|
93
|
+
const numVal = Number(val)
|
|
94
|
+
if (isNaN(numVal)) {
|
|
95
|
+
return false
|
|
96
|
+
}
|
|
97
|
+
if (!validMinValue(min, numVal)) {
|
|
98
|
+
return false
|
|
99
|
+
}
|
|
100
|
+
if (!validMaxValue(max, numVal)) {
|
|
101
|
+
return false
|
|
102
|
+
}
|
|
103
|
+
} else {
|
|
104
|
+
if (isStrType) {
|
|
105
|
+
if (!XEUtils.isString(val)) {
|
|
106
|
+
return false
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
if (required) {
|
|
110
|
+
if (!strVal) {
|
|
111
|
+
return false
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
if (!validMinValue(min, strVal.length)) {
|
|
115
|
+
return false
|
|
116
|
+
}
|
|
117
|
+
if (!validMaxValue(max, strVal.length)) {
|
|
118
|
+
return false
|
|
119
|
+
}
|
|
59
120
|
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
121
|
+
return true
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
function checkRuleStatus (rule: VxeTableDefines.ValidatorRule, val: any) {
|
|
125
|
+
const { required } = rule
|
|
126
|
+
const isEmptyVal = XEUtils.eqNull(val)
|
|
127
|
+
if (required) {
|
|
128
|
+
if (isEmptyVal) {
|
|
129
|
+
return false
|
|
130
|
+
}
|
|
131
|
+
if (!validRuleValue(rule, val, required)) {
|
|
132
|
+
return false
|
|
133
|
+
}
|
|
134
|
+
} else {
|
|
135
|
+
if (!isEmptyVal) {
|
|
136
|
+
if (!validRuleValue(rule, val, required)) {
|
|
137
|
+
return false
|
|
138
|
+
}
|
|
139
|
+
}
|
|
63
140
|
}
|
|
64
|
-
return
|
|
141
|
+
return true
|
|
65
142
|
}
|
|
66
143
|
|
|
67
144
|
export default {
|
|
@@ -70,10 +147,8 @@ export default {
|
|
|
70
147
|
* 完整校验,和 validate 的区别就是会给有效数据中的每一行进行校验
|
|
71
148
|
*/
|
|
72
149
|
_fullValidate (rows: any, cb: any) {
|
|
73
|
-
if (
|
|
74
|
-
|
|
75
|
-
warnLog('vxe.error.notValidators', ['fullValidate(rows, callback)', 'fullValidate(rows)'])
|
|
76
|
-
}
|
|
150
|
+
if (XEUtils.isFunction(cb)) {
|
|
151
|
+
warnLog('vxe.error.notValidators', ['fullValidate(rows, callback)', 'fullValidate(rows)'])
|
|
77
152
|
}
|
|
78
153
|
return this.beginValidate(rows, null, cb, true)
|
|
79
154
|
},
|
|
@@ -81,10 +156,8 @@ export default {
|
|
|
81
156
|
* 快速校验,如果存在记录不通过的记录,则返回不再继续校验(异步校验除外)
|
|
82
157
|
*/
|
|
83
158
|
_validate (rows: any, cb: any) {
|
|
84
|
-
if (
|
|
85
|
-
|
|
86
|
-
warnLog('vxe.error.notValidators', ['validate(rows, callback)', 'validate(rows)'])
|
|
87
|
-
}
|
|
159
|
+
if (XEUtils.isFunction(cb)) {
|
|
160
|
+
warnLog('vxe.error.notValidators', ['validate(rows, callback)', 'validate(rows)'])
|
|
88
161
|
}
|
|
89
162
|
return this.beginValidate(rows, null, cb)
|
|
90
163
|
},
|
|
@@ -326,7 +399,7 @@ export default {
|
|
|
326
399
|
if (rules) {
|
|
327
400
|
const cellValue = XEUtils.isUndefined(val) ? XEUtils.get(row, property) : val
|
|
328
401
|
rules.forEach((rule: any) => {
|
|
329
|
-
const {
|
|
402
|
+
const { trigger, validator } = rule
|
|
330
403
|
if (validType === 'all' || !trigger || validType === trigger) {
|
|
331
404
|
if (validator) {
|
|
332
405
|
const validParams: any = {
|
|
@@ -348,9 +421,7 @@ export default {
|
|
|
348
421
|
if (tcvMethod) {
|
|
349
422
|
customValid = tcvMethod(validParams)
|
|
350
423
|
} else {
|
|
351
|
-
|
|
352
|
-
warnLog('vxe.error.notValidators', [validator])
|
|
353
|
-
}
|
|
424
|
+
errLog('vxe.error.notValidators', [validator])
|
|
354
425
|
}
|
|
355
426
|
} else {
|
|
356
427
|
errLog('vxe.error.notValidators', [validator])
|
|
@@ -373,17 +444,7 @@ export default {
|
|
|
373
444
|
}
|
|
374
445
|
}
|
|
375
446
|
} else {
|
|
376
|
-
|
|
377
|
-
const isArrVal = XEUtils.isArray(cellValue)
|
|
378
|
-
let hasEmpty = true
|
|
379
|
-
if (isArrType || isArrVal) {
|
|
380
|
-
hasEmpty = !isArrVal || !cellValue.length
|
|
381
|
-
} else if (XEUtils.isString(cellValue)) {
|
|
382
|
-
hasEmpty = eqEmptyValue(cellValue.trim())
|
|
383
|
-
} else {
|
|
384
|
-
hasEmpty = eqEmptyValue(cellValue)
|
|
385
|
-
}
|
|
386
|
-
if (required ? (hasEmpty || validErrorRuleValue(rule, cellValue)) : (!hasEmpty && validErrorRuleValue(rule, cellValue))) {
|
|
447
|
+
if (!checkRuleStatus(rule, cellValue)) {
|
|
387
448
|
this.validRuleErr = true
|
|
388
449
|
errorRules.push(new Rule(rule))
|
|
389
450
|
}
|