调整代码结构
This commit is contained in:
@@ -684,10 +684,19 @@ export default AbstractRenderer.extend(WidgetAdapterMixin, {
|
||||
const stopDate = this.state.stopDate;
|
||||
let day = this.state.startDate;
|
||||
const dates = [];
|
||||
while (day <= stopDate) {
|
||||
dates.push(day);
|
||||
day = day.clone().add(1, token);
|
||||
const shift_time = 8;
|
||||
if (this.state.scale == "day") {
|
||||
while (day <= stopDate) {
|
||||
dates.push(day);
|
||||
day = day.clone().add(shift_time, token);
|
||||
}
|
||||
} else {
|
||||
while (day <= stopDate) {
|
||||
dates.push(day);
|
||||
day = day.clone().add(1, token);
|
||||
}
|
||||
}
|
||||
console.log(dates)
|
||||
return dates;
|
||||
},
|
||||
/**
|
||||
@@ -806,6 +815,7 @@ export default AbstractRenderer.extend(WidgetAdapterMixin, {
|
||||
* @override
|
||||
*/
|
||||
async _renderView() {
|
||||
console.log('this.state', this.state)
|
||||
const oldRowWidgets = Object.keys(this.rowWidgets).map((rowId) => {
|
||||
return this.rowWidgets[rowId];
|
||||
});
|
||||
|
||||
@@ -457,16 +457,50 @@ var GanttRow = Widget.extend({
|
||||
this.pills.forEach(function (pill) {
|
||||
let widthPill;
|
||||
let margin;
|
||||
const shift_time = 8;
|
||||
switch (self.state.scale) {
|
||||
case 'day':
|
||||
left = pill.startDate.diff(pill.startDate.clone().startOf('hour'), 'minutes');
|
||||
pill.leftMargin = (left / 60) * 100;
|
||||
// left = pill.startDate.diff(pill.startDate.clone().startOf('hour'), 'minutes');
|
||||
left = pill.startDate.diff(pill.startDate.clone().startOf('day'), 'minutes') % (shift_time * 60);
|
||||
|
||||
console.log('left', left)
|
||||
pill.leftMargin = (left / (shift_time * 60)) * 100;
|
||||
console.log('pill.leftMargin', pill.leftMargin)
|
||||
diff = pill.stopDate.diff(pill.startDate, 'minutes');
|
||||
var gapSize = pill.stopDate.diff(pill.startDate, 'hours') - 1; // Eventually compensate border(s) width
|
||||
widthPill = (diff / 60) * 100;
|
||||
console.log('diff', diff)
|
||||
var gapSize = pill.stopDate.diff(pill.startDate, 'hours') - shift_time; // Eventually compensate border(s) width
|
||||
console.log('gapSize', gapSize)
|
||||
widthPill = (diff / (shift_time * 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)
|
||||
// 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');
|
||||
@@ -666,21 +700,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)
|
||||
});
|
||||
},
|
||||
/**
|
||||
@@ -727,7 +768,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 = '';
|
||||
@@ -759,6 +800,7 @@ var GanttRow = Widget.extend({
|
||||
stop: slotStop,
|
||||
pills: [],
|
||||
});
|
||||
console.log('啊啊啊啊this啊啊啊啊.啊啊啊啊slots啊啊啊啊', this.slots)
|
||||
}
|
||||
},
|
||||
/**
|
||||
|
||||
@@ -76,8 +76,17 @@
|
||||
<div t-attf-class="col position-relative o_gantt_header_cell text-center p-2 #{isToday? 'o_gantt_today' : ''} ">
|
||||
<t t-if="widget.state.scale in formats" t-esc="slot.format(formats[widget.state.scale])"/>
|
||||
<small t-else="">
|
||||
<b t-esc="slot.format('k')"/>
|
||||
<span class="d-block d-xl-inline-block" t-esc="slot.format('a')"/>
|
||||
<t t-if="slot.format('k') == 24">
|
||||
<div>夜班</div>
|
||||
</t>
|
||||
<t t-if="slot.format('k') == 8">
|
||||
<div>早班</div>
|
||||
</t>
|
||||
<t t-if="slot.format('k') == 16">
|
||||
<div>晚班</div>
|
||||
</t>
|
||||
<!-- <b t-esc="slot.format('k')"/> -->
|
||||
<!-- <span class="d-block d-xl-inline-block" t-esc="slot.format('a')"/> -->
|
||||
</small>
|
||||
</div>
|
||||
</t>
|
||||
|
||||
Reference in New Issue
Block a user