新时间尺度下pill已可正确展示(包括左边距和宽度)
This commit is contained in:
@@ -466,44 +466,46 @@ var GanttRow = Widget.extend({
|
||||
switch (self.state.scale) {
|
||||
case 'day':
|
||||
// left = pill.startDate.diff(pill.startDate.clone().startOf('hour'), 'minutes');
|
||||
// console.log('left', left)
|
||||
// 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('day'), 'minutes') % (8 * 60);
|
||||
|
||||
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;
|
||||
|
||||
pill.leftMargin = (left / 480) * 100;
|
||||
console.log('pill.leftMargin', pill.leftMargin)
|
||||
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小时为单位
|
||||
var gapSize = pill.stopDate.diff(pill.startDate, 'hours') - 8; // Eventually compensate border(s) width
|
||||
console.log('gapSize', gapSize)
|
||||
|
||||
widthPill = diff;
|
||||
widthPill = (diff / 480) * 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)
|
||||
// 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 'month':
|
||||
left = pill.startDate.diff(pill.startDate.clone().startOf('day'), 'hours');
|
||||
@@ -703,21 +705,28 @@ var GanttRow = Widget.extend({
|
||||
* @private
|
||||
*/
|
||||
_insertIntoSlot: function () {
|
||||
console.log('this.slots', this.slots);
|
||||
var slotsToFill = this.slots;
|
||||
this.pills.forEach(function (currentPill) {
|
||||
var skippedSlots = [];
|
||||
slotsToFill.some(function (currentSlot) {
|
||||
console.log('currentPill.startDate1111111111', currentPill)
|
||||
// console.log('currentSlot.stop2222222222222', currentSlot.stop)
|
||||
var fitsInThisSlot = currentPill.startDate < currentSlot.stop;
|
||||
console.log('fitsInThisSlot', fitsInThisSlot)
|
||||
if (fitsInThisSlot) {
|
||||
currentSlot.pills.push(currentPill);
|
||||
console.log('currentSlot.pills', currentSlot.pills)
|
||||
} else {
|
||||
skippedSlots.push(currentSlot);
|
||||
console.log('skippedSlots', skippedSlots)
|
||||
}
|
||||
return fitsInThisSlot;
|
||||
});
|
||||
// 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
|
||||
slotsToFill = _.difference(slotsToFill, skippedSlots);
|
||||
console.log('slotsToFill', slotsToFill)
|
||||
});
|
||||
},
|
||||
/**
|
||||
@@ -764,7 +773,7 @@ var GanttRow = Widget.extend({
|
||||
let index = 0;
|
||||
for (const date of this.viewInfo.slots) {
|
||||
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';
|
||||
|
||||
let slotStyle = '';
|
||||
@@ -796,6 +805,7 @@ var GanttRow = Widget.extend({
|
||||
stop: slotStop,
|
||||
pills: [],
|
||||
});
|
||||
console.log('啊啊啊啊this啊啊啊啊.啊啊啊啊slots啊啊啊啊', this.slots)
|
||||
}
|
||||
},
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user