vxe-gantt 3.0.27 → 3.1.0
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.
- package/es/gantt/src/gantt-header.js +11 -2
- package/es/gantt/src/gantt-view.js +306 -45
- package/es/gantt/src/gantt.js +18 -0
- package/es/gantt/src/util.js +11 -0
- package/es/ui/index.js +1 -1
- package/es/ui/src/log.js +1 -1
- package/lib/gantt/src/gantt-header.js +9 -1
- package/lib/gantt/src/gantt-header.min.js +1 -1
- package/lib/gantt/src/gantt-view.js +341 -49
- package/lib/gantt/src/gantt-view.min.js +1 -1
- package/lib/gantt/src/gantt.js +20 -0
- package/lib/gantt/src/gantt.min.js +1 -1
- package/lib/gantt/src/util.js +12 -0
- package/lib/gantt/src/util.min.js +1 -1
- package/lib/index.umd.js +389 -56
- package/lib/index.umd.min.js +1 -1
- package/lib/ui/index.js +1 -1
- package/lib/ui/index.min.js +1 -1
- package/lib/ui/src/log.js +1 -1
- package/lib/ui/src/log.min.js +1 -1
- package/package.json +3 -3
- package/packages/gantt/src/gantt-header.ts +9 -2
- package/packages/gantt/src/gantt-view.ts +316 -47
- package/packages/gantt/src/gantt.ts +21 -0
- package/packages/gantt/src/util.ts +13 -0
package/lib/ui/index.js
CHANGED
|
@@ -15,7 +15,7 @@ var _log = require("./src/log");
|
|
|
15
15
|
var setConfig = _core.VxeUI.setConfig,
|
|
16
16
|
setIcon = _core.VxeUI.setIcon,
|
|
17
17
|
checkVersion = _core.VxeUI.checkVersion;
|
|
18
|
-
_core.VxeUI.ganttVersion = "3.0
|
|
18
|
+
_core.VxeUI.ganttVersion = "3.1.0";
|
|
19
19
|
setConfig({
|
|
20
20
|
gantt: {
|
|
21
21
|
// size: null,
|
package/lib/ui/index.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"VxeUI",{enumerable:!0,get:function(){return _core.VxeUI}}),exports.default=void 0;var _core=require("@vxe-ui/core"),_log=require("./src/log"),setConfig=_core.VxeUI.setConfig,setIcon=_core.VxeUI.setIcon,checkVersion=_core.VxeUI.checkVersion,iconPrefix=(_core.VxeUI.ganttVersion="3.0
|
|
1
|
+
Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"VxeUI",{enumerable:!0,get:function(){return _core.VxeUI}}),exports.default=void 0;var _core=require("@vxe-ui/core"),_log=require("./src/log"),setConfig=_core.VxeUI.setConfig,setIcon=_core.VxeUI.setIcon,checkVersion=_core.VxeUI.checkVersion,iconPrefix=(_core.VxeUI.ganttVersion="3.1.0",setConfig({gantt:{formConfig:{enabled:!0},pagerConfig:{enabled:!0},toolbarConfig:{enabled:!0},proxyConfig:{enabled:!0,autoLoad:!0,showLoading:!0,showResponseMsg:!0,showActionMsg:!0,response:{list:null,result:"result",total:"page.total",message:"message"}},taskViewScaleConfig:{week:{startDay:1}},taskViewConfig:{showNowLine:!0},taskSplitConfig:{enabled:!0,resize:!0,showCollapseTableButton:!0,showCollapseTaskButton:!0}}}),"vxe-icon-"),pVersion=(setIcon({GANTT_VIEW_LEFT_OPEN:iconPrefix+"arrow-left",GANTT_VIEW_LEFT_CLOSE:iconPrefix+"arrow-right",GANTT_VIEW_RIGHT_OPEN:iconPrefix+"arrow-right",GANTT_VIEW_RIGHT_CLOSE:iconPrefix+"arrow-left"}),3),sVersion=18,_default=(checkVersion?checkVersion(_core.VxeUI.tableVersion,pVersion,sVersion)||(0,_log.errLog)("vxe.error.errorVersion",["vxe-table@".concat(_core.VxeUI.tableVersion||"?"),"vxe-table v".concat(pVersion,".").concat(sVersion,"+")]):(0,_log.errLog)("Requires vxe-table v".concat(pVersion,".").concat(sVersion,"+")),exports.default=_core.VxeUI);
|
package/lib/ui/src/log.js
CHANGED
|
@@ -6,6 +6,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.warnLog = exports.errLog = void 0;
|
|
7
7
|
var _core = require("@vxe-ui/core");
|
|
8
8
|
var log = _core.VxeUI.log;
|
|
9
|
-
var version = "gantt v".concat("3.0
|
|
9
|
+
var version = "gantt v".concat("3.1.0");
|
|
10
10
|
var warnLog = exports.warnLog = log.create('warn', version);
|
|
11
11
|
var errLog = exports.errLog = log.create('error', version);
|
package/lib/ui/src/log.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,"__esModule",{value:!0}),exports.warnLog=exports.errLog=void 0;var _core=require("@vxe-ui/core"),log=_core.VxeUI.log,version="gantt v".concat("3.0
|
|
1
|
+
Object.defineProperty(exports,"__esModule",{value:!0}),exports.warnLog=exports.errLog=void 0;var _core=require("@vxe-ui/core"),log=_core.VxeUI.log,version="gantt v".concat("3.1.0"),warnLog=exports.warnLog=log.create("warn",version),errLog=exports.errLog=log.create("error",version);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vxe-gantt",
|
|
3
|
-
"version": "3.0
|
|
3
|
+
"version": "3.1.0",
|
|
4
4
|
"description": "A vue based gantt component",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"update": "npm install --legacy-peer-deps",
|
|
@@ -64,8 +64,8 @@
|
|
|
64
64
|
"vue": "~2.6.14",
|
|
65
65
|
"vue-i18n": "^8.15.1",
|
|
66
66
|
"vue-router": "^3.5.1",
|
|
67
|
-
"vxe-pc-ui": "^3.10.
|
|
68
|
-
"vxe-table": "^3.19.
|
|
67
|
+
"vxe-pc-ui": "^3.10.43",
|
|
68
|
+
"vxe-table": "^3.19.26"
|
|
69
69
|
},
|
|
70
70
|
"vetur": {
|
|
71
71
|
"tags": "helper/vetur/tags.json",
|
|
@@ -70,9 +70,10 @@ export default defineVxeComponent({
|
|
|
70
70
|
})
|
|
71
71
|
})),
|
|
72
72
|
h('thead', {}, headerGroups.map(({ scaleItem, columns }, $rowIndex) => {
|
|
73
|
-
const { type, titleMethod, headerCellStyle, slots } = scaleItem
|
|
73
|
+
const { type, titleFormat, titleMethod, headerCellStyle, slots } = scaleItem
|
|
74
74
|
const titleSlot = slots ? slots.title : null
|
|
75
|
-
const
|
|
75
|
+
const isLast = $rowIndex === headerGroups.length - 1
|
|
76
|
+
const todayValue = isLast && showNowLine ? todayDateMaps[type] : null
|
|
76
77
|
return h('tr', {
|
|
77
78
|
key: $rowIndex
|
|
78
79
|
}, columns.map((column, cIndex) => {
|
|
@@ -84,6 +85,10 @@ export default defineVxeComponent({
|
|
|
84
85
|
} else {
|
|
85
86
|
label = getI18n(`vxe.gantt.${!$rowIndex && headerGroups.length > 1 ? 'tFullFormat' : 'tSimpleFormat'}.${type}`, dateObj)
|
|
86
87
|
}
|
|
88
|
+
} else {
|
|
89
|
+
if (isLast && scaleItem.type === 'week') {
|
|
90
|
+
label = getI18n(`vxe.gantt.tSimpleFormat.${type}`, dateObj)
|
|
91
|
+
}
|
|
87
92
|
}
|
|
88
93
|
let cellVNs: string | VxeComponentSlotType[] = label
|
|
89
94
|
const ctParams = { source: sourceType, type: viewType, column, scaleObj: scaleItem, title: label, dateObj: dateObj, $rowIndex }
|
|
@@ -91,6 +96,8 @@ export default defineVxeComponent({
|
|
|
91
96
|
cellVNs = $xeGantt.callSlot(titleSlot, ctParams, h)
|
|
92
97
|
} else if (titleMethod) {
|
|
93
98
|
cellVNs = `${titleMethod(ctParams)}`
|
|
99
|
+
} else if (titleFormat) {
|
|
100
|
+
cellVNs = XEUtils.toDateString(dateObj.date, titleFormat)
|
|
94
101
|
}
|
|
95
102
|
let cellStys = {}
|
|
96
103
|
if (headerCellStyle) {
|
|
@@ -2,7 +2,7 @@ import { VNode, CreateElement } from 'vue'
|
|
|
2
2
|
import { defineVxeComponent } from '../../ui/src/comp'
|
|
3
3
|
import { VxeUI } from '@vxe-ui/core'
|
|
4
4
|
import { setScrollTop, setScrollLeft, removeClass, addClass } from '../../ui/src/dom'
|
|
5
|
-
import { getRefElem } from './util'
|
|
5
|
+
import { getRefElem, getStandardGapTime } from './util'
|
|
6
6
|
import XEUtils from 'xe-utils'
|
|
7
7
|
import GanttViewHeaderComponent from './gantt-header'
|
|
8
8
|
import GanttViewBodyComponent from './gantt-body'
|
|
@@ -14,6 +14,8 @@ import type { VxeGanttViewConstructor, GanttViewReactData, VxeGanttDefines, VxeG
|
|
|
14
14
|
const { globalEvents } = VxeUI
|
|
15
15
|
|
|
16
16
|
const sourceType = 'gantt'
|
|
17
|
+
const minuteMs = 1000 * 60
|
|
18
|
+
const dayMs = minuteMs * 60 * 24
|
|
17
19
|
|
|
18
20
|
function createInternalData (): GanttViewInternalData {
|
|
19
21
|
return {
|
|
@@ -76,41 +78,19 @@ function updateTodayData ($xeGanttView: VxeGanttViewConstructor & VxeGanttViewPr
|
|
|
76
78
|
}
|
|
77
79
|
}
|
|
78
80
|
|
|
79
|
-
function
|
|
81
|
+
function handleColumnHeader ($xeGanttView: VxeGanttViewConstructor & VxeGanttViewPrivateMethods) {
|
|
80
82
|
const $xeGantt = $xeGanttView.$xeGantt
|
|
81
|
-
const reactData = $xeGanttView.reactData
|
|
82
|
-
const internalData = $xeGanttView.internalData
|
|
83
83
|
|
|
84
|
-
const ganttProps = $xeGantt
|
|
85
84
|
const ganttReactData = $xeGantt.reactData
|
|
86
|
-
const { treeConfig } = ganttProps
|
|
87
85
|
const { taskScaleList } = ganttReactData
|
|
88
|
-
const
|
|
89
|
-
const minScale =
|
|
86
|
+
const scaleUnit = $xeGantt.computeScaleUnit
|
|
87
|
+
const minScale = $xeGantt.computeMinScale
|
|
88
|
+
const weekScale = $xeGantt.computeWeekScale
|
|
89
|
+
const scaleDateList = $xeGanttView.computeScaleDateList
|
|
90
90
|
const fullCols: VxeGanttDefines.ViewColumn[] = []
|
|
91
91
|
const groupCols: VxeGanttDefines.GroupColumn[] = []
|
|
92
|
-
if (minScale && minViewDate && maxViewDate) {
|
|
93
|
-
const minSType = minScale.type
|
|
94
|
-
const weekScale = taskScaleList.find(item => item.type === 'week')
|
|
95
|
-
let gapTime = 1000 * 60 * 60 * 24
|
|
96
|
-
switch (minScale.type) {
|
|
97
|
-
case 'hour':
|
|
98
|
-
gapTime = 1000 * 60 * 60
|
|
99
|
-
break
|
|
100
|
-
case 'minute':
|
|
101
|
-
gapTime = 1000 * 60
|
|
102
|
-
break
|
|
103
|
-
case 'second':
|
|
104
|
-
gapTime = 1000
|
|
105
|
-
break
|
|
106
|
-
default: {
|
|
107
|
-
break
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
const currTime = minViewDate.getTime()
|
|
111
|
-
const diffDayNum = maxViewDate.getTime() - minViewDate.getTime()
|
|
112
|
-
const countSize = Math.max(5, Math.floor(diffDayNum / gapTime) + 1)
|
|
113
92
|
|
|
93
|
+
if (minScale && scaleUnit && scaleDateList.length) {
|
|
114
94
|
const renderListMaps: Record<VxeGanttDefines.ColumnScaleType, VxeGanttDefines.ViewColumn[]> = {
|
|
115
95
|
year: [],
|
|
116
96
|
quarter: [],
|
|
@@ -136,7 +116,7 @@ function handleParseColumn ($xeGanttView: VxeGanttViewConstructor & VxeGanttView
|
|
|
136
116
|
}
|
|
137
117
|
|
|
138
118
|
const handleData = (type: VxeGanttDefines.ColumnScaleType, colMaps: Record<VxeGanttDefines.ColumnScaleType, VxeGanttDefines.ViewColumn>, minCol: VxeGanttDefines.ViewColumn) => {
|
|
139
|
-
if (
|
|
119
|
+
if (minScale.type === type) {
|
|
140
120
|
return
|
|
141
121
|
}
|
|
142
122
|
const currCol = colMaps[type]
|
|
@@ -154,14 +134,15 @@ function handleParseColumn ($xeGanttView: VxeGanttViewConstructor & VxeGanttView
|
|
|
154
134
|
currGpCol.children.push(minCol)
|
|
155
135
|
}
|
|
156
136
|
}
|
|
157
|
-
|
|
158
|
-
|
|
137
|
+
|
|
138
|
+
for (let i = 0; i < scaleDateList.length; i++) {
|
|
139
|
+
const itemDate = scaleDateList[i]
|
|
159
140
|
const [yyyy, MM, dd, HH, mm, ss] = XEUtils.toDateString(itemDate, 'yyyy-M-d-H-m-s').split('-')
|
|
160
141
|
const e = itemDate.getDay()
|
|
161
142
|
const E = e + 1
|
|
162
143
|
const q = Math.ceil((itemDate.getMonth() + 1) / 3)
|
|
163
144
|
const W = XEUtils.getYearWeek(itemDate, weekScale ? weekScale.startDay : undefined)
|
|
164
|
-
const dateObj: VxeGanttDefines.ScaleDateObj = { yy: yyyy, M: MM, d: dd, H: HH, m: mm, s: ss, q, W, E, e }
|
|
145
|
+
const dateObj: VxeGanttDefines.ScaleDateObj = { date: itemDate, yy: yyyy, M: MM, d: dd, H: HH, m: mm, s: ss, q, W, E, e }
|
|
165
146
|
const colMaps: Record<VxeGanttDefines.ColumnScaleType, VxeGanttDefines.ViewColumn> = {
|
|
166
147
|
year: {
|
|
167
148
|
field: yyyy,
|
|
@@ -209,7 +190,7 @@ function handleParseColumn ($xeGanttView: VxeGanttViewConstructor & VxeGanttView
|
|
|
209
190
|
dateObj
|
|
210
191
|
}
|
|
211
192
|
}
|
|
212
|
-
const minCol = colMaps[
|
|
193
|
+
const minCol = colMaps[minScale.type]
|
|
213
194
|
if (minScale.level < 19) {
|
|
214
195
|
handleData('year', colMaps, minCol)
|
|
215
196
|
}
|
|
@@ -239,7 +220,7 @@ function handleParseColumn ($xeGanttView: VxeGanttViewConstructor & VxeGanttView
|
|
|
239
220
|
}
|
|
240
221
|
|
|
241
222
|
taskScaleList.forEach(scaleItem => {
|
|
242
|
-
if (scaleItem.type ===
|
|
223
|
+
if (scaleItem.type === minScale.type) {
|
|
243
224
|
groupCols.push({
|
|
244
225
|
scaleItem,
|
|
245
226
|
columns: fullCols
|
|
@@ -258,7 +239,221 @@ function handleParseColumn ($xeGanttView: VxeGanttViewConstructor & VxeGanttView
|
|
|
258
239
|
columns: list
|
|
259
240
|
})
|
|
260
241
|
})
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
return {
|
|
245
|
+
fullCols,
|
|
246
|
+
groupCols
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
function createChartRender ($xeGanttView: VxeGanttViewConstructor & VxeGanttViewPrivateMethods, fullCols: VxeGanttDefines.ViewColumn[]) {
|
|
251
|
+
const $xeGantt = $xeGanttView.$xeGantt
|
|
252
|
+
const reactData = $xeGanttView.reactData
|
|
253
|
+
|
|
254
|
+
const { minViewDate } = reactData
|
|
255
|
+
const minScale = $xeGantt.computeMinScale
|
|
256
|
+
const scaleUnit = $xeGantt.computeScaleUnit
|
|
257
|
+
const weekScale = $xeGantt.computeWeekScale
|
|
258
|
+
switch (scaleUnit) {
|
|
259
|
+
case 'year': {
|
|
260
|
+
const indexMaps: Record<string, number> = {}
|
|
261
|
+
fullCols.forEach(({ dateObj }, i) => {
|
|
262
|
+
const yyyyMM = XEUtils.toDateString(dateObj.date, 'yyyy')
|
|
263
|
+
indexMaps[yyyyMM] = i
|
|
264
|
+
})
|
|
265
|
+
return (startValue: any, endValue: any) => {
|
|
266
|
+
const startDate = parseStringDate($xeGanttView, startValue)
|
|
267
|
+
const endDate = parseStringDate($xeGanttView, endValue)
|
|
268
|
+
const startStr = XEUtils.toDateString(startDate, 'yyyy')
|
|
269
|
+
const startFirstDate = XEUtils.getWhatYear(startDate, 0, 'first')
|
|
270
|
+
const endStr = XEUtils.toDateString(endDate, 'yyyy')
|
|
271
|
+
const endFirstDate = XEUtils.getWhatYear(endDate, 0, 'first')
|
|
272
|
+
const dateSize = Math.floor((XEUtils.getWhatYear(endDate, 1, 'first').getTime() - endFirstDate.getTime()) / dayMs)
|
|
273
|
+
const subtract = (startDate.getTime() - startFirstDate.getTime()) / dayMs / dateSize
|
|
274
|
+
const addSize = Math.max(0, (endDate.getTime() - endFirstDate.getTime()) / dayMs + 1) / dateSize
|
|
275
|
+
const offsetLeftSize = (indexMaps[startStr] || 0) + subtract
|
|
276
|
+
return {
|
|
277
|
+
offsetLeftSize,
|
|
278
|
+
offsetWidthSize: (indexMaps[endStr] || 0) - offsetLeftSize + addSize
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
case 'quarter': {
|
|
283
|
+
const indexMaps: Record<string, number> = {}
|
|
284
|
+
fullCols.forEach(({ dateObj }, i) => {
|
|
285
|
+
const q = XEUtils.toDateString(dateObj.date, 'yyyy-q')
|
|
286
|
+
indexMaps[q] = i
|
|
287
|
+
})
|
|
288
|
+
return (startValue: any, endValue: any) => {
|
|
289
|
+
const startDate = parseStringDate($xeGanttView, startValue)
|
|
290
|
+
const endDate = parseStringDate($xeGanttView, endValue)
|
|
291
|
+
const startStr = XEUtils.toDateString(startDate, 'yyyy-q')
|
|
292
|
+
const startFirstDate = XEUtils.getWhatQuarter(startDate, 0, 'first')
|
|
293
|
+
const endStr = XEUtils.toDateString(endDate, 'yyyy-q')
|
|
294
|
+
const endFirstDate = XEUtils.getWhatQuarter(endDate, 0, 'first')
|
|
295
|
+
const dateSize = Math.floor((XEUtils.getWhatQuarter(endDate, 1, 'first').getTime() - endFirstDate.getTime()) / dayMs)
|
|
296
|
+
const subtract = (startDate.getTime() - startFirstDate.getTime()) / dayMs / dateSize
|
|
297
|
+
const addSize = Math.max(0, (endDate.getTime() - endFirstDate.getTime()) / dayMs + 1) / dateSize
|
|
298
|
+
const offsetLeftSize = (indexMaps[startStr] || 0) + subtract
|
|
299
|
+
return {
|
|
300
|
+
offsetLeftSize,
|
|
301
|
+
offsetWidthSize: (indexMaps[endStr] || 0) - offsetLeftSize + addSize
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
case 'month': {
|
|
306
|
+
const indexMaps: Record<string, number> = {}
|
|
307
|
+
fullCols.forEach(({ dateObj }, i) => {
|
|
308
|
+
const yyyyMM = XEUtils.toDateString(dateObj.date, 'yyyy-MM')
|
|
309
|
+
indexMaps[yyyyMM] = i
|
|
310
|
+
})
|
|
311
|
+
return (startValue: any, endValue: any) => {
|
|
312
|
+
const startDate = parseStringDate($xeGanttView, startValue)
|
|
313
|
+
const endDate = parseStringDate($xeGanttView, endValue)
|
|
314
|
+
const startStr = XEUtils.toDateString(startDate, 'yyyy-MM')
|
|
315
|
+
const startFirstDate = XEUtils.getWhatMonth(startDate, 0, 'first')
|
|
316
|
+
const endStr = XEUtils.toDateString(endDate, 'yyyy-MM')
|
|
317
|
+
const endFirstDate = XEUtils.getWhatMonth(endDate, 0, 'first')
|
|
318
|
+
const dateSize = Math.floor((XEUtils.getWhatMonth(endDate, 1, 'first').getTime() - endFirstDate.getTime()) / dayMs)
|
|
319
|
+
const subtract = (startDate.getTime() - startFirstDate.getTime()) / dayMs / dateSize
|
|
320
|
+
const addSize = Math.max(0, (endDate.getTime() - endFirstDate.getTime()) / dayMs + 1) / dateSize
|
|
321
|
+
const offsetLeftSize = (indexMaps[startStr] || 0) + subtract
|
|
322
|
+
return {
|
|
323
|
+
offsetLeftSize,
|
|
324
|
+
offsetWidthSize: (indexMaps[endStr] || 0) - offsetLeftSize + addSize
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
case 'week': {
|
|
329
|
+
const indexMaps: Record<string, number> = {}
|
|
330
|
+
fullCols.forEach(({ dateObj }, i) => {
|
|
331
|
+
const yyyyW = XEUtils.toDateString(dateObj.date, 'yyyy-W', { firstDay: weekScale ? weekScale.startDay : undefined })
|
|
332
|
+
indexMaps[yyyyW] = i
|
|
333
|
+
})
|
|
334
|
+
return (startValue: any, endValue: any) => {
|
|
335
|
+
const startDate = parseStringDate($xeGanttView, startValue)
|
|
336
|
+
const endDate = parseStringDate($xeGanttView, endValue)
|
|
337
|
+
const startStr = XEUtils.toDateString(startDate, 'yyyy-W', { firstDay: weekScale ? weekScale.startDay : undefined })
|
|
338
|
+
const startFirstDate = XEUtils.getWhatWeek(startDate, 0, weekScale ? weekScale.startDay : undefined, weekScale ? weekScale.startDay : undefined)
|
|
339
|
+
const endStr = XEUtils.toDateString(endDate, 'yyyy-W', { firstDay: weekScale ? weekScale.startDay : undefined })
|
|
340
|
+
const endFirstDate = XEUtils.getWhatWeek(endDate, 0, weekScale ? weekScale.startDay : undefined, weekScale ? weekScale.startDay : undefined)
|
|
341
|
+
const dateSize = Math.floor((XEUtils.getWhatWeek(endDate, 1, weekScale ? weekScale.startDay : undefined, weekScale ? weekScale.startDay : undefined).getTime() - endFirstDate.getTime()) / dayMs)
|
|
342
|
+
const subtract = (startDate.getTime() - startFirstDate.getTime()) / dayMs / dateSize
|
|
343
|
+
const addSize = Math.max(0, (endDate.getTime() - endFirstDate.getTime()) / dayMs + 1) / dateSize
|
|
344
|
+
const offsetLeftSize = (indexMaps[startStr] || 0) + subtract
|
|
345
|
+
return {
|
|
346
|
+
offsetLeftSize,
|
|
347
|
+
offsetWidthSize: (indexMaps[endStr] || 0) - offsetLeftSize + addSize
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
case 'day':
|
|
352
|
+
case 'date': {
|
|
353
|
+
const indexMaps: Record<string, number> = {}
|
|
354
|
+
fullCols.forEach(({ dateObj }, i) => {
|
|
355
|
+
const yyyyMM = XEUtils.toDateString(dateObj.date, 'yyyy-MM-dd')
|
|
356
|
+
indexMaps[yyyyMM] = i
|
|
357
|
+
})
|
|
358
|
+
return (startValue: any, endValue: any) => {
|
|
359
|
+
const startDate = parseStringDate($xeGanttView, startValue)
|
|
360
|
+
const endDate = parseStringDate($xeGanttView, endValue)
|
|
361
|
+
const startStr = XEUtils.toDateString(startDate, 'yyyy-MM-dd')
|
|
362
|
+
const startFirstDate = XEUtils.getWhatDay(startDate, 0, 'first')
|
|
363
|
+
const endStr = XEUtils.toDateString(endDate, 'yyyy-MM-dd')
|
|
364
|
+
const endFirstDate = XEUtils.getWhatDay(endDate, 0, 'first')
|
|
365
|
+
const minuteSize = Math.floor((XEUtils.getWhatDay(endDate, 1, 'first').getTime() - endFirstDate.getTime()) / minuteMs)
|
|
366
|
+
const subtract = (startDate.getTime() - startFirstDate.getTime()) / minuteMs / minuteSize
|
|
367
|
+
const addSize = Math.max(0, (endDate.getTime() - endFirstDate.getTime()) / minuteMs + 1) / minuteSize
|
|
368
|
+
const offsetLeftSize = (indexMaps[startStr] || 0) + subtract
|
|
369
|
+
return {
|
|
370
|
+
offsetLeftSize,
|
|
371
|
+
offsetWidthSize: (indexMaps[endStr] || 0) - offsetLeftSize + addSize
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
case 'hour': {
|
|
376
|
+
const indexMaps: Record<string, number> = {}
|
|
377
|
+
fullCols.forEach(({ dateObj }, i) => {
|
|
378
|
+
const yyyyMM = XEUtils.toDateString(dateObj.date, 'yyyy-MM-dd HH')
|
|
379
|
+
indexMaps[yyyyMM] = i
|
|
380
|
+
})
|
|
381
|
+
return (startValue: any, endValue: any) => {
|
|
382
|
+
const startDate = parseStringDate($xeGanttView, startValue)
|
|
383
|
+
const endDate = parseStringDate($xeGanttView, endValue)
|
|
384
|
+
const startStr = XEUtils.toDateString(startDate, 'yyyy-MM-dd HH')
|
|
385
|
+
const startFirstDate = XEUtils.getWhatHours(startDate, 0, 'first')
|
|
386
|
+
const endStr = XEUtils.toDateString(endDate, 'yyyy-MM-dd HH')
|
|
387
|
+
const endFirstDate = XEUtils.getWhatHours(endDate, 0, 'first')
|
|
388
|
+
const minuteSize = Math.floor((XEUtils.getWhatHours(endDate, 1, 'first').getTime() - endFirstDate.getTime()) / minuteMs)
|
|
389
|
+
const subtract = (startDate.getTime() - startFirstDate.getTime()) / minuteMs / minuteSize
|
|
390
|
+
const addSize = Math.max(0, (endDate.getTime() - endFirstDate.getTime()) / minuteMs + 1) / minuteSize
|
|
391
|
+
const offsetLeftSize = (indexMaps[startStr] || 0) + subtract
|
|
392
|
+
return {
|
|
393
|
+
offsetLeftSize,
|
|
394
|
+
offsetWidthSize: (indexMaps[endStr] || 0) - offsetLeftSize + addSize
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
case 'minute': {
|
|
399
|
+
const indexMaps: Record<string, number> = {}
|
|
400
|
+
fullCols.forEach(({ dateObj }, i) => {
|
|
401
|
+
const yyyyMM = XEUtils.toDateString(dateObj.date, 'yyyy-MM-dd HH:mm')
|
|
402
|
+
indexMaps[yyyyMM] = i
|
|
403
|
+
})
|
|
404
|
+
return (startValue: any, endValue: any) => {
|
|
405
|
+
const startDate = parseStringDate($xeGanttView, startValue)
|
|
406
|
+
const endDate = parseStringDate($xeGanttView, endValue)
|
|
407
|
+
const startStr = XEUtils.toDateString(startDate, 'yyyy-MM-dd HH:mm')
|
|
408
|
+
const startFirstDate = XEUtils.getWhatMinutes(startDate, 0, 'first')
|
|
409
|
+
const endStr = XEUtils.toDateString(endDate, 'yyyy-MM-dd HH:mm')
|
|
410
|
+
const endFirstDate = XEUtils.getWhatMinutes(endDate, 0, 'first')
|
|
411
|
+
const minuteSize = Math.floor((XEUtils.getWhatMinutes(endDate, 1, 'first').getTime() - endFirstDate.getTime()) / minuteMs)
|
|
412
|
+
const subtract = (startDate.getTime() - startFirstDate.getTime()) / minuteMs / minuteSize
|
|
413
|
+
const addSize = Math.max(0, (endDate.getTime() - endFirstDate.getTime()) / minuteMs + 1) / minuteSize
|
|
414
|
+
const offsetLeftSize = (indexMaps[startStr] || 0) + subtract
|
|
415
|
+
return {
|
|
416
|
+
offsetLeftSize,
|
|
417
|
+
offsetWidthSize: (indexMaps[endStr] || 0) - offsetLeftSize + addSize
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
case 'second': {
|
|
422
|
+
const gapTime = getStandardGapTime(minScale.type)
|
|
423
|
+
return (startValue: any, endValue: any) => {
|
|
424
|
+
const startDate = parseStringDate($xeGanttView, startValue)
|
|
425
|
+
const endDate = parseStringDate($xeGanttView, endValue)
|
|
426
|
+
let offsetLeftSize = 0
|
|
427
|
+
let offsetWidthSize = 0
|
|
428
|
+
if (minViewDate) {
|
|
429
|
+
offsetLeftSize = (startDate.getTime() - minViewDate.getTime()) / gapTime
|
|
430
|
+
offsetWidthSize = ((endDate.getTime() - startDate.getTime()) / gapTime) + 1
|
|
431
|
+
}
|
|
432
|
+
return {
|
|
433
|
+
offsetLeftSize,
|
|
434
|
+
offsetWidthSize
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
return () => {
|
|
440
|
+
return {
|
|
441
|
+
offsetLeftSize: 0,
|
|
442
|
+
offsetWidthSize: 0
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
}
|
|
261
446
|
|
|
447
|
+
function handleParseColumn ($xeGanttView: VxeGanttViewConstructor & VxeGanttViewPrivateMethods) {
|
|
448
|
+
const $xeGantt = $xeGanttView.$xeGantt
|
|
449
|
+
const reactData = $xeGanttView.reactData
|
|
450
|
+
const internalData = $xeGanttView.internalData
|
|
451
|
+
|
|
452
|
+
const ganttProps = $xeGantt
|
|
453
|
+
const { treeConfig } = ganttProps
|
|
454
|
+
const { minViewDate, maxViewDate } = reactData
|
|
455
|
+
const { fullCols, groupCols } = handleColumnHeader($xeGanttView)
|
|
456
|
+
if (minViewDate && maxViewDate) {
|
|
262
457
|
const $xeTable = internalData.xeTable
|
|
263
458
|
if ($xeTable) {
|
|
264
459
|
const startField = $xeGantt.computeStartField
|
|
@@ -273,32 +468,30 @@ function handleParseColumn ($xeGanttView: VxeGanttViewConstructor & VxeGanttView
|
|
|
273
468
|
const childrenField = treeOpts.children || treeOpts.childrenField
|
|
274
469
|
|
|
275
470
|
const ctMaps: Record<string, VxeGanttDefines.RowCacheItem> = {}
|
|
471
|
+
const renderFn = createChartRender($xeGanttView, fullCols)
|
|
276
472
|
const handleParseRender = (row: any) => {
|
|
277
473
|
const rowid = $xeTable.getRowid(row)
|
|
278
474
|
const startValue = XEUtils.get(row, startField)
|
|
279
475
|
const endValue = XEUtils.get(row, endField)
|
|
280
476
|
if (startValue && endValue) {
|
|
281
|
-
const
|
|
282
|
-
const endDate = parseStringDate($xeGanttView, endValue)
|
|
283
|
-
const oLeftSize = Math.floor((startDate.getTime() - minViewDate.getTime()) / gapTime)
|
|
284
|
-
const oWidthSize = Math.floor((endDate.getTime() - startDate.getTime()) / gapTime) + 1
|
|
477
|
+
const { offsetLeftSize, offsetWidthSize } = renderFn(startValue, endValue)
|
|
285
478
|
ctMaps[rowid] = {
|
|
286
479
|
row,
|
|
287
480
|
rowid,
|
|
288
|
-
oLeftSize,
|
|
289
|
-
oWidthSize
|
|
481
|
+
oLeftSize: offsetLeftSize,
|
|
482
|
+
oWidthSize: offsetWidthSize
|
|
290
483
|
}
|
|
291
484
|
}
|
|
292
485
|
}
|
|
293
486
|
|
|
294
487
|
if (isRowGroupStatus) {
|
|
295
|
-
|
|
488
|
+
// 行分组
|
|
296
489
|
const mapChildrenField = aggregateOpts.mapChildrenField
|
|
297
490
|
if (mapChildrenField) {
|
|
298
491
|
XEUtils.eachTree(afterGroupFullData, handleParseRender, { children: mapChildrenField })
|
|
299
492
|
}
|
|
300
493
|
} else if (treeConfig) {
|
|
301
|
-
|
|
494
|
+
// 树结构
|
|
302
495
|
XEUtils.eachTree(afterTreeFullData, handleParseRender, { children: transform ? treeOpts.mapChildrenField : childrenField })
|
|
303
496
|
} else {
|
|
304
497
|
afterFullData.forEach(handleParseRender)
|
|
@@ -572,10 +765,10 @@ function handleLazyRecalculate ($xeGanttView: VxeGanttViewConstructor & VxeGantt
|
|
|
572
765
|
return new Promise<void>(resolve => {
|
|
573
766
|
const { rceTimeout, rceRunTime } = internalData
|
|
574
767
|
const $xeTable = internalData.xeTable
|
|
575
|
-
let refreshDelay =
|
|
768
|
+
let refreshDelay = 30
|
|
576
769
|
if ($xeTable) {
|
|
577
770
|
const resizeOpts = $xeTable.computeResizeOpts
|
|
578
|
-
refreshDelay = resizeOpts.refreshDelay ||
|
|
771
|
+
refreshDelay = resizeOpts.refreshDelay || refreshDelay
|
|
579
772
|
}
|
|
580
773
|
if (rceTimeout) {
|
|
581
774
|
clearTimeout(rceTimeout)
|
|
@@ -1009,7 +1202,75 @@ export default defineVxeComponent({
|
|
|
1009
1202
|
computed: {
|
|
1010
1203
|
...({} as {
|
|
1011
1204
|
$xeGantt(): (VxeGanttConstructor & VxeGanttPrivateMethods)
|
|
1012
|
-
})
|
|
1205
|
+
}),
|
|
1206
|
+
computeScaleDateList () {
|
|
1207
|
+
const $xeGanttView = this
|
|
1208
|
+
const $xeGantt = $xeGanttView.$xeGantt
|
|
1209
|
+
const reactData = $xeGanttView.reactData
|
|
1210
|
+
|
|
1211
|
+
const { minViewDate, maxViewDate } = reactData
|
|
1212
|
+
const minScale = $xeGantt.computeMinScale
|
|
1213
|
+
const dateList: Date[] = []
|
|
1214
|
+
if (!minViewDate || !maxViewDate) {
|
|
1215
|
+
return dateList
|
|
1216
|
+
}
|
|
1217
|
+
|
|
1218
|
+
const startTime = minViewDate.getTime()
|
|
1219
|
+
const endTime = maxViewDate.getTime()
|
|
1220
|
+
switch (minScale.type) {
|
|
1221
|
+
case 'year': {
|
|
1222
|
+
let currDate = XEUtils.getWhatYear(minViewDate, 0, 'first')
|
|
1223
|
+
while (currDate <= maxViewDate) {
|
|
1224
|
+
const itemDate = currDate
|
|
1225
|
+
dateList.push(itemDate)
|
|
1226
|
+
currDate = XEUtils.getWhatYear(currDate, 1)
|
|
1227
|
+
}
|
|
1228
|
+
break
|
|
1229
|
+
}
|
|
1230
|
+
case 'quarter': {
|
|
1231
|
+
let currDate = XEUtils.getWhatQuarter(minViewDate, 0, 'first')
|
|
1232
|
+
while (currDate <= maxViewDate) {
|
|
1233
|
+
const itemDate = currDate
|
|
1234
|
+
dateList.push(itemDate)
|
|
1235
|
+
currDate = XEUtils.getWhatQuarter(currDate, 1)
|
|
1236
|
+
}
|
|
1237
|
+
break
|
|
1238
|
+
}
|
|
1239
|
+
case 'month': {
|
|
1240
|
+
let currDate = XEUtils.getWhatMonth(minViewDate, 0, 'first')
|
|
1241
|
+
while (currDate <= maxViewDate) {
|
|
1242
|
+
const itemDate = currDate
|
|
1243
|
+
dateList.push(itemDate)
|
|
1244
|
+
currDate = XEUtils.getWhatMonth(currDate, 1)
|
|
1245
|
+
}
|
|
1246
|
+
break
|
|
1247
|
+
}
|
|
1248
|
+
case 'week': {
|
|
1249
|
+
let currDate = XEUtils.getWhatWeek(minViewDate, 0, minScale.startDay, minScale.startDay)
|
|
1250
|
+
while (currDate <= maxViewDate) {
|
|
1251
|
+
const itemDate = currDate
|
|
1252
|
+
dateList.push(itemDate)
|
|
1253
|
+
currDate = XEUtils.getWhatWeek(currDate, 1)
|
|
1254
|
+
}
|
|
1255
|
+
break
|
|
1256
|
+
}
|
|
1257
|
+
case 'day':
|
|
1258
|
+
case 'date':
|
|
1259
|
+
case 'hour':
|
|
1260
|
+
case 'minute':
|
|
1261
|
+
case 'second': {
|
|
1262
|
+
const gapTime = getStandardGapTime(minScale.type)
|
|
1263
|
+
let currTime = startTime
|
|
1264
|
+
while (currTime <= endTime) {
|
|
1265
|
+
const itemDate = new Date(currTime)
|
|
1266
|
+
dateList.push(itemDate)
|
|
1267
|
+
currTime += gapTime
|
|
1268
|
+
}
|
|
1269
|
+
break
|
|
1270
|
+
}
|
|
1271
|
+
}
|
|
1272
|
+
return dateList
|
|
1273
|
+
}
|
|
1013
1274
|
},
|
|
1014
1275
|
methods: {
|
|
1015
1276
|
//
|
|
@@ -1017,9 +1278,17 @@ export default defineVxeComponent({
|
|
|
1017
1278
|
//
|
|
1018
1279
|
refreshData (): Promise<void> {
|
|
1019
1280
|
const $xeGanttView = this
|
|
1281
|
+
const internalData = $xeGanttView.internalData
|
|
1020
1282
|
|
|
1021
1283
|
handleUpdateData($xeGanttView)
|
|
1022
|
-
|
|
1284
|
+
handleRecalculateStyle($xeGanttView)
|
|
1285
|
+
return $xeGanttView.$nextTick().then(() => {
|
|
1286
|
+
const $xeTable = internalData.xeTable
|
|
1287
|
+
handleRecalculateStyle($xeGanttView)
|
|
1288
|
+
if ($xeTable) {
|
|
1289
|
+
return $xeTable.recalculate()
|
|
1290
|
+
}
|
|
1291
|
+
})
|
|
1023
1292
|
},
|
|
1024
1293
|
updateViewData (): Promise<void> {
|
|
1025
1294
|
const $xeGanttView = this
|
|
@@ -256,6 +256,26 @@ export default /* define-vxe-component start */ defineVxeComponent({
|
|
|
256
256
|
|
|
257
257
|
return Object.assign({}, getConfig().gantt.taskSplitConfig, props.taskSplitConfig)
|
|
258
258
|
},
|
|
259
|
+
computeScaleUnit () {
|
|
260
|
+
const $xeGantt = this
|
|
261
|
+
|
|
262
|
+
const minScale = $xeGantt.computeMinScale as VxeGanttDefines.ColumnScaleObj
|
|
263
|
+
return minScale ? minScale.type : 'date'
|
|
264
|
+
},
|
|
265
|
+
computeMinScale () {
|
|
266
|
+
const $xeGantt = this
|
|
267
|
+
const reactData = ($xeGantt as any).reactData as GanttReactData
|
|
268
|
+
|
|
269
|
+
const { taskScaleList } = reactData
|
|
270
|
+
return XEUtils.last(taskScaleList)
|
|
271
|
+
},
|
|
272
|
+
computeWeekScale () {
|
|
273
|
+
const $xeGantt = this
|
|
274
|
+
const reactData = ($xeGantt as any).reactData as GanttReactData
|
|
275
|
+
|
|
276
|
+
const { taskScaleList } = reactData
|
|
277
|
+
return taskScaleList.find(item => item.type === 'week')
|
|
278
|
+
},
|
|
259
279
|
computeTaskScaleConfs () {
|
|
260
280
|
const $xeGantt = this
|
|
261
281
|
|
|
@@ -534,6 +554,7 @@ export default /* define-vxe-component start */ defineVxeComponent({
|
|
|
534
554
|
const $xeGantt = this
|
|
535
555
|
|
|
536
556
|
$xeGantt.handleTaskScaleConfig()
|
|
557
|
+
$xeGantt.refreshTaskView()
|
|
537
558
|
}
|
|
538
559
|
},
|
|
539
560
|
methods: {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { VxeGanttDefines } from '../../../types'
|
|
1
2
|
import type { VxeTableDefines, VxeTablePropTypes } from 'vxe-table'
|
|
2
3
|
|
|
3
4
|
export function getRefElem (refEl: any) {
|
|
@@ -10,3 +11,15 @@ export function getRefElem (refEl: any) {
|
|
|
10
11
|
export function getCellRestHeight (rowRest: VxeTableDefines.RowCacheItem, cellOpts: VxeTablePropTypes.CellConfig, rowOpts: VxeTablePropTypes.RowConfig, defaultRowHeight: number) {
|
|
11
12
|
return rowRest.resizeHeight || cellOpts.height || rowOpts.height || rowRest.height || defaultRowHeight
|
|
12
13
|
}
|
|
14
|
+
|
|
15
|
+
export function getStandardGapTime (type: VxeGanttDefines.ColumnScaleType) {
|
|
16
|
+
switch (type) {
|
|
17
|
+
case 'hour':
|
|
18
|
+
return 1000 * 60 * 60
|
|
19
|
+
case 'minute':
|
|
20
|
+
return 1000 * 60
|
|
21
|
+
case 'second':
|
|
22
|
+
return 1000
|
|
23
|
+
}
|
|
24
|
+
return 1000 * 60 * 60 * 24
|
|
25
|
+
}
|