llj
2026-02-06 070bc45c1cfbbcca54cfa0579ba4310f404b07f1
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
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
<template>
    <view class="content">
        <view class="form">
            <view class="form-item">
                <view class="title">物料编码:</view>
                <view class="righton">
                    <input v-model="baseInfo.HMaterNumber" disabled />
                </view>
            </view>
            <view class="form-item">
                <view class="title">物料名称:</view>
                <view class="righton">
                    <input v-model="baseInfo.HMaterName" disabled />
                </view>
            </view>
            <view class="form-item">
                <view class="title">规格型号:</view>
                <view class="righton">
                    <input v-model="baseInfo.HMaterModel" disabled />
                </view>
            </view>
            <view class="form-item">
                <view class="title">批次:</view>
                <view class="righton">
                    <input v-model="baseInfo.HBatchNo" disabled />
                </view>
            </view>
            <view class="form-item">
                <view class="title">收料数量:</view>
                <view class="righton">
                    <input v-model="baseInfo.HQty" disabled />
                </view>
            </view>
            <view class="form-item">
                <view class="title">MTO号:</view>
                <view class="righton">
                    <input v-model="baseInfo.HMTONo" disabled />
                </view>
            </view>
            <view class="form-item">
                <view class="title">每箱数量:</view>
                <view class="righton">
                    <input disabled v-model="baseInfo.HMinQty" type="number" placeholder="请输入数量" @confirm="getNum()"
                        @blur="getNum()" />
                </view>
            </view>
            <view class="buttons">
                <button class="btn-b" size="mini" type="default" @tap="getList()">条码生成</button>
                <button class="btn-c" :disabled="codeGenComplete == false" size="mini" type="default"
                    @tap="search">打印</button>
                <!-- <button class="btn-c" size="mini" type="default"
                        @tap="exit">退出</button> -->
            </view>
        </view>
 
        <view style="width: 100%;height: 16rpx;background-color: #e5e5e5;"></view>
 
        <view class="list" v-for="(item,index) in listData" :key="item['行号']">
            <uni-card :title="item.物料代码" :extra="'行号. ' + item['行号']" style="margin: 10px;">
                <view class="card-detail">
                    <view class="detail">
                        <text>物料名称:</text>{{item.物料名称}}
                    </view>
                    <view class="detail">
                        <text>规格型号:</text>{{item.规格型号}}
                    </view>
                    <view class="detail">
                        <text>数量:</text>{{item.数量}}
                    </view>
                    <view class="detail" style="width: 100%;">
                        <text>条码编号:</text>{{item.条码编号}}
                    </view>
                </view>
 
            </uni-card>
 
        </view>
        <view class="over" v-if="listData.length == 0">暂无数据</view>
        <view class="over" v-if="listData.length != 0">已到底</view>
        <view>
            <labelPrinterComponentVue ref="labelPrinter" :printInfo="printInfo" :printMode="'cpcl'">
            </labelPrinterComponentVue>
        </view>
    </view>
</template>
 
