vxe-table 3.19.39 → 3.20.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (109) hide show
  1. package/es/index.css +1 -1
  2. package/es/index.esm.js +2 -1
  3. package/es/index.min.css +1 -1
  4. package/es/style.css +1 -1
  5. package/es/style.min.css +1 -1
  6. package/es/table/module/custom/mixin.js +6 -4
  7. package/es/table/module/custom/panel.js +806 -799
  8. package/es/table/module/edit/mixin.js +43 -31
  9. package/es/table/module/export/export-panel.js +511 -458
  10. package/es/table/module/export/import-panel.js +224 -192
  11. package/es/table/module/keyboard/mixin.js +2 -2
  12. package/es/table/module/menu/panel.js +165 -161
  13. package/es/table/module/validator/mixin.js +255 -236
  14. package/es/table/src/body.js +2 -1
  15. package/es/table/src/cell.js +2 -2
  16. package/es/table/src/methods.js +33 -43
  17. package/es/table/src/table.js +13 -249
  18. package/es/table/src/util.js +242 -0
  19. package/es/table/style.css +23 -50
  20. package/es/table/style.min.css +1 -1
  21. package/es/ui/index.js +2 -2
  22. package/es/ui/src/dom.js +22 -0
  23. package/es/ui/src/log.js +1 -1
  24. package/es/vxe-table/style.css +23 -50
  25. package/es/vxe-table/style.min.css +1 -1
  26. package/lib/index.common.js +2 -1
  27. package/lib/index.css +1 -1
  28. package/lib/index.min.css +1 -1
  29. package/lib/index.umd.js +3640 -4790
  30. package/lib/index.umd.min.js +1 -1
  31. package/lib/style.css +1 -1
  32. package/lib/style.min.css +1 -1
  33. package/lib/table/module/custom/mixin.js +6 -4
  34. package/lib/table/module/custom/mixin.min.js +1 -1
  35. package/lib/table/module/custom/panel.js +693 -685
  36. package/lib/table/module/custom/panel.min.js +1 -1
  37. package/lib/table/module/edit/mixin.js +47 -31
  38. package/lib/table/module/edit/mixin.min.js +1 -1
  39. package/lib/table/module/export/export-panel.js +450 -384
  40. package/lib/table/module/export/export-panel.min.js +1 -1
  41. package/lib/table/module/export/import-panel.js +200 -159
  42. package/lib/table/module/export/import-panel.min.js +1 -1
  43. package/lib/table/module/keyboard/mixin.js +2 -2
  44. package/lib/table/module/keyboard/mixin.min.js +1 -1
  45. package/lib/table/module/menu/panel.js +119 -114
  46. package/lib/table/module/menu/panel.min.js +1 -1
  47. package/lib/table/module/validator/mixin.js +271 -259
  48. package/lib/table/module/validator/mixin.min.js +1 -1
  49. package/lib/table/src/body.js +2 -1
  50. package/lib/table/src/body.min.js +1 -1
  51. package/lib/table/src/cell.js +2 -2
  52. package/lib/table/src/cell.min.js +1 -1
  53. package/lib/table/src/methods.js +33 -45
  54. package/lib/table/src/methods.min.js +1 -1
  55. package/lib/table/src/table.js +12 -248
  56. package/lib/table/src/table.min.js +1 -1
  57. package/lib/table/src/util.js +243 -0
  58. package/lib/table/src/util.min.js +1 -1
  59. package/lib/table/style/style.css +23 -50
  60. package/lib/table/style/style.min.css +1 -1
  61. package/lib/ui/index.js +2 -2
  62. package/lib/ui/index.min.js +1 -1
  63. package/lib/ui/src/dom.js +22 -0
  64. package/lib/ui/src/dom.min.js +1 -1
  65. package/lib/ui/src/log.js +1 -1
  66. package/lib/ui/src/log.min.js +1 -1
  67. package/lib/v-x-e-table/index.js +2 -1
  68. package/lib/v-x-e-table/index.min.js +1 -1
  69. package/lib/vxe-colgroup/index.js +2 -1
  70. package/lib/vxe-colgroup/index.min.js +1 -1
  71. package/lib/vxe-column/index.js +2 -1
  72. package/lib/vxe-column/index.min.js +1 -1
  73. package/lib/vxe-grid/index.js +2 -1
  74. package/lib/vxe-grid/index.min.js +1 -1
  75. package/lib/vxe-table/index.js +2 -1
  76. package/lib/vxe-table/index.min.js +1 -1
  77. package/lib/vxe-table/style/style.css +23 -50
  78. package/lib/vxe-table/style/style.min.css +1 -1
  79. package/lib/vxe-toolbar/index.js +2 -1
  80. package/lib/vxe-toolbar/index.min.js +1 -1
  81. package/lib/vxe-ui/index.js +2 -1
  82. package/lib/vxe-ui/index.min.js +1 -1
  83. package/lib/vxe-v-x-e-table/index.js +2 -1
  84. package/lib/vxe-v-x-e-table/index.min.js +1 -1
  85. package/package.json +1 -1
  86. package/packages/table/module/custom/mixin.ts +7 -4
  87. package/packages/table/module/custom/panel.ts +846 -839
  88. package/packages/table/module/edit/mixin.ts +55 -35
  89. package/packages/table/module/export/export-panel.ts +545 -469
  90. package/packages/table/module/export/import-panel.ts +245 -202
  91. package/packages/table/module/filter/panel.ts +4 -18
  92. package/packages/table/module/keyboard/mixin.ts +2 -2
  93. package/packages/table/module/menu/panel.ts +171 -163
  94. package/packages/table/module/validator/mixin.ts +279 -240
  95. package/packages/table/src/body.ts +2 -1
  96. package/packages/table/src/cell.ts +2 -2
  97. package/packages/table/src/methods.ts +43 -45
  98. package/packages/table/src/table.ts +14 -260
  99. package/packages/table/src/util.ts +254 -0
  100. package/packages/ui/index.ts +1 -1
  101. package/packages/ui/src/dom.ts +22 -0
  102. package/styles/components/table.scss +5 -2
  103. package/styles/theme/base.scss +2 -1
  104. /package/es/{iconfont.1767145426781.ttf → iconfont.1767492234857.ttf} +0 -0
  105. /package/es/{iconfont.1767145426781.woff → iconfont.1767492234857.woff} +0 -0
  106. /package/es/{iconfont.1767145426781.woff2 → iconfont.1767492234857.woff2} +0 -0
  107. /package/lib/{iconfont.1767145426781.ttf → iconfont.1767492234857.ttf} +0 -0
  108. /package/lib/{iconfont.1767145426781.woff → iconfont.1767492234857.woff} +0 -0
  109. /package/lib/{iconfont.1767145426781.woff2 → iconfont.1767492234857.woff2} +0 -0
