Accept Merge Request #709: (feature/前端样式修改 -> develop)

Merge Request: 前端样式修改,甘特图增加功能

Created By: @黄焱
Reviewed By: @马广威
Approved By: @马广威 
Accepted By: @黄焱
URL: https://jikimo-hn.coding.net/p/jikimo_sfs/d/jikimo_sf/git/merge/709?initial=true
This commit is contained in:
黄焱
2023-12-06 15:46:02 +08:00
committed by Coding
5 changed files with 122 additions and 25 deletions

View File

@@ -135,7 +135,7 @@ td.o_required_modifier {
.text-truncate {
overflow: unset !important;
text-overflow: unset !important;
white-space: unset !important;
white-space: nowrap!important;
}
.o_list_renderer .o_list_table tbody > tr > td:not(.o_list_record_selector):not(.o_handle_cell):not(.o_list_button):not(.o_list_record_remove) {
@@ -370,9 +370,16 @@ div:has(.o_required_modifier) > label::before {
top: 40px;
left: 168px;
padding: 0;
display: flex;
flex-wrap: wrap;
box-sizing: border-box;
.row {
width: 50%;
margin: 0;
>div {
padding: 0;
width: unset;
margin-right: 10px;
}
}
}

View File

@@ -23,7 +23,7 @@ html .o_web_client > .o_action_manager > .o_action {
}
.o_form_view {
background-color: unset !important;
//background-color: unset !important;
min-height: unset !important;
}

View File

@@ -221,7 +221,15 @@ export default AbstractModel.extend({
this.ganttData.groupedBy = this.defaultGroupBy;
}
}
const time = sessionStorage.getItem('time')
const scale = sessionStorage.getItem('scale')
if(time) {
this._setRange(moment(time), scale);
console.log('进入自定义时间')
}
return this._fetchData().then(() => {
sessionStorage.removeItem('time')
sessionStorage.removeItem('scale')
// The 'reload' function returns a promise which resolves with the
// handle to pass to the 'get' function to access the data. In this
// case, we don't want to pass any argument to 'get' (see its API).

View File

@@ -8,7 +8,6 @@ var Widget = require('web.Widget');
const pyUtils = require('web.py_utils');
let pyUtilsContext = null;
const fieldUtils = require('web.field_utils');
var QWeb = core.qweb;
var _t = core._t;
@@ -22,6 +21,9 @@ var GanttRow = Widget.extend({
'click': '_onRowSidebarClicked',
'click .o_gantt_cell_buttons > div > .o_gantt_cell_add': '_onButtonAddClicked',
'click .o_gantt_cell_buttons > div > .o_gantt_cell_plan': '_onButtonPlanClicked',
'mousewheel .o_gantt_hoverable': '_onColMouseWheel',
'click .o_gantt_hoverable': '_onColClicked',
},
NB_GANTT_RECORD_COLORS: 12,
LEVEL_LEFT_OFFSET: 16, // 16 px per level
@@ -144,7 +146,7 @@ var GanttRow = Widget.extend({
}
this._super();
},
//--------------------------------------------------------------------------
// Public
//--------------------------------------------------------------------------
@@ -261,18 +263,18 @@ var GanttRow = Widget.extend({
_adaptPills: function () {
var self = this;
var dateStartField = this.state.dateStartField;
console.log("dateStartField",dateStartField)
// console.log("dateStartField",dateStartField)
var dateStopField = this.state.dateStopField;
console.log("dateStopField",dateStopField)
// console.log("dateStopField",dateStopField)
var ganttStartDate = this.state.startDate;
console.log("ganttStartDate",ganttStartDate)
// console.log("ganttStartDate",ganttStartDate)
var ganttStopDate = this.state.stopDate;
console.log("ganttStopDate",ganttStopDate)
// console.log("ganttStopDate",ganttStopDate)
this.pills.forEach(function (pill) {
var pillStartDate = self._convertToUserTime(pill[dateStartField]);
console.log("pillStartDate",pillStartDate)
// console.log("pillStartDate",pillStartDate)
var pillStopDate = self._convertToUserTime(pill[dateStopField]);
console.log("pillStopDate",pillStopDate)
// console.log("pillStopDate",pillStopDate)
if (pillStartDate < ganttStartDate) {
pill.startDate = ganttStartDate;
pill.disableStartResize = true;
@@ -469,19 +471,19 @@ var GanttRow = Widget.extend({
// 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)
// console.log('left', left)
pill.leftMargin = (left / (shift_time * 60)) * 100;
console.log('pill.leftMargin', pill.leftMargin)
// console.log('pill.leftMargin', pill.leftMargin)
diff = pill.stopDate.diff(pill.startDate, 'minutes');
console.log('diff', diff)
// console.log('diff', diff)
var gapSize = pill.stopDate.diff(pill.startDate, 'hours') - shift_time; // Eventually compensate border(s) width
console.log('gapSize', gapSize)
// console.log('gapSize', gapSize)
widthPill = (diff / (shift_time * 60)) * 100;
console.log('widthPill', widthPill)
// console.log('widthPill', widthPill)
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)`;
console.log('pill.width', pill.width)
// console.log('pill.width', pill.width)
break;
// left = pill.startDate.diff(pill.startDate.clone().startOf('hour'), 'minutes');
@@ -711,16 +713,16 @@ var GanttRow = Widget.extend({
this.pills.forEach(function (currentPill) {
var skippedSlots = [];
slotsToFill.some(function (currentSlot) {
console.log('currentPill.startDate1111111111', currentPill)
// console.log('currentPill.startDate1111111111', currentPill)
// console.log('currentSlot.stop2222222222222', currentSlot.stop)
var fitsInThisSlot = currentPill.startDate < currentSlot.stop;
console.log('fitsInThisSlot', fitsInThisSlot)
// console.log('fitsInThisSlot', fitsInThisSlot)
if (fitsInThisSlot) {
currentSlot.pills.push(currentPill);
console.log('currentSlot.pills', currentSlot.pills)
// console.log('currentSlot.pills', currentSlot.pills)
} else {
skippedSlots.push(currentSlot);
console.log('skippedSlots', skippedSlots)
// console.log('skippedSlots', skippedSlots)
}
return fitsInThisSlot;
});
@@ -813,7 +815,7 @@ var GanttRow = Widget.extend({
stop: slotStop,
pills: [],
});
console.log('啊啊啊啊this啊啊啊啊.啊啊啊啊slots啊啊啊啊', this.slots)
// console.log('啊啊啊啊this啊啊啊啊.啊啊啊啊slots啊啊啊啊', this.slots)
}
},
/**
@@ -1161,6 +1163,8 @@ var GanttRow = Widget.extend({
* @param {MouseEvent} ev
*/
_onButtonAddClicked: function (ev) {
ev.stopPropagation()
ev.cancelBubble
var date = moment($(ev.currentTarget).closest('.o_gantt_cell').data('date'));
this.trigger_up('add_button_clicked', {
date: date,
@@ -1174,6 +1178,8 @@ var GanttRow = Widget.extend({
* @param {MouseEvent} ev
*/
_onButtonPlanClicked: function (ev) {
ev.stopPropagation()
ev.cancelBubble
var date = moment($(ev.currentTarget).closest('.o_gantt_cell').data('date'));
this.trigger_up('plan_button_clicked', {
date: date,
@@ -1246,6 +1252,8 @@ var GanttRow = Widget.extend({
* @param {MouseEvent} ev
*/
_onPillClicked: function (ev) {
ev.stopPropagation()
ev.cancelBubble
if (!this.isGroup) {
this.trigger_up('pill_clicked', {
target: $(ev.currentTarget),
@@ -1288,6 +1296,80 @@ var GanttRow = Widget.extend({
}
}
},
// _getTimeSlot(scale = 'day', date = new Date()) {
// if(scale == 'day') {
// return [date, date]
// } else if(scale == 'week') {
//
// const week = new Date(date).getDay()
// const before = week - 1
// const after = 7 - week
// return [+new Date(date) - (before * 86400000), +new Date(date) + (after * 86400000)]
// } else if(scale == 'month') {
//
// const year = new Date(date).getFullYear()
// const month = new Date(date).getMonth() + 1
// const monthDay = new Date(year, month, 0).getDate()
// const before = new Date(year + '/' + (month < 10 ? '0' + month : month) + '/01')
// const after = new Date(year + '/' + (month < 10 ? '0' + month : month) + '/' +monthDay)
// return [before, after]
// } else {
//
// const year = new Date(date).getFullYear()
// return [year + '/01/01', year + '/12/31']
// }
// },
_onColClicked(e) {
if(sessionStorage.getItem('scale')) return
const scale = ['day', 'week', 'month', 'year']
const index = scale.indexOf(this.viewInfo.state.scale)
const dom = $('.o_gantt_button_scale.btn.btn-secondary.active').prev()
const nextScale = scale[index - 1]
if(!nextScale) return;
sessionStorage.setItem('scale', nextScale)
sessionStorage.setItem('time', e.target.dataset.date )
if(dom) {
dom.click()
}
},
/**
* 鼠标滚动
*
* @private
*/
_onColMouseWheel: function (e) {
if(sessionStorage.getItem('scale')) return
const scale = ['day', 'week', 'month', 'year']
let direction
if(e.originalEvent.wheelDelta) { //判断浏览器IE谷歌滑轮事件
direction = e.originalEvent.wheelDelta > 0
} else { //Firefox滑轮事件
direction = e.originalEvent.detail > 0
}
const index = scale.indexOf(this.viewInfo.state.scale)
if(direction) { // 滚轮向上滑动
const dom = $('.o_gantt_button_scale.btn.btn-secondary.active').prev()
const nextScale = scale[index - 1]
if(!nextScale) return;
sessionStorage.setItem('scale', nextScale)
// sessionStorage.setItem('time', JSON.stringify(this._getTimeSlot(nextScale, e.target.dataset.date)))
sessionStorage.setItem('time', e.target.dataset.date || e.currentTarget.dataset.date)
if(dom) {
dom.click()
}
} else { // 滚轮向下滑动
const dom = $('.o_gantt_button_scale.btn.btn-secondary.active').next()
const nextScale = scale[index + 1]
if(!nextScale) return;
sessionStorage.setItem('scale', nextScale)
sessionStorage.setItem('time', e.target.dataset.date || e.currentTarget.dataset.date)
// sessionStorage.setItem('time', JSON.stringify(this._getTimeSlot(nextScale, e.target.dataset.date)))
if(dom) {
dom.click()
}
}
}
});
return GanttRow;

View File

@@ -77,13 +77,13 @@
<t t-if="widget.state.scale in formats" t-esc="slot.format(formats[widget.state.scale])"/>
<small t-else="">
<t t-if="slot.format('k') == 24">
<div>班(00:00-08:00)</div>
<div>班(00:00-08:00)</div>
</t>
<t t-if="slot.format('k') == 8">
<div>班(08:00-16:00)</div>
<div>班(08:00-16:00)</div>
</t>
<t t-if="slot.format('k') == 16">
<div>晚班(16:00-00:00)</div>
<div>晚班(16:00-24:00)</div>
</t>
<!-- <b t-esc="slot.format('k')"/> -->
<!-- <span class="d-block d-xl-inline-block" t-esc="slot.format('a')"/> -->