排产代码提交

dev-scheduling
zhangdi 4 months ago
parent 90c6031f56
commit b1c2bed160
  1. 131
      src/views/productionSchedulingPlan/schedulingDashboard/index.vue
  2. 7
      src/views/productionSchedulingPlan/schedulingException/index.vue

@ -14,7 +14,7 @@
</el-col> </el-col>
<el-col :span="6" v-if="formLabelAlign.type == '1'"> <el-col :span="6" v-if="formLabelAlign.type == '1'">
<el-form-item label="车间订单号:" label-width="120px"> <el-form-item label="车间订单号:" label-width="120px">
<el-input v-model="formLabelAlign.woCode"></el-input> <el-input v-model="formLabelAlign.woCode" placeholder="请输入"></el-input>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="6" v-if="formLabelAlign.type == '2'"> <el-col :span="6" v-if="formLabelAlign.type == '2'">
@ -99,8 +99,12 @@
<div <div
v-for="(device, index) in devices" v-for="(device, index) in devices"
:key="index" :key="index"
class="device-item" :style="{
:style="{ height: rowHeight + 'px' }" height: getRowHeight(device) + 'px',
lineHeight: getRowHeight(device) + 'px',
textAlign: 'center',
borderBottom: '1px solid #ccc',
}"
:title="device" :title="device"
> >
{{ device }} {{ device }}
@ -181,24 +185,33 @@
v-for="(device, devIndex) in devices" v-for="(device, devIndex) in devices"
:key="devIndex" :key="devIndex"
class="device-task-row" class="device-task-row"
:style="{ height: rowHeight + 'px' }" :style="{ height: getRowHeight(device) + 'px' }"
> >
<template v-for="(layer, layerIndex) in getLayeredTasks(device)" :key="layerIndex">
<div <div
v-for="(task, taskIndex) in getDeviceTasks(device)" v-for="(task, taskIndex) in layer"
:key="taskIndex" :key="taskIndex"
class="task-bar" class="task-bar"
:style="{ :style="{
left: `${getPositionPercent(task.startTime)}%`, left: `${getPositionPercent(task.startTime)}%`,
width: `${getWidthPercent(task.startTime, task.endTime)}%`, width: `${getWidthPercent(task.startTime, task.endTime)}%`,
backgroundColor: getStatusColor(task.status), backgroundColor: getStatusColor(task),
top: `${getLayerOffset(
layerIndex,
getLayeredTasks(device).length,
device
)}px`,
height: `${getLayerTaskHeight(getLayeredTasks(device).length, device)}px`,
}" }"
@mouseenter="showTooltip($event, task, device)" @mouseenter="showTooltip($event, task, device)"
@mouseleave="hideTooltip()" @mouseleave="hideTooltip()"
> >
<!-- 任务标签内容不变 -->
<span class="task-label" v-if="searchType == '1'">{{ task.processName }}</span> <span class="task-label" v-if="searchType == '1'">{{ task.processName }}</span>
<span class="task-label" v-if="searchType == '2'">{{ task.woCode }}</span> <span class="task-label" v-if="searchType == '2'">{{ task.woCode }}</span>
<span class="task-label" v-if="searchType == '3'">{{ task.woCode }}</span> <span class="task-label" v-if="searchType == '3'">{{ task.woCode }}</span>
</div> </div>
</template>
</div> </div>
</div> </div>
</div> </div>
@ -293,6 +306,8 @@ export default {
tooltipData: {}, tooltipData: {},
tooltipX: 0, tooltipX: 0,
tooltipY: 0, tooltipY: 0,
baseRowHeight: 40, //
rowHeights: {}, //
}; };
}, },
computed: { computed: {
@ -322,7 +337,6 @@ export default {
methods: { methods: {
getData() { getData() {
getData(this.formLabelAlign).then(res => { getData(this.formLabelAlign).then(res => {
console.log(99999, res.data.data);
this.processData(res.data.data); this.processData(res.data.data);
}); });
}, },
@ -435,13 +449,15 @@ export default {
}, },
// //
getStatusColor(status) { getStatusColor(row) {
switch (status) { let staus=this.searchType=='1'?row.planStatus:row.orderStatus
case '已完成':
switch (staus) {
case '3':
return '#28a745'; return '#28a745';
case '进行中': case '2':
return '#007bff'; return '#007bff';
case '未开始': case '1':
return '#6c757d'; return '#6c757d';
default: default:
return '#ccc'; return '#ccc';
@ -478,23 +494,73 @@ export default {
hideTooltip() { hideTooltip() {
this.tooltipVisible = false; 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) { getLayeredTasks(device) {
const tasks = this.getDeviceTasks(device); const tasks = this.getDeviceTasks(device);
if (!tasks.length) return []; if (!tasks.length) return [];
// //
const sortedTasks = [...tasks].sort((a, b) => { 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 = []; const layers = [];
sortedTasks.forEach(task => { sortedTasks.forEach(task => {
//
let placed = false; 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++) { for (let i = 0; i < layers.length; i++) {
const lastTask = layers[i][layers[i].length - 1]; 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); layers[i].push(task);
placed = true; placed = true;
break; break;
@ -507,20 +573,6 @@ export default {
return layers; 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;
},
}, },
}; };
</script> </script>
@ -633,7 +685,7 @@ export default {
} }
} }
.device-item-title { .device-item-title {
background: var(--el-color-primary); background: #284c89 !important;
text-align: center; text-align: center;
color: #fff; color: #fff;
} }
@ -659,7 +711,7 @@ export default {
width: 100%; width: 100%;
height: 30px; height: 30px;
display: flex; display: flex;
background-color: var(--el-color-primary); background-color: #284c89 !important;
} }
/* 主刻度标签(小时) */ /* 主刻度标签(小时) */
@ -703,7 +755,7 @@ export default {
left: 0; left: 0;
width: 100%; width: 100%;
height: 6px; height: 6px;
background-color: var(--el-color-primary); background-color: #284c89 !important;
} }
/* 主刻度线(小时) */ /* 主刻度线(小时) */
@ -780,13 +832,13 @@ export default {
position: relative; position: relative;
border-bottom: 1px solid #e9ecef; border-bottom: 1px solid #e9ecef;
box-sizing: border-box; box-sizing: border-box;
padding: 0;
margin: 0;
} }
.task-bar { .task-bar {
position: absolute; position: absolute;
top: 5px; border-radius: 18px;
height: 26px;
border-radius: 4px;
display: flex; display: flex;
align-items: center; align-items: center;
padding: 0 10px; padding: 0 10px;
@ -794,6 +846,7 @@ export default {
cursor: pointer; cursor: pointer;
overflow: hidden; overflow: hidden;
transition: all 0.2s; transition: all 0.2s;
white-space: nowrap;
} }
.task-bar:hover { .task-bar:hover {
@ -857,4 +910,8 @@ export default {
} }
} }
} }
:deep(.el-button--primary){
background-color: #284c89 !important;
color:#fff
}
</style> </style>

@ -16,7 +16,6 @@
@refresh-change="refreshChange" @refresh-change="refreshChange"
@on-load="onLoad" @on-load="onLoad"
> >
</avue-crud> </avue-crud>
</basic-container> </basic-container>
</template> </template>
@ -301,3 +300,9 @@ export default {
}, },
}; };
</script> </script>
<style lang="scss" scoped>
:deep(.el-button--primary) {
background-color: #284c89 !important;
color: #fff;
}
</style>

Loading…
Cancel
Save