vxe-table 3.12.10-beta.9 → 3.12.10
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/index.css +1 -1
- package/es/index.min.css +1 -1
- package/es/locale/lang/ar-EG.js +2 -1
- package/es/locale/lang/de-DE.js +2 -1
- package/es/locale/lang/en-US.js +4 -3
- package/es/locale/lang/es-ES.js +2 -1
- package/es/locale/lang/fr-FR.js +2 -1
- package/es/locale/lang/hu-HU.js +2 -1
- package/es/locale/lang/hy-AM.js +2 -1
- package/es/locale/lang/it-IT.js +2 -1
- package/es/locale/lang/ja-JP.js +2 -1
- package/es/locale/lang/ko-KR.js +2 -1
- package/es/locale/lang/nb-NO.js +2 -1
- package/es/locale/lang/pt-BR.js +2 -1
- package/es/locale/lang/ru-RU.js +4 -3
- package/es/locale/lang/th-TH.js +2 -1
- package/es/locale/lang/ug-CN.js +2 -1
- package/es/locale/lang/uk-UA.js +518 -517
- package/es/locale/lang/vi-VN.js +2 -1
- package/es/locale/lang/zh-CHT.js +2 -1
- package/es/locale/lang/zh-CN.js +2 -1
- package/es/style.css +1 -1
- package/es/style.min.css +1 -1
- package/es/table/module/edit/mixin.js +7 -7
- package/es/table/module/export/mixin.js +105 -69
- package/es/table/module/keyboard/mixin.js +68 -25
- package/es/table/module/menu/mixin.js +3 -1
- package/es/table/src/body.js +125 -86
- package/es/table/src/cell.js +43 -57
- package/es/table/src/column.js +43 -8
- package/es/table/src/columnInfo.js +3 -0
- package/es/table/src/footer.js +47 -6
- package/es/table/src/header.js +67 -165
- package/es/table/src/methods.js +962 -480
- package/es/table/src/props.js +14 -4
- package/es/table/src/table.js +114 -33
- package/es/table/src/util.js +73 -57
- package/es/table/style.css +246 -191
- package/es/table/style.min.css +1 -1
- package/es/ui/index.js +20 -6
- package/es/ui/src/log.js +1 -1
- package/es/vxe-table/style.css +246 -191
- package/es/vxe-table/style.min.css +1 -1
- package/lib/index.css +1 -1
- package/lib/index.min.css +1 -1
- package/lib/index.umd.js +1734 -1020
- package/lib/index.umd.min.js +1 -1
- package/lib/locale/lang/ar-EG.js +2 -1
- package/lib/locale/lang/ar-EG.min.js +1 -1
- package/lib/locale/lang/de-DE.js +2 -1
- package/lib/locale/lang/de-DE.min.js +1 -1
- package/lib/locale/lang/en-US.js +4 -3
- package/lib/locale/lang/en-US.min.js +1 -1
- package/lib/locale/lang/en-US.umd.js +4 -3
- package/lib/locale/lang/es-ES.js +2 -1
- package/lib/locale/lang/es-ES.min.js +1 -1
- package/lib/locale/lang/es-ES.umd.js +2 -1
- package/lib/locale/lang/fr-FR.js +2 -1
- package/lib/locale/lang/fr-FR.min.js +1 -1
- package/lib/locale/lang/hu-HU.js +2 -1
- package/lib/locale/lang/hu-HU.min.js +1 -1
- package/lib/locale/lang/hu-HU.umd.js +2 -1
- package/lib/locale/lang/hy-AM.js +2 -1
- package/lib/locale/lang/hy-AM.min.js +1 -1
- package/lib/locale/lang/it-IT.js +2 -1
- package/lib/locale/lang/it-IT.min.js +1 -1
- package/lib/locale/lang/ja-JP.js +2 -1
- package/lib/locale/lang/ja-JP.min.js +1 -1
- package/lib/locale/lang/ja-JP.umd.js +2 -1
- package/lib/locale/lang/ko-KR.js +2 -1
- package/lib/locale/lang/ko-KR.min.js +1 -1
- package/lib/locale/lang/ko-KR.umd.js +2 -1
- package/lib/locale/lang/nb-NO.js +2 -1
- package/lib/locale/lang/nb-NO.min.js +1 -1
- package/lib/locale/lang/pt-BR.js +2 -1
- package/lib/locale/lang/pt-BR.min.js +1 -1
- package/lib/locale/lang/pt-BR.umd.js +2 -1
- package/lib/locale/lang/ru-RU.js +4 -3
- package/lib/locale/lang/ru-RU.min.js +1 -1
- package/lib/locale/lang/ru-RU.umd.js +4 -3
- package/lib/locale/lang/th-TH.js +2 -1
- package/lib/locale/lang/th-TH.min.js +1 -1
- package/lib/locale/lang/ug-CN.js +2 -1
- package/lib/locale/lang/ug-CN.min.js +1 -1
- package/lib/locale/lang/uk-UA.js +518 -517
- package/lib/locale/lang/uk-UA.min.js +1 -1
- package/lib/locale/lang/uk-UA.umd.js +518 -517
- package/lib/locale/lang/vi-VN.js +2 -1
- package/lib/locale/lang/vi-VN.min.js +1 -1
- package/lib/locale/lang/zh-CHT.js +2 -1
- package/lib/locale/lang/zh-CHT.min.js +1 -1
- package/lib/locale/lang/zh-CHT.umd.js +2 -1
- package/lib/locale/lang/zh-CN.js +2 -1
- package/lib/locale/lang/zh-CN.min.js +1 -1
- package/lib/locale/lang/zh-CN.umd.js +2 -1
- package/lib/style.css +1 -1
- package/lib/style.min.css +1 -1
- package/lib/table/module/edit/mixin.js +7 -2
- package/lib/table/module/edit/mixin.min.js +1 -1
- package/lib/table/module/export/mixin.js +105 -64
- package/lib/table/module/export/mixin.min.js +1 -1
- package/lib/table/module/keyboard/mixin.js +73 -27
- package/lib/table/module/keyboard/mixin.min.js +1 -1
- package/lib/table/module/menu/mixin.js +3 -1
- package/lib/table/src/body.js +124 -79
- package/lib/table/src/body.min.js +1 -1
- package/lib/table/src/cell.js +32 -42
- package/lib/table/src/cell.min.js +1 -1
- package/lib/table/src/column.js +12 -0
- package/lib/table/src/column.min.js +1 -1
- package/lib/table/src/columnInfo.js +3 -0
- package/lib/table/src/columnInfo.min.js +1 -1
- package/lib/table/src/footer.js +43 -4
- package/lib/table/src/footer.min.js +1 -1
- package/lib/table/src/header.js +49 -172
- package/lib/table/src/header.min.js +1 -1
- package/lib/table/src/methods.js +1072 -538
- package/lib/table/src/methods.min.js +1 -1
- package/lib/table/src/props.js +14 -4
- package/lib/table/src/props.min.js +1 -1
- package/lib/table/src/table.js +113 -36
- package/lib/table/src/table.min.js +1 -1
- package/lib/table/src/util.js +87 -70
- package/lib/table/src/util.min.js +1 -1
- package/lib/table/style/style.css +246 -191
- package/lib/table/style/style.min.css +1 -1
- package/lib/ui/index.js +20 -6
- 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/lib/vxe-table/style/style.css +246 -191
- package/lib/vxe-table/style/style.min.css +1 -1
- package/package.json +2 -2
- package/packages/locale/lang/ar-EG.ts +2 -1
- package/packages/locale/lang/de-DE.ts +2 -1
- package/packages/locale/lang/en-US.ts +4 -3
- package/packages/locale/lang/es-ES.ts +2 -1
- package/packages/locale/lang/fr-FR.ts +2 -1
- package/packages/locale/lang/hu-HU.ts +2 -1
- package/packages/locale/lang/hy-AM.ts +2 -1
- package/packages/locale/lang/it-IT.ts +2 -1
- package/packages/locale/lang/ja-JP.ts +2 -1
- package/packages/locale/lang/ko-KR.ts +2 -1
- package/packages/locale/lang/nb-NO.ts +2 -1
- package/packages/locale/lang/pt-BR.ts +2 -1
- package/packages/locale/lang/ru-RU.ts +4 -3
- package/packages/locale/lang/th-TH.ts +2 -1
- package/packages/locale/lang/ug-CN.ts +2 -1
- package/packages/locale/lang/uk-UA.ts +518 -517
- package/packages/locale/lang/vi-VN.ts +2 -1
- package/packages/locale/lang/zh-CHT.ts +2 -1
- package/packages/locale/lang/zh-CN.ts +2 -1
- package/packages/table/module/edit/mixin.ts +7 -7
- package/packages/table/module/export/mixin.ts +138 -80
- package/packages/table/module/keyboard/mixin.ts +65 -24
- package/packages/table/module/menu/mixin.ts +4 -1
- package/packages/table/src/body.ts +136 -89
- package/packages/table/src/cell.ts +45 -67
- package/packages/table/src/column.ts +48 -10
- package/packages/table/src/columnInfo.ts +3 -0
- package/packages/table/src/footer.ts +50 -7
- package/packages/table/src/header.ts +67 -166
- package/packages/table/src/methods.ts +1007 -492
- package/packages/table/src/props.ts +16 -6
- package/packages/table/src/table.ts +124 -33
- package/packages/table/src/util.ts +82 -62
- package/packages/ui/index.ts +19 -5
- package/styles/components/table.scss +313 -274
- package/styles/theme/base.scss +4 -6
- package/styles/theme/dark.scss +1 -0
- package/styles/theme/light.scss +1 -0
- package/styles/variable.scss +1 -0
- /package/es/{iconfont.1736854649055.ttf → iconfont.1738985837413.ttf} +0 -0
- /package/es/{iconfont.1736854649055.woff → iconfont.1738985837413.woff} +0 -0
- /package/es/{iconfont.1736854649055.woff2 → iconfont.1738985837413.woff2} +0 -0
- /package/lib/{iconfont.1736854649055.ttf → iconfont.1738985837413.ttf} +0 -0
- /package/lib/{iconfont.1736854649055.woff → iconfont.1738985837413.woff} +0 -0
- /package/lib/{iconfont.1736854649055.woff2 → iconfont.1738985837413.woff2} +0 -0
|
@@ -30,7 +30,7 @@ function insertTreeRow (_vm: any, newRecords: any[], isAppend: any) {
|
|
|
30
30
|
}
|
|
31
31
|
parentChilds[funcName](item)
|
|
32
32
|
mapChilds[funcName](item)
|
|
33
|
-
const rest = { row: item, rowid, seq: -1, index: -1, _index: -1, $index: -1, treeIndex: -1, items: parentChilds, parent: parentRow, level: parentLevel + 1, height: 0, oTop: 0 }
|
|
33
|
+
const rest = { row: item, rowid, seq: -1, index: -1, _index: -1, $index: -1, treeIndex: -1, items: parentChilds, parent: parentRow, level: parentLevel + 1, height: 0, resizeHeight: 0, oTop: 0 }
|
|
34
34
|
fullDataRowIdData[rowid] = rest
|
|
35
35
|
fullAllDataRowIdData[rowid] = rest
|
|
36
36
|
} else {
|
|
@@ -41,7 +41,7 @@ function insertTreeRow (_vm: any, newRecords: any[], isAppend: any) {
|
|
|
41
41
|
}
|
|
42
42
|
afterFullData[funcName](item)
|
|
43
43
|
tableFullTreeData[funcName](item)
|
|
44
|
-
const rest = { row: item, rowid, seq: -1, index: -1, _index: -1, $index: -1, treeIndex: -1, items: tableFullTreeData, parent: null, level: 0, height: 0, oTop: 0 }
|
|
44
|
+
const rest = { row: item, rowid, seq: -1, index: -1, _index: -1, $index: -1, treeIndex: -1, items: tableFullTreeData, parent: null, level: 0, height: 0, resizeHeight: 0, oTop: 0 }
|
|
45
45
|
fullDataRowIdData[rowid] = rest
|
|
46
46
|
fullAllDataRowIdData[rowid] = rest
|
|
47
47
|
}
|
|
@@ -70,7 +70,7 @@ function handleInsertRowAt ($xeTable: any, records: any[], targetRow: any, isIns
|
|
|
70
70
|
} else {
|
|
71
71
|
newRecords.forEach(item => {
|
|
72
72
|
const rowid = getRowid($xeTable, item)
|
|
73
|
-
const rest = { row: item, rowid, seq: -1, index: -1, _index: -1, $index: -1, treeIndex: -1, items: afterFullData, parent: null, level: 0, height: 0, oTop: 0 }
|
|
73
|
+
const rest = { row: item, rowid, seq: -1, index: -1, _index: -1, $index: -1, treeIndex: -1, items: afterFullData, parent: null, level: 0, height: 0, resizeHeight: 0, oTop: 0 }
|
|
74
74
|
fullDataRowIdData[rowid] = rest
|
|
75
75
|
fullAllDataRowIdData[rowid] = rest
|
|
76
76
|
afterFullData.unshift(item)
|
|
@@ -92,7 +92,7 @@ function handleInsertRowAt ($xeTable: any, records: any[], targetRow: any, isIns
|
|
|
92
92
|
} else {
|
|
93
93
|
newRecords.forEach(item => {
|
|
94
94
|
const rowid = getRowid($xeTable, item)
|
|
95
|
-
const rest = { row: item, rowid, seq: -1, index: -1, _index: -1, $index: -1, treeIndex: -1, items: afterFullData, parent: null, level: 0, height: 0, oTop: 0 }
|
|
95
|
+
const rest = { row: item, rowid, seq: -1, index: -1, _index: -1, $index: -1, treeIndex: -1, items: afterFullData, parent: null, level: 0, height: 0, resizeHeight: 0, oTop: 0 }
|
|
96
96
|
fullDataRowIdData[rowid] = rest
|
|
97
97
|
fullAllDataRowIdData[rowid] = rest
|
|
98
98
|
afterFullData.push(item)
|
|
@@ -132,7 +132,7 @@ function handleInsertRowAt ($xeTable: any, records: any[], targetRow: any, isIns
|
|
|
132
132
|
targetIndex = targetIndex + 1
|
|
133
133
|
}
|
|
134
134
|
parentMapChilds.splice(targetIndex, 0, item)
|
|
135
|
-
const rest = { row: item, rowid, seq: -1, index: -1, _index: -1, $index: -1, treeIndex: -1, items: parentMapChilds, parent: parentRow, level: parentLevel + 1, height: 0, oTop: 0 }
|
|
135
|
+
const rest = { row: item, rowid, seq: -1, index: -1, _index: -1, $index: -1, treeIndex: -1, items: parentMapChilds, parent: parentRow, level: parentLevel + 1, height: 0, resizeHeight: 0, oTop: 0 }
|
|
136
136
|
fullDataRowIdData[rowid] = rest
|
|
137
137
|
fullAllDataRowIdData[rowid] = rest
|
|
138
138
|
})
|
|
@@ -199,7 +199,7 @@ function handleInsertRowAt ($xeTable: any, records: any[], targetRow: any, isIns
|
|
|
199
199
|
const rowid = getRowid($xeTable, newRow)
|
|
200
200
|
insertMaps[rowid] = newRow
|
|
201
201
|
})
|
|
202
|
-
$xeTable.cacheRowMap()
|
|
202
|
+
$xeTable.cacheRowMap(false)
|
|
203
203
|
$xeTable.updateScrollYStatus()
|
|
204
204
|
$xeTable.handleTableData(treeConfig && transform)
|
|
205
205
|
if (!(treeConfig && transform)) {
|
|
@@ -376,7 +376,7 @@ export default {
|
|
|
376
376
|
}
|
|
377
377
|
})
|
|
378
378
|
$xeTable.updateFooter()
|
|
379
|
-
$xeTable.cacheRowMap()
|
|
379
|
+
$xeTable.cacheRowMap(false)
|
|
380
380
|
$xeTable.handleTableData(treeConfig && transform)
|
|
381
381
|
if (!(treeConfig && transform)) {
|
|
382
382
|
$xeTable.updateAfterDataIndex()
|
|
@@ -5,7 +5,7 @@ import { parseFile, formatText, eqEmptyValue } from '../../../ui/src/utils'
|
|
|
5
5
|
import { createHtmlPage, getExportBlobByContent } from './util'
|
|
6
6
|
import { warnLog, errLog } from '../../../ui/src/log'
|
|
7
7
|
|
|
8
|
-
import type { VxeTablePropTypes, VxeGridConstructor, VxeTableDefines, TableReactData, TableInternalData, GridReactData, VxeColumnPropTypes, VxeTableConstructor } from '../../../../types'
|
|
8
|
+
import type { VxeTablePropTypes, VxeGridConstructor, VxeTableDefines, TableReactData, VxeTablePrivateMethods, TableInternalData, GridReactData, VxeColumnPropTypes, VxeTableConstructor } from '../../../../types'
|
|
9
9
|
|
|
10
10
|
const { getI18n, renderer } = VxeUI
|
|
11
11
|
|
|
@@ -643,7 +643,7 @@ function handleExport ($xeTable: any, opts: VxeTablePropTypes.ExportHandleOption
|
|
|
643
643
|
}
|
|
644
644
|
|
|
645
645
|
function getElementsByTagName (elem: any, qualifiedName: any) {
|
|
646
|
-
return elem.getElementsByTagName(qualifiedName)
|
|
646
|
+
return elem.getElementsByTagName(qualifiedName) as HTMLElement[]
|
|
647
647
|
}
|
|
648
648
|
|
|
649
649
|
function getTxtCellKey (now: any) {
|
|
@@ -659,32 +659,50 @@ function getTxtCellValue (val: any, vMaps: any) {
|
|
|
659
659
|
return rest.replace(/^"+$/g, (qVal: any) => '"'.repeat(Math.ceil(qVal.length / 2)))
|
|
660
660
|
}
|
|
661
661
|
|
|
662
|
-
function
|
|
662
|
+
function toExportField (tableConf: {
|
|
663
|
+
fieldMaps: Record<string, VxeTableDefines.ColumnInfo>
|
|
664
|
+
titleMaps: Record<string, VxeTableDefines.ColumnInfo>
|
|
665
|
+
}, field: string) {
|
|
666
|
+
const { fieldMaps, titleMaps } = tableConf
|
|
667
|
+
// title 转 field
|
|
668
|
+
if (!fieldMaps[field]) {
|
|
669
|
+
const teCol = titleMaps[field]
|
|
670
|
+
if (teCol && teCol.field) {
|
|
671
|
+
field = teCol.field
|
|
672
|
+
}
|
|
673
|
+
}
|
|
674
|
+
return field
|
|
675
|
+
}
|
|
676
|
+
|
|
677
|
+
function parseCsvAndTxt (tableConf: {
|
|
678
|
+
fieldMaps: Record<string, VxeTableDefines.ColumnInfo>
|
|
679
|
+
titleMaps: Record<string, VxeTableDefines.ColumnInfo>
|
|
680
|
+
}, content: string, cellSeparator: string) {
|
|
663
681
|
const list = content.split(enterSymbol)
|
|
664
682
|
const rows: any[] = []
|
|
665
|
-
let fields
|
|
683
|
+
let fields: string[] = []
|
|
666
684
|
if (list.length) {
|
|
667
685
|
const vMaps: any = {}
|
|
668
686
|
const now = Date.now()
|
|
669
|
-
list.forEach((rVal
|
|
687
|
+
list.forEach((rVal) => {
|
|
670
688
|
if (rVal) {
|
|
671
689
|
const item: any = {}
|
|
672
|
-
rVal = rVal.replace(/("")|(\n)/g, (text:
|
|
690
|
+
rVal = rVal.replace(/("")|(\n)/g, (text: string, dVal: string) => {
|
|
673
691
|
const key = getTxtCellKey(now)
|
|
674
692
|
vMaps[key] = dVal ? '"' : '\n'
|
|
675
693
|
return key
|
|
676
|
-
}).replace(/"(.*?)"/g, (text:
|
|
694
|
+
}).replace(/"(.*?)"/g, (text: string, cVal: string) => {
|
|
677
695
|
const key = getTxtCellKey(now)
|
|
678
696
|
vMaps[key] = replaceTxtCell(cVal, vMaps)
|
|
679
697
|
return key
|
|
680
698
|
})
|
|
681
|
-
const cells = rVal.split(cellSeparator)
|
|
699
|
+
const cells: string[] = rVal.split(cellSeparator)
|
|
682
700
|
if (!fields.length) {
|
|
683
|
-
fields = cells.map((val:
|
|
701
|
+
fields = cells.map((val: string) => toExportField(tableConf, getTxtCellValue(val.trim(), vMaps)))
|
|
684
702
|
} else {
|
|
685
|
-
cells.forEach((val
|
|
703
|
+
cells.forEach((val, colIndex) => {
|
|
686
704
|
if (colIndex < fields.length) {
|
|
687
|
-
item[fields[colIndex]] = getTxtCellValue(val, vMaps)
|
|
705
|
+
item[fields[colIndex]] = getTxtCellValue(val.trim(), vMaps)
|
|
688
706
|
}
|
|
689
707
|
})
|
|
690
708
|
rows.push(item)
|
|
@@ -695,35 +713,44 @@ function parseCsvAndTxt (columns: any, content: any, cellSeparator: any) {
|
|
|
695
713
|
return { fields, rows }
|
|
696
714
|
}
|
|
697
715
|
|
|
698
|
-
function parseCsv (
|
|
699
|
-
|
|
716
|
+
function parseCsv (tableConf: {
|
|
717
|
+
fieldMaps: Record<string, VxeTableDefines.ColumnInfo>
|
|
718
|
+
titleMaps: Record<string, VxeTableDefines.ColumnInfo>
|
|
719
|
+
}, content: string) {
|
|
720
|
+
return parseCsvAndTxt(tableConf, content, ',')
|
|
700
721
|
}
|
|
701
722
|
|
|
702
|
-
function parseTxt (
|
|
703
|
-
|
|
723
|
+
function parseTxt (tableConf: {
|
|
724
|
+
fieldMaps: Record<string, VxeTableDefines.ColumnInfo>
|
|
725
|
+
titleMaps: Record<string, VxeTableDefines.ColumnInfo>
|
|
726
|
+
}, content: string) {
|
|
727
|
+
return parseCsvAndTxt(tableConf, content, '\t')
|
|
704
728
|
}
|
|
705
729
|
|
|
706
|
-
function parseHTML (
|
|
730
|
+
function parseHTML (tableConf: {
|
|
731
|
+
fieldMaps: Record<string, VxeTableDefines.ColumnInfo>
|
|
732
|
+
titleMaps: Record<string, VxeTableDefines.ColumnInfo>
|
|
733
|
+
}, content: string) {
|
|
707
734
|
const domParser = new DOMParser()
|
|
708
735
|
const xmlDoc = domParser.parseFromString(content, 'text/html')
|
|
709
736
|
const bodyNodes = getElementsByTagName(xmlDoc, 'body')
|
|
710
|
-
const rows
|
|
711
|
-
const fields:
|
|
737
|
+
const rows: any[] = []
|
|
738
|
+
const fields: string[] = []
|
|
712
739
|
if (bodyNodes.length) {
|
|
713
740
|
const tableNodes = getElementsByTagName(bodyNodes[0], 'table')
|
|
714
741
|
if (tableNodes.length) {
|
|
715
742
|
const theadNodes = getElementsByTagName(tableNodes[0], 'thead')
|
|
716
743
|
if (theadNodes.length) {
|
|
717
|
-
XEUtils.arrayEach(getElementsByTagName(theadNodes[0], 'tr'),
|
|
718
|
-
XEUtils.arrayEach(getElementsByTagName(rowNode, 'th'),
|
|
719
|
-
fields.push(cellNode.textContent)
|
|
744
|
+
XEUtils.arrayEach(getElementsByTagName(theadNodes[0], 'tr'), rowNode => {
|
|
745
|
+
XEUtils.arrayEach(getElementsByTagName(rowNode, 'th'), cellNode => {
|
|
746
|
+
fields.push(toExportField(tableConf, cellNode.textContent || ''))
|
|
720
747
|
})
|
|
721
748
|
})
|
|
722
749
|
const tbodyNodes = getElementsByTagName(tableNodes[0], 'tbody')
|
|
723
750
|
if (tbodyNodes.length) {
|
|
724
751
|
XEUtils.arrayEach(getElementsByTagName(tbodyNodes[0], 'tr'), rowNode => {
|
|
725
|
-
const item
|
|
726
|
-
XEUtils.arrayEach(getElementsByTagName(rowNode, 'td'), (cellNode
|
|
752
|
+
const item: any = {}
|
|
753
|
+
XEUtils.arrayEach(getElementsByTagName(rowNode, 'td'), (cellNode, colIndex) => {
|
|
727
754
|
if (fields[colIndex]) {
|
|
728
755
|
item[fields[colIndex]] = cellNode.textContent || ''
|
|
729
756
|
}
|
|
@@ -737,25 +764,28 @@ function parseHTML (columns: any, content: any) {
|
|
|
737
764
|
return { fields, rows }
|
|
738
765
|
}
|
|
739
766
|
|
|
740
|
-
function parseXML (
|
|
767
|
+
function parseXML (tableConf: {
|
|
768
|
+
fieldMaps: Record<string, VxeTableDefines.ColumnInfo>
|
|
769
|
+
titleMaps: Record<string, VxeTableDefines.ColumnInfo>
|
|
770
|
+
}, content: string) {
|
|
741
771
|
const domParser = new DOMParser()
|
|
742
772
|
const xmlDoc = domParser.parseFromString(content, 'application/xml')
|
|
743
773
|
const sheetNodes = getElementsByTagName(xmlDoc, 'Worksheet')
|
|
744
774
|
const rows: any[] = []
|
|
745
|
-
const fields
|
|
775
|
+
const fields: string[] = []
|
|
746
776
|
if (sheetNodes.length) {
|
|
747
777
|
const tableNodes = getElementsByTagName(sheetNodes[0], 'Table')
|
|
748
778
|
if (tableNodes.length) {
|
|
749
779
|
const rowNodes = getElementsByTagName(tableNodes[0], 'Row')
|
|
750
780
|
if (rowNodes.length) {
|
|
751
|
-
XEUtils.arrayEach(getElementsByTagName(rowNodes[0], 'Cell'),
|
|
752
|
-
fields.push(cellNode.textContent)
|
|
781
|
+
XEUtils.arrayEach(getElementsByTagName(rowNodes[0], 'Cell'), cellNode => {
|
|
782
|
+
fields.push(toExportField(tableConf, cellNode.textContent || ''))
|
|
753
783
|
})
|
|
754
784
|
XEUtils.arrayEach(rowNodes, (rowNode, index) => {
|
|
755
785
|
if (index) {
|
|
756
|
-
const item
|
|
786
|
+
const item: any = {}
|
|
757
787
|
const cellNodes = getElementsByTagName(rowNode, 'Cell')
|
|
758
|
-
XEUtils.arrayEach(cellNodes, (cellNode
|
|
788
|
+
XEUtils.arrayEach(cellNodes, (cellNode, colIndex) => {
|
|
759
789
|
if (fields[colIndex]) {
|
|
760
790
|
item[fields[colIndex]] = cellNode.textContent
|
|
761
791
|
}
|
|
@@ -769,51 +799,56 @@ function parseXML (columns: any, content: any) {
|
|
|
769
799
|
return { fields, rows }
|
|
770
800
|
}
|
|
771
801
|
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
802
|
+
function handleImport ($xeTable: VxeTableConstructor & VxeTablePrivateMethods, content: any, opts: any) {
|
|
803
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
804
|
+
|
|
805
|
+
const { tableFullColumn, _importResolve, _importReject } = internalData
|
|
806
|
+
let rest: {
|
|
807
|
+
fields: string[];
|
|
808
|
+
rows: any[];
|
|
809
|
+
} = { fields: [], rows: [] }
|
|
810
|
+
const tableFieldMaps: Record<string, VxeTableDefines.ColumnInfo> = {}
|
|
811
|
+
const tableTitleMaps: Record<string, VxeTableDefines.ColumnInfo> = {}
|
|
812
|
+
tableFullColumn.forEach((column) => {
|
|
780
813
|
const field = column.field
|
|
814
|
+
const title = column.getTitle()
|
|
781
815
|
if (field) {
|
|
782
|
-
|
|
816
|
+
tableFieldMaps[field] = column
|
|
817
|
+
}
|
|
818
|
+
if (title) {
|
|
819
|
+
tableTitleMaps[column.getTitle()] = column
|
|
783
820
|
}
|
|
784
821
|
})
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
const { tableFullColumn, _importResolve, _importReject } = $xetable
|
|
790
|
-
let rest: any = { fields: [], rows: [] }
|
|
822
|
+
const tableConf = {
|
|
823
|
+
fieldMaps: tableFieldMaps,
|
|
824
|
+
titleMaps: tableTitleMaps
|
|
825
|
+
}
|
|
791
826
|
switch (opts.type) {
|
|
792
827
|
case 'csv':
|
|
793
|
-
rest = parseCsv(
|
|
828
|
+
rest = parseCsv(tableConf, content)
|
|
794
829
|
break
|
|
795
830
|
case 'txt':
|
|
796
|
-
rest = parseTxt(
|
|
831
|
+
rest = parseTxt(tableConf, content)
|
|
797
832
|
break
|
|
798
833
|
case 'html':
|
|
799
|
-
rest = parseHTML(
|
|
834
|
+
rest = parseHTML(tableConf, content)
|
|
800
835
|
break
|
|
801
836
|
case 'xml':
|
|
802
|
-
rest = parseXML(
|
|
837
|
+
rest = parseXML(tableConf, content)
|
|
803
838
|
break
|
|
804
839
|
}
|
|
805
840
|
const { fields, rows } = rest
|
|
806
|
-
const status =
|
|
841
|
+
const status = fields.some(field => tableFieldMaps[field] || tableTitleMaps[field])
|
|
807
842
|
if (status) {
|
|
808
|
-
$
|
|
843
|
+
$xeTable.createData(rows)
|
|
809
844
|
.then((data: any) => {
|
|
810
845
|
let loadRest
|
|
811
846
|
if (opts.mode === 'insert' || opts.mode === 'insertBottom') {
|
|
812
|
-
loadRest = $
|
|
847
|
+
loadRest = $xeTable.insertAt(data, -1)
|
|
813
848
|
} if (opts.mode === 'insertTop') {
|
|
814
|
-
loadRest = $
|
|
849
|
+
loadRest = $xeTable.insert(data)
|
|
815
850
|
} else {
|
|
816
|
-
loadRest = $
|
|
851
|
+
loadRest = $xeTable.reloadData(data)
|
|
817
852
|
}
|
|
818
853
|
if (opts.message !== false) {
|
|
819
854
|
// 检测弹窗模块
|
|
@@ -984,6 +1019,45 @@ export function readLocalFile (options: any = {}) {
|
|
|
984
1019
|
})
|
|
985
1020
|
}
|
|
986
1021
|
|
|
1022
|
+
function handleFilterColumns (exportOpts: VxeTablePropTypes.ExportConfig, column: VxeTableDefines.ColumnInfo, columns: VxeTableDefines.ColumnInfo[] | VxeTablePropTypes.ExportOrPrintColumnOption[]) {
|
|
1023
|
+
return columns.some((item: any) => {
|
|
1024
|
+
if (isColumnInfo(item)) {
|
|
1025
|
+
return column.id === (item as any).id
|
|
1026
|
+
} else if (XEUtils.isString(item)) {
|
|
1027
|
+
return column.field === item
|
|
1028
|
+
} else {
|
|
1029
|
+
const colid = item.id || item.colId
|
|
1030
|
+
const type = item.type
|
|
1031
|
+
const field = item.field
|
|
1032
|
+
if (colid) {
|
|
1033
|
+
return column.id === colid
|
|
1034
|
+
} else if (field && type) {
|
|
1035
|
+
return column.field === field && column.type === type
|
|
1036
|
+
} else if (field) {
|
|
1037
|
+
return column.field === field
|
|
1038
|
+
} else if (type) {
|
|
1039
|
+
return column.type === type
|
|
1040
|
+
}
|
|
1041
|
+
}
|
|
1042
|
+
return false
|
|
1043
|
+
})
|
|
1044
|
+
}
|
|
1045
|
+
|
|
1046
|
+
function handleFilterFields (exportOpts: VxeTablePropTypes.ExportConfig, column: VxeTableDefines.ColumnInfo, includeFields: string[] | undefined, excludeFields: string[] | undefined) {
|
|
1047
|
+
if (excludeFields) {
|
|
1048
|
+
if (XEUtils.includes(excludeFields, column.field)) {
|
|
1049
|
+
return false
|
|
1050
|
+
}
|
|
1051
|
+
}
|
|
1052
|
+
if (includeFields) {
|
|
1053
|
+
if (XEUtils.includes(includeFields, column.field)) {
|
|
1054
|
+
return true
|
|
1055
|
+
}
|
|
1056
|
+
return false
|
|
1057
|
+
}
|
|
1058
|
+
return exportOpts.original ? column.field : defaultFilterExportColumn(column)
|
|
1059
|
+
}
|
|
1060
|
+
|
|
987
1061
|
function handleExportAndPrint ($xeTable: VxeTableConstructor, options: VxeTablePropTypes.ExportOpts | VxeTablePropTypes.ExportConfig, isPrint?: any) {
|
|
988
1062
|
const props = $xeTable
|
|
989
1063
|
const reactData = $xeTable as unknown as TableReactData
|
|
@@ -1014,7 +1088,7 @@ function handleExportAndPrint ($xeTable: VxeTableConstructor, options: VxeTableP
|
|
|
1014
1088
|
const modes = defOpts.modes || []
|
|
1015
1089
|
const checkMethod = customOpts.checkMethod
|
|
1016
1090
|
const exportColumns = collectColumn.slice(0)
|
|
1017
|
-
const { columns } = defOpts
|
|
1091
|
+
const { columns, excludeFields, includeFields } = defOpts
|
|
1018
1092
|
// 处理类型
|
|
1019
1093
|
const typeList = types.map((value) => {
|
|
1020
1094
|
return {
|
|
@@ -1037,33 +1111,17 @@ function handleExportAndPrint ($xeTable: VxeTableConstructor, options: VxeTableP
|
|
|
1037
1111
|
// 默认选中
|
|
1038
1112
|
XEUtils.eachTree(exportColumns, (column, index, items, path, parent) => {
|
|
1039
1113
|
const isColGroup = column.children && column.children.length
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
} else {
|
|
1048
|
-
const colid = item.id || item.colId
|
|
1049
|
-
const type = item.type
|
|
1050
|
-
const field = item.field
|
|
1051
|
-
if (colid) {
|
|
1052
|
-
return column.id === colid
|
|
1053
|
-
} else if (field && type) {
|
|
1054
|
-
return column.field === field && column.type === type
|
|
1055
|
-
} else if (field) {
|
|
1056
|
-
return column.field === field
|
|
1057
|
-
} else if (type) {
|
|
1058
|
-
return column.type === type
|
|
1059
|
-
}
|
|
1060
|
-
}
|
|
1061
|
-
return false
|
|
1062
|
-
})
|
|
1063
|
-
: column.visible
|
|
1064
|
-
column.halfChecked = false
|
|
1065
|
-
column.disabled = (parent && parent.disabled) || (checkMethod ? !checkMethod({ column }) : false)
|
|
1114
|
+
let isChecked = false
|
|
1115
|
+
if (columns && columns.length) {
|
|
1116
|
+
isChecked = handleFilterColumns(defOpts, column, columns)
|
|
1117
|
+
} else if (excludeFields || includeFields) {
|
|
1118
|
+
isChecked = handleFilterFields(defOpts, column, includeFields, excludeFields)
|
|
1119
|
+
} else {
|
|
1120
|
+
isChecked = column.visible && (isColGroup || defaultFilterExportColumn(column))
|
|
1066
1121
|
}
|
|
1122
|
+
column.checked = isChecked
|
|
1123
|
+
column.halfChecked = false
|
|
1124
|
+
column.disabled = (parent && parent.disabled) || (checkMethod ? !checkMethod({ column }) : false)
|
|
1067
1125
|
})
|
|
1068
1126
|
// 更新条件
|
|
1069
1127
|
Object.assign(exportStore, {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import XEUtils from 'xe-utils'
|
|
2
|
+
import { getRefElem } from '../../src/util'
|
|
2
3
|
import { browse, hasClass, getAbsolutePos, addClass, removeClass } from '../../../ui/src/dom'
|
|
3
4
|
|
|
4
5
|
function getTargetOffset (target: any, container: any) {
|
|
@@ -24,33 +25,62 @@ function getTargetOffset (target: any, container: any) {
|
|
|
24
25
|
}
|
|
25
26
|
|
|
26
27
|
function getCheckboxRangeRows ($xeTable: any, evnt: MouseEvent, params: any, targetTrElem: HTMLElement, trRect: DOMRect, offsetClientTop: number, moveRange: number) {
|
|
28
|
+
const props = $xeTable
|
|
27
29
|
const reactData = $xeTable
|
|
28
30
|
const internalData = $xeTable
|
|
29
31
|
|
|
32
|
+
const { showOverflow } = props
|
|
33
|
+
const { fullAllDataRowIdData, isResizeCellHeight } = internalData
|
|
34
|
+
const rowOpts = $xeTable.computeRowOpts
|
|
35
|
+
const cellOpts = $xeTable.computeCellOpts
|
|
36
|
+
const defaultRowHeight = $xeTable.computeDefaultRowHeight
|
|
37
|
+
const { row } = params
|
|
30
38
|
let countHeight = 0
|
|
31
39
|
let rangeRows: any[] = []
|
|
32
40
|
let moveSize = 0
|
|
33
41
|
const isDown = moveRange > 0
|
|
34
|
-
const { scrollYLoad
|
|
42
|
+
const { scrollYLoad } = reactData
|
|
35
43
|
const { afterFullData } = internalData
|
|
44
|
+
if (isDown) {
|
|
45
|
+
moveSize = offsetClientTop + moveRange
|
|
46
|
+
} else {
|
|
47
|
+
moveSize = (trRect.height - offsetClientTop) + Math.abs(moveRange)
|
|
48
|
+
}
|
|
36
49
|
if (scrollYLoad) {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
50
|
+
const _rowIndex = $xeTable.getVTRowIndex(row)
|
|
51
|
+
const isCustomCellHeight = isResizeCellHeight || cellOpts.height || rowOpts.height
|
|
52
|
+
if (!isCustomCellHeight && showOverflow) {
|
|
53
|
+
if (isDown) {
|
|
54
|
+
rangeRows = afterFullData.slice(_rowIndex, _rowIndex + Math.ceil(moveSize / defaultRowHeight))
|
|
55
|
+
} else {
|
|
56
|
+
rangeRows = afterFullData.slice(_rowIndex - Math.floor(moveSize / defaultRowHeight), _rowIndex + 1)
|
|
57
|
+
}
|
|
45
58
|
} else {
|
|
46
|
-
|
|
59
|
+
if (isDown) {
|
|
60
|
+
for (let i = _rowIndex; i < afterFullData.length; i++) {
|
|
61
|
+
const item = afterFullData[i]
|
|
62
|
+
const rowid = $xeTable.getRowid(item)
|
|
63
|
+
const rowRest = fullAllDataRowIdData[rowid] || {}
|
|
64
|
+
countHeight += rowRest.resizeHeight || cellOpts.height || rowOpts.height || defaultRowHeight
|
|
65
|
+
rangeRows.push(item)
|
|
66
|
+
if (countHeight > moveSize) {
|
|
67
|
+
return rangeRows
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
} else {
|
|
71
|
+
for (let len = _rowIndex; len >= 0; len--) {
|
|
72
|
+
const item = afterFullData[len]
|
|
73
|
+
const rowid = $xeTable.getRowid(item)
|
|
74
|
+
const rowRest = fullAllDataRowIdData[rowid] || {}
|
|
75
|
+
countHeight += rowRest.resizeHeight || cellOpts.height || rowOpts.height || defaultRowHeight
|
|
76
|
+
rangeRows.push(item)
|
|
77
|
+
if (countHeight > moveSize) {
|
|
78
|
+
return rangeRows
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
47
82
|
}
|
|
48
83
|
} else {
|
|
49
|
-
if (isDown) {
|
|
50
|
-
moveSize = evnt.clientY - trRect.y
|
|
51
|
-
} else {
|
|
52
|
-
moveSize = trRect.y - evnt.clientY + trRect.height
|
|
53
|
-
}
|
|
54
84
|
const siblingProp = isDown ? 'next' : 'previous'
|
|
55
85
|
while (targetTrElem && countHeight < moveSize) {
|
|
56
86
|
const rowNodeRest = $xeTable.getRowNode(targetTrElem)
|
|
@@ -203,16 +233,27 @@ export default {
|
|
|
203
233
|
},
|
|
204
234
|
handleCheckboxRangeEvent (evnt: any, params: any) {
|
|
205
235
|
const $xeTable = this
|
|
236
|
+
const internalData = $xeTable
|
|
206
237
|
|
|
238
|
+
const { elemStore } = internalData
|
|
239
|
+
const bodyScrollElem = getRefElem(elemStore['main-body-scroll'])
|
|
240
|
+
const leftScrollElem = getRefElem(elemStore['left-body-scroll'])
|
|
241
|
+
const rightScrollElem = getRefElem(elemStore['right-body-scroll'])
|
|
207
242
|
const { column, cell } = params
|
|
208
243
|
if (column.type === 'checkbox') {
|
|
209
|
-
|
|
244
|
+
let bodyWrapperElem = bodyScrollElem as HTMLElement
|
|
245
|
+
if (leftScrollElem && column.fixed === 'left') {
|
|
246
|
+
bodyWrapperElem = leftScrollElem
|
|
247
|
+
} else if (rightScrollElem && column.fixed === 'right') {
|
|
248
|
+
bodyWrapperElem = rightScrollElem
|
|
249
|
+
}
|
|
250
|
+
if (!bodyWrapperElem) {
|
|
251
|
+
return
|
|
252
|
+
}
|
|
253
|
+
const el = $xeTable.$refs.refElem as HTMLDivElement
|
|
210
254
|
const disX = evnt.clientX
|
|
211
255
|
const disY = evnt.clientY
|
|
212
|
-
const
|
|
213
|
-
const checkboxRangeElem = bodyWrapperElem.querySelector('.vxe-table--checkbox-range')
|
|
214
|
-
const domMousemove = document.onmousemove
|
|
215
|
-
const domMouseup = document.onmouseup
|
|
256
|
+
const checkboxRangeElem = bodyWrapperElem.querySelector('.vxe-table--checkbox-range') as HTMLElement
|
|
216
257
|
const trElem = cell.parentNode
|
|
217
258
|
const selectRecords = this.getCheckboxRecords()
|
|
218
259
|
let lastRangeRows = []
|
|
@@ -312,7 +353,7 @@ export default {
|
|
|
312
353
|
}
|
|
313
354
|
}, 50)
|
|
314
355
|
}
|
|
315
|
-
addClass(
|
|
356
|
+
addClass(el, 'drag--range')
|
|
316
357
|
document.onmousemove = evnt => {
|
|
317
358
|
evnt.preventDefault()
|
|
318
359
|
evnt.stopPropagation()
|
|
@@ -338,10 +379,10 @@ export default {
|
|
|
338
379
|
}
|
|
339
380
|
document.onmouseup = (evnt) => {
|
|
340
381
|
stopMouseScroll()
|
|
341
|
-
removeClass(
|
|
382
|
+
removeClass(el, 'drag--range')
|
|
342
383
|
checkboxRangeElem.removeAttribute('style')
|
|
343
|
-
document.onmousemove =
|
|
344
|
-
document.onmouseup =
|
|
384
|
+
document.onmousemove = null
|
|
385
|
+
document.onmouseup = null
|
|
345
386
|
triggerEvent('end', evnt)
|
|
346
387
|
}
|
|
347
388
|
triggerEvent('start', evnt)
|
|
@@ -55,6 +55,9 @@ export default {
|
|
|
55
55
|
* 快捷菜单事件处理
|
|
56
56
|
*/
|
|
57
57
|
handleGlobalContextmenuEvent (evnt: any) {
|
|
58
|
+
const $xeTable = this
|
|
59
|
+
const internalData = $xeTable
|
|
60
|
+
|
|
58
61
|
const { $refs, tId, editStore, menuConfig, contextMenu, ctxMenuStore, ctxMenuOpts, mouseConfig, mouseOpts } = this
|
|
59
62
|
const { selected } = editStore
|
|
60
63
|
const layoutList = ['header', 'body', 'footer']
|
|
@@ -63,7 +66,7 @@ export default {
|
|
|
63
66
|
evnt.preventDefault()
|
|
64
67
|
return
|
|
65
68
|
}
|
|
66
|
-
if (
|
|
69
|
+
if (internalData._keyCtx) {
|
|
67
70
|
const type = 'body'
|
|
68
71
|
const params: any = { type, $grid: this.$xegrid, $table: this, keyboard: true, columns: this.visibleColumn.slice(0), $event: evnt }
|
|
69
72
|
// 如果开启单元格区域
|