vxe-table 3.15.28 → 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.
Files changed (63) hide show
  1. package/es/grid/src/grid.js +39 -42
  2. package/es/index.css +1 -1
  3. package/es/index.min.css +1 -1
  4. package/es/style.css +1 -1
  5. package/es/style.min.css +1 -1
  6. package/es/table/module/edit/mixin.js +11 -27
  7. package/es/table/module/export/mixin.js +65 -139
  8. package/es/table/module/filter/mixin.js +1 -0
  9. package/es/table/module/menu/mixin.js +2 -6
  10. package/es/table/module/validator/mixin.js +99 -41
  11. package/es/table/src/methods.js +110 -89
  12. package/es/table/src/table.js +6 -8
  13. package/es/table/style.css +6 -0
  14. package/es/table/style.min.css +1 -1
  15. package/es/ui/index.js +1 -1
  16. package/es/ui/src/log.js +1 -1
  17. package/es/vxe-table/style.css +6 -0
  18. package/es/vxe-table/style.min.css +1 -1
  19. package/lib/grid/src/grid.js +24 -26
  20. package/lib/grid/src/grid.min.js +1 -1
  21. package/lib/index.css +1 -1
  22. package/lib/index.min.css +1 -1
  23. package/lib/index.umd.js +358 -615
  24. package/lib/index.umd.min.js +1 -1
  25. package/lib/style.css +1 -1
  26. package/lib/style.min.css +1 -1
  27. package/lib/table/module/edit/mixin.js +11 -27
  28. package/lib/table/module/edit/mixin.min.js +1 -1
  29. package/lib/table/module/export/mixin.js +78 -168
  30. package/lib/table/module/export/mixin.min.js +1 -1
  31. package/lib/table/module/filter/mixin.js +1 -0
  32. package/lib/table/module/menu/mixin.js +2 -6
  33. package/lib/table/module/menu/mixin.min.js +1 -1
  34. package/lib/table/module/validator/mixin.js +97 -40
  35. package/lib/table/module/validator/mixin.min.js +1 -1
  36. package/lib/table/src/methods.js +121 -95
  37. package/lib/table/src/methods.min.js +1 -1
  38. package/lib/table/src/table.js +8 -10
  39. package/lib/table/src/table.min.js +1 -1
  40. package/lib/table/style/style.css +6 -0
  41. package/lib/table/style/style.min.css +1 -1
  42. package/lib/ui/index.js +1 -1
  43. package/lib/ui/index.min.js +1 -1
  44. package/lib/ui/src/log.js +1 -1
  45. package/lib/ui/src/log.min.js +1 -1
  46. package/lib/vxe-table/style/style.css +6 -0
  47. package/lib/vxe-table/style/style.min.css +1 -1
  48. package/package.json +1 -1
  49. package/packages/grid/src/grid.ts +39 -41
  50. package/packages/table/module/edit/mixin.ts +11 -27
  51. package/packages/table/module/export/mixin.ts +96 -158
  52. package/packages/table/module/filter/mixin.ts +1 -0
  53. package/packages/table/module/menu/mixin.ts +2 -6
  54. package/packages/table/module/validator/mixin.ts +101 -40
  55. package/packages/table/src/methods.ts +115 -90
  56. package/packages/table/src/table.ts +6 -8
  57. package/styles/components/table.scss +14 -0
  58. /package/es/{iconfont.1747176212818.ttf → iconfont.1747357311626.ttf} +0 -0
  59. /package/es/{iconfont.1747176212818.woff → iconfont.1747357311626.woff} +0 -0
  60. /package/es/{iconfont.1747176212818.woff2 → iconfont.1747357311626.woff2} +0 -0
  61. /package/lib/{iconfont.1747176212818.ttf → iconfont.1747357311626.ttf} +0 -0
  62. /package/lib/{iconfont.1747176212818.woff → iconfont.1747357311626.woff} +0 -0
  63. /package/lib/{iconfont.1747176212818.woff2 → iconfont.1747357311626.woff2} +0 -0
