大屏判断逻辑修改

This commit is contained in:
jhd
2026-05-27 11:54:52 +08:00
parent 75f745cdb2
commit 6313be9c52

View File

@@ -82,7 +82,7 @@
</div>
<div class="legend-item">
<span class="chart-dot available"></span>
可用 <span class="legend-val">{{ statistics.available }}</span>
空闲 <span class="legend-val">{{ statistics.available }}</span>
</div>
</div>
</div>
@@ -109,7 +109,7 @@
<div class="grid-legend">
<div class="legend-item">
<span class="legend-dot available"></span>
<span>可用</span>
<span>空闲</span>
</div>
<div class="legend-item">
<span class="legend-dot occupied"></span>
@@ -492,7 +492,7 @@ export default {
data: [
{ value: statistics.occupied || 0, name: '已占用', itemStyle: { color: '#7c63ff' } },
{ value: statistics.error || 0, name: '异常', itemStyle: { color: '#ff6b6b' } },
{ value: statistics.available || 0, name: '可用', itemStyle: { color: '#00ff88' } }
{ value: statistics.available || 0, name: '空闲', itemStyle: { color: '#00ff88' } }
]
}],
graphic: [
@@ -569,15 +569,13 @@ export default {
// 统计数据 — 与 getStatusClass 逻辑一一对应
const total = warehouseList.value.length
const error = warehouseList.value.filter(w =>
w.isEnabled === 0 && !w.currentCoilNo
).length
const occupied = warehouseList.value.filter(w =>
w.isEnabled === 0 && w.currentCoilNo
).length
const available = warehouseList.value.filter(w =>
w.isEnabled !== 0
w.isEnabled === 1 && !w.currentCoilNo
).length
const error = total - occupied - available
const usable = occupied + available
const utilization = usable > 0 ? Math.round((occupied / usable) * 100) : 0
@@ -603,37 +601,52 @@ export default {
// 获取状态文本
const getStatusText = (row) => {
if (row.isEnabled === 0 && !row.currentCoilNo) {
return '异常'
} else if (row.isEnabled === 0 && row.currentCoilNo) {
if (row.isEnabled === 0 && row.currentCoilNo) {
return '已占用'
} else if (row.isEnabled === 1 && !row.currentCoilNo) {
return '空闲'
} else {
return '可用'
return '异常'
}
}
// 获取状态样式类
const getStatusClass = (row) => {
if (row.isEnabled === 0 && !row.currentCoilNo) {
return 'error'
} else if (row.isEnabled === 0 && row.currentCoilNo) {
if (row.isEnabled === 0 && row.currentCoilNo) {
return 'occupied'
} else {
} else if (row.isEnabled === 1 && !row.currentCoilNo) {
return 'available'
} else {
return 'error'
}
}
// 解析库位编码: F2A101-01-1 → { column: 101, row: 1, layer: 1 }
// 解析库位编码:支持三级编码 F2B101-01-1 和四级编码 F2B3-X38-2
const parseWarehouseCode = (code) => {
if (!code) return null
const reg = /^([A-Za-z0-9]{3})([^-]+)-(\d{2})-(\d+)$/
const match = code.match(reg)
if (!match) return null
return {
column: Number(match[2]),
row: Number(match[3]),
layer: match[4]
// 先尝试四级编码 F2B3-X38-2
const reg4 = /^([A-Za-z0-9]{3})([^-]+)-X(\d{2})-(\d+)$/
const match4 = code.match(reg4)
if (match4) {
return {
level: 4,
column: Number(match4[2]),
row: Number(match4[3]),
layer: match4[4]
}
}
// 再尝试三级编码 F2B101-01-1
const reg3 = /^([A-Za-z0-9]{3})([^-]+)-(\d{2})-(\d+)$/
const match3 = code.match(reg3)
if (match3) {
return {
level: 3,
column: Number(match3[2]),
row: Number(match3[3]),
layer: match3[4]
}
}
return null
}
// 构建网格数据结构:按列分组 → 按层分行