2025-12-05 11:29:28 +08:00
|
|
|
|
<template>
|
2025-12-05 13:03:08 +08:00
|
|
|
|
<div>
|
|
|
|
|
|
<div style="display: flex; align-items: center;">
|
|
|
|
|
|
<el-divider content-position="left">第{{ layer }}层库位</el-divider>
|
|
|
|
|
|
<el-button type="text" icon="el-icon-refresh-left" size="mini" @click="toggleTranspose">
|
|
|
|
|
|
{{ isTransposed ? '恢复行列' : '行列转置' }}
|
|
|
|
|
|
</el-button>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div class="grid-wrapper">
|
|
|
|
|
|
<div class="grid-scroll-container" ref="scrollContainerRef">
|
2025-12-06 10:01:49 +08:00
|
|
|
|
<div class="scroll-content" ref="contentRef">
|
2025-12-05 13:03:08 +08:00
|
|
|
|
<!-- 列标尺(顶部) -->
|
2025-12-06 10:01:49 +08:00
|
|
|
|
<div class="col-ruler" :style="{ '--cell-width': `${cellWidth}px` }">
|
2025-12-05 13:03:08 +08:00
|
|
|
|
<div class="ruler-empty"></div>
|
|
|
|
|
|
<div v-for="col in transposedLayerData.maxColumn" :key="`col-${layer}-${col}`" class="ruler-item">
|
|
|
|
|
|
{{ col }}
|
2025-12-05 11:29:28 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
2025-12-05 13:03:08 +08:00
|
|
|
|
<!-- 行标尺 + 库位网格 -->
|
|
|
|
|
|
<div class="row-grid-wrapper">
|
|
|
|
|
|
<!-- 行标尺(左侧) -->
|
|
|
|
|
|
<div class="row-ruler">
|
|
|
|
|
|
<div v-for="row in transposedLayerData.maxRow" :key="`row-${layer}-${row}`" class="ruler-item">
|
|
|
|
|
|
{{ row }}
|
|
|
|
|
|
</div>
|
2025-12-05 11:29:28 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
|
2025-12-06 10:01:49 +08:00
|
|
|
|
<!-- 库位网格 - 修复伪元素遮挡问题 -->
|
|
|
|
|
|
<div class="grid-container"
|
|
|
|
|
|
:style="{
|
|
|
|
|
|
'--cell-width': `${cellWidth}px`,
|
|
|
|
|
|
'--column-count': transposedLayerData.maxColumn
|
|
|
|
|
|
}">
|
2025-12-05 13:03:08 +08:00
|
|
|
|
<!-- 库位格子 -->
|
|
|
|
|
|
<div v-for="warehouse in transposedLayerData.warehouses" :key="warehouse.actualWarehouseId"
|
|
|
|
|
|
class="warehouse-cell" :class="{ disabled: warehouse.isEnabled === 0 }"
|
|
|
|
|
|
@click="handleCellClick(warehouse)">
|
|
|
|
|
|
<div class="cell-name">{{ warehouse.actualWarehouseName || '-' }}</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<!-- 空库位占位 -->
|
|
|
|
|
|
<div class="warehouse-cell empty-cell" v-for="i in transposedLayerData.emptyCount"
|
|
|
|
|
|
:key="`empty-${layer}-${i}`">
|
|
|
|
|
|
<div class="cell-code">-</div>
|
|
|
|
|
|
</div>
|
2025-12-05 11:29:28 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
2025-12-06 10:01:49 +08:00
|
|
|
|
<!-- 弹窗修复:改回 .sync 绑定,恢复 footer 插槽写法 -->
|
2025-12-05 13:03:08 +08:00
|
|
|
|
<el-dialog title="库位详情" :visible.sync="dialogVisible" width="600px" destroy-on-close append-to-body center>
|
|
|
|
|
|
<el-descriptions :column="2" border size="small" v-if="currentWarehouse">
|
|
|
|
|
|
<el-descriptions-item label="库位编码">{{ currentWarehouse.actualWarehouseCode }}</el-descriptions-item>
|
|
|
|
|
|
<el-descriptions-item label="库位名称">{{ currentWarehouse.actualWarehouseName || '无' }}</el-descriptions-item>
|
|
|
|
|
|
<el-descriptions-item label="所属层级">{{ currentWarehouse.parsedInfo.layer || '未知' }}</el-descriptions-item>
|
|
|
|
|
|
<el-descriptions-item label="行号">
|
|
|
|
|
|
{{ isTransposed ? currentWarehouse.parsedInfo.column : currentWarehouse.parsedInfo.row || '未知' }}
|
|
|
|
|
|
</el-descriptions-item>
|
|
|
|
|
|
<el-descriptions-item label="列号">
|
|
|
|
|
|
{{ isTransposed ? currentWarehouse.parsedInfo.row : currentWarehouse.parsedInfo.column || '未知' }}
|
|
|
|
|
|
</el-descriptions-item>
|
2025-12-06 10:01:49 +08:00
|
|
|
|
<el-descriptions-item label="一级编码">{{ currentWarehouse.parsedInfo.warehouseFirst || '未知' }}</el-descriptions-item>
|
|
|
|
|
|
<el-descriptions-item label="二级编码">{{ currentWarehouse.parsedInfo.warehouseSecond || '未知' }}</el-descriptions-item>
|
2025-12-05 13:03:08 +08:00
|
|
|
|
<el-descriptions-item label="启用状态">
|
|
|
|
|
|
<el-tag :type="currentWarehouse.isEnabled === 1 ? 'success' : 'danger'">
|
|
|
|
|
|
{{ currentWarehouse.isEnabled === 1 ? '启用' : '禁用' }}
|
|
|
|
|
|
</el-tag>
|
|
|
|
|
|
</el-descriptions-item>
|
|
|
|
|
|
<el-descriptions-item label="库位码">
|
|
|
|
|
|
<QRCode :content="currentWarehouse.actualWarehouseId" size="60" />
|
|
|
|
|
|
</el-descriptions-item>
|
|
|
|
|
|
<el-descriptions-item label="创建时间" span="2">{{ currentWarehouse.createTime || '无' }}</el-descriptions-item>
|
|
|
|
|
|
<el-descriptions-item label="备注信息" span="2">{{ currentWarehouse.remark || '无' }}</el-descriptions-item>
|
|
|
|
|
|
</el-descriptions>
|
|
|
|
|
|
<template slot="footer">
|
|
|
|
|
|
<el-button @click="dialogVisible = false">关闭</el-button>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
</el-dialog>
|
|
|
|
|
|
</div>
|
2025-12-05 11:29:28 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
|
import QRCode from '@/components/QRCode/index.vue';
|
|
|
|
|
|
|
|
|
|
|
|
export default {
|
|
|
|
|
|
name: "WarehouseGrid",
|
|
|
|
|
|
components: { QRCode },
|
|
|
|
|
|
props: {
|
|
|
|
|
|
layer: {
|
|
|
|
|
|
type: [String, Number],
|
|
|
|
|
|
required: true
|
|
|
|
|
|
},
|
|
|
|
|
|
layerData: {
|
|
|
|
|
|
type: Object,
|
|
|
|
|
|
required: true,
|
|
|
|
|
|
default: () => ({
|
|
|
|
|
|
maxRow: 0,
|
|
|
|
|
|
maxColumn: 0,
|
|
|
|
|
|
warehouses: [],
|
|
|
|
|
|
emptyCount: 0
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
data() {
|
|
|
|
|
|
return {
|
|
|
|
|
|
dialogVisible: false,
|
|
|
|
|
|
currentWarehouse: null,
|
2025-12-06 10:01:49 +08:00
|
|
|
|
isTransposed: false,
|
|
|
|
|
|
containerWidth: 0,
|
|
|
|
|
|
resizeTimer: null
|
2025-12-05 11:29:28 +08:00
|
|
|
|
};
|
|
|
|
|
|
},
|
|
|
|
|
|
computed: {
|
|
|
|
|
|
transposedLayerData() {
|
|
|
|
|
|
const { maxRow, maxColumn, warehouses } = this.layerData;
|
|
|
|
|
|
const transMaxRow = this.isTransposed ? maxColumn : maxRow;
|
|
|
|
|
|
const transMaxColumn = this.isTransposed ? maxRow : maxColumn;
|
|
|
|
|
|
|
2025-12-06 10:01:49 +08:00
|
|
|
|
// 深拷贝避免修改原数据
|
2025-12-05 11:29:28 +08:00
|
|
|
|
const transWarehouses = JSON.parse(JSON.stringify(warehouses)).map(item => {
|
|
|
|
|
|
if (this.isTransposed && item.parsedInfo) {
|
|
|
|
|
|
const { row, column } = item.parsedInfo;
|
|
|
|
|
|
item.parsedInfo.row = column;
|
|
|
|
|
|
item.parsedInfo.column = row;
|
|
|
|
|
|
}
|
|
|
|
|
|
return item;
|
|
|
|
|
|
});
|
|
|
|
|
|
|
2025-12-06 10:01:49 +08:00
|
|
|
|
// 排序保证网格展示顺序正确
|
2025-12-05 11:29:28 +08:00
|
|
|
|
transWarehouses.sort((a, b) => {
|
|
|
|
|
|
if (a.parsedInfo.row !== b.parsedInfo.row) {
|
|
|
|
|
|
return a.parsedInfo.row - b.parsedInfo.row;
|
|
|
|
|
|
}
|
|
|
|
|
|
return a.parsedInfo.column - b.parsedInfo.column;
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
const totalGrid = transMaxRow * transMaxColumn;
|
|
|
|
|
|
const emptyCount = Math.max(0, totalGrid - transWarehouses.length);
|
|
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
|
maxRow: transMaxRow,
|
|
|
|
|
|
maxColumn: transMaxColumn,
|
|
|
|
|
|
warehouses: transWarehouses,
|
|
|
|
|
|
emptyCount
|
|
|
|
|
|
};
|
2025-12-06 10:01:49 +08:00
|
|
|
|
},
|
|
|
|
|
|
cellWidth() {
|
|
|
|
|
|
if (!this.containerWidth || this.transposedLayerData.maxColumn === 0) return 60;
|
|
|
|
|
|
// 容器可用宽度 = 滚动容器宽度 - 行标尺宽度(30px)
|
|
|
|
|
|
const availableWidth = Math.max(0, this.containerWidth - 30);
|
|
|
|
|
|
// 均分宽度,最小60px
|
|
|
|
|
|
const averageWidth = availableWidth / this.transposedLayerData.maxColumn;
|
|
|
|
|
|
return Math.max(60, averageWidth);
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
watch: {
|
|
|
|
|
|
isTransposed() {
|
|
|
|
|
|
this.calcContainerWidth();
|
|
|
|
|
|
},
|
|
|
|
|
|
layerData: {
|
|
|
|
|
|
deep: true,
|
|
|
|
|
|
handler() {
|
|
|
|
|
|
this.calcContainerWidth();
|
|
|
|
|
|
}
|
2025-12-05 11:29:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
},
|
2025-12-06 10:01:49 +08:00
|
|
|
|
mounted() {
|
|
|
|
|
|
this.calcContainerWidth();
|
|
|
|
|
|
window.addEventListener('resize', this.handleResize);
|
|
|
|
|
|
},
|
|
|
|
|
|
beforeUnmount() {
|
|
|
|
|
|
window.removeEventListener('resize', this.handleResize);
|
|
|
|
|
|
clearTimeout(this.resizeTimer);
|
|
|
|
|
|
},
|
2025-12-05 11:29:28 +08:00
|
|
|
|
methods: {
|
2025-12-06 10:01:49 +08:00
|
|
|
|
calcContainerWidth() {
|
|
|
|
|
|
if (this.$refs.scrollContainerRef) {
|
|
|
|
|
|
this.containerWidth = this.$refs.scrollContainerRef.clientWidth;
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
handleResize() {
|
|
|
|
|
|
clearTimeout(this.resizeTimer);
|
|
|
|
|
|
this.resizeTimer = setTimeout(() => {
|
|
|
|
|
|
this.calcContainerWidth();
|
|
|
|
|
|
}, 100);
|
|
|
|
|
|
},
|
2025-12-05 11:29:28 +08:00
|
|
|
|
toggleTranspose() {
|
|
|
|
|
|
this.isTransposed = !this.isTransposed;
|
|
|
|
|
|
this.dialogVisible = false;
|
|
|
|
|
|
this.currentWarehouse = null;
|
|
|
|
|
|
},
|
2025-12-06 10:01:49 +08:00
|
|
|
|
// 修复点击事件:增加日志便于调试,确保赋值正确
|
2025-12-05 11:29:28 +08:00
|
|
|
|
handleCellClick(warehouse) {
|
2025-12-06 10:01:49 +08:00
|
|
|
|
console.log('点击库位:', warehouse); // 调试用
|
2025-12-05 11:29:28 +08:00
|
|
|
|
this.currentWarehouse = warehouse;
|
|
|
|
|
|
this.dialogVisible = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
<style scoped lang="scss">
|
|
|
|
|
|
.grid-wrapper {
|
|
|
|
|
|
background: #fff;
|
|
|
|
|
|
border-radius: 8px;
|
|
|
|
|
|
overflow: hidden;
|
|
|
|
|
|
width: 100%;
|
2025-12-06 10:01:49 +08:00
|
|
|
|
position: relative;
|
|
|
|
|
|
min-height: 100px;
|
2025-12-05 11:29:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.grid-scroll-container {
|
|
|
|
|
|
width: 100%;
|
|
|
|
|
|
overflow-x: auto;
|
|
|
|
|
|
overflow-y: hidden;
|
|
|
|
|
|
position: relative;
|
2025-12-06 10:01:49 +08:00
|
|
|
|
padding-bottom: 8px;
|
2025-12-05 13:03:08 +08:00
|
|
|
|
|
2025-12-05 11:29:28 +08:00
|
|
|
|
&::-webkit-scrollbar {
|
|
|
|
|
|
height: 8px;
|
|
|
|
|
|
}
|
|
|
|
|
|
&::-webkit-scrollbar-track {
|
|
|
|
|
|
background: #f1f1f1;
|
|
|
|
|
|
border-radius: 4px;
|
|
|
|
|
|
}
|
|
|
|
|
|
&::-webkit-scrollbar-thumb {
|
|
|
|
|
|
background: #c1c1c1;
|
|
|
|
|
|
border-radius: 4px;
|
|
|
|
|
|
&:hover {
|
|
|
|
|
|
background: #a8a8a8;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
scrollbar-width: thin;
|
|
|
|
|
|
scrollbar-color: #c1c1c1 #f1f1f1;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.scroll-content {
|
|
|
|
|
|
display: inline-block;
|
|
|
|
|
|
background: #fff;
|
2025-12-06 10:01:49 +08:00
|
|
|
|
min-width: 100%;
|
2025-12-05 11:29:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.col-ruler {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
height: 30px;
|
|
|
|
|
|
line-height: 30px;
|
|
|
|
|
|
background: #eef2f7;
|
|
|
|
|
|
border-bottom: 1px solid #dcdfe6;
|
|
|
|
|
|
|
|
|
|
|
|
.ruler-empty {
|
|
|
|
|
|
width: 30px;
|
|
|
|
|
|
text-align: center;
|
|
|
|
|
|
font-weight: 600;
|
|
|
|
|
|
color: #606266;
|
|
|
|
|
|
border-right: 1px solid #dcdfe6;
|
|
|
|
|
|
flex-shrink: 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.ruler-item {
|
2025-12-06 10:01:49 +08:00
|
|
|
|
width: var(--cell-width);
|
|
|
|
|
|
min-width: 60px;
|
2025-12-05 11:29:28 +08:00
|
|
|
|
text-align: center;
|
|
|
|
|
|
font-weight: 600;
|
|
|
|
|
|
color: #606266;
|
|
|
|
|
|
border-right: 1px solid #dcdfe6;
|
|
|
|
|
|
box-sizing: border-box;
|
|
|
|
|
|
flex-shrink: 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.row-grid-wrapper {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
width: 100%;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.row-ruler {
|
|
|
|
|
|
width: 30px;
|
|
|
|
|
|
background: #eef2f7;
|
|
|
|
|
|
border-right: 1px solid #dcdfe6;
|
|
|
|
|
|
flex-shrink: 0;
|
|
|
|
|
|
|
|
|
|
|
|
.ruler-item {
|
2025-12-05 13:03:08 +08:00
|
|
|
|
height: 60px;
|
|
|
|
|
|
line-height: 60px;
|
2025-12-05 11:29:28 +08:00
|
|
|
|
text-align: center;
|
|
|
|
|
|
font-weight: 600;
|
|
|
|
|
|
color: #606266;
|
|
|
|
|
|
border-bottom: 1px solid #dcdfe6;
|
|
|
|
|
|
box-sizing: border-box;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.grid-container {
|
2025-12-06 10:01:49 +08:00
|
|
|
|
display: flex;
|
|
|
|
|
|
flex-wrap: wrap;
|
|
|
|
|
|
width: 100%;
|
2025-12-05 11:29:28 +08:00
|
|
|
|
box-sizing: border-box;
|
|
|
|
|
|
|
2025-12-06 10:01:49 +08:00
|
|
|
|
// 修复伪元素遮挡点击事件:添加 pointer-events: none
|
|
|
|
|
|
&::before {
|
|
|
|
|
|
content: '';
|
|
|
|
|
|
width: calc(var(--cell-width) * var(--column-count));
|
|
|
|
|
|
display: block;
|
|
|
|
|
|
height: 0;
|
|
|
|
|
|
visibility: hidden;
|
|
|
|
|
|
pointer-events: none; // 关键:让伪元素不拦截点击事件
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-12-05 11:29:28 +08:00
|
|
|
|
.warehouse-cell {
|
2025-12-06 10:01:49 +08:00
|
|
|
|
width: var(--cell-width);
|
|
|
|
|
|
min-width: 60px;
|
2025-12-05 13:03:08 +08:00
|
|
|
|
height: 60px;
|
2025-12-05 11:29:28 +08:00
|
|
|
|
border: 1px solid #e6e6e6;
|
|
|
|
|
|
border-radius: 0;
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
|
justify-content: center;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
|
transition: all 0.2s;
|
|
|
|
|
|
box-sizing: border-box;
|
|
|
|
|
|
margin: 0;
|
2025-12-06 10:01:49 +08:00
|
|
|
|
flex-shrink: 0;
|
|
|
|
|
|
position: relative; // 确保层级正常
|
|
|
|
|
|
z-index: 1; // 高于伪元素
|
2025-12-05 11:29:28 +08:00
|
|
|
|
|
|
|
|
|
|
&:hover {
|
|
|
|
|
|
border-color: #409eff;
|
|
|
|
|
|
background: #e8f4ff;
|
2025-12-06 10:01:49 +08:00
|
|
|
|
z-index: 2;
|
2025-12-05 11:29:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
&.disabled {
|
2025-12-06 10:24:07 +08:00
|
|
|
|
background: #eeff6f;
|
2025-12-05 11:29:28 +08:00
|
|
|
|
color: #909399;
|
|
|
|
|
|
cursor: not-allowed;
|
|
|
|
|
|
&:hover {
|
|
|
|
|
|
border-color: #e6e6e6;
|
2025-12-06 10:24:07 +08:00
|
|
|
|
background: #eeff6f;
|
2025-12-05 11:29:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.cell-name {
|
|
|
|
|
|
font-size: 12px;
|
|
|
|
|
|
color: #606266;
|
2025-12-06 10:01:49 +08:00
|
|
|
|
word-break: break-all;
|
|
|
|
|
|
text-align: center;
|
|
|
|
|
|
padding: 0 2px;
|
2025-12-05 11:29:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.empty-cell {
|
|
|
|
|
|
background: #fafafa;
|
|
|
|
|
|
border-style: solid;
|
|
|
|
|
|
border-color: #e6e6e6;
|
2025-12-06 10:01:49 +08:00
|
|
|
|
pointer-events: none; // 空格子不需要点击事件
|
2025-12-05 11:29:28 +08:00
|
|
|
|
|
|
|
|
|
|
.cell-code {
|
|
|
|
|
|
color: #c0c4cc;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
</style>
|