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,266 +1,266 @@
|
|
|
1
|
-
import { h, ref, Ref, computed, inject, reactive, nextTick, PropType } from 'vue'
|
|
2
|
-
import { defineVxeComponent } from '../../../ui/src/comp'
|
|
3
|
-
import { VxeUI } from '../../../ui'
|
|
4
|
-
import XEUtils from 'xe-utils'
|
|
5
|
-
import { parseFile } 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: 'VxeTableImportPanel',
|
|
14
|
-
props: {
|
|
15
|
-
defaultOptions: {
|
|
16
|
-
type: Object as PropType<VxeTableDefines.ImportParamsObj>,
|
|
17
|
-
default: () => ({} as VxeTableDefines.ImportParamsObj)
|
|
18
|
-
},
|
|
19
|
-
storeData: {
|
|
20
|
-
type: Object as PropType<VxeTableDefines.ImportStoreObj>,
|
|
21
|
-
default: () => ({} as VxeTableDefines.ImportStoreObj)
|
|
22
|
-
}
|
|
23
|
-
},
|
|
24
|
-
setup (props) {
|
|
25
|
-
const VxeUIModalComponent = VxeUI.getComponent('VxeModal')
|
|
26
|
-
const VxeUIButtonComponent = VxeUI.getComponent('VxeButton')
|
|
27
|
-
const VxeUISelectComponent = VxeUI.getComponent('VxeSelect')
|
|
28
|
-
|
|
29
|
-
const $xeTable = inject('$xeTable', {} as VxeTableConstructor & VxeTableMethods & VxeTablePrivateMethods)
|
|
30
|
-
const { computeImportOpts } = $xeTable.getComputeMaps()
|
|
31
|
-
|
|
32
|
-
const reactData = reactive({
|
|
33
|
-
loading: false
|
|
34
|
-
})
|
|
35
|
-
|
|
36
|
-
const refFileBtn = ref() as Ref<HTMLButtonElement>
|
|
37
|
-
|
|
38
|
-
const computeSelectName = computed(() => {
|
|
39
|
-
const { storeData } = props
|
|
40
|
-
return `${storeData.filename}.${storeData.type}`
|
|
41
|
-
})
|
|
42
|
-
|
|
43
|
-
const computeHasFile = computed(() => {
|
|
44
|
-
const { storeData } = props
|
|
45
|
-
return storeData.file && storeData.type
|
|
46
|
-
})
|
|
47
|
-
|
|
48
|
-
const computeParseTypeLabel = computed(() => {
|
|
49
|
-
const { storeData } = props
|
|
50
|
-
const { type, typeList } = storeData
|
|
51
|
-
if (type) {
|
|
52
|
-
const selectItem = XEUtils.find(typeList, item => type === item.value)
|
|
53
|
-
return `${selectItem ? selectItem.label : '*.*'}`
|
|
54
|
-
}
|
|
55
|
-
return `*.${typeList.map((item) => item.value).join(', *.')}`
|
|
56
|
-
})
|
|
57
|
-
|
|
58
|
-
const clearFileEvent = () => {
|
|
59
|
-
const { storeData } = props
|
|
60
|
-
Object.assign(storeData, {
|
|
61
|
-
filename: '',
|
|
62
|
-
sheetName: '',
|
|
63
|
-
type: ''
|
|
64
|
-
})
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
const selectFileEvent = () => {
|
|
68
|
-
const { storeData, defaultOptions } = props
|
|
69
|
-
$xeTable.readFile(defaultOptions).then((params) => {
|
|
70
|
-
const { file } = params
|
|
71
|
-
Object.assign(storeData, parseFile(file), { file })
|
|
72
|
-
}).catch(() => {})
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
const showEvent = () => {
|
|
76
|
-
nextTick(() => {
|
|
77
|
-
const targetElem = refFileBtn.value
|
|
78
|
-
if (targetElem) {
|
|
79
|
-
targetElem.focus()
|
|
80
|
-
}
|
|
81
|
-
})
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
const cancelEvent = () => {
|
|
85
|
-
const { storeData } = props
|
|
86
|
-
storeData.visible = false
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
const importEvent = () => {
|
|
90
|
-
const { storeData, defaultOptions } = props
|
|
91
|
-
const importOpts = computeImportOpts.value
|
|
92
|
-
reactData.loading = true
|
|
93
|
-
$xeTable.importByFile(storeData.file, Object.assign({}, importOpts, defaultOptions)).then(() => {
|
|
94
|
-
reactData.loading = false
|
|
95
|
-
storeData.visible = false
|
|
96
|
-
}).catch(() => {
|
|
97
|
-
reactData.loading = false
|
|
98
|
-
})
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
const renderVN = () => {
|
|
102
|
-
const $xeGrid = $xeTable.xeGrid
|
|
103
|
-
const $xeGantt = $xeTable.xeGantt
|
|
104
|
-
|
|
105
|
-
const { defaultOptions, storeData } = props
|
|
106
|
-
const selectName = computeSelectName.value
|
|
107
|
-
const hasFile = computeHasFile.value
|
|
108
|
-
const parseTypeLabel = computeParseTypeLabel.value
|
|
109
|
-
const slots = defaultOptions.slots || {}
|
|
110
|
-
const topSlot = slots.top
|
|
111
|
-
const bottomSlot = slots.bottom
|
|
112
|
-
const defaultSlot = slots.default
|
|
113
|
-
const footerSlot = slots.footer
|
|
114
|
-
return VxeUIModalComponent
|
|
115
|
-
? h(VxeUIModalComponent, {
|
|
116
|
-
id: 'VXE_IMPORT_MODAL',
|
|
117
|
-
modelValue: storeData.visible,
|
|
118
|
-
title: getI18n('vxe.import.impTitle'),
|
|
119
|
-
className: 'vxe-table-export-popup-wrapper',
|
|
120
|
-
width: 540,
|
|
121
|
-
minWidth: 360,
|
|
122
|
-
minHeight: 240,
|
|
123
|
-
mask: true,
|
|
124
|
-
lockView: true,
|
|
125
|
-
showFooter: true,
|
|
126
|
-
escClosable: true,
|
|
127
|
-
maskClosable: true,
|
|
128
|
-
showMaximize: true,
|
|
129
|
-
resize: true,
|
|
130
|
-
loading: reactData.loading,
|
|
131
|
-
'onUpdate:modelValue' (value: any) {
|
|
132
|
-
storeData.visible = value
|
|
133
|
-
},
|
|
134
|
-
onShow: showEvent
|
|
135
|
-
}, {
|
|
136
|
-
default: () => {
|
|
137
|
-
const params = {
|
|
138
|
-
$table: $xeTable,
|
|
139
|
-
$grid: $xeGrid,
|
|
140
|
-
$gantt: $xeGantt,
|
|
141
|
-
options: defaultOptions,
|
|
142
|
-
params: defaultOptions.params as any
|
|
143
|
-
}
|
|
144
|
-
return h('div', {
|
|
145
|
-
class: 'vxe-table-export--panel'
|
|
146
|
-
}, [
|
|
147
|
-
topSlot
|
|
148
|
-
? h('div', {
|
|
149
|
-
class: 'vxe-table-export--panel-top'
|
|
150
|
-
}, $xeTable.callSlot(topSlot, params))
|
|
151
|
-
: renderEmptyElement($xeTable),
|
|
152
|
-
h('div', {
|
|
153
|
-
class: 'vxe-table-export--panel-body'
|
|
154
|
-
}, defaultSlot
|
|
155
|
-
? $xeTable.callSlot(defaultSlot, params)
|
|
156
|
-
: [
|
|
157
|
-
h('table', {
|
|
158
|
-
class: 'vxe-table-export--panel-table',
|
|
159
|
-
cellspacing: 0,
|
|
160
|
-
cellpadding: 0,
|
|
161
|
-
border: 0
|
|
162
|
-
}, [
|
|
163
|
-
h('tbody', [
|
|
164
|
-
h('tr', [
|
|
165
|
-
h('td', getI18n('vxe.import.impFile')),
|
|
166
|
-
h('td', [
|
|
167
|
-
hasFile
|
|
168
|
-
? h('div', {
|
|
169
|
-
class: 'vxe-table-export--selected--file',
|
|
170
|
-
title: selectName
|
|
171
|
-
}, [
|
|
172
|
-
h('span', selectName),
|
|
173
|
-
h('i', {
|
|
174
|
-
class: getIcon().INPUT_CLEAR,
|
|
175
|
-
onClick: clearFileEvent
|
|
176
|
-
})
|
|
177
|
-
])
|
|
178
|
-
: h('button', {
|
|
179
|
-
ref: refFileBtn,
|
|
180
|
-
class: 'vxe-table-export--select--file',
|
|
181
|
-
onClick: selectFileEvent
|
|
182
|
-
}, getI18n('vxe.import.impSelect'))
|
|
183
|
-
])
|
|
184
|
-
]),
|
|
185
|
-
h('tr', [
|
|
186
|
-
h('td', getI18n('vxe.import.impType')),
|
|
187
|
-
h('td', parseTypeLabel)
|
|
188
|
-
]),
|
|
189
|
-
h('tr', [
|
|
190
|
-
h('td', getI18n('vxe.import.impMode')),
|
|
191
|
-
h('td', [
|
|
192
|
-
VxeUISelectComponent
|
|
193
|
-
? h(VxeUISelectComponent, {
|
|
194
|
-
modelValue: defaultOptions.mode,
|
|
195
|
-
options: storeData.modeList,
|
|
196
|
-
'onUpdate:modelValue' (value: any) {
|
|
197
|
-
defaultOptions.mode = value
|
|
198
|
-
}
|
|
199
|
-
})
|
|
200
|
-
: renderEmptyElement($xeTable)
|
|
201
|
-
])
|
|
202
|
-
])
|
|
203
|
-
])
|
|
204
|
-
])
|
|
205
|
-
]
|
|
206
|
-
),
|
|
207
|
-
bottomSlot
|
|
208
|
-
? h('div', {
|
|
209
|
-
class: 'vxe-table-export--panel-bottom'
|
|
210
|
-
}, $xeTable.callSlot(bottomSlot, params))
|
|
211
|
-
: renderEmptyElement($xeTable)
|
|
212
|
-
])
|
|
213
|
-
},
|
|
214
|
-
footer () {
|
|
215
|
-
const params = {
|
|
216
|
-
$table: $xeTable,
|
|
217
|
-
$grid: $xeGrid,
|
|
218
|
-
$gantt: $xeGantt,
|
|
219
|
-
options: defaultOptions,
|
|
220
|
-
params: defaultOptions.params as any
|
|
221
|
-
}
|
|
222
|
-
return h('div', {
|
|
223
|
-
class: 'vxe-table-export--panel-footer'
|
|
224
|
-
}, footerSlot
|
|
225
|
-
? $xeTable.callSlot(footerSlot, params)
|
|
226
|
-
: [
|
|
227
|
-
h('div', {
|
|
228
|
-
class: 'vxe-table-export--panel-btns'
|
|
229
|
-
}, [
|
|
230
|
-
VxeUIButtonComponent
|
|
231
|
-
? h(VxeUIButtonComponent, {
|
|
232
|
-
content: getI18n('vxe.import.impCancel'),
|
|
233
|
-
onClick: cancelEvent
|
|
234
|
-
})
|
|
235
|
-
: renderEmptyElement($xeTable),
|
|
236
|
-
VxeUIButtonComponent
|
|
237
|
-
? h(VxeUIButtonComponent, {
|
|
238
|
-
status: 'primary',
|
|
239
|
-
disabled: !hasFile || reactData.loading,
|
|
240
|
-
content: getI18n('vxe.import.impConfirm'),
|
|
241
|
-
onClick: importEvent
|
|
242
|
-
})
|
|
243
|
-
: renderEmptyElement($xeTable)
|
|
244
|
-
])
|
|
245
|
-
]
|
|
246
|
-
)
|
|
247
|
-
}
|
|
248
|
-
})
|
|
249
|
-
: renderEmptyElement($xeTable)
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
nextTick(() => {
|
|
253
|
-
if (!VxeUIModalComponent) {
|
|
254
|
-
errLog('vxe.error.reqComp', ['vxe-modal'])
|
|
255
|
-
}
|
|
256
|
-
if (!VxeUIButtonComponent) {
|
|
257
|
-
errLog('vxe.error.reqComp', ['vxe-button'])
|
|
258
|
-
}
|
|
259
|
-
if (!VxeUISelectComponent) {
|
|
260
|
-
errLog('vxe.error.reqComp', ['vxe-select'])
|
|
261
|
-
}
|
|
262
|
-
})
|
|
263
|
-
|
|
264
|
-
return renderVN
|
|
265
|
-
}
|
|
266
|
-
})
|
|
1
|
+
import { h, ref, Ref, computed, inject, reactive, nextTick, PropType } from 'vue'
|
|
2
|
+
import { defineVxeComponent } from '../../../ui/src/comp'
|
|
3
|
+
import { VxeUI } from '../../../ui'
|
|
4
|
+
import XEUtils from 'xe-utils'
|
|
5
|
+
import { parseFile } 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: 'VxeTableImportPanel',
|
|
14
|
+
props: {
|
|
15
|
+
defaultOptions: {
|
|
16
|
+
type: Object as PropType<VxeTableDefines.ImportParamsObj>,
|
|
17
|
+
default: () => ({} as VxeTableDefines.ImportParamsObj)
|
|
18
|
+
},
|
|
19
|
+
storeData: {
|
|
20
|
+
type: Object as PropType<VxeTableDefines.ImportStoreObj>,
|
|
21
|
+
default: () => ({} as VxeTableDefines.ImportStoreObj)
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
setup (props) {
|
|
25
|
+
const VxeUIModalComponent = VxeUI.getComponent('VxeModal')
|
|
26
|
+
const VxeUIButtonComponent = VxeUI.getComponent('VxeButton')
|
|
27
|
+
const VxeUISelectComponent = VxeUI.getComponent('VxeSelect')
|
|
28
|
+
|
|
29
|
+
const $xeTable = inject('$xeTable', {} as VxeTableConstructor & VxeTableMethods & VxeTablePrivateMethods)
|
|
30
|
+
const { computeImportOpts } = $xeTable.getComputeMaps()
|
|
31
|
+
|
|
32
|
+
const reactData = reactive({
|
|
33
|
+
loading: false
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
const refFileBtn = ref() as Ref<HTMLButtonElement>
|
|
37
|
+
|
|
38
|
+
const computeSelectName = computed(() => {
|
|
39
|
+
const { storeData } = props
|
|
40
|
+
return `${storeData.filename}.${storeData.type}`
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
const computeHasFile = computed(() => {
|
|
44
|
+
const { storeData } = props
|
|
45
|
+
return storeData.file && storeData.type
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
const computeParseTypeLabel = computed(() => {
|
|
49
|
+
const { storeData } = props
|
|
50
|
+
const { type, typeList } = storeData
|
|
51
|
+
if (type) {
|
|
52
|
+
const selectItem = XEUtils.find(typeList, item => type === item.value)
|
|
53
|
+
return `${selectItem ? selectItem.label : '*.*'}`
|
|
54
|
+
}
|
|
55
|
+
return `*.${typeList.map((item) => item.value).join(', *.')}`
|
|
56
|
+
})
|
|
57
|
+
|
|
58
|
+
const clearFileEvent = () => {
|
|
59
|
+
const { storeData } = props
|
|
60
|
+
Object.assign(storeData, {
|
|
61
|
+
filename: '',
|
|
62
|
+
sheetName: '',
|
|
63
|
+
type: ''
|
|
64
|
+
})
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const selectFileEvent = () => {
|
|
68
|
+
const { storeData, defaultOptions } = props
|
|
69
|
+
$xeTable.readFile(defaultOptions).then((params) => {
|
|
70
|
+
const { file } = params
|
|
71
|
+
Object.assign(storeData, parseFile(file), { file })
|
|
72
|
+
}).catch(() => {})
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const showEvent = () => {
|
|
76
|
+
nextTick(() => {
|
|
77
|
+
const targetElem = refFileBtn.value
|
|
78
|
+
if (targetElem) {
|
|
79
|
+
targetElem.focus()
|
|
80
|
+
}
|
|
81
|
+
})
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
const cancelEvent = () => {
|
|
85
|
+
const { storeData } = props
|
|
86
|
+
storeData.visible = false
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
const importEvent = () => {
|
|
90
|
+
const { storeData, defaultOptions } = props
|
|
91
|
+
const importOpts = computeImportOpts.value
|
|
92
|
+
reactData.loading = true
|
|
93
|
+
$xeTable.importByFile(storeData.file, Object.assign({}, importOpts, defaultOptions)).then(() => {
|
|
94
|
+
reactData.loading = false
|
|
95
|
+
storeData.visible = false
|
|
96
|
+
}).catch(() => {
|
|
97
|
+
reactData.loading = false
|
|
98
|
+
})
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
const renderVN = () => {
|
|
102
|
+
const $xeGrid = $xeTable.xeGrid
|
|
103
|
+
const $xeGantt = $xeTable.xeGantt
|
|
104
|
+
|
|
105
|
+
const { defaultOptions, storeData } = props
|
|
106
|
+
const selectName = computeSelectName.value
|
|
107
|
+
const hasFile = computeHasFile.value
|
|
108
|
+
const parseTypeLabel = computeParseTypeLabel.value
|
|
109
|
+
const slots = defaultOptions.slots || {}
|
|
110
|
+
const topSlot = slots.top
|
|
111
|
+
const bottomSlot = slots.bottom
|
|
112
|
+
const defaultSlot = slots.default
|
|
113
|
+
const footerSlot = slots.footer
|
|
114
|
+
return VxeUIModalComponent
|
|
115
|
+
? h(VxeUIModalComponent, {
|
|
116
|
+
id: 'VXE_IMPORT_MODAL',
|
|
117
|
+
modelValue: storeData.visible,
|
|
118
|
+
title: getI18n('vxe.import.impTitle'),
|
|
119
|
+
className: 'vxe-table-export-popup-wrapper',
|
|
120
|
+
width: 540,
|
|
121
|
+
minWidth: 360,
|
|
122
|
+
minHeight: 240,
|
|
123
|
+
mask: true,
|
|
124
|
+
lockView: true,
|
|
125
|
+
showFooter: true,
|
|
126
|
+
escClosable: true,
|
|
127
|
+
maskClosable: true,
|
|
128
|
+
showMaximize: true,
|
|
129
|
+
resize: true,
|
|
130
|
+
loading: reactData.loading,
|
|
131
|
+
'onUpdate:modelValue' (value: any) {
|
|
132
|
+
storeData.visible = value
|
|
133
|
+
},
|
|
134
|
+
onShow: showEvent
|
|
135
|
+
}, {
|
|
136
|
+
default: () => {
|
|
137
|
+
const params = {
|
|
138
|
+
$table: $xeTable,
|
|
139
|
+
$grid: $xeGrid,
|
|
140
|
+
$gantt: $xeGantt,
|
|
141
|
+
options: defaultOptions,
|
|
142
|
+
params: defaultOptions.params as any
|
|
143
|
+
}
|
|
144
|
+
return h('div', {
|
|
145
|
+
class: 'vxe-table-export--panel'
|
|
146
|
+
}, [
|
|
147
|
+
topSlot
|
|
148
|
+
? h('div', {
|
|
149
|
+
class: 'vxe-table-export--panel-top'
|
|
150
|
+
}, $xeTable.callSlot(topSlot, params))
|
|
151
|
+
: renderEmptyElement($xeTable),
|
|
152
|
+
h('div', {
|
|
153
|
+
class: 'vxe-table-export--panel-body'
|
|
154
|
+
}, defaultSlot
|
|
155
|
+
? $xeTable.callSlot(defaultSlot, params)
|
|
156
|
+
: [
|
|
157
|
+
h('table', {
|
|
158
|
+
class: 'vxe-table-export--panel-table',
|
|
159
|
+
cellspacing: 0,
|
|
160
|
+
cellpadding: 0,
|
|
161
|
+
border: 0
|
|
162
|
+
}, [
|
|
163
|
+
h('tbody', [
|
|
164
|
+
h('tr', [
|
|
165
|
+
h('td', getI18n('vxe.import.impFile')),
|
|
166
|
+
h('td', [
|
|
167
|
+
hasFile
|
|
168
|
+
? h('div', {
|
|
169
|
+
class: 'vxe-table-export--selected--file',
|
|
170
|
+
title: selectName
|
|
171
|
+
}, [
|
|
172
|
+
h('span', selectName),
|
|
173
|
+
h('i', {
|
|
174
|
+
class: getIcon().INPUT_CLEAR,
|
|
175
|
+
onClick: clearFileEvent
|
|
176
|
+
})
|
|
177
|
+
])
|
|
178
|
+
: h('button', {
|
|
179
|
+
ref: refFileBtn,
|
|
180
|
+
class: 'vxe-table-export--select--file',
|
|
181
|
+
onClick: selectFileEvent
|
|
182
|
+
}, getI18n('vxe.import.impSelect'))
|
|
183
|
+
])
|
|
184
|
+
]),
|
|
185
|
+
h('tr', [
|
|
186
|
+
h('td', getI18n('vxe.import.impType')),
|
|
187
|
+
h('td', parseTypeLabel)
|
|
188
|
+
]),
|
|
189
|
+
h('tr', [
|
|
190
|
+
h('td', getI18n('vxe.import.impMode')),
|
|
191
|
+
h('td', [
|
|
192
|
+
VxeUISelectComponent
|
|
193
|
+
? h(VxeUISelectComponent, {
|
|
194
|
+
modelValue: defaultOptions.mode,
|
|
195
|
+
options: storeData.modeList,
|
|
196
|
+
'onUpdate:modelValue' (value: any) {
|
|
197
|
+
defaultOptions.mode = value
|
|
198
|
+
}
|
|
199
|
+
})
|
|
200
|
+
: renderEmptyElement($xeTable)
|
|
201
|
+
])
|
|
202
|
+
])
|
|
203
|
+
])
|
|
204
|
+
])
|
|
205
|
+
]
|
|
206
|
+
),
|
|
207
|
+
bottomSlot
|
|
208
|
+
? h('div', {
|
|
209
|
+
class: 'vxe-table-export--panel-bottom'
|
|
210
|
+
}, $xeTable.callSlot(bottomSlot, params))
|
|
211
|
+
: renderEmptyElement($xeTable)
|
|
212
|
+
])
|
|
213
|
+
},
|
|
214
|
+
footer () {
|
|
215
|
+
const params = {
|
|
216
|
+
$table: $xeTable,
|
|
217
|
+
$grid: $xeGrid,
|
|
218
|
+
$gantt: $xeGantt,
|
|
219
|
+
options: defaultOptions,
|
|
220
|
+
params: defaultOptions.params as any
|
|
221
|
+
}
|
|
222
|
+
return h('div', {
|
|
223
|
+
class: 'vxe-table-export--panel-footer'
|
|
224
|
+
}, footerSlot
|
|
225
|
+
? $xeTable.callSlot(footerSlot, params)
|
|
226
|
+
: [
|
|
227
|
+
h('div', {
|
|
228
|
+
class: 'vxe-table-export--panel-btns'
|
|
229
|
+
}, [
|
|
230
|
+
VxeUIButtonComponent
|
|
231
|
+
? h(VxeUIButtonComponent, {
|
|
232
|
+
content: getI18n('vxe.import.impCancel'),
|
|
233
|
+
onClick: cancelEvent
|
|
234
|
+
})
|
|
235
|
+
: renderEmptyElement($xeTable),
|
|
236
|
+
VxeUIButtonComponent
|
|
237
|
+
? h(VxeUIButtonComponent, {
|
|
238
|
+
status: 'primary',
|
|
239
|
+
disabled: !hasFile || reactData.loading,
|
|
240
|
+
content: getI18n('vxe.import.impConfirm'),
|
|
241
|
+
onClick: importEvent
|
|
242
|
+
})
|
|
243
|
+
: renderEmptyElement($xeTable)
|
|
244
|
+
])
|
|
245
|
+
]
|
|
246
|
+
)
|
|
247
|
+
}
|
|
248
|
+
})
|
|
249
|
+
: renderEmptyElement($xeTable)
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
nextTick(() => {
|
|
253
|
+
if (!VxeUIModalComponent) {
|
|
254
|
+
errLog('vxe.error.reqComp', ['vxe-modal'])
|
|
255
|
+
}
|
|
256
|
+
if (!VxeUIButtonComponent) {
|
|
257
|
+
errLog('vxe.error.reqComp', ['vxe-button'])
|
|
258
|
+
}
|
|
259
|
+
if (!VxeUISelectComponent) {
|
|
260
|
+
errLog('vxe.error.reqComp', ['vxe-select'])
|
|
261
|
+
}
|
|
262
|
+
})
|
|
263
|
+
|
|
264
|
+
return renderVN
|
|
265
|
+
}
|
|
266
|
+
})
|
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
import type { VxeTablePropTypes } from '../../../../types'
|
|
2
|
-
|
|
3
|
-
// 默认导出或打印的 HTML 样式
|
|
4
|
-
const defaultHtmlStyle = 'body{margin:0;padding: 0 1px;color:#333333;font-size:14px;font-family:"Microsoft YaHei",微软雅黑,"MicrosoftJhengHei",华文细黑,STHeiti,MingLiu}body *{-webkit-box-sizing:border-box;box-sizing:border-box}.vxe-table{border-collapse:collapse;text-align:left;border-spacing:0}.vxe-table:not(.is--print){table-layout:fixed}.vxe-table,.vxe-table th,.vxe-table td,.vxe-table td{border-color:#D0D0D0;border-style:solid;border-width:0}.vxe-table.is--print{width:100%}.border--default,.border--full,.border--outer{border-top-width:1px}.border--default,.border--full,.border--outer{border-left-width:1px}.border--outer,.border--default th,.border--default td,.border--full th,.border--full td,.border--outer th,.border--inner th,.border--inner td{border-bottom-width:1px}.border--default,.border--outer,.border--full th,.border--full td{border-right-width:1px}.border--default th,.border--full th,.border--outer th{background-color:#f8f8f9}.vxe-table td>div,.vxe-table th>div{padding:.5em .4em}.col--center{text-align:center}.col--right{text-align:right}.vxe-table:not(.is--print) .col--ellipsis>div{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;word-break:break-all}.vxe-table--tree-node{text-align:left}.vxe-table--tree-node-wrapper{position:relative}.vxe-table--tree-icon-wrapper{position:absolute;top:50%;width:1em;height:1em;text-align:center;-webkit-transform:translateY(-50%);transform:translateY(-50%);-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;cursor:pointer}.vxe-table--tree-unfold-icon,.vxe-table--tree-fold-icon{position:absolute;width:0;height:0;border-style:solid;border-width:.5em;border-right-color:transparent;border-bottom-color:transparent}.vxe-table--tree-unfold-icon{left:.3em;top:0;border-left-color:#939599;border-top-color:transparent}.vxe-table--tree-fold-icon{left:0;top:.3em;border-left-color:transparent;border-top-color:#939599}.vxe-table--tree-cell{display:block;padding-left:1.5em}.vxe-table input[type="checkbox"]{margin:0}.vxe-table input[type="checkbox"],.vxe-table input[type="radio"],.vxe-table input[type="checkbox"]+span,.vxe-table input[type="radio"]+span{vertical-align:middle;padding-left:0.4em}'
|
|
5
|
-
|
|
6
|
-
export function getExportBlobByContent (content: string, options: { type: string }) {
|
|
7
|
-
return new Blob([content], { type: `text/${options.type};charset=utf-8;` })
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export function createHtmlPage (opts: VxeTablePropTypes.PrintConfig, content: string): string {
|
|
11
|
-
const { style } = opts
|
|
12
|
-
return [
|
|
13
|
-
'<!DOCTYPE html><html>',
|
|
14
|
-
'<head>',
|
|
15
|
-
'<meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no,minimal-ui">',
|
|
16
|
-
`<title>${opts.sheetName}</title>`,
|
|
17
|
-
'<style media="print">.vxe-page-break-before{page-break-before:always;}.vxe-page-break-after{page-break-after:always;}</style>',
|
|
18
|
-
`<style>${defaultHtmlStyle}</style>`,
|
|
19
|
-
style ? `<style>${style}</style>` : '',
|
|
20
|
-
'</head>',
|
|
21
|
-
`<body>${content}</body>`,
|
|
22
|
-
'</html>'
|
|
23
|
-
].join('')
|
|
24
|
-
}
|
|
1
|
+
import type { VxeTablePropTypes } from '../../../../types'
|
|
2
|
+
|
|
3
|
+
// 默认导出或打印的 HTML 样式
|
|
4
|
+
const defaultHtmlStyle = 'body{margin:0;padding: 0 1px;color:#333333;font-size:14px;font-family:"Microsoft YaHei",微软雅黑,"MicrosoftJhengHei",华文细黑,STHeiti,MingLiu}body *{-webkit-box-sizing:border-box;box-sizing:border-box}.vxe-table{border-collapse:collapse;text-align:left;border-spacing:0}.vxe-table:not(.is--print){table-layout:fixed}.vxe-table,.vxe-table th,.vxe-table td,.vxe-table td{border-color:#D0D0D0;border-style:solid;border-width:0}.vxe-table.is--print{width:100%}.border--default,.border--full,.border--outer{border-top-width:1px}.border--default,.border--full,.border--outer{border-left-width:1px}.border--outer,.border--default th,.border--default td,.border--full th,.border--full td,.border--outer th,.border--inner th,.border--inner td{border-bottom-width:1px}.border--default,.border--outer,.border--full th,.border--full td{border-right-width:1px}.border--default th,.border--full th,.border--outer th{background-color:#f8f8f9}.vxe-table td>div,.vxe-table th>div{padding:.5em .4em}.col--center{text-align:center}.col--right{text-align:right}.vxe-table:not(.is--print) .col--ellipsis>div{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;word-break:break-all}.vxe-table--tree-node{text-align:left}.vxe-table--tree-node-wrapper{position:relative}.vxe-table--tree-icon-wrapper{position:absolute;top:50%;width:1em;height:1em;text-align:center;-webkit-transform:translateY(-50%);transform:translateY(-50%);-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;cursor:pointer}.vxe-table--tree-unfold-icon,.vxe-table--tree-fold-icon{position:absolute;width:0;height:0;border-style:solid;border-width:.5em;border-right-color:transparent;border-bottom-color:transparent}.vxe-table--tree-unfold-icon{left:.3em;top:0;border-left-color:#939599;border-top-color:transparent}.vxe-table--tree-fold-icon{left:0;top:.3em;border-left-color:transparent;border-top-color:#939599}.vxe-table--tree-cell{display:block;padding-left:1.5em}.vxe-table input[type="checkbox"]{margin:0}.vxe-table input[type="checkbox"],.vxe-table input[type="radio"],.vxe-table input[type="checkbox"]+span,.vxe-table input[type="radio"]+span{vertical-align:middle;padding-left:0.4em}'
|
|
5
|
+
|
|
6
|
+
export function getExportBlobByContent (content: string, options: { type: string }) {
|
|
7
|
+
return new Blob([content], { type: `text/${options.type};charset=utf-8;` })
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function createHtmlPage (opts: VxeTablePropTypes.PrintConfig, content: string): string {
|
|
11
|
+
const { style } = opts
|
|
12
|
+
return [
|
|
13
|
+
'<!DOCTYPE html><html>',
|
|
14
|
+
'<head>',
|
|
15
|
+
'<meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no,minimal-ui">',
|
|
16
|
+
`<title>${opts.sheetName}</title>`,
|
|
17
|
+
'<style media="print">.vxe-page-break-before{page-break-before:always;}.vxe-page-break-after{page-break-after:always;}</style>',
|
|
18
|
+
`<style>${defaultHtmlStyle}</style>`,
|
|
19
|
+
style ? `<style>${style}</style>` : '',
|
|
20
|
+
'</head>',
|
|
21
|
+
`<body>${content}</body>`,
|
|
22
|
+
'</html>'
|
|
23
|
+
].join('')
|
|
24
|
+
}
|