feat(标签打印): 添加镀锌原料标签组件及显示逻辑
新增 ZincRawTag 组件用于显示镀锌原料标签,并在特定仓库条件下自动选择该标签类型。标签包含冷卷号、热卷号、规格等字段,并支持二维码显示和打印适配。
This commit is contained in:
290
klp-ui/src/views/wms/coil/panels/LabelRender/ZincRawTag.vue
Normal file
290
klp-ui/src/views/wms/coil/panels/LabelRender/ZincRawTag.vue
Normal file
@@ -0,0 +1,290 @@
|
|||||||
|
<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" contenteditable>{{ content.currentCoilNo || '' }}</div>
|
||||||
|
</div>
|
||||||
|
<div class="grid-cell label-cell">热卷号</div>
|
||||||
|
<div class="grid-cell value-cell">
|
||||||
|
<div class="nob" contenteditable>{{ content.enterCoilNo || '' }}</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- 第二行:规格、钢种 -->
|
||||||
|
<div class="grid-cell label-cell">规格</div>
|
||||||
|
<div class="grid-cell value-cell">
|
||||||
|
<div class="nob" contenteditable>{{ content.specification || '' }}</div>
|
||||||
|
</div>
|
||||||
|
<div class="grid-cell label-cell">钢种</div>
|
||||||
|
<div class="grid-cell value-cell">
|
||||||
|
<div class="nob" contenteditable>{{ content.material || '' }}</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- 第三行:净重、下工序 -->
|
||||||
|
<div class="grid-cell label-cell">净重</div>
|
||||||
|
<div class="grid-cell value-cell">
|
||||||
|
<div class="nob" contenteditable>{{ content.netWeight || '' }}</div>
|
||||||
|
</div>
|
||||||
|
<div class="grid-cell label-cell">下工序</div>
|
||||||
|
<div class="grid-cell value-cell">
|
||||||
|
<div class="nob" contenteditable>{{ content.nextProcess || '冷硬卷' }}</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- 第四行:包装要求、切边要求 -->
|
||||||
|
<div class="grid-cell label-cell">包装要求</div>
|
||||||
|
<div class="grid-cell value-cell">
|
||||||
|
<div class="nob" contenteditable>{{ content.packagingRequirements || '' }}</div>
|
||||||
|
</div>
|
||||||
|
<div class="grid-cell label-cell">切边要求</div>
|
||||||
|
<div class="grid-cell value-cell">
|
||||||
|
<div class="nob" contenteditable>{{ content.trimmingRequirements || '' }}</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- 第五行:班组、代码(二维码) -->
|
||||||
|
<div class="grid-cell label-cell">班组</div>
|
||||||
|
<div class="grid-cell value-cell">
|
||||||
|
<div class="nob" contenteditable>{{ content.team || '' }}</div>
|
||||||
|
</div>
|
||||||
|
<div class="grid-cell label-cell">代码</div>
|
||||||
|
<div class="grid-cell qrcode-cell">
|
||||||
|
<!-- 二维码容器 -->
|
||||||
|
<QRCode :content="content.qrcodeRecordId" />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- 第六行:生产日期 -->
|
||||||
|
<div class="grid-cell label-cell">生产日期</div>
|
||||||
|
<div class="grid-cell value-cell date-cell">
|
||||||
|
<div class="nob" contenteditable>{{ 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
|
||||||
|
}
|
||||||
|
},
|
||||||
|
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>
|
||||||
|
.label-container {
|
||||||
|
width: 45em;
|
||||||
|
height: 25em;
|
||||||
|
padding: 0;
|
||||||
|
font-family: "SimSun", serif;
|
||||||
|
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: 14px;
|
||||||
|
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: 18px;
|
||||||
|
font-weight: bold;
|
||||||
|
background-color: #f5f5f5;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 标签单元格(左) */
|
||||||
|
.label-cell {
|
||||||
|
background-color: #f5f5f5;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 值单元格 */
|
||||||
|
.value-cell {
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.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;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 打印样式 */
|
||||||
|
@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>
|
||||||
@@ -26,6 +26,12 @@
|
|||||||
:paperWidthMm="100"
|
:paperWidthMm="100"
|
||||||
:paperHeightMm="80"
|
:paperHeightMm="80"
|
||||||
/>
|
/>
|
||||||
|
<ZincRawTag
|
||||||
|
v-if="tagType === '5'"
|
||||||
|
:content="content"
|
||||||
|
:paperWidthMm="180"
|
||||||
|
:paperHeightMm="100"
|
||||||
|
/>
|
||||||
<!-- <SampleTagPreview v-if="labelType === '4'" :content="content" />
|
<!-- <SampleTagPreview v-if="labelType === '4'" :content="content" />
|
||||||
<ForgeTagPreview v-if="labelType === '5'" :content="content" />
|
<ForgeTagPreview v-if="labelType === '5'" :content="content" />
|
||||||
<SaltSprayTagPreview v-if="labelType === '6'" :content="content" /> -->
|
<SaltSprayTagPreview v-if="labelType === '6'" :content="content" /> -->
|
||||||
@@ -47,6 +53,8 @@ import MaterialTag from './MaterialTag.vue';
|
|||||||
import OuterTagPreview from './OuterTagPreview.vue';
|
import OuterTagPreview from './OuterTagPreview.vue';
|
||||||
import GalvanizedTag from './GalvanizedTag.vue';
|
import GalvanizedTag from './GalvanizedTag.vue';
|
||||||
import WhereTag from './WhereTag.vue';
|
import WhereTag from './WhereTag.vue';
|
||||||
|
import ZincRawTag from './ZincRawTag.vue';
|
||||||
|
|
||||||
// import SampleTagPreview from './SampleTagPreview.vue';
|
// import SampleTagPreview from './SampleTagPreview.vue';
|
||||||
// import ForgeTagPreview from './ForgeTagPreview.vue';
|
// import ForgeTagPreview from './ForgeTagPreview.vue';
|
||||||
// import SaltSprayTagPreview from './SaltSprayTagPreview.vue';
|
// import SaltSprayTagPreview from './SaltSprayTagPreview.vue';
|
||||||
@@ -58,6 +66,7 @@ export default {
|
|||||||
OuterTagPreview,
|
OuterTagPreview,
|
||||||
GalvanizedTag,
|
GalvanizedTag,
|
||||||
WhereTag,
|
WhereTag,
|
||||||
|
ZincRawTag,
|
||||||
// SampleTagPreview,
|
// SampleTagPreview,
|
||||||
// ForgeTagPreview,
|
// ForgeTagPreview,
|
||||||
// SaltSprayTagPreview,
|
// SaltSprayTagPreview,
|
||||||
@@ -114,8 +123,11 @@ export default {
|
|||||||
watch: {
|
watch: {
|
||||||
content: {
|
content: {
|
||||||
handler(newVal) {
|
handler(newVal) {
|
||||||
const { itemName, itemType } = newVal;
|
const { itemName, itemType, warehouseId } = newVal;
|
||||||
if (itemType == 'raw_material') {
|
// 在镀锌颜料库的卷使用镀锌原料标签
|
||||||
|
if (itemType == 'raw_material' && warehouseId == '1988150263284953089') {
|
||||||
|
this.labelType = '5';
|
||||||
|
} else if (itemType == 'raw_material') {
|
||||||
this.labelType = '2';
|
this.labelType = '2';
|
||||||
} else if (itemType == 'product' && itemName == '冷硬卷') {
|
} else if (itemType == 'product' && itemName == '冷硬卷') {
|
||||||
this.labelType = '3';
|
this.labelType = '3';
|
||||||
|
|||||||
Reference in New Issue
Block a user