vxe-table 3.8.11 → 3.8.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/lib/export/src/mixin.js +1 -1
  2. package/lib/export/src/mixin.min.js +1 -1
  3. package/lib/filter/src/mixin.js +19 -14
  4. package/lib/filter/src/mixin.min.js +1 -1
  5. package/lib/filter/src/panel.js +3 -3
  6. package/lib/filter/src/panel.min.js +1 -1
  7. package/lib/grid/src/grid.js +3 -3
  8. package/lib/grid/src/grid.min.js +1 -1
  9. package/lib/icon/style/style.css +1 -1
  10. package/lib/icon/style/style.min.css +1 -1
  11. package/lib/index.css +1 -1
  12. package/lib/index.umd.js +464 -361
  13. package/lib/index.umd.min.js +1 -1
  14. package/lib/modal/src/modal.js +33 -33
  15. package/lib/modal/src/modal.min.js +1 -1
  16. package/lib/style.css +1 -1
  17. package/lib/style.min.css +1 -1
  18. package/lib/table/src/cell.js +51 -11
  19. package/lib/table/src/cell.min.js +1 -1
  20. package/lib/table/src/column.js +2 -0
  21. package/lib/table/src/column.min.js +1 -1
  22. package/lib/table/src/columnInfo.js +2 -0
  23. package/lib/table/src/columnInfo.min.js +1 -1
  24. package/lib/table/src/methods.js +342 -292
  25. package/lib/table/src/methods.min.js +1 -1
  26. package/lib/table/src/table.js +9 -1
  27. package/lib/table/src/table.min.js +1 -1
  28. package/lib/table/style/style.css +12 -4
  29. package/lib/table/style/style.min.css +1 -1
  30. package/lib/tools/dom.js +1 -1
  31. package/lib/tools/dom.min.js +1 -1
  32. package/lib/tools/log.js +1 -1
  33. package/lib/tools/log.min.js +1 -1
  34. package/lib/v-x-e-table/index.js +1 -1
  35. package/lib/v-x-e-table/index.min.js +1 -1
  36. package/lib/v-x-e-table/src/conf.js +1 -1
  37. package/lib/v-x-e-table/src/conf.min.js +1 -1
  38. package/lib/vxe-table/style/style.css +12 -4
  39. package/lib/vxe-table/style/style.min.css +1 -1
  40. package/package.json +1 -1
  41. package/packages/export/src/mixin.js +1 -0
  42. package/packages/filter/src/mixin.js +17 -14
  43. package/packages/filter/src/panel.js +3 -3
  44. package/packages/grid/src/grid.js +3 -3
  45. package/packages/modal/src/modal.js +36 -36
  46. package/packages/table/src/cell.js +51 -10
  47. package/packages/table/src/column.js +2 -0
  48. package/packages/table/src/columnInfo.js +2 -0
  49. package/packages/table/src/methods.js +61 -15
  50. package/packages/table/src/table.js +7 -0
  51. package/packages/tools/dom.js +1 -1
  52. package/packages/v-x-e-table/src/conf.js +1 -1
  53. package/styles/table.scss +22 -6
  54. /package/lib/icon/style/{iconfont.1720519524864.ttf → iconfont.1721119959483.ttf} +0 -0
  55. /package/lib/icon/style/{iconfont.1720519524864.woff → iconfont.1721119959483.woff} +0 -0
  56. /package/lib/icon/style/{iconfont.1720519524864.woff2 → iconfont.1721119959483.woff2} +0 -0
  57. /package/lib/{iconfont.1720519524864.ttf → iconfont.1721119959483.ttf} +0 -0
  58. /package/lib/{iconfont.1720519524864.woff → iconfont.1721119959483.woff} +0 -0
  59. /package/lib/{iconfont.1720519524864.woff2 → iconfont.1721119959483.woff2} +0 -0