@@ -111,13 +111,11 @@ function getToolbarSlots (_vm: any) {
111
111
  let buttonsSlot
112
112
  let toolsSlot
113
113
  const slots: any = {}
114
- if (process.env.VUE_APP_VXE_ENV === 'development') {
115
- if ($scopedSlots.buttons && (!toolbarOptSlots || toolbarOptSlots.buttons !== 'buttons')) {
116
- warnLog('vxe.error.reqProp', ['toolbar-config.slots.buttons'])
117
- }
118
- if ($scopedSlots.tools && (!toolbarOptSlots || toolbarOptSlots.tools !== 'tools')) {
119
- warnLog('vxe.error.reqProp', ['toolbar-config.slots.tools'])
120
- }
114
+ if ($scopedSlots.buttons && (!toolbarOptSlots || toolbarOptSlots.buttons !== 'buttons')) {
115
+ warnLog('vxe.error.reqProp', ['toolbar-config.slots.buttons'])
116
+ }
117
+ if ($scopedSlots.tools && (!toolbarOptSlots || toolbarOptSlots.tools !== 'tools')) {
118
+ warnLog('vxe.error.reqProp', ['toolbar-config.slots.tools'])
121
119
  }
122
120
  if (toolbarOptSlots) {
123
121
  buttonsSlot = getFuncSlot(_vm, toolbarOptSlots, 'buttons')
@@ -604,17 +602,15 @@ export default {
604
602
  // errLog('vxe.error.errConflicts', ['grid.data', 'grid.proxy-config'])
605
603
  // }
606
604
 
607
- if (process.env.VUE_APP_VXE_ENV === 'development') {
608
- if (this.toolbar) {
609
- warnLog('vxe.error.delProp', ['grid.toolbar', 'grid.toolbar-config'])
610
- }
611
- if (this.toolbarConfig && !XEUtils.isObject(this.toolbarConfig)) {
612
- warnLog('vxe.error.errProp', [`grid.toolbar-config=${this.toolbarConfig}`, 'grid.toolbar-config={}'])
613
- }
614
- // if (proxyOpts.props) {
615
- // warnLog('vxe.error.delProp', ['proxy-config.props', 'proxy-config.response'])
616
- // }
605
+ if (this.toolbar) {
606
+ warnLog('vxe.error.delProp', ['grid.toolbar', 'grid.toolbar-config'])
607
+ }
608
+ if (this.toolbarConfig && !XEUtils.isObject(this.toolbarConfig)) {
609
+ warnLog('vxe.error.errProp', [`grid.toolbar-config=${this.toolbarConfig}`, 'grid.toolbar-config={}'])
617
610
  }
611
+ // if (proxyOpts.props) {
612
+ // warnLog('vxe.error.delProp', ['proxy-config.props', 'proxy-config.response'])
613
+ // }
618
614
 
619
615
  // 使用已安装的组件,如果未安装则不渲染
620
616
  const VxeUIFormComponent = VxeUI.getComponent<VxeFormComponent>('VxeForm')
@@ -1279,8 +1275,10 @@ export default {
1279
1275
  })
1280
1276
  },
1281
1277
  getProxyInfo () {
1282
- const { $refs, sortData, proxyConfig } = this
1283
- const $xeTable = $refs.xTable
1278
+ const $xeGrid = this
1279
+ const $xeTable = $xeGrid.$refs.xTable as VxeTableConstructor & VxeTablePrivateMethods
1280
+
1281
+ const { sortData, proxyConfig } = this
1284
1282
  if (proxyConfig) {
1285
1283
  return {
1286
1284
  data: $xeTable ? $xeTable.getFullData() : [],
@@ -1294,29 +1292,29 @@ export default {
1294
1292
  }
1295
1293
  return null
1296
1294
  },
1297
- // 检查插槽
1298
- ...(process.env.VUE_APP_VXE_ENV === 'development'
1299
- ? {
1300
- loadColumn (columns: any[]) {
1301
- const { $scopedSlots } = this
1302
- XEUtils.eachTree(columns, column => {
1303
- if (column.slots) {
1304
- XEUtils.each(column.slots, (func) => {
1305
- if (!XEUtils.isFunction(func)) {
1306
- if (!$scopedSlots[func]) {
1307
- errLog('vxe.error.notSlot', [func])
1308
- }
1309
- }
1310
- })
1295
+ loadColumn (columns: any[]) {
1296
+ const $xeGrid = this
1297
+ const $xeTable = $xeGrid.$refs.xTable as VxeTableConstructor & VxeTablePrivateMethods
1298
+
1299
+ const { $scopedSlots } = this
1300
+ XEUtils.eachTree(columns, column => {
1301
+ if (column.slots) {
1302
+ XEUtils.each(column.slots, (func) => {
1303
+ if (!XEUtils.isFunction(func)) {
1304
+ if (!$scopedSlots[func]) {
1305
+ errLog('vxe.error.notSlot', [func])
1311
1306
  }
1312
- })
1313
- return this.$refs.xTable.loadColumn(columns)
1314
- },
1315
- reloadColumn (columns: any[]) {
1316
- this.clearAll()
1317
- return this.loadColumn(columns)
1318
- }
1307
+ }
1308
+ })
1319
1309
  }
1320
- : null)
1310
+ })
1311
+ return $xeTable.loadColumn(columns)
1312
+ },
1313
+ reloadColumn (columns: any[]) {
1314
+ const $xeGrid = this
1315
+
1316
+ $xeGrid.clearAll()
1317
+ return $xeGrid.loadColumn(columns)
1318
+ }
1321
1319
  } as any
1322
1320
  }
@@ -84,10 +84,8 @@ function insertTreeRow ($xeTable: VxeTableConstructor & VxeTablePrivateMethods,
84
84
  fullDataRowIdData[rowid] = rest
85
85
  fullAllDataRowIdData[rowid] = rest
86
86
  } else {
87
- if (process.env.VUE_APP_VXE_ENV === 'development') {
88
- if (parentRowId) {
89
- warnLog('vxe.error.unableInsert')
90
- }
87
+ if (parentRowId) {
88
+ warnLog('vxe.error.unableInsert')
91
89
  }
92
90
  afterFullData[funcName](item)
93
91
  tableFullTreeData[funcName](item)
@@ -166,11 +164,9 @@ function handleInsertRowAt ($xeTable: VxeTableConstructor & VxeTablePrivateMetho
166
164
  const parentLevel = parentRest ? parentRest.level : 0
167
165
  newRecords.forEach((item: any, i: any) => {
168
166
  const rowid = getRowid($xeTable, item)
169
- if (process.env.VUE_APP_VXE_ENV === 'development') {
170
- if (item[treeOpts.parentField]) {
171
- if (parentRow && item[treeOpts.parentField] !== parentRow[rowField]) {
172
- errLog('vxe.error.errProp', [`${treeOpts.parentField}=${item[treeOpts.parentField]}`, `${treeOpts.parentField}=${parentRow[rowField]}`])
173
- }
167
+ if (item[treeOpts.parentField]) {
168
+ if (parentRow && item[treeOpts.parentField] !== parentRow[rowField]) {
169
+ errLog('vxe.error.errProp', [`${treeOpts.parentField}=${item[treeOpts.parentField]}`, `${treeOpts.parentField}=${parentRow[rowField]}`])
174
170
  }
175
171
  }
176
172
  if (parentRow) {
@@ -199,9 +195,7 @@ function handleInsertRowAt ($xeTable: VxeTableConstructor & VxeTablePrivateMetho
199
195
  }
200
196
  }
201
197
  } else {
202
- if (process.env.VUE_APP_VXE_ENV === 'development') {
203
- warnLog('vxe.error.unableInsert')
204
- }
198
+ warnLog('vxe.error.unableInsert')
205
199
  insertTreeRow($xeTable, newRecords, true)
206
200
  }
207
201
  } else {
@@ -745,9 +739,7 @@ export default {
745
739
  syncActivedCell($xeTable)
746
740
  },
747
741
  _clearActived (row: any) {
748
- if (process.env.VUE_APP_VXE_ENV === 'development') {
749
- warnLog('vxe.error.delFunc', ['clearActived', 'clearEdit'])
750
- }
742
+ warnLog('vxe.error.delFunc', ['clearActived', 'clearEdit'])
751
743
  // 即将废弃
752
744
  return this.clearEdit(row)
753
745
  },
@@ -770,9 +762,7 @@ export default {
770
762
  _getActiveRecord () {
771
763
  const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
772
764
 
773
- if (process.env.VUE_APP_VXE_ENV === 'development') {
774
- warnLog('vxe.error.delFunc', ['getActiveRecord', 'getEditRecord'])
775
- }
765
+ warnLog('vxe.error.delFunc', ['getActiveRecord', 'getEditRecord'])
776
766
  // 即将废弃
777
767
  return $xeTable.getEditRecord()
778
768
  },
@@ -793,9 +783,7 @@ export default {
793
783
  _isActiveByRow (row: any) {
794
784
  const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
795
785
 
796
- if (process.env.VUE_APP_VXE_ENV === 'development') {
797
- warnLog('vxe.error.delFunc', ['isActiveByRow', 'isEditByRow'])
798
- }
786
+ warnLog('vxe.error.delFunc', ['isActiveByRow', 'isEditByRow'])
799
787
  // 即将废弃
800
788
  return $xeTable.isEditByRow(row)
801
789
  },
@@ -872,9 +860,7 @@ export default {
872
860
  _setActiveRow (row: any) {
873
861
  const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
874
862
 
875
- if (process.env.VUE_APP_VXE_ENV === 'development') {
876
- warnLog('vxe.error.delFunc', ['setActiveRow', 'setEditRow'])
877
- }
863
+ warnLog('vxe.error.delFunc', ['setActiveRow', 'setEditRow'])
878
864
  // 即将废弃
879
865
  return $xeTable.setEditRow(row)
880
866
  },
@@ -895,9 +881,7 @@ export default {
895
881
  return handleEditCell($xeTable, row, column, isPos)
896
882
  },
897
883
  _setActiveCell (row: any, fieldOrColumn: any) {
898
- if (process.env.VUE_APP_VXE_ENV === 'development') {
899
- warnLog('vxe.error.delFunc', ['setActiveCell', 'setEditCell'])
900
- }
884
+ warnLog('vxe.error.delFunc', ['setActiveCell', 'setEditCell'])
901
885
  // 即将废弃
902
886
  return this.setEditCell(row, fieldOrColumn)
903
887
  },
@@ -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: any) {
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: any) {
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: any, opts: any, columns: any[], datas: any[]) {
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
- saveLocalFile({ filename, type, content }).then(() => {
606
- if (opts.message !== false) {
607
- // 检测弹窗模块
608
- if (!VxeUI.modal) {
609
- errLog('vxe.error.reqModule', ['Modal'])
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
- VxeUI.modal.message({ content: getI18n('vxe.table.expSuccess'), status: 'success' })
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: any, opts: VxeTablePropTypes.ExportHandleOptions) {
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: any) {
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 { mergeFooterList, isGroup } = reactData
1261
- const { tableFullColumn, afterFullData, mergeBodyList, collectColumn } = internalData
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
- handleOptions.columnFilterMethod = ({ column }) => {
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 (process.env.VUE_APP_VXE_ENV === 'development') {
1414
- if (['xlsx', 'pdf'].includes(type)) {
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 (process.env.VUE_APP_VXE_ENV === 'development') {
1438
- if (!$xeGrid) {
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 (process.env.VUE_APP_VXE_ENV === 'development') {
1454
- if (!ajaxMethods) {
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: any, options: any) {
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: this })
1407
+ beforeImportMethod({ options: opts, $table: $xeTable })
1499
1408
  }
1500
- return handleFileImport(this, file, opts)
1409
+ return handleFileImport($xeTable, file, opts)
1501
1410
  },
1502
- _importData (options: any) {
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 readLocalFile(opts).catch(e => {
1424
+ return VxeUI.readFile(opts).catch(e => {
1514
1425
  if (afterImportMethod) {
1515
- afterImportMethod({ status: false, options: opts, $table: this })
1426
+ afterImportMethod({ status: false, options: opts, $table: $xeTable })
1516
1427
  }
1517
1428
  return Promise.reject(e)
1518
- }).then((params: any) => {
1429
+ }).then((params) => {
1519
1430
  const { file } = params
1520
- return handleFileImport(this, file, opts)
1431
+ return handleFileImport($xeTable, file, opts)
1521
1432
  })
1522
1433
  },
1523
- _saveFile (options: any) {
1524
- return saveLocalFile(options)
1434
+ _saveFile (options: {
1435
+ filename: string
1436
+ type: string
1437
+ content: string | Blob
1438
+ }) {
1439
+ return VxeUI.saveFile(options)
1525
1440
  },
1526
- _readFile (options: any) {
1527
- return readLocalFile(options)
1441
+ _readFile (options?: {
1442
+ multiple?: boolean
1443
+ types?: string[]
1444
+ message?: boolean
1445
+ }) {
1446
+ return VxeUI.readFile(options)
1528
1447
  },
1529
- _print (options: any) {
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: any) {
1635
- const { importOpts } = this
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
- }, options, importOpts)
1566
+ }, importOpts, options)
1642
1567
  const types = defOpts.types || []
1643
1568
  const modes = defOpts.modes || []
1644
- const isTree = !!this.getTreeStatus()
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 (!this.importConfig) {
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(this.importStore, {
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(this.importParams, defOpts)
1682
- if (!modeList.some((item: any) => item.value === this.importParams.mode)) {
1683
- this.importParams.mode = modeList[0].value
1606
+ Object.assign(importParams, defOpts)
1607
+ if (!modeList.some(item => item.value === importParams.mode)) {
1608
+ importParams.mode = modeList[0].value
1684
1609
  }
1685
- this.initStore.import = true
1610
+ initStore.import = true
1686
1611
  },
1687
1612
  _closeExport: handleCloseExport,
1688
1613
  _openExport (options: any) {
1689
- const { exportOpts } = this
1690
- if (!this.exportConfig) {
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(this, Object.assign({}, exportOpts, options))
1625
+ return handleExportAndPrint($xeTable, defOpts)
1694
1626
  },
1695
1627
  _closePrint: handleCloseExport,
1696
1628
  _openPrint (options: any) {
1697
- const { printOpts } = this
1698
- if (!this.printConfig) {
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(this, Object.assign({}, printOpts, options), true)
1639
+ return handleExportAndPrint($xeTable, defOpts, true)
1702
1640
  }
1703
1641
  } as any
1704
1642
  } as any
@@ -41,6 +41,7 @@ export default {
41
41
  if (column && column.filters) {
42
42
  column.filters = toFilters(options || [])
43
43
  if (isUpdate) {
44
+ // 已废弃,即将去掉事件触发 new Event('click') -> null
44
45
  return $xeTable.handleColumnConfirmFilter(column, new Event('click'))
45
46
  }
46
47
  }