diff --git a/src/views/productionSchedulingPlan/schedulingDashboard/index.vue b/src/views/productionSchedulingPlan/schedulingDashboard/index.vue index fb571aa..146c4d5 100644 --- a/src/views/productionSchedulingPlan/schedulingDashboard/index.vue +++ b/src/views/productionSchedulingPlan/schedulingDashboard/index.vue @@ -14,7 +14,7 @@ - + @@ -99,8 +99,12 @@
{{ device }} @@ -181,24 +185,33 @@ v-for="(device, devIndex) in devices" :key="devIndex" class="device-task-row" - :style="{ height: rowHeight + 'px' }" + :style="{ height: getRowHeight(device) + 'px' }" > -
- {{ task.processName }} - {{ task.woCode }} - {{ task.woCode }} -
+
@@ -293,6 +306,8 @@ export default { tooltipData: {}, tooltipX: 0, tooltipY: 0, + baseRowHeight: 40, // 基础行高(单任务时的高度) + rowHeights: {}, // 存储每个设备的动态行高 }; }, computed: { @@ -322,7 +337,6 @@ export default { methods: { getData() { getData(this.formLabelAlign).then(res => { - console.log(99999, res.data.data); this.processData(res.data.data); }); }, @@ -435,13 +449,15 @@ export default { }, // 根据状态获取颜色 - getStatusColor(status) { - switch (status) { - case '已完成': + getStatusColor(row) { + let staus=this.searchType=='1'?row.planStatus:row.orderStatus + + switch (staus) { + case '3': return '#28a745'; - case '进行中': + case '2': return '#007bff'; - case '未开始': + case '1': return '#6c757d'; default: return '#ccc'; @@ -478,23 +494,73 @@ export default { hideTooltip() { this.tooltipVisible = false; }, - // 在methods中添加处理重叠任务的方法 + // 计算每个设备的行高 + getRowHeight(device) { + const layers = this.getLayeredTasks(device); + const layerCount = layers.length; + // 行高 = 基础行高 * 层数(确保至少有基础行高) + const height = Math.max(this.baseRowHeight, layerCount * this.baseRowHeight); + // 缓存计算结果避免重复计算 + this.rowHeights[device] = height; + return height; + }, + + // 修复层级偏移计算(基于实际行高) + getLayerOffset(layerIndex, totalLayers, device) { + const rowHeight = this.getRowHeight(device); + if (totalLayers <= 1) return 2; // 单层级时的顶部间距 + + // 计算每层可用高度(减去总间距) + const totalSpacing = totalLayers * 4; // 每层4px间距 + const availableHeight = rowHeight - totalSpacing; + const layerHeight = availableHeight / totalLayers; + return layerIndex * (layerHeight + 4) + 2; // 2px顶部边距 + }, + + // 修复任务高度计算(基于实际行高) + getLayerTaskHeight(totalLayers, device) { + const rowHeight = this.getRowHeight(device); + if (totalLayers <= 1) { + return rowHeight - 4; // 减去上下间距 + } else { + const totalSpacing = totalLayers * 4; + const availableHeight = rowHeight - totalSpacing; + return availableHeight / totalLayers; + } + }, + + // 优化层级计算逻辑 getLayeredTasks(device) { const tasks = this.getDeviceTasks(device); if (!tasks.length) return []; - // 按开始时间排序 + // 按开始时间排序,并处理跨天任务 const sortedTasks = [...tasks].sort((a, b) => { - return this.timeToMinutes(a.startTime) - this.timeToMinutes(b.startTime); + const aStart = this.timeToMinutes(a.startTime); + const bStart = this.timeToMinutes(b.startTime); + // 跨天任务(结束时间小于开始时间)排在前面 + if (this.timeToMinutes(a.endTime) < aStart && this.timeToMinutes(b.endTime) >= bStart) { + return -1; + } + return aStart - bStart; }); const layers = []; sortedTasks.forEach(task => { - // 尝试找到可以放置当前任务的层级 let placed = false; + const taskStart = this.timeToMinutes(task.startTime); + const taskEnd = this.timeToMinutes(task.endTime); + + // 处理跨天任务的结束时间(转换为第二天的分钟数) + const adjustedEnd = taskEnd < taskStart ? taskEnd + 24 * 60 : taskEnd; + for (let i = 0; i < layers.length; i++) { const lastTask = layers[i][layers[i].length - 1]; - if (this.timeToMinutes(task.startTime) >= this.timeToMinutes(lastTask.endTime)) { + const lastEnd = this.timeToMinutes(lastTask.endTime); + const lastAdjustedEnd = + lastEnd < this.timeToMinutes(lastTask.startTime) ? lastEnd + 24 * 60 : lastEnd; + + if (taskStart >= lastAdjustedEnd) { layers[i].push(task); placed = true; break; @@ -507,20 +573,6 @@ export default { return layers; }, - - // 计算任务所在层级的垂直偏移 - getLayerOffset(layerIndex, totalLayers) { - if (totalLayers <= 1) return 0; - // 每层高度 = 行高 / 总层数 - const layerHeight = this.rowHeight / totalLayers; - return layerIndex * layerHeight + 2; // 加2px间距 - }, - - // 计算任务在层级中的高度 - getLayerTaskHeight(totalLayers) { - if (totalLayers <= 1) return this.rowHeight - 4; // 减4px间距 - return this.rowHeight / totalLayers - 4; - }, }, }; @@ -633,7 +685,7 @@ export default { } } .device-item-title { - background: var(--el-color-primary); + background: #284c89 !important; text-align: center; color: #fff; } @@ -659,7 +711,7 @@ export default { width: 100%; height: 30px; display: flex; - background-color: var(--el-color-primary); + background-color: #284c89 !important; } /* 主刻度标签(小时) */ @@ -703,7 +755,7 @@ export default { left: 0; width: 100%; height: 6px; - background-color: var(--el-color-primary); + background-color: #284c89 !important; } /* 主刻度线(小时) */ @@ -780,13 +832,13 @@ export default { position: relative; border-bottom: 1px solid #e9ecef; box-sizing: border-box; + padding: 0; + margin: 0; } .task-bar { position: absolute; - top: 5px; - height: 26px; - border-radius: 4px; + border-radius: 18px; display: flex; align-items: center; padding: 0 10px; @@ -794,6 +846,7 @@ export default { cursor: pointer; overflow: hidden; transition: all 0.2s; + white-space: nowrap; } .task-bar:hover { @@ -857,4 +910,8 @@ export default { } } } +:deep(.el-button--primary){ + background-color: #284c89 !important; + color:#fff +} diff --git a/src/views/productionSchedulingPlan/schedulingException/index.vue b/src/views/productionSchedulingPlan/schedulingException/index.vue index 36c5605..f7ad268 100644 --- a/src/views/productionSchedulingPlan/schedulingException/index.vue +++ b/src/views/productionSchedulingPlan/schedulingException/index.vue @@ -16,7 +16,6 @@ @refresh-change="refreshChange" @on-load="onLoad" > - @@ -106,14 +105,14 @@ export default { width: 150, span: 12, }, - // { - // label: '处理方式', - // prop: 'partName', - // search: false, - // sortable: true, - // width: 150, - // span: 12, - // }, + // { + // label: '处理方式', + // prop: 'partName', + // search: false, + // sortable: true, + // width: 150, + // span: 12, + // }, { label: '调度员', prop: 'planUser', @@ -301,3 +300,9 @@ export default { }, }; +