@@ -40,6 +40,8 @@ const props = {
40
40
  footerClassName: [String, Function],
41
41
  // 格式化显示内容
42
42
  formatter: [Function, Array, String],
43
+ // 格式化表尾显示内容
44
+ footerFormatter: [Function, Array, String],
43
45
  // 是否允许排序
44
46
  sortable: Boolean,
45
47
  // 在 v3 中废弃
@@ -74,6 +74,7 @@ export class ColumnInfo {
74
74
  headerClassName: _vm.headerClassName,
75
75
  footerClassName: _vm.footerClassName,
76
76
  formatter,
77
+ footerFormatter: _vm.footerFormatter,
77
78
  sortable: _vm.sortable,
78
79
  sortBy: _vm.sortBy,
79
80
  sortType: _vm.sortType,
@@ -127,6 +128,7 @@ export class ColumnInfo {
127
128
  renderWidth: 0,
128
129
  renderHeight: 0,
129
130
  renderResizeWidth: 0,
131
+ renderAutoWidth: 0,
130
132
  resizeWidth: 0, // 手动调整
131
133
 
132
134
  renderLeft: 0,
@@ -2005,6 +2005,7 @@ const Methods = {
2005
2005
  const scaleList = []
2006
2006
  const scaleMinList = []
2007
2007
  const autoList = []
2008
+ const remainList = []
2008
2009
  this.tableFullColumn.forEach(column => {
2009
2010
  if (defaultWidth && !column.width) {
2010
2011
  column.width = defaultWidth
@@ -2015,6 +2016,8 @@ const Methods = {
2015
2016
  if (column.visible) {
2016
2017
  if (column.resizeWidth) {
2017
2018
  resizeList.push(column)
2019
+ } else if (column.width === 'auto') {
2020
+ autoList.push(column)
2018
2021
  } else if (DomTools.isPx(column.width)) {
2019
2022
  pxList.push(column)
2020
2023
  } else if (DomTools.isScale(column.width)) {
@@ -2024,11 +2027,11 @@ const Methods = {
2024
2027
  } else if (DomTools.isScale(column.minWidth)) {
2025
2028
  scaleMinList.push(column)
2026
2029
  } else {
2027
- autoList.push(column)
2030
+ remainList.push(column)
2028
2031
  }
2029
2032
  }
2030
2033
  })
2031
- Object.assign(this.columnStore, { resizeList, pxList, pxMinList, scaleList, scaleMinList, autoList })
2034
+ Object.assign(this.columnStore, { resizeList, pxList, pxMinList, scaleList, scaleMinList, autoList, remainList })
2032
2035
  },
2033
2036
  /**
2034
2037
  * 刷新滚动操作,手动同步滚动相关位置(对于某些特殊的操作,比如滚动条错位、固定列不同步)
@@ -2069,6 +2072,7 @@ const Methods = {
2069
2072
  const headerElem = tableHeader ? tableHeader.$el : null
2070
2073
  const footerElem = tableFooter ? tableFooter.$el : null
2071
2074
  if (bodyElem) {
2075
+ this.calcCellWidth()
2072
2076
  this.autoCellWidth(headerElem, bodyElem, footerElem)
2073
2077
  if (refull === true) {
2074
2078
  // 初始化时需要在列计算之后再执行优化运算,达到最优显示效果
@@ -2080,6 +2084,38 @@ const Methods = {
2080
2084
  }
2081
2085
  return this.computeScrollLoad()
2082
2086
  },
2087
+ calcCellWidth () {
2088
+ const { autoWidthColumnList, tableData } = this
2089
+ if (!tableData.length || !autoWidthColumnList.length) {
2090
+ this.isCalcColumn = false
2091
+ return this.$nextTick()
2092
+ }
2093
+ this.isCalcColumn = true
2094
+ return this.$nextTick().then(() => {
2095
+ const el = this.$el
2096
+ if (el) {
2097
+ autoWidthColumnList.forEach(column => {
2098
+ const cellElList = el.querySelectorAll(`.vxe-header--column.${column.id}>.vxe-cell,.vxe-body--column.${column.id}>.vxe-cell,.vxe-footer--column.${column.id}>.vxe-cell`)
2099
+ const firstCellEl = cellElList[0]
2100
+ let paddingSize = 0
2101
+ if (firstCellEl) {
2102
+ const cellStyle = getComputedStyle(firstCellEl)
2103
+ paddingSize = Math.floor(XEUtils.toNumber(cellStyle.paddingLeft) + XEUtils.toNumber(cellStyle.paddingRight)) + 2
2104
+ }
2105
+ let colWidth = column.renderAutoWidth - paddingSize + 2
2106
+ XEUtils.arrayEach(cellElList, (cellEl) => {
2107
+ const labelEl = cellEl.firstChild
2108
+ if (labelEl) {
2109
+ colWidth = Math.max(colWidth, labelEl.offsetWidth)
2110
+ }
2111
+ })
2112
+ column.renderAutoWidth = colWidth + paddingSize
2113
+ })
2114
+ this.analyColumnWidth()
2115
+ }
2116
+ this.isCalcColumn = false
2117
+ })
2118
+ },
2083
2119
  /**
2084
2120
  * 列宽算法
2085
2121
  * 支持 px、%、固定 混合分配
@@ -2097,7 +2133,7 @@ const Methods = {
2097
2133
  let remainWidth = bodyWidth
2098
2134
  let meanWidth = remainWidth / 100
2099
2135
  const { fit, columnStore } = this
2100
- const { resizeList, pxMinList, pxList, scaleList, scaleMinList, autoList } = columnStore
2136
+ const { resizeList, pxMinList, pxList, scaleList, scaleMinList, autoList, remainList } = columnStore
2101
2137
  // 最小宽
2102
2138
  pxMinList.forEach(column => {
2103
2139
  const minWidth = parseInt(column.minWidth)
@@ -2122,6 +2158,12 @@ const Methods = {
2122
2158
  tableWidth += width
2123
2159
  column.renderWidth = width
2124
2160
  })
2161
+ // 自适应宽
2162
+ autoList.forEach((column) => {
2163
+ const width = Math.max(60, XEUtils.toInteger(column.renderAutoWidth))
2164
+ tableWidth += width
2165
+ column.renderWidth = width
2166
+ })
2125
2167
  // 调整了列宽
2126
2168
  resizeList.forEach(column => {
2127
2169
  const width = parseInt(column.resizeWidth)
@@ -2129,7 +2171,7 @@ const Methods = {
2129
2171
  column.renderWidth = width
2130
2172
  })
2131
2173
  remainWidth -= tableWidth
2132
- meanWidth = remainWidth > 0 ? Math.floor(remainWidth / (scaleMinList.length + pxMinList.length + autoList.length)) : 0
2174
+ meanWidth = remainWidth > 0 ? Math.floor(remainWidth / (scaleMinList.length + pxMinList.length + remainList.length)) : 0
2133
2175
  if (fit) {
2134
2176
  if (remainWidth > 0) {
2135
2177
  scaleMinList.concat(pxMinList).forEach(column => {
@@ -2140,8 +2182,8 @@ const Methods = {
2140
2182
  } else {
2141
2183
  meanWidth = minCellWidth
2142
2184
  }
2143
- // 自适应
2144
- autoList.forEach(column => {
2185
+ // 剩余均分
2186
+ remainList.forEach(column => {
2145
2187
  const width = Math.max(meanWidth, minCellWidth)
2146
2188
  column.renderWidth = width
2147
2189
  tableWidth += width
@@ -2151,7 +2193,7 @@ const Methods = {
2151
2193
  * 偏移量算法
2152
2194
  * 如果所有列足够放的情况下,从最后动态列开始分配
2153
2195
  */
2154
- const dynamicList = scaleList.concat(scaleMinList).concat(pxMinList).concat(autoList)
2196
+ const dynamicList = scaleList.concat(scaleMinList).concat(pxMinList).concat(remainList)
2155
2197
  let dynamicSize = dynamicList.length - 1
2156
2198
  if (dynamicSize > 0) {
2157
2199
  let odiffer = bodyWidth - tableWidth
@@ -2181,19 +2223,23 @@ const Methods = {
2181
2223
  } else {
2182
2224
  this.headerHeight = 0
2183
2225
  }
2226
+ let overflowX = false
2227
+ let footerHeight = 0
2228
+ let scrollbarHeight = 0
2184
2229
  if (footerElem) {
2185
- const footerHeight = footerElem.offsetHeight
2186
- this.scrollbarHeight = Math.max(footerHeight - footerElem.clientHeight, 0)
2187
- this.overflowX = tableWidth > footerElem.clientWidth
2188
- this.footerHeight = footerHeight
2230
+ footerHeight = footerElem.offsetHeight
2231
+ overflowX = tableWidth > footerElem.clientWidth
2232
+ scrollbarHeight = Math.max(footerHeight - footerElem.clientHeight, 0)
2189
2233
  } else {
2190
- this.footerHeight = 0
2191
- this.scrollbarHeight = Math.max(tableHeight - bodyElem.clientHeight, 0)
2192
- this.overflowX = tableWidth > bodyWidth
2234
+ overflowX = tableWidth > bodyWidth
2235
+ scrollbarHeight = Math.max(tableHeight - bodyElem.clientHeight, 0)
2193
2236
  }
2237
+ this.footerHeight = footerHeight
2238
+ this.overflowX = tableWidth > bodyWidth
2239
+ this.scrollbarHeight = scrollbarHeight
2194
2240
  this.updateHeight()
2195
2241
  this.parentHeight = Math.max(this.headerHeight + this.footerHeight + 20, this.getParentHeight())
2196
- if (this.overflowX) {
2242
+ if (overflowX) {
2197
2243
  this.checkScrolling()
2198
2244
  }
2199
2245
  },
@@ -273,6 +273,7 @@ export default {
273
273
  data () {
274
274
  return {
275
275
  tId: `${XEUtils.uniqueId()}`,
276
+ isCalcColumn: false,
276
277
  // 低性能的静态列
277
278
  staticColumns: [],
278
279
  // 渲染的列分组
@@ -615,6 +616,10 @@ export default {
615
616
  customOpts () {
616
617
  return Object.assign({}, GlobalConfig.table.customConfig, this.customConfig)
617
618
  },
619
+ autoWidthColumnList () {
620
+ const { visibleColumn } = this
621
+ return visibleColumn.filter(column => column.width === 'auto')
622
+ },
618
623
  fixedColumnSize () {
619
624
  const { collectColumn } = this
620
625
  let fixedSize = 0
@@ -1022,6 +1027,7 @@ export default {
1022
1027
  _e,
1023
1028
  $scopedSlots,
1024
1029
  tId,
1030
+ isCalcColumn,
1025
1031
  tableData,
1026
1032
  tableColumn,
1027
1033
  tableGroupColumn,
@@ -1075,6 +1081,7 @@ export default {
1075
1081
  'row--highlight': rowOpts.isHover || highlightHoverRow,
1076
1082
  'column--highlight': columnOpts.isHover || highlightHoverColumn,
1077
1083
  'checkbox--range': checkboxOpts.range,
1084
+ 'column--calc': isCalcColumn,
1078
1085
  'is--header': showHeader,
1079
1086
  'is--footer': showFooter,
1080
1087
  'is--group': isGroup,
@@ -159,7 +159,7 @@ export const DomTools = {
159
159
  const val = $xetable[key]
160
160
  let num = 0
161
161
  if (val) {
162
- if (val === 'auto') {
162
+ if (val === '100%' || val === 'auto') {
163
163
  num = $xetable.parentHeight
164
164
  } else {
165
165
  const excludeHeight = $xetable.getExcludeHeight()
@@ -219,7 +219,7 @@ export default {
219
219
  MODAL_CLOSE: iconPrefix + 'close',
220
220
  MODAL_INFO: iconPrefix + 'info-circle-fill',
221
221
  MODAL_SUCCESS: iconPrefix + 'success-circle-fill',
222
- MODAL_WARNING: iconPrefix + 'warnion-circle-fill',
222
+ MODAL_WARNING: iconPrefix + 'warning-circle-fill',
223
223
  MODAL_ERROR: iconPrefix + 'error-circle-fill',
224
224
  MODAL_QUESTION: iconPrefix + 'question-circle-fill',
225
225
  MODAL_LOADING: iconPrefix + 'spinner roll',
package/styles/table.scss CHANGED
@@ -315,6 +315,20 @@
315
315
  }
316
316
  }
317
317
 
318
+ /*列宽*/
319
+ .vxe-table {
320
+ &.column--calc {
321
+ .vxe-header--column,
322
+ .vxe-body--column,
323
+ .vxe-footer--column {
324
+ .vxe-cell {
325
+ word-break: break-all;
326
+ white-space: nowrap;
327
+ }
328
+ }
329
+ }
330
+ }
331
+
318
332
  /*header*/
319
333
  .vxe-table {
320
334
  .vxe-table--header-wrapper {
@@ -611,11 +625,6 @@
611
625
  }
612
626
  }
613
627
  }
614
- &.checkbox--range {
615
- .vxe-body--column {
616
- user-select: none;
617
- }
618
- }
619
628
  &.cell--area {
620
629
  .vxe-table--body-wrapper,
621
630
  .vxe-body--column {
@@ -623,10 +632,17 @@
623
632
  }
624
633
  }
625
634
  &.drag--range {
626
- .vxe-cell--checkbox {
635
+ .vxe-body--column {
627
636
  user-select: none;
628
637
  }
629
638
  }
639
+ &.checkbox--range {
640
+ .vxe-body--column {
641
+ &.col--checkbox {
642
+ user-select: none;
643
+ }
644
+ }
645
+ }
630
646
  .vxe-header--column,
631
647
  .vxe-body--column,
632
648
  .vxe-footer--column {