chenhaozhe
2025-07-14 c0b7297222bc3590041c579a51cc3ee3098a408c
完善 来料条码打印 UI页面
3个文件已修改
1个文件已添加
292 ■■■■ 已修改文件
components/labelPrinterComponent/labelPrinterComponent.vue 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages.json 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/tiaomadaying/tiaomadaying.vue 283 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
static/logo_icon.png 补丁 | 查看 | 原始文档 | blame | 历史
components/labelPrinterComponent/labelPrinterComponent.vue
@@ -80,9 +80,8 @@
                        // 传入的printInfo是函数,直接执行
                        let msg = await this.printInfo()
                        msg = this.uint8ArrayToSignedArray(msg)
                        console.log(msg)
                        this.sendMessage(msg)
                        this.blueToothConnector.sendMessage(msg)
                    } else if (typeof this.printInfo === 'string') {
                        // 传入的参数是字符串,则根据打印模式调用不同的打印API
                        // 这里的字符串需要对应打印模式
@@ -137,7 +136,7 @@
    }
</script>
<style lang="scss">
<style lang="scss" scoped>
    * {
        box-sizing: border-box;
    }
pages.json
@@ -392,7 +392,7 @@
        {
            "path": "pages/tiaomadaying/tiaomadaying",
            "style": {
                "navigationBarTitleText": "条码打印"
                "navigationBarTitleText": "来料条码打印"
            }
        }
    ],
pages/tiaomadaying/tiaomadaying.vue
@@ -1,8 +1,86 @@
<template>
    <view>
        <button @click="print">打印</button>
        <labelPrinterComponentVue ref="labelPrinter" :printInfo="printInfo" :printMode="'cpcl'">
        </labelPrinterComponentVue>
    <view class="container">
        <view class="content">
            <view class="header"></view>
            <view class="items">
                <view class="item">
                    <view class="left">条码编号:</view>
                    <view class="right">
                        <input name="HBarCode" disabled v-model="lailiaoInfo.barCodeNo" placeholder="请扫描来料条码" />
                    </view>
                    <view>
                        <uni-icons type="scan"
                            style="background-color: #3A78FF;padding: 6rpx;color: #fff;border-radius: 100%;font-weight: 500;"
                            size="20" @click="toScanCode"></uni-icons>
                    </view>
                </view>
                <view class="item">
                    <view class="left">源单号:</view>
                    <view class="right">
                        <input name="HSourceBillNo" v-model="lailiaoInfo.HSourceBillNo" />
                    </view>
                </view>
                <view class="item">
                    <view class="left">源单行号:</view>
                    <view class="right">
                        <input name="HSourceBillLineNo" v-model="lailiaoInfo.HSourceBillLineNo" />
                    </view>
                </view>
                <view class="item">
                    <view class="left">物料编码:</view>
                    <view class="right">
                        <input name="HMaterNo" v-model="lailiaoInfo.HMaterNo" />
                    </view>
                </view>
                <view class="item">
                    <view class="left">物料名称:</view>
                    <view class="right">
                        <input name="HMaterName" v-model="lailiaoInfo.HMaterName" />
                    </view>
                </view>
                <view class="item">
                    <view class="left">规格型号:</view>
                    <view class="right">
                        <input name="HMaterType" v-model="lailiaoInfo.HMaterType" />
                    </view>
                </view>
                <view class="item">
                    <view class="left">批次:</view>
                    <view class="right">
                        <input name="HBatchNo" v-model="lailiaoInfo.HBatchNo" />
                    </view>
                </view>
                <view class="item">
                    <view class="left">数量:</view>
                    <view class="right">
                        <input name="HQty" v-model="lailiaoInfo.HQty" />
                    </view>
                </view>
                <view class="item">
                    <view class="left">MTO号:</view>
                    <view class="right">
                        <input name="HMTONo" v-model="lailiaoInfo.HMTONo" />
                    </view>
                </view>
                <view class="item">
                    <view class="left">供应商:</view>
                    <view class="right">
                        <input name="HSupName" v-model="lailiaoInfo.HSupName" />
                    </view>
                </view>
                <view class="item">
                    <view class="left">供应商简称:</view>
                    <view class="right">
                        <input name="HSupNameShort" v-model="lailiaoInfo.HSupNameShort" />
                    </view>
                </view>
            </view>
        </view>
        <view class="operation-zone">
            <button @click="print">打印</button>
            <labelPrinterComponentVue ref="labelPrinter" :printInfo="printInfo" :printMode="'cpcl'">
            </labelPrinterComponentVue>
        </view>
    </view>