<script>
    import {
        getUserInfo
    } from "@/utils/auth.js";
    import {
        CommonUtils
    } from "../../utils/common";
    import {
        nextTick
    } from "vue";
    import labelPrinterComponentVue from "@/components/labelPrinterComponent/labelPrinterComponent.vue"
    export default {
        data() {
            return {
                billNo: '',
                lineNo: 0,
                printInfo: "",
                userInfo: getUserInfo(),
                serverUrl: uni.getStorageSync('serverUrl') || 'http://47.96.97.237/API',
                OperationType: 1, //数据类型  1添加 保存  2复制  3 编辑
                linterid: '',
                HEntryID: '',
                hmaterid: '',
                codeGenComplete: false,
                baseInfo: {
                    HMainID: '',
                    HSubID: '',
                    HInnerBillNo: '',
                    HMaterID: '',
                    // barCodeNo: '',
                    HBillNo: '',
                    HBillLineNo: '',
                    HMaterNumber: '',
                    HMaterName: '',
                    HMaterModel: '',
                    HPcsName: '',
                    HBatchNo: '',
                    HQty: 0,
                    HMTONo: '',
                    HSupName: '',
                    HSupNameShort: '',
                    HMinQty: 0,
                    HBQty: 0,
                    HSupID: '',
                    HUnitID: '',
                    HDate: '',
                    HSourceBillNo: '',
                    HMaker: getUserInfo()["Czymc"],
                    HSupNumber: '',
                    HCoilNO: '',
                    HFurnaceNO: '',
                    HFactory: '',
                },
                sWhere: '',
                listData: [],
 
            }
        },
        components: {
            labelPrinterComponentVue
        },
        onLoad(e) {
            console.log("页面传递参数: ", e)
            this.OperationType = e.OperationType
            this.billNo = e.billNo
            this.baseInfo.HBillNo = e.billNo
            this.baseInfo.HBillLineNo = e.lineNo
            this.lineNo = e.lineNo
            this.baseInfo.HSourceBillNo = e.billNo
            this.baseInfo.HInnerBillNo = e.billNo
            this.getData()
        },
        methods: {
            getData() {
                CommonUtils.doRequest(
                    "/Cg_POOrderBill/list", {
                        sWhere: ` and 单据号 = '${this.billNo}' and 行号 = ${this.lineNo}`,
                        user: this.userInfo.Czymc,
                    },
                    (res) => {
                        console.log('采购订单: ', res)
                        let {
                            data,
                            count
                        } = res.data
                        if (count > 0) {
                            let d = data[0]
                            this.baseInfo = Object.assign(this.baseInfo, {
                                HMaterNumber: d['物料编码'],
                                HMaterName: d['物料名称'],
                                HMaterModel: d['规格型号'],
                                HBatchNo: d['批号'],
                                HQty: d['数量'],
                                HMinQty: d['数量'],
                                HBQty: d['数量'],
                                HSupID: d['HSupID'],
                                HSupNumber: d['供应商代码'],
                                HSupName: d['供应商'],
                                HUnitID: d['HUnitID'],
                                HPcsName: d['计量单位'],
                                HSupNameShort: d['供应商'],
                                HMTONo: d['计划跟踪号'].trim(),
                                HMainID: d['hmainid'],
                                HSubID: d['HEntryID'],
                                HMaterID: d['HMaterID'],
                                HDate: d['日期'],
                                HCoilNO: d['款号'],
                                HFurnaceNO: d['分组'],
                                HFactory: d['客户编号']
                            })
                            console.log(this.baseInfo)
                            // CommonUtils.playSound(1)
                            this.listData = data
                        } else {
                            uni.showToast({
                                title: res.data.Message,
                                icon: 'none'
                            })
                        }
                    }
                )
            },
            getNum(e) {
                if (this.baseInfo.HMinQty && this.baseInfo.HMinQty > 0) {
                    var a = Number(this.baseInfo.HQty) / Number(this.baseInfo.HMinQty)
                    this.baseInfo.HBQty = Math.ceil(Number(this.baseInfo.HQty) / Number(this.baseInfo.HMinQty))
                    this.$forceUpdate()
                } else {
                    uni.showToast({
                        title: '请输入大于0的合理数量',
                        icon: "none"
                    })
                }
            },
            async search() {
                // #ifndef APP-PLUS
                uni.showModal({
                    content: "不支持蓝牙打印功能,请切换手机...",
                })
                return
                // #endif
                if (this.$printer.isConnected() === false) {
                    this.$refs.labelPrinter.openPopup()
                } else {
                    let printContent = []
                    let printInfoBuffer = []
                    let count = 0
                    for (let listOne of this.listData) {
                        let HBarCodeNoStr =
                            `${this.baseInfo.HBillNo}@${this.baseInfo.HBillLineNo}@${this.baseInfo.HMaterNumber || ''}@${this.baseInfo.HMTONo || ''}@${this.baseInfo.HQty || 0}@${this.baseInfo.HSupNumber  || ''}`
                        let pcsInfo = this.baseInfo.HPcsName ? '(' + this.baseInfo.HPcsName + ')' : ''
 
                        printContent.push(`! 0 200 200 400 1
PAGE-WIDTH 608
SETQRVER 3
B QR 475 15 Q 0 U 3
LA,${HBarCodeNoStr}
ENDQR
T 24 0 0 30 供应商: ${this.baseInfo.HSupName}
T 55 0 0 55 (Supplier)
T 24 0 0 75 供应商料号:  ${this.baseInfo.HMaterNumber}
T 55 0 0 100 (Supplier Sku No.)
T 24 0 0 120 物料名称: ${this.baseInfo.HMaterName}
T 55 0 0 145 (Material Code)
T 24 0 0 165 款号: ${this.baseInfo.HCoilNO}
T 55 0 0 190 (Style No.)
T 24 0 300 165 客户编号: ${this.baseInfo.HFactory}
T 55 0 300 190 (Consumer No.)
T 24 0 0 210 分组: ${this.baseInfo.HFurnaceNO || ''}
T 55 0 0 235 (Group) 
T 24 0 300 210 规格: ${this.baseInfo.HMaterModel}
T 55 0 300 235 (SKU NO.) 
T 24 0 0 255 数量:  ${ parseFloat(this.baseInfo.HQty || 0).toFixed(0) } ${pcsInfo}
T 55 0 0 280 (Quantity) 
T 24 0 300 255 日期: ${this.baseInfo.HDate || ''}
T 55 0 300 280 (Date) 
T 24 0 0 300 检验员: 
T 55 0 0 325 (QC)  
T 24 0 300 300 采购单号: ${this.baseInfo.HBillNo || ''}
T 55 0 300 325 (Purchase Order No.)  
T 24 0 0 345 检验结果: 
T 55 0 0 370 (Inspection status) 
BOX 240 345 260 365 4
T 24 0 270 345 合格
T 55 0 250 370 (Pass) 
BOX 340 345 360 365 4
T 24 0 370 345 不合格
T 55 0 370 370 (Fail) 
BOX 460 345 480 365 4
T 24 0 490 345 特采
T 55 0 440 370 (Spec. accepted) 
FORM
PRINT`)
                        count++;
                        if (count == 10) {
                            printInfoBuffer.push(printContent.join("\r\n"))
                            count = 0
                            printContent = []
                        }
                    }
                    printInfoBuffer.push(printContent.join("\r\n"))
                    this.printInfo = JSON.stringify(printInfoBuffer)
 
                    printInfoBuffer = []
 
                    await this.$nextTick(() => {
                        this.$refs.labelPrinter.execPrint()
                    })
                }
            },
            getList() {
                let HBarCodeNoStr =
                    `${this.baseInfo.HBillNo}@${this.baseInfo.HBillLineNo}@${this.baseInfo.HMaterNumber || ''}@${this.baseInfo.HMTONo || ''}@${this.baseInfo.HQty || 0}@${this.baseInfo.HSupNumber  || ''}`
                var sMain = []
                sMain[0] = this.baseInfo
                var sMainStr = JSON.stringify(sMain);
                //获取选择的组织
                var HOrgType = uni.getStorageSync('Organization');
                //获取选择的工厂代码
                var CampanyName = "xxx";
                //获取选择的源单类型
                var HSourceBillType = "采购订单";
                //获取选择的条码类型
                var HSelectBarCodeType = "品种条码";
                //获取当前登录人员
                var UserName = uni.getStorageSync('HUserName');
                let sMainSub = sMainStr + ';' + HOrgType + ';' + HSourceBillType + ';' + HSelectBarCodeType + ';' +
                    CampanyName + ';' + UserName + ';' + HBarCodeNoStr +
                    ';' + this.baseInfo.HFactory + ';' + this.baseInfo.HCoilNO +
                    ';' + this.baseInfo.HFurnaceNO  + '';
                    
                CommonUtils.doRequest(
                    "/Sc_BarCode/SaveBarCode_NoGenerate", {
                        msg: sMainSub,
                        CampanyName: CampanyName
                    },
                    (res) => {
                        console.log(res)
                        let {
                            data,
                            count,
                            Message
                        } = res.data
                        if (count > 0) {
                            // this.generatedBarCode = data[0]['条码编号']/
                            // console.log(this.generatedBarCode)
                            uni.showToast({
                                icon: 'none',
                                title: Message
                            })
                            this.codeGenComplete = true
                            this.buttonStatus = {
                                btn1: true,
                                btn2: false
                            }
                            for (let listOne of this.listData) {
                                listOne['条码编号'] = HBarCodeNoStr
                            }
                        } else {
                            this.buttonStatus = {
                                btn1: false,
                                btn2: false
                            }
                            uni.showToast({
                                icon: 'none',
                                title: Message
                            })
                        }
                    },
                    (err) => {
                        this.buttonStatus = {
                            btn1: false,
                            btn2: false
                        }
                        uni.showToast({
                            icon: 'none',
                            title: err
                        })
                    },
                    "POST"
                )
            }
        }
    }
