From 90c689b30d997b522067649f2a4699cd153b21bb Mon Sep 17 00:00:00 2001 From: zhangdi <15053473693@163.com> Date: Mon, 29 Dec 2025 21:03:00 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8E=92=E4=BA=A7=E7=9C=8B=E6=9D=BF=E5=B7=A5?= =?UTF-8?q?=E5=BA=8F=E5=90=8D=E5=AD=97=E5=B1=95=E7=A4=BA=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../schedulingDashboard/container.vue | 59 ++++++++++++------- 1 file changed, 38 insertions(+), 21 deletions(-) diff --git a/src/views/productionSchedulingPlan/schedulingDashboard/container.vue b/src/views/productionSchedulingPlan/schedulingDashboard/container.vue index cc7c752..5945124 100644 --- a/src/views/productionSchedulingPlan/schedulingDashboard/container.vue +++ b/src/views/productionSchedulingPlan/schedulingDashboard/container.vue @@ -304,7 +304,8 @@ :key="taskIndex" class="task-bar" :class="{ - 'task-bar-narrow': getWidthPercent(task.planStartTime, task.planEndTime) < 2.1, + 'task-bar-narrow': + getWidthPercent(task.planStartTime, task.planEndTime) < 2.1, }" :style="{ left: `${getPositionPercent(task.planStartTime)}%`, @@ -323,23 +324,28 @@ @mouseenter="showTooltip($event, task, order.woCode)" @mouseleave="hideTooltip()" > - -
- {{ task.processName }} +
+ {{ + task.processName + }}
- +
{{ task.processName }} @@ -450,7 +456,7 @@ export default { name: 'GanttChart', data() { return { - valuerrr:'铜合金化学镀镍',// + valuerrr: '铜合金化学镀镍', // loading: false, formLabelAlign: { startTime: null, //时间 @@ -775,17 +781,28 @@ export default { return offset; }, // 根据层索引确定窄任务文本的垂直偏移 - getNarrowTaskOffsetByLayerLeft(processName,width,layerIndex) { - // 偶数层在上方显示(负值),奇数层在下方显示(正值) - const offset = null; - - if (processName.length >= 6) { - return -15; - } - if (processName.length >= 5) { - return -17; + getNarrowTaskOffsetByLayerLeft(processName, widthPercent, layerIndex) { + // 偶数层在上方显示(负值),奇数层在下方显示(正值) + const textWidth = processName.length * 2; + const timeLine = this.$refs.timelineContainer.clientWidth; + const taskBarWidth = (timeLine * widthPercent) / 100; + + if (textWidth > taskBarWidth) { + console.log('大于宽度的', textWidth, taskBarWidth,processName); + if (processName <= 4) { + return -7; // 文字超出任务条时,向左偏移一半文字宽度 + } else { + return -textWidth*1.5; // 文字超出任务条时,向左偏移一半文字宽度 + } + } else { + // console.log('小于宽度的', textWidth, taskBarWidth,processName); + if (processName <= 4) { + return -7; // 文字超出任务条时,向左偏移一半文字宽度 + } else { + return -textWidth; // 文字超出任务条时,向左偏移一半文字宽度 + } } - return -7 + // return -7; // 默认偏移 }, handleParamsChange() { // 参数变化时的处理逻辑