</template>
@@ -29,10 +107,30 @@
        CStatus,
        CPCL,
    } from "@psdk/cpcl";
    import {
        CommonUtils
    } from '../../utils/common';
    import {
        getUserInfo
    } from "@/utils/auth.js";
    export default {
        data() {
            return {
                printInfo: ""
                printInfo: "",
                userInfo: getUserInfo(),
                lailiaoInfo: {
                    barCodeNo: '',
                    HSourceBillNo: '',
                    HSourceBillLineNo: '',
                    HMaterNo: '',
                    HMaterName: '',
                    HMaterType: '',
                    HBatchNo: '',
                    HQty: '',
                    HMTONo: '',
                    HSupName: '',
                    HSupNameShort: ''
                }
            };
        },
        components: {
@@ -47,12 +145,12 @@
                    //     let cpcl = await this.$printer.cpcl().clear()
                    //         .page(new CPage({
                    //             width: 608,
                    //             height: 1040
                    //             height: 400
                    //         }))
                    //         .qrcode(new CQRCode({
                    //             x: 54,
                    //             y: 480,
                    //             width: 10,
                    //             x: 500,
                    //             y: 30,
                    //             width: 3,
                    //             content: "PDDZDA00017106",
                    //             codeRotation: CCodeRotation.ROTATION_0,
                    //             level: CCorrectLevel.L
@@ -118,11 +216,11 @@
                    //             font: CFont.TSS24
                    //         }))
                    //         .box(new CBox({
                    //             topLeftX: 280,
                    //             topLeftX: 260,
                    //             topLeftY: 320,
                    //             bottomRightX: 350,
                    //             bottomRightY: 390,
                    //             lineWidth: 2,
                    //             bottomRightX: 280,
                    //             bottomRightY: 340,
                    //             lineWidth: 4,
                    //         }))
                    //         .text(new CText({
                    //             x: 290,
@@ -131,28 +229,28 @@
                    //             font: CFont.TSS24
                    //         }))
                    //         .box(new CBox({
                    //             topLeftX: 380,
                    //             topLeftX: 360,
                    //             topLeftY: 320,
                    //             bottomRightX: 450,
                    //             bottomRightY: 390,
                    //             lineWidth: 2,
                    //             bottomRightX: 380,
                    //             bottomRightY: 340,
                    //             lineWidth: 4,
                    //         }))
                    //         .text(new CText({
                    //             x: 390,
                    //             y: 330,
                    //             y: 320,
                    //             content: "不合格",
                    //             font: CFont.TSS24
                    //         }))
                    //         .box(new CBox({
                    //             topLeftX: 480,
                    //             topLeftY: 320,
                    //             bottomRightX: 550,
                    //             bottomRightY: 390,
                    //             lineWidth: 2,
                    //             bottomRightX: 500,
                    //             bottomRightY: 340,
                    //             lineWidth: 4,
                    //         }))
                    //         .text(new CText({
                    //             x: 490,
                    //             y: 330,
                    //             x: 510,
                    //             y: 320,
                    //             content: "特采",
                    //             font: CFont.TSS24
                    //         }))
@@ -164,11 +262,11 @@
                    // await this.$nextTick(() => {
                    //     this.$refs.labelPrinter.execPrint()
                    // })
                    this.printInfo = `! 0 200 200 600 1
                    this.printInfo = `! 0 200 200 400 1
PAGE-WIDTH 608
SETQRVER 3
B QR 54 480 M 2 U 10
B QR 500 30 M 2 U 3
LA,PDDZDA00017106
ENDQR
T 24 0 30 30 供应商: 
@@ -181,26 +279,147 @@
T 24 0 30 280 检验员: 
T 24 0 300 280 计划跟踪号: 
T 24 0 30 330 检验结果: 
BOX 280 320 350 390 2
BOX 260 320 280 340 4
T 24 0 290 320 合格
BOX 380 320 450 390 2
T 24 0 390 330 不合格
BOX 480 320 550 390 2
T 24 0 490 330 特采
BOX 360 320 380 340 4
T 24 0 390 320 不合格
BOX 480 320 500 340 4W
T 24 0 510 320 特采
FORM
PRINT`
                    await this.$nextTick(() => {
                        this.$refs.labelPrinter.execPrint()
                    })
                }
            },
            setLailiaoInfo(data, row) {
                if(row > data.length) {
                    return uni.showToast({
                        icon: 'none',
                        title: '查询的单据号不存在...'
                    })
                }
                let d = data[row - 1]
                this.lailiaoInfo = Object.assign(this.lailiaoInfo, {
                    HMaterNo: d['物料编码'],
                    HMaterName: d['物料名称'],
                    HMaterType: d['规格型号'],
                    HBatchNo: d['批号'],
                    HQty: d['数量'],
                    HSupName: d['供应商'],
                    HSupNameShort: d['供应商']
                })
            },
            toScanCode() {
                uni.scanCode({
                    onlyFromCamera: true,
                    success: (res) => {
                        if (CommonUtils.isEmpty(res.result) === false) {
                            console.log('条码内容:' + res.result);
                            this.lailiaoInfo.barCodeNo = res.result;
                            if (res.result.includes("@") === false) {
                                return uni.showToast({
                                    icon: 'none',
                                    title: '条码格式错误,请重新扫描...'
                                })
                            }
                            let barCodeInfo = res.result.split("@")
                            let [PurchaseBillNo, Row] = barCodeInfo
                            this.lailiaoInfo.HSourceBillNo = PurchaseBillNo,
                            this.lailiaoInfo.HSourceBillLineNo = Row
                            console.log( {
                                    sWhere: ` and 单据号 = '${PurchaseBillNo}'`,
                                    user: this.userInfo.Czymc,
                                })
                            CommonUtils.doRequest(
                                "/Cg_POOrderBill/list", {
                                    sWhere: ` and 单据号 = '${PurchaseBillNo}'`,
                                    user: this.userInfo.Czymc,
                                },
                                (res) => {
                                    console.log('采购订单: ', res)
                                    let {data, count} = res.data
                                    if(count > 0){
                                        this.setLailiaoInfo(data, Row)
                                    }
                                },
                                (error) => {
                                }
                            )
                        }
                    }
                });
            }
        }
    }
</script>
<style lang="scss">
    * {
        box-sizing: border-box;
    }
    input {
        padding: 8rpx 20rpx;
        font-size: 24rpx;
        line-height: 24rpx;
    }
    .container {
        display: flex;
        flex-direction: column;
        height: 100%;
        .content {
            flex: 1;
            .items {
                display: flex;
                flex-direction: column;
                gap: 10rpx;
                padding: 20rpx;
                .item {
                    display: flex;
                    flex-direction: row;
                    padding: 0 10rpx;
                    gap: 20rpx;
                    font-size: 24rpx;
                    // height: 1.5rem;
                    // justify-content: center;
                    align-items: center;
                    .left {
                        text-align: left;
                        width: 5rem;
                    }
                    .right {
                        flex: 1;
                        height: 100%;
                        padding: 6rpx 0;
                        border-radius: 22rpx;
                        border: 1px solid #e4e4e4;
                        background-color: #e4e4e4;
                        >input {
                            height: auto;
                        }
                    }
                }
            }
        }
        .operation-zone {
            height: 6rem;
            display: flex;
            align-items: center;
            justify-content: space-between;
        }
    }
</style>
static/logo_icon.png