vxe-gantt 4.1.20 → 4.2.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.
@@ -1,4 +1,4 @@
1
- import { h, ref, reactive, nextTick, inject, watch, provide, computed, onMounted, onUnmounted } from 'vue'
1
+ import { h, ref, reactive, nextTick, inject, onBeforeUnmount, provide, computed, onMounted, onUnmounted } from 'vue'
2
2
  import { defineVxeComponent } from '../../ui/src/comp'
3
3
  import { setScrollTop, setScrollLeft, removeClass, addClass, hasClass } from '../../ui/src/dom'
4
4
  import { VxeUI } from '@vxe-ui/core'
@@ -41,6 +41,43 @@ function createInternalData (): GanttViewInternalData {
41
41
  }
42
42
  }
43
43
 
44
+ function createReactData (): GanttViewReactData {
45
+ return {
46
+ // 是否启用了横向 X 可视渲染方式加载
47
+ scrollXLoad: false,
48
+ // 是否启用了纵向 Y 可视渲染方式加载
49
+ scrollYLoad: false,
50
+ // 是否存在纵向滚动条
51
+ overflowY: true,
52
+ // 是否存在横向滚动条
53
+ overflowX: true,
54
+ // 纵向滚动条的宽度
55
+ scrollbarWidth: 0,
56
+ // 横向滚动条的高度
57
+ scrollbarHeight: 0,
58
+
59
+ // 最后滚动时间戳
60
+ lastScrollTime: 0,
61
+ lazScrollLoading: false,
62
+
63
+ scrollVMLoading: false,
64
+ scrollYHeight: 0,
65
+ scrollYTop: 0,
66
+ isScrollYBig: false,
67
+ scrollXLeft: 0,
68
+ scrollXWidth: 0,
69
+ isScrollXBig: false,
70
+
71
+ minViewDate: null,
72
+ maxViewDate: null,
73
+ tableData: [],
74
+ tableColumn: [],
75
+ headerGroups: [],
76
+
77
+ viewCellWidth: 40
78
+ }
79
+ }
80
+
44
81
  const maxYHeight = 5e6
45
82
  // const maxXWidth = 5e6
46
83
 
@@ -71,40 +108,7 @@ export default defineVxeComponent({
71
108
 
72
109
  const refColInfoElem = ref<HTMLDivElement>()
73
110
 
74
- const reactData = reactive<GanttViewReactData>({
75
- // 是否启用了横向 X 可视渲染方式加载
76
- scrollXLoad: false,
77
- // 是否启用了纵向 Y 可视渲染方式加载
78
- scrollYLoad: false,
79
- // 是否存在纵向滚动条
80
- overflowY: true,
81
- // 是否存在横向滚动条
82
- overflowX: true,
83
- // 纵向滚动条的宽度
84
- scrollbarWidth: 0,
85
- // 横向滚动条的高度
86
- scrollbarHeight: 0,
87
-
88
- // 最后滚动时间戳
89
- lastScrollTime: 0,
90
- lazScrollLoading: false,
91
-
92
- scrollVMLoading: false,
93
- scrollYHeight: 0,
94
- scrollYTop: 0,
95
- isScrollYBig: false,
96
- scrollXLeft: 0,
97
- scrollXWidth: 0,
98
- isScrollXBig: false,
99
-
100
- minViewDate: null,
101
- maxViewDate: null,
102
- tableData: [],
103
- tableColumn: [],
104
- headerGroups: [],
105
-
106
- viewCellWidth: 40
107
- })
111
+ const reactData = reactive(createReactData())
108
112
 
109
113
  const internalData = createInternalData()
110
114
 
@@ -1102,30 +1106,35 @@ export default defineVxeComponent({
1102
1106
  // footerTableElem.style.transform = `translate(${xSpaceLeft}px, 0px)`
1103
1107
  // }
1104
1108
 
1109
+ const ySpaceWidth = scrollXWidth
1110
+
1105
1111
  const layoutList = ['header', 'body', 'footer']
1106
1112
  layoutList.forEach(layout => {
1107
1113
  const xSpaceElem = getRefElem(elemStore[`main-${layout}-xSpace`])
1108
1114
  if (xSpaceElem) {
1109
- xSpaceElem.style.width = scrollXLoad ? `${scrollXWidth}px` : ''
1115
+ xSpaceElem.style.width = scrollXLoad ? `${ySpaceWidth}px` : ''
1110
1116
  }
1111
1117
  })
1112
1118
 
1113
1119
  const scrollXSpaceEl = refScrollXSpaceElem.value
1114
1120
  if (scrollXSpaceEl) {
1115
- scrollXSpaceEl.style.width = `${scrollXWidth}px`
1121
+ scrollXSpaceEl.style.width = `${ySpaceWidth}px`
1116
1122
  }
1117
1123
 
1118
1124
  const beforeWrapper = getRefElem(elemStore['main-chart-before-wrapper'])
1119
1125
  const beforeSvgElem = beforeWrapper ? beforeWrapper.firstElementChild as HTMLDivElement : null
1120
1126
  if (beforeSvgElem) {
1121
- beforeSvgElem.style.width = `${scrollXWidth}px`
1127
+ beforeSvgElem.style.width = `${ySpaceWidth}px`
1122
1128
  }
1123
1129
  const afterWrapper = getRefElem(elemStore['main-chart-after-wrapper'])
1124
1130
  const afterSvgElem = afterWrapper ? afterWrapper.firstElementChild as HTMLDivElement : null
1125
1131
  if (afterSvgElem) {
1126
- afterSvgElem.style.width = `${scrollXWidth}px`
1132
+ afterSvgElem.style.width = `${ySpaceWidth}px`
1127
1133
  }
1128
1134
 
1135
+ reactData.scrollXLeft = xSpaceLeft
1136
+ reactData.scrollXWidth = ySpaceWidth
1137
+
1129
1138
  calcScrollbar()
1130
1139
  return nextTick()
1131
1140
  }
@@ -1172,7 +1181,7 @@ export default defineVxeComponent({
1172
1181
  bodyTableElem.style.transform = `translate(${reactData.scrollXLeft || 0}px, ${scrollYTop}px)`
1173
1182
  }
1174
1183
  if (bodyChartWrapperElem) {
1175
- bodyChartWrapperElem.style.transform = `translate(${reactData.scrollXLeft || 0}px, ${scrollYTop}px)`
1184
+ bodyChartWrapperElem.style.transform = `translateY(${scrollYTop}px)`
1176
1185
  }
1177
1186
 
1178
1187
  const bodyYSpaceElem = getRefElem(elemStore['main-body-ySpace'])
@@ -1334,12 +1343,16 @@ export default defineVxeComponent({
1334
1343
  }
1335
1344
  })
1336
1345
  },
1337
- updateViewData () {
1346
+ updateViewData (force?: boolean) {
1338
1347
  const $xeTable = internalData.xeTable
1339
1348
  if ($xeTable) {
1340
1349
  const tableReactData = $xeTable.reactData
1341
1350
  const { tableData } = tableReactData
1342
1351
  reactData.tableData = tableData
1352
+ if (force) {
1353
+ handleUpdateData()
1354
+ }
1355
+ handleRecalculateStyle()
1343
1356
  }
1344
1357
  return nextTick()
1345
1358
  },
@@ -1655,21 +1668,14 @@ export default defineVxeComponent({
1655
1668
  ])
1656
1669
  }
1657
1670
 
1658
- const tdFlag = ref(0)
1659
- watch(() => reactData.tableData, () => {
1660
- tdFlag.value++
1661
- })
1662
- watch(() => reactData.tableData.length, () => {
1663
- tdFlag.value++
1664
- })
1665
- watch(tdFlag, () => {
1666
- handleUpdateData()
1667
- })
1668
-
1669
1671
  onMounted(() => {
1670
1672
  globalEvents.on($xeGanttView, 'resize', handleGlobalResizeEvent)
1671
1673
  })
1672
1674
 
1675
+ onBeforeUnmount(() => {
1676
+ XEUtils.assign(reactData, createReactData())
1677
+ })
1678
+
1673
1679
  onUnmounted(() => {
1674
1680
  globalEvents.off($xeGanttView, 'keydown')
1675
1681
  XEUtils.assign(internalData, createInternalData())
@@ -17,7 +17,7 @@ import type { VxeTableMethods, VxeToolbarPropTypes, VxeTableProps, VxeTablePropT
17
17
 
18
18
  const { getConfig, getIcon, getI18n, commands, hooks, useFns, createEvent, globalEvents, GLOBAL_EVENT_KEYS, renderEmptyElement } = VxeUI
19
19
 
20
- const tableProps = (VxeTableComponent as any).props
20
+ const tableProps = VxeTableComponent.props
21
21
 
22
22
  const tableComponentPropKeys = Object.keys(tableProps) as (keyof VxeTableProps)[]
23
23
  const tableComponentMethodKeys: (keyof VxeTableMethods)[] = ['clearAll', 'syncData', 'updateData', 'loadData', 'reloadData', 'reloadRow', 'loadColumn', 'reloadColumn', 'getRowNode', 'getColumnNode', 'getRowIndex', 'getVTRowIndex', 'getVMRowIndex', 'getColumnIndex', 'getVTColumnIndex', 'getVMColumnIndex', 'setRow', 'createData', 'createRow', 'revertData', 'clearData', 'isRemoveByRow', 'isInsertByRow', 'isUpdateByRow', 'getColumns', 'getColumnById', 'getColumnByField', 'getTableColumn', 'getFullColumns', 'getData', 'getCheckboxRecords', 'getParentRow', 'getTreeRowChildren', 'getTreeRowLevel', 'getTreeParentRow', 'getRowSeq', 'getRowById', 'getRowid', 'getTableData', 'getFullData', 'setColumnFixed', 'clearColumnFixed', 'setColumnWidth', 'getColumnWidth', 'recalcRowHeight', 'setRowHeightConf', 'getRowHeightConf', 'setRowHeight', 'getRowHeight', 'hideColumn', 'showColumn', 'resetColumn', 'refreshColumn', 'refreshScroll', 'recalculate', 'closeTooltip', 'isAllCheckboxChecked', 'isAllCheckboxIndeterminate', 'getCheckboxIndeterminateRecords', 'setCheckboxRow', 'setCheckboxRowKey', 'isCheckedByCheckboxRow', 'isCheckedByCheckboxRowKey', 'isIndeterminateByCheckboxRow', 'isIndeterminateByCheckboxRowKey', 'toggleCheckboxRow', 'setAllCheckboxRow', 'getRadioReserveRecord', 'clearRadioReserve', 'getCheckboxReserveRecords', 'clearCheckboxReserve', 'toggleAllCheckboxRow', 'clearCheckboxRow', 'setCurrentRow', 'isCheckedByRadioRow', 'isCheckedByRadioRowKey', 'setRadioRow', 'setRadioRowKey', 'clearCurrentRow', 'clearRadioRow', 'getCurrentRecord', 'getRadioRecord', 'getCurrentColumn', 'setCurrentColumn', 'clearCurrentColumn', 'setPendingRow', 'togglePendingRow', 'hasPendingByRow', 'isPendingByRow', 'getPendingRecords', 'clearPendingRow', 'setFilterByEvent', 'sort', 'setSort', 'setSortByEvent', 'clearSort', 'clearSortByEvent', 'isSort', 'getSortColumns', 'closeFilter', 'isFilter', 'clearFilterByEvent', 'isActiveFilterByColumn', 'isRowExpandLoaded', 'clearRowExpandLoaded', 'reloadRowExpand', 'reloadRowExpand', 'toggleRowExpand', 'setAllRowExpand', 'setRowExpand', 'isExpandByRow', 'isRowExpandByRow', 'clearRowExpand', 'clearRowExpandReserve', 'getRowExpandRecords', 'getTreeExpandRecords', 'isTreeExpandLoaded', 'clearTreeExpandLoaded', 'reloadTreeExpand', 'reloadTreeChilds', 'toggleTreeExpand', 'setAllTreeExpand', 'setTreeExpand', 'isTreeExpandByRow', 'clearTreeExpand', 'clearTreeExpandReserve', 'getScroll', 'scrollTo', 'scrollToRow', 'scrollToColumn', 'clearScroll', 'updateFooter', 'updateStatus', 'setMergeCells', 'removeInsertRow', 'removeMergeCells', 'getMergeCells', 'clearMergeCells', 'setMergeFooterItems', 'removeMergeFooterItems', 'getMergeFooterItems', 'clearMergeFooterItems', 'getCustomStoreData', 'setRowGroupExpand', 'setRowGroupExpandByField', 'setAllRowGroupExpand', 'clearRowGroupExpand', 'isRowGroupExpandByRow', 'isRowGroupRecord', 'isAggregateRecord', 'isAggregateExpandByRow', 'getAggregateContentByRow', 'getAggregateRowChildren', 'setRowGroups', 'clearRowGroups', 'openTooltip', 'moveColumnTo', 'moveRowTo', 'getCellLabel', 'getCellElement', 'focus', 'blur', 'connect']