feat(wms/coil/label): 新增退火原料标签组件并调整标签逻辑
拆分退火原料库和脱脂原料库的标签逻辑,新增退火原料专用标签组件,调整仓库对应的标签类型映射规则
This commit is contained in:
312
klp-ui/src/views/wms/coil/panels/LabelRender/TuiHuoRawTag.vue
Normal file
312
klp-ui/src/views/wms/coil/panels/LabelRender/TuiHuoRawTag.vue
Normal file
@@ -0,0 +1,312 @@
|
||||
<template>
|
||||
<div class="label-container" :style="{ '--print-scale': printScale }">
|
||||
<div class="material-label-grid">
|
||||
<!-- 公司名称行 -->
|
||||
<div class="grid-cell company-cell">嘉祥科伦普重工有限公司</div>
|
||||
|
||||
<!-- 第一行:冷卷号、热卷号 -->
|
||||
<div class="grid-cell label-cell">冷卷号</div>
|
||||
<div class="grid-cell value-cell">
|
||||
<div class="nob current-coil-no">{{ content.currentCoilNo || '' }}</div>
|
||||
</div>
|
||||
<div class="grid-cell label-cell">热卷号</div>
|
||||
<div class="grid-cell value-cell">
|
||||
<div class="nob enter-coil-no" :style="enterCoilNoStyle">{{ content.enterCoilNo || '' }}</div>
|
||||
</div>
|
||||
|
||||
<!-- 第二行:规格、钢种 -->
|
||||
<div class="grid-cell label-cell">规格</div>
|
||||
<div class="grid-cell value-cell">
|
||||
<div class="nob">{{ content.specification || '' }}</div>
|
||||
</div>
|
||||
<div class="grid-cell label-cell">钢种</div>
|
||||
<div class="grid-cell value-cell">
|
||||
<div class="nob">{{ content.material || '' }}</div>
|
||||
</div>
|
||||
|
||||
<!-- 第三行:净重、下工序 -->
|
||||
<div class="grid-cell label-cell">净重</div>
|
||||
<div class="grid-cell value-cell">
|
||||
<div class="nob">{{ content.netWeight || '' }}</div>
|
||||
</div>
|
||||
<div class="grid-cell label-cell">下工序</div>
|
||||
<div class="grid-cell value-cell">
|
||||
<div class="nob">{{ content.nextProcess || '退火' }}</div>
|
||||
</div>
|
||||
|
||||
<!-- 第四行:包装要求、切边要求 -->
|
||||
<div class="grid-cell label-cell">包装要求</div>
|
||||
<div class="grid-cell value-cell">
|
||||
<div class="nob">{{ content.packagingRequirement || '' }}</div>
|
||||
</div>
|
||||
<div class="grid-cell label-cell">切边要求</div>
|
||||
<div class="grid-cell value-cell">
|
||||
<div class="nob">{{ content.trimmingRequirement || '' }}</div>
|
||||
</div>
|
||||
|
||||
<!-- 第五行:班组、代码(二维码) -->
|
||||
<div class="grid-cell label-cell">班组</div>
|
||||
<div class="grid-cell value-cell">
|
||||
<div class="nob">{{ content.team || '' }}</div>
|
||||
</div>
|
||||
<div class="grid-cell label-cell">代码</div>
|
||||
<div class="grid-cell qrcode-cell">
|
||||
<!-- 二维码容器 -->
|
||||
<QRCode :content="content.qrcodeRecordId" :size="80"/>
|
||||
</div>
|
||||
|
||||
<!-- 第六行:生产日期 -->
|
||||
<div class="grid-cell label-cell">生产日期</div>
|
||||
<div class="grid-cell value-cell date-cell">
|
||||
<div class="nob">{{ content.createTime || '' }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import QRCode from '@/components/QRCode/index.vue';
|
||||
|
||||
export default {
|
||||
name: 'ZincRawTag',
|
||||
components: {
|
||||
QRCode
|
||||
},
|
||||
props: {
|
||||
content: {
|
||||
type: Object,
|
||||
default: () => ({
|
||||
currentCoilNo: '',
|
||||
entryCoilNo: '',
|
||||
specification: '',
|
||||
material: '',
|
||||
netWeight: '',
|
||||
nextProcess: '',
|
||||
packagingRequirements: '',
|
||||
trimmingRequirements: '',
|
||||
team: '',
|
||||
createTime: '',
|
||||
qrcodeRecordId: '',
|
||||
})
|
||||
},
|
||||
paperWidthMm: {
|
||||
type: Number,
|
||||
default: 100
|
||||
},
|
||||
paperHeightMm: {
|
||||
type: Number,
|
||||
default: 80
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
printScale: 1,
|
||||
printMediaQuery: null
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
enterCoilNoStyle() {
|
||||
const len = (this.content.enterCoilNo || '').length;
|
||||
if (len > 25) return { fontSize: '0.55em' };
|
||||
if (len > 20) return { fontSize: '0.65em' };
|
||||
if (len > 15) return { fontSize: '0.75em' };
|
||||
if (len > 10) return { fontSize: '0.9em' };
|
||||
return {};
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.printMediaQuery = window.matchMedia('print');
|
||||
this.printMediaQuery.addListener(this.handlePrintMediaChange);
|
||||
window.addEventListener('beforeprint', this.handleBeforePrint);
|
||||
window.addEventListener('afterprint', this.handleAfterPrint);
|
||||
this.$nextTick(() => {
|
||||
this.calculatePrintScale();
|
||||
});
|
||||
},
|
||||
beforeDestroy() {
|
||||
if (this.printMediaQuery) {
|
||||
this.printMediaQuery.removeListener(this.handlePrintMediaChange);
|
||||
}
|
||||
window.removeEventListener('beforeprint', this.handleBeforePrint);
|
||||
window.removeEventListener('afterprint', this.handleAfterPrint);
|
||||
},
|
||||
methods: {
|
||||
handlePrintMediaChange(mq) {
|
||||
mq.matches ? this.calculatePrintScale() : this.resetPrintScale();
|
||||
},
|
||||
handleBeforePrint() {
|
||||
setTimeout(() => this.calculatePrintScale(), 100);
|
||||
},
|
||||
handleAfterPrint() {
|
||||
this.resetPrintScale();
|
||||
},
|
||||
calculatePrintScale() {
|
||||
this.$nextTick(() => {
|
||||
const container = this.$el;
|
||||
if (!container) return;
|
||||
|
||||
const dpi = 96;
|
||||
const mmToPx = dpi / 25.4;
|
||||
const paperWidthPx = this.paperWidthMm * mmToPx;
|
||||
const paperHeightPx = this.paperHeightMm * mmToPx;
|
||||
const marginPx = 2 * mmToPx;
|
||||
|
||||
const rect = container.getBoundingClientRect();
|
||||
const contentWidth = rect.width || container.scrollWidth;
|
||||
const contentHeight = rect.height || container.scrollHeight;
|
||||
|
||||
const availableWidth = paperWidthPx - marginPx * 2;
|
||||
const availableHeight = paperHeightPx - marginPx * 2;
|
||||
|
||||
const scaleX = contentWidth > 0 ? availableWidth / contentWidth : 1;
|
||||
const scaleY = contentHeight > 0 ? availableHeight / contentHeight : 1;
|
||||
|
||||
this.printScale = Math.min(scaleX, scaleY, 1);
|
||||
container.style.setProperty('--print-scale', this.printScale);
|
||||
container.style.setProperty('--paper-width', `${this.paperWidthMm}mm`);
|
||||
container.style.setProperty('--paper-height', `${this.paperHeightMm}mm`);
|
||||
});
|
||||
},
|
||||
resetPrintScale() {
|
||||
this.printScale = 1;
|
||||
if (this.$el) {
|
||||
this.$el.style.setProperty('--print-scale', 1);
|
||||
this.$el.style.removeProperty('--paper-width');
|
||||
this.$el.style.removeProperty('--paper-height');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
@import './label-common.css';
|
||||
.label-container {
|
||||
width: 45em;
|
||||
height: 25em;
|
||||
padding: 16px;
|
||||
font-family: var(--label-font);
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
/* 核心Grid布局 */
|
||||
.material-label-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(4, 1fr); /* 4列等宽 */
|
||||
grid-auto-rows: 1fr; /* 行高自适应 */
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
border: 1px solid #333;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.grid-cell {
|
||||
border: 1px solid #333;
|
||||
padding: 4px;
|
||||
font-size: 20px;
|
||||
box-sizing: border-box;
|
||||
text-align: center;
|
||||
word-break: break-all;
|
||||
overflow-wrap: break-word;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
/* 公司名称单元格 */
|
||||
.company-cell {
|
||||
grid-column: span 4; /* 跨4列 */
|
||||
font-size: 24px;
|
||||
font-weight: bold;
|
||||
/* background-color: #f5f5f5; */
|
||||
}
|
||||
|
||||
/* 标签单元格(左) */
|
||||
.label-cell {
|
||||
/* background-color: #f5f5f5; */
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
/* 值单元格 */
|
||||
.value-cell {
|
||||
text-align: center;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.date-cell {
|
||||
grid-column: span 2;
|
||||
}
|
||||
|
||||
/* 二维码单元格(跨2列+2行) */
|
||||
.qrcode-cell {
|
||||
grid-row: span 2; /* 跨2行 */
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.qrcode-container {
|
||||
width: 80%;
|
||||
height: 80%;
|
||||
border: 1px dashed #999; /* 占位虚线 */
|
||||
}
|
||||
|
||||
/* 内容可编辑区域 */
|
||||
.nob {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
border: none;
|
||||
outline: none;
|
||||
background: transparent;
|
||||
text-align: center;
|
||||
font-size: inherit;
|
||||
word-break: break-all;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-weight: 900;
|
||||
color: #000;
|
||||
|
||||
font-family: var(--label-font);
|
||||
font-size: 1.2em;
|
||||
}
|
||||
|
||||
.current-coil-no, .enter-coil-no {
|
||||
font-size: 1em;
|
||||
}
|
||||
|
||||
|
||||
/* 打印样式 */
|
||||
@media print {
|
||||
@page {
|
||||
size: 100mm 80mm;
|
||||
margin: 0 !important;
|
||||
}
|
||||
|
||||
* {
|
||||
-webkit-print-color-adjust: exact !important;
|
||||
print-color-adjust: exact !important;
|
||||
}
|
||||
|
||||
html,
|
||||
body {
|
||||
margin: 0 !important;
|
||||
padding: 0 !important;
|
||||
overflow: hidden !important;
|
||||
}
|
||||
|
||||
body>*:not(.label-container) {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
.label-container {
|
||||
page-break-inside: avoid !important;
|
||||
break-inside: avoid !important;
|
||||
transform: scale(var(--print-scale, 1)) !important;
|
||||
transform-origin: top left !important;
|
||||
max-width: var(--paper-width, 100mm) !important;
|
||||
max-height: var(--paper-height, 80mm) !important;
|
||||
overflow: hidden !important;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -50,6 +50,12 @@
|
||||
:paperWidthMm="100"
|
||||
:paperHeightMm="80"
|
||||
/>
|
||||
<TuiHuoRawTag
|
||||
v-if="tagType === 'tuihuo-raw'"
|
||||
:content="innerContent"
|
||||
:paperWidthMm="180"
|
||||
:paperHeightMm="100"
|
||||
/>
|
||||
</div>
|
||||
<div class="action-buttons" v-if="!hideActions">
|
||||
<el-button type="primary" @click="downloadLabelAsImage">下载标签图片</el-button>
|
||||
@@ -73,6 +79,7 @@ import ZincRawTag from './ZincRawTag.vue';
|
||||
import DuGeTag from './DuGeTag.vue';
|
||||
import TuoZhiTag from './TuoZhiTag.vue';
|
||||
import SplitTag from './SplitTag.vue';
|
||||
import TuiHuoRawTag from './TuiHuoRawTag.vue';
|
||||
|
||||
export default {
|
||||
name: 'LabelRender',
|
||||
@@ -85,6 +92,7 @@ export default {
|
||||
DuGeTag,
|
||||
TuoZhiTag,
|
||||
SplitTag,
|
||||
TuiHuoRawTag,
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
@@ -123,6 +131,10 @@ export default {
|
||||
width: 100,
|
||||
height: 80,
|
||||
},
|
||||
'tuihuo-raw': {
|
||||
width: 180,
|
||||
height: 100,
|
||||
}
|
||||
},
|
||||
loading: false,
|
||||
}
|
||||
@@ -173,10 +185,14 @@ export default {
|
||||
if (itemType == 'raw_material' && (warehouseId == '1988150263284953089' || warehouseId == '1988150487185289217')) {
|
||||
this.labelType = '5';
|
||||
}
|
||||
// 在脱脂原料库或者退火原料库或者罩式退火纵剪分条原料库的卷使用脱脂原料标签
|
||||
else if (itemType == 'raw_material' && (warehouseId == '1988150545175736322' || warehouseId == '1988150648993148929' || warehouseId == '1988150750390448129')) {
|
||||
// 在脱脂原料库使用脱脂原料标签
|
||||
else if (itemType == 'raw_material' && warehouseId == '1988150545175736322') {
|
||||
this.labelType = '6';
|
||||
}
|
||||
// 在退火原料库或者罩式退火纵剪分条原料库的卷使用退火原料标签
|
||||
else if (itemType == 'raw_material' && (warehouseId == '1988150648993148929' || warehouseId == '1988150750390448129')) {
|
||||
this.labelType = 'tuihuo-raw';
|
||||
}
|
||||
// 否则使用普通的原料标签
|
||||
else if (itemType == 'raw_material') {
|
||||
this.labelType = '2';
|
||||
|
||||
Reference in New Issue
Block a user