@@ -1,28 +1,29 @@
1
- import { CreateElement } from 'vue'
1
+ import { CreateElement, VNode, PropType } from 'vue'
2
+ import { defineVxeComponent } from '../../../ui/src/comp'
2
3
  import { VxeUI } from '../../../ui'
3
4
  import XEUtils from 'xe-utils'
4
5
  import { formatText } from '../../../ui/src/utils'
5
6
  import { errLog } from '../../../ui/src/log'
6
7
 
7
- import type { VxeTableConstructor, VxeTablePrivateMethods } from '../../../../types'
8
+ import type { VxeComponentSizeType } from 'vxe-pc-ui'
9
+ import type { VxeTableConstructor, VxeTablePrivateMethods, VxeTableDefines } from '../../../../types'
8
10
 
9
11
  const { getI18n, getIcon, globalMixins, renderEmptyElement } = VxeUI
10
12
 
11
- export default {
13
+ export default /* define-vxe-component start */ defineVxeComponent({
12
14
  name: 'VxeTableExportPanel',
13
15
  mixins: [
14
16
  globalMixins.sizeMixin
15
17
  ],
16
18
  props: {
17
- defaultOptions: Object,
18
- storeData: Object
19
- },
20
- components: {
21
- // VxeModal,
22
- // VxeInput,
23
- // VxeCheckbox,
24
- // VxeSelect,
25
- // VxeOption
19
+ defaultOptions: {
20
+ type: Object as PropType<VxeTableDefines.ExportParamsObj>,
21
+ default: () => ({} as VxeTableDefines.ExportParamsObj)
22
+ },
23
+ storeData: {
24
+ type: Object as PropType<VxeTableDefines.ExportStoreObj>,
25
+ default: () => ({} as VxeTableDefines.ExportStoreObj)
26
+ }
26
27
  },
27
28
  inject: {
28
29
  $xeTable: {
@@ -30,33 +31,58 @@ export default {
30
31
  }
31
32
  },
32
33
  data () {
33
- return {
34
+ const reactData = {
34
35
  isAll: false,
35
36
  isIndeterminate: false,
36
37
  loading: false
37
38
  }
39
+
40
+ return {
41
+ reactData
42
+ }
38
43
  },
39
44
  computed: {
40
- checkedAll () {
41
- return this.storeData.columns.every((column: any) => column.checked)
45
+ ...({} as {
46
+ computeSize(): VxeComponentSizeType
47
+ $xeTable(): VxeTableConstructor & VxeTablePrivateMethods
48
+ }),
49
+ computeCheckedAll () {
50
+ const $xeExportPanel = this
51
+ const props = $xeExportPanel
52
+
53
+ const { storeData } = props
54
+ return storeData.columns.every((column) => column.checked)
42
55
  },
43
- showSheet () {
44
- return ['html', 'xml', 'xlsx', 'pdf'].indexOf(this.defaultOptions.type) > -1
56
+ computeShowSheet () {
57
+ const $xeExportPanel = this
58
+ const props = $xeExportPanel
59
+
60
+ const { defaultOptions } = props
61
+ return ['html', 'xml', 'xlsx', 'pdf'].indexOf(defaultOptions.type) > -1
45
62
  },
46
- supportMerge () {
47
- const { storeData, defaultOptions } = this
63
+ computeSupportMerge () {
64
+ const $xeExportPanel = this
65
+ const props = $xeExportPanel
66
+
67
+ const { storeData, defaultOptions } = props
48
68
  return !defaultOptions.original && defaultOptions.mode === 'current' && (storeData.isPrint || ['html', 'xlsx'].indexOf(defaultOptions.type) > -1)
49
69
  },
50
70
  // computeSupportGroup () {
51
- // const { defaultOptions } = this
71
+ // const $xeExportPanel = this
72
+ // const props = $xeExportPanel
73
+
74
+ // const { defaultOptions } = props
52
75
  // return ['html', 'xlsx', 'csv', 'txt'].indexOf(defaultOptions.type) > -1
53
76
  // },
54
- supportStyle () {
55
- const { defaultOptions } = this
77
+ computeSupportStyle () {
78
+ const $xeExportPanel = this
79
+ const props = $xeExportPanel
80
+
81
+ const { defaultOptions } = props
56
82
  return !defaultOptions.original && ['xlsx'].indexOf(defaultOptions.type) > -1
57
83
  }
58
- } as any,
59
- created (this: any) {
84
+ },
85
+ created () {
60
86
  const $xeTableExportPanel = this
61
87
 
62
88
  const VxeUIModalComponent = VxeUI.getComponent('VxeModal')
@@ -83,467 +109,78 @@ export default {
83
109
  }
84
110
  })
85
111
  },
86
- render (this: any, h: CreateElement) {
87
- const $xeTable = this.$xeTable as VxeTableConstructor & VxeTablePrivateMethods
88
- const $xeGrid = $xeTable.$xeGrid
89
- const $xeGantt = $xeTable.$xeGantt
90
-
91
- const { _e, checkedAll, isAll: isAllChecked, isIndeterminate: isAllIndeterminate, showSheet, supportMerge, supportStyle, defaultOptions, storeData } = this
92
- const { hasTree, hasMerge, isPrint, hasColgroup, columns } = storeData
93
- const { isHeader } = defaultOptions
94
- // const supportGroup = this.computeSupportGroup
95
- const slots = defaultOptions.slots || {}
96
- const topSlot = slots.top
97
- const bottomSlot = slots.bottom
98
- const defaultSlot = slots.default
99
- const footerSlot = slots.footer
100
- const parameterSlot = slots.parameter
101
- const cols: any[] = []
102
- XEUtils.eachTree(columns, column => {
103
- const colTitle = formatText(column.getTitle(), 1)
104
- const isColGroup = column.children && column.children.length
105
- const isChecked = column.checked
106
- const indeterminate = column.halfChecked
107
- const isHtml = column.type === 'html'
108
- cols.push(
109
- h('li', {
110
- class: ['vxe-table-export--panel-column-option', `level--${column.level}`, {
111
- 'is--group': isColGroup,
112
- 'is--checked': isChecked,
113
- 'is--indeterminate': indeterminate,
114
- 'is--disabled': column.disabled
115
- }],
116
- attrs: {
117
- title: colTitle
118
- },
119
- on: {
120
- click: () => {
121
- if (!column.disabled) {
122
- this.changeOption(column)
123
- }
124
- }
125
- }
126
- }, [
127
- h('span', {
128
- class: ['vxe-checkbox--icon', indeterminate ? getIcon().TABLE_CHECKBOX_INDETERMINATE : (isChecked ? getIcon().TABLE_CHECKBOX_CHECKED : getIcon().TABLE_CHECKBOX_UNCHECKED)]
129
- }),
130
- isHtml
131
- ? h('span', {
132
- key: '1',
133
- class: 'vxe-checkbox--label',
134
- domProps: {
135
- innerHTML: colTitle
136
- }
137
- })
138
- : h('span', {
139
- key: '0',
140
- class: 'vxe-checkbox--label'
141
- }, colTitle)
142
- ])
143
- )
144
- })
145
- return h('vxe-modal', {
146
- ref: 'modal',
147
- props: {
148
- id: 'VXE_EXPORT_MODAL',
149
- value: storeData.visible,
150
- title: getI18n(isPrint ? 'vxe.export.printTitle' : 'vxe.export.expTitle'),
151
- width: 660,
152
- minWidth: 500,
153
- minHeight: 400,
154
- mask: true,
155
- lockView: true,
156
- showFooter: true,
157
- escClosable: true,
158
- maskClosable: true,
159
- showMaximize: true,
160
- resize: true,
161
- loading: this.loading
162
- },
163
- on: {
164
- input (value: any) {
165
- storeData.visible = value
166
- },
167
- show: this.showEvent
168
- },
169
- scopedSlots: {
170
- default: () => {
171
- const params = {
172
- $table: $xeTable,
173
- $grid: $xeGrid,
174
- $gantt: $xeGantt,
175
- options: defaultOptions,
176
- columns,
177
- params: defaultOptions.params as any
178
- }
179
- const hasEmptyData = defaultOptions.mode === 'empty'
180
-
181
- return h('div', {
182
- class: 'vxe-table-export--panel'
183
- }, [
184
- topSlot
185
- ? h('div', {
186
- class: 'vxe-table-export--panel-top'
187
- }, $xeTable.callSlot(topSlot, params, h))
188
- : renderEmptyElement(this),
189
- h('div', {
190
- class: 'vxe-table-export--panel-body'
191
- }, defaultSlot
192
- ? $xeTable.callSlot(defaultSlot, params, h)
193
- : [
194
- h('table', {
195
- attrs: {
196
- class: 'vxe-table-export--panel-table',
197
- cellspacing: 0,
198
- cellpadding: 0,
199
- border: 0
200
- }
201
- }, [
202
- h('tbody', [
203
- [
204
- isPrint
205
- ? _e()
206
- : h('tr', [
207
- h('td', getI18n('vxe.export.expName')),
208
- h('td', [
209
- h('vxe-input', {
210
- ref: 'filename',
211
- props: {
212
- value: defaultOptions.filename,
213
- type: 'text',
214
- clearable: true,
215
- placeholder: getI18n('vxe.export.expNamePlaceholder')
216
- },
217
- on: {
218
- modelValue (value: any) {
219
- defaultOptions.filename = value
220
- }
221
- }
222
- })
223
- ])
224
- ]),
225
- isPrint
226
- ? _e()
227
- : h('tr', [
228
- h('td', getI18n('vxe.export.expType')),
229
- h('td', [
230
- h('vxe-select', {
231
- props: {
232
- value: defaultOptions.type,
233
- options: storeData.typeList
234
- },
235
- on: {
236
- modelValue (value: any) {
237
- defaultOptions.type = value
238
- }
239
- }
240
- })
241
- ])
242
- ]),
243
- isPrint || showSheet
244
- ? h('tr', [
245
- h('td', getI18n('vxe.export.expSheetName')),
246
- h('td', [
247
- h('vxe-input', {
248
- ref: 'sheetname',
249
- props: {
250
- value: defaultOptions.sheetName,
251
- type: 'text',
252
- clearable: true,
253
- placeholder: getI18n('vxe.export.expSheetNamePlaceholder')
254
- },
255
- on: {
256
- modelValue (value: any) {
257
- defaultOptions.sheetName = value
258
- }
259
- }
260
- })
261
- ])
262
- ])
263
- : _e(),
264
- h('tr', [
265
- h('td', getI18n('vxe.export.expMode')),
266
- h('td', [
267
- h('vxe-select', {
268
- props: {
269
- value: defaultOptions.mode,
270
- options: storeData.modeList
271
- },
272
- on: {
273
- modelValue (value: any) {
274
- defaultOptions.mode = value
275
- }
276
- }
277
- })
278
- ])
279
- ]),
280
- h('tr', [
281
- h('td', [getI18n('vxe.export.expColumn')]),
282
- h('td', [
283
- h('div', {
284
- class: 'vxe-table-export--panel-column'
285
- }, [
286
- h('ul', {
287
- class: 'vxe-table-export--panel-column-header'
288
- }, [
289
- h('li', {
290
- class: ['vxe-table-export--panel-column-option', {
291
- 'is--checked': isAllChecked,
292
- 'is--indeterminate': isAllIndeterminate
293
- }],
294
- attrs: {
295
- title: getI18n('vxe.table.allTitle')
296
- },
297
- on: {
298
- click: this.allColumnEvent
299
- }
300
- }, [
301
- h('span', {
302
- class: ['vxe-checkbox--icon', isAllIndeterminate ? getIcon().TABLE_CHECKBOX_INDETERMINATE : (isAllChecked ? getIcon().TABLE_CHECKBOX_CHECKED : getIcon().TABLE_CHECKBOX_UNCHECKED)]
303
- }),
304
- h('span', {
305
- class: 'vxe-checkbox--label'
306
- }, getI18n('vxe.export.expCurrentColumn'))
307
- ])
308
- ]),
309
- h('ul', {
310
- class: 'vxe-table-export--panel-column-body'
311
- }, cols)
312
- ])
313
- ])
314
- ]),
315
- h('tr', [
316
- h('td', getI18n('vxe.export.expOpts')),
317
- parameterSlot
318
- ? h('td', [
319
- h('div', {
320
- class: 'vxe-table-export--panel-option-row'
321
- }, $xeTable.callSlot(parameterSlot, params, h))
322
- ])
323
- : h('td', [
324
- h('div', {
325
- class: 'vxe-table-export--panel-option-row'
326
- }, [
327
- h('vxe-checkbox', {
328
- props: {
329
- value: hasEmptyData || isHeader,
330
- disabled: hasEmptyData,
331
- title: getI18n('vxe.export.expHeaderTitle'),
332
- content: getI18n('vxe.export.expOptHeader')
333
- },
334
- on: {
335
- input (value: any) {
336
- defaultOptions.isHeader = value
337
- }
338
- }
339
- }),
340
- h('vxe-checkbox', {
341
- props: {
342
- value: isHeader ? defaultOptions.isTitle : false,
343
- disabled: !isHeader,
344
- title: getI18n('vxe.export.expTitleTitle'),
345
- content: getI18n('vxe.export.expOptTitle')
346
- },
347
- on: {
348
- input (value: any) {
349
- defaultOptions.isTitle = value
350
- }
351
- }
352
- }),
353
- h('vxe-checkbox', {
354
- props: {
355
- value: isHeader && hasColgroup && supportMerge ? defaultOptions.isColgroup : false,
356
- disabled: !isHeader || !hasColgroup || !supportMerge,
357
- title: getI18n('vxe.export.expColgroupTitle'),
358
- content: getI18n('vxe.export.expOptColgroup')
359
- },
360
- on: {
361
- input (value: any) {
362
- defaultOptions.isColgroup = value
363
- }
364
- }
365
- })
366
- ]),
367
- h('div', {
368
- class: 'vxe-table-export--panel-option-row'
369
- }, [
370
- h('vxe-checkbox', {
371
- props: {
372
- value: hasEmptyData ? false : defaultOptions.original,
373
- disabled: hasEmptyData,
374
- title: getI18n('vxe.export.expOriginalTitle'),
375
- content: getI18n('vxe.export.expOptOriginal')
376
- },
377
- on: {
378
- input (value: any) {
379
- defaultOptions.original = value
380
- }
381
- }
382
- }),
383
- h('vxe-checkbox', {
384
- props: {
385
- value: hasMerge && supportMerge && checkedAll ? defaultOptions.isMerge : false,
386
- disabled: hasEmptyData || !hasMerge || !supportMerge || !checkedAll,
387
- title: getI18n('vxe.export.expMergeTitle'),
388
- content: getI18n('vxe.export.expOptMerge')
389
- },
390
- on: {
391
- input (value: any) {
392
- defaultOptions.isMerge = value
393
- }
394
- }
395
- }),
396
- isPrint
397
- ? _e()
398
- : h('vxe-checkbox', {
399
- props: {
400
- value: supportStyle ? defaultOptions.useStyle : false,
401
- disabled: !supportStyle,
402
- title: getI18n('vxe.export.expUseStyleTitle'),
403
- content: getI18n('vxe.export.expOptUseStyle')
404
- },
405
- on: {
406
- input (value: any) {
407
- defaultOptions.useStyle = value
408
- }
409
- }
410
- }),
411
- h('vxe-checkbox', {
412
- props: {
413
- value: hasTree ? defaultOptions.isAllExpand : false,
414
- disabled: hasEmptyData || !hasTree,
415
- title: getI18n('vxe.export.expAllExpandTitle'),
416
- content: getI18n('vxe.export.expOptAllExpand')
417
- },
418
- on: {
419
- input (value: any) {
420
- defaultOptions.isAllExpand = value
421
- }
422
- }
423
- })
424
- ]),
425
-
426
- h('div', {
427
- class: 'vxe-table-export--panel-option-row'
428
- }, [
429
- h('vxe-checkbox', {
430
- props: {
431
- value: defaultOptions.isFooter,
432
- disabled: !storeData.hasFooter,
433
- title: getI18n('vxe.export.expFooterTitle'),
434
- content: getI18n('vxe.export.expOptFooter')
435
- },
436
- on: {
437
- input (value: any) {
438
- defaultOptions.isFooter = value
439
- }
440
- }
441
- })
442
- ])
443
- ])
444
- ])
445
- ]
446
- ])
447
- ])
448
- ]),
449
- bottomSlot
450
- ? h('div', {
451
- class: 'vxe-table-export--panel-bottom'
452
- }, $xeTable.callSlot(bottomSlot, params, h))
453
- : renderEmptyElement(this)
454
- ])
455
- },
456
- footer: () => {
457
- const params = {
458
- $table: $xeTable,
459
- $grid: $xeGrid,
460
- $gantt: $xeGantt,
461
- options: defaultOptions,
462
- columns,
463
- params: defaultOptions.params as any
464
- }
465
- return h('div', {
466
- class: 'vxe-table-export--panel-footer'
467
- }, footerSlot
468
- ? $xeTable.callSlot(footerSlot, params, h)
469
- : [
470
- h('div', {
471
- class: 'vxe-table-export--panel-btns'
472
- }, [
473
- h('vxe-button', {
474
- props: {
475
- content: getI18n('vxe.export.expCancel')
476
- },
477
- on: {
478
- click: this.cancelEvent
479
- }
480
- }),
481
- h('vxe-button', {
482
- ref: 'confirmBtn',
483
- props: {
484
- status: 'primary',
485
- content: getI18n(isPrint ? 'vxe.export.expPrint' : 'vxe.export.expConfirm')
486
- },
487
- on: {
488
- click: this.confirmEvent
489
- }
490
- })
491
- ])
492
- ])
493
- }
494
- }
495
- })
496
- },
497
112
  methods: {
498
113
  changeOption (column: any) {
114
+ const $xeExportPanel = this
115
+
499
116
  const isChecked = !column.checked
500
117
  XEUtils.eachTree([column], (item) => {
501
118
  item.checked = isChecked
502
119
  item.halfChecked = false
503
120
  })
504
- this.handleOptionCheck(column)
505
- this.checkStatus()
121
+ $xeExportPanel.handleOptionCheck(column)
122
+ $xeExportPanel.checkStatus()
506
123
  },
507
124
  handleOptionCheck (column: any) {
508
- const matchObj = XEUtils.findTree(this.storeData.columns as any[], item => item === column)
125
+ const $xeExportPanel = this
126
+ const props = $xeExportPanel
127
+
128
+ const { storeData } = props
129
+ const matchObj = XEUtils.findTree(storeData.columns as any[], item => item === column)
509
130
  if (matchObj && matchObj.parent) {
510
131
  const { parent } = matchObj
511
132
  if (parent.children && parent.children.length) {
512
133
  parent.checked = parent.children.every((column: any) => column.checked)
513
134
  parent.halfChecked = !parent.checked && parent.children.some((column: any) => column.checked || column.halfChecked)
514
- this.handleOptionCheck(parent)
135
+ $xeExportPanel.handleOptionCheck(parent)
515
136
  }
516
137
  }
517
138
  },
518
139
  checkStatus () {
519
- const columns = this.storeData.columns
520
- this.isAll = columns.every((column: any) => column.disabled || column.checked)
521
- this.isIndeterminate = !this.isAll && columns.some((column: any) => !column.disabled && (column.checked || column.halfChecked))
140
+ const $xeExportPanel = this
141
+ const props = $xeExportPanel
142
+ const reactData = $xeExportPanel.reactData
143
+
144
+ const { storeData } = props
145
+ const columns = storeData.columns
146
+ reactData.isAll = columns.every((column: any) => column.disabled || column.checked)
147
+ reactData.isIndeterminate = !reactData.isAll && columns.some((column: any) => !column.disabled && (column.checked || column.halfChecked))
522
148
  },
523
149
  allColumnEvent () {
524
- const isAll = !this.isAll
525
- XEUtils.eachTree(this.storeData.columns, column => {
150
+ const $xeExportPanel = this
151
+ const props = $xeExportPanel
152
+ const reactData = $xeExportPanel.reactData
153
+
154
+ const { storeData } = props
155
+ const isAll = !reactData.isAll
156
+ XEUtils.eachTree(storeData.columns, column => {
526
157
  if (!column.disabled) {
527
158
  column.checked = isAll
528
159
  column.halfChecked = false
529
160
  }
530
161
  })
531
- this.isAll = isAll
532
- this.checkStatus()
162
+ reactData.isAll = isAll
163
+ $xeExportPanel.checkStatus()
533
164
  },
534
165
  showEvent () {
535
- this.$nextTick(() => {
536
- const { $refs } = this
537
- const targetElem = $refs.filename || $refs.sheetname || $refs.confirmBtn
166
+ const $xeExportPanel = this
167
+
168
+ $xeExportPanel.$nextTick(() => {
169
+ const targetElem = ($xeExportPanel.$refs.filename || $xeExportPanel.$refs.sheetname || $xeExportPanel.$refs.confirmBtn) as HTMLInputElement
538
170
  if (targetElem) {
539
171
  targetElem.focus()
540
172
  }
541
173
  })
542
- this.checkStatus()
174
+ $xeExportPanel.checkStatus()
543
175
  },
544
- getExportOption () {
545
- const { checkedAll, storeData, defaultOptions, supportMerge } = this
176
+ getExportOption (): VxeTableDefines.ExportParamsObj {
177
+ const $xeExportPanel = this
178
+ const props = $xeExportPanel
179
+
180
+ const { storeData, defaultOptions } = props
546
181
  const { hasMerge, columns } = storeData
182
+ const checkedAll = $xeExportPanel.computeCheckedAll
183
+ const supportMerge = $xeExportPanel.computeSupportMerge
547
184
  const expColumns = XEUtils.searchTree(columns, column => column.checked, { children: 'children', mapChildren: 'childNodes', original: true })
548
185
  return Object.assign({}, defaultOptions, {
549
186
  columns: expColumns,
@@ -551,32 +188,471 @@ export default {
551
188
  })
552
189
  },
553
190
  cancelEvent () {
554
- this.storeData.visible = false
191
+ const $xeExportPanel = this
192
+ const props = $xeExportPanel
193
+
194
+ const { storeData } = props
195
+ storeData.visible = false
555
196
  },
556
- confirmEvent (evnt: any) {
557
- if (this.storeData.isPrint) {
558
- this.printEvent(evnt)
197
+ confirmEvent () {
198
+ const $xeExportPanel = this
199
+ const props = $xeExportPanel
200
+
201
+ const { storeData } = props
202
+ if (storeData.isPrint) {
203
+ $xeExportPanel.printEvent()
559
204
  } else {
560
- this.exportEvent(evnt)
205
+ $xeExportPanel.exportEvent()
561
206
  }
562
207
  },
563
208
  printEvent () {
564
- const $xeTable = this.$parent as VxeTableConstructor & VxeTablePrivateMethods
209
+ const $xeExportPanel = this
210
+ const props = $xeExportPanel
211
+ const $xeTable = $xeExportPanel.$xeTable as VxeTableConstructor & VxeTablePrivateMethods
565
212
 
566
- this.storeData.visible = false
567
- $xeTable.print(Object.assign({}, $xeTable.printOpts, this.getExportOption()))
213
+ const { storeData } = props
214
+ storeData.visible = false
215
+ $xeTable.print(Object.assign({}, $xeTable.printOpts, $xeExportPanel.getExportOption()))
568
216
  },
569
217
  exportEvent () {
570
- const $xeTable = this.$xeTable
571
- const exportOpts = $xeTable.exportOpts
218
+ const $xeExportPanel = this
219
+ const props = $xeExportPanel
220
+ const reactData = $xeExportPanel.reactData
221
+ const $xeTable = $xeExportPanel.$xeTable as VxeTableConstructor & VxeTablePrivateMethods
572
222
 
573
- this.loading = true
574
- $xeTable.exportData(Object.assign({}, exportOpts, this.getExportOption())).then(() => {
575
- this.loading = false
576
- this.storeData.visible = false
223
+ const { storeData } = props
224
+ const exportOpts = $xeTable.exportOpts
225
+ reactData.loading = true
226
+ $xeTable.exportData(Object.assign({}, exportOpts, $xeExportPanel.getExportOption())).then(() => {
227
+ reactData.loading = false
228
+ storeData.visible = false
577
229
  }).catch(() => {
578
- this.loading = false
230
+ reactData.loading = false
231
+ })
232
+ },
233
+
234
+ renderVN (h: CreateElement): VNode {
235
+ const $xeExportPanel = this
236
+ const props = $xeExportPanel
237
+ const reactData = $xeExportPanel.reactData
238
+
239
+ const $xeTable = $xeExportPanel.$xeTable as VxeTableConstructor & VxeTablePrivateMethods
240
+ const $xeGrid = $xeTable.$xeGrid
241
+ const $xeGantt = $xeTable.$xeGantt
242
+
243
+ const { defaultOptions, storeData } = props
244
+ const { isAll: isAllChecked, isIndeterminate: isAllIndeterminate } = reactData
245
+ const { hasTree, hasMerge, isPrint, hasColgroup, columns } = storeData
246
+ const { isHeader } = defaultOptions
247
+ const colVNs: VNode[] = []
248
+ const checkedAll = $xeExportPanel.computeCheckedAll
249
+ const showSheet = $xeExportPanel.computeShowSheet
250
+ const supportMerge = $xeExportPanel.computeSupportMerge
251
+ const supportStyle = $xeExportPanel.computeSupportStyle
252
+ // const supportGroup = $xeExportPanel.computeSupportGroup
253
+ const slots = defaultOptions.slots || {}
254
+ const topSlot = slots.top
255
+ const bottomSlot = slots.bottom
256
+ const defaultSlot = slots.default
257
+ const footerSlot = slots.footer
258
+ const parameterSlot = slots.parameter
259
+ XEUtils.eachTree(columns, column => {
260
+ const colTitle = formatText(column.getTitle(), 1)
261
+ const isColGroup = column.children && column.children.length
262
+ const isChecked = column.checked
263
+ const indeterminate = column.halfChecked
264
+ const isHtml = column.type === 'html'
265
+ colVNs.push(
266
+ h('li', {
267
+ class: ['vxe-table-export--panel-column-option', `level--${column.level}`, {
268
+ 'is--group': isColGroup,
269
+ 'is--checked': isChecked,
270
+ 'is--indeterminate': indeterminate,
271
+ 'is--disabled': column.disabled
272
+ }],
273
+ attrs: {
274
+ title: colTitle
275
+ },
276
+ on: {
277
+ click: () => {
278
+ if (!column.disabled) {
279
+ $xeExportPanel.changeOption(column)
280
+ }
281
+ }
282
+ }
283
+ }, [
284
+ h('span', {
285
+ class: ['vxe-checkbox--icon', indeterminate ? getIcon().TABLE_CHECKBOX_INDETERMINATE : (isChecked ? getIcon().TABLE_CHECKBOX_CHECKED : getIcon().TABLE_CHECKBOX_UNCHECKED)]
286
+ }),
287
+ isHtml
288
+ ? h('span', {
289
+ key: '1',
290
+ class: 'vxe-checkbox--label',
291
+ domProps: {
292
+ innerHTML: colTitle
293
+ }
294
+ })
295
+ : h('span', {
296
+ key: '0',
297
+ class: 'vxe-checkbox--label'
298
+ }, colTitle)
299
+ ])
300
+ )
301
+ })
302
+ return h('vxe-modal', {
303
+ ref: 'modal',
304
+ props: {
305
+ id: 'VXE_EXPORT_MODAL',
306
+ value: storeData.visible,
307
+ title: getI18n(isPrint ? 'vxe.export.printTitle' : 'vxe.export.expTitle'),
308
+ width: 660,
309
+ minWidth: 500,
310
+ minHeight: 400,
311
+ mask: true,
312
+ lockView: true,
313
+ showFooter: true,
314
+ escClosable: true,
315
+ maskClosable: true,
316
+ showMaximize: true,
317
+ resize: true,
318
+ loading: reactData.loading
319
+ },
320
+ on: {
321
+ input (value: any) {
322
+ storeData.visible = value
323
+ },
324
+ show: $xeExportPanel.showEvent
325
+ },
326
+ scopedSlots: {
327
+ default (): VNode {
328
+ const params = {
329
+ $table: $xeTable,
330
+ $grid: $xeGrid,
331
+ $gantt: $xeGantt,
332
+ options: defaultOptions,
333
+ columns,
334
+ params: defaultOptions.params as any
335
+ }
336
+ const hasEmptyData = defaultOptions.mode === 'empty'
337
+
338
+ return h('div', {
339
+ class: 'vxe-table-export--panel'
340
+ }, [
341
+ topSlot
342
+ ? h('div', {
343
+ class: 'vxe-table-export--panel-top'
344
+ }, $xeTable.callSlot(topSlot, params, h))
345
+ : renderEmptyElement($xeTable),
346
+ h('div', {
347
+ class: 'vxe-table-export--panel-body'
348
+ }, defaultSlot
349
+ ? $xeTable.callSlot(defaultSlot, params, h)
350
+ : [
351
+ h('table', {
352
+ attrs: {
353
+ class: 'vxe-table-export--panel-table',
354
+ cellspacing: 0,
355
+ cellpadding: 0,
356
+ border: 0
357
+ }
358
+ }, [
359
+ h('tbody', [
360
+ [
361
+ isPrint
362
+ ? renderEmptyElement($xeTable)
363
+ : h('tr', [
364
+ h('td', getI18n('vxe.export.expName')),
365
+ h('td', [
366
+ h('vxe-input', {
367
+ ref: 'filename',
368
+ props: {
369
+ value: defaultOptions.filename,
370
+ type: 'text',
371
+ clearable: true,
372
+ placeholder: getI18n('vxe.export.expNamePlaceholder')
373
+ },
374
+ on: {
375
+ modelValue (value: any) {
376
+ defaultOptions.filename = value
377
+ }
378
+ }
379
+ })
380
+ ])
381
+ ]),
382
+ isPrint
383
+ ? renderEmptyElement($xeTable)
384
+ : h('tr', [
385
+ h('td', getI18n('vxe.export.expType')),
386
+ h('td', [
387
+ h('vxe-select', {
388
+ props: {
389
+ value: defaultOptions.type,
390
+ options: storeData.typeList
391
+ },
392
+ on: {
393
+ modelValue (value: any) {
394
+ defaultOptions.type = value
395
+ }
396
+ }
397
+ })
398
+ ])
399
+ ]),
400
+ isPrint || showSheet
401
+ ? h('tr', [
402
+ h('td', getI18n('vxe.export.expSheetName')),
403
+ h('td', [
404
+ h('vxe-input', {
405
+ ref: 'sheetname',
406
+ props: {
407
+ value: defaultOptions.sheetName,
408
+ type: 'text',
409
+ clearable: true,
410
+ placeholder: getI18n('vxe.export.expSheetNamePlaceholder')
411
+ },
412
+ on: {
413
+ modelValue (value: any) {
414
+ defaultOptions.sheetName = value
415
+ }
416
+ }
417
+ })
418
+ ])
419
+ ])
420
+ : renderEmptyElement($xeTable),
421
+ h('tr', [
422
+ h('td', getI18n('vxe.export.expMode')),
423
+ h('td', [
424
+ h('vxe-select', {
425
+ props: {
426
+ value: defaultOptions.mode,
427
+ options: storeData.modeList
428
+ },
429
+ on: {
430
+ modelValue (value: any) {
431
+ defaultOptions.mode = value
432
+ }
433
+ }
434
+ })
435
+ ])
436
+ ]),
437
+ h('tr', [
438
+ h('td', [getI18n('vxe.export.expColumn')]),
439
+ h('td', [
440
+ h('div', {
441
+ class: 'vxe-table-export--panel-column'
442
+ }, [
443
+ h('ul', {
444
+ class: 'vxe-table-export--panel-column-header'
445
+ }, [
446
+ h('li', {
447
+ class: ['vxe-table-export--panel-column-option', {
448
+ 'is--checked': isAllChecked,
449
+ 'is--indeterminate': isAllIndeterminate
450
+ }],
451
+ attrs: {
452
+ title: getI18n('vxe.table.allTitle')
453
+ },
454
+ on: {
455
+ click: $xeExportPanel.allColumnEvent
456
+ }
457
+ }, [
458
+ h('span', {
459
+ class: ['vxe-checkbox--icon', isAllIndeterminate ? getIcon().TABLE_CHECKBOX_INDETERMINATE : (isAllChecked ? getIcon().TABLE_CHECKBOX_CHECKED : getIcon().TABLE_CHECKBOX_UNCHECKED)]
460
+ }),
461
+ h('span', {
462
+ class: 'vxe-checkbox--label'
463
+ }, getI18n('vxe.export.expCurrentColumn'))
464
+ ])
465
+ ]),
466
+ h('ul', {
467
+ class: 'vxe-table-export--panel-column-body'
468
+ }, colVNs)
469
+ ])
470
+ ])
471
+ ]),
472
+ h('tr', [
473
+ h('td', getI18n('vxe.export.expOpts')),
474
+ parameterSlot
475
+ ? h('td', [
476
+ h('div', {
477
+ class: 'vxe-table-export--panel-option-row'
478
+ }, $xeTable.callSlot(parameterSlot, params, h))
479
+ ])
480
+ : h('td', [
481
+ h('div', {
482
+ class: 'vxe-table-export--panel-option-row'
483
+ }, [
484
+ h('vxe-checkbox', {
485
+ props: {
486
+ value: hasEmptyData || isHeader,
487
+ disabled: hasEmptyData,
488
+ title: getI18n('vxe.export.expHeaderTitle'),
489
+ content: getI18n('vxe.export.expOptHeader')
490
+ },
491
+ on: {
492
+ input (value: any) {
493
+ defaultOptions.isHeader = value
494
+ }
495
+ }
496
+ }),
497
+ h('vxe-checkbox', {
498
+ props: {
499
+ value: isHeader ? defaultOptions.isTitle : false,
500
+ disabled: !isHeader,
501
+ title: getI18n('vxe.export.expTitleTitle'),
502
+ content: getI18n('vxe.export.expOptTitle')
503
+ },
504
+ on: {
505
+ input (value: any) {
506
+ defaultOptions.isTitle = value
507
+ }
508
+ }
509
+ }),
510
+ h('vxe-checkbox', {
511
+ props: {
512
+ value: isHeader && hasColgroup && supportMerge ? defaultOptions.isColgroup : false,
513
+ disabled: !isHeader || !hasColgroup || !supportMerge,
514
+ title: getI18n('vxe.export.expColgroupTitle'),
515
+ content: getI18n('vxe.export.expOptColgroup')
516
+ },
517
+ on: {
518
+ input (value: any) {
519
+ defaultOptions.isColgroup = value
520
+ }
521
+ }
522
+ })
523
+ ]),
524
+ h('div', {
525
+ class: 'vxe-table-export--panel-option-row'
526
+ }, [
527
+ h('vxe-checkbox', {
528
+ props: {
529
+ value: hasEmptyData ? false : defaultOptions.original,
530
+ disabled: hasEmptyData,
531
+ title: getI18n('vxe.export.expOriginalTitle'),
532
+ content: getI18n('vxe.export.expOptOriginal')
533
+ },
534
+ on: {
535
+ input (value: any) {
536
+ defaultOptions.original = value
537
+ }
538
+ }
539
+ }),
540
+ h('vxe-checkbox', {
541
+ props: {
542
+ value: hasMerge && supportMerge && checkedAll ? defaultOptions.isMerge : false,
543
+ disabled: hasEmptyData || !hasMerge || !supportMerge || !checkedAll,
544
+ title: getI18n('vxe.export.expMergeTitle'),
545
+ content: getI18n('vxe.export.expOptMerge')
546
+ },
547
+ on: {
548
+ input (value: any) {
549
+ defaultOptions.isMerge = value
550
+ }
551
+ }
552
+ }),
553
+ isPrint
554
+ ? renderEmptyElement($xeTable)
555
+ : h('vxe-checkbox', {
556
+ props: {
557
+ value: supportStyle ? defaultOptions.useStyle : false,
558
+ disabled: !supportStyle,
559
+ title: getI18n('vxe.export.expUseStyleTitle'),
560
+ content: getI18n('vxe.export.expOptUseStyle')
561
+ },
562
+ on: {
563
+ input (value: any) {
564
+ defaultOptions.useStyle = value
565
+ }
566
+ }
567
+ }),
568
+ h('vxe-checkbox', {
569
+ props: {
570
+ value: hasTree ? defaultOptions.isAllExpand : false,
571
+ disabled: hasEmptyData || !hasTree,
572
+ title: getI18n('vxe.export.expAllExpandTitle'),
573
+ content: getI18n('vxe.export.expOptAllExpand')
574
+ },
575
+ on: {
576
+ input (value: any) {
577
+ defaultOptions.isAllExpand = value
578
+ }
579
+ }
580
+ })
581
+ ]),
582
+
583
+ h('div', {
584
+ class: 'vxe-table-export--panel-option-row'
585
+ }, [
586
+ h('vxe-checkbox', {
587
+ props: {
588
+ value: defaultOptions.isFooter,
589
+ disabled: !storeData.hasFooter,
590
+ title: getI18n('vxe.export.expFooterTitle'),
591
+ content: getI18n('vxe.export.expOptFooter')
592
+ },
593
+ on: {
594
+ input (value: any) {
595
+ defaultOptions.isFooter = value
596
+ }
597
+ }
598
+ })
599
+ ])
600
+ ])
601
+ ])
602
+ ]
603
+ ])
604
+ ])
605
+ ]),
606
+ bottomSlot
607
+ ? h('div', {
608
+ class: 'vxe-table-export--panel-bottom'
609
+ }, $xeTable.callSlot(bottomSlot, params, h))
610
+ : renderEmptyElement($xeTable)
611
+ ])
612
+ },
613
+ footer (): VNode {
614
+ const params = {
615
+ $table: $xeTable,
616
+ $grid: $xeGrid,
617
+ $gantt: $xeGantt,
618
+ options: defaultOptions,
619
+ columns,
620
+ params: defaultOptions.params as any
621
+ }
622
+ return h('div', {
623
+ class: 'vxe-table-export--panel-footer'
624
+ }, footerSlot
625
+ ? $xeTable.callSlot(footerSlot, params, h)
626
+ : [
627
+ h('div', {
628
+ class: 'vxe-table-export--panel-btns'
629
+ }, [
630
+ h('vxe-button', {
631
+ props: {
632
+ content: getI18n('vxe.export.expCancel')
633
+ },
634
+ on: {
635
+ click: $xeExportPanel.cancelEvent
636
+ }
637
+ }),
638
+ h('vxe-button', {
639
+ ref: 'confirmBtn',
640
+ props: {
641
+ status: 'primary',
642
+ content: getI18n(isPrint ? 'vxe.export.expPrint' : 'vxe.export.expConfirm')
643
+ },
644
+ on: {
645
+ click: $xeExportPanel.confirmEvent
646
+ }
647
+ })
648
+ ])
649
+ ])
650
+ }
651
+ }
579
652
  })
580
653
  }
581
- } as any
582
- }
654
+ },
655
+ render (h: CreateElement) {
656
+ return (this as any).renderVN(h)
657
+ }
658
+ }) /* define-vxe-component end */