2025-12-05 11:29:28 +08:00
|
|
|
|
<template>
|
|
|
|
|
|
<div class="bird-container">
|
|
|
|
|
|
<!-- 统计信息卡片 -->
|
|
|
|
|
|
<div class="statistics-card">
|
|
|
|
|
|
<el-card shadow="hover">
|
|
|
|
|
|
<div class="statistics-item">
|
|
|
|
|
|
<span class="label">总库位数:</span>
|
|
|
|
|
|
<span class="value">{{ statistics.total }}</span>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div class="statistics-item">
|
2025-12-19 18:06:55 +08:00
|
|
|
|
<span class="label">总列数:</span>
|
|
|
|
|
|
<span class="value">{{ statistics.columnCount }}</span>
|
2025-12-05 11:29:28 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
<div class="statistics-item">
|
2025-12-19 18:06:55 +08:00
|
|
|
|
<span class="label">各列库位分布:</span>
|
2025-12-05 11:29:28 +08:00
|
|
|
|
<span class="value">
|
2025-12-19 18:06:55 +08:00
|
|
|
|
<span v-for="(count, column) in statistics.columnDetail" :key="column">
|
|
|
|
|
|
第{{ column }}列:{{ count }}个
|
2025-12-05 11:29:28 +08:00
|
|
|
|
</span>
|
|
|
|
|
|
</span>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</el-card>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
2025-12-05 13:03:08 +08:00
|
|
|
|
<!-- 图例 -->
|
|
|
|
|
|
<div class="legend-container">
|
|
|
|
|
|
<div class="legend-item">
|
2025-12-08 11:48:20 +08:00
|
|
|
|
<div class="legend-color layer-1"></div>
|
|
|
|
|
|
<span class="legend-text">一层</span>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div class="legend-item">
|
|
|
|
|
|
<div class="legend-color layer-2"></div>
|
|
|
|
|
|
<span class="legend-text">二层</span>
|
2025-12-05 13:03:08 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
<div class="legend-item">
|
|
|
|
|
|
<div class="legend-color occupied"></div>
|
|
|
|
|
|
<span class="legend-text">已占用</span>
|
|
|
|
|
|
</div>
|
2026-01-14 08:52:50 +08:00
|
|
|
|
<div class="legend-item">
|
|
|
|
|
|
<div class="legend-color error"></div>
|
|
|
|
|
|
<span class="legend-text">异常</span>
|
|
|
|
|
|
</div>
|
2025-12-05 13:03:08 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
|
2025-12-19 18:06:55 +08:00
|
|
|
|
<!-- 分列库位容器 -->
|
2025-12-05 11:29:28 +08:00
|
|
|
|
<div class="layers-container">
|
|
|
|
|
|
<!-- 无数据提示 -->
|
2025-12-19 18:06:55 +08:00
|
|
|
|
<div class="empty-tip" v-if="Object.keys(columns).length === 0 && warehouseList.length > 0">
|
|
|
|
|
|
暂无解析到有效的库位分列数据
|
2025-12-05 11:29:28 +08:00
|
|
|
|
</div>
|
2025-12-08 11:48:20 +08:00
|
|
|
|
<div class="empty-tip" v-else-if="warehouseList.length === 0">
|
2025-12-05 11:29:28 +08:00
|
|
|
|
<div class="empty-text">该分类下暂无库位数据</div>
|
|
|
|
|
|
<el-button type="primary" icon="el-icon-plus" @click="openInitDialog">初始化库位</el-button>
|
|
|
|
|
|
</div>
|
2026-01-07 10:18:26 +08:00
|
|
|
|
<warehouse-interlaced v-else="warehouseList.length" :id="id" :columns="columns"
|
2026-01-14 17:32:32 +08:00
|
|
|
|
:canToggle="canToggle" :canRelease="canRelease"
|
|
|
|
|
|
@split-warehouse="handleSplitWarehouse" @merge-warehouse="handleMergeWarehouse" @release-warehouse="handleReleaseWarehouse"/>
|
2025-12-05 11:29:28 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<script>
|
2025-12-08 11:48:20 +08:00
|
|
|
|
import WarehouseInterlaced from './WarehouseInterlaced.vue';
|
2025-12-05 11:29:28 +08:00
|
|
|
|
|
|
|
|
|
|
export default {
|
|
|
|
|
|
name: "WarehouseBird",
|
2025-12-19 18:06:55 +08:00
|
|
|
|
components: { WarehouseInterlaced },
|
2025-12-05 11:29:28 +08:00
|
|
|
|
props: {
|
|
|
|
|
|
// 原始库位列表
|
|
|
|
|
|
warehouseList: {
|
|
|
|
|
|
type: Array,
|
|
|
|
|
|
default: () => []
|
2025-12-24 10:00:26 +08:00
|
|
|
|
},
|
|
|
|
|
|
id: {
|
|
|
|
|
|
type: String,
|
|
|
|
|
|
default: ''
|
2026-01-14 17:32:32 +08:00
|
|
|
|
},
|
|
|
|
|
|
canToggle: {
|
|
|
|
|
|
default: true,
|
|
|
|
|
|
type: Boolean
|
|
|
|
|
|
},
|
|
|
|
|
|
canRelease: {
|
|
|
|
|
|
default: false,
|
|
|
|
|
|
type: Boolean
|
2025-12-05 11:29:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
data() {
|
|
|
|
|
|
return {
|
2025-12-19 18:06:55 +08:00
|
|
|
|
// 分列库位数据(核心修改:从layers改为columns)
|
|
|
|
|
|
columns: {},
|
|
|
|
|
|
// 统计信息(适配分列逻辑)
|
2025-12-05 11:29:28 +08:00
|
|
|
|
statistics: {
|
|
|
|
|
|
total: 0,
|
2025-12-19 18:06:55 +08:00
|
|
|
|
columnCount: 0,
|
|
|
|
|
|
columnDetail: {}
|
2026-01-14 17:32:32 +08:00
|
|
|
|
},
|
2025-12-05 11:29:28 +08:00
|
|
|
|
};
|
|
|
|
|
|
},
|
|
|
|
|
|
watch: {
|
2025-12-19 18:06:55 +08:00
|
|
|
|
// 监听库位列表变化,重新构建分列数据
|
2025-12-05 11:29:28 +08:00
|
|
|
|
warehouseList: {
|
|
|
|
|
|
immediate: true,
|
|
|
|
|
|
handler(newVal) {
|
|
|
|
|
|
this.buildWarehouseBox(newVal);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
methods: {
|
2025-12-19 18:06:55 +08:00
|
|
|
|
handleSplitWarehouse(warehouse) {
|
|
|
|
|
|
this.$emit('split-warehouse', warehouse);
|
|
|
|
|
|
},
|
2025-12-20 15:12:07 +08:00
|
|
|
|
|
|
|
|
|
|
handleMergeWarehouse(warehouse) {
|
|
|
|
|
|
this.$emit('merge-warehouse', warehouse);
|
|
|
|
|
|
},
|
2026-01-14 17:32:32 +08:00
|
|
|
|
|
|
|
|
|
|
handleReleaseWarehouse(warehouse) {
|
|
|
|
|
|
this.$emit('release-warehouse', warehouse);
|
|
|
|
|
|
},
|
2025-12-05 11:29:28 +08:00
|
|
|
|
/**
|
2025-12-19 18:06:55 +08:00
|
|
|
|
* 解析第三级库位编码
|
2026-01-07 10:18:26 +08:00
|
|
|
|
* 新规则:
|
|
|
|
|
|
* 1. 前三位:数字或字母的任意组合
|
|
|
|
|
|
* 2. column:从第五位开始到第一个"-"为止(支持多位数)
|
|
|
|
|
|
* 3. 保留 row(两位数字)、layer(数字)的解析规则
|
2025-12-05 11:29:28 +08:00
|
|
|
|
*/
|
|
|
|
|
|
parseWarehouseCode(code) {
|
|
|
|
|
|
if (!code) return null;
|
2026-01-07 10:18:26 +08:00
|
|
|
|
|
|
|
|
|
|
// 新正则表达式解析规则
|
|
|
|
|
|
// ^([A-Za-z0-9]{3}) :匹配前3位(数字/字母)
|
|
|
|
|
|
// . :匹配第4位(任意单个字符)
|
|
|
|
|
|
// ([^-]+) :匹配column(到第一个"-"为止,至少1位)
|
|
|
|
|
|
// -(\d{2}) :匹配row(两位数字)
|
|
|
|
|
|
// -(\d+) :匹配layer(一位或多位数字)
|
|
|
|
|
|
const reg = /^([A-Za-z0-9]{3})([^-]+)-(\d{2})-(\d+)$/;
|
2025-12-05 11:29:28 +08:00
|
|
|
|
const match = code.match(reg);
|
|
|
|
|
|
|
|
|
|
|
|
if (!match) {
|
|
|
|
|
|
console.warn(`库位编码解析失败:${code},格式不符合规范`);
|
|
|
|
|
|
return null;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return {
|
2025-12-19 18:06:55 +08:00
|
|
|
|
level: 3,
|
2026-01-07 10:18:26 +08:00
|
|
|
|
warehousePrefix: match[1], // 前三位(数字/字母),替代原warehouseFirst/warehouseSecond
|
|
|
|
|
|
warehouseFirst: match[1].slice(0, 2), // 前三位的前两个字符
|
|
|
|
|
|
warehouseSecond: match[1].slice(2, 3), // 前三位的第三个字符
|
|
|
|
|
|
column: Number(match[2]), // 第五位到第一个"-"的内容(多位数)
|
|
|
|
|
|
row: Number(match[3]), // 两位数字的行号
|
|
|
|
|
|
layer: match[4] // 层级数字(可多位数)
|
2025-12-19 18:06:55 +08:00
|
|
|
|
};
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2025-12-30 10:36:44 +08:00
|
|
|
|
* 解析第四级库位编码,格式为F2A1-X01-1
|
2025-12-19 18:06:55 +08:00
|
|
|
|
*/
|
|
|
|
|
|
parseWarehouseCodeFourth(code) {
|
|
|
|
|
|
if (!code) return null;
|
2026-01-07 10:18:26 +08:00
|
|
|
|
const reg = /^([A-Za-z0-9]{3})([^-]+)-X(\d{2})-(\d+)$/;
|
2025-12-19 18:06:55 +08:00
|
|
|
|
const match = code.match(reg);
|
|
|
|
|
|
|
|
|
|
|
|
if (!match) {
|
|
|
|
|
|
console.warn(`库位编码解析失败:${code},格式不符合规范`);
|
|
|
|
|
|
return null;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-01-07 10:18:26 +08:00
|
|
|
|
// console.log('match:', match);
|
|
|
|
|
|
|
2025-12-19 18:06:55 +08:00
|
|
|
|
return {
|
|
|
|
|
|
level: 4,
|
2026-01-07 10:18:26 +08:00
|
|
|
|
warehousePrefix: match[1],
|
|
|
|
|
|
warehouseFirst: match[1].slice(0, 2), // 前三位的前两个字符
|
|
|
|
|
|
warehouseSecond: match[1].slice(2, 3), // 前三位的第三个字符
|
|
|
|
|
|
// warehouseSecond: match[2],
|
|
|
|
|
|
column: Number(match[2]),
|
|
|
|
|
|
row: Number(match[3]),
|
|
|
|
|
|
layer: match[4],
|
2025-12-05 11:29:28 +08:00
|
|
|
|
};
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2025-12-19 18:06:55 +08:00
|
|
|
|
* 重构:按列构建库位数据结构,每列分为两层数组
|
2025-12-05 11:29:28 +08:00
|
|
|
|
*/
|
|
|
|
|
|
buildWarehouseBox(list) {
|
2025-12-19 18:06:55 +08:00
|
|
|
|
const columnMap = {}; // 按列分组的核心对象
|
2025-12-05 11:29:28 +08:00
|
|
|
|
const statistics = {
|
|
|
|
|
|
total: list.length,
|
2025-12-19 18:06:55 +08:00
|
|
|
|
columnCount: 0,
|
|
|
|
|
|
columnDetail: {},
|
2025-12-05 11:29:28 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
2025-12-19 18:06:55 +08:00
|
|
|
|
// 1. 按列分组,每列内部分为layer1和layer2两个数组
|
2025-12-05 11:29:28 +08:00
|
|
|
|
list.forEach((warehouse) => {
|
2025-12-19 18:06:55 +08:00
|
|
|
|
let codeInfo = {}
|
|
|
|
|
|
if (warehouse.actualWarehouseType == 4) {
|
|
|
|
|
|
codeInfo = this.parseWarehouseCodeFourth(warehouse.actualWarehouseCode);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
codeInfo = this.parseWarehouseCode(warehouse.actualWarehouseCode);
|
|
|
|
|
|
}
|
2025-12-05 11:29:28 +08:00
|
|
|
|
if (!codeInfo) return;
|
|
|
|
|
|
|
|
|
|
|
|
const { layer, row, column } = codeInfo;
|
|
|
|
|
|
warehouse.parsedInfo = codeInfo;
|
|
|
|
|
|
|
2025-12-19 18:06:55 +08:00
|
|
|
|
// 初始化列数据结构:每列包含layer1、layer2数组,以及最大行号
|
|
|
|
|
|
if (!columnMap[column]) {
|
|
|
|
|
|
columnMap[column] = {
|
2025-12-05 11:29:28 +08:00
|
|
|
|
maxRow: 0,
|
2025-12-19 18:06:55 +08:00
|
|
|
|
layer1: [], // 第一层库位数组
|
|
|
|
|
|
layer2: [], // 第二层库位数组
|
|
|
|
|
|
total: 0 // 该列总库位数
|
2025-12-05 11:29:28 +08:00
|
|
|
|
};
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-12-19 18:06:55 +08:00
|
|
|
|
// 更新列的最大行号
|
|
|
|
|
|
columnMap[column].maxRow = Math.max(columnMap[column].maxRow, row);
|
|
|
|
|
|
|
|
|
|
|
|
// 根据层数将库位放入对应数组
|
|
|
|
|
|
if (layer === '1' || layer === 1) {
|
|
|
|
|
|
columnMap[column].layer1.push(warehouse);
|
|
|
|
|
|
} else if (layer === '2' || layer === 2) {
|
|
|
|
|
|
columnMap[column].layer2.push(warehouse);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 更新该列总库位数
|
|
|
|
|
|
columnMap[column].total = columnMap[column].layer1.length + columnMap[column].layer2.length;
|
2025-12-05 11:29:28 +08:00
|
|
|
|
});
|
|
|
|
|
|
|
2025-12-19 18:06:55 +08:00
|
|
|
|
// 2. 对每列的两层数据分别按行号排序
|
|
|
|
|
|
Object.keys(columnMap).forEach((column) => {
|
|
|
|
|
|
const columnData = columnMap[column];
|
2026-01-07 10:18:26 +08:00
|
|
|
|
|
2025-12-19 18:06:55 +08:00
|
|
|
|
// 按行号排序(保证展示顺序正确)
|
|
|
|
|
|
columnData.layer1.sort((a, b) => a.parsedInfo.row - b.parsedInfo.row);
|
|
|
|
|
|
columnData.layer2.sort((a, b) => a.parsedInfo.row - b.parsedInfo.row);
|
2025-12-05 11:29:28 +08:00
|
|
|
|
});
|
|
|
|
|
|
|
2025-12-19 18:06:55 +08:00
|
|
|
|
// 3. 更新统计信息(适配分列逻辑)
|
|
|
|
|
|
statistics.columnCount = Object.keys(columnMap).length;
|
|
|
|
|
|
Object.keys(columnMap).forEach((column) => {
|
|
|
|
|
|
statistics.columnDetail[column] = columnMap[column].total;
|
2025-12-05 11:29:28 +08:00
|
|
|
|
});
|
|
|
|
|
|
|
2025-12-19 18:06:55 +08:00
|
|
|
|
// 4. 赋值到响应式数据
|
|
|
|
|
|
this.columns = columnMap;
|
2025-12-05 11:29:28 +08:00
|
|
|
|
this.statistics = statistics;
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 打开初始化弹窗(透传至根组件)
|
|
|
|
|
|
*/
|
|
|
|
|
|
openInitDialog() {
|
|
|
|
|
|
this.$emit('open-init-dialog');
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
};
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
<style scoped lang="scss">
|
|
|
|
|
|
.bird-container {
|
|
|
|
|
|
width: 100%;
|
|
|
|
|
|
height: 100%;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 统计卡片样式
|
|
|
|
|
|
.statistics-card {
|
|
|
|
|
|
margin-bottom: 16px;
|
|
|
|
|
|
|
|
|
|
|
|
.statistics-item {
|
|
|
|
|
|
margin-bottom: 8px;
|
|
|
|
|
|
|
|
|
|
|
|
&:last-child {
|
|
|
|
|
|
margin-bottom: 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.label {
|
|
|
|
|
|
color: #606266;
|
|
|
|
|
|
font-size: 14px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.value {
|
|
|
|
|
|
color: #303133;
|
|
|
|
|
|
font-size: 14px;
|
|
|
|
|
|
font-weight: 500;
|
|
|
|
|
|
margin-left: 8px;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-12-05 13:03:08 +08:00
|
|
|
|
// 图例样式
|
|
|
|
|
|
.legend-container {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
margin-bottom: 16px;
|
|
|
|
|
|
padding: 8px 12px;
|
|
|
|
|
|
background: #f8f9fa;
|
|
|
|
|
|
border-radius: 4px;
|
|
|
|
|
|
|
|
|
|
|
|
.legend-item {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
margin-right: 24px;
|
|
|
|
|
|
|
|
|
|
|
|
&:last-child {
|
|
|
|
|
|
margin-right: 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.legend-color {
|
|
|
|
|
|
width: 16px;
|
|
|
|
|
|
height: 16px;
|
|
|
|
|
|
border-radius: 2px;
|
|
|
|
|
|
margin-right: 8px;
|
|
|
|
|
|
border: 1px solid #e6e6e6;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.normal {
|
|
|
|
|
|
background-color: #ffffff;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-12-08 11:48:20 +08:00
|
|
|
|
.layer-1 {
|
|
|
|
|
|
background-color: #fff3e0;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.layer-2 {
|
|
|
|
|
|
background-color: #e8f5e9;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-12-05 13:03:08 +08:00
|
|
|
|
.occupied {
|
2025-12-19 18:06:55 +08:00
|
|
|
|
background-color: #fafafa;
|
2025-12-05 13:03:08 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2026-01-14 08:52:50 +08:00
|
|
|
|
.error {
|
|
|
|
|
|
background-color: #fdecea;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-12-05 13:03:08 +08:00
|
|
|
|
.legend-text {
|
|
|
|
|
|
font-size: 14px;
|
|
|
|
|
|
color: #606266;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-12-19 18:06:55 +08:00
|
|
|
|
// 分列容器样式
|
2025-12-05 11:29:28 +08:00
|
|
|
|
.layers-container {
|
2025-12-05 13:03:08 +08:00
|
|
|
|
display: flex;
|
2026-01-07 10:18:26 +08:00
|
|
|
|
|
2025-12-05 11:29:28 +08:00
|
|
|
|
.layer-section {
|
2025-12-05 13:03:08 +08:00
|
|
|
|
flex: 1;
|
|
|
|
|
|
max-width: 50%;
|
2025-12-05 11:29:28 +08:00
|
|
|
|
margin-bottom: 24px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.empty-tip {
|
|
|
|
|
|
text-align: center;
|
|
|
|
|
|
padding: 32px;
|
|
|
|
|
|
color: #909399;
|
|
|
|
|
|
font-size: 14px;
|
|
|
|
|
|
background: #fff;
|
|
|
|
|
|
border-radius: 8px;
|
|
|
|
|
|
|
|
|
|
|
|
.empty-text {
|
|
|
|
|
|
margin-bottom: 16px;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
</style>
|