新时间尺度下pill已可正确展示(包括左边距和宽度)
This commit is contained in:
@@ -466,44 +466,46 @@ var GanttRow = Widget.extend({
|
|||||||
switch (self.state.scale) {
|
switch (self.state.scale) {
|
||||||
case 'day':
|
case 'day':
|
||||||
// left = pill.startDate.diff(pill.startDate.clone().startOf('hour'), 'minutes');
|
// left = pill.startDate.diff(pill.startDate.clone().startOf('hour'), 'minutes');
|
||||||
// console.log('left', left)
|
left = pill.startDate.diff(pill.startDate.clone().startOf('day'), 'minutes') % (8 * 60);
|
||||||
// pill.leftMargin = (left / 60) * 100;
|
|
||||||
// console.log('pill.leftMargin', pill.leftMargin)
|
|
||||||
// diff = pill.stopDate.diff(pill.startDate, 'minutes');
|
|
||||||
// console.log('diff', diff)
|
|
||||||
// var gapSize = pill.stopDate.diff(pill.startDate, 'hours') - 1; // Eventually compensate border(s) width
|
|
||||||
// console.log('gapSize', gapSize)
|
|
||||||
// widthPill = (diff / 60) * 100;
|
|
||||||
// console.log('widthPill', widthPill)
|
|
||||||
// margin = pill.aggregatedPills ? 0 : 4;
|
|
||||||
// console.log('margin', margin)
|
|
||||||
// pill.width = gapSize > 0 ? `calc(${widthPill}% + ${gapSize}px - ${margin}px)` : `calc(${widthPill}% - ${margin}px)`;
|
|
||||||
// console.log('pill.width', pill.width)
|
|
||||||
// break;
|
|
||||||
|
|
||||||
left = pill.startDate.diff(pill.startDate.clone().startOf('hour'), 'minutes');
|
|
||||||
console.log('left', left)
|
console.log('left', left)
|
||||||
left = (left / (8 * 60)) * 100; // 修改这里,以8小时为单位
|
pill.leftMargin = (left / 480) * 100;
|
||||||
console.log('adjusted left', left)
|
console.log('pill.leftMargin', pill.leftMargin)
|
||||||
pill.leftMargin = left;
|
|
||||||
|
|
||||||
diff = pill.stopDate.diff(pill.startDate, 'minutes');
|
diff = pill.stopDate.diff(pill.startDate, 'minutes');
|
||||||
console.log('diff', diff)
|
console.log('diff', diff)
|
||||||
diff = (diff / (8 * 60)) * 100; // 修改这里,以8小时为单位
|
var gapSize = pill.stopDate.diff(pill.startDate, 'hours') - 8; // Eventually compensate border(s) width
|
||||||
console.log('adjusted diff', diff)
|
|
||||||
|
|
||||||
var gapSize = pill.stopDate.diff(pill.startDate, 'hours') / 8 - 1; // 修改这里,以8小时为单位
|
|
||||||
console.log('gapSize', gapSize)
|
console.log('gapSize', gapSize)
|
||||||
|
widthPill = (diff / 480) * 100;
|
||||||
widthPill = diff;
|
|
||||||
console.log('widthPill', widthPill)
|
console.log('widthPill', widthPill)
|
||||||
|
|
||||||
margin = pill.aggregatedPills ? 0 : 4;
|
margin = pill.aggregatedPills ? 0 : 4;
|
||||||
console.log('margin', margin)
|
console.log('margin', margin)
|
||||||
|
|
||||||
pill.width = gapSize > 0 ? `calc(${widthPill}% + ${gapSize}px - ${margin}px)` : `calc(${widthPill}% - ${margin}px)`;
|
pill.width = gapSize > 0 ? `calc(${widthPill}% + ${gapSize}px - ${margin}px)` : `calc(${widthPill}% - ${margin}px)`;
|
||||||
console.log('pill.width', pill.width)
|
console.log('pill.width', pill.width)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
// left = pill.startDate.diff(pill.startDate.clone().startOf('hour'), 'minutes');
|
||||||
|
// console.log('left', left)
|
||||||
|
// left = (left / (8 * 60)) * 100; // 修改这里,以8小时为单位
|
||||||
|
// console.log('adjusted left', left)
|
||||||
|
// pill.leftMargin = left;
|
||||||
|
//
|
||||||
|
// diff = pill.stopDate.diff(pill.startDate, 'minutes');
|
||||||
|
// console.log('diff', diff)
|
||||||
|
// diff = (diff / (8 * 60)) * 100; // 修改这里,以8小时为单位
|
||||||
|
// console.log('adjusted diff', diff)
|
||||||
|
//
|
||||||
|
// var gapSize = pill.stopDate.diff(pill.startDate, 'hours') / 8 - 1; // 修改这里,以8小时为单位
|
||||||
|
// console.log('gapSize', gapSize)
|
||||||
|
//
|
||||||
|
// widthPill = diff;
|
||||||
|
// console.log('widthPill', widthPill)
|
||||||
|
//
|
||||||
|
// margin = pill.aggregatedPills ? 0 : 4;
|
||||||
|
// console.log('margin', margin)
|
||||||
|
//
|
||||||
|
// pill.width = gapSize > 0 ? `calc(${widthPill}% + ${gapSize}px - ${margin}px)` : `calc(${widthPill}% - ${margin}px)`;
|
||||||
|
// console.log('pill.width', pill.width)
|
||||||
|
// break;
|
||||||
case 'week':
|
case 'week':
|
||||||
case 'month':
|
case 'month':
|
||||||
left = pill.startDate.diff(pill.startDate.clone().startOf('day'), 'hours');
|
left = pill.startDate.diff(pill.startDate.clone().startOf('day'), 'hours');
|
||||||
@@ -703,21 +705,28 @@ var GanttRow = Widget.extend({
|
|||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
_insertIntoSlot: function () {
|
_insertIntoSlot: function () {
|
||||||
|
console.log('this.slots', this.slots);
|
||||||
var slotsToFill = this.slots;
|
var slotsToFill = this.slots;
|
||||||
this.pills.forEach(function (currentPill) {
|
this.pills.forEach(function (currentPill) {
|
||||||
var skippedSlots = [];
|
var skippedSlots = [];
|
||||||
slotsToFill.some(function (currentSlot) {
|
slotsToFill.some(function (currentSlot) {
|
||||||
|
console.log('currentPill.startDate1111111111', currentPill)
|
||||||
|
// console.log('currentSlot.stop2222222222222', currentSlot.stop)
|
||||||
var fitsInThisSlot = currentPill.startDate < currentSlot.stop;
|
var fitsInThisSlot = currentPill.startDate < currentSlot.stop;
|
||||||
|
console.log('fitsInThisSlot', fitsInThisSlot)
|
||||||
if (fitsInThisSlot) {
|
if (fitsInThisSlot) {
|
||||||
currentSlot.pills.push(currentPill);
|
currentSlot.pills.push(currentPill);
|
||||||
|
console.log('currentSlot.pills', currentSlot.pills)
|
||||||
} else {
|
} else {
|
||||||
skippedSlots.push(currentSlot);
|
skippedSlots.push(currentSlot);
|
||||||
|
console.log('skippedSlots', skippedSlots)
|
||||||
}
|
}
|
||||||
return fitsInThisSlot;
|
return fitsInThisSlot;
|
||||||
});
|
});
|
||||||
// Pills are sorted by start date, so any slot that was skipped
|
// Pills are sorted by start date, so any slot that was skipped
|
||||||
// for this pill will not be suitable for any of the next pills
|
// for this pill will not be suitable for any of the next pills
|
||||||
slotsToFill = _.difference(slotsToFill, skippedSlots);
|
slotsToFill = _.difference(slotsToFill, skippedSlots);
|
||||||
|
console.log('slotsToFill', slotsToFill)
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
@@ -764,7 +773,7 @@ var GanttRow = Widget.extend({
|
|||||||
let index = 0;
|
let index = 0;
|
||||||
for (const date of this.viewInfo.slots) {
|
for (const date of this.viewInfo.slots) {
|
||||||
const slotStart = date;
|
const slotStart = date;
|
||||||
const slotStop = date.clone().add(1, interval);
|
const slotStop = date.clone().add(8, interval);
|
||||||
const isToday = date.isSame(new Date(), 'day') && this.state.scale !== 'day';
|
const isToday = date.isSame(new Date(), 'day') && this.state.scale !== 'day';
|
||||||
|
|
||||||
let slotStyle = '';
|
let slotStyle = '';
|
||||||
@@ -796,6 +805,7 @@ var GanttRow = Widget.extend({
|
|||||||
stop: slotStop,
|
stop: slotStop,
|
||||||
pills: [],
|
pills: [],
|
||||||
});
|
});
|
||||||
|
console.log('啊啊啊啊this啊啊啊啊.啊啊啊啊slots啊啊啊啊', this.slots)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user