yyb
11 小时以前 fd73fca2d3eaf5f53e81d634ecdea408604e798f
核磅录入代码层次错误
已修改1个文件
253 ■■■■ 文件已修改
pages/wareHouse/nuclearScale/nuclearscalerecord.vue 253 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/wareHouse/nuclearScale/nuclearscalerecord.vue
@@ -267,7 +267,7 @@
            // 检查蓝牙连接状态
            async checkBluetoothConnection() {
                if (!this.connectedDevice) return false;
                // 尝试发送一个简单命令检查连接状态
                return new Promise(resolve => {
                    jcapi.checkPrinterStatus(this.connectedDevice.address, r => {
@@ -346,131 +346,133 @@
                    rwMatlBindId: item.id
                };
                try {
                let res = await this.$u.api.dailyPaper.zongjianLabelInfo(params)
                if (!res.data) {
                    this.$refs.uToast.show({
                        title: '未查询到该标签信息!',
                        type: 'warning '
                    })
                    return
                }
                // const res = {
                //     ht: 'HT20250717995352665',
                //     lj: '88.118.1/A0611091',
                //     ljms: '铜单线 裸铜-TY-圆形-3.0',
                //     fh: '1083.6',
                //     scdt: '2025-07-14 13:46:55.0',
                //     scph: '2025071273-3',
                //     fhdw: '江东合金技术有限公司',
                //     shdw: '昆山泰德通铜业有限公司',
                // }
                // 从API响应中提取所需数据
                const {
                    ht,
                    lj,
                    ljms,
                    fh,
                    scdt,
                    scph,
                    fhdw,
                    shdw
                } = res.data
                // const jsonString = JSON.stringify(res.data)
                // 初始化画板
                jcapi.initDrawingBoard({
                    width: 70,
                    height: 49,
                    rotate: 90
                });
                // 绘制二维码
                const qrContent =
                    `ht:${ht}\nlj:${lj}\nljms:${ljms}\nfh:${fh}\nscdt:${scdt}\nscph:${scph}\nfhdw:${fhdw}\nshdw:${shdw}`;
                jcapi.drawLabelQrCode({
                    x: 43.5,
                    y: 2,
                    width: 24,
                    height: 24,
                    value: qrContent,
                    rotate: 0,
                    codeType: QrCodeType.QrCode,
                });
                // getDrawLabelLine    (x坐标,y坐标,线条宽度,线条高度,旋转角度,线条类型)
                // 绘制横线 实线8条
                this.getDrawLabelLine(1, 1, 67, 0.5, 0, LineType.Solid)
                this.getDrawLabelLine(1, 6, 42, 0.3, 0, LineType.Solid)
                this.getDrawLabelLine(1, 11, 42, 0.3, 0, LineType.Solid)
                this.getDrawLabelLine(1, 16, 42, 0.3, 0, LineType.Solid)
                this.getDrawLabelLine(1, 21, 42, 0.3, 0, LineType.Solid)
                this.getDrawLabelLine(1, 27, 67, 0.3, 0, LineType.Solid)
                this.getDrawLabelLine(1, 32, 67,0.3, 0, LineType.Solid)
                this.getDrawLabelLine(1, 37, 67, 0.3, 0, LineType.Solid)
                this.getDrawLabelLine(1, 42, 67, 0.3, 0, LineType.Solid)
                this.getDrawLabelLine(1, 47, 67, 0.5, 0, LineType.Solid)
                //绘制竖线
                this.getDrawLabelLine(1, 1, 0.5, 46, 0, LineType.Solid) // 竖线1
                this.getDrawLabelLine(43, 1, 0.3, 26, 0, LineType.Solid) // 竖线2
                this.getDrawLabelLine(68, 1, 0.5, 46, 0, LineType.Solid) // 竖线2
                // getDrawLabelText    (1.x坐标,2.y坐标,3.文本框宽度,4.文本框高度,5.绘制文字内容,6.字体大小(默认高度4mm),7.旋转角度,8.换行方式,9.⾏间隔,10.字间隔,11.文字水平布局,12文字垂直布局)
                // 标题
                this.getDrawLabelText(3, 2.5, 40, 8, '中天科技装箱清单', 2.5, 0, LineModeType.AutoHeight, 0, 0, 1, 1,1)
                // 填冲文字标题
                this.getDrawLabelText(2, 7, 25, 8, '合同号:', 2.5, 0, LineModeType.AutoHeight, 0, 0, 0, 1,1)
                this.getDrawLabelText(2, 12, 25, 8, '零件号:', 2.5, 0, LineModeType.AutoHeight, 0, 0, 0, 1,1)
                this.getDrawLabelText(2, 17, 25, 8, '零件描述:', 2.5, 0, LineModeType.AutoHeight, 0, 0, 0, 1,1)
                this.getDrawLabelText(2, 22.5, 25, 8, '发货/装箱数:', 2.5, 0, LineModeType.AutoHeight, 0, 0, 0, 1,1)
                this.getDrawLabelText(2, 27.5, 25, 8, '生产日期:', 2.5, 0, LineModeType.AutoHeight, 0, 0, 0, 1,1)
                this.getDrawLabelText(2, 32.5, 25, 8, '生产批号:', 2.5, 0, LineModeType.AutoHeight, 0, 0, 0, 1,1)
                this.getDrawLabelText(2, 37.5, 25, 8, '发货单位:', 2.5, 0, LineModeType.AutoHeight, 0, 0, 0, 1,1)
                this.getDrawLabelText(2, 42.5, 25, 8, '收货单位:', 2.5, 0, LineModeType.AutoHeight, 0, 0, 0, 1,1)
                // 填冲参数值
                this.getDrawLabelText(11, 7, 30, 8, ht, 2.5, 0, LineModeType.AutoHeight, 0, 0, 0, 0,1)
                this.getDrawLabelText(11, 12, 32, 8, lj, 2.5, 0, LineModeType.AutoHeight, 0, 0, 0, 0,1)
                this.getDrawLabelText(14, 17, 30, 8, ljms, 2.5, 0, LineModeType.AutoHeight, 0, 0, 0, 0,1)
                this.getDrawLabelText(17, 22.5, 27, 8, fh, 2.5, 0, LineModeType.AutoHeight, 0, 0, 0, 0,1)
                this.getDrawLabelText(14, 27.5, 55, 8, scdt, 2.5, 0, LineModeType.AutoHeight, 0, 0, 0, 0,1)
                this.getDrawLabelText(14, 32.5, 55, 8, scph, 2.5, 0, LineModeType.AutoHeight, 0, 0, 0, 0,1)
                this.getDrawLabelText(14, 37.5,55, 8, fhdw, 2.5, 0, LineModeType.AutoHeight, 0, 0, 0, 0,1)
                this.getDrawLabelText(14, 42.5, 55, 8, shdw, 2.5, 0, LineModeType.AutoHeight, 0, 0, 0, 0,1)
                // 生成打印数据
                let imageJsonObj = jcapi.generateLabelJson()
                let imageJsonObj111 = jcapi.generatePrintPreviewImage(imageJsonObj)
                console.log('预览', imageJsonObj111)
                // // 设置打印任务
                jcapi.startJob({
                    totalCount: 1,
                    density: this.printDensity,
                    labelType: this.labelType,
                    printMode: this.printMode,
                }, function(r) {
                    console.log('打印', r)
                    if (r.code == 0) {
                        // 打印数据
                        jcapi.printData(imageJsonObj, {
                            "printQuantity": 1,
                        }, function(r) {
                            if (r.code == 0) {
                                console.log("打印成功")
                                uni.showToast({
                                    title: '打印成功',
                                    icon: 'success'
                                })
                            } else {
                                console.log("打印失败")
                                uni.showToast({
                                    title: '打印失败: ' + (r.msg || '未知错误'),
                                    icon: 'none'
                                })
                            }
                    let res = await this.$u.api.dailyPaper.zongjianLabelInfo(params)
                    if (!res.data) {
                        this.$refs.uToast.show({
                            title: '未查询到该标签信息!',
                            type: 'warning '
                        })
                    } else {
                        console.log("设置打印任务失败")
                        return
                    }
                    // const res = {
                    //     ht: 'HT20250717995352665',
                    //     lj: '88.118.1/A0611091',
                    //     ljms: '铜单线 裸铜-TY-圆形-3.0',
                    //     fh: '1083.6',
                    //     scdt: '2025-07-14 13:46:55.0',
                    //     scph: '2025071273-3',
                    //     fhdw: '江东合金技术有限公司',
                    //     shdw: '昆山泰德通铜业有限公司',
                    // }
                    // 从API响应中提取所需数据
                    const {
                        ht,
                        lj,
                        ljms,
                        fh,
                        scdt,
                        scph,
                        fhdw,
                        shdw
                    } = res.data
                    // const jsonString = JSON.stringify(res.data)
                })
                    // 初始化画板
                    jcapi.initDrawingBoard({
                        width: 70,
                        height: 49,
                        rotate: 90
                    });
                    // 绘制二维码
                    const qrContent =
                        `ht:${ht}\nlj:${lj}\nljms:${ljms}\nfh:${fh}\nscdt:${scdt}\nscph:${scph}\nfhdw:${fhdw}\nshdw:${shdw}`;
                    jcapi.drawLabelQrCode({
                        x: 43.5,
                        y: 2,
                        width: 24,
                        height: 24,
                        value: qrContent,
                        rotate: 0,
                        codeType: QrCodeType.QrCode,
                    });
                    // getDrawLabelLine    (x坐标,y坐标,线条宽度,线条高度,旋转角度,线条类型)
                    // 绘制横线 实线8条
                    this.getDrawLabelLine(1, 1, 67, 0.5, 0, LineType.Solid)
                    this.getDrawLabelLine(1, 6, 42, 0.3, 0, LineType.Solid)
                    this.getDrawLabelLine(1, 11, 42, 0.3, 0, LineType.Solid)
                    this.getDrawLabelLine(1, 16, 42, 0.3, 0, LineType.Solid)
                    this.getDrawLabelLine(1, 21, 42, 0.3, 0, LineType.Solid)
                    this.getDrawLabelLine(1, 27, 67, 0.3, 0, LineType.Solid)
                    this.getDrawLabelLine(1, 32, 67, 0.3, 0, LineType.Solid)
                    this.getDrawLabelLine(1, 37, 67, 0.3, 0, LineType.Solid)
                    this.getDrawLabelLine(1, 42, 67, 0.3, 0, LineType.Solid)
                    this.getDrawLabelLine(1, 47, 67, 0.5, 0, LineType.Solid)
                    //绘制竖线
                    this.getDrawLabelLine(1, 1, 0.5, 46, 0, LineType.Solid) // 竖线1
                    this.getDrawLabelLine(43, 1, 0.3, 26, 0, LineType.Solid) // 竖线2
                    this.getDrawLabelLine(68, 1, 0.5, 46, 0, LineType.Solid) // 竖线2
                    // getDrawLabelText    (1.x坐标,2.y坐标,3.文本框宽度,4.文本框高度,5.绘制文字内容,6.字体大小(默认高度4mm),7.旋转角度,8.换行方式,9.⾏间隔,10.字间隔,11.文字水平布局,12文字垂直布局)
                    // 标题
                    this.getDrawLabelText(3, 2.5, 40, 8, '中天科技装箱清单', 2.5, 0, LineModeType.AutoHeight, 0, 0, 1, 1, 1)
                    // 填冲文字标题
                    this.getDrawLabelText(2, 7, 25, 8, '合同号:', 2.5, 0, LineModeType.AutoHeight, 0, 0, 0, 1, 1)
                    this.getDrawLabelText(2, 12, 25, 8, '零件号:', 2.5, 0, LineModeType.AutoHeight, 0, 0, 0, 1, 1)
                    this.getDrawLabelText(2, 17, 25, 8, '零件描述:', 2.5, 0, LineModeType.AutoHeight, 0, 0, 0, 1, 1)
                    this.getDrawLabelText(2, 22.5, 25, 8, '发货/装箱数:', 2.5, 0, LineModeType.AutoHeight, 0, 0, 0, 1, 1)
                    this.getDrawLabelText(2, 27.5, 25, 8, '生产日期:', 2.5, 0, LineModeType.AutoHeight, 0, 0, 0, 1, 1)
                    this.getDrawLabelText(2, 32.5, 25, 8, '生产批号:', 2.5, 0, LineModeType.AutoHeight, 0, 0, 0, 1, 1)
                    this.getDrawLabelText(2, 37.5, 25, 8, '发货单位:', 2.5, 0, LineModeType.AutoHeight, 0, 0, 0, 1, 1)
                    this.getDrawLabelText(2, 42.5, 25, 8, '收货单位:', 2.5, 0, LineModeType.AutoHeight, 0, 0, 0, 1, 1)
                    // 填冲参数值
                    this.getDrawLabelText(11, 7, 30, 8, ht, 2.5, 0, LineModeType.AutoHeight, 0, 0, 0, 0, 1)
                    this.getDrawLabelText(11, 12, 32, 8, lj, 2.5, 0, LineModeType.AutoHeight, 0, 0, 0, 0, 1)
                    this.getDrawLabelText(14, 17, 30, 8, ljms, 2.5, 0, LineModeType.AutoHeight, 0, 0, 0, 0, 1)
                    this.getDrawLabelText(17, 22.5, 27, 8, fh, 2.5, 0, LineModeType.AutoHeight, 0, 0, 0, 0, 1)
                    this.getDrawLabelText(14, 27.5, 55, 8, scdt, 2.5, 0, LineModeType.AutoHeight, 0, 0, 0, 0, 1)
                    this.getDrawLabelText(14, 32.5, 55, 8, scph, 2.5, 0, LineModeType.AutoHeight, 0, 0, 0, 0, 1)
                    this.getDrawLabelText(14, 37.5, 55, 8, fhdw, 2.5, 0, LineModeType.AutoHeight, 0, 0, 0, 0, 1)
                    this.getDrawLabelText(14, 42.5, 55, 8, shdw, 2.5, 0, LineModeType.AutoHeight, 0, 0, 0, 0, 1)
                    // 生成打印数据
                    let imageJsonObj = jcapi.generateLabelJson()
                    let imageJsonObj111 = jcapi.generatePrintPreviewImage(imageJsonObj)
                    console.log('预览', imageJsonObj111)
                    // // 设置打印任务
                    jcapi.startJob({
                        totalCount: 1,
                        density: this.printDensity,
                        labelType: this.labelType,
                        printMode: this.printMode,
                    }, function(r) {
                        console.log('打印', r)
                        if (r.code == 0) {
                            // 打印数据
                            jcapi.printData(imageJsonObj, {
                                "printQuantity": 1,
                            }, function(r) {
                                if (r.code == 0) {
                                    console.log("打印成功")
                                    uni.showToast({
                                        title: '打印成功',
                                        icon: 'success'
                                    })
                                } else {
                                    console.log("打印失败")
                                    uni.showToast({
                                        title: '打印失败: ' + (r.msg || '未知错误'),
                                        icon: 'none'
                                    })
                                }
                            })
                        } else {
                            console.log("设置打印任务失败")
                        }
                    })
                } catch (error) {
                    console.log(error)
                }
            },
            tapQuery(item) {
                this.maskShow = false
@@ -517,7 +519,8 @@
                            // 搜索到设备回调
                            uni.hideLoading()
                            // 如果之前有连接的设备但不在搜索结果中,说明设备已更换
                            if (_this.connectedDevice && !r.some(dev => dev.address === _this.connectedDevice.address)) {
                            if (_this.connectedDevice && !r.some(dev => dev.address === _this
                                    .connectedDevice.address)) {
                                _this.connectedDevice = null;
                                uni.showToast({
                                    icon: 'none',
@@ -552,7 +555,7 @@
            },
            // 填冲文字标题
            getDrawLabelText(x, y, width, height, value, fontSize, rotate, lineMode, lineSpace, letterSpace,
                textAlignHorizontal, textAlignVertical,bold) {
                textAlignHorizontal, textAlignVertical, bold) {
                jcapi.drawLabelText({
                    x: x,
@@ -567,7 +570,7 @@
                    letterSpace: letterSpace,
                    textAlignHorizontal: textAlignHorizontal,
                    textAlignVertical: textAlignVertical,
                    bold:bold
                    bold: bold
                })
            },