vxe-table 3.21.5 → 3.21.7

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.
@@ -775,10 +775,66 @@ export function toFilters (filters: any, colid?: string) {
775
775
  return filters
776
776
  }
777
777
 
778
- export function getColReMinWidth (params: any) {
778
+ /**
779
+ * 列宽拖动最大宽度
780
+ */
781
+ export function getColReMaxWidth (params: {
782
+ $table: VxeTableConstructor & VxeTablePrivateMethods;
783
+ column: VxeTableDefines.ColumnInfo;
784
+ columnIndex: number;
785
+ $columnIndex: number;
786
+ $rowIndex: number;
787
+ cell: HTMLTableCellElement;
788
+ }) {
789
+ const { $table, column, cell } = params
790
+ const internalData = $table as unknown as TableInternalData
791
+ const { elemStore } = internalData
792
+ const resizableOpts = $table.computeResizableOpts
793
+ const columnOpts = $table.computeColumnOpts
794
+ const { maxWidth: reMaxWidth } = resizableOpts
795
+ const colMaxWidth = column.maxWidth || columnOpts.maxWidth
796
+ // 如果自定义调整宽度逻辑
797
+ if (reMaxWidth) {
798
+ const customMaxWidth = XEUtils.isFunction(reMaxWidth) ? reMaxWidth(params) : reMaxWidth
799
+ if (customMaxWidth !== 'auto') {
800
+ return Math.max(1, XEUtils.toNumber(customMaxWidth))
801
+ }
802
+ }
803
+ const minTitleWidth = XEUtils.floor((XEUtils.toNumber(getComputedStyle(cell).fontSize) || 14) * 1.8)
804
+ const paddingLeftRight = getPaddingLeftRightSize(cell) + getPaddingLeftRightSize(queryElement(cell, '.vxe-cell'))
805
+ const mWidth = minTitleWidth + paddingLeftRight
806
+ // 如果设置最小宽
807
+ if (colMaxWidth) {
808
+ const bodyScrollElem = getRefElem(elemStore['main-body-scroll'])
809
+ if (bodyScrollElem) {
810
+ if (isScale(colMaxWidth)) {
811
+ const bodyWidth = bodyScrollElem.clientWidth - 1
812
+ const meanWidth = bodyWidth / 100
813
+ return Math.max(mWidth, Math.floor(XEUtils.toInteger(colMaxWidth) * meanWidth))
814
+ } else if (isPx(colMaxWidth)) {
815
+ return Math.max(mWidth, XEUtils.toInteger(colMaxWidth))
816
+ }
817
+ }
818
+ }
819
+ return -1
820
+ }
821
+
822
+ /**
823
+ * 列宽拖动最小宽度
824
+ */
825
+ export function getColReMinWidth (params: {
826
+ $table: VxeTableConstructor & VxeTablePrivateMethods;
827
+ column: VxeTableDefines.ColumnInfo;
828
+ columnIndex: number;
829
+ $columnIndex: number;
830
+ $rowIndex: number;
831
+ cell: HTMLTableCellElement;
832
+ }) {
779
833
  const { $table, column, cell } = params
780
- const internalData = $table
781
- const { showHeaderOverflow: allColumnHeaderOverflow, resizableOpts } = $table
834
+ const tableProps = $table
835
+ const internalData = $table as unknown as TableInternalData
836
+ const resizableOpts = $table.computeResizableOpts
837
+ const columnOpts = $table.computeColumnOpts
782
838
  const { minWidth } = resizableOpts
783
839
  // 如果自定义调整宽度逻辑
784
840
  if (minWidth) {
@@ -788,7 +844,9 @@ export function getColReMinWidth (params: any) {
788
844
  }
789
845
  }
790
846
  const { elemStore } = internalData
791
- const { showHeaderOverflow, minWidth: colMinWidth } = column
847
+ const { showHeaderOverflow: allColumnHeaderOverflow } = tableProps
848
+ const { showHeaderOverflow } = column
849
+ const colMinWidth = column.minWidth || columnOpts.minWidth
792
850
  const headOverflow = XEUtils.isUndefined(showHeaderOverflow) || XEUtils.isNull(showHeaderOverflow) ? allColumnHeaderOverflow : showHeaderOverflow
793
851
  const showEllipsis = headOverflow === 'ellipsis'
794
852
  const showTitle = headOverflow === 'title'