doway-coms 3.2.2 → 3.2.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "doway-coms",
3
- "version": "3.2.2",
3
+ "version": "3.2.4",
4
4
  "description": "doway组件库",
5
5
  "author": "dowaysoft",
6
6
  "main": "packages/index.js",
@@ -25,7 +25,7 @@
25
25
  "vue-router": "3.6.5",
26
26
  "vuedraggable": "^2.24.3",
27
27
  "vuex": "3.6.2",
28
- "doway-vxe-table": "3.9.21-beta1",
28
+ "vxe-table": "3.9.21",
29
29
  "vxe-pc-ui":"3.3.83",
30
30
  "xe-clipboard": "1.10.2",
31
31
  "xe-utils": "3.5.4"
package/packages/index.js CHANGED
@@ -68,7 +68,6 @@ const components = [
68
68
  import 'vxe-table/lib/style.css'
69
69
  import VXETable from 'vxe-table'
70
70
 
71
-
72
71
  import VxeUI from 'vxe-pc-ui'
73
72
  import 'vxe-pc-ui/lib/style.css'
74
73
 
@@ -0,0 +1,873 @@
1
+ import { CreateElement } from 'vue'
2
+ import XEUtils from 'xe-utils'
3
+ import { VxeUI } from '../../ui'
4
+ import { getFuncText, isEnableConf, formatText, eqEmptyValue } from '../../ui/src/utils'
5
+ import { updateCellTitle } from '../../ui/src/dom'
6
+ import { createColumn, getRowid } from './util'
7
+ import { getSlotVNs } from '../../ui/src/vn'
8
+
9
+ const { getI18n, getIcon, renderer, formats } = VxeUI
10
+
11
+ function renderTitlePrefixIcon (h: CreateElement, params: any) {
12
+ const { $table, column } = params
13
+ const titlePrefix = column.titlePrefix || column.titleHelp
14
+ return titlePrefix
15
+ ? [
16
+ h('i', {
17
+ class: ['vxe-cell-title-prefix-icon', titlePrefix.icon || getIcon().TABLE_TITLE_PREFIX],
18
+ on: {
19
+ mouseenter (evnt: any) {
20
+ $table.triggerHeaderTitleEvent(evnt, titlePrefix, params)
21
+ },
22
+ mouseleave (evnt: any) {
23
+ $table.handleTargetLeaveEvent(evnt)
24
+ }
25
+ }
26
+ })
27
+ ]
28
+ : []
29
+ }
30
+
31
+ function renderTitleSuffixIcon (h: CreateElement, params: any) {
32
+ const { $table, column } = params
33
+ const titleSuffix = column.titleSuffix
34
+ return titleSuffix
35
+ ? [
36
+ h('i', {
37
+ class: ['vxe-cell-title-suffix-icon', titleSuffix.icon || getIcon().TABLE_TITLE_SUFFIX],
38
+ on: {
39
+ mouseenter (evnt: any) {
40
+ $table.triggerHeaderTitleEvent(evnt, titleSuffix, params)
41
+ },
42
+ mouseleave (evnt: any) {
43
+ $table.handleTargetLeaveEvent(evnt)
44
+ }
45
+ }
46
+ })
47
+ ]
48
+ : []
49
+ }
50
+
51
+ function renderTitleContent (h: CreateElement, params: any, content: any) {
52
+ const { $table, column } = params
53
+ const { type, showHeaderOverflow } = column
54
+ const { showHeaderOverflow: allColumnHeaderOverflow, tooltipOpts } = $table
55
+ const showAllTip = tooltipOpts.showAll || tooltipOpts.enabled
56
+ const headOverflow = XEUtils.isUndefined(showHeaderOverflow) || XEUtils.isNull(showHeaderOverflow) ? allColumnHeaderOverflow : showHeaderOverflow
57
+ const showTitle = headOverflow === 'title'
58
+ const showTooltip = headOverflow === true || headOverflow === 'tooltip'
59
+ const ons: any = {}
60
+ if (showTitle || showTooltip || showAllTip) {
61
+ ons.mouseenter = (evnt: any) => {
62
+ if ($table._isResize) {
63
+ return
64
+ }
65
+ if (showTitle) {
66
+ updateCellTitle(evnt.currentTarget, column)
67
+ } else if (showTooltip || showAllTip) {
68
+ $table.triggerHeaderTooltipEvent(evnt, params)
69
+ }
70
+ }
71
+ }
72
+ if (showTooltip || showAllTip) {
73
+ ons.mouseleave = (evnt: any) => {
74
+ if ($table._isResize) {
75
+ return
76
+ }
77
+ if (showTooltip || showAllTip) {
78
+ $table.handleTargetLeaveEvent(evnt)
79
+ }
80
+ }
81
+ }
82
+ return [
83
+ type === 'html' && XEUtils.isString(content)
84
+ ? h('span', {
85
+ class: 'vxe-cell--title',
86
+ domProps: {
87
+ innerHTML: content
88
+ },
89
+ on: ons
90
+ })
91
+ : h('span', {
92
+ class: 'vxe-cell--title',
93
+ on: ons
94
+ }, getSlotVNs(content))
95
+ ]
96
+ }
97
+
98
+ function formatFooterLabel (footerFormatter: any, params: any) {
99
+ if (XEUtils.isFunction(footerFormatter)) {
100
+ return footerFormatter(params)
101
+ }
102
+ const isArr = XEUtils.isArray(footerFormatter)
103
+ const gFormatOpts = isArr ? formats.get(footerFormatter[0]) : formats.get(footerFormatter)
104
+ const footerFormatMethod = gFormatOpts ? gFormatOpts.tableFooterCellFormatMethod : null
105
+ if (footerFormatMethod) {
106
+ return isArr ? footerFormatMethod(params, ...footerFormatter.slice(1)) : footerFormatMethod(params)
107
+ }
108
+ return ''
109
+ }
110
+
111
+ function getFooterContent (h: CreateElement, params: any) {
112
+ const { $table, column, _columnIndex, row, items } = params
113
+ const { slots, editRender, cellRender, footerFormatter } = column
114
+ const renderOpts = editRender || cellRender
115
+ if (slots && slots.footer) {
116
+ return $table.callSlot(slots.footer, params, h)
117
+ }
118
+ if (renderOpts) {
119
+ const compConf = renderer.get(renderOpts.name)
120
+ const rtFooter = compConf ? (compConf.renderTableFooter || compConf.renderFooter) : null
121
+ if (rtFooter) {
122
+ return getSlotVNs(rtFooter.call($table, h, renderOpts, params))
123
+ }
124
+ }
125
+ let itemValue = ''
126
+ // 兼容老模式
127
+ if (XEUtils.isArray(items)) {
128
+ itemValue = items[_columnIndex]
129
+ return [
130
+ footerFormatter
131
+ ? formatFooterLabel(footerFormatter, {
132
+ itemValue,
133
+ column,
134
+ row,
135
+ items,
136
+ _columnIndex
137
+ })
138
+ : formatText(itemValue, 1)
139
+ ]
140
+ }
141
+ itemValue = XEUtils.get(row, column.field)
142
+ return [
143
+ footerFormatter
144
+ ? formatFooterLabel(footerFormatter, {
145
+ itemValue,
146
+ column,
147
+ row,
148
+ items,
149
+ _columnIndex
150
+ })
151
+ : formatText(itemValue, 1)
152
+ ]
153
+ }
154
+
155
+ function getDefaultCellLabel (params: any) {
156
+ const { $table, row, column } = params
157
+ return formatText($table.getCellLabel(row, column), 1)
158
+ }
159
+
160
+ export const Cell = {
161
+ createColumn ($xetable: any, _vm: any) {
162
+ const { type, sortable, remoteSort, filters, editRender, treeNode } = _vm
163
+ const { editConfig, editOpts, checkboxOpts } = $xetable
164
+ const renMaps: any = {
165
+ renderHeader: this.renderDefaultHeader,
166
+ renderCell: treeNode ? this.renderTreeCell : this.renderDefaultCell,
167
+ renderFooter: this.renderDefaultFooter
168
+ }
169
+ switch (type) {
170
+ case 'seq':
171
+ renMaps.renderHeader = this.renderSeqHeader
172
+ renMaps.renderCell = treeNode ? this.renderTreeIndexCell : this.renderSeqCell
173
+ break
174
+ case 'radio':
175
+ renMaps.renderHeader = this.renderRadioHeader
176
+ renMaps.renderCell = treeNode ? this.renderTreeRadioCell : this.renderRadioCell
177
+ break
178
+ case 'checkbox':
179
+ renMaps.renderHeader = this.renderCheckboxHeader
180
+ renMaps.renderCell = checkboxOpts.checkField ? (treeNode ? this.renderTreeSelectionCellByProp : this.renderCheckboxCellByProp) : (treeNode ? this.renderTreeSelectionCell : this.renderCheckboxCell)
181
+ break
182
+ case 'expand':
183
+ renMaps.renderCell = this.renderExpandCell
184
+ renMaps.renderData = this.renderExpandData
185
+ break
186
+ case 'html':
187
+ renMaps.renderCell = treeNode ? this.renderTreeHTMLCell : this.renderHTMLCell
188
+ if (filters && (sortable || remoteSort)) {
189
+ renMaps.renderHeader = this.renderSortAndFilterHeader
190
+ } else if (sortable || remoteSort) {
191
+ renMaps.renderHeader = this.renderSortHeader
192
+ } else if (filters) {
193
+ renMaps.renderHeader = this.renderFilterHeader
194
+ }
195
+ break
196
+ default:
197
+ if (editConfig && editRender) {
198
+ renMaps.renderHeader = this.renderEditHeader
199
+ renMaps.renderCell = editOpts.mode === 'cell' ? (treeNode ? this.renderTreeCellEdit : this.renderCellEdit) : (treeNode ? this.renderTreeRowEdit : this.renderRowEdit)
200
+ } else if (filters && (sortable || remoteSort)) {
201
+ renMaps.renderHeader = this.renderSortAndFilterHeader
202
+ } else if (sortable || remoteSort) {
203
+ renMaps.renderHeader = this.renderSortHeader
204
+ } else if (filters) {
205
+ renMaps.renderHeader = this.renderFilterHeader
206
+ }
207
+ }
208
+ return createColumn($xetable, _vm, renMaps)
209
+ },
210
+ /**
211
+ * 单元格
212
+ */
213
+ renderHeaderTitle (h: any, params: any) {
214
+ const { $table, column } = params
215
+ const { slots, editRender, cellRender } = column
216
+ const renderOpts = editRender || cellRender
217
+ if (slots && slots.header) {
218
+ return renderTitleContent(h, params, $table.callSlot(slots.header, params, h))
219
+ }
220
+ if (renderOpts) {
221
+ const compConf = renderer.get(renderOpts.name)
222
+ const rtHeader = compConf ? (compConf.renderTableHeader || compConf.renderHeader) : null
223
+ if (rtHeader) {
224
+ return getSlotVNs(renderTitleContent(h, params, rtHeader.call($table, h, renderOpts, params)))
225
+ }
226
+ }
227
+ return renderTitleContent(h, params, formatText(column.getTitle(), 1))
228
+ },
229
+ renderDefaultHeader (h: CreateElement, params: any) {
230
+ return renderTitlePrefixIcon(h, params).concat(Cell.renderHeaderTitle(h, params)).concat(renderTitleSuffixIcon(h, params))
231
+ },
232
+ renderDefaultCell (h: CreateElement, params: any) {
233
+ const { $table, row, column } = params
234
+ const { slots, editRender, cellRender } = column
235
+ const renderOpts = editRender || cellRender
236
+ if (slots && slots.default) {
237
+ return $table.callSlot(slots.default, params, h)
238
+ }
239
+ if (renderOpts) {
240
+ const compConf = renderer.get(renderOpts.name)
241
+ const rtDefault = compConf ? (compConf.renderTableDefault || compConf.renderDefault) : null
242
+ const rtCell = compConf ? (compConf.renderTableCell || compConf.renderCell) : null
243
+ const renderFn = editRender ? rtCell : rtDefault
244
+ if (renderFn) {
245
+ return getSlotVNs(renderFn.call($table, h, renderOpts, Object.assign({ $type: editRender ? 'edit' : 'cell' }, params)))
246
+ }
247
+ }
248
+ const cellValue = $table.getCellLabel(row, column)
249
+ const cellPlaceholder = editRender ? editRender.placeholder : ''
250
+ return [
251
+ h('span', {
252
+ class: 'vxe-cell--label'
253
+ }, [
254
+ // 如果设置占位符
255
+ editRender && eqEmptyValue(cellValue)
256
+ ? h('span', {
257
+ class: 'vxe-cell--placeholder'
258
+ }, formatText(getFuncText(cellPlaceholder), 1))
259
+ : h('span', formatText(cellValue, 1))
260
+ ])
261
+ ]
262
+ },
263
+ renderTreeCell (h: CreateElement, params: any) {
264
+ return Cell.renderTreeIcon(h, params, Cell.renderDefaultCell.call(this, h, params))
265
+ },
266
+ renderDefaultFooter (h: CreateElement, params: any) {
267
+ return [
268
+ h('span', {
269
+ class: 'vxe-cell--item'
270
+ }, getFooterContent(h, params))
271
+ ]
272
+ },
273
+
274
+ /**
275
+ * 树节点
276
+ */
277
+ renderTreeIcon (h: CreateElement, params: any, cellVNodes: any) {
278
+ const { $table, isHidden } = params
279
+ const { treeOpts, treeExpandedMaps, treeExpandLazyLoadedMaps, fullAllDataRowIdData } = $table
280
+ const { row, column, level } = params
281
+ const { slots } = column
282
+ const { indent, lazy, trigger, iconLoaded, showIcon, iconOpen, iconClose } = treeOpts
283
+ const childrenField = treeOpts.children || treeOpts.childrenField
284
+ const hasChildField = treeOpts.hasChild || treeOpts.hasChildField
285
+ const rowChilds = row[childrenField]
286
+ const hasChild = rowChilds && rowChilds.length
287
+ let hasLazyChilds = false
288
+ let isAceived = false
289
+ let isLazyLoading = false
290
+ let isLazyLoaded = false
291
+ const on: any = {}
292
+ if (slots && slots.icon) {
293
+ return $table.callSlot(slots.icon, params, h, cellVNodes)
294
+ }
295
+ if (!isHidden) {
296
+ const rowid = getRowid($table, row)
297
+ isAceived = !!treeExpandedMaps[rowid]
298
+ if (lazy) {
299
+ const rest = fullAllDataRowIdData[rowid]
300
+ isLazyLoading = !!treeExpandLazyLoadedMaps[rowid]
301
+ hasLazyChilds = row[hasChildField]
302
+ isLazyLoaded = !!rest.treeLoaded
303
+ }
304
+ }
305
+ if (!trigger || trigger === 'default') {
306
+ on.click = (evnt: any) => {
307
+ $table.triggerTreeExpandEvent(evnt, params)
308
+ }
309
+ }
310
+ return [
311
+ h('div', {
312
+ class: ['vxe-cell--tree-node', {
313
+ 'is--active': isAceived
314
+ }],
315
+ style: {
316
+ paddingLeft: `${level * indent}px`
317
+ }
318
+ }, [
319
+ showIcon && (lazy ? (isLazyLoaded ? hasChild : hasLazyChilds) : hasChild)
320
+ ? [
321
+ h('div', {
322
+ class: 'vxe-tree--btn-wrapper',
323
+ on
324
+ }, [
325
+ h('i', {
326
+ class: ['vxe-tree--node-btn', isLazyLoading ? (iconLoaded || getIcon().TABLE_TREE_LOADED) : (isAceived ? (iconOpen || getIcon().TABLE_TREE_OPEN) : (iconClose || getIcon().TABLE_TREE_CLOSE))]
327
+ })
328
+ ])
329
+ ]
330
+ : null,
331
+ h('div', {
332
+ class: 'vxe-tree-cell'
333
+ }, cellVNodes)
334
+ ])
335
+ ]
336
+ },
337
+
338
+ /**
339
+ * 索引
340
+ */
341
+ renderSeqHeader (h: CreateElement, params: any) {
342
+ const { $table, column } = params
343
+ const { slots } = column
344
+ return renderTitleContent(h, params, slots && slots.header ? $table.callSlot(slots.header, params, h) : formatText(column.getTitle(), 1))
345
+ },
346
+ renderSeqCell (h: CreateElement, params: any) {
347
+ const { $table, column } = params
348
+ const { treeConfig, seqOpts } = $table
349
+ const { slots } = column
350
+ if (slots && slots.default) {
351
+ return $table.callSlot(slots.default, params, h)
352
+ }
353
+ const { seq } = params
354
+ const seqMethod = seqOpts.seqMethod
355
+ return [formatText(seqMethod ? seqMethod(params) : treeConfig ? seq : (seqOpts.startIndex || 0) + seq, 1)]
356
+ },
357
+ renderTreeIndexCell (h: CreateElement, params: any) {
358
+ return Cell.renderTreeIcon(h, params, Cell.renderSeqCell(h, params))
359
+ },
360
+
361
+ /**
362
+ * 单选
363
+ */
364
+ renderRadioHeader (h: CreateElement, params: any) {
365
+ const { $table, column } = params
366
+ const { slots } = column
367
+ const headerSlot = slots ? slots.header : null
368
+ const titleSlot = slots ? slots.title : null
369
+ return renderTitleContent(h, params, headerSlot
370
+ ? $table.callSlot(headerSlot, params, h)
371
+ : [
372
+ h('span', {
373
+ class: 'vxe-radio--label'
374
+ }, titleSlot ? $table.callSlot(titleSlot, params, h) : formatText(column.getTitle(), 1))
375
+ ])
376
+ },
377
+ renderRadioCell (h: CreateElement, params: any) {
378
+ const { $table, column, isHidden } = params
379
+ const { radioOpts, selectRadioRow } = $table
380
+ const { slots } = column
381
+ const { labelField, checkMethod, visibleMethod } = radioOpts
382
+ const { row } = params
383
+ const defaultSlot = slots ? slots.default : null
384
+ const radioSlot = slots ? slots.radio : null
385
+ const isChecked = row === selectRadioRow
386
+ const isVisible = !visibleMethod || visibleMethod({ row })
387
+ let isDisabled = !!checkMethod
388
+ let on: any
389
+ if (!isHidden) {
390
+ on = {
391
+ click (evnt: any) {
392
+ if (!isDisabled && isVisible) {
393
+ $table.triggerRadioRowEvent(evnt, params)
394
+ }
395
+ }
396
+ }
397
+ if (checkMethod) {
398
+ isDisabled = !checkMethod({ row })
399
+ }
400
+ }
401
+ const radioParams = { ...params, checked: isChecked, disabled: isDisabled, visible: isVisible }
402
+ if (radioSlot) {
403
+ return $table.callSlot(radioSlot, radioParams, h)
404
+ }
405
+ const radioVNs = []
406
+ if (isVisible) {
407
+ radioVNs.push(
408
+ h('span', {
409
+ class: ['vxe-radio--icon', isChecked ? getIcon().TABLE_RADIO_CHECKED : getIcon().TABLE_RADIO_UNCHECKED]
410
+ })
411
+ )
412
+ }
413
+ if (defaultSlot || labelField) {
414
+ radioVNs.push(
415
+ h('span', {
416
+ class: 'vxe-radio--label'
417
+ }, defaultSlot ? $table.callSlot(defaultSlot, radioParams, h) : XEUtils.get(row, labelField))
418
+ )
419
+ }
420
+ return [
421
+ h('span', {
422
+ class: ['vxe-cell--radio', {
423
+ 'is--checked': isChecked,
424
+ 'is--disabled': isDisabled
425
+ }],
426
+ on
427
+ }, radioVNs)
428
+ ]
429
+ },
430
+ renderTreeRadioCell (h: CreateElement, params: any) {
431
+ return Cell.renderTreeIcon(h, params, Cell.renderRadioCell(h, params))
432
+ },
433
+
434
+ /**
435
+ * 多选
436
+ */
437
+ renderCheckboxHeader (h: CreateElement, params: any) {
438
+ const { $table, column, isHidden } = params
439
+ const { isAllSelected: isAllCheckboxSelected, isIndeterminate: isAllCheckboxIndeterminate, isAllCheckboxDisabled } = $table
440
+ const { slots } = column
441
+ const headerSlot = slots ? slots.header : null
442
+ const titleSlot = slots ? slots.title : null
443
+ const checkboxOpts = $table.checkboxOpts
444
+ const headerTitle = column.getTitle()
445
+ let on
446
+ if (!isHidden) {
447
+ on = {
448
+ click (evnt: any) {
449
+ if (!isAllCheckboxDisabled) {
450
+ $table.triggerCheckAllEvent(evnt, !isAllCheckboxSelected)
451
+ }
452
+ }
453
+ }
454
+ }
455
+ const checkboxParams = { ...params, checked: isAllCheckboxSelected, disabled: isAllCheckboxDisabled, indeterminate: isAllCheckboxIndeterminate }
456
+ if (headerSlot) {
457
+ return renderTitleContent(h, checkboxParams, $table.callSlot(headerSlot, checkboxParams, h))
458
+ }
459
+ if (checkboxOpts.checkStrictly ? !checkboxOpts.showHeader : checkboxOpts.showHeader === false) {
460
+ return renderTitleContent(h, checkboxParams, [
461
+ h('span', {
462
+ class: 'vxe-checkbox--label'
463
+ }, titleSlot ? $table.callSlot(titleSlot, checkboxParams, h) : headerTitle)
464
+ ])
465
+ }
466
+ return renderTitleContent(h, checkboxParams, [
467
+ h('span', {
468
+ class: ['vxe-cell--checkbox', {
469
+ 'is--checked': isAllCheckboxSelected,
470
+ 'is--disabled': isAllCheckboxDisabled,
471
+ 'is--indeterminate': isAllCheckboxIndeterminate
472
+ }],
473
+ attrs: {
474
+ title: getI18n('vxe.table.allTitle')
475
+ },
476
+ on
477
+ }, [
478
+ h('span', {
479
+ class: ['vxe-checkbox--icon', isAllCheckboxIndeterminate ? getIcon().TABLE_CHECKBOX_INDETERMINATE : (isAllCheckboxSelected ? getIcon().TABLE_CHECKBOX_CHECKED : getIcon().TABLE_CHECKBOX_UNCHECKED)]
480
+ })
481
+ ].concat(titleSlot || headerTitle
482
+ ? [
483
+ h('span', {
484
+ class: 'vxe-checkbox--label'
485
+ }, titleSlot ? $table.callSlot(titleSlot, checkboxParams, h) : headerTitle)
486
+ ]
487
+ : []))
488
+ ])
489
+ },
490
+ renderCheckboxCell (h: CreateElement, params: any) {
491
+ const { $table, row, column, isHidden } = params
492
+ const { treeConfig, treeIndeterminateMaps, selectCheckboxMaps } = $table
493
+ const { labelField, checkMethod, visibleMethod } = $table.checkboxOpts
494
+ const { slots } = column
495
+ const defaultSlot = slots ? slots.default : null
496
+ const checkboxSlot = slots ? slots.checkbox : null
497
+ let indeterminate = false
498
+ let isChecked = false
499
+ const isVisible = !visibleMethod || visibleMethod({ row })
500
+ let isDisabled = !!checkMethod
501
+ let on
502
+ if (!isHidden) {
503
+ const rowid = getRowid($table, row)
504
+ isChecked = !!selectCheckboxMaps[rowid]
505
+ on = {
506
+ click (evnt: any) {
507
+ if (!isDisabled && isVisible) {
508
+ $table.triggerCheckRowEvent(evnt, params, !isChecked)
509
+ }
510
+ }
511
+ }
512
+ if (checkMethod) {
513
+ isDisabled = !checkMethod({ row })
514
+ }
515
+ if (treeConfig) {
516
+ indeterminate = !!treeIndeterminateMaps[rowid]
517
+ }
518
+ }
519
+ const checkboxParams = { ...params, checked: isChecked, disabled: isDisabled, visible: isVisible, indeterminate }
520
+ if (checkboxSlot) {
521
+ return $table.callSlot(checkboxSlot, checkboxParams, h)
522
+ }
523
+ const checkVNs = []
524
+ if (isVisible) {
525
+ checkVNs.push(
526
+ h('span', {
527
+ class: ['vxe-checkbox--icon', indeterminate ? getIcon().TABLE_CHECKBOX_INDETERMINATE : (isChecked ? getIcon().TABLE_CHECKBOX_CHECKED : getIcon().TABLE_CHECKBOX_UNCHECKED)]
528
+ })
529
+ )
530
+ }
531
+ if (defaultSlot || labelField) {
532
+ checkVNs.push(
533
+ h('span', {
534
+ class: 'vxe-checkbox--label'
535
+ }, defaultSlot ? $table.callSlot(defaultSlot, checkboxParams, h) : XEUtils.get(row, labelField))
536
+ )
537
+ }
538
+ return [
539
+ h('span', {
540
+ class: ['vxe-cell--checkbox', {
541
+ 'is--checked': isChecked,
542
+ 'is--disabled': isDisabled,
543
+ 'is--indeterminate': indeterminate,
544
+ 'is--hidden': !isVisible
545
+ }],
546
+ on
547
+ }, checkVNs)
548
+ ]
549
+ },
550
+ renderTreeSelectionCell (h: CreateElement, params: any) {
551
+ return Cell.renderTreeIcon(h, params, Cell.renderCheckboxCell(h, params))
552
+ },
553
+ renderCheckboxCellByProp (h: CreateElement, params: any) {
554
+ const { $table, row, column, isHidden } = params
555
+ const { treeConfig, treeIndeterminateMaps, checkboxOpts } = $table
556
+ const { labelField, checkField, checkMethod, visibleMethod } = checkboxOpts
557
+ const indeterminateField = checkboxOpts.indeterminateField || checkboxOpts.halfField
558
+ const { slots } = column
559
+ const defaultSlot = slots ? slots.default : null
560
+ const checkboxSlot = slots ? slots.checkbox : null
561
+ let isIndeterminate = false
562
+ let isChecked = false
563
+ const isVisible = !visibleMethod || visibleMethod({ row })
564
+ let isDisabled = !!checkMethod
565
+ let on
566
+ if (!isHidden) {
567
+ const rowid = getRowid($table, row)
568
+ isChecked = XEUtils.get(row, checkField)
569
+ on = {
570
+ click (evnt: any) {
571
+ if (!isDisabled && isVisible) {
572
+ $table.triggerCheckRowEvent(evnt, params, !isChecked)
573
+ }
574
+ }
575
+ }
576
+ if (checkMethod) {
577
+ isDisabled = !checkMethod({ row })
578
+ }
579
+ if (treeConfig) {
580
+ isIndeterminate = !!treeIndeterminateMaps[rowid]
581
+ }
582
+ }
583
+ const checkboxParams = { ...params, checked: isChecked, disabled: isDisabled, visible: isVisible, indeterminate: isIndeterminate }
584
+ if (checkboxSlot) {
585
+ return $table.callSlot(checkboxSlot, checkboxParams, h)
586
+ }
587
+ const checkVNs = []
588
+ if (isVisible) {
589
+ checkVNs.push(
590
+ h('span', {
591
+ class: ['vxe-checkbox--icon', isIndeterminate ? getIcon().TABLE_CHECKBOX_INDETERMINATE : (isChecked ? getIcon().TABLE_CHECKBOX_CHECKED : getIcon().TABLE_CHECKBOX_UNCHECKED)]
592
+ })
593
+ )
594
+ }
595
+ if (defaultSlot || labelField) {
596
+ checkVNs.push(
597
+ h('span', {
598
+ class: 'vxe-checkbox--label'
599
+ }, defaultSlot ? $table.callSlot(defaultSlot, checkboxParams, h) : XEUtils.get(row, labelField))
600
+ )
601
+ }
602
+ return [
603
+ h('span', {
604
+ class: ['vxe-cell--checkbox', {
605
+ 'is--checked': isChecked,
606
+ 'is--disabled': isDisabled,
607
+ 'is--indeterminate': indeterminateField && !isChecked ? row[indeterminateField] : isIndeterminate,
608
+ 'is--hidden': !isVisible
609
+ }],
610
+ on
611
+ }, checkVNs)
612
+ ]
613
+ },
614
+ renderTreeSelectionCellByProp (h: CreateElement, params: any) {
615
+ return Cell.renderTreeIcon(h, params, Cell.renderCheckboxCellByProp(h, params))
616
+ },
617
+
618
+ /**
619
+ * 展开行
620
+ */
621
+ renderExpandCell (h: CreateElement, params: any) {
622
+ const { $table, isHidden, row, column } = params
623
+ const { expandOpts, rowExpandedMaps, rowExpandLazyLoadedMaps } = $table
624
+ const { lazy, labelField, iconLoaded, showIcon, iconOpen, iconClose, visibleMethod } = expandOpts
625
+ const { slots } = column
626
+ const defaultSlot = slots ? slots.default : null
627
+ let isAceived = false
628
+ let isLazyLoading = false
629
+ if (slots && slots.icon) {
630
+ return $table.callSlot(slots.icon, params, h)
631
+ }
632
+ if (!isHidden) {
633
+ const rowid = getRowid($table, row)
634
+ isAceived = !!rowExpandedMaps[rowid]
635
+ if (lazy) {
636
+ isLazyLoading = !!rowExpandLazyLoadedMaps[rowid]
637
+ }
638
+ }
639
+ return [
640
+ showIcon && (!visibleMethod || visibleMethod(params))
641
+ ? h('span', {
642
+ class: ['vxe-table--expanded', {
643
+ 'is--active': isAceived
644
+ }],
645
+ on: {
646
+ click (evnt: any) {
647
+ $table.triggerRowExpandEvent(evnt, params)
648
+ }
649
+ }
650
+ }, [
651
+ h('i', {
652
+ class: ['vxe-table--expand-btn', isLazyLoading ? (iconLoaded || getIcon().TABLE_EXPAND_LOADED) : (isAceived ? (iconOpen || getIcon().TABLE_EXPAND_OPEN) : (iconClose || getIcon().TABLE_EXPAND_CLOSE))]
653
+ })
654
+ ])
655
+ : null,
656
+ defaultSlot || labelField
657
+ ? h('span', {
658
+ class: 'vxe-table--expand-label'
659
+ }, defaultSlot ? $table.callSlot(defaultSlot, params, h) : XEUtils.get(row, labelField))
660
+ : null
661
+ ]
662
+ },
663
+ renderExpandData (h: CreateElement, params: any) {
664
+ const { $table, column } = params
665
+ const { slots, contentRender } = column
666
+ if (slots && slots.content) {
667
+ return $table.callSlot(slots.content, params, h)
668
+ }
669
+ if (contentRender) {
670
+ const compConf = renderer.get(contentRender.name)
671
+ const rtExpand = compConf ? (compConf.renderTableExpand || compConf.renderExpand) : null
672
+ if (rtExpand) {
673
+ return getSlotVNs(rtExpand.call($table, h, contentRender, params))
674
+ }
675
+ }
676
+ return []
677
+ },
678
+
679
+ /**
680
+ * HTML 标签
681
+ */
682
+ renderHTMLCell (h: CreateElement, params: any) {
683
+ const { $table, column } = params
684
+ const { slots } = column
685
+ if (slots && slots.default) {
686
+ return $table.callSlot(slots.default, params, h)
687
+ }
688
+ return [
689
+ h('span', {
690
+ class: 'vxe-cell--html',
691
+ domProps: {
692
+ innerHTML: getDefaultCellLabel(params)
693
+ }
694
+ })
695
+ ]
696
+ },
697
+ renderTreeHTMLCell (h: CreateElement, params: any) {
698
+ return Cell.renderTreeIcon(h, params, Cell.renderHTMLCell(h, params))
699
+ },
700
+
701
+ /**
702
+ * 排序和筛选
703
+ */
704
+ renderSortAndFilterHeader (h: CreateElement, params: any) {
705
+ return Cell.renderDefaultHeader(h, params)
706
+ .concat(Cell.renderSortIcon(h, params))
707
+ .concat(Cell.renderFilterIcon(h, params))
708
+ },
709
+
710
+ /**
711
+ * 排序
712
+ */
713
+ renderSortHeader (h: CreateElement, params: any) {
714
+ return Cell.renderDefaultHeader(h, params).concat(Cell.renderSortIcon(h, params))
715
+ },
716
+ renderSortIcon (h: CreateElement, params: any) {
717
+ console.log('renderSortIcon',params)
718
+ const { $table, column } = params
719
+ const { showIcon, iconLayout, iconAsc, iconDesc } = $table.sortOpts
720
+ return showIcon
721
+ ? [
722
+ h('span', {
723
+ class: ['vxe-cell--sort', `vxe-cell--sort-${iconLayout}-layout`]
724
+ }, [
725
+ h('i', {
726
+ class: ['vxe-sort--asc-btn', iconAsc || getIcon().TABLE_SORT_ASC, {
727
+ 'sort--active': column.order === 'asc'
728
+ }],
729
+ attrs: {
730
+ title: getI18n('vxe.table.sortAsc')
731
+ },
732
+ on: {
733
+ click (evnt: any) {
734
+ evnt.stopPropagation()
735
+ $table.triggerSortEvent(evnt, column, 'asc')
736
+ }
737
+ }
738
+ }),
739
+ h('i', {
740
+ class: ['vxe-sort--desc-btn', iconDesc || getIcon().TABLE_SORT_DESC, {
741
+ 'sort--active': column.order === 'desc'
742
+ }],
743
+ attrs: {
744
+ title: getI18n('vxe.table.sortDesc')
745
+ },
746
+ on: {
747
+ click (evnt: any) {
748
+ evnt.stopPropagation()
749
+ $table.triggerSortEvent(evnt, column, 'desc')
750
+ }
751
+ }
752
+ })
753
+ ])
754
+ ]
755
+ : []
756
+ },
757
+
758
+ /**
759
+ * 筛选
760
+ */
761
+ renderFilterHeader (h: CreateElement, params: any) {
762
+ return Cell.renderDefaultHeader(h, params).concat(Cell.renderFilterIcon(h, params))
763
+ },
764
+ renderFilterIcon (h: CreateElement, params: any) {
765
+ const { $table, column, hasFilter } = params
766
+ const { filterStore, filterOpts } = $table
767
+ const { showIcon, iconNone, iconMatch } = filterOpts
768
+ return showIcon
769
+ ? [
770
+ h('span', {
771
+ class: ['vxe-cell--filter', {
772
+ 'is--active': filterStore.visible && filterStore.column === column
773
+ }]
774
+ }, [
775
+ h('i', {
776
+ class: ['vxe-filter--btn', hasFilter ? (iconMatch || getIcon().TABLE_FILTER_MATCH) : (iconNone || getIcon().TABLE_FILTER_NONE)],
777
+ attrs: {
778
+ title: getI18n('vxe.table.filter')
779
+ },
780
+ on: {
781
+ click (evnt: any) {
782
+ if ($table.triggerFilterEvent) {
783
+ $table.triggerFilterEvent(evnt, params.column, params)
784
+ }
785
+ }
786
+ }
787
+ })
788
+ ])
789
+ ]
790
+ : []
791
+ },
792
+
793
+ /**
794
+ * 可编辑
795
+ */
796
+ renderEditHeader (h: CreateElement, params: any) {
797
+ const { $table, column } = params
798
+ const { editConfig, editRules, editOpts } = $table
799
+ const { sortable, remoteSort, filters, editRender } = column
800
+ let isRequired = false
801
+ if (editRules) {
802
+ const columnRules = XEUtils.get(editRules, column.field)
803
+ if (columnRules) {
804
+ isRequired = columnRules.some((rule: any) => rule.required)
805
+ }
806
+ }
807
+ return (isEnableConf(editConfig)
808
+ ? [
809
+ isRequired && editOpts.showAsterisk
810
+ ? h('i', {
811
+ class: 'vxe-cell--required-icon'
812
+ })
813
+ : null,
814
+ isEnableConf(editRender) && editOpts.showIcon
815
+ ? h('i', {
816
+ class: ['vxe-cell--edit-icon', editOpts.icon || getIcon().TABLE_EDIT]
817
+ })
818
+ : null
819
+ ]
820
+ : []).concat(Cell.renderDefaultHeader(h, params))
821
+ .concat(sortable || remoteSort ? Cell.renderSortIcon(h, params) : [])
822
+ .concat(filters ? Cell.renderFilterIcon(h, params) : [])
823
+ },
824
+ // 行格编辑模式
825
+ renderRowEdit (h: CreateElement, params: any) {
826
+ const { $table, column } = params
827
+ const { editRender } = column
828
+ const { actived } = $table.editStore
829
+ return Cell.runRenderer(h, params, this, isEnableConf(editRender) && actived && actived.row === params.row)
830
+ },
831
+ renderTreeRowEdit (h: CreateElement, params: any) {
832
+ return Cell.renderTreeIcon(h, params, Cell.renderRowEdit(h, params))
833
+ },
834
+ // 单元格编辑模式
835
+ renderCellEdit (h: CreateElement, params: any) {
836
+ const { $table, column } = params
837
+ const { editRender } = column
838
+ const { actived } = $table.editStore
839
+ return Cell.runRenderer(h, params, this, isEnableConf(editRender) && actived && actived.row === params.row && actived.column === params.column)
840
+ },
841
+ renderTreeCellEdit (h: CreateElement, params: any) {
842
+ return Cell.renderTreeIcon(h, params, Cell.renderCellEdit(h, params))
843
+ },
844
+ runRenderer (h: CreateElement, params: any, _vm: any, isEdit: any) {
845
+ const { $table, column } = params
846
+ const { slots, editRender, formatter } = column
847
+ const compConf = renderer.get(editRender.name)
848
+ const rtEdit = compConf ? (compConf.renderTableEdit || compConf.renderEdit) : null
849
+ const cellParams = Object.assign({ $type: '', isEdit }, params)
850
+ if (isEdit) {
851
+ if (slots && slots.edit) {
852
+ return $table.callSlot(slots.edit, cellParams, h)
853
+ }
854
+ if (rtEdit) {
855
+ return getSlotVNs(rtEdit.call($table, h, editRender, cellParams))
856
+ }
857
+ return []
858
+ }
859
+ if (slots && slots.default) {
860
+ return $table.callSlot(slots.default, cellParams, h)
861
+ }
862
+ if (formatter) {
863
+ return [
864
+ h('span', {
865
+ class: 'vxe-cell--label'
866
+ }, [getDefaultCellLabel(cellParams)])
867
+ ]
868
+ }
869
+ return Cell.renderDefaultCell.call(_vm, h, cellParams)
870
+ }
871
+ } as any
872
+
873
+ export default Cell
package/vue.config.js CHANGED
@@ -50,9 +50,14 @@ module.exports = {
50
50
  // 修改它的选项...
51
51
  return options
52
52
  })
53
-
54
-
55
- }
53
+ },
54
+ // configureWebpack: {
55
+ // resolve: {
56
+ // alias: {
57
+ // 'node-modules/vxe-table/packages/table/src/cell.ts': path.resolve(__dirname, 'packages/utils/cell.ts') // 新的别名
58
+ // }
59
+ // }
60
+ // }
56
61
  }
57
62
 
58
63