排产看板页面调整

dev-scheduling
zhangdi 2 months ago
parent 78c041256a
commit 1685246f6d
  1. 98
      src/views/productionSchedulingPlan/schedulingDashboard/container.vue

@ -328,6 +328,24 @@
@mouseleave="hideTooltip()"
>
<div
class="task-text-wrapper"
:class="{
'text-inside': canFitText(
task.processName,
task.planStartTime,
task.planEndTime
),
'text-outside': !canFitText(
task.processName,
task.planStartTime,
task.planEndTime
),
}"
:style="getTaskTextStyle(task, layerIndex)"
>
{{ task.processName }}
</div>
<!-- <div
class="task-label"
v-if="getWidthPercent(task.planStartTime, task.planEndTime) >= 1.5"
>
@ -335,9 +353,6 @@
task.processName
}}</span>
</div>
<!-- 为窄任务添加带偏移的文本显示 task.processName-->
<div
v-else
class="task-overlay-text"
@ -352,7 +367,7 @@
}"
>
{{ task.processName }}
</div>
</div> -->
</div>
</template>
</div>
@ -1329,14 +1344,21 @@ export default {
},
//
getStatusColor(row) {
if (row.planStatus === '1') {
if (row.remindStatus === '1') {
return '#FFD700'; //
} else if (row.remindStatus === '2') {
return '#dc3545'; //
}
// remindStatus
return '#6c757d';
}
switch (row.planStatus) {
case '5':
return '#007bff';
case '2':
case '3':
return '#28a745';
case '1':
return '#6c757d';
case '6':
return '#dc3545';
default:
@ -1494,6 +1516,8 @@ export default {
//
getWidthPercent(startTime, endTime) {
let labelsWidth = document.querySelector('.date-label').offsetWidth;
const startHour = this.parseTimeToHours(startTime);
const endHour = this.parseTimeToHours(endTime);
@ -1572,6 +1596,65 @@ export default {
const day = String(d.getDate()).padStart(2, '0');
return `${year}-${month}-${day}`;
},
//
canFitText(text, startTime, endTime) {
if (!text || !startTime || !endTime || !this.$refs.timelineContainer) {
return false;
}
const taskWidthPercent = this.getWidthPercent(startTime, endTime);
const containerWidth = this.$refs.timelineContainer.scrollWidth;
if (containerWidth <= 0) return false; //
const taskPixelWidth = (containerWidth * taskWidthPercent)/100;
console.log(taskWidthPercent,taskPixelWidth,'任务宽度百分比和容器宽度');
const textWidth = this.getTextWidth(text, 10); //
return taskPixelWidth >= textWidth + 4; // 4px padding
},
//
getTextWidth(text, fontSize = 12) {
// canvas
const canvas = document.createElement('canvas');
const context = canvas.getContext('2d');
context.font = `${fontSize}px Arial`;
const metrics = context.measureText(text);
return Math.ceil(metrics.width);
},
//
getTaskTextStyle(task, layerIndex) {
const canFit = this.canFitText(task.processName, task.planStartTime, task.planEndTime);
if (canFit) {
//
return {
position: 'absolute',
top: '50%',
left: '50%',
transform: 'translate(-50%, -50%)',
color: 'white',
fontSize: '10px',
whiteSpace: 'nowrap',
textShadow: '0 0 2px rgba(0,0,0,0.5)',
};
} else {
//
const isEvenLayer = layerIndex % 2 === 0;
return {
position: 'absolute',
top: isEvenLayer ? '-15px' : 'calc(100% )',
left: '50%',
transform: 'translateX(-50%)',
color: '#333',
fontSize: '10px',
whiteSpace: 'nowrap',
padding: '2px 6px',
borderRadius: '3px',
zIndex: 10,
};
}
},
},
};
</script>
@ -2169,4 +2252,7 @@ export default {
text-align: right;
padding-right: 10px;
}
.task-text-wrapper {
pointer-events: none; /* 避免遮挡 hover 事件 */
}
</style>

Loading…
Cancel
Save