index.vue
9.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
<template>
<div>
<el-button type='primary' @click='printClick'>打印</el-button>
<!-- 打印 start -->
<div style="display: none;">
<el-button id="trueBtn" v-print="printObj" type="info" size="mini" icon="el-icon-printer">打印</el-button>
<!-- <div style="display: none"> -->
<div v-if="printFlag" id="printId" style="width: 100%;">
<!-- 打印 (打印元素有边距时,会打印出2张纸;使用svg或img)start-->
<div class="print-box" style='margin-bottom: 50px;'>
<div class="flex align-center border-bottom">
<div class="title">单证号</div>
<div class="flex-1 center">
<span>{{wmsInfo.waybill}}</span><span v-if="wmsInfo.billfhl">_{{wmsInfo.billfhl}}</span>
</div>
</div>
<div class="flex align-center border-bottom">
<div class="title">件数</div>
<div class="flex-1 center">{{wmsInfo.pcs}}</div>
</div>
<div class="flex align-center border-bottom">
<div class="title">重量</div>
<div class="flex-1 center">{{wmsInfo.billweight}}</div>
</div>
<div class="flex align-center border-bottom">
<div class="title">计费重量</div>
<div class="flex-1 center">{{wmsInfo.feeweight}}</div>
</div>
<div class="flex justify-center py-1">
<barcode
:value="wmsInfo.serialnumber"
:options="barcodeOptions1"
>
条形码生成失败
</barcode>
</div>
</div>
<!-- 打印单个 end -->
<!-- 打印多个,一张纸一个 start-->
<!-- <div class="print-box" style='margin-bottom: 50px;page-break-after: always' v-for="(item, index) in selection" :key="index">-->
<!-- <div class="flex align-center border-bottom">-->
<!-- <div class="title">模具编码</div>-->
<!-- <div class="flex-1 center">{{item.moldCode}}</div>-->
<!-- </div>-->
<!-- <div class="flex align-center border-bottom">-->
<!-- <div class="title">规格</div>-->
<!-- <div class="flex-1 center">{{item.moldSpec}}</div>-->
<!-- </div>-->
<!-- <div class="flex justify-center py-1">-->
<!-- <img :id="'barcodeId' + index" class="img-print"></img>-->
<!-- <VueBarcode-->
<!-- value="172-12345678"-->
<!-- :options="{ widht:100,height:50,background:'rgba(255,255,255,.0)'}"-->
<!-- >-->
<!-- 条形码显示失败时的内容-->
<!-- </VueBarcode>-->
<!-- </div>-->
<!-- </div>-->
<!-- 打印多个 end -->
</div>
<!-- </div> -->
</div>
<!-- 打印 end -->
</div>
</template>
<script>
import jsutil from "@/common/js/util";
export default {
components: {
},
props:['wmsInfo'],
data() {
return {
printFlag: false,
printObj: {
id: "printId",
popTitle: "打印条形码", //页眉,不传文字默认显示项目名
extraCss: "https://www.google.com,https://www.google.com",
extraHead: '<meta http-equiv="Content-Language"content="zh-cn"/>,<style>html{ margin:0},body:{margin:0} <style>',
},
barcodeOptions: {
format: "CODE39",
height: 60,
displayValue: true,
// text: barCode,
font: "fantasy",
textAlign: "center",
textPosition: "bottom",
textMargin: 10,
fontSize: 14,
// width:100,
// background: "#eee",
lineColor: "#333333",
margin: 20
},
barcodeOptions1:{
widht:100,
height:50,
background:'rgba(255,255,255,.0)',
margin: 20
},
wmsData:{},
// 条形码长度是6位数
selection:[
{
moldCode:'000001',
moldSpec:'56*22'
},
{
moldCode:'000002',
moldSpec:'26*20'
},
{
moldCode:'000003',
moldSpec:'56*22'
},
{
moldCode:'000004',
moldSpec:'26*20'
},
{
moldCode:'000005',
moldSpec:'56*22'
},
{
moldCode:'000006',
moldSpec:'26*20'
},
]
}
},
mounted() {
let itemAttr = "{\"材质\":\"3\",\"厚\":\"4\",\"宽\":\"56\",\"长\":\"1\"}";
let data = JSON.parse(itemAttr)
let list1 = Object.entries(data)
// console.log(2, list1)
let list = [];
for (let key in data) {
list.push({
name: key,
value: data[key]
})
}
// console.log(1, list)
},
methods: {
printClick() {
this.printFlag = true;
//多个
// this.$nextTick(() => {
// this.selection.forEach((v,index)=>{
// let options = {
// format: 'CODE39',
// height: 30,
// displayValue:true,
// text:v.moldCode,
// font:"fantasy",
// textAlign:"center",
// textPosition:"bottom",
// textMargin:2,
// fontSize:12,
// background:"#eee",
// lineColor:"#333333",
// // margin:20
// }
// // JsBarcode('#barcodeId' + index, v.moldCode,options)
// })
// })
// 单个
let barCode = this.selection[0].moldCode;
let options = {
format: "CODE39",
height: 60,
displayValue: true,
text: barCode,
font: "fantasy",
textAlign: "center",
textPosition: "bottom",
textMargin: 10,
fontSize: 14,
background: "#eee",
lineColor: "#333333",
margin: 20
}
this.$nextTick(() => {
// JsBarcode("#barcodeId", barCode, options);
});
setTimeout(() => {
document.getElementById("trueBtn").click();
this.printFlag = false;
}, 1000);
},
},
watch: {
wmsInfo(value) {
if (jsutil.checkNull(value)){
this.wmsData = value;
}
console.log("仓库数据已传递:"+value)
}
}
}
</script>
<style media="print">
@page {
size: auto;
margin: 0;
padding: 0;
}
html {
/* margin: 0; */
}
#printId {
margin: 0;
padding: 0;
height: 98%;
}
body {
/* margin: 0; */
}
</style>
<style scoped>
/* 大小可根据打印纸调整 */
.flex{
display: flex;
}
.align-center{
align-items: center;
}
.justify-center{
justify-content: center;
}
.center{
text-align: center;
}
.flex-1{
flex: 1;
}
.py-1{
/* padding: 4px 0; */
}
.print-box {
margin: 0 !important;
padding: 0 !important;
width: 330px;
border: 1px solid black;
font-size: 12px;
transform: scale(0.7);
}
.img-print{
transform: scale(0.8);
}
.title {
width: 90px;
height: 20px;
font-size: 12px;
line-height: 20px;
text-align: center;
border-right: 1px solid black;
}
.border-bottom {
border-bottom: 1px solid black;
}
</style>