</script>
 
<style lang="scss" scoped>
    .form {
        width: 640rpx;
        margin: 20rpx auto;
    }
 
    .form-item {
        display: flex;
        align-items: center;
        font-size: 28rpx;
        padding: 6rpx 0;
 
        .title {
            width: 180rpx;
 
            text {
                color: red;
                font-weight: bold;
            }
        }
 
        .right {
            flex: 1;
            border-radius: 22rpx;
            border: 1px solid #acacac;
        }
 
        .righton {
            flex: 1;
            border-radius: 22rpx;
            border: 1px solid #e4e4e4;
            background-color: #e4e4e4;
        }
 
        input {
            width: inherit;
            padding: 8rpx 20rpx;
            font-size: 30rpx;
        }
    }
 
    .buttons {
        width: 100%;
        display: flex;
        justify-content: center;
        margin-top: 20rpx;
 
        button {
            border-radius: 50rpx;
            width: 220rpx;
            height: 66rpx;
            line-height: 66rpx;
            font-size: 28rpx;
        }
 
        button[disabled] {
            background-color: #acacac;
            color: #fff;
        }
 
        .btn-a {
            background-color: #acacac;
            color: #fff;
        }
 
        .btn-b {
            background-color: #41a863;
            color: #fff;
        }
 
        .btn-c {
            background-color: #3a78ff;
            color: #fff;
        }
    }
 
    .list {
        width: 100%;
        word-break: break-all;
 
        .card-detail {
            width: 100%;
            display: flex;
            flex-wrap: wrap;
            justify-content: space-between;
            line-height: 120%;
 
            .detail {
                // width: 50%;
                font-size: 26rpx;
                margin-bottom: 12rpx;
                color: #555;
                margin-right: 20rpx;
 
                text {
                    color: #999;
                    font-size: 26rpx;
                }
            }
        }
 
        .more {
            color: #888;
            font-size: 24rpx;
            display: flex;
            border-top: 1px solid #eee;
            padding-top: 20rpx;
 
            .part {
                width: 50%;
                text-align: center;
            }
        }
    }
</style>