vxe-table 4.4.2-beta.2 → 4.4.2-beta.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.
Files changed (44) hide show
  1. package/README.en.md +0 -1
  2. package/README.md +0 -1
  3. package/README.zh-TW.md +0 -1
  4. package/es/icon/style.css +1 -1
  5. package/es/style.css +1 -1
  6. package/es/style.min.css +1 -1
  7. package/es/table/src/cell.js +1 -1
  8. package/es/table/src/columnInfo.js +1 -0
  9. package/es/table/src/table.js +75 -8
  10. package/es/tools/log.js +1 -1
  11. package/es/v-x-e-table/index.js +1 -1
  12. package/lib/icon/style/style.css +1 -1
  13. package/lib/icon/style/style.min.css +1 -1
  14. package/lib/index.umd.js +89 -11
  15. package/lib/index.umd.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 +1 -1
  19. package/lib/table/src/cell.min.js +1 -1
  20. package/lib/table/src/columnInfo.js +1 -0
  21. package/lib/table/src/columnInfo.min.js +1 -1
  22. package/lib/table/src/table.js +81 -8
  23. package/lib/table/src/table.min.js +1 -1
  24. package/lib/tools/log.js +1 -1
  25. package/lib/tools/log.min.js +1 -1
  26. package/lib/v-x-e-table/index.js +1 -1
  27. package/lib/v-x-e-table/index.min.js +1 -1
  28. package/package.json +2 -2
  29. package/packages/table/src/cell.ts +1 -1
  30. package/packages/table/src/columnInfo.ts +1 -0
  31. package/packages/table/src/table.ts +75 -8
  32. package/types/table.d.ts +12 -0
  33. /package/es/icon/style/{iconfont.1686011878916.ttf → iconfont.1686184068573.ttf} +0 -0
  34. /package/es/icon/style/{iconfont.1686011878916.woff → iconfont.1686184068573.woff} +0 -0
  35. /package/es/icon/style/{iconfont.1686011878916.woff2 → iconfont.1686184068573.woff2} +0 -0
  36. /package/es/{iconfont.1686011878916.ttf → iconfont.1686184068573.ttf} +0 -0
  37. /package/es/{iconfont.1686011878916.woff → iconfont.1686184068573.woff} +0 -0
  38. /package/es/{iconfont.1686011878916.woff2 → iconfont.1686184068573.woff2} +0 -0
  39. /package/lib/icon/style/{iconfont.1686011878916.ttf → iconfont.1686184068573.ttf} +0 -0
  40. /package/lib/icon/style/{iconfont.1686011878916.woff → iconfont.1686184068573.woff} +0 -0
  41. /package/lib/icon/style/{iconfont.1686011878916.woff2 → iconfont.1686184068573.woff2} +0 -0
  42. /package/lib/{iconfont.1686011878916.ttf → iconfont.1686184068573.ttf} +0 -0
  43. /package/lib/{iconfont.1686011878916.woff → iconfont.1686184068573.woff} +0 -0
  44. /package/lib/{iconfont.1686011878916.woff2 → iconfont.1686184068573.woff2} +0 -0
@@ -849,6 +849,7 @@ export default defineComponent({
849
849
  field?: VxeColumnPropTypes.Field
850
850
  resizeWidth?: number
851
851
  visible?: boolean
852
+ fixed?: string
852
853
  }
853
854
  } = {}
854
855
  if (!id) {
@@ -868,7 +869,15 @@ export default defineComponent({
868
869
  if (isCustomFixed) {
869
870
  const columnFixedStorage = getCustomStorageMap(fixedStorageKey)[id]
870
871
  if (columnFixedStorage) {
871
- // 开发中...
872
+ const colFixeds = columnFixedStorage.split(',')
873
+ colFixeds.forEach((fixConf: any) => {
874
+ const [field, fixed] = fixConf.split('|')
875
+ if (customMap[field]) {
876
+ customMap[field].fixed = fixed
877
+ } else {
878
+ customMap[field] = { field, fixed }
879
+ }
880
+ })
872
881
  }
873
882
  }
874
883
  // 自定义顺序
@@ -910,7 +919,7 @@ export default defineComponent({
910
919
  keyMap[colKey] = column
911
920
  }
912
921
  })
913
- XEUtils.each(customMap, ({ visible, resizeWidth }, field) => {
922
+ XEUtils.each(customMap, ({ visible, resizeWidth, fixed }, field) => {
914
923
  const column = keyMap[field]
915
924
  if (column) {
916
925
  if (XEUtils.isNumber(resizeWidth)) {
@@ -919,6 +928,9 @@ export default defineComponent({
919
928
  if (XEUtils.isBoolean(visible)) {
920
929
  column.visible = visible
921
930
  }
931
+ if (fixed) {
932
+ column.fixed = fixed
933
+ }
922
934
  }
923
935
  })
924
936
  }
@@ -3059,25 +3071,55 @@ export default defineComponent({
3059
3071
  footerData: footerTableData.slice(0)
3060
3072
  }
3061
3073
  },
3074
+ /**
3075
+ * 设置为固定列
3076
+ */
3077
+ setColumnFixed (fieldOrColumn, fixed) {
3078
+ const column = handleFieldOrColumn($xetable, fieldOrColumn)
3079
+ if (column && column.fixed !== fixed) {
3080
+ XEUtils.eachTree([column], (column) => {
3081
+ column.fixed = fixed
3082
+ })
3083
+ tablePrivateMethods.saveCustomFixed()
3084
+ return tableMethods.refreshColumn()
3085
+ }
3086
+ return nextTick()
3087
+ },
3088
+ /**
3089
+ * 取消指定固定列
3090
+ */
3091
+ clearColumnFixed (fieldOrColumn) {
3092
+ const column = handleFieldOrColumn($xetable, fieldOrColumn)
3093
+ if (column && column.fixed) {
3094
+ XEUtils.eachTree([column], (column) => {
3095
+ column.fixed = null
3096
+ })
3097
+ tablePrivateMethods.saveCustomFixed()
3098
+ return tableMethods.refreshColumn()
3099
+ }
3100
+ return nextTick()
3101
+ },
3062
3102
  /**
3063
3103
  * 隐藏指定列
3064
3104
  */
3065
3105
  hideColumn (fieldOrColumn) {
3066
3106
  const column = handleFieldOrColumn($xetable, fieldOrColumn)
3067
- if (column) {
3107
+ if (column && column.visible) {
3068
3108
  column.visible = false
3109
+ return tablePrivateMethods.handleCustom()
3069
3110
  }
3070
- return tablePrivateMethods.handleCustom()
3111
+ return nextTick()
3071
3112
  },
3072
3113
  /**
3073
3114
  * 显示指定列
3074
3115
  */
3075
3116
  showColumn (fieldOrColumn) {
3076
3117
  const column = handleFieldOrColumn($xetable, fieldOrColumn)
3077
- if (column) {
3118
+ if (column && !column.visible) {
3078
3119
  column.visible = true
3120
+ return tablePrivateMethods.handleCustom()
3079
3121
  }
3080
- return tablePrivateMethods.handleCustom()
3122
+ return nextTick()
3081
3123
  },
3082
3124
  setColumnWidth (fieldOrColumn, width) {
3083
3125
  const column = handleFieldOrColumn($xetable, fieldOrColumn)
@@ -4850,13 +4892,38 @@ export default defineComponent({
4850
4892
  localStorage.setItem(resizableStorageKey, XEUtils.toJSONString(columnWidthStorageMap))
4851
4893
  }
4852
4894
  },
4895
+ saveCustomFixed () {
4896
+ const { id, customConfig } = props
4897
+ const { collectColumn } = internalData
4898
+ const customOpts = computeCustomOpts.value
4899
+ const { storage } = customOpts
4900
+ const isCustomFixed = storage === true || (storage && storage.fixed)
4901
+ if (customConfig && isCustomFixed) {
4902
+ const columnFixedStorageMap = getCustomStorageMap(fixedStorageKey)
4903
+ const colFixeds: any[] = []
4904
+ if (!id) {
4905
+ errLog('vxe.error.reqProp', ['id'])
4906
+ return
4907
+ }
4908
+ XEUtils.eachTree(collectColumn, (column) => {
4909
+ if (column.fixed && column.fixed !== column.defaultFixed) {
4910
+ const colKey = column.getKey()
4911
+ if (colKey) {
4912
+ colFixeds.push(`${colKey}|${column.fixed}`)
4913
+ }
4914
+ }
4915
+ })
4916
+ columnFixedStorageMap[id] = colFixeds.join(',') || undefined
4917
+ localStorage.setItem(fixedStorageKey, XEUtils.toJSONString(columnFixedStorageMap))
4918
+ }
4919
+ },
4853
4920
  saveCustomVisible () {
4854
4921
  const { id, customConfig } = props
4855
4922
  const { collectColumn } = internalData
4856
4923
  const customOpts = computeCustomOpts.value
4857
4924
  const { checkMethod, storage } = customOpts
4858
- const isVisible = storage === true || (storage && storage.visible)
4859
- if (customConfig && isVisible) {
4925
+ const isCustomVisible = storage === true || (storage && storage.visible)
4926
+ if (customConfig && isCustomVisible) {
4860
4927
  const columnVisibleStorageMap = getCustomStorageMap(visibleStorageKey)
4861
4928
  const colHides: any[] = []
4862
4929
  const colShows: any[] = []
package/types/table.d.ts CHANGED
@@ -307,6 +307,16 @@ export interface TablePublicMethods<DT = VxeTableDataRow> {
307
307
  tableData: DT[]
308
308
  footerData: DT[][]
309
309
  }
310
+ /**
311
+ * 设置指定列为固定列
312
+ * @param columnOrField 列对象或字段名
313
+ */
314
+ setColumnFixed(fieldOrColumn: VxeColumnPropTypes.Field | VxeTableDefines.ColumnInfo<any>, fixed: VxeColumnPropTypes.Fixed): Promise<void>
315
+ /**
316
+ * 取消指定的固定列
317
+ * @param columnOrField 列对象或字段名
318
+ */
319
+ clearColumnFixed(fieldOrColumn: VxeColumnPropTypes.Field | VxeTableDefines.ColumnInfo<any>): Promise<void>
310
320
  /**
311
321
  * 隐藏指定列
312
322
  * @param columnOrField 列对象或字段名
@@ -720,6 +730,7 @@ export interface TablePrivateMethods<D = VxeTableDataRow> {
720
730
  cacheRowMap(isSource?: boolean): void
721
731
  saveCustomResizable(isReset?: boolean): void
722
732
  saveCustomVisible(): void
733
+ saveCustomFixed(): void
723
734
  analyColumnWidth(): void
724
735
  checkSelectionStatus(): void
725
736
  handleSelectRow(params: any, value: any, isForce?: boolean): void
@@ -2324,6 +2335,7 @@ export namespace VxeTableDefines {
2324
2335
  colSpan: number
2325
2336
  halfVisible: boolean
2326
2337
  defaultVisible: any
2338
+ defaultFixed: any
2327
2339
  checked: boolean
2328
2340
  halfChecked: boolean
2329
2341
  disabled: boolean