diff --git a/klp-ui/src/views/wms/productionLine/GanttChartEcharts.vue b/klp-ui/src/views/wms/productionLine/GanttChartEcharts.vue index 19842cf6..dd821d22 100644 --- a/klp-ui/src/views/wms/productionLine/GanttChartEcharts.vue +++ b/klp-ui/src/views/wms/productionLine/GanttChartEcharts.vue @@ -57,6 +57,7 @@ export default { const name = (item.remark || item.taskName || item.productName || item.name || `任务${idx+1}`) + (item.productName ? `-${item.productName}` : ''); const start = item.startDate || item.start_time || item.start || item.start_date; const end = item.endDate || item.end_time || item.end || item.end_date; + console.log(item.lineId, item.orderId, idx, '颜色取值依据') return { name, value: [start, end], @@ -72,6 +73,26 @@ export default { endDate: end }; }); + // 先全部用 getColor 分配基础色 + taskData.forEach((item, idx) => { + item._color = getColor(item.lineId, item.orderId, idx); + }); + // 检查冲突(同产线时间重叠),有冲突的都标红 + for (let i = 0; i < taskData.length; i++) { + for (let j = i + 1; j < taskData.length; j++) { + if ( + taskData[i].lineId && + taskData[i].lineId === taskData[j].lineId && + new Date(taskData[i].value[0]) < new Date(taskData[j].value[1]) && + new Date(taskData[i].value[1]) > new Date(taskData[j].value[0]) + ) { + taskData[i]._color = '#F56C6C'; + taskData[j]._color = '#F56C6C'; + } + } + } + // 颜色映射 + const colorMap = taskData.map(d => d._color); // Y轴任务名 const yData = taskData.map(d => d.name); // X轴时间范围 @@ -93,10 +114,12 @@ export default { tooltip: { confine: true, formatter: params => { - const d = Array.isArray(params.data) ? params.data[3] : params.data; - return `任务:${d.name}` + - `
开始:${d.startDate}` + - `
结束:${d.endDate}` + + // 用 params.data[2] 作为索引查找 taskData + const idx = params.data && params.data[2]; + const d = (typeof idx === 'number' && taskData[idx]) ? taskData[idx] : {}; + return `任务:${d.name || ''}` + + `
开始:${d.startDate || ''}` + + `
结束:${d.endDate || ''}` + `
日产能:${d.capacity != null ? d.capacity : d.capacity || ''}` + `
总产能:${d.totalCapacity != null ? d.totalCapacity : d.total_capacity || ''}` + `
目标生产:${d.planQuantity != null ? d.planQuantity : d.plan_quantity || ''}` + @@ -128,16 +151,9 @@ export default { const start = api.coord([api.value(0), categoryIndex]); const end = api.coord([api.value(1), categoryIndex]); const barHeight = 18; - const d = Array.isArray(params.data) ? params.data[3] : params.data; - // 调试:输出d - // console.log('renderItem d:', d); - let fillColor = api.style().fill; - if (d && d.itemStyle && d.itemStyle.color) { - fillColor = d.itemStyle.color; - } else if (d && d.name && d.name.indexOf('预览') !== -1) { - // 兜底:只要是预览条,强制绿色或红色 - fillColor = '#67C23A'; - } + // 颜色从 colorMap 查 + const idx = params.dataIndex; + let fillColor = colorMap[idx] || '#409EFF'; return { type: 'rect', shape: { @@ -148,7 +164,6 @@ export default { r: 6 }, style: { - ...api.style(), fill: fillColor } }; @@ -157,7 +172,7 @@ export default { x: [0, 1], y: 2 }, - data: taskData.map((d, i) => [d.value[0], d.value[1], i, d]), + data: taskData.map((d, i) => [d.value[0], d.value[1], i]), itemStyle: { borderRadius: 6 } diff --git a/klp-ui/src/views/wms/warehouse/index.vue b/klp-ui/src/views/wms/warehouse/index.vue index cbc1cb92..08ba56fa 100644 --- a/klp-ui/src/views/wms/warehouse/index.vue +++ b/klp-ui/src/views/wms/warehouse/index.vue @@ -205,7 +205,7 @@ export default { { required: true, message: "仓库/库区名称不能为空", trigger: "blur" } ], warehouseType: [ - { required: true, message: "类型:0=仓库,1=库区,2=库位,…不能为空", trigger: "change" } + { required: true, message: "类型不能为空", trigger: "change" } ], } };