vxe-gantt 4.0.23 → 4.0.24

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,6 +1,8 @@
1
1
  import { h, inject, VNode, ref, Ref, onMounted, onUnmounted } from 'vue'
2
2
  import { defineVxeComponent } from '../../ui/src/comp'
3
3
  import { getCellRestHeight } from './util'
4
+ import { getClass } from '../../ui/src/utils'
5
+ import XEUtils from 'xe-utils'
4
6
  import GanttViewChartComponent from './gantt-chart'
5
7
 
6
8
  import type { VxeTableConstructor, VxeTableMethods, VxeTablePrivateMethods, VxeTableDefines } from 'vxe-table'
@@ -39,9 +41,10 @@ export default defineVxeComponent({
39
41
  const { headerGroups } = reactData
40
42
  const { todayDateMaps } = internalData
41
43
  const taskViewOpts = computeTaskViewOpts.value
42
- const { showNowLine } = taskViewOpts
44
+ const { showNowLine, viewStyle } = taskViewOpts
43
45
  const { scaleItem } = headerGroups[headerGroups.length - 1] || {}
44
- const { field } = column
46
+ const { field, dateObj } = column
47
+ const { cellClassName, cellStyle } = viewStyle || {}
45
48
  const todayValue = showNowLine && scaleItem ? todayDateMaps[scaleItem.type] : null
46
49
 
47
50
  const rowRest = fullAllDataRowIdData[rowid] || {}
@@ -85,16 +88,24 @@ export default defineVxeComponent({
85
88
  })
86
89
  )
87
90
  }
88
- const ctParams = { source: sourceType, type: viewType, row, column, $rowIndex, rowIndex, _rowIndex }
91
+ const ctParams = { source: sourceType, type: viewType, dateObj, row, column, $rowIndex, rowIndex, _rowIndex }
89
92
  return h('td', {
90
93
  key: $columnIndex,
91
- class: ['vxe-gantt-view--body-column', {
92
- 'is--now': showNowLine && todayValue === field,
93
- 'col--rs-height': isRsHeight
94
- }],
95
- style: {
96
- height: `${cellHeight}px`
97
- },
94
+ class: [
95
+ 'vxe-gantt-view--body-column',
96
+ {
97
+ 'is--now': showNowLine && todayValue === field,
98
+ 'col--rs-height': isRsHeight
99
+ },
100
+ getClass(cellClassName, ctParams)
101
+ ],
102
+ style: cellStyle
103
+ ? Object.assign({}, XEUtils.isFunction(cellStyle) ? cellStyle(ctParams) : cellStyle, {
104
+ height: `${cellHeight}px`
105
+ })
106
+ : {
107
+ height: `${cellHeight}px`
108
+ },
98
109
  onClick (evnt) {
99
110
  $xeGantt.handleTaskCellClickEvent(evnt, { row, column })
100
111
  },
@@ -122,6 +133,10 @@ export default defineVxeComponent({
122
133
  const { transform } = treeOpts
123
134
  const childrenField = treeOpts.children || treeOpts.childrenField
124
135
 
136
+ const taskViewOpts = computeTaskViewOpts.value
137
+ const { viewStyle } = taskViewOpts
138
+ const { rowClassName, rowStyle } = viewStyle || {}
139
+
125
140
  const { tableColumn, scrollYLoad } = reactData
126
141
 
127
142
  const trVNs:VNode[] = []
@@ -155,17 +170,23 @@ export default defineVxeComponent({
155
170
  trOns.onDragend = $xeTable.handleRowDragDragendEvent
156
171
  trOns.onDragover = $xeTable.handleRowDragDragoverEvent
157
172
  }
173
+ const rowParams = { source: sourceType, type: viewType, row, rowIndex, $rowIndex, _rowIndex }
158
174
  trVNs.push(
159
175
  h('tr', {
160
176
  key: treeConfig ? rowid : $rowIndex,
161
- class: ['vxe-gantt-view--body-row', {
162
- 'row--stripe': stripe && (_rowIndex + 1) % 2 === 0,
163
- 'is--new': isNewRow,
164
- 'row--radio': radioOpts.highlight && $xeTable.eqRow(selectRadioRow, row),
165
- 'row--checked': checkboxOpts.highlight && $xeTable.isCheckedByCheckboxRow(row),
166
- 'row--pending': !!pendingRowFlag && !!pendingRowMaps[rowid]
167
- }],
177
+ class: [
178
+ 'vxe-gantt-view--body-row',
179
+ {
180
+ 'row--stripe': stripe && (_rowIndex + 1) % 2 === 0,
181
+ 'is--new': isNewRow,
182
+ 'row--radio': radioOpts.highlight && $xeTable.eqRow(selectRadioRow, row),
183
+ 'row--checked': checkboxOpts.highlight && $xeTable.isCheckedByCheckboxRow(row),
184
+ 'row--pending': !!pendingRowFlag && !!pendingRowMaps[rowid]
185
+ },
186
+ getClass(rowClassName, rowParams)
187
+ ],
168
188
  rowid,
189
+ style: rowStyle ? XEUtils.isFunction(rowStyle) ? rowStyle(rowParams) : rowStyle : undefined,
169
190
  ...trOns
170
191
  }, tableColumn.map((column, $columnIndex) => renderColumn($xeTable, row, rowid, rowIndex, $rowIndex, _rowIndex, column, $columnIndex)))
171
192
  )
@@ -12,6 +12,8 @@ import type { VxeGanttViewConstructor, GanttViewReactData, GanttViewPrivateRef,
12
12
 
13
13
  const { globalEvents } = VxeUI
14
14
 
15
+ const sourceType = 'gantt'
16
+
15
17
  function createInternalData (): GanttViewInternalData {
16
18
  return {
17
19
  xeTable: null,
@@ -855,8 +857,7 @@ export default defineVxeComponent({
855
857
  }, 200)
856
858
  }
857
859
 
858
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
859
- const handleScrollEvent = (evnt: Event, isRollY: boolean, isRollX: boolean, scrollTop: number, scrollLeft: number) => {
860
+ const handleScrollData = (isRollY: boolean, isRollX: boolean, scrollTop: number, scrollLeft: number) => {
860
861
  if (isRollX) {
861
862
  internalData.lastScrollLeft = scrollLeft
862
863
  }
@@ -867,6 +868,91 @@ export default defineVxeComponent({
867
868
  checkLastSyncScroll(isRollX, isRollY)
868
869
  }
869
870
 
871
+ const handleScrollEvent = (evnt: Event, isRollY: boolean, isRollX: boolean, scrollTop: number, scrollLeft: number) => {
872
+ const $xeTable = internalData.xeTable
873
+
874
+ const { lastScrollLeft, lastScrollTop } = internalData
875
+ const xHandleEl = refScrollXHandleElem.value
876
+ const yHandleEl = refScrollYHandleElem.value
877
+ if (!xHandleEl || !yHandleEl) {
878
+ return
879
+ }
880
+ if (!$xeTable) {
881
+ return
882
+ }
883
+ const { computeScrollXThreshold, computeScrollYThreshold } = $xeTable.getComputeMaps()
884
+ const bodyHeight = yHandleEl.clientHeight
885
+ const bodyWidth = xHandleEl.clientWidth
886
+ const scrollHeight = yHandleEl.scrollHeight
887
+ const scrollWidth = xHandleEl.scrollWidth
888
+ let isTop = false
889
+ let isBottom = false
890
+ let isLeft = false
891
+ let isRight = false
892
+ let direction = ''
893
+ let isTopBoundary = false
894
+ let isBottomBoundary = false
895
+ let isLeftBoundary = false
896
+ let isRightBoundary = false
897
+ if (isRollX) {
898
+ const xThreshold = computeScrollXThreshold.value
899
+ isLeft = scrollLeft <= 0
900
+ if (!isLeft) {
901
+ isRight = scrollLeft + bodyWidth >= scrollWidth - 1
902
+ }
903
+ if (scrollLeft > lastScrollLeft) {
904
+ direction = 'right'
905
+ if (scrollLeft + bodyWidth >= scrollWidth - xThreshold) {
906
+ isRightBoundary = true
907
+ }
908
+ } else {
909
+ direction = 'left'
910
+ if (scrollLeft <= xThreshold) {
911
+ isLeftBoundary = true
912
+ }
913
+ }
914
+ }
915
+ if (isRollY) {
916
+ const yThreshold = computeScrollYThreshold.value
917
+ isTop = scrollTop <= 0
918
+ if (!isTop) {
919
+ isBottom = scrollTop + bodyHeight >= scrollHeight - 1
920
+ }
921
+ if (scrollTop > lastScrollTop) {
922
+ direction = 'bottom'
923
+ if (scrollTop + bodyHeight >= scrollHeight - yThreshold) {
924
+ isBottomBoundary = true
925
+ }
926
+ } else {
927
+ direction = 'top'
928
+ if (scrollTop <= yThreshold) {
929
+ isTopBoundary = true
930
+ }
931
+ }
932
+ }
933
+ handleScrollData(isRollY, isRollX, scrollTop, scrollLeft)
934
+ const evntParams = {
935
+ source: sourceType,
936
+ scrollTop,
937
+ scrollLeft,
938
+ bodyHeight,
939
+ bodyWidth,
940
+ scrollHeight,
941
+ scrollWidth,
942
+ isX: isRollX,
943
+ isY: isRollY,
944
+ isTop,
945
+ isBottom,
946
+ isLeft,
947
+ isRight,
948
+ direction
949
+ }
950
+ if (isBottomBoundary || isTopBoundary || isRightBoundary || isLeftBoundary) {
951
+ $xeGantt.dispatchEvent('scroll-boundary', evntParams, evnt)
952
+ }
953
+ $xeGantt.dispatchEvent('scroll', evntParams, evnt)
954
+ }
955
+
870
956
  const ganttViewMethods: VxeGanttViewMethods = {
871
957
  refreshData () {
872
958
  handleUpdateData()
@@ -986,7 +1072,12 @@ export default defineVxeComponent({
986
1072
  triggerScrollXEvent()
987
1073
  }
988
1074
  }
989
- handleScrollEvent(evnt, isRollY, isRollX, wrapperEl.scrollTop, scrollLeft)
1075
+ if (isRollY) {
1076
+ handleScrollData(isRollY, isRollX, wrapperEl.scrollTop, scrollLeft)
1077
+ }
1078
+ if (isRollX) {
1079
+ handleScrollEvent(evnt, isRollY, isRollX, wrapperEl.scrollTop, scrollLeft)
1080
+ }
990
1081
  },
991
1082
  // triggerFooterScrollEvent (evnt) {
992
1083
  // const { inVirtualScroll, inHeaderScroll, inBodyScroll } = internalData
@@ -1040,7 +1131,7 @@ export default defineVxeComponent({
1040
1131
  internalData.inVirtualScroll = true
1041
1132
  setScrollTop(bodyScrollElem, currTopNum)
1042
1133
  syncTableScrollTop(currTopNum)
1043
- handleScrollEvent(evnt, isRollY, isRollX, currTopNum, wrapperEl.scrollLeft)
1134
+ handleScrollData(isRollY, isRollX, currTopNum, wrapperEl.scrollLeft)
1044
1135
  }
1045
1136
  },
1046
1137
  handleUpdateSXSpace () {
@@ -52,3 +52,7 @@ export function eqEmptyValue (cellValue: any) {
52
52
  export function getStringValue (cellValue: any) {
53
53
  return eqEmptyValue(cellValue) ? '' : cellValue
54
54
  }
55
+
56
+ export function getClass (property: any, params: any) {
57
+ return property ? XEUtils.isFunction(property) ? property(params) : property : ''
58
+ }