@worktile/gantt 19.0.8-next.3 → 19.0.8-next.5
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/fesm2022/worktile-gantt.mjs +45 -18
- package/fesm2022/worktile-gantt.mjs.map +1 -1
- package/gantt-print.service.d.ts +1 -0
- package/package.json +1 -1
- package/views/day.d.ts +1 -0
- package/views/view.d.ts +7 -0
|
@@ -1005,6 +1005,18 @@ class GanttView {
|
|
|
1005
1005
|
return this.getDayOccupancyWidth(date);
|
|
1006
1006
|
}
|
|
1007
1007
|
}
|
|
1008
|
+
/**
|
|
1009
|
+
* 根据起始日期和宽度计算结束日期
|
|
1010
|
+
* @param start 起始日期
|
|
1011
|
+
* @param width 视觉宽度
|
|
1012
|
+
* @returns 结束日期
|
|
1013
|
+
*/
|
|
1014
|
+
getEndDateByWidth(start, width) {
|
|
1015
|
+
const startX = this.getXPointByDate(start);
|
|
1016
|
+
// 减去偏移量避免因为 getDateRangeWidth 加了 1 秒而多算一天
|
|
1017
|
+
const endX = startX + width - 0.1;
|
|
1018
|
+
return this.getDateByXPoint(endX);
|
|
1019
|
+
}
|
|
1008
1020
|
}
|
|
1009
1021
|
|
|
1010
1022
|
const viewOptions$5 = {
|
|
@@ -1065,6 +1077,30 @@ class GanttViewDay extends GanttView {
|
|
|
1065
1077
|
}
|
|
1066
1078
|
return points;
|
|
1067
1079
|
}
|
|
1080
|
+
getEndDateByWidth(start, width) {
|
|
1081
|
+
if (!this.options.hoilday?.hideHoliday) {
|
|
1082
|
+
return super.getEndDateByWidth(start, width);
|
|
1083
|
+
}
|
|
1084
|
+
// 通过宽度计算包含多少个工作日(每个工作日的宽度是 cellWidth)
|
|
1085
|
+
const workingDaysCount = Math.round(width / this.getCellWidth());
|
|
1086
|
+
let end = start;
|
|
1087
|
+
let addedWorkingDays = 0;
|
|
1088
|
+
let attempts = 0;
|
|
1089
|
+
const maxAttempts = 365;
|
|
1090
|
+
while (addedWorkingDays < workingDaysCount && attempts < maxAttempts) {
|
|
1091
|
+
if (this.getDayOccupancyWidth(end) > 0) {
|
|
1092
|
+
addedWorkingDays++;
|
|
1093
|
+
if (addedWorkingDays < workingDaysCount) {
|
|
1094
|
+
end = end.addDays(1);
|
|
1095
|
+
}
|
|
1096
|
+
}
|
|
1097
|
+
else {
|
|
1098
|
+
end = end.addDays(1);
|
|
1099
|
+
}
|
|
1100
|
+
attempts++;
|
|
1101
|
+
}
|
|
1102
|
+
return end;
|
|
1103
|
+
}
|
|
1068
1104
|
}
|
|
1069
1105
|
|
|
1070
1106
|
const viewOptions$4 = {
|
|
@@ -2398,25 +2434,13 @@ class GanttBarDrag {
|
|
|
2398
2434
|
}
|
|
2399
2435
|
barDragMove() {
|
|
2400
2436
|
const currentX = this.item().refs.x + this.barDragMoveDistance + this.dragScrollDistance;
|
|
2401
|
-
const
|
|
2402
|
-
const
|
|
2403
|
-
const currentEndDate = this.ganttUpper.view.getDateByXPoint(currentX + this.item().refs.width);
|
|
2404
|
-
const diffs = this.ganttUpper.view.differenceByPrecisionUnit(currentEndDate, currentDate);
|
|
2405
|
-
let start = currentDate;
|
|
2406
|
-
let end = currentDate.add(diffs, this.ganttUpper.view?.options?.datePrecisionUnit);
|
|
2407
|
-
// 日视图特殊逻辑处理
|
|
2408
|
-
if (this.ganttUpper.view.viewType === GanttViewType.day) {
|
|
2409
|
-
const dayWidth = this.ganttUpper.view.getDayOccupancyWidth(currentDate);
|
|
2410
|
-
if (currentX > currentStartX + dayWidth / 2) {
|
|
2411
|
-
start = start.addDays(1);
|
|
2412
|
-
end = end.addDays(1);
|
|
2413
|
-
}
|
|
2414
|
-
}
|
|
2437
|
+
const start = this.ganttUpper.view.getDateByXPoint(currentX);
|
|
2438
|
+
const end = this.ganttUpper.view.getEndDateByWidth(start, this.item().refs.width);
|
|
2415
2439
|
if (this.dragScrolling) {
|
|
2416
2440
|
const left = currentX - this.barDragMoveDistance;
|
|
2417
2441
|
this.barElement.style.left = left + 'px';
|
|
2418
2442
|
}
|
|
2419
|
-
this.openDragBackdrop(this.barElement,
|
|
2443
|
+
this.openDragBackdrop(this.barElement, start, end);
|
|
2420
2444
|
if (!this.isStartOrEndInsideView(start, end)) {
|
|
2421
2445
|
return;
|
|
2422
2446
|
}
|
|
@@ -3147,7 +3171,7 @@ class GanttPrintService {
|
|
|
3147
3171
|
this.root = root.nativeElement;
|
|
3148
3172
|
this.mainContainer = this.root.getElementsByClassName('gantt-main-container')[0];
|
|
3149
3173
|
}
|
|
3150
|
-
async
|
|
3174
|
+
async html2canvas(ignoreElementClass) {
|
|
3151
3175
|
const root = this.root;
|
|
3152
3176
|
const mainContainer = this.mainContainer;
|
|
3153
3177
|
// set print width
|
|
@@ -3155,7 +3179,7 @@ class GanttPrintService {
|
|
|
3155
3179
|
// set print height
|
|
3156
3180
|
const printHeight = root.offsetHeight - mainContainer.offsetHeight + mainContainer.scrollHeight;
|
|
3157
3181
|
const html2canvas = (await import(/* webpackChunkName: 'html2canvas' */ 'html2canvas')).default;
|
|
3158
|
-
html2canvas(root, {
|
|
3182
|
+
return html2canvas(root, {
|
|
3159
3183
|
logging: false,
|
|
3160
3184
|
allowTaint: true,
|
|
3161
3185
|
useCORS: true,
|
|
@@ -3189,7 +3213,10 @@ class GanttPrintService {
|
|
|
3189
3213
|
// setInlineStyles for svg
|
|
3190
3214
|
this.setInlineStyles(cloneGanttDom);
|
|
3191
3215
|
}
|
|
3192
|
-
})
|
|
3216
|
+
});
|
|
3217
|
+
}
|
|
3218
|
+
async print(name = 'download', ignoreElementClass) {
|
|
3219
|
+
this.html2canvas(ignoreElementClass).then((canvas) => {
|
|
3193
3220
|
const link = document.createElement('a');
|
|
3194
3221
|
const dataUrl = canvas.toDataURL('image/png');
|
|
3195
3222
|
link.download = `${name}.png`;
|