vxe-pc-ui 3.15.11 → 3.15.13
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/collapse/src/collapse.js +72 -36
- package/es/components.js +6 -0
- package/es/date-picker/src/date-picker.js +1 -0
- package/es/icon/style.css +1 -1
- package/es/image/src/image.js +14 -14
- package/es/language/ar-EG.js +4 -0
- package/es/language/de-DE.js +4 -0
- package/es/language/en-US.js +5 -1
- package/es/language/es-ES.js +4 -0
- package/es/language/fr-FR.js +4 -0
- package/es/language/hu-HU.js +4 -0
- package/es/language/hy-AM.js +4 -0
- package/es/language/id-ID.js +4 -0
- package/es/language/it-IT.js +4 -0
- package/es/language/ja-JP.js +4 -0
- package/es/language/ko-KR.js +4 -0
- package/es/language/ms-MY.js +4 -0
- package/es/language/nb-NO.js +4 -0
- package/es/language/pt-BR.js +4 -0
- package/es/language/ru-RU.js +4 -0
- package/es/language/th-TH.js +4 -0
- package/es/language/ug-CN.js +4 -0
- package/es/language/uk-UA.js +4 -0
- package/es/language/uz-UZ.js +4 -0
- package/es/language/vi-VN.js +4 -0
- package/es/language/zh-CHT.js +4 -0
- package/es/language/zh-CN.js +4 -0
- package/es/list/src/list.js +1260 -32
- package/es/list/src/store.js +8 -0
- package/es/list/style.css +333 -0
- package/es/list/style.min.css +1 -1
- package/es/print/src/util.js +1 -1
- package/es/pulldown/src/pulldown.js +4 -4
- package/es/style.css +1 -1
- package/es/style.min.css +1 -1
- package/es/table-transfer/index.js +12 -0
- package/es/table-transfer/src/table-transfer.js +71 -0
- package/es/table-transfer/style.css +0 -0
- package/es/table-transfer/style.min.css +0 -0
- package/es/transfer/index.js +12 -0
- package/es/transfer/src/transfer.js +86 -0
- package/es/transfer/style.css +0 -0
- package/es/transfer/style.min.css +0 -0
- package/es/tree/src/tree.js +20 -26
- package/es/tree/src/util.js +0 -7
- package/es/tree-select/src/tree-select.js +8 -7
- package/es/ui/index.js +14 -2
- package/es/ui/src/log.js +1 -1
- package/es/ui/src/utils.js +12 -0
- package/es/vxe-list/style.css +333 -0
- package/es/vxe-list/style.min.css +1 -1
- package/es/vxe-table-transfer/index.js +3 -0
- package/es/vxe-table-transfer/style.css +0 -0
- package/es/vxe-table-transfer/style.min.css +0 -0
- package/es/vxe-transfer/index.js +3 -0
- package/es/vxe-transfer/style.css +0 -0
- package/es/vxe-transfer/style.min.css +0 -0
- package/lib/collapse/src/collapse.js +74 -37
- package/lib/collapse/src/collapse.min.js +1 -1
- package/lib/components.js +25 -1
- package/lib/components.min.js +1 -1
- package/lib/date-picker/src/date-picker.js +1 -0
- package/lib/date-picker/src/date-picker.min.js +1 -1
- package/lib/icon/style/style.css +1 -1
- package/lib/icon/style/style.min.css +1 -1
- package/lib/image/src/image.js +17 -17
- package/lib/image/src/image.min.js +1 -1
- package/lib/index.umd.js +1792 -202
- package/lib/index.umd.min.js +1 -1
- package/lib/language/ar-EG.js +4 -0
- package/lib/language/ar-EG.min.js +1 -1
- package/lib/language/ar-EG.umd.js +4 -0
- package/lib/language/de-DE.js +4 -0
- package/lib/language/de-DE.min.js +1 -1
- package/lib/language/de-DE.umd.js +4 -0
- package/lib/language/en-US.js +5 -1
- package/lib/language/en-US.min.js +1 -1
- package/lib/language/en-US.umd.js +5 -1
- package/lib/language/es-ES.js +4 -0
- package/lib/language/es-ES.min.js +1 -1
- package/lib/language/es-ES.umd.js +4 -0
- package/lib/language/fr-FR.js +4 -0
- package/lib/language/fr-FR.min.js +1 -1
- package/lib/language/fr-FR.umd.js +4 -0
- package/lib/language/hu-HU.js +4 -0
- package/lib/language/hu-HU.min.js +1 -1
- package/lib/language/hu-HU.umd.js +4 -0
- package/lib/language/hy-AM.js +4 -0
- package/lib/language/hy-AM.min.js +1 -1
- package/lib/language/hy-AM.umd.js +4 -0
- package/lib/language/id-ID.js +4 -0
- package/lib/language/id-ID.min.js +1 -1
- package/lib/language/id-ID.umd.js +4 -0
- package/lib/language/it-IT.js +4 -0
- package/lib/language/it-IT.min.js +1 -1
- package/lib/language/it-IT.umd.js +4 -0
- package/lib/language/ja-JP.js +4 -0
- package/lib/language/ja-JP.min.js +1 -1
- package/lib/language/ja-JP.umd.js +4 -0
- package/lib/language/ko-KR.js +4 -0
- package/lib/language/ko-KR.min.js +1 -1
- package/lib/language/ko-KR.umd.js +4 -0
- package/lib/language/ms-MY.js +4 -0
- package/lib/language/ms-MY.min.js +1 -1
- package/lib/language/ms-MY.umd.js +4 -0
- package/lib/language/nb-NO.js +4 -0
- package/lib/language/nb-NO.min.js +1 -1
- package/lib/language/nb-NO.umd.js +4 -0
- package/lib/language/pt-BR.js +4 -0
- package/lib/language/pt-BR.min.js +1 -1
- package/lib/language/pt-BR.umd.js +4 -0
- package/lib/language/ru-RU.js +4 -0
- package/lib/language/ru-RU.min.js +1 -1
- package/lib/language/ru-RU.umd.js +4 -0
- package/lib/language/th-TH.js +4 -0
- package/lib/language/th-TH.min.js +1 -1
- package/lib/language/th-TH.umd.js +4 -0
- package/lib/language/ug-CN.js +4 -0
- package/lib/language/ug-CN.min.js +1 -1
- package/lib/language/ug-CN.umd.js +4 -0
- package/lib/language/uk-UA.js +4 -0
- package/lib/language/uk-UA.min.js +1 -1
- package/lib/language/uk-UA.umd.js +4 -0
- package/lib/language/uz-UZ.js +4 -0
- package/lib/language/uz-UZ.min.js +1 -1
- package/lib/language/uz-UZ.umd.js +4 -0
- package/lib/language/vi-VN.js +4 -0
- package/lib/language/vi-VN.min.js +1 -1
- package/lib/language/vi-VN.umd.js +4 -0
- package/lib/language/zh-CHT.js +4 -0
- package/lib/language/zh-CHT.min.js +1 -1
- package/lib/language/zh-CHT.umd.js +4 -0
- package/lib/language/zh-CN.js +4 -0
- package/lib/language/zh-CN.min.js +1 -1
- package/lib/language/zh-CN.umd.js +4 -0
- package/lib/list/src/list.js +1347 -36
- package/lib/list/src/list.min.js +1 -1
- package/lib/list/src/store.js +15 -0
- package/lib/list/src/store.min.js +1 -0
- package/lib/list/style/style.css +333 -0
- package/lib/list/style/style.min.css +1 -1
- package/lib/print/src/util.js +1 -1
- package/lib/print/src/util.min.js +1 -1
- package/lib/pulldown/src/pulldown.js +4 -0
- package/lib/pulldown/src/pulldown.min.js +1 -1
- package/lib/style.css +1 -1
- package/lib/style.min.css +1 -1
- package/lib/table-transfer/index.js +19 -0
- package/lib/table-transfer/index.min.js +1 -0
- package/lib/table-transfer/src/table-transfer.js +84 -0
- package/lib/table-transfer/src/table-transfer.min.js +1 -0
- package/lib/table-transfer/style/index.js +1 -0
- package/lib/table-transfer/style/style.css +0 -0
- package/lib/table-transfer/style/style.min.css +0 -0
- package/lib/transfer/index.js +19 -0
- package/lib/transfer/index.min.js +1 -0
- package/lib/transfer/src/transfer.js +93 -0
- package/lib/transfer/src/transfer.min.js +1 -0
- package/lib/transfer/style/index.js +1 -0
- package/lib/transfer/style/style.css +0 -0
- package/lib/transfer/style/style.min.css +0 -0
- package/lib/tree/src/tree.js +18 -28
- package/lib/tree/src/tree.min.js +1 -1
- package/lib/tree/src/util.js +0 -10
- package/lib/tree/src/util.min.js +1 -1
- package/lib/tree-select/src/tree-select.js +9 -6
- package/lib/tree-select/src/tree-select.min.js +1 -1
- package/lib/ui/index.js +14 -2
- 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/ui/src/utils.js +15 -0
- package/lib/ui/src/utils.min.js +1 -1
- package/lib/vxe-list/style/style.css +333 -0
- package/lib/vxe-list/style/style.min.css +1 -1
- package/lib/vxe-table-transfer/index.js +22 -0
- package/lib/vxe-table-transfer/index.min.js +1 -0
- package/lib/vxe-table-transfer/style/index.js +1 -0
- package/lib/vxe-table-transfer/style/style.css +0 -0
- package/lib/vxe-table-transfer/style/style.min.css +0 -0
- package/lib/vxe-transfer/index.js +22 -0
- package/lib/vxe-transfer/index.min.js +1 -0
- package/lib/vxe-transfer/style/index.js +1 -0
- package/lib/vxe-transfer/style/style.css +0 -0
- package/lib/vxe-transfer/style/style.min.css +0 -0
- package/package.json +1 -1
- package/packages/collapse/src/collapse.ts +79 -36
- package/packages/components.ts +6 -0
- package/packages/date-picker/src/date-picker.ts +1 -0
- package/packages/image/src/image.ts +14 -14
- package/packages/language/ar-EG.ts +4 -0
- package/packages/language/de-DE.ts +4 -0
- package/packages/language/en-US.ts +5 -1
- package/packages/language/es-ES.ts +4 -0
- package/packages/language/fr-FR.ts +4 -0
- package/packages/language/hu-HU.ts +4 -0
- package/packages/language/hy-AM.ts +4 -0
- package/packages/language/id-ID.ts +4 -0
- package/packages/language/it-IT.ts +4 -0
- package/packages/language/ja-JP.ts +4 -0
- package/packages/language/ko-KR.ts +4 -0
- package/packages/language/ms-MY.ts +4 -0
- package/packages/language/nb-NO.ts +4 -0
- package/packages/language/pt-BR.ts +4 -0
- package/packages/language/ru-RU.ts +4 -0
- package/packages/language/th-TH.ts +4 -0
- package/packages/language/ug-CN.ts +4 -0
- package/packages/language/uk-UA.ts +4 -0
- package/packages/language/uz-UZ.ts +4 -0
- package/packages/language/vi-VN.ts +4 -0
- package/packages/language/zh-CHT.ts +4 -0
- package/packages/language/zh-CN.ts +4 -0
- package/packages/list/src/list.ts +1366 -35
- package/packages/list/src/store.ts +15 -0
- package/packages/print/src/util.ts +1 -2
- package/packages/pulldown/src/pulldown.ts +4 -4
- package/packages/table-transfer/index.ts +16 -0
- package/packages/table-transfer/src/table-transfer.ts +88 -0
- package/packages/transfer/index.ts +16 -0
- package/packages/transfer/src/transfer.ts +103 -0
- package/packages/tree/src/tree.ts +20 -26
- package/packages/tree/src/util.ts +0 -10
- package/packages/tree-select/src/tree-select.ts +8 -7
- package/packages/ui/index.ts +14 -1
- package/packages/ui/src/utils.ts +15 -0
- package/styles/all.scss +2 -0
- package/styles/components/list.scss +245 -0
- package/styles/components/table-transfer.scss +0 -0
- package/styles/components/transfer.scss +0 -0
- package/styles/components/tree.scss +1 -0
- package/styles/theme/base.scss +3 -0
- package/styles/theme/dark.scss +10 -0
- package/styles/theme/light.scss +10 -0
- package/styles/variable.scss +11 -1
- package/types/all.d.ts +6 -0
- package/types/components/collapse.d.ts +5 -2
- package/types/components/list.d.ts +359 -19
- package/types/components/pulldown.d.ts +1 -0
- package/types/components/table-transfer.d.ts +77 -0
- package/types/components/table.d.ts +4 -0
- package/types/components/transfer.d.ts +77 -0
- package/types/components/tree-select.d.ts +4 -0
- package/types/components/tree.d.ts +1 -1
- package/types/ui/global-config.d.ts +4 -0
- package/types/ui/global-icon.d.ts +6 -1
- /package/es/icon/{iconfont.1782358504076.ttf → iconfont.1782658257467.ttf} +0 -0
- /package/es/icon/{iconfont.1782358504076.woff → iconfont.1782658257467.woff} +0 -0
- /package/es/icon/{iconfont.1782358504076.woff2 → iconfont.1782658257467.woff2} +0 -0
- /package/es/{iconfont.1782358504076.ttf → iconfont.1782658257467.ttf} +0 -0
- /package/es/{iconfont.1782358504076.woff → iconfont.1782658257467.woff} +0 -0
- /package/es/{iconfont.1782358504076.woff2 → iconfont.1782658257467.woff2} +0 -0
- /package/lib/icon/style/{iconfont.1782358504076.ttf → iconfont.1782658257467.ttf} +0 -0
- /package/lib/icon/style/{iconfont.1782358504076.woff → iconfont.1782658257467.woff} +0 -0
- /package/lib/icon/style/{iconfont.1782358504076.woff2 → iconfont.1782658257467.woff2} +0 -0
- /package/lib/{iconfont.1782358504076.ttf → iconfont.1782658257467.ttf} +0 -0
- /package/lib/{iconfont.1782358504076.woff → iconfont.1782658257467.woff} +0 -0
- /package/lib/{iconfont.1782358504076.woff2 → iconfont.1782658257467.woff2} +0 -0
|
@@ -1,24 +1,53 @@
|
|
|
1
1
|
import { PropType, CreateElement, VNode } from 'vue'
|
|
2
2
|
import { defineVxeComponent } from '../../ui/src/comp'
|
|
3
|
-
import XEUtils from 'xe-utils'
|
|
4
|
-
import { getConfig, globalEvents, globalResize, createEvent, globalMixins } from '../../ui'
|
|
5
|
-
import {
|
|
3
|
+
import XEUtils, { XEBrowse } from 'xe-utils'
|
|
4
|
+
import { getConfig, getIcon, getI18n, globalEvents, globalResize, createEvent, globalMixins, renderEmptyElement } from '../../ui'
|
|
5
|
+
import { crossListDragRowGlobal, getCrossListDragRowInfo } from './store'
|
|
6
|
+
import { addClass, getTpImg, isScale, removeClass, toCssUnit } from '../../ui/src/dom'
|
|
7
|
+
import { isEnableConf, getText, enModelValue, deModelValue } from '../../ui/src/utils'
|
|
6
8
|
import { getSlotVNs } from '../../ui/src/vn'
|
|
9
|
+
import { createComponentLog } from '../../ui/src/log'
|
|
10
|
+
import { moveRowAnimateToTb, clearRowAnimate } from '../../ui/src/anime'
|
|
7
11
|
import VxeLoadingComponent from '../../loading/src/loading'
|
|
8
12
|
|
|
9
|
-
import type { VxeListPropTypes, VxeListEmits, VxeComponentSizeType, ListReactData, ValueOf, ListInternalData } from '../../../types'
|
|
13
|
+
import type { VxeListPropTypes, VxeListEmits, VxeComponentSizeType, ListReactData, VxeListDefines, ValueOf, ListInternalData, VxeListConstructor, VxeListPrivateMethods, VxeComponentStyleType } from '../../../types'
|
|
10
14
|
|
|
11
|
-
const
|
|
15
|
+
const { errLog } = createComponentLog('tree')
|
|
16
|
+
|
|
17
|
+
function eqRowKey (rowKey1: any, rowKey2: any) {
|
|
18
|
+
return ('' + rowKey1) === ('' + rowKey2)
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function getRowKeyByField (row: any, keyField: string) {
|
|
22
|
+
return row ? ('' + (row[keyField] || '')) : ''
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function getRowIdByField (row: any, keyField: string) {
|
|
26
|
+
if (!row) {
|
|
27
|
+
return ''
|
|
28
|
+
}
|
|
29
|
+
const rowKey = getRowKeyByField(row, keyField)
|
|
30
|
+
return enModelValue(rowKey)
|
|
31
|
+
}
|
|
12
32
|
|
|
13
33
|
function createReactData (): ListReactData {
|
|
14
34
|
return {
|
|
15
35
|
scrollYLoad: false,
|
|
16
36
|
bodyHeight: 0,
|
|
37
|
+
headHeight: 0,
|
|
38
|
+
footHeight: 0,
|
|
17
39
|
customHeight: 0,
|
|
18
40
|
customMaxHeight: 0,
|
|
19
41
|
parentHeight: 0,
|
|
20
42
|
topSpaceHeight: 0,
|
|
21
|
-
|
|
43
|
+
rowList: [],
|
|
44
|
+
selectRadioRow: null,
|
|
45
|
+
currRowFlag: 1,
|
|
46
|
+
updateCheckboxFlag: 1,
|
|
47
|
+
isAllChecked: false,
|
|
48
|
+
isAllIndeterminate: false,
|
|
49
|
+
dragRow: null,
|
|
50
|
+
dragTipText: ''
|
|
22
51
|
}
|
|
23
52
|
}
|
|
24
53
|
|
|
@@ -26,6 +55,7 @@ function createInternalData (): ListInternalData {
|
|
|
26
55
|
return {
|
|
27
56
|
resizeObserver: undefined,
|
|
28
57
|
fullData: [],
|
|
58
|
+
fullKeyMaps: {},
|
|
29
59
|
lastScrollLeft: 0,
|
|
30
60
|
lastScrollTop: 0,
|
|
31
61
|
scrollYStore: {
|
|
@@ -34,7 +64,11 @@ function createInternalData (): ListInternalData {
|
|
|
34
64
|
visibleSize: 0,
|
|
35
65
|
offsetSize: 0,
|
|
36
66
|
rowHeight: 0
|
|
37
|
-
}
|
|
67
|
+
},
|
|
68
|
+
currentRow: null,
|
|
69
|
+
selectCheckboxMaps: {}
|
|
70
|
+
// prevDragRow: null,
|
|
71
|
+
// prevDragPos: ''
|
|
38
72
|
}
|
|
39
73
|
}
|
|
40
74
|
|
|
@@ -58,6 +92,20 @@ export default /* define-vxe-component start */ defineVxeComponent({
|
|
|
58
92
|
default: () => getConfig().list.autoResize
|
|
59
93
|
},
|
|
60
94
|
syncResize: [Boolean, String, Number] as PropType<VxeListPropTypes.SyncResize>,
|
|
95
|
+
showRadio: {
|
|
96
|
+
type: Boolean as PropType<VxeListPropTypes.ShowRadio>,
|
|
97
|
+
default: () => getConfig().list.showRadio
|
|
98
|
+
},
|
|
99
|
+
checkRowKey: [String, Number] as PropType<VxeListPropTypes.CheckRowKey>,
|
|
100
|
+
radioConfig: Object as PropType<VxeListPropTypes.RadioConfig>,
|
|
101
|
+
showCheckbox: {
|
|
102
|
+
type: Boolean as PropType<VxeListPropTypes.ShowCheckbox>,
|
|
103
|
+
default: () => getConfig().list.showCheckbox
|
|
104
|
+
},
|
|
105
|
+
checkRowKeys: Array as PropType<VxeListPropTypes.CheckRowKeys>,
|
|
106
|
+
checkboxConfig: Object as PropType<VxeListPropTypes.CheckboxConfig>,
|
|
107
|
+
rowConfig: Object as PropType<VxeListPropTypes.RowConfig>,
|
|
108
|
+
dragConfig: Object as PropType<VxeListPropTypes.DragConfig>,
|
|
61
109
|
virtualYConfig: Object as PropType<VxeListPropTypes.VirtualYConfig>,
|
|
62
110
|
scrollY: Object as PropType<VxeListPropTypes.ScrollY>
|
|
63
111
|
},
|
|
@@ -66,35 +114,95 @@ export default /* define-vxe-component start */ defineVxeComponent({
|
|
|
66
114
|
const reactData = createReactData()
|
|
67
115
|
return {
|
|
68
116
|
...({} as {
|
|
69
|
-
internalData: ListInternalData
|
|
117
|
+
internalData: ListInternalData,
|
|
118
|
+
browseObj: XEBrowse
|
|
70
119
|
}),
|
|
71
120
|
xID,
|
|
72
|
-
reactData
|
|
121
|
+
reactData,
|
|
122
|
+
crossListDragRowInfo: crossListDragRowGlobal,
|
|
123
|
+
|
|
124
|
+
reFlag: 0
|
|
73
125
|
}
|
|
74
126
|
},
|
|
75
127
|
computed: {
|
|
76
128
|
...({} as {
|
|
77
129
|
computeSize(): VxeComponentSizeType
|
|
78
130
|
}),
|
|
131
|
+
computeRowOpts () {
|
|
132
|
+
const $xeList = this
|
|
133
|
+
const props = $xeList
|
|
134
|
+
|
|
135
|
+
return Object.assign({}, getConfig().list.rowConfig, props.rowConfig)
|
|
136
|
+
},
|
|
137
|
+
computeDragOpts () {
|
|
138
|
+
const $xeList = this
|
|
139
|
+
const props = $xeList
|
|
140
|
+
|
|
141
|
+
return Object.assign({}, getConfig().list.dragConfig, props.dragConfig)
|
|
142
|
+
},
|
|
79
143
|
computeSYOpts () {
|
|
80
144
|
const $xeList = this
|
|
81
145
|
const props = $xeList
|
|
82
146
|
|
|
83
147
|
return Object.assign({} as { gt: number }, getConfig().list.virtualYConfig || getConfig().list.scrollY, props.virtualYConfig || props.scrollY)
|
|
84
148
|
},
|
|
85
|
-
|
|
149
|
+
computeKeyField () {
|
|
150
|
+
const $xeList = this
|
|
151
|
+
|
|
152
|
+
const rowOpts = $xeList.computeRowOpts as VxeListPropTypes.RowConfig
|
|
153
|
+
const { keyField } = rowOpts
|
|
154
|
+
return keyField || ''
|
|
155
|
+
},
|
|
156
|
+
computeIsDrag () {
|
|
157
|
+
const $xeList = this
|
|
158
|
+
const props = $xeList
|
|
159
|
+
|
|
160
|
+
const { dragConfig } = props
|
|
161
|
+
const dragOpts = $xeList.computeDragOpts as VxeListPropTypes.DragConfig
|
|
162
|
+
return dragConfig && isEnableConf(dragOpts)
|
|
163
|
+
},
|
|
164
|
+
computeRowHeight () {
|
|
165
|
+
const $xeList = this
|
|
166
|
+
|
|
167
|
+
const rowOpts = $xeList.computeRowOpts as VxeListPropTypes.RowConfig
|
|
168
|
+
const { height } = rowOpts
|
|
169
|
+
return height
|
|
170
|
+
},
|
|
171
|
+
computeRadioOpts () {
|
|
172
|
+
const $xeList = this
|
|
173
|
+
const props = $xeList
|
|
174
|
+
|
|
175
|
+
return Object.assign({ showIcon: true }, getConfig().list.radioConfig, props.radioConfig)
|
|
176
|
+
},
|
|
177
|
+
computeCheckboxOpts () {
|
|
178
|
+
const $xeList = this
|
|
179
|
+
const props = $xeList
|
|
180
|
+
|
|
181
|
+
return Object.assign({ showIcon: true }, getConfig().list.checkboxConfig, props.checkboxConfig)
|
|
182
|
+
},
|
|
183
|
+
computeWrapperStyles () {
|
|
184
|
+
const $xeList = this
|
|
185
|
+
|
|
186
|
+
const rowHeight = $xeList.computeRowHeight
|
|
187
|
+
const style: VxeComponentStyleType = {}
|
|
188
|
+
if (rowHeight) {
|
|
189
|
+
style['--vxe-ui-list-row-height'] = toCssUnit(rowHeight)
|
|
190
|
+
}
|
|
191
|
+
return style
|
|
192
|
+
},
|
|
193
|
+
computeVirtualStyles () {
|
|
86
194
|
const $xeList = this
|
|
87
195
|
const props = $xeList
|
|
88
196
|
const reactData = $xeList.reactData
|
|
89
197
|
|
|
90
198
|
const { height, maxHeight } = props
|
|
91
|
-
const { customHeight, customMaxHeight } = reactData
|
|
92
|
-
const style:
|
|
199
|
+
const { customHeight, customMaxHeight, headHeight, footHeight } = reactData
|
|
200
|
+
const style: VxeComponentStyleType = {}
|
|
93
201
|
if (height) {
|
|
94
|
-
style.height =
|
|
202
|
+
style.height = toCssUnit(Math.max(20, customHeight - headHeight - footHeight))
|
|
95
203
|
} else if (maxHeight) {
|
|
96
204
|
style.height = 'auto'
|
|
97
|
-
style.maxHeight =
|
|
205
|
+
style.maxHeight = toCssUnit(Math.max(20, customMaxHeight - headHeight - footHeight))
|
|
98
206
|
}
|
|
99
207
|
return style
|
|
100
208
|
}
|
|
@@ -108,6 +216,16 @@ export default /* define-vxe-component start */ defineVxeComponent({
|
|
|
108
216
|
const $xeList = this
|
|
109
217
|
$xeList.$emit(type, createEvent(evnt, { $list: $xeList }, params))
|
|
110
218
|
},
|
|
219
|
+
emitCheckboxMode (value: VxeListPropTypes.CheckRowKeys) {
|
|
220
|
+
const $xeList = this
|
|
221
|
+
|
|
222
|
+
$xeList.$emit('update:checkRowKeys', value)
|
|
223
|
+
},
|
|
224
|
+
emitRadioMode (value: VxeListPropTypes.CheckRowKey) {
|
|
225
|
+
const $xeList = this
|
|
226
|
+
|
|
227
|
+
$xeList.$emit('update:checkRowKey', value)
|
|
228
|
+
},
|
|
111
229
|
callSlot (slotFunc: ((params: any, h: CreateElement) => any) | string | null, params: any, h: CreateElement) {
|
|
112
230
|
const $xeList = this
|
|
113
231
|
const slots = $xeList.$scopedSlots
|
|
@@ -122,6 +240,61 @@ export default /* define-vxe-component start */ defineVxeComponent({
|
|
|
122
240
|
}
|
|
123
241
|
return []
|
|
124
242
|
},
|
|
243
|
+
getRowId (row: any) {
|
|
244
|
+
const $xeList = this
|
|
245
|
+
|
|
246
|
+
const keyField = $xeList.computeKeyField
|
|
247
|
+
return getRowIdByField(row, keyField)
|
|
248
|
+
},
|
|
249
|
+
updateRadioModeValue () {
|
|
250
|
+
const $xeList = this
|
|
251
|
+
const props = $xeList
|
|
252
|
+
const reactData = $xeList.reactData
|
|
253
|
+
const internalData = $xeList.internalData
|
|
254
|
+
|
|
255
|
+
const { checkRowKey } = props
|
|
256
|
+
const { fullKeyMaps } = internalData
|
|
257
|
+
if (checkRowKey) {
|
|
258
|
+
const row = fullKeyMaps[checkRowKey]
|
|
259
|
+
reactData.selectRadioRow = row || null
|
|
260
|
+
} else {
|
|
261
|
+
reactData.selectRadioRow = null
|
|
262
|
+
}
|
|
263
|
+
},
|
|
264
|
+
updateCheckboxModeValue () {
|
|
265
|
+
const $xeList = this
|
|
266
|
+
const props = $xeList
|
|
267
|
+
const internalData = $xeList.internalData
|
|
268
|
+
|
|
269
|
+
const { checkRowKeys } = props
|
|
270
|
+
const { fullKeyMaps } = internalData
|
|
271
|
+
const keyField = $xeList.computeKeyField
|
|
272
|
+
const selectMaps: Record<string, any> = {}
|
|
273
|
+
if (checkRowKeys && checkRowKeys.length) {
|
|
274
|
+
for (const rowKey of checkRowKeys) {
|
|
275
|
+
const row = fullKeyMaps[rowKey as string]
|
|
276
|
+
if (row) {
|
|
277
|
+
const rowid = getRowIdByField(row, keyField)
|
|
278
|
+
selectMaps[rowid] = row
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
internalData.selectCheckboxMaps = selectMaps
|
|
283
|
+
$xeList.updateCheckboxStatus()
|
|
284
|
+
},
|
|
285
|
+
cacheRowMap () {
|
|
286
|
+
const $xeList = this
|
|
287
|
+
const internalData = $xeList.internalData
|
|
288
|
+
|
|
289
|
+
const { fullData } = internalData
|
|
290
|
+
const keyField = $xeList.computeKeyField
|
|
291
|
+
const keyMaps: Record<string, any> = {}
|
|
292
|
+
fullData.forEach(row => {
|
|
293
|
+
const rowKey = getRowKeyByField(row, keyField)
|
|
294
|
+
keyMaps[rowKey] = row
|
|
295
|
+
})
|
|
296
|
+
internalData.fullKeyMaps = keyMaps
|
|
297
|
+
},
|
|
125
298
|
/**
|
|
126
299
|
* 加载数据
|
|
127
300
|
* @param {Array} datas 数据
|
|
@@ -142,7 +315,10 @@ export default /* define-vxe-component start */ defineVxeComponent({
|
|
|
142
315
|
internalData.fullData = fullData
|
|
143
316
|
// 如果gt为0,则总是启用
|
|
144
317
|
reactData.scrollYLoad = !!sYOpts.enabled && sYOpts.gt > -1 && (sYOpts.gt === 0 || sYOpts.gt <= fullData.length)
|
|
318
|
+
$xeList.cacheRowMap()
|
|
145
319
|
$xeList.handleData()
|
|
320
|
+
$xeList.updateRadioModeValue()
|
|
321
|
+
$xeList.updateCheckboxModeValue()
|
|
146
322
|
return $xeList.computeScrollLoad().then(() => {
|
|
147
323
|
$xeList.refreshScroll()
|
|
148
324
|
})
|
|
@@ -157,6 +333,13 @@ export default /* define-vxe-component start */ defineVxeComponent({
|
|
|
157
333
|
$xeList.clearScroll()
|
|
158
334
|
return $xeList.loadData(datas)
|
|
159
335
|
},
|
|
336
|
+
getFullData () {
|
|
337
|
+
const $xeList = this
|
|
338
|
+
const internalData = $xeList.internalData
|
|
339
|
+
|
|
340
|
+
const { fullData } = internalData
|
|
341
|
+
return fullData
|
|
342
|
+
},
|
|
160
343
|
calcTableHeight (key: 'height' | 'maxHeight') {
|
|
161
344
|
const $xeList = this
|
|
162
345
|
const props = $xeList
|
|
@@ -183,6 +366,10 @@ export default /* define-vxe-component start */ defineVxeComponent({
|
|
|
183
366
|
const $xeList = this
|
|
184
367
|
const reactData = $xeList.reactData
|
|
185
368
|
|
|
369
|
+
const headEl = $xeList.$refs.refHeaderElem as HTMLDivElement
|
|
370
|
+
const footEl = $xeList.$refs.refFooterElem as HTMLDivElement
|
|
371
|
+
reactData.headHeight = headEl ? Math.floor(headEl.offsetHeight) : 0
|
|
372
|
+
reactData.footHeight = footEl ? Math.floor(footEl.offsetHeight) : 0
|
|
186
373
|
reactData.customHeight = $xeList.calcTableHeight('height')
|
|
187
374
|
reactData.customMaxHeight = $xeList.calcTableHeight('maxHeight')
|
|
188
375
|
},
|
|
@@ -203,7 +390,7 @@ export default /* define-vxe-component start */ defineVxeComponent({
|
|
|
203
390
|
|
|
204
391
|
const { scrollYLoad } = reactData
|
|
205
392
|
const { fullData, scrollYStore } = internalData
|
|
206
|
-
reactData.
|
|
393
|
+
reactData.rowList = scrollYLoad ? fullData.slice(scrollYStore.startIndex, scrollYStore.endIndex) : fullData.slice(0)
|
|
207
394
|
return $xeList.$nextTick()
|
|
208
395
|
},
|
|
209
396
|
updateYData () {
|
|
@@ -216,6 +403,7 @@ export default /* define-vxe-component start */ defineVxeComponent({
|
|
|
216
403
|
const $xeList = this
|
|
217
404
|
const reactData = $xeList.reactData
|
|
218
405
|
const internalData = $xeList.internalData
|
|
406
|
+
const browseObj = $xeList.browseObj
|
|
219
407
|
|
|
220
408
|
return $xeList.$nextTick().then(() => {
|
|
221
409
|
const { scrollYLoad } = reactData
|
|
@@ -223,17 +411,17 @@ export default /* define-vxe-component start */ defineVxeComponent({
|
|
|
223
411
|
const virtualBodyElem = $xeList.$refs.refVirtualBody as HTMLDivElement
|
|
224
412
|
const sYOpts = $xeList.computeSYOpts
|
|
225
413
|
let rowHeight = 0
|
|
226
|
-
let
|
|
414
|
+
let firstRowElem: HTMLElement | undefined
|
|
227
415
|
if (virtualBodyElem) {
|
|
228
416
|
if (sYOpts.sItem) {
|
|
229
|
-
|
|
417
|
+
firstRowElem = virtualBodyElem.querySelector(sYOpts.sItem) as HTMLElement
|
|
230
418
|
}
|
|
231
|
-
if (!
|
|
232
|
-
|
|
419
|
+
if (!firstRowElem) {
|
|
420
|
+
firstRowElem = virtualBodyElem.children[0] as HTMLElement
|
|
233
421
|
}
|
|
234
422
|
}
|
|
235
|
-
if (
|
|
236
|
-
rowHeight =
|
|
423
|
+
if (firstRowElem) {
|
|
424
|
+
rowHeight = firstRowElem.offsetHeight
|
|
237
425
|
}
|
|
238
426
|
rowHeight = Math.max(12, rowHeight)
|
|
239
427
|
scrollYStore.rowHeight = rowHeight
|
|
@@ -364,32 +552,1121 @@ export default /* define-vxe-component start */ defineVxeComponent({
|
|
|
364
552
|
}
|
|
365
553
|
$xeList.dispatchEvent('scroll', { scrollLeft, scrollTop, isX, isY }, evnt)
|
|
366
554
|
},
|
|
555
|
+
getRowKey (row: any) {
|
|
556
|
+
const $xeList = this
|
|
557
|
+
|
|
558
|
+
const keyField = $xeList.computeKeyField
|
|
559
|
+
return getRowKeyByField(row, keyField)
|
|
560
|
+
},
|
|
561
|
+
eqRowKey,
|
|
562
|
+
eqRow (row1: any, row2: any) {
|
|
563
|
+
const $xeList = this
|
|
564
|
+
|
|
565
|
+
if (row1 && row2) {
|
|
566
|
+
if (row1 === row2) {
|
|
567
|
+
return true
|
|
568
|
+
}
|
|
569
|
+
return eqRowKey($xeList.getRowId(row1), $xeList.getRowId(row2))
|
|
570
|
+
}
|
|
571
|
+
return false
|
|
572
|
+
},
|
|
573
|
+
eqRowByKey (row: any, rowKey: string | number | null | undefined) {
|
|
574
|
+
const $xeList = this
|
|
575
|
+
|
|
576
|
+
return row && eqRowKey($xeList.getRowKey(row), rowKey)
|
|
577
|
+
},
|
|
578
|
+
findRow (list: any, row: any) {
|
|
579
|
+
const $xeList = this
|
|
580
|
+
|
|
581
|
+
return row ? XEUtils.find(list, obj => $xeList.eqRow(obj, row)) : null
|
|
582
|
+
},
|
|
583
|
+
findRowByKey (list: any, rowId: string | number | null | undefined) {
|
|
584
|
+
const $xeList = this
|
|
585
|
+
|
|
586
|
+
const keyField = $xeList.computeKeyField
|
|
587
|
+
return XEUtils.find(list, obj => eqRowKey(getRowIdByField(obj, keyField), rowId))
|
|
588
|
+
},
|
|
589
|
+
findRowIndexOf (list: any, row: any) {
|
|
590
|
+
const $xeList = this
|
|
591
|
+
|
|
592
|
+
return row ? XEUtils.findIndexOf(list, obj => $xeList.eqRow(obj, row)) : -1
|
|
593
|
+
},
|
|
594
|
+
findRowIndexOfByKey (list: any, rowKey: string | number | null | undefined) {
|
|
595
|
+
const $xeList = this
|
|
596
|
+
|
|
597
|
+
const keyField = $xeList.computeKeyField
|
|
598
|
+
return XEUtils.findIndexOf(list, obj => eqRowKey(getRowIdByField(obj, keyField), rowKey))
|
|
599
|
+
},
|
|
600
|
+
isCheckedByRadioRowKey (rowKey: string | number | null | undefined) {
|
|
601
|
+
const $xeList = this
|
|
602
|
+
const reactData = $xeList.reactData
|
|
603
|
+
|
|
604
|
+
const { selectRadioRow } = reactData
|
|
605
|
+
return $xeList.getRowKey(selectRadioRow) === rowKey
|
|
606
|
+
},
|
|
607
|
+
isCheckedByRadioRow (row: any) {
|
|
608
|
+
const $xeList = this
|
|
609
|
+
|
|
610
|
+
return $xeList.isCheckedByRadioRowKey($xeList.getRowKey(row))
|
|
611
|
+
},
|
|
612
|
+
isCheckedByCheckboxRowKey (rowid: any) {
|
|
613
|
+
const $xeList = this
|
|
614
|
+
const reactData = $xeList.reactData
|
|
615
|
+
const internalData = $xeList.internalData
|
|
616
|
+
|
|
617
|
+
const { updateCheckboxFlag } = reactData
|
|
618
|
+
const { selectCheckboxMaps } = internalData
|
|
619
|
+
return !!(updateCheckboxFlag && selectCheckboxMaps[rowid])
|
|
620
|
+
},
|
|
621
|
+
isCheckedByCheckboxRow (row: any) {
|
|
622
|
+
const $xeList = this
|
|
623
|
+
|
|
624
|
+
return $xeList.isCheckedByCheckboxRowKey($xeList.getRowKey(row))
|
|
625
|
+
},
|
|
626
|
+
setCurrentRow (row: any) {
|
|
627
|
+
const $xeList = this
|
|
628
|
+
const reactData = $xeList.reactData
|
|
629
|
+
const internalData = $xeList.internalData
|
|
630
|
+
|
|
631
|
+
internalData.currentRow = row
|
|
632
|
+
reactData.currRowFlag++
|
|
633
|
+
return $xeList.$nextTick()
|
|
634
|
+
},
|
|
635
|
+
setCurrentRowByKey (rowKey: string | number | null | undefined) {
|
|
636
|
+
const $xeList = this
|
|
637
|
+
const reactData = $xeList.reactData
|
|
638
|
+
const internalData = $xeList.internalData
|
|
639
|
+
|
|
640
|
+
const { fullData } = internalData
|
|
641
|
+
internalData.currentRow = $xeList.findRowByKey(fullData, rowKey)
|
|
642
|
+
reactData.currRowFlag++
|
|
643
|
+
return $xeList.$nextTick()
|
|
644
|
+
},
|
|
645
|
+
getCurrentRow () {
|
|
646
|
+
const $xeList = this
|
|
647
|
+
const internalData = $xeList.internalData
|
|
648
|
+
|
|
649
|
+
const { currentRow } = internalData
|
|
650
|
+
return currentRow
|
|
651
|
+
},
|
|
652
|
+
getCurrentRowKey () {
|
|
653
|
+
const $xeList = this
|
|
654
|
+
const internalData = $xeList.internalData
|
|
655
|
+
|
|
656
|
+
const { currentRow } = internalData
|
|
657
|
+
return currentRow ? $xeList.getRowKey(currentRow) : null
|
|
658
|
+
},
|
|
659
|
+
clearCurrentRow () {
|
|
660
|
+
const $xeList = this
|
|
661
|
+
const reactData = $xeList.reactData
|
|
662
|
+
const internalData = $xeList.internalData
|
|
663
|
+
|
|
664
|
+
internalData.currentRow = null
|
|
665
|
+
reactData.currRowFlag++
|
|
666
|
+
return $xeList.$nextTick()
|
|
667
|
+
},
|
|
668
|
+
setRadioRow (row: any) {
|
|
669
|
+
const $xeList = this
|
|
670
|
+
const reactData = $xeList.reactData
|
|
671
|
+
|
|
672
|
+
reactData.selectRadioRow = row
|
|
673
|
+
const value = $xeList.getRowKey(row)
|
|
674
|
+
$xeList.emitRadioMode(value)
|
|
675
|
+
return $xeList.$nextTick()
|
|
676
|
+
},
|
|
677
|
+
setRadioRowByKey (rowKey: string | number | null | undefined) {
|
|
678
|
+
const $xeList = this
|
|
679
|
+
const reactData = $xeList.reactData
|
|
680
|
+
const internalData = $xeList.internalData
|
|
681
|
+
|
|
682
|
+
const { fullData } = internalData
|
|
683
|
+
reactData.selectRadioRow = $xeList.findRowByKey(fullData, rowKey)
|
|
684
|
+
const value = rowKey as string
|
|
685
|
+
$xeList.emitRadioMode(value)
|
|
686
|
+
return $xeList.$nextTick()
|
|
687
|
+
},
|
|
688
|
+
getRadioRow () {
|
|
689
|
+
const $xeList = this
|
|
690
|
+
const reactData = $xeList.reactData
|
|
691
|
+
|
|
692
|
+
const { selectRadioRow } = reactData
|
|
693
|
+
return selectRadioRow
|
|
694
|
+
},
|
|
695
|
+
getRadioRowKey () {
|
|
696
|
+
const $xeList = this
|
|
697
|
+
const reactData = $xeList.reactData
|
|
698
|
+
|
|
699
|
+
const { selectRadioRow } = reactData
|
|
700
|
+
return selectRadioRow ? $xeList.getRowKey(selectRadioRow) : null
|
|
701
|
+
},
|
|
702
|
+
clearRadioRow () {
|
|
703
|
+
const $xeList = this
|
|
704
|
+
const reactData = $xeList.reactData
|
|
705
|
+
|
|
706
|
+
const value = null
|
|
707
|
+
reactData.selectRadioRow = value
|
|
708
|
+
$xeList.emitRadioMode(value)
|
|
709
|
+
return $xeList.$nextTick()
|
|
710
|
+
},
|
|
711
|
+
setCheckboxRow (row: any | any[], checked: boolean) {
|
|
712
|
+
const $xeList = this
|
|
713
|
+
const internalData = $xeList.internalData
|
|
714
|
+
|
|
715
|
+
const { selectCheckboxMaps } = internalData
|
|
716
|
+
const keyField = $xeList.computeKeyField
|
|
717
|
+
const rowList = row ? (XEUtils.isArray(row) ? row : [row]) : []
|
|
718
|
+
rowList.forEach(checked
|
|
719
|
+
? (obj) => {
|
|
720
|
+
const rowid = getRowIdByField(obj, keyField)
|
|
721
|
+
if (!selectCheckboxMaps[rowid]) {
|
|
722
|
+
selectCheckboxMaps[rowid] = obj
|
|
723
|
+
}
|
|
724
|
+
}
|
|
725
|
+
: (obj) => {
|
|
726
|
+
const rowid = getRowIdByField(obj, keyField)
|
|
727
|
+
if (selectCheckboxMaps[rowid]) {
|
|
728
|
+
delete selectCheckboxMaps[rowid]
|
|
729
|
+
}
|
|
730
|
+
})
|
|
731
|
+
const value = $xeList.getCheckboxRowKeys()
|
|
732
|
+
$xeList.emitCheckboxMode(value)
|
|
733
|
+
return $xeList.updateCheckboxStatus()
|
|
734
|
+
},
|
|
735
|
+
setCheckboxRowByKey (rowKey: string | number | null | undefined | (string | number | null | undefined)[], checked: boolean) {
|
|
736
|
+
const $xeList = this
|
|
737
|
+
const internalData = $xeList.internalData
|
|
738
|
+
|
|
739
|
+
const { selectCheckboxMaps, fullKeyMaps } = internalData
|
|
740
|
+
const keyField = $xeList.computeKeyField
|
|
741
|
+
const rowKeys = rowKey ? (XEUtils.isArray(rowKey) ? rowKey : [rowKey]) : []
|
|
742
|
+
rowKeys.forEach(checked
|
|
743
|
+
? (key) => {
|
|
744
|
+
const row = fullKeyMaps[key || '']
|
|
745
|
+
if (row) {
|
|
746
|
+
const rowid = getRowIdByField(row, keyField)
|
|
747
|
+
if (row && !selectCheckboxMaps[rowid]) {
|
|
748
|
+
selectCheckboxMaps[rowid] = row
|
|
749
|
+
}
|
|
750
|
+
}
|
|
751
|
+
}
|
|
752
|
+
: (key) => {
|
|
753
|
+
const row = fullKeyMaps[key || '']
|
|
754
|
+
if (row) {
|
|
755
|
+
const rowid = getRowIdByField(row, keyField)
|
|
756
|
+
if (selectCheckboxMaps[rowid]) {
|
|
757
|
+
delete selectCheckboxMaps[rowid]
|
|
758
|
+
}
|
|
759
|
+
}
|
|
760
|
+
})
|
|
761
|
+
const value = $xeList.getCheckboxRowKeys()
|
|
762
|
+
$xeList.emitCheckboxMode(value)
|
|
763
|
+
return $xeList.updateCheckboxStatus()
|
|
764
|
+
},
|
|
765
|
+
getCheckboxRows () {
|
|
766
|
+
const $xeList = this
|
|
767
|
+
const reactData = $xeList.reactData
|
|
768
|
+
const internalData = $xeList.internalData
|
|
769
|
+
|
|
770
|
+
const { updateCheckboxFlag } = reactData
|
|
771
|
+
const { selectCheckboxMaps } = internalData
|
|
772
|
+
const rowList: string[] = []
|
|
773
|
+
if (updateCheckboxFlag) {
|
|
774
|
+
XEUtils.each(selectCheckboxMaps, row => {
|
|
775
|
+
if (row) {
|
|
776
|
+
rowList.push(row)
|
|
777
|
+
}
|
|
778
|
+
})
|
|
779
|
+
}
|
|
780
|
+
return rowList
|
|
781
|
+
},
|
|
782
|
+
getCheckboxRowKeys () {
|
|
783
|
+
const $xeList = this
|
|
784
|
+
const reactData = $xeList.reactData
|
|
785
|
+
const internalData = $xeList.internalData
|
|
786
|
+
|
|
787
|
+
const { updateCheckboxFlag } = reactData
|
|
788
|
+
const { selectCheckboxMaps } = internalData
|
|
789
|
+
const keyField = $xeList.computeKeyField
|
|
790
|
+
const rowKeys: string[] = []
|
|
791
|
+
if (updateCheckboxFlag) {
|
|
792
|
+
XEUtils.each(selectCheckboxMaps, row => {
|
|
793
|
+
if (row) {
|
|
794
|
+
const rowKey = getRowKeyByField(row, keyField)
|
|
795
|
+
rowKeys.push(rowKey)
|
|
796
|
+
}
|
|
797
|
+
})
|
|
798
|
+
}
|
|
799
|
+
return rowKeys
|
|
800
|
+
},
|
|
801
|
+
clearCheckboxRow () {
|
|
802
|
+
const $xeList = this
|
|
803
|
+
const reactData = $xeList.reactData
|
|
804
|
+
const internalData = $xeList.internalData
|
|
805
|
+
|
|
806
|
+
internalData.selectCheckboxMaps = {}
|
|
807
|
+
reactData.updateCheckboxFlag++
|
|
808
|
+
reactData.isAllChecked = false
|
|
809
|
+
reactData.isAllIndeterminate = false
|
|
810
|
+
const value: string[] = []
|
|
811
|
+
$xeList.emitCheckboxMode(value)
|
|
812
|
+
return $xeList.$nextTick()
|
|
813
|
+
},
|
|
814
|
+
setAllCheckboxRow (checked: boolean) {
|
|
815
|
+
const $xeList = this
|
|
816
|
+
const internalData = $xeList.internalData
|
|
817
|
+
|
|
818
|
+
const { fullData, selectCheckboxMaps } = internalData
|
|
819
|
+
const keyField = $xeList.computeKeyField
|
|
820
|
+
if (checked) {
|
|
821
|
+
const value: string[] = []
|
|
822
|
+
for (const row of fullData) {
|
|
823
|
+
const rowKey = getRowKeyByField(row, keyField)
|
|
824
|
+
const rowid = getRowIdByField(row, keyField)
|
|
825
|
+
selectCheckboxMaps[rowid] = row
|
|
826
|
+
value.push(rowKey)
|
|
827
|
+
}
|
|
828
|
+
$xeList.emitCheckboxMode(value)
|
|
829
|
+
return $xeList.updateCheckboxStatus()
|
|
830
|
+
}
|
|
831
|
+
return $xeList.clearCheckboxRow()
|
|
832
|
+
},
|
|
833
|
+
updateCheckboxStatus () {
|
|
834
|
+
const $xeList = this
|
|
835
|
+
const reactData = $xeList.reactData
|
|
836
|
+
const internalData = $xeList.internalData
|
|
837
|
+
|
|
838
|
+
const { selectCheckboxMaps, fullData } = internalData
|
|
839
|
+
const keyField = $xeList.computeKeyField
|
|
840
|
+
const checkboxOpts = $xeList.computeCheckboxOpts
|
|
841
|
+
const { checkMethod } = checkboxOpts
|
|
842
|
+
|
|
843
|
+
let hasChecked = false
|
|
844
|
+
let hasUnchecked = false
|
|
845
|
+
if (checkMethod) {
|
|
846
|
+
for (const row of fullData) {
|
|
847
|
+
if (checkMethod({ row, $list: $xeList })) {
|
|
848
|
+
const rowid = getRowIdByField(row, keyField)
|
|
849
|
+
if (selectCheckboxMaps[rowid]) {
|
|
850
|
+
hasChecked = true
|
|
851
|
+
} else {
|
|
852
|
+
hasUnchecked = true
|
|
853
|
+
if (hasChecked) {
|
|
854
|
+
break
|
|
855
|
+
}
|
|
856
|
+
}
|
|
857
|
+
}
|
|
858
|
+
}
|
|
859
|
+
} else {
|
|
860
|
+
for (const row of fullData) {
|
|
861
|
+
const rowid = getRowIdByField(row, keyField)
|
|
862
|
+
if (selectCheckboxMaps[rowid]) {
|
|
863
|
+
hasChecked = true
|
|
864
|
+
} else {
|
|
865
|
+
hasUnchecked = true
|
|
866
|
+
if (hasChecked) {
|
|
867
|
+
break
|
|
868
|
+
}
|
|
869
|
+
}
|
|
870
|
+
}
|
|
871
|
+
}
|
|
872
|
+
|
|
873
|
+
reactData.isAllChecked = hasChecked && !hasUnchecked
|
|
874
|
+
reactData.isAllIndeterminate = hasChecked && hasUnchecked
|
|
875
|
+
reactData.updateCheckboxFlag++
|
|
876
|
+
return $xeList.$nextTick()
|
|
877
|
+
},
|
|
878
|
+
changeCheckboxAllEvent (evnt: MouseEvent) {
|
|
879
|
+
const $xeList = this
|
|
880
|
+
const reactData = $xeList.reactData
|
|
881
|
+
|
|
882
|
+
const { isAllChecked } = reactData
|
|
883
|
+
const isChecked = !isAllChecked
|
|
884
|
+
if (isChecked) {
|
|
885
|
+
$xeList.setAllCheckboxRow(true)
|
|
886
|
+
} else {
|
|
887
|
+
$xeList.clearCheckboxRow()
|
|
888
|
+
}
|
|
889
|
+
$xeList.dispatchEvent('checkbox-all', { checked: isChecked }, evnt)
|
|
890
|
+
},
|
|
891
|
+
changeCheckboxEvent (evnt: MouseEvent, row: any) {
|
|
892
|
+
const $xeList = this
|
|
893
|
+
const reactData = $xeList.reactData
|
|
894
|
+
const internalData = $xeList.internalData
|
|
895
|
+
|
|
896
|
+
evnt.preventDefault()
|
|
897
|
+
evnt.stopPropagation()
|
|
898
|
+
const { selectCheckboxMaps } = internalData
|
|
899
|
+
const checkboxOpts = $xeList.computeCheckboxOpts
|
|
900
|
+
const { checkMethod } = checkboxOpts
|
|
901
|
+
const rowid = $xeList.getRowKey(row)
|
|
902
|
+
const isDisabled = checkMethod ? !checkMethod({ $list: $xeList, row }) : false
|
|
903
|
+
if (isDisabled) {
|
|
904
|
+
return
|
|
905
|
+
}
|
|
906
|
+
let isChecked = false
|
|
907
|
+
if (selectCheckboxMaps[rowid]) {
|
|
908
|
+
delete selectCheckboxMaps[rowid]
|
|
909
|
+
} else {
|
|
910
|
+
isChecked = true
|
|
911
|
+
selectCheckboxMaps[rowid] = row
|
|
912
|
+
}
|
|
913
|
+
reactData.updateCheckboxFlag++
|
|
914
|
+
$xeList.updateCheckboxStatus()
|
|
915
|
+
const rowids = XEUtils.keys(selectCheckboxMaps)
|
|
916
|
+
const value = rowids.map(deModelValue)
|
|
917
|
+
$xeList.emitCheckboxMode(value)
|
|
918
|
+
$xeList.dispatchEvent('checkbox-change', { row, value, checked: isChecked }, evnt)
|
|
919
|
+
},
|
|
920
|
+
changeCurrentEvent (evnt: MouseEvent, row: any) {
|
|
921
|
+
const $xeList = this
|
|
922
|
+
const reactData = $xeList.reactData
|
|
923
|
+
const internalData = $xeList.internalData
|
|
924
|
+
|
|
925
|
+
evnt.preventDefault()
|
|
926
|
+
const rowOpts = $xeList.computeRowOpts
|
|
927
|
+
const { currentMethod } = rowOpts
|
|
928
|
+
let isDisabled = false
|
|
929
|
+
if (currentMethod) {
|
|
930
|
+
isDisabled = !currentMethod({ row })
|
|
931
|
+
}
|
|
932
|
+
if (isDisabled) {
|
|
933
|
+
return
|
|
934
|
+
}
|
|
935
|
+
const isChecked = true
|
|
936
|
+
internalData.currentRow = row
|
|
937
|
+
reactData.currRowFlag++
|
|
938
|
+
$xeList.dispatchEvent('current-change', { row, checked: isChecked }, evnt)
|
|
939
|
+
},
|
|
940
|
+
changeRadioEvent (evnt: MouseEvent, row: any) {
|
|
941
|
+
const $xeList = this
|
|
942
|
+
const reactData = $xeList.reactData
|
|
943
|
+
|
|
944
|
+
evnt.preventDefault()
|
|
945
|
+
evnt.stopPropagation()
|
|
946
|
+
const { selectRadioRow } = reactData
|
|
947
|
+
const radioOpts = $xeList.computeRadioOpts
|
|
948
|
+
const { strict, checkMethod } = radioOpts
|
|
949
|
+
const rowKey = $xeList.getRowKey(row)
|
|
950
|
+
const isDisabled = checkMethod ? !checkMethod({ $list: $xeList, row }) : false
|
|
951
|
+
if (isDisabled) {
|
|
952
|
+
return
|
|
953
|
+
}
|
|
954
|
+
const value = rowKey
|
|
955
|
+
let isChecked = true
|
|
956
|
+
if (strict) {
|
|
957
|
+
if (selectRadioRow && rowKey === $xeList.getRowKey(selectRadioRow)) {
|
|
958
|
+
isChecked = false
|
|
959
|
+
reactData.selectRadioRow = null
|
|
960
|
+
} else {
|
|
961
|
+
reactData.selectRadioRow = row
|
|
962
|
+
}
|
|
963
|
+
} else {
|
|
964
|
+
reactData.selectRadioRow = row
|
|
965
|
+
}
|
|
966
|
+
$xeList.emitRadioMode(value)
|
|
967
|
+
$xeList.dispatchEvent('radio-change', { row, value, checked: isChecked }, evnt)
|
|
968
|
+
},
|
|
969
|
+
clearRowDropOrigin () {
|
|
970
|
+
const $xeList = this
|
|
971
|
+
|
|
972
|
+
const el = $xeList.$refs.refElem as HTMLDivElement
|
|
973
|
+
if (el) {
|
|
974
|
+
const clss = 'row--drag-origin'
|
|
975
|
+
XEUtils.arrayEach(el.querySelectorAll(`.${clss}`), (elem) => {
|
|
976
|
+
(elem as HTMLTableCellElement).draggable = false
|
|
977
|
+
removeClass(elem, clss)
|
|
978
|
+
})
|
|
979
|
+
}
|
|
980
|
+
},
|
|
981
|
+
updateRowDropOrigin (row: any) {
|
|
982
|
+
const $xeList = this
|
|
983
|
+
|
|
984
|
+
const sYOpts = $xeList.computeSYOpts
|
|
985
|
+
const { sItem } = sYOpts
|
|
986
|
+
const el = $xeList.$refs.refElem as HTMLDivElement
|
|
987
|
+
if (el) {
|
|
988
|
+
const clss = 'row--drag-origin'
|
|
989
|
+
const rowid = $xeList.getRowId(row)
|
|
990
|
+
XEUtils.arrayEach(el.querySelectorAll<HTMLDivElement>(`.vxe-list--row[rowid="${rowid}"]` + (sItem ? `${sItem}[rowid="${rowid}"]` : '')), (elem) => {
|
|
991
|
+
addClass(elem, clss)
|
|
992
|
+
})
|
|
993
|
+
}
|
|
994
|
+
},
|
|
995
|
+
updateRowDropTipContent (rowEl: HTMLElement) {
|
|
996
|
+
const $xeList = this
|
|
997
|
+
const reactData = $xeList.reactData
|
|
998
|
+
|
|
999
|
+
const { dragRow } = reactData
|
|
1000
|
+
const dragOpts = $xeList.computeDragOpts
|
|
1001
|
+
const { tooltipMethod } = dragOpts
|
|
1002
|
+
const rTooltipMethod = tooltipMethod
|
|
1003
|
+
let tipContent = ''
|
|
1004
|
+
if (rTooltipMethod) {
|
|
1005
|
+
const rtParams = {
|
|
1006
|
+
$list: $xeList,
|
|
1007
|
+
row: dragRow
|
|
1008
|
+
}
|
|
1009
|
+
tipContent = `${rTooltipMethod(rtParams) || ''}`
|
|
1010
|
+
} else {
|
|
1011
|
+
tipContent = getI18n('vxe.list.dragTip', [rowEl.textContent || ''])
|
|
1012
|
+
}
|
|
1013
|
+
reactData.dragTipText = tipContent
|
|
1014
|
+
},
|
|
1015
|
+
hideDropTip () {
|
|
1016
|
+
const $xeList = this
|
|
1017
|
+
|
|
1018
|
+
const rdTipEl = $xeList.$refs.refDragTipElem as HTMLDivElement
|
|
1019
|
+
const rdLineEl = $xeList.$refs.refDragRowLineElem as HTMLDivElement
|
|
1020
|
+
if (rdTipEl) {
|
|
1021
|
+
rdTipEl.style.display = ''
|
|
1022
|
+
}
|
|
1023
|
+
if (rdLineEl) {
|
|
1024
|
+
rdLineEl.style.display = ''
|
|
1025
|
+
}
|
|
1026
|
+
},
|
|
1027
|
+
clearCrossListDragStatus () {
|
|
1028
|
+
const $xeList = this
|
|
1029
|
+
const crossListDragRowInfo = getCrossListDragRowInfo($xeList as VxeListConstructor & VxeListPrivateMethods)
|
|
1030
|
+
|
|
1031
|
+
// crossListDragRowObj = null
|
|
1032
|
+
crossListDragRowInfo.row = null
|
|
1033
|
+
},
|
|
1034
|
+
clearDragStatus () {
|
|
1035
|
+
const $xeList = this
|
|
1036
|
+
const reactData = $xeList.reactData
|
|
1037
|
+
|
|
1038
|
+
const { dragRow } = reactData
|
|
1039
|
+
if (dragRow) {
|
|
1040
|
+
$xeList.hideDropTip()
|
|
1041
|
+
$xeList.clearRowDropOrigin()
|
|
1042
|
+
$xeList.clearCrossListDragStatus()
|
|
1043
|
+
reactData.dragRow = null
|
|
1044
|
+
}
|
|
1045
|
+
},
|
|
1046
|
+
handleRowDragMousedownEvent (evnt: MouseEvent, params: { row: any }) {
|
|
1047
|
+
const $xeList = this
|
|
1048
|
+
const reactData = $xeList.reactData
|
|
1049
|
+
|
|
1050
|
+
evnt.stopPropagation()
|
|
1051
|
+
const { row } = params
|
|
1052
|
+
const dragConfig = $xeList.computeDragOpts
|
|
1053
|
+
const { trigger, dragStartMethod } = dragConfig
|
|
1054
|
+
const dragEl = evnt.currentTarget as HTMLElement
|
|
1055
|
+
const rowEl = trigger === 'row' ? dragEl : (dragEl.parentElement as HTMLElement).parentElement as HTMLElement
|
|
1056
|
+
$xeList.clearRowDropOrigin()
|
|
1057
|
+
if (dragStartMethod && !dragStartMethod(params)) {
|
|
1058
|
+
rowEl.draggable = false
|
|
1059
|
+
reactData.dragRow = null
|
|
1060
|
+
$xeList.hideDropTip()
|
|
1061
|
+
return
|
|
1062
|
+
}
|
|
1063
|
+
const dragstartEventParams: VxeListDefines.RowDragstartEventParams = {
|
|
1064
|
+
row
|
|
1065
|
+
}
|
|
1066
|
+
reactData.dragRow = row
|
|
1067
|
+
rowEl.draggable = true
|
|
1068
|
+
$xeList.updateRowDropOrigin(row)
|
|
1069
|
+
$xeList.updateRowDropTipContent(rowEl)
|
|
1070
|
+
$xeList.dispatchEvent('row-dragstart', dragstartEventParams, evnt)
|
|
1071
|
+
},
|
|
1072
|
+
handleRowDragMouseupEvent () {
|
|
1073
|
+
const $xeList = this
|
|
1074
|
+
|
|
1075
|
+
$xeList.clearDragStatus()
|
|
1076
|
+
},
|
|
1077
|
+
showDropTip (evnt: DragEvent | MouseEvent, rowEl: HTMLElement | null, showLine: boolean, dragPos: string) {
|
|
1078
|
+
const $xeList = this
|
|
1079
|
+
|
|
1080
|
+
const wrapperEl = $xeList.$refs.refElem as HTMLDivElement
|
|
1081
|
+
if (!wrapperEl) {
|
|
1082
|
+
return
|
|
1083
|
+
}
|
|
1084
|
+
const wrapperRect = wrapperEl.getBoundingClientRect()
|
|
1085
|
+
const wrapperHeight = wrapperEl.clientHeight
|
|
1086
|
+
if (rowEl) {
|
|
1087
|
+
const rdLineEl = $xeList.$refs.refDragRowLineElem as HTMLDivElement
|
|
1088
|
+
if (rdLineEl) {
|
|
1089
|
+
if (showLine) {
|
|
1090
|
+
const trRect = rowEl.getBoundingClientRect()
|
|
1091
|
+
let rowHeight = rowEl.clientHeight
|
|
1092
|
+
const offsetTop = Math.max(1, trRect.y - wrapperRect.y)
|
|
1093
|
+
if (offsetTop + rowHeight > wrapperHeight) {
|
|
1094
|
+
rowHeight = wrapperHeight - offsetTop
|
|
1095
|
+
}
|
|
1096
|
+
rdLineEl.style.display = 'block'
|
|
1097
|
+
rdLineEl.style.top = `${offsetTop}px`
|
|
1098
|
+
rdLineEl.style.height = `${rowHeight}px`
|
|
1099
|
+
rdLineEl.setAttribute('drag-pos', dragPos)
|
|
1100
|
+
} else {
|
|
1101
|
+
rdLineEl.style.display = ''
|
|
1102
|
+
}
|
|
1103
|
+
}
|
|
1104
|
+
}
|
|
1105
|
+
const rdTipEl = $xeList.$refs.refDragTipElem as HTMLDivElement
|
|
1106
|
+
if (rdTipEl) {
|
|
1107
|
+
rdTipEl.style.display = 'block'
|
|
1108
|
+
rdTipEl.style.top = `${Math.min(wrapperEl.clientHeight - wrapperEl.scrollTop - rdTipEl.clientHeight, evnt.clientY - wrapperRect.y)}px`
|
|
1109
|
+
rdTipEl.style.left = `${Math.min(wrapperEl.clientWidth - wrapperEl.scrollLeft - rdTipEl.clientWidth - 1, evnt.clientX - wrapperRect.x)}px`
|
|
1110
|
+
rdTipEl.setAttribute('drag-status', showLine ? 'normal' : 'disabled')
|
|
1111
|
+
}
|
|
1112
|
+
},
|
|
1113
|
+
clearRowDragData () {
|
|
1114
|
+
const $xeList = this
|
|
1115
|
+
const reactData = $xeList.reactData
|
|
1116
|
+
|
|
1117
|
+
const wrapperEl = $xeList.$refs.refElem as HTMLDivElement
|
|
1118
|
+
const dtClss = ['.vxe-list--row']
|
|
1119
|
+
$xeList.hideDropTip()
|
|
1120
|
+
$xeList.clearRowDropOrigin()
|
|
1121
|
+
clearRowAnimate(wrapperEl, dtClss)
|
|
1122
|
+
reactData.dragRow = null
|
|
1123
|
+
},
|
|
1124
|
+
handleRowDragSwapEvent (evnt: DragEvent | null, dragRow: any, prevDragRow: any, prevDragPos: '' | 'top' | 'bottom' | undefined) {
|
|
1125
|
+
const $xeList = this
|
|
1126
|
+
const reactData = $xeList.reactData
|
|
1127
|
+
const internalData = $xeList.internalData
|
|
1128
|
+
|
|
1129
|
+
const { fullData } = internalData
|
|
1130
|
+
const dragConfig = $xeList.computeDragOpts
|
|
1131
|
+
const { animation, dragEndMethod } = dragConfig
|
|
1132
|
+
const dEndMethod = dragEndMethod || (dragConfig ? dragConfig.dragEndMethod : null)
|
|
1133
|
+
const dragOffsetIndex: 0 | 1 = prevDragPos === 'bottom' ? 1 : 0
|
|
1134
|
+
const el = $xeList.$refs.refElem as HTMLDivElement
|
|
1135
|
+
const errRest = {
|
|
1136
|
+
status: false
|
|
1137
|
+
}
|
|
1138
|
+
if (!(el && prevDragRow && dragRow)) {
|
|
1139
|
+
return Promise.resolve(errRest)
|
|
1140
|
+
}
|
|
1141
|
+
// 判断是否有拖动
|
|
1142
|
+
if (prevDragRow !== dragRow) {
|
|
1143
|
+
const dragParams = {
|
|
1144
|
+
oldRow: dragRow,
|
|
1145
|
+
newRow: prevDragRow,
|
|
1146
|
+
dragRow,
|
|
1147
|
+
dragPos: prevDragPos as 'top' | 'bottom',
|
|
1148
|
+
offsetIndex: dragOffsetIndex
|
|
1149
|
+
}
|
|
1150
|
+
|
|
1151
|
+
const dragRowid = $xeList.getRowId(dragRow)
|
|
1152
|
+
const _dragRowIndex = $xeList.findRowIndexOfByKey(fullData, dragRowid)
|
|
1153
|
+
const newRowid = $xeList.getRowKey(prevDragRow)
|
|
1154
|
+
let dragRowHeight = 0
|
|
1155
|
+
let dragOffsetTop = -1
|
|
1156
|
+
if (animation) {
|
|
1157
|
+
const prevRowEl = el.querySelector<HTMLElement>(`.vxe-list--row[rowid="${newRowid}"]`)
|
|
1158
|
+
const oldRowEl = el.querySelector<HTMLElement>(`.vxe-list--row[rowid="${dragRowid}"]`)
|
|
1159
|
+
const targetRowEl = prevRowEl || oldRowEl
|
|
1160
|
+
if (targetRowEl) {
|
|
1161
|
+
dragRowHeight = targetRowEl.offsetHeight
|
|
1162
|
+
}
|
|
1163
|
+
if (oldRowEl) {
|
|
1164
|
+
dragOffsetTop = oldRowEl.offsetTop
|
|
1165
|
+
}
|
|
1166
|
+
}
|
|
1167
|
+
|
|
1168
|
+
let oafIndex = -1
|
|
1169
|
+
let nafIndex = -1
|
|
1170
|
+
|
|
1171
|
+
return Promise.resolve(dEndMethod ? dEndMethod(dragParams) : true).then((status) => {
|
|
1172
|
+
if (!status) {
|
|
1173
|
+
return errRest
|
|
1174
|
+
}
|
|
1175
|
+
|
|
1176
|
+
// 移出
|
|
1177
|
+
oafIndex = $xeList.findRowIndexOf(fullData, dragRow)
|
|
1178
|
+
fullData.splice(oafIndex, 1)
|
|
1179
|
+
// 插入
|
|
1180
|
+
const pafIndex = $xeList.findRowIndexOf(fullData, prevDragRow)
|
|
1181
|
+
nafIndex = pafIndex + dragOffsetIndex
|
|
1182
|
+
fullData.splice(nafIndex, 0, dragRow)
|
|
1183
|
+
|
|
1184
|
+
$xeList.handleData()
|
|
1185
|
+
if (reactData.scrollYLoad) {
|
|
1186
|
+
$xeList.updateYSpace()
|
|
1187
|
+
}
|
|
1188
|
+
|
|
1189
|
+
if (evnt) {
|
|
1190
|
+
const dragendEventParams: VxeListDefines.RowDragendEventParams = {
|
|
1191
|
+
oldRow: dragRow,
|
|
1192
|
+
newRow: prevDragRow,
|
|
1193
|
+
dragRow,
|
|
1194
|
+
dragPos: prevDragPos as 'top' | 'bottom',
|
|
1195
|
+
offsetIndex: dragOffsetIndex,
|
|
1196
|
+
_index: {
|
|
1197
|
+
newIndex: nafIndex,
|
|
1198
|
+
oldIndex: oafIndex
|
|
1199
|
+
}
|
|
1200
|
+
}
|
|
1201
|
+
$xeList.dispatchEvent('row-dragend', dragendEventParams, evnt)
|
|
1202
|
+
}
|
|
1203
|
+
|
|
1204
|
+
return $xeList.$nextTick().then(() => {
|
|
1205
|
+
if (animation) {
|
|
1206
|
+
const { rowList } = reactData
|
|
1207
|
+
const { fullData } = internalData
|
|
1208
|
+
const _newRowIndex = $xeList.findRowIndexOfByKey(fullData, dragRowid)
|
|
1209
|
+
const firstRow = fullData[0]
|
|
1210
|
+
const _firstRowIndex = $xeList.findRowIndexOf(fullData, firstRow)
|
|
1211
|
+
const wrapperEl = el
|
|
1212
|
+
if (_firstRowIndex > -1) {
|
|
1213
|
+
const _lastRowIndex = _firstRowIndex + fullData.length
|
|
1214
|
+
|
|
1215
|
+
let rsIndex = -1
|
|
1216
|
+
let reIndex = -1
|
|
1217
|
+
let offsetRate = 1
|
|
1218
|
+
if (_dragRowIndex < _firstRowIndex) {
|
|
1219
|
+
// 从上往下虚拟拖拽
|
|
1220
|
+
rsIndex = 0
|
|
1221
|
+
reIndex = _newRowIndex - _firstRowIndex
|
|
1222
|
+
} else if (_dragRowIndex > _lastRowIndex) {
|
|
1223
|
+
// 从下往上虚拟拖拽
|
|
1224
|
+
const $newRowIndex = $xeList.findRowIndexOfByKey(rowList, dragRowid)
|
|
1225
|
+
rsIndex = $newRowIndex + 1
|
|
1226
|
+
reIndex = fullData.length
|
|
1227
|
+
offsetRate = -1
|
|
1228
|
+
} else {
|
|
1229
|
+
if (_newRowIndex > _dragRowIndex) {
|
|
1230
|
+
// 从上往下拖拽
|
|
1231
|
+
rsIndex = _dragRowIndex - _firstRowIndex
|
|
1232
|
+
reIndex = rsIndex + _newRowIndex - _dragRowIndex
|
|
1233
|
+
} else {
|
|
1234
|
+
// 从下往上拖拽
|
|
1235
|
+
rsIndex = _newRowIndex - _firstRowIndex
|
|
1236
|
+
reIndex = rsIndex + _dragRowIndex - _newRowIndex + 1
|
|
1237
|
+
offsetRate = -1
|
|
1238
|
+
}
|
|
1239
|
+
}
|
|
1240
|
+
|
|
1241
|
+
const dragRangeList = fullData.slice(rsIndex, reIndex)
|
|
1242
|
+
if (dragRangeList.length) {
|
|
1243
|
+
const dtClss: string[] = []
|
|
1244
|
+
dragRangeList.forEach(obj => {
|
|
1245
|
+
const rowid = $xeList.getRowId(obj)
|
|
1246
|
+
dtClss.push(`.vxe-list--row[rowid="${rowid}"]`)
|
|
1247
|
+
})
|
|
1248
|
+
const dtTrList = wrapperEl.querySelectorAll<HTMLElement>(dtClss.join(','))
|
|
1249
|
+
moveRowAnimateToTb(dtTrList, offsetRate * dragRowHeight)
|
|
1250
|
+
}
|
|
1251
|
+
}
|
|
1252
|
+
|
|
1253
|
+
const drClss = [`.vxe-list--row[rowid="${dragRowid}"]`]
|
|
1254
|
+
const newDtTrList = wrapperEl.querySelectorAll<HTMLElement>(drClss.join(','))
|
|
1255
|
+
const newTrEl = newDtTrList[0]
|
|
1256
|
+
if (dragOffsetTop > -1 && newTrEl) {
|
|
1257
|
+
moveRowAnimateToTb(newDtTrList, dragOffsetTop - newTrEl.offsetTop)
|
|
1258
|
+
}
|
|
1259
|
+
}
|
|
1260
|
+
|
|
1261
|
+
$xeList.recalculate()
|
|
1262
|
+
}).then(() => {
|
|
1263
|
+
return {
|
|
1264
|
+
status: true
|
|
1265
|
+
}
|
|
1266
|
+
})
|
|
1267
|
+
}).catch(() => {
|
|
1268
|
+
return errRest
|
|
1269
|
+
}).then((rest) => {
|
|
1270
|
+
$xeList.clearRowDragData()
|
|
1271
|
+
$xeList.clearCrossListDragStatus()
|
|
1272
|
+
return rest
|
|
1273
|
+
})
|
|
1274
|
+
}
|
|
1275
|
+
$xeList.clearRowDragData()
|
|
1276
|
+
$xeList.clearCrossListDragStatus()
|
|
1277
|
+
return Promise.resolve(errRest)
|
|
1278
|
+
},
|
|
1279
|
+
handleRowDragDragstartEvent (evnt: DragEvent) {
|
|
1280
|
+
if (evnt.dataTransfer) {
|
|
1281
|
+
evnt.dataTransfer.setDragImage(getTpImg(), 0, 0)
|
|
1282
|
+
}
|
|
1283
|
+
},
|
|
1284
|
+
handleRowDragDragendEvent (evnt: DragEvent) {
|
|
1285
|
+
const $xeList = this
|
|
1286
|
+
const reactData = $xeList.reactData
|
|
1287
|
+
const internalData = $xeList.internalData
|
|
1288
|
+
|
|
1289
|
+
const { dragRow } = reactData
|
|
1290
|
+
const { prevDragRow, prevDragPos } = internalData
|
|
1291
|
+
$xeList.handleRowDragSwapEvent(evnt, dragRow, prevDragRow, prevDragPos)
|
|
1292
|
+
},
|
|
1293
|
+
handleRowDragDragoverEvent (evnt: DragEvent) {
|
|
1294
|
+
const $xeList = this
|
|
1295
|
+
const reactData = $xeList.reactData
|
|
1296
|
+
const internalData = $xeList.internalData
|
|
1297
|
+
|
|
1298
|
+
const { dragRow } = reactData
|
|
1299
|
+
const { fullData } = internalData
|
|
1300
|
+
if (!dragRow) {
|
|
1301
|
+
evnt.preventDefault()
|
|
1302
|
+
}
|
|
1303
|
+
const rowEl = evnt.currentTarget as HTMLElement
|
|
1304
|
+
const rowid = rowEl.getAttribute('rowid') || ''
|
|
1305
|
+
const row = $xeList.findRowByKey(fullData, rowid)
|
|
1306
|
+
if (row) {
|
|
1307
|
+
evnt.preventDefault()
|
|
1308
|
+
const offsetY = evnt.clientY - rowEl.getBoundingClientRect().y
|
|
1309
|
+
const dragPos = offsetY < rowEl.clientHeight / 2 ? 'top' : 'bottom'
|
|
1310
|
+
internalData.prevDragRow = row
|
|
1311
|
+
internalData.prevDragPos = dragPos
|
|
1312
|
+
if ((dragRow && $xeList.getRowId(dragRow) === rowid)) {
|
|
1313
|
+
$xeList.showDropTip(evnt, rowEl, false, dragPos)
|
|
1314
|
+
return
|
|
1315
|
+
}
|
|
1316
|
+
const dragOffsetIndex = dragPos === 'bottom' ? 1 : 0
|
|
1317
|
+
const offsetIndex = dragOffsetIndex
|
|
1318
|
+
const dragoverEventParams: VxeListDefines.RowDragoverEventParams = {
|
|
1319
|
+
oldRow: dragRow,
|
|
1320
|
+
targetRow: row,
|
|
1321
|
+
dragPos,
|
|
1322
|
+
dragRow,
|
|
1323
|
+
offsetIndex
|
|
1324
|
+
}
|
|
1325
|
+
$xeList.showDropTip(evnt, rowEl, true, dragPos)
|
|
1326
|
+
$xeList.dispatchEvent('row-dragover', dragoverEventParams, evnt)
|
|
1327
|
+
}
|
|
1328
|
+
},
|
|
1329
|
+
handleRowMousedownEvent (evnt: MouseEvent, row: any) {
|
|
1330
|
+
const $xeList = this
|
|
1331
|
+
|
|
1332
|
+
const dragConfig = $xeList.computeDragOpts
|
|
1333
|
+
const isDrag = $xeList.computeIsDrag
|
|
1334
|
+
const { trigger, disabledMethod } = dragConfig
|
|
1335
|
+
let isRowDrag = false
|
|
1336
|
+
if (isDrag) {
|
|
1337
|
+
isRowDrag = trigger === 'row'
|
|
1338
|
+
}
|
|
1339
|
+
const params = { row, $list: $xeList }
|
|
1340
|
+
if (isRowDrag && !(disabledMethod && disabledMethod(params))) {
|
|
1341
|
+
$xeList.handleRowDragMousedownEvent(evnt, params)
|
|
1342
|
+
}
|
|
1343
|
+
},
|
|
1344
|
+
handleRowClickEvent (evnt: MouseEvent, row: any) {
|
|
1345
|
+
const $xeList = this
|
|
1346
|
+
const reactData = $xeList.reactData
|
|
1347
|
+
const internalData = $xeList.internalData
|
|
1348
|
+
|
|
1349
|
+
const { currentRow } = internalData
|
|
1350
|
+
const rowOpts = $xeList.computeRowOpts
|
|
1351
|
+
const { isCurrent } = rowOpts
|
|
1352
|
+
let triggerCurrent = false
|
|
1353
|
+
if (isCurrent) {
|
|
1354
|
+
triggerCurrent = true
|
|
1355
|
+
$xeList.changeCurrentEvent(evnt, row)
|
|
1356
|
+
} else if (currentRow) {
|
|
1357
|
+
internalData.currentRow = null
|
|
1358
|
+
reactData.currRowFlag++
|
|
1359
|
+
}
|
|
1360
|
+
$xeList.dispatchEvent('row-click', { row, triggerCurrent }, evnt)
|
|
1361
|
+
},
|
|
1362
|
+
handleRowDblclickEvent (evnt: MouseEvent, row: any) {
|
|
1363
|
+
const $xeList = this
|
|
1364
|
+
|
|
1365
|
+
$xeList.dispatchEvent('row-dblclick', { row }, evnt)
|
|
1366
|
+
},
|
|
367
1367
|
|
|
368
1368
|
//
|
|
369
1369
|
// Render
|
|
370
1370
|
//
|
|
1371
|
+
renderDragTip (h: CreateElement) {
|
|
1372
|
+
const $xeList = this
|
|
1373
|
+
const reactData = $xeList.reactData
|
|
1374
|
+
|
|
1375
|
+
const { dragRow, dragTipText } = reactData
|
|
1376
|
+
const dragOpts = $xeList.computeDragOpts
|
|
1377
|
+
const isDrag = $xeList.computeIsDrag
|
|
1378
|
+
const dRow = dragRow
|
|
1379
|
+
if (isDrag) {
|
|
1380
|
+
return h('div', {
|
|
1381
|
+
class: 'vxe-list--drag-wrapper'
|
|
1382
|
+
}, [
|
|
1383
|
+
h('div', {
|
|
1384
|
+
ref: 'refDragRowLineElem',
|
|
1385
|
+
class: ['vxe-list--drag-row-line', {
|
|
1386
|
+
'is--guides': dragOpts.showGuidesStatus
|
|
1387
|
+
}]
|
|
1388
|
+
}),
|
|
1389
|
+
dRow && dragOpts.showDragTip
|
|
1390
|
+
? h('div', {
|
|
1391
|
+
ref: 'refDragTipElem',
|
|
1392
|
+
class: 'vxe-list--drag-sort-tip'
|
|
1393
|
+
}, [
|
|
1394
|
+
h('div', {
|
|
1395
|
+
class: 'vxe-list--drag-sort-tip-wrapper'
|
|
1396
|
+
}, [
|
|
1397
|
+
h('div', {
|
|
1398
|
+
class: 'vxe-list--drag-sort-tip-status'
|
|
1399
|
+
}, [
|
|
1400
|
+
h('span', {
|
|
1401
|
+
class: ['vxe-list--drag-sort-tip-normal-status', getIcon().LIST_DRAG_STATUS_NODE]
|
|
1402
|
+
}),
|
|
1403
|
+
h('span', {
|
|
1404
|
+
class: ['vxe-list--drag-sort-tip-disabled-status', getIcon().LIST_DRAG_DISABLED]
|
|
1405
|
+
})
|
|
1406
|
+
]),
|
|
1407
|
+
h('div', {
|
|
1408
|
+
class: 'vxe-list--drag-sort-tip-content'
|
|
1409
|
+
}, dragTipText)
|
|
1410
|
+
])
|
|
1411
|
+
])
|
|
1412
|
+
: renderEmptyElement($xeList)
|
|
1413
|
+
])
|
|
1414
|
+
}
|
|
1415
|
+
return renderEmptyElement($xeList)
|
|
1416
|
+
},
|
|
1417
|
+
renderRadio (h: CreateElement, row: any, rowid: string, isChecked: boolean) {
|
|
1418
|
+
const $xeList = this
|
|
1419
|
+
const props = $xeList
|
|
1420
|
+
|
|
1421
|
+
const { showRadio } = props
|
|
1422
|
+
const radioOpts = $xeList.computeRadioOpts
|
|
1423
|
+
const { showIcon, checkMethod, visibleMethod } = radioOpts
|
|
1424
|
+
const isVisible = !visibleMethod || visibleMethod({ $list: $xeList, row })
|
|
1425
|
+
if (showRadio && showIcon && isVisible) {
|
|
1426
|
+
const isDisabled = checkMethod ? !checkMethod({ $list: $xeList, row }) : false
|
|
1427
|
+
return h('div', {
|
|
1428
|
+
key: 'ct2',
|
|
1429
|
+
class: ['vxe-list--radio-option', {
|
|
1430
|
+
'is--checked': isChecked,
|
|
1431
|
+
'is--disabled': isDisabled
|
|
1432
|
+
}],
|
|
1433
|
+
on: {
|
|
1434
|
+
click (evnt: MouseEvent) {
|
|
1435
|
+
if (!isDisabled) {
|
|
1436
|
+
$xeList.changeRadioEvent(evnt, row)
|
|
1437
|
+
}
|
|
1438
|
+
}
|
|
1439
|
+
}
|
|
1440
|
+
}, [
|
|
1441
|
+
h('span', {
|
|
1442
|
+
class: ['vxe-radio--icon', isChecked ? getIcon().RADIO_CHECKED : getIcon().RADIO_UNCHECKED]
|
|
1443
|
+
})
|
|
1444
|
+
])
|
|
1445
|
+
}
|
|
1446
|
+
return renderEmptyElement($xeList)
|
|
1447
|
+
},
|
|
1448
|
+
renderCheckbox (h: CreateElement, row: any, rowid: string, isChecked: boolean) {
|
|
1449
|
+
const $xeList = this
|
|
1450
|
+
const props = $xeList
|
|
1451
|
+
|
|
1452
|
+
const { showCheckbox } = props
|
|
1453
|
+
const checkboxOpts = $xeList.computeCheckboxOpts
|
|
1454
|
+
const { showIcon, checkMethod, visibleMethod } = checkboxOpts
|
|
1455
|
+
const isVisible = !visibleMethod || visibleMethod({ $list: $xeList, row })
|
|
1456
|
+
if (showCheckbox && showIcon && isVisible) {
|
|
1457
|
+
const isDisabled = checkMethod ? !checkMethod({ $list: $xeList, row }) : false
|
|
1458
|
+
return h('div', {
|
|
1459
|
+
key: 'ct3',
|
|
1460
|
+
class: ['vxe-list--checkbox-option', {
|
|
1461
|
+
'is--checked': isChecked,
|
|
1462
|
+
'is--disabled': isDisabled
|
|
1463
|
+
}],
|
|
1464
|
+
on: {
|
|
1465
|
+
click (evnt: MouseEvent) {
|
|
1466
|
+
if (!isDisabled) {
|
|
1467
|
+
$xeList.changeCheckboxEvent(evnt, row)
|
|
1468
|
+
}
|
|
1469
|
+
}
|
|
1470
|
+
}
|
|
1471
|
+
}, [
|
|
1472
|
+
h('span', {
|
|
1473
|
+
class: ['vxe-checkbox--icon', isChecked ? getIcon().CHECKBOX_CHECKED : getIcon().CHECKBOX_UNCHECKED]
|
|
1474
|
+
})
|
|
1475
|
+
])
|
|
1476
|
+
}
|
|
1477
|
+
return renderEmptyElement($xeList)
|
|
1478
|
+
},
|
|
1479
|
+
renderRow (h: CreateElement, row: any, rowIndex: any) {
|
|
1480
|
+
const $xeList = this
|
|
1481
|
+
const props = $xeList
|
|
1482
|
+
const reactData = $xeList.reactData
|
|
1483
|
+
const internalData = $xeList.internalData
|
|
1484
|
+
const slots = $xeList.$scopedSlots
|
|
1485
|
+
|
|
1486
|
+
const { showRadio, showCheckbox } = props
|
|
1487
|
+
const { selectRadioRow, currRowFlag, updateCheckboxFlag } = reactData
|
|
1488
|
+
const { selectCheckboxMaps, currentRow } = internalData
|
|
1489
|
+
const contentSlot = slots.content
|
|
1490
|
+
const dragOpts = $xeList.computeDragOpts
|
|
1491
|
+
const { trigger, icon, disabledMethod, visibleMethod } = dragOpts
|
|
1492
|
+
const rowOpts = $xeList.computeRowOpts
|
|
1493
|
+
const { useKey, contentField, className: rowClassName, isCurrent } = rowOpts
|
|
1494
|
+
const isDrag = $xeList.computeIsDrag
|
|
1495
|
+
const keyField = $xeList.computeKeyField
|
|
1496
|
+
const isRowFnCls = rowClassName && XEUtils.isFunction(rowClassName)
|
|
1497
|
+
|
|
1498
|
+
const hasKey = keyField || useKey || isDrag || isCurrent || showRadio || showCheckbox
|
|
1499
|
+
|
|
1500
|
+
const rowKey = hasKey && keyField ? getRowIdByField(row, keyField) : ''
|
|
1501
|
+
const rowid = enModelValue(rowKey)
|
|
1502
|
+
const rowParams = { row, $list: $xeList }
|
|
1503
|
+
|
|
1504
|
+
let isRadioChecked = false
|
|
1505
|
+
if (showRadio) {
|
|
1506
|
+
isRadioChecked = selectRadioRow && (row === selectRadioRow || $xeList.eqRowByKey(selectRadioRow, rowKey))
|
|
1507
|
+
}
|
|
1508
|
+
|
|
1509
|
+
let isCheckboxChecked = false
|
|
1510
|
+
if (showCheckbox) {
|
|
1511
|
+
isCheckboxChecked = !!(updateCheckboxFlag && selectCheckboxMaps[rowid])
|
|
1512
|
+
}
|
|
1513
|
+
|
|
1514
|
+
const ctVNs: VNode[] = []
|
|
1515
|
+
let isDragDisabled = false
|
|
1516
|
+
if (isDrag && keyField && (!visibleMethod || visibleMethod(rowParams))) {
|
|
1517
|
+
const handleOns: {
|
|
1518
|
+
mousedown?: (evnt: MouseEvent) => void
|
|
1519
|
+
mouseup?: (evnt: MouseEvent) => void
|
|
1520
|
+
} = {}
|
|
1521
|
+
if (trigger !== 'row') {
|
|
1522
|
+
isDragDisabled = !!(disabledMethod && disabledMethod(rowParams))
|
|
1523
|
+
handleOns.mousedown = (evnt) => {
|
|
1524
|
+
if (!isDragDisabled) {
|
|
1525
|
+
$xeList.handleRowDragMousedownEvent(evnt, rowParams)
|
|
1526
|
+
}
|
|
1527
|
+
}
|
|
1528
|
+
handleOns.mouseup = $xeList.handleRowDragMouseupEvent
|
|
1529
|
+
}
|
|
1530
|
+
ctVNs.push(
|
|
1531
|
+
h('div', {
|
|
1532
|
+
key: 'ct1',
|
|
1533
|
+
class: 'vxe-list--row-drag'
|
|
1534
|
+
}, [
|
|
1535
|
+
h('span', {
|
|
1536
|
+
class: 'vxe-list--drag-handle',
|
|
1537
|
+
on: handleOns
|
|
1538
|
+
}, [
|
|
1539
|
+
h('i', {
|
|
1540
|
+
class: icon || getIcon().LIST_DRAG
|
|
1541
|
+
})
|
|
1542
|
+
])
|
|
1543
|
+
])
|
|
1544
|
+
)
|
|
1545
|
+
}
|
|
1546
|
+
if (showRadio) {
|
|
1547
|
+
ctVNs.push(
|
|
1548
|
+
$xeList.renderRadio(h, row, rowid, isRadioChecked)
|
|
1549
|
+
)
|
|
1550
|
+
}
|
|
1551
|
+
if (showCheckbox) {
|
|
1552
|
+
ctVNs.push(
|
|
1553
|
+
$xeList.renderCheckbox(h, row, rowid, isCheckboxChecked)
|
|
1554
|
+
)
|
|
1555
|
+
}
|
|
1556
|
+
ctVNs.push(
|
|
1557
|
+
h('div', {
|
|
1558
|
+
key: 'ct5',
|
|
1559
|
+
class: 'vxe-list--row-content'
|
|
1560
|
+
}, contentSlot ? contentSlot(rowParams) : (contentField ? getText(row[contentField]) : ''))
|
|
1561
|
+
)
|
|
1562
|
+
|
|
1563
|
+
const rowOns: {
|
|
1564
|
+
mousedown: (evnt: MouseEvent) => void
|
|
1565
|
+
mouseup: (evnt: MouseEvent) => void
|
|
1566
|
+
click: (evnt: MouseEvent) => void
|
|
1567
|
+
dblclick: (evnt: MouseEvent) => void
|
|
1568
|
+
dragstart?: (evnt: DragEvent) => void
|
|
1569
|
+
dragend?: (evnt: DragEvent) => void
|
|
1570
|
+
dragover?: (evnt: DragEvent) => void
|
|
1571
|
+
} = {
|
|
1572
|
+
mousedown (evnt: MouseEvent) {
|
|
1573
|
+
$xeList.handleRowMousedownEvent(evnt, row)
|
|
1574
|
+
},
|
|
1575
|
+
mouseup: $xeList.handleRowDragMouseupEvent,
|
|
1576
|
+
click (evnt: MouseEvent) {
|
|
1577
|
+
$xeList.handleRowClickEvent(evnt, row)
|
|
1578
|
+
},
|
|
1579
|
+
dblclick (evnt: MouseEvent) {
|
|
1580
|
+
$xeList.handleRowDblclickEvent(evnt, row)
|
|
1581
|
+
}
|
|
1582
|
+
}
|
|
1583
|
+
// 拖拽行事件
|
|
1584
|
+
if (isDrag) {
|
|
1585
|
+
rowOns.dragstart = $xeList.handleRowDragDragstartEvent
|
|
1586
|
+
rowOns.dragend = $xeList.handleRowDragDragendEvent
|
|
1587
|
+
rowOns.dragover = $xeList.handleRowDragDragoverEvent
|
|
1588
|
+
}
|
|
1589
|
+
|
|
1590
|
+
return h('div', {
|
|
1591
|
+
key: hasKey && keyField ? rowid : rowIndex,
|
|
1592
|
+
class: ['vxe-list--row', isRowFnCls ? rowClassName(rowParams) : (rowClassName || ''), {
|
|
1593
|
+
'is--drag-disabled': isDragDisabled,
|
|
1594
|
+
'is--current': currRowFlag && currentRow && $xeList.eqRowByKey(currentRow, rowKey),
|
|
1595
|
+
'is-radio--checked': isRadioChecked,
|
|
1596
|
+
'is-checkbox--checked': isCheckboxChecked
|
|
1597
|
+
}],
|
|
1598
|
+
attrs: hasKey && keyField
|
|
1599
|
+
? {
|
|
1600
|
+
rowid
|
|
1601
|
+
}
|
|
1602
|
+
: undefined,
|
|
1603
|
+
on: rowOns
|
|
1604
|
+
}, ctVNs)
|
|
1605
|
+
},
|
|
371
1606
|
renderVN (h: CreateElement): VNode {
|
|
372
1607
|
const $xeList = this
|
|
373
1608
|
const props = $xeList
|
|
374
1609
|
const reactData = $xeList.reactData
|
|
375
1610
|
const slots = $xeList.$scopedSlots
|
|
376
1611
|
|
|
377
|
-
const { className, loading } = props
|
|
378
|
-
const { bodyHeight, topSpaceHeight,
|
|
1612
|
+
const { showCheckbox, className, loading } = props
|
|
1613
|
+
const { bodyHeight, topSpaceHeight, rowList, isAllChecked, isAllIndeterminate } = reactData
|
|
379
1614
|
const defaultSlot = slots.default
|
|
1615
|
+
const headerSlot = slots.header
|
|
1616
|
+
const footerSlot = slots.footer
|
|
380
1617
|
const vSize = $xeList.computeSize
|
|
381
|
-
const
|
|
1618
|
+
const wrapperStyles = $xeList.computeWrapperStyles
|
|
1619
|
+
const virtualStyles = $xeList.computeVirtualStyles
|
|
1620
|
+
const radioOpts = $xeList.computeRadioOpts
|
|
1621
|
+
const checkboxOpts = $xeList.computeCheckboxOpts
|
|
1622
|
+
const dragOpts = $xeList.computeDragOpts
|
|
1623
|
+
const { trigger } = dragOpts
|
|
1624
|
+
const rowOpts = $xeList.computeRowOpts
|
|
1625
|
+
const { isHover, padding } = rowOpts
|
|
1626
|
+
const showDefChekboxHead = showCheckbox && checkboxOpts.showHeader !== false
|
|
382
1627
|
return h('div', {
|
|
383
1628
|
ref: 'refElem',
|
|
384
1629
|
class: ['vxe-list', className ? (XEUtils.isFunction(className) ? className({ $list: $xeList }) : className) : '', {
|
|
385
1630
|
[`size--${vSize}`]: vSize,
|
|
386
1631
|
'is--loading': loading
|
|
387
|
-
}]
|
|
1632
|
+
}],
|
|
1633
|
+
style: wrapperStyles
|
|
388
1634
|
}, [
|
|
1635
|
+
headerSlot || showDefChekboxHead
|
|
1636
|
+
? h('div', {
|
|
1637
|
+
ref: 'refHeaderElem',
|
|
1638
|
+
class: 'vxe-list--header-wrapper'
|
|
1639
|
+
}, [
|
|
1640
|
+
showDefChekboxHead
|
|
1641
|
+
? h('div', {
|
|
1642
|
+
class: 'vxe-list--header-left'
|
|
1643
|
+
}, [
|
|
1644
|
+
h('div', {
|
|
1645
|
+
class: ['vxe-list--checkbox-header', {
|
|
1646
|
+
'is--checked': isAllChecked,
|
|
1647
|
+
'is--indeterminate': isAllIndeterminate
|
|
1648
|
+
}],
|
|
1649
|
+
on: {
|
|
1650
|
+
click: $xeList.changeCheckboxAllEvent
|
|
1651
|
+
}
|
|
1652
|
+
}, [
|
|
1653
|
+
h('span', {
|
|
1654
|
+
class: ['vxe-checkbox--icon', isAllChecked ? getIcon().CHECKBOX_CHECKED : (isAllIndeterminate ? getIcon().CHECKBOX_INDETERMINATE : getIcon().CHECKBOX_UNCHECKED)]
|
|
1655
|
+
})
|
|
1656
|
+
])
|
|
1657
|
+
])
|
|
1658
|
+
: renderEmptyElement($xeList),
|
|
1659
|
+
headerSlot
|
|
1660
|
+
? h('div', {
|
|
1661
|
+
class: 'vxe-list--header-content'
|
|
1662
|
+
}, headerSlot({ items: rowList, $list: $xeList }))
|
|
1663
|
+
: renderEmptyElement($xeList)
|
|
1664
|
+
])
|
|
1665
|
+
: renderEmptyElement($xeList),
|
|
389
1666
|
h('div', {
|
|
390
1667
|
ref: 'refVirtualWrapper',
|
|
391
1668
|
class: 'vxe-list--virtual-wrapper',
|
|
392
|
-
style:
|
|
1669
|
+
style: virtualStyles,
|
|
393
1670
|
on: {
|
|
394
1671
|
scroll: $xeList.scrollEvent
|
|
395
1672
|
}
|
|
@@ -402,12 +1679,28 @@ export default /* define-vxe-component start */ defineVxeComponent({
|
|
|
402
1679
|
}),
|
|
403
1680
|
h('div', {
|
|
404
1681
|
ref: 'refVirtualBody',
|
|
405
|
-
class: 'vxe-list--body',
|
|
1682
|
+
class: ['vxe-list--body', {
|
|
1683
|
+
'trigger--row': trigger === 'row',
|
|
1684
|
+
'checkbox--highlight': checkboxOpts.highlight,
|
|
1685
|
+
'radio--highlight': radioOpts.highlight,
|
|
1686
|
+
'row--hover': isHover,
|
|
1687
|
+
'is--padding': padding
|
|
1688
|
+
}],
|
|
406
1689
|
style: {
|
|
407
1690
|
marginTop: topSpaceHeight ? `${topSpaceHeight}px` : ''
|
|
408
1691
|
}
|
|
409
|
-
}, defaultSlot ?
|
|
1692
|
+
}, defaultSlot ? defaultSlot({ items: rowList, $list: $xeList }) : rowList.map((row, i) => $xeList.renderRow(h, row, i)))
|
|
410
1693
|
]),
|
|
1694
|
+
footerSlot
|
|
1695
|
+
? h('div', {
|
|
1696
|
+
ref: 'refFooterElem',
|
|
1697
|
+
class: 'vxe-list--footer-wrapper'
|
|
1698
|
+
}, footerSlot({ items: rowList, $list: $xeList }))
|
|
1699
|
+
: renderEmptyElement($xeList),
|
|
1700
|
+
/**
|
|
1701
|
+
* 拖拽提示
|
|
1702
|
+
*/
|
|
1703
|
+
$xeList.renderDragTip(h),
|
|
411
1704
|
/**
|
|
412
1705
|
* 加载中
|
|
413
1706
|
*/
|
|
@@ -430,20 +1723,39 @@ export default /* define-vxe-component start */ defineVxeComponent({
|
|
|
430
1723
|
height () {
|
|
431
1724
|
const $xeList = this
|
|
432
1725
|
|
|
433
|
-
$xeList.
|
|
1726
|
+
$xeList.reFlag++
|
|
434
1727
|
},
|
|
435
1728
|
maxHeight () {
|
|
436
1729
|
const $xeList = this
|
|
437
1730
|
|
|
438
|
-
$xeList.
|
|
1731
|
+
$xeList.reFlag++
|
|
439
1732
|
},
|
|
440
|
-
syncResize (
|
|
1733
|
+
syncResize () {
|
|
441
1734
|
const $xeList = this
|
|
442
1735
|
|
|
443
|
-
|
|
1736
|
+
$xeList.reFlag++
|
|
1737
|
+
},
|
|
1738
|
+
computeRowHeight () {
|
|
1739
|
+
const $xeList = this
|
|
1740
|
+
|
|
1741
|
+
$xeList.reFlag++
|
|
1742
|
+
},
|
|
1743
|
+
reFlag () {
|
|
1744
|
+
const $xeList = this
|
|
1745
|
+
|
|
1746
|
+
$xeList.$nextTick(() => {
|
|
444
1747
|
$xeList.recalculate()
|
|
445
|
-
|
|
446
|
-
|
|
1748
|
+
})
|
|
1749
|
+
},
|
|
1750
|
+
checkRowKey () {
|
|
1751
|
+
const $xeList = this
|
|
1752
|
+
|
|
1753
|
+
$xeList.updateRadioModeValue()
|
|
1754
|
+
},
|
|
1755
|
+
checkRowKeys () {
|
|
1756
|
+
const $xeList = this
|
|
1757
|
+
|
|
1758
|
+
$xeList.updateCheckboxModeValue()
|
|
447
1759
|
}
|
|
448
1760
|
},
|
|
449
1761
|
created () {
|
|
@@ -451,6 +1763,7 @@ export default /* define-vxe-component start */ defineVxeComponent({
|
|
|
451
1763
|
const props = $xeList
|
|
452
1764
|
|
|
453
1765
|
$xeList.internalData = createInternalData()
|
|
1766
|
+
$xeList.browseObj = XEUtils.browse()
|
|
454
1767
|
|
|
455
1768
|
$xeList.loadData(props.data || [])
|
|
456
1769
|
},
|
|
@@ -459,7 +1772,24 @@ export default /* define-vxe-component start */ defineVxeComponent({
|
|
|
459
1772
|
const props = $xeList
|
|
460
1773
|
const internalData = $xeList.internalData
|
|
461
1774
|
|
|
462
|
-
|
|
1775
|
+
const { showRadio, showCheckbox } = props
|
|
1776
|
+
const rowOpts = $xeList.computeRowOpts
|
|
1777
|
+
const { useKey, keyField } = rowOpts
|
|
1778
|
+
const isDrag = $xeList.computeIsDrag
|
|
1779
|
+
if (!keyField) {
|
|
1780
|
+
if (showRadio) {
|
|
1781
|
+
errLog('vxe.error.reqSupportProp', ['show-radio', 'row-config.keyField'])
|
|
1782
|
+
}
|
|
1783
|
+
if (showCheckbox) {
|
|
1784
|
+
errLog('vxe.error.reqSupportProp', ['show-checkbox', 'row-config.keyField'])
|
|
1785
|
+
}
|
|
1786
|
+
if (isDrag) {
|
|
1787
|
+
errLog('vxe.error.reqSupportProp', ['drag-config', 'row-config.keyField'])
|
|
1788
|
+
}
|
|
1789
|
+
}
|
|
1790
|
+
if (useKey && !keyField) {
|
|
1791
|
+
errLog('vxe.error.reqSupportProp', ['row-config.useKey', 'row-config.keyField'])
|
|
1792
|
+
}
|
|
463
1793
|
if (props.autoResize) {
|
|
464
1794
|
const el = $xeList.$refs.refElem as HTMLDivElement
|
|
465
1795
|
const resizeObserver = globalResize.create(() => $xeList.recalculate())
|
|
@@ -469,6 +1799,7 @@ export default /* define-vxe-component start */ defineVxeComponent({
|
|
|
469
1799
|
}
|
|
470
1800
|
internalData.resizeObserver = resizeObserver
|
|
471
1801
|
}
|
|
1802
|
+
$xeList.recalculate()
|
|
472
1803
|
globalEvents.on($xeList, 'resize', $xeList.recalculate)
|
|
473
1804
|
},
|
|
474
1805
|
activated () {
|