vxe-table 4.18.6 → 4.18.8
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/LICENSE +20 -20
- package/README.en.md +118 -118
- package/README.ja-JP.md +117 -117
- package/README.md +268 -268
- package/README.zh-TW.md +117 -117
- package/es/style.css +1 -1
- package/es/table/src/table.js +89 -79
- package/es/table/src/util.js +6 -0
- package/es/table/style.css +18 -48
- package/es/ui/index.js +1 -1
- package/es/ui/src/dom.js +21 -0
- package/es/ui/src/log.js +1 -1
- package/es/vxe-table/style.css +18 -48
- package/lib/index.common.js +2 -1
- package/lib/index.umd.js +2762 -2833
- package/lib/index.umd.min.js +1 -1
- package/lib/style.css +1 -1
- package/lib/table/src/table.js +15 -12
- package/lib/table/src/table.min.js +1 -1
- package/lib/table/src/util.js +6 -0
- package/lib/table/src/util.min.js +1 -1
- package/lib/table/style/style.css +18 -48
- package/lib/ui/index.js +1 -1
- package/lib/ui/index.min.js +1 -1
- package/lib/ui/src/dom.js +23 -0
- package/lib/ui/src/dom.min.js +1 -1
- package/lib/ui/src/log.js +1 -1
- package/lib/ui/src/log.min.js +1 -1
- package/lib/v-x-e-table/index.js +2 -1
- package/lib/v-x-e-table/index.min.js +1 -1
- package/lib/vxe-colgroup/index.js +2 -1
- package/lib/vxe-colgroup/index.min.js +1 -1
- package/lib/vxe-column/index.js +2 -1
- package/lib/vxe-column/index.min.js +1 -1
- package/lib/vxe-grid/index.js +2 -1
- package/lib/vxe-grid/index.min.js +1 -1
- package/lib/vxe-table/index.js +2 -1
- package/lib/vxe-table/index.min.js +1 -1
- package/lib/vxe-table/style/style.css +18 -48
- package/lib/vxe-toolbar/index.js +2 -1
- package/lib/vxe-toolbar/index.min.js +1 -1
- package/lib/vxe-ui/index.js +2 -1
- package/lib/vxe-ui/index.min.js +1 -1
- package/lib/vxe-v-x-e-table/index.js +2 -1
- package/lib/vxe-v-x-e-table/index.min.js +1 -1
- package/package.json +91 -91
- package/packages/colgroup/index.ts +22 -22
- package/packages/column/index.ts +22 -22
- package/packages/components.ts +43 -43
- package/packages/grid/index.ts +18 -18
- package/packages/grid/src/emits.ts +19 -19
- package/packages/grid/src/grid.ts +1768 -1768
- package/packages/grid/src/props.ts +23 -23
- package/packages/index.ts +4 -4
- package/packages/locale/lang/ar-EG.ts +832 -832
- package/packages/locale/lang/de-DE.ts +832 -832
- package/packages/locale/lang/en-US.ts +832 -832
- package/packages/locale/lang/es-ES.ts +832 -832
- package/packages/locale/lang/fr-FR.ts +832 -832
- package/packages/locale/lang/hu-HU.ts +832 -832
- package/packages/locale/lang/hy-AM.ts +832 -832
- package/packages/locale/lang/id-ID.ts +832 -832
- package/packages/locale/lang/it-IT.ts +832 -832
- package/packages/locale/lang/ja-JP.ts +832 -832
- package/packages/locale/lang/ko-KR.ts +832 -832
- package/packages/locale/lang/ms-MY.ts +832 -832
- package/packages/locale/lang/nb-NO.ts +832 -832
- package/packages/locale/lang/pt-BR.ts +832 -832
- package/packages/locale/lang/ru-RU.ts +832 -832
- package/packages/locale/lang/th-TH.ts +832 -832
- package/packages/locale/lang/ug-CN.ts +832 -832
- package/packages/locale/lang/uk-UA.ts +832 -832
- package/packages/locale/lang/uz-UZ.ts +832 -832
- package/packages/locale/lang/vi-VN.ts +832 -832
- package/packages/locale/lang/zh-CHT.ts +832 -832
- package/packages/locale/lang/zh-CN.ts +832 -832
- package/packages/locale/lang/zh-HK.ts +3 -3
- package/packages/locale/lang/zh-MO.ts +3 -3
- package/packages/locale/lang/zh-TC.ts +3 -3
- package/packages/locale/lang/zh-TW.ts +3 -3
- package/packages/table/index.ts +26 -26
- package/packages/table/module/custom/hook.ts +359 -359
- package/packages/table/module/custom/panel.ts +1331 -1331
- package/packages/table/module/edit/hook.ts +1032 -1032
- package/packages/table/module/export/export-panel.ts +567 -567
- package/packages/table/module/export/hook.ts +1654 -1654
- package/packages/table/module/export/import-panel.ts +266 -266
- package/packages/table/module/export/util.ts +24 -24
- package/packages/table/module/filter/hook.ts +468 -468
- package/packages/table/module/filter/panel.ts +301 -301
- package/packages/table/module/keyboard/hook.ts +495 -495
- package/packages/table/module/menu/hook.ts +325 -325
- package/packages/table/module/menu/panel.ts +201 -201
- package/packages/table/module/validator/hook.ts +631 -631
- package/packages/table/render/index.ts +1440 -1440
- package/packages/table/src/body.ts +932 -932
- package/packages/table/src/cell.ts +1290 -1290
- package/packages/table/src/column.ts +190 -190
- package/packages/table/src/columnInfo.ts +225 -225
- package/packages/table/src/emits.ts +123 -123
- package/packages/table/src/footer.ts +368 -368
- package/packages/table/src/group.ts +59 -59
- package/packages/table/src/header.ts +559 -559
- package/packages/table/src/props.ts +324 -324
- package/packages/table/src/store.ts +14 -14
- package/packages/table/src/table.ts +14010 -14001
- package/packages/table/src/use/cell-view.ts +44 -44
- package/packages/table/src/use/index.ts +1 -1
- package/packages/table/src/util.ts +1070 -1064
- package/packages/toolbar/index.ts +18 -18
- package/packages/toolbar/src/toolbar.ts +701 -701
- package/packages/ui/index.ts +530 -530
- package/packages/ui/src/anime.ts +52 -52
- package/packages/ui/src/comp.ts +3 -3
- package/packages/ui/src/dom.ts +259 -236
- package/packages/ui/src/log.ts +8 -8
- package/packages/ui/src/utils.ts +56 -56
- package/packages/ui/src/vn.ts +55 -55
- package/packages/v-x-e-table/index.d.ts +4 -4
- package/packages/v-x-e-table/index.ts +4 -4
- package/styles/all.scss +7 -7
- package/styles/base.scss +16 -16
- package/styles/components/grid.scss +89 -89
- package/styles/components/icon.scss +225 -225
- package/styles/components/old-icon.scss +715 -715
- package/styles/components/table-module/all.scss +6 -6
- package/styles/components/table-module/custom.scss +527 -527
- package/styles/components/table-module/export.scss +130 -130
- package/styles/components/table-module/filter.scss +130 -130
- package/styles/components/table-module/menu.scss +81 -81
- package/styles/components/table.scss +2679 -2679
- package/styles/components/toolbar.scss +119 -119
- package/styles/default.scss +2 -2
- package/styles/helpers/baseMixin.scss +95 -95
- package/styles/index.scss +4 -4
- package/styles/modules.scss +5 -5
- package/styles/theme/base.scss +93 -93
- package/styles/theme/dark.scss +49 -49
- package/styles/theme/light.scss +44 -44
- package/styles/variable.scss +43 -43
- package/types/all.d.ts +37 -37
- package/types/index.d.ts +4 -4
- /package/es/{iconfont.1773972993993.ttf → iconfont.1774240404046.ttf} +0 -0
- /package/es/{iconfont.1773972993993.woff → iconfont.1774240404046.woff} +0 -0
- /package/es/{iconfont.1773972993993.woff2 → iconfont.1774240404046.woff2} +0 -0
- /package/lib/{iconfont.1773972993993.ttf → iconfont.1774240404046.ttf} +0 -0
- /package/lib/{iconfont.1773972993993.woff → iconfont.1774240404046.woff} +0 -0
- /package/lib/{iconfont.1773972993993.woff2 → iconfont.1774240404046.woff2} +0 -0
|
@@ -1,567 +1,567 @@
|
|
|
1
|
-
import { h, ref, Ref, computed, reactive, inject, nextTick, VNode, PropType } from 'vue'
|
|
2
|
-
import { defineVxeComponent } from '../../../ui/src/comp'
|
|
3
|
-
import { VxeUI } from '../../../ui'
|
|
4
|
-
import XEUtils from 'xe-utils'
|
|
5
|
-
import { formatText } from '../../../ui/src/utils'
|
|
6
|
-
import { errLog } from '../../../ui/src/log'
|
|
7
|
-
|
|
8
|
-
import type { VxeTablePrivateMethods, VxeTableConstructor, VxeTableMethods, VxeTableDefines } from '../../../../types'
|
|
9
|
-
|
|
10
|
-
const { getI18n, getIcon, renderEmptyElement } = VxeUI
|
|
11
|
-
|
|
12
|
-
export default defineVxeComponent({
|
|
13
|
-
name: 'VxeTableExportPanel',
|
|
14
|
-
props: {
|
|
15
|
-
defaultOptions: {
|
|
16
|
-
type: Object as PropType<VxeTableDefines.ExportParamsObj>,
|
|
17
|
-
default: () => ({} as VxeTableDefines.ExportParamsObj)
|
|
18
|
-
},
|
|
19
|
-
storeData: {
|
|
20
|
-
type: Object as PropType<VxeTableDefines.ExportStoreObj>,
|
|
21
|
-
default: () => ({} as VxeTableDefines.ExportStoreObj)
|
|
22
|
-
}
|
|
23
|
-
},
|
|
24
|
-
setup (props) {
|
|
25
|
-
const VxeUIModalComponent = VxeUI.getComponent('VxeModal')
|
|
26
|
-
const VxeUIButtonComponent = VxeUI.getComponent('VxeButton')
|
|
27
|
-
const VxeUISelectComponent = VxeUI.getComponent('VxeSelect')
|
|
28
|
-
const VxeUIInputComponent = VxeUI.getComponent('VxeInput')
|
|
29
|
-
const VxeUICheckboxComponent = VxeUI.getComponent('VxeCheckbox')
|
|
30
|
-
|
|
31
|
-
const $xeTable = inject('$xeTable', {} as VxeTableConstructor & VxeTableMethods & VxeTablePrivateMethods)
|
|
32
|
-
const { computeExportOpts, computePrintOpts } = $xeTable.getComputeMaps()
|
|
33
|
-
|
|
34
|
-
const reactData = reactive({
|
|
35
|
-
isAll: false,
|
|
36
|
-
isIndeterminate: false,
|
|
37
|
-
loading: false
|
|
38
|
-
})
|
|
39
|
-
|
|
40
|
-
const xButtonConfirm = ref() as Ref<HTMLButtonElement>
|
|
41
|
-
const xInputFilename = ref() as Ref<HTMLInputElement>
|
|
42
|
-
const xInputSheetname = ref() as Ref<HTMLInputElement>
|
|
43
|
-
|
|
44
|
-
const computeCheckedAll = computed(() => {
|
|
45
|
-
const { storeData } = props
|
|
46
|
-
return storeData.columns.every((column) => column.checked)
|
|
47
|
-
})
|
|
48
|
-
|
|
49
|
-
const computeShowSheet = computed(() => {
|
|
50
|
-
const { defaultOptions } = props
|
|
51
|
-
return ['html', 'xml', 'xlsx', 'pdf'].indexOf(defaultOptions.type) > -1
|
|
52
|
-
})
|
|
53
|
-
|
|
54
|
-
const computeSupportMerge = computed(() => {
|
|
55
|
-
const { storeData, defaultOptions } = props
|
|
56
|
-
return !defaultOptions.original && defaultOptions.mode === 'current' && (storeData.isPrint || ['html', 'xlsx'].indexOf(defaultOptions.type) > -1)
|
|
57
|
-
})
|
|
58
|
-
|
|
59
|
-
// const computeSupportGroup = computed(() => {
|
|
60
|
-
// const { defaultOptions } = props
|
|
61
|
-
// return ['html', 'xlsx', 'csv', 'txt'].indexOf(defaultOptions.type) > -1
|
|
62
|
-
// })
|
|
63
|
-
|
|
64
|
-
const computeSupportStyle = computed(() => {
|
|
65
|
-
const { defaultOptions } = props
|
|
66
|
-
return !defaultOptions.original && ['xlsx'].indexOf(defaultOptions.type) > -1
|
|
67
|
-
})
|
|
68
|
-
|
|
69
|
-
const handleOptionCheck = (column: any) => {
|
|
70
|
-
const { storeData } = props
|
|
71
|
-
const matchObj = XEUtils.findTree(storeData.columns as any[], item => item === column)
|
|
72
|
-
if (matchObj && matchObj.parent) {
|
|
73
|
-
const { parent } = matchObj
|
|
74
|
-
if (parent.children && parent.children.length) {
|
|
75
|
-
parent.checked = parent.children.every((column: any) => column.checked)
|
|
76
|
-
parent.halfChecked = !parent.checked && parent.children.some((column: any) => column.checked || column.halfChecked)
|
|
77
|
-
handleOptionCheck(parent)
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
const checkStatus = () => {
|
|
83
|
-
const { storeData } = props
|
|
84
|
-
const columns = storeData.columns
|
|
85
|
-
reactData.isAll = columns.every((column: any) => column.disabled || column.checked)
|
|
86
|
-
reactData.isIndeterminate = !reactData.isAll && columns.some((column: any) => !column.disabled && (column.checked || column.halfChecked))
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
const changeOption = (column: any) => {
|
|
90
|
-
const isChecked = !column.checked
|
|
91
|
-
XEUtils.eachTree([column], (item) => {
|
|
92
|
-
item.checked = isChecked
|
|
93
|
-
item.halfChecked = false
|
|
94
|
-
})
|
|
95
|
-
handleOptionCheck(column)
|
|
96
|
-
checkStatus()
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
const allColumnEvent = () => {
|
|
100
|
-
const { storeData } = props
|
|
101
|
-
const isAll = !reactData.isAll
|
|
102
|
-
XEUtils.eachTree(storeData.columns, (column: any) => {
|
|
103
|
-
if (!column.disabled) {
|
|
104
|
-
column.checked = isAll
|
|
105
|
-
column.halfChecked = false
|
|
106
|
-
}
|
|
107
|
-
})
|
|
108
|
-
reactData.isAll = isAll
|
|
109
|
-
checkStatus()
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
const showEvent = () => {
|
|
113
|
-
nextTick(() => {
|
|
114
|
-
const filenameInp = xInputFilename.value
|
|
115
|
-
const sheetnameInp = xInputSheetname.value
|
|
116
|
-
const confirmBtn = xButtonConfirm.value
|
|
117
|
-
const targetElem = filenameInp || sheetnameInp || confirmBtn
|
|
118
|
-
if (targetElem) {
|
|
119
|
-
targetElem.focus()
|
|
120
|
-
}
|
|
121
|
-
})
|
|
122
|
-
checkStatus()
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
const getExportOption = () => {
|
|
126
|
-
const { storeData, defaultOptions } = props
|
|
127
|
-
const { hasMerge, columns } = storeData
|
|
128
|
-
const checkedAll = computeCheckedAll.value
|
|
129
|
-
const supportMerge = computeSupportMerge.value
|
|
130
|
-
const expColumns = XEUtils.searchTree(columns, (column: any) => column.checked, { children: 'children', mapChildren: 'childNodes', original: true })
|
|
131
|
-
return Object.assign({}, defaultOptions, {
|
|
132
|
-
columns: expColumns,
|
|
133
|
-
isMerge: hasMerge && supportMerge && checkedAll ? defaultOptions.isMerge : false
|
|
134
|
-
})
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
const printEvent = () => {
|
|
138
|
-
const { storeData } = props
|
|
139
|
-
const printOpts = computePrintOpts.value
|
|
140
|
-
storeData.visible = false
|
|
141
|
-
$xeTable.print(Object.assign({}, printOpts, getExportOption()))
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
const exportEvent = () => {
|
|
145
|
-
const { storeData } = props
|
|
146
|
-
const exportOpts = computeExportOpts.value
|
|
147
|
-
reactData.loading = true
|
|
148
|
-
$xeTable.exportData(Object.assign({}, exportOpts, getExportOption())).then(() => {
|
|
149
|
-
reactData.loading = false
|
|
150
|
-
storeData.visible = false
|
|
151
|
-
}).catch(() => {
|
|
152
|
-
reactData.loading = false
|
|
153
|
-
})
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
const cancelEvent = () => {
|
|
157
|
-
const { storeData } = props
|
|
158
|
-
storeData.visible = false
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
const confirmEvent = () => {
|
|
162
|
-
const { storeData } = props
|
|
163
|
-
if (storeData.isPrint) {
|
|
164
|
-
printEvent()
|
|
165
|
-
} else {
|
|
166
|
-
exportEvent()
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
const renderVN = () => {
|
|
171
|
-
const $xeGrid = $xeTable.xeGrid
|
|
172
|
-
const $xeGantt = $xeTable.xeGantt
|
|
173
|
-
|
|
174
|
-
const { defaultOptions, storeData } = props
|
|
175
|
-
const { isAll: isAllChecked, isIndeterminate: isAllIndeterminate } = reactData
|
|
176
|
-
const { hasTree, hasMerge, isPrint, hasColgroup, columns } = storeData
|
|
177
|
-
const { isHeader } = defaultOptions
|
|
178
|
-
const colVNs: VNode[] = []
|
|
179
|
-
const checkedAll = computeCheckedAll.value
|
|
180
|
-
const showSheet = computeShowSheet.value
|
|
181
|
-
const supportMerge = computeSupportMerge.value
|
|
182
|
-
const supportStyle = computeSupportStyle.value
|
|
183
|
-
// const supportGroup = computeSupportGroup.value
|
|
184
|
-
const slots = defaultOptions.slots || {}
|
|
185
|
-
const topSlot = slots.top
|
|
186
|
-
const bottomSlot = slots.bottom
|
|
187
|
-
const defaultSlot = slots.default
|
|
188
|
-
const footerSlot = slots.footer
|
|
189
|
-
const parameterSlot = slots.parameter
|
|
190
|
-
XEUtils.eachTree(columns, (column) => {
|
|
191
|
-
const colTitle = formatText(column.getTitle(), 1)
|
|
192
|
-
const isColGroup = column.children && column.children.length
|
|
193
|
-
const isChecked = column.checked
|
|
194
|
-
const indeterminate = column.halfChecked
|
|
195
|
-
const isHtml = column.type === 'html'
|
|
196
|
-
colVNs.push(
|
|
197
|
-
h('li', {
|
|
198
|
-
key: column.id,
|
|
199
|
-
class: ['vxe-table-export--panel-column-option', `level--${column.level}`, {
|
|
200
|
-
'is--group': isColGroup,
|
|
201
|
-
'is--checked': isChecked,
|
|
202
|
-
'is--indeterminate': indeterminate,
|
|
203
|
-
'is--disabled': column.disabled
|
|
204
|
-
}],
|
|
205
|
-
title: isHtml ? '' : colTitle,
|
|
206
|
-
onClick: () => {
|
|
207
|
-
if (!column.disabled) {
|
|
208
|
-
changeOption(column)
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
}, [
|
|
212
|
-
h('span', {
|
|
213
|
-
class: ['vxe-checkbox--icon', indeterminate ? getIcon().TABLE_CHECKBOX_INDETERMINATE : (isChecked ? getIcon().TABLE_CHECKBOX_CHECKED : getIcon().TABLE_CHECKBOX_UNCHECKED)]
|
|
214
|
-
}),
|
|
215
|
-
isHtml
|
|
216
|
-
? h('span', {
|
|
217
|
-
key: '1',
|
|
218
|
-
class: 'vxe-checkbox--label',
|
|
219
|
-
innerHTML: colTitle
|
|
220
|
-
})
|
|
221
|
-
: h('span', {
|
|
222
|
-
key: '0',
|
|
223
|
-
class: 'vxe-checkbox--label'
|
|
224
|
-
}, colTitle)
|
|
225
|
-
])
|
|
226
|
-
)
|
|
227
|
-
})
|
|
228
|
-
|
|
229
|
-
return VxeUIModalComponent
|
|
230
|
-
? h(VxeUIModalComponent, {
|
|
231
|
-
id: 'VXE_EXPORT_MODAL',
|
|
232
|
-
modelValue: storeData.visible,
|
|
233
|
-
title: getI18n(isPrint ? 'vxe.export.printTitle' : 'vxe.export.expTitle'),
|
|
234
|
-
className: 'vxe-table-export-popup-wrapper',
|
|
235
|
-
width: 660,
|
|
236
|
-
minWidth: 500,
|
|
237
|
-
minHeight: 400,
|
|
238
|
-
mask: true,
|
|
239
|
-
lockView: true,
|
|
240
|
-
showFooter: true,
|
|
241
|
-
escClosable: true,
|
|
242
|
-
maskClosable: true,
|
|
243
|
-
showMaximize: true,
|
|
244
|
-
resize: true,
|
|
245
|
-
loading: reactData.loading,
|
|
246
|
-
'onUpdate:modelValue' (value: any) {
|
|
247
|
-
storeData.visible = value
|
|
248
|
-
},
|
|
249
|
-
onShow: showEvent
|
|
250
|
-
}, {
|
|
251
|
-
default: () => {
|
|
252
|
-
const params = {
|
|
253
|
-
$table: $xeTable,
|
|
254
|
-
$grid: $xeGrid,
|
|
255
|
-
$gantt: $xeGantt,
|
|
256
|
-
options: defaultOptions,
|
|
257
|
-
columns,
|
|
258
|
-
params: defaultOptions.params as any
|
|
259
|
-
}
|
|
260
|
-
const hasEmptyData = defaultOptions.mode === 'empty'
|
|
261
|
-
|
|
262
|
-
return h('div', {
|
|
263
|
-
class: 'vxe-table-export--panel'
|
|
264
|
-
}, [
|
|
265
|
-
topSlot
|
|
266
|
-
? h('div', {
|
|
267
|
-
class: 'vxe-table-export--panel-top'
|
|
268
|
-
}, $xeTable.callSlot(topSlot, params))
|
|
269
|
-
: renderEmptyElement($xeTable),
|
|
270
|
-
h('div', {
|
|
271
|
-
class: 'vxe-table-export--panel-body'
|
|
272
|
-
}, defaultSlot
|
|
273
|
-
? $xeTable.callSlot(defaultSlot, params)
|
|
274
|
-
: [
|
|
275
|
-
h('table', {
|
|
276
|
-
class: 'vxe-table-export--panel-table',
|
|
277
|
-
cellspacing: 0,
|
|
278
|
-
cellpadding: 0,
|
|
279
|
-
border: 0
|
|
280
|
-
}, [
|
|
281
|
-
h('tbody', [
|
|
282
|
-
[
|
|
283
|
-
isPrint
|
|
284
|
-
? renderEmptyElement($xeTable)
|
|
285
|
-
: h('tr', [
|
|
286
|
-
h('td', getI18n('vxe.export.expName')),
|
|
287
|
-
h('td', [
|
|
288
|
-
VxeUIInputComponent
|
|
289
|
-
? h(VxeUIInputComponent, {
|
|
290
|
-
ref: xInputFilename,
|
|
291
|
-
modelValue: defaultOptions.filename,
|
|
292
|
-
type: 'text',
|
|
293
|
-
clearable: true,
|
|
294
|
-
placeholder: getI18n('vxe.export.expNamePlaceholder'),
|
|
295
|
-
'onUpdate:modelValue' (value: any) {
|
|
296
|
-
defaultOptions.filename = value
|
|
297
|
-
}
|
|
298
|
-
})
|
|
299
|
-
: renderEmptyElement($xeTable)
|
|
300
|
-
])
|
|
301
|
-
]),
|
|
302
|
-
isPrint
|
|
303
|
-
? renderEmptyElement($xeTable)
|
|
304
|
-
: h('tr', [
|
|
305
|
-
h('td', getI18n('vxe.export.expType')),
|
|
306
|
-
h('td', [
|
|
307
|
-
VxeUISelectComponent
|
|
308
|
-
? h(VxeUISelectComponent, {
|
|
309
|
-
modelValue: defaultOptions.type,
|
|
310
|
-
options: storeData.typeList,
|
|
311
|
-
'onUpdate:modelValue' (value: any) {
|
|
312
|
-
defaultOptions.type = value
|
|
313
|
-
}
|
|
314
|
-
})
|
|
315
|
-
: renderEmptyElement($xeTable)
|
|
316
|
-
])
|
|
317
|
-
]),
|
|
318
|
-
isPrint || showSheet
|
|
319
|
-
? h('tr', [
|
|
320
|
-
h('td', getI18n('vxe.export.expSheetName')),
|
|
321
|
-
h('td', [
|
|
322
|
-
VxeUIInputComponent
|
|
323
|
-
? h(VxeUIInputComponent, {
|
|
324
|
-
ref: xInputSheetname,
|
|
325
|
-
modelValue: defaultOptions.sheetName,
|
|
326
|
-
type: 'text',
|
|
327
|
-
clearable: true,
|
|
328
|
-
placeholder: getI18n('vxe.export.expSheetNamePlaceholder'),
|
|
329
|
-
'onUpdate:modelValue' (value: any) {
|
|
330
|
-
defaultOptions.sheetName = value
|
|
331
|
-
}
|
|
332
|
-
})
|
|
333
|
-
: renderEmptyElement($xeTable)
|
|
334
|
-
])
|
|
335
|
-
])
|
|
336
|
-
: renderEmptyElement($xeTable),
|
|
337
|
-
h('tr', [
|
|
338
|
-
h('td', getI18n('vxe.export.expMode')),
|
|
339
|
-
h('td', [
|
|
340
|
-
VxeUISelectComponent
|
|
341
|
-
? h(VxeUISelectComponent, {
|
|
342
|
-
modelValue: defaultOptions.mode,
|
|
343
|
-
options: storeData.modeList.map((item: any) => {
|
|
344
|
-
return {
|
|
345
|
-
value: item.value,
|
|
346
|
-
label: getI18n(item.label)
|
|
347
|
-
}
|
|
348
|
-
}),
|
|
349
|
-
'onUpdate:modelValue' (value: any) {
|
|
350
|
-
defaultOptions.mode = value
|
|
351
|
-
}
|
|
352
|
-
})
|
|
353
|
-
: renderEmptyElement($xeTable)
|
|
354
|
-
])
|
|
355
|
-
]),
|
|
356
|
-
h('tr', [
|
|
357
|
-
h('td', [getI18n('vxe.export.expColumn')]),
|
|
358
|
-
h('td', [
|
|
359
|
-
h('div', {
|
|
360
|
-
class: 'vxe-table-export--panel-column'
|
|
361
|
-
}, [
|
|
362
|
-
h('ul', {
|
|
363
|
-
class: 'vxe-table-export--panel-column-header'
|
|
364
|
-
}, [
|
|
365
|
-
h('li', {
|
|
366
|
-
class: ['vxe-table-export--panel-column-option', {
|
|
367
|
-
'is--checked': isAllChecked,
|
|
368
|
-
'is--indeterminate': isAllIndeterminate
|
|
369
|
-
}],
|
|
370
|
-
title: getI18n('vxe.table.allTitle'),
|
|
371
|
-
onClick: allColumnEvent
|
|
372
|
-
}, [
|
|
373
|
-
h('span', {
|
|
374
|
-
class: ['vxe-checkbox--icon', isAllIndeterminate ? getIcon().TABLE_CHECKBOX_INDETERMINATE : (isAllChecked ? getIcon().TABLE_CHECKBOX_CHECKED : getIcon().TABLE_CHECKBOX_UNCHECKED)]
|
|
375
|
-
}),
|
|
376
|
-
h('span', {
|
|
377
|
-
class: 'vxe-checkbox--label'
|
|
378
|
-
}, getI18n('vxe.export.expCurrentColumn'))
|
|
379
|
-
])
|
|
380
|
-
]),
|
|
381
|
-
h('ul', {
|
|
382
|
-
class: 'vxe-table-export--panel-column-body'
|
|
383
|
-
}, colVNs)
|
|
384
|
-
])
|
|
385
|
-
])
|
|
386
|
-
]),
|
|
387
|
-
h('tr', [
|
|
388
|
-
h('td', getI18n('vxe.export.expOpts')),
|
|
389
|
-
parameterSlot
|
|
390
|
-
? h('td', [
|
|
391
|
-
h('div', {
|
|
392
|
-
class: 'vxe-table-export--panel-option-row'
|
|
393
|
-
}, $xeTable.callSlot(parameterSlot, params))
|
|
394
|
-
])
|
|
395
|
-
: h('td', [
|
|
396
|
-
h('div', {
|
|
397
|
-
class: 'vxe-table-export--panel-option-row'
|
|
398
|
-
}, [
|
|
399
|
-
VxeUICheckboxComponent
|
|
400
|
-
? h(VxeUICheckboxComponent, {
|
|
401
|
-
modelValue: hasEmptyData || isHeader,
|
|
402
|
-
disabled: hasEmptyData,
|
|
403
|
-
title: getI18n('vxe.export.expHeaderTitle'),
|
|
404
|
-
content: getI18n('vxe.export.expOptHeader'),
|
|
405
|
-
'onUpdate:modelValue' (value: any) {
|
|
406
|
-
defaultOptions.isHeader = value
|
|
407
|
-
}
|
|
408
|
-
})
|
|
409
|
-
: renderEmptyElement($xeTable),
|
|
410
|
-
VxeUICheckboxComponent
|
|
411
|
-
? h(VxeUICheckboxComponent, {
|
|
412
|
-
modelValue: isHeader ? defaultOptions.isTitle : false,
|
|
413
|
-
disabled: !isHeader,
|
|
414
|
-
title: getI18n('vxe.export.expTitleTitle'),
|
|
415
|
-
content: getI18n('vxe.export.expOptTitle'),
|
|
416
|
-
'onUpdate:modelValue' (value: any) {
|
|
417
|
-
defaultOptions.isTitle = value
|
|
418
|
-
}
|
|
419
|
-
})
|
|
420
|
-
: renderEmptyElement($xeTable),
|
|
421
|
-
VxeUICheckboxComponent
|
|
422
|
-
? h(VxeUICheckboxComponent, {
|
|
423
|
-
modelValue: isHeader && hasColgroup && supportMerge ? defaultOptions.isColgroup : false,
|
|
424
|
-
title: getI18n('vxe.export.expColgroupTitle'),
|
|
425
|
-
disabled: !isHeader || !hasColgroup || !supportMerge,
|
|
426
|
-
content: getI18n('vxe.export.expOptColgroup'),
|
|
427
|
-
'onUpdate:modelValue' (value: any) {
|
|
428
|
-
defaultOptions.isColgroup = value
|
|
429
|
-
}
|
|
430
|
-
})
|
|
431
|
-
: renderEmptyElement($xeTable)
|
|
432
|
-
]),
|
|
433
|
-
h('div', {
|
|
434
|
-
class: 'vxe-table-export--panel-option-row'
|
|
435
|
-
}, [
|
|
436
|
-
VxeUICheckboxComponent
|
|
437
|
-
? h(VxeUICheckboxComponent, {
|
|
438
|
-
modelValue: hasEmptyData ? false : defaultOptions.original,
|
|
439
|
-
disabled: hasEmptyData,
|
|
440
|
-
title: getI18n('vxe.export.expOriginalTitle'),
|
|
441
|
-
content: getI18n('vxe.export.expOptOriginal'),
|
|
442
|
-
'onUpdate:modelValue' (value: any) {
|
|
443
|
-
defaultOptions.original = value
|
|
444
|
-
}
|
|
445
|
-
})
|
|
446
|
-
: renderEmptyElement($xeTable),
|
|
447
|
-
VxeUICheckboxComponent
|
|
448
|
-
? h(VxeUICheckboxComponent, {
|
|
449
|
-
modelValue: hasMerge && supportMerge && checkedAll ? defaultOptions.isMerge : false,
|
|
450
|
-
title: getI18n('vxe.export.expMergeTitle'),
|
|
451
|
-
disabled: hasEmptyData || !hasMerge || !supportMerge || !checkedAll,
|
|
452
|
-
content: getI18n('vxe.export.expOptMerge'),
|
|
453
|
-
'onUpdate:modelValue' (value: any) {
|
|
454
|
-
defaultOptions.isMerge = value
|
|
455
|
-
}
|
|
456
|
-
})
|
|
457
|
-
: renderEmptyElement($xeTable),
|
|
458
|
-
isPrint || !VxeUICheckboxComponent
|
|
459
|
-
? renderEmptyElement($xeTable)
|
|
460
|
-
: h(VxeUICheckboxComponent, {
|
|
461
|
-
modelValue: supportStyle ? defaultOptions.useStyle : false,
|
|
462
|
-
disabled: !supportStyle,
|
|
463
|
-
title: getI18n('vxe.export.expUseStyleTitle'),
|
|
464
|
-
content: getI18n('vxe.export.expOptUseStyle'),
|
|
465
|
-
'onUpdate:modelValue' (value: any) {
|
|
466
|
-
defaultOptions.useStyle = value
|
|
467
|
-
}
|
|
468
|
-
}),
|
|
469
|
-
VxeUICheckboxComponent
|
|
470
|
-
? h(VxeUICheckboxComponent, {
|
|
471
|
-
modelValue: hasTree ? defaultOptions.isAllExpand : false,
|
|
472
|
-
disabled: hasEmptyData || !hasTree,
|
|
473
|
-
title: getI18n('vxe.export.expAllExpandTitle'),
|
|
474
|
-
content: getI18n('vxe.export.expOptAllExpand'),
|
|
475
|
-
'onUpdate:modelValue' (value: any) {
|
|
476
|
-
defaultOptions.isAllExpand = value
|
|
477
|
-
}
|
|
478
|
-
})
|
|
479
|
-
: renderEmptyElement($xeTable)
|
|
480
|
-
]),
|
|
481
|
-
h('div', {
|
|
482
|
-
class: 'vxe-table-export--panel-option-row'
|
|
483
|
-
}, [
|
|
484
|
-
VxeUICheckboxComponent
|
|
485
|
-
? h(VxeUICheckboxComponent, {
|
|
486
|
-
modelValue: defaultOptions.isFooter,
|
|
487
|
-
disabled: !storeData.hasFooter,
|
|
488
|
-
title: getI18n('vxe.export.expFooterTitle'),
|
|
489
|
-
content: getI18n('vxe.export.expOptFooter'),
|
|
490
|
-
'onUpdate:modelValue' (value: any) {
|
|
491
|
-
defaultOptions.isFooter = value
|
|
492
|
-
}
|
|
493
|
-
})
|
|
494
|
-
: renderEmptyElement($xeTable)
|
|
495
|
-
])
|
|
496
|
-
])
|
|
497
|
-
])
|
|
498
|
-
]
|
|
499
|
-
])
|
|
500
|
-
])
|
|
501
|
-
]),
|
|
502
|
-
bottomSlot
|
|
503
|
-
? h('div', {
|
|
504
|
-
class: 'vxe-table-export--panel-bottom'
|
|
505
|
-
}, $xeTable.callSlot(bottomSlot, params))
|
|
506
|
-
: renderEmptyElement($xeTable)
|
|
507
|
-
])
|
|
508
|
-
},
|
|
509
|
-
footer () {
|
|
510
|
-
const params = {
|
|
511
|
-
$table: $xeTable,
|
|
512
|
-
$grid: $xeGrid,
|
|
513
|
-
$gantt: $xeGantt,
|
|
514
|
-
options: defaultOptions,
|
|
515
|
-
columns,
|
|
516
|
-
params: defaultOptions.params as any
|
|
517
|
-
}
|
|
518
|
-
return h('div', {
|
|
519
|
-
class: 'vxe-table-export--panel-footer'
|
|
520
|
-
}, footerSlot
|
|
521
|
-
? $xeTable.callSlot(footerSlot, params)
|
|
522
|
-
: [
|
|
523
|
-
h('div', {
|
|
524
|
-
class: 'vxe-table-export--panel-btns'
|
|
525
|
-
}, [
|
|
526
|
-
VxeUIButtonComponent
|
|
527
|
-
? h(VxeUIButtonComponent, {
|
|
528
|
-
content: getI18n('vxe.export.expCancel'),
|
|
529
|
-
onClick: cancelEvent
|
|
530
|
-
})
|
|
531
|
-
: renderEmptyElement($xeTable),
|
|
532
|
-
VxeUIButtonComponent
|
|
533
|
-
? h(VxeUIButtonComponent, {
|
|
534
|
-
ref: xButtonConfirm,
|
|
535
|
-
status: 'primary',
|
|
536
|
-
content: getI18n(isPrint ? 'vxe.export.expPrint' : 'vxe.export.expConfirm'),
|
|
537
|
-
onClick: confirmEvent
|
|
538
|
-
})
|
|
539
|
-
: renderEmptyElement($xeTable)
|
|
540
|
-
])
|
|
541
|
-
])
|
|
542
|
-
}
|
|
543
|
-
})
|
|
544
|
-
: renderEmptyElement($xeTable)
|
|
545
|
-
}
|
|
546
|
-
|
|
547
|
-
nextTick(() => {
|
|
548
|
-
if (!VxeUIModalComponent) {
|
|
549
|
-
errLog('vxe.error.reqComp', ['vxe-modal'])
|
|
550
|
-
}
|
|
551
|
-
if (!VxeUIButtonComponent) {
|
|
552
|
-
errLog('vxe.error.reqComp', ['vxe-button'])
|
|
553
|
-
}
|
|
554
|
-
if (!VxeUISelectComponent) {
|
|
555
|
-
errLog('vxe.error.reqComp', ['vxe-select'])
|
|
556
|
-
}
|
|
557
|
-
if (!VxeUIInputComponent) {
|
|
558
|
-
errLog('vxe.error.reqComp', ['vxe-input'])
|
|
559
|
-
}
|
|
560
|
-
if (!VxeUICheckboxComponent) {
|
|
561
|
-
errLog('vxe.error.reqComp', ['vxe-checkbox'])
|
|
562
|
-
}
|
|
563
|
-
})
|
|
564
|
-
|
|
565
|
-
return renderVN
|
|
566
|
-
}
|
|
567
|
-
})
|
|
1
|
+
import { h, ref, Ref, computed, reactive, inject, nextTick, VNode, PropType } from 'vue'
|
|
2
|
+
import { defineVxeComponent } from '../../../ui/src/comp'
|
|
3
|
+
import { VxeUI } from '../../../ui'
|
|
4
|
+
import XEUtils from 'xe-utils'
|
|
5
|
+
import { formatText } from '../../../ui/src/utils'
|
|
6
|
+
import { errLog } from '../../../ui/src/log'
|
|
7
|
+
|
|
8
|
+
import type { VxeTablePrivateMethods, VxeTableConstructor, VxeTableMethods, VxeTableDefines } from '../../../../types'
|
|
9
|
+
|
|
10
|
+
const { getI18n, getIcon, renderEmptyElement } = VxeUI
|
|
11
|
+
|
|
12
|
+
export default defineVxeComponent({
|
|
13
|
+
name: 'VxeTableExportPanel',
|
|
14
|
+
props: {
|
|
15
|
+
defaultOptions: {
|
|
16
|
+
type: Object as PropType<VxeTableDefines.ExportParamsObj>,
|
|
17
|
+
default: () => ({} as VxeTableDefines.ExportParamsObj)
|
|
18
|
+
},
|
|
19
|
+
storeData: {
|
|
20
|
+
type: Object as PropType<VxeTableDefines.ExportStoreObj>,
|
|
21
|
+
default: () => ({} as VxeTableDefines.ExportStoreObj)
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
setup (props) {
|
|
25
|
+
const VxeUIModalComponent = VxeUI.getComponent('VxeModal')
|
|
26
|
+
const VxeUIButtonComponent = VxeUI.getComponent('VxeButton')
|
|
27
|
+
const VxeUISelectComponent = VxeUI.getComponent('VxeSelect')
|
|
28
|
+
const VxeUIInputComponent = VxeUI.getComponent('VxeInput')
|
|
29
|
+
const VxeUICheckboxComponent = VxeUI.getComponent('VxeCheckbox')
|
|
30
|
+
|
|
31
|
+
const $xeTable = inject('$xeTable', {} as VxeTableConstructor & VxeTableMethods & VxeTablePrivateMethods)
|
|
32
|
+
const { computeExportOpts, computePrintOpts } = $xeTable.getComputeMaps()
|
|
33
|
+
|
|
34
|
+
const reactData = reactive({
|
|
35
|
+
isAll: false,
|
|
36
|
+
isIndeterminate: false,
|
|
37
|
+
loading: false
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
const xButtonConfirm = ref() as Ref<HTMLButtonElement>
|
|
41
|
+
const xInputFilename = ref() as Ref<HTMLInputElement>
|
|
42
|
+
const xInputSheetname = ref() as Ref<HTMLInputElement>
|
|
43
|
+
|
|
44
|
+
const computeCheckedAll = computed(() => {
|
|
45
|
+
const { storeData } = props
|
|
46
|
+
return storeData.columns.every((column) => column.checked)
|
|
47
|
+
})
|
|
48
|
+
|
|
49
|
+
const computeShowSheet = computed(() => {
|
|
50
|
+
const { defaultOptions } = props
|
|
51
|
+
return ['html', 'xml', 'xlsx', 'pdf'].indexOf(defaultOptions.type) > -1
|
|
52
|
+
})
|
|
53
|
+
|
|
54
|
+
const computeSupportMerge = computed(() => {
|
|
55
|
+
const { storeData, defaultOptions } = props
|
|
56
|
+
return !defaultOptions.original && defaultOptions.mode === 'current' && (storeData.isPrint || ['html', 'xlsx'].indexOf(defaultOptions.type) > -1)
|
|
57
|
+
})
|
|
58
|
+
|
|
59
|
+
// const computeSupportGroup = computed(() => {
|
|
60
|
+
// const { defaultOptions } = props
|
|
61
|
+
// return ['html', 'xlsx', 'csv', 'txt'].indexOf(defaultOptions.type) > -1
|
|
62
|
+
// })
|
|
63
|
+
|
|
64
|
+
const computeSupportStyle = computed(() => {
|
|
65
|
+
const { defaultOptions } = props
|
|
66
|
+
return !defaultOptions.original && ['xlsx'].indexOf(defaultOptions.type) > -1
|
|
67
|
+
})
|
|
68
|
+
|
|
69
|
+
const handleOptionCheck = (column: any) => {
|
|
70
|
+
const { storeData } = props
|
|
71
|
+
const matchObj = XEUtils.findTree(storeData.columns as any[], item => item === column)
|
|
72
|
+
if (matchObj && matchObj.parent) {
|
|
73
|
+
const { parent } = matchObj
|
|
74
|
+
if (parent.children && parent.children.length) {
|
|
75
|
+
parent.checked = parent.children.every((column: any) => column.checked)
|
|
76
|
+
parent.halfChecked = !parent.checked && parent.children.some((column: any) => column.checked || column.halfChecked)
|
|
77
|
+
handleOptionCheck(parent)
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const checkStatus = () => {
|
|
83
|
+
const { storeData } = props
|
|
84
|
+
const columns = storeData.columns
|
|
85
|
+
reactData.isAll = columns.every((column: any) => column.disabled || column.checked)
|
|
86
|
+
reactData.isIndeterminate = !reactData.isAll && columns.some((column: any) => !column.disabled && (column.checked || column.halfChecked))
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
const changeOption = (column: any) => {
|
|
90
|
+
const isChecked = !column.checked
|
|
91
|
+
XEUtils.eachTree([column], (item) => {
|
|
92
|
+
item.checked = isChecked
|
|
93
|
+
item.halfChecked = false
|
|
94
|
+
})
|
|
95
|
+
handleOptionCheck(column)
|
|
96
|
+
checkStatus()
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
const allColumnEvent = () => {
|
|
100
|
+
const { storeData } = props
|
|
101
|
+
const isAll = !reactData.isAll
|
|
102
|
+
XEUtils.eachTree(storeData.columns, (column: any) => {
|
|
103
|
+
if (!column.disabled) {
|
|
104
|
+
column.checked = isAll
|
|
105
|
+
column.halfChecked = false
|
|
106
|
+
}
|
|
107
|
+
})
|
|
108
|
+
reactData.isAll = isAll
|
|
109
|
+
checkStatus()
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
const showEvent = () => {
|
|
113
|
+
nextTick(() => {
|
|
114
|
+
const filenameInp = xInputFilename.value
|
|
115
|
+
const sheetnameInp = xInputSheetname.value
|
|
116
|
+
const confirmBtn = xButtonConfirm.value
|
|
117
|
+
const targetElem = filenameInp || sheetnameInp || confirmBtn
|
|
118
|
+
if (targetElem) {
|
|
119
|
+
targetElem.focus()
|
|
120
|
+
}
|
|
121
|
+
})
|
|
122
|
+
checkStatus()
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
const getExportOption = () => {
|
|
126
|
+
const { storeData, defaultOptions } = props
|
|
127
|
+
const { hasMerge, columns } = storeData
|
|
128
|
+
const checkedAll = computeCheckedAll.value
|
|
129
|
+
const supportMerge = computeSupportMerge.value
|
|
130
|
+
const expColumns = XEUtils.searchTree(columns, (column: any) => column.checked, { children: 'children', mapChildren: 'childNodes', original: true })
|
|
131
|
+
return Object.assign({}, defaultOptions, {
|
|
132
|
+
columns: expColumns,
|
|
133
|
+
isMerge: hasMerge && supportMerge && checkedAll ? defaultOptions.isMerge : false
|
|
134
|
+
})
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
const printEvent = () => {
|
|
138
|
+
const { storeData } = props
|
|
139
|
+
const printOpts = computePrintOpts.value
|
|
140
|
+
storeData.visible = false
|
|
141
|
+
$xeTable.print(Object.assign({}, printOpts, getExportOption()))
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
const exportEvent = () => {
|
|
145
|
+
const { storeData } = props
|
|
146
|
+
const exportOpts = computeExportOpts.value
|
|
147
|
+
reactData.loading = true
|
|
148
|
+
$xeTable.exportData(Object.assign({}, exportOpts, getExportOption())).then(() => {
|
|
149
|
+
reactData.loading = false
|
|
150
|
+
storeData.visible = false
|
|
151
|
+
}).catch(() => {
|
|
152
|
+
reactData.loading = false
|
|
153
|
+
})
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
const cancelEvent = () => {
|
|
157
|
+
const { storeData } = props
|
|
158
|
+
storeData.visible = false
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
const confirmEvent = () => {
|
|
162
|
+
const { storeData } = props
|
|
163
|
+
if (storeData.isPrint) {
|
|
164
|
+
printEvent()
|
|
165
|
+
} else {
|
|
166
|
+
exportEvent()
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
const renderVN = () => {
|
|
171
|
+
const $xeGrid = $xeTable.xeGrid
|
|
172
|
+
const $xeGantt = $xeTable.xeGantt
|
|
173
|
+
|
|
174
|
+
const { defaultOptions, storeData } = props
|
|
175
|
+
const { isAll: isAllChecked, isIndeterminate: isAllIndeterminate } = reactData
|
|
176
|
+
const { hasTree, hasMerge, isPrint, hasColgroup, columns } = storeData
|
|
177
|
+
const { isHeader } = defaultOptions
|
|
178
|
+
const colVNs: VNode[] = []
|
|
179
|
+
const checkedAll = computeCheckedAll.value
|
|
180
|
+
const showSheet = computeShowSheet.value
|
|
181
|
+
const supportMerge = computeSupportMerge.value
|
|
182
|
+
const supportStyle = computeSupportStyle.value
|
|
183
|
+
// const supportGroup = computeSupportGroup.value
|
|
184
|
+
const slots = defaultOptions.slots || {}
|
|
185
|
+
const topSlot = slots.top
|
|
186
|
+
const bottomSlot = slots.bottom
|
|
187
|
+
const defaultSlot = slots.default
|
|
188
|
+
const footerSlot = slots.footer
|
|
189
|
+
const parameterSlot = slots.parameter
|
|
190
|
+
XEUtils.eachTree(columns, (column) => {
|
|
191
|
+
const colTitle = formatText(column.getTitle(), 1)
|
|
192
|
+
const isColGroup = column.children && column.children.length
|
|
193
|
+
const isChecked = column.checked
|
|
194
|
+
const indeterminate = column.halfChecked
|
|
195
|
+
const isHtml = column.type === 'html'
|
|
196
|
+
colVNs.push(
|
|
197
|
+
h('li', {
|
|
198
|
+
key: column.id,
|
|
199
|
+
class: ['vxe-table-export--panel-column-option', `level--${column.level}`, {
|
|
200
|
+
'is--group': isColGroup,
|
|
201
|
+
'is--checked': isChecked,
|
|
202
|
+
'is--indeterminate': indeterminate,
|
|
203
|
+
'is--disabled': column.disabled
|
|
204
|
+
}],
|
|
205
|
+
title: isHtml ? '' : colTitle,
|
|
206
|
+
onClick: () => {
|
|
207
|
+
if (!column.disabled) {
|
|
208
|
+
changeOption(column)
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
}, [
|
|
212
|
+
h('span', {
|
|
213
|
+
class: ['vxe-checkbox--icon', indeterminate ? getIcon().TABLE_CHECKBOX_INDETERMINATE : (isChecked ? getIcon().TABLE_CHECKBOX_CHECKED : getIcon().TABLE_CHECKBOX_UNCHECKED)]
|
|
214
|
+
}),
|
|
215
|
+
isHtml
|
|
216
|
+
? h('span', {
|
|
217
|
+
key: '1',
|
|
218
|
+
class: 'vxe-checkbox--label',
|
|
219
|
+
innerHTML: colTitle
|
|
220
|
+
})
|
|
221
|
+
: h('span', {
|
|
222
|
+
key: '0',
|
|
223
|
+
class: 'vxe-checkbox--label'
|
|
224
|
+
}, colTitle)
|
|
225
|
+
])
|
|
226
|
+
)
|
|
227
|
+
})
|
|
228
|
+
|
|
229
|
+
return VxeUIModalComponent
|
|
230
|
+
? h(VxeUIModalComponent, {
|
|
231
|
+
id: 'VXE_EXPORT_MODAL',
|
|
232
|
+
modelValue: storeData.visible,
|
|
233
|
+
title: getI18n(isPrint ? 'vxe.export.printTitle' : 'vxe.export.expTitle'),
|
|
234
|
+
className: 'vxe-table-export-popup-wrapper',
|
|
235
|
+
width: 660,
|
|
236
|
+
minWidth: 500,
|
|
237
|
+
minHeight: 400,
|
|
238
|
+
mask: true,
|
|
239
|
+
lockView: true,
|
|
240
|
+
showFooter: true,
|
|
241
|
+
escClosable: true,
|
|
242
|
+
maskClosable: true,
|
|
243
|
+
showMaximize: true,
|
|
244
|
+
resize: true,
|
|
245
|
+
loading: reactData.loading,
|
|
246
|
+
'onUpdate:modelValue' (value: any) {
|
|
247
|
+
storeData.visible = value
|
|
248
|
+
},
|
|
249
|
+
onShow: showEvent
|
|
250
|
+
}, {
|
|
251
|
+
default: () => {
|
|
252
|
+
const params = {
|
|
253
|
+
$table: $xeTable,
|
|
254
|
+
$grid: $xeGrid,
|
|
255
|
+
$gantt: $xeGantt,
|
|
256
|
+
options: defaultOptions,
|
|
257
|
+
columns,
|
|
258
|
+
params: defaultOptions.params as any
|
|
259
|
+
}
|
|
260
|
+
const hasEmptyData = defaultOptions.mode === 'empty'
|
|
261
|
+
|
|
262
|
+
return h('div', {
|
|
263
|
+
class: 'vxe-table-export--panel'
|
|
264
|
+
}, [
|
|
265
|
+
topSlot
|
|
266
|
+
? h('div', {
|
|
267
|
+
class: 'vxe-table-export--panel-top'
|
|
268
|
+
}, $xeTable.callSlot(topSlot, params))
|
|
269
|
+
: renderEmptyElement($xeTable),
|
|
270
|
+
h('div', {
|
|
271
|
+
class: 'vxe-table-export--panel-body'
|
|
272
|
+
}, defaultSlot
|
|
273
|
+
? $xeTable.callSlot(defaultSlot, params)
|
|
274
|
+
: [
|
|
275
|
+
h('table', {
|
|
276
|
+
class: 'vxe-table-export--panel-table',
|
|
277
|
+
cellspacing: 0,
|
|
278
|
+
cellpadding: 0,
|
|
279
|
+
border: 0
|
|
280
|
+
}, [
|
|
281
|
+
h('tbody', [
|
|
282
|
+
[
|
|
283
|
+
isPrint
|
|
284
|
+
? renderEmptyElement($xeTable)
|
|
285
|
+
: h('tr', [
|
|
286
|
+
h('td', getI18n('vxe.export.expName')),
|
|
287
|
+
h('td', [
|
|
288
|
+
VxeUIInputComponent
|
|
289
|
+
? h(VxeUIInputComponent, {
|
|
290
|
+
ref: xInputFilename,
|
|
291
|
+
modelValue: defaultOptions.filename,
|
|
292
|
+
type: 'text',
|
|
293
|
+
clearable: true,
|
|
294
|
+
placeholder: getI18n('vxe.export.expNamePlaceholder'),
|
|
295
|
+
'onUpdate:modelValue' (value: any) {
|
|
296
|
+
defaultOptions.filename = value
|
|
297
|
+
}
|
|
298
|
+
})
|
|
299
|
+
: renderEmptyElement($xeTable)
|
|
300
|
+
])
|
|
301
|
+
]),
|
|
302
|
+
isPrint
|
|
303
|
+
? renderEmptyElement($xeTable)
|
|
304
|
+
: h('tr', [
|
|
305
|
+
h('td', getI18n('vxe.export.expType')),
|
|
306
|
+
h('td', [
|
|
307
|
+
VxeUISelectComponent
|
|
308
|
+
? h(VxeUISelectComponent, {
|
|
309
|
+
modelValue: defaultOptions.type,
|
|
310
|
+
options: storeData.typeList,
|
|
311
|
+
'onUpdate:modelValue' (value: any) {
|
|
312
|
+
defaultOptions.type = value
|
|
313
|
+
}
|
|
314
|
+
})
|
|
315
|
+
: renderEmptyElement($xeTable)
|
|
316
|
+
])
|
|
317
|
+
]),
|
|
318
|
+
isPrint || showSheet
|
|
319
|
+
? h('tr', [
|
|
320
|
+
h('td', getI18n('vxe.export.expSheetName')),
|
|
321
|
+
h('td', [
|
|
322
|
+
VxeUIInputComponent
|
|
323
|
+
? h(VxeUIInputComponent, {
|
|
324
|
+
ref: xInputSheetname,
|
|
325
|
+
modelValue: defaultOptions.sheetName,
|
|
326
|
+
type: 'text',
|
|
327
|
+
clearable: true,
|
|
328
|
+
placeholder: getI18n('vxe.export.expSheetNamePlaceholder'),
|
|
329
|
+
'onUpdate:modelValue' (value: any) {
|
|
330
|
+
defaultOptions.sheetName = value
|
|
331
|
+
}
|
|
332
|
+
})
|
|
333
|
+
: renderEmptyElement($xeTable)
|
|
334
|
+
])
|
|
335
|
+
])
|
|
336
|
+
: renderEmptyElement($xeTable),
|
|
337
|
+
h('tr', [
|
|
338
|
+
h('td', getI18n('vxe.export.expMode')),
|
|
339
|
+
h('td', [
|
|
340
|
+
VxeUISelectComponent
|
|
341
|
+
? h(VxeUISelectComponent, {
|
|
342
|
+
modelValue: defaultOptions.mode,
|
|
343
|
+
options: storeData.modeList.map((item: any) => {
|
|
344
|
+
return {
|
|
345
|
+
value: item.value,
|
|
346
|
+
label: getI18n(item.label)
|
|
347
|
+
}
|
|
348
|
+
}),
|
|
349
|
+
'onUpdate:modelValue' (value: any) {
|
|
350
|
+
defaultOptions.mode = value
|
|
351
|
+
}
|
|
352
|
+
})
|
|
353
|
+
: renderEmptyElement($xeTable)
|
|
354
|
+
])
|
|
355
|
+
]),
|
|
356
|
+
h('tr', [
|
|
357
|
+
h('td', [getI18n('vxe.export.expColumn')]),
|
|
358
|
+
h('td', [
|
|
359
|
+
h('div', {
|
|
360
|
+
class: 'vxe-table-export--panel-column'
|
|
361
|
+
}, [
|
|
362
|
+
h('ul', {
|
|
363
|
+
class: 'vxe-table-export--panel-column-header'
|
|
364
|
+
}, [
|
|
365
|
+
h('li', {
|
|
366
|
+
class: ['vxe-table-export--panel-column-option', {
|
|
367
|
+
'is--checked': isAllChecked,
|
|
368
|
+
'is--indeterminate': isAllIndeterminate
|
|
369
|
+
}],
|
|
370
|
+
title: getI18n('vxe.table.allTitle'),
|
|
371
|
+
onClick: allColumnEvent
|
|
372
|
+
}, [
|
|
373
|
+
h('span', {
|
|
374
|
+
class: ['vxe-checkbox--icon', isAllIndeterminate ? getIcon().TABLE_CHECKBOX_INDETERMINATE : (isAllChecked ? getIcon().TABLE_CHECKBOX_CHECKED : getIcon().TABLE_CHECKBOX_UNCHECKED)]
|
|
375
|
+
}),
|
|
376
|
+
h('span', {
|
|
377
|
+
class: 'vxe-checkbox--label'
|
|
378
|
+
}, getI18n('vxe.export.expCurrentColumn'))
|
|
379
|
+
])
|
|
380
|
+
]),
|
|
381
|
+
h('ul', {
|
|
382
|
+
class: 'vxe-table-export--panel-column-body'
|
|
383
|
+
}, colVNs)
|
|
384
|
+
])
|
|
385
|
+
])
|
|
386
|
+
]),
|
|
387
|
+
h('tr', [
|
|
388
|
+
h('td', getI18n('vxe.export.expOpts')),
|
|
389
|
+
parameterSlot
|
|
390
|
+
? h('td', [
|
|
391
|
+
h('div', {
|
|
392
|
+
class: 'vxe-table-export--panel-option-row'
|
|
393
|
+
}, $xeTable.callSlot(parameterSlot, params))
|
|
394
|
+
])
|
|
395
|
+
: h('td', [
|
|
396
|
+
h('div', {
|
|
397
|
+
class: 'vxe-table-export--panel-option-row'
|
|
398
|
+
}, [
|
|
399
|
+
VxeUICheckboxComponent
|
|
400
|
+
? h(VxeUICheckboxComponent, {
|
|
401
|
+
modelValue: hasEmptyData || isHeader,
|
|
402
|
+
disabled: hasEmptyData,
|
|
403
|
+
title: getI18n('vxe.export.expHeaderTitle'),
|
|
404
|
+
content: getI18n('vxe.export.expOptHeader'),
|
|
405
|
+
'onUpdate:modelValue' (value: any) {
|
|
406
|
+
defaultOptions.isHeader = value
|
|
407
|
+
}
|
|
408
|
+
})
|
|
409
|
+
: renderEmptyElement($xeTable),
|
|
410
|
+
VxeUICheckboxComponent
|
|
411
|
+
? h(VxeUICheckboxComponent, {
|
|
412
|
+
modelValue: isHeader ? defaultOptions.isTitle : false,
|
|
413
|
+
disabled: !isHeader,
|
|
414
|
+
title: getI18n('vxe.export.expTitleTitle'),
|
|
415
|
+
content: getI18n('vxe.export.expOptTitle'),
|
|
416
|
+
'onUpdate:modelValue' (value: any) {
|
|
417
|
+
defaultOptions.isTitle = value
|
|
418
|
+
}
|
|
419
|
+
})
|
|
420
|
+
: renderEmptyElement($xeTable),
|
|
421
|
+
VxeUICheckboxComponent
|
|
422
|
+
? h(VxeUICheckboxComponent, {
|
|
423
|
+
modelValue: isHeader && hasColgroup && supportMerge ? defaultOptions.isColgroup : false,
|
|
424
|
+
title: getI18n('vxe.export.expColgroupTitle'),
|
|
425
|
+
disabled: !isHeader || !hasColgroup || !supportMerge,
|
|
426
|
+
content: getI18n('vxe.export.expOptColgroup'),
|
|
427
|
+
'onUpdate:modelValue' (value: any) {
|
|
428
|
+
defaultOptions.isColgroup = value
|
|
429
|
+
}
|
|
430
|
+
})
|
|
431
|
+
: renderEmptyElement($xeTable)
|
|
432
|
+
]),
|
|
433
|
+
h('div', {
|
|
434
|
+
class: 'vxe-table-export--panel-option-row'
|
|
435
|
+
}, [
|
|
436
|
+
VxeUICheckboxComponent
|
|
437
|
+
? h(VxeUICheckboxComponent, {
|
|
438
|
+
modelValue: hasEmptyData ? false : defaultOptions.original,
|
|
439
|
+
disabled: hasEmptyData,
|
|
440
|
+
title: getI18n('vxe.export.expOriginalTitle'),
|
|
441
|
+
content: getI18n('vxe.export.expOptOriginal'),
|
|
442
|
+
'onUpdate:modelValue' (value: any) {
|
|
443
|
+
defaultOptions.original = value
|
|
444
|
+
}
|
|
445
|
+
})
|
|
446
|
+
: renderEmptyElement($xeTable),
|
|
447
|
+
VxeUICheckboxComponent
|
|
448
|
+
? h(VxeUICheckboxComponent, {
|
|
449
|
+
modelValue: hasMerge && supportMerge && checkedAll ? defaultOptions.isMerge : false,
|
|
450
|
+
title: getI18n('vxe.export.expMergeTitle'),
|
|
451
|
+
disabled: hasEmptyData || !hasMerge || !supportMerge || !checkedAll,
|
|
452
|
+
content: getI18n('vxe.export.expOptMerge'),
|
|
453
|
+
'onUpdate:modelValue' (value: any) {
|
|
454
|
+
defaultOptions.isMerge = value
|
|
455
|
+
}
|
|
456
|
+
})
|
|
457
|
+
: renderEmptyElement($xeTable),
|
|
458
|
+
isPrint || !VxeUICheckboxComponent
|
|
459
|
+
? renderEmptyElement($xeTable)
|
|
460
|
+
: h(VxeUICheckboxComponent, {
|
|
461
|
+
modelValue: supportStyle ? defaultOptions.useStyle : false,
|
|
462
|
+
disabled: !supportStyle,
|
|
463
|
+
title: getI18n('vxe.export.expUseStyleTitle'),
|
|
464
|
+
content: getI18n('vxe.export.expOptUseStyle'),
|
|
465
|
+
'onUpdate:modelValue' (value: any) {
|
|
466
|
+
defaultOptions.useStyle = value
|
|
467
|
+
}
|
|
468
|
+
}),
|
|
469
|
+
VxeUICheckboxComponent
|
|
470
|
+
? h(VxeUICheckboxComponent, {
|
|
471
|
+
modelValue: hasTree ? defaultOptions.isAllExpand : false,
|
|
472
|
+
disabled: hasEmptyData || !hasTree,
|
|
473
|
+
title: getI18n('vxe.export.expAllExpandTitle'),
|
|
474
|
+
content: getI18n('vxe.export.expOptAllExpand'),
|
|
475
|
+
'onUpdate:modelValue' (value: any) {
|
|
476
|
+
defaultOptions.isAllExpand = value
|
|
477
|
+
}
|
|
478
|
+
})
|
|
479
|
+
: renderEmptyElement($xeTable)
|
|
480
|
+
]),
|
|
481
|
+
h('div', {
|
|
482
|
+
class: 'vxe-table-export--panel-option-row'
|
|
483
|
+
}, [
|
|
484
|
+
VxeUICheckboxComponent
|
|
485
|
+
? h(VxeUICheckboxComponent, {
|
|
486
|
+
modelValue: defaultOptions.isFooter,
|
|
487
|
+
disabled: !storeData.hasFooter,
|
|
488
|
+
title: getI18n('vxe.export.expFooterTitle'),
|
|
489
|
+
content: getI18n('vxe.export.expOptFooter'),
|
|
490
|
+
'onUpdate:modelValue' (value: any) {
|
|
491
|
+
defaultOptions.isFooter = value
|
|
492
|
+
}
|
|
493
|
+
})
|
|
494
|
+
: renderEmptyElement($xeTable)
|
|
495
|
+
])
|
|
496
|
+
])
|
|
497
|
+
])
|
|
498
|
+
]
|
|
499
|
+
])
|
|
500
|
+
])
|
|
501
|
+
]),
|
|
502
|
+
bottomSlot
|
|
503
|
+
? h('div', {
|
|
504
|
+
class: 'vxe-table-export--panel-bottom'
|
|
505
|
+
}, $xeTable.callSlot(bottomSlot, params))
|
|
506
|
+
: renderEmptyElement($xeTable)
|
|
507
|
+
])
|
|
508
|
+
},
|
|
509
|
+
footer () {
|
|
510
|
+
const params = {
|
|
511
|
+
$table: $xeTable,
|
|
512
|
+
$grid: $xeGrid,
|
|
513
|
+
$gantt: $xeGantt,
|
|
514
|
+
options: defaultOptions,
|
|
515
|
+
columns,
|
|
516
|
+
params: defaultOptions.params as any
|
|
517
|
+
}
|
|
518
|
+
return h('div', {
|
|
519
|
+
class: 'vxe-table-export--panel-footer'
|
|
520
|
+
}, footerSlot
|
|
521
|
+
? $xeTable.callSlot(footerSlot, params)
|
|
522
|
+
: [
|
|
523
|
+
h('div', {
|
|
524
|
+
class: 'vxe-table-export--panel-btns'
|
|
525
|
+
}, [
|
|
526
|
+
VxeUIButtonComponent
|
|
527
|
+
? h(VxeUIButtonComponent, {
|
|
528
|
+
content: getI18n('vxe.export.expCancel'),
|
|
529
|
+
onClick: cancelEvent
|
|
530
|
+
})
|
|
531
|
+
: renderEmptyElement($xeTable),
|
|
532
|
+
VxeUIButtonComponent
|
|
533
|
+
? h(VxeUIButtonComponent, {
|
|
534
|
+
ref: xButtonConfirm,
|
|
535
|
+
status: 'primary',
|
|
536
|
+
content: getI18n(isPrint ? 'vxe.export.expPrint' : 'vxe.export.expConfirm'),
|
|
537
|
+
onClick: confirmEvent
|
|
538
|
+
})
|
|
539
|
+
: renderEmptyElement($xeTable)
|
|
540
|
+
])
|
|
541
|
+
])
|
|
542
|
+
}
|
|
543
|
+
})
|
|
544
|
+
: renderEmptyElement($xeTable)
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
nextTick(() => {
|
|
548
|
+
if (!VxeUIModalComponent) {
|
|
549
|
+
errLog('vxe.error.reqComp', ['vxe-modal'])
|
|
550
|
+
}
|
|
551
|
+
if (!VxeUIButtonComponent) {
|
|
552
|
+
errLog('vxe.error.reqComp', ['vxe-button'])
|
|
553
|
+
}
|
|
554
|
+
if (!VxeUISelectComponent) {
|
|
555
|
+
errLog('vxe.error.reqComp', ['vxe-select'])
|
|
556
|
+
}
|
|
557
|
+
if (!VxeUIInputComponent) {
|
|
558
|
+
errLog('vxe.error.reqComp', ['vxe-input'])
|
|
559
|
+
}
|
|
560
|
+
if (!VxeUICheckboxComponent) {
|
|
561
|
+
errLog('vxe.error.reqComp', ['vxe-checkbox'])
|
|
562
|
+
}
|
|
563
|
+
})
|
|
564
|
+
|
|
565
|
+
return renderVN
|
|
566
|
+
}
|
|
567
|
+
})
|