zrg
2026-01-25 6b6400c7254cc83f8ae9014a54e9ebea7ac74d39
Merge branch 'Dev' of http://101.37.171.70:10101/r/~jhz/STUWMS into Dev
3个文件已添加
11个文件已修改
793 ■■■■■ 已修改文件
.hbuilderx/launch.json 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
manifest.json 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
nativeplugins/LcPrinter/android/unilcprinterplugin_module-release.aar 补丁 | 查看 | 原始文档 | blame | 历史
nativeplugins/LcPrinter/package.json 25 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages.json 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/ZLGL/QualityReportStep/QualityReportStepBill.vue 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/ZLGL/WorkSelfCheckBill/WorkSelfCheckBill.vue 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/ZLGL/checkFlowList/QC_CheckBillflowList.vue 21 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/ZLGL/chuchangjiaoyandan/QC_OutCompCheckBill.vue 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/ZLGL/lailiaojianyan/POStockInCheckBill.vue 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/ZLGL/mojianjianyan/ProcessCheckBill.vue 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/ZLGL/shoujianjianyan/firstCheckBill.vue 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/index/index.vue 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/tiaomachaima/tiaomachaimaCopy.vue 703 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
.hbuilderx/launch.json
@@ -22,9 +22,9 @@
        },
        {
            "customPlaygroundType" : "local",
            "localRepoPath" : "D:/WorkBench/ZY_APP_Dev/STUWMS/unpackage/debug",
            "localRepoPath" : "C:/Users/19858/Desktop/智云迈思/APP/STUWMS/unpackage/debug",
            "openVueDevtools" : true,
            "packageName" : "com.shebeiguanli.www",
            "packageName" : "com.iflytek.inputmethod",
            "playground" : "custom",
            "type" : "uni-app:app-android"
        }
manifest.json
@@ -158,6 +158,20 @@
                        }
                    }
                }
            },
            "LcPrinter" : {
                "__plugin_info__" : {
                    "name" : "LcPrinter",
                    "description" : "新版打印插件",
                    "platforms" : "Android",
                    "url" : "",
                    "android_package_name" : "",
                    "ios_bundle_id" : "",
                    "isCloud" : false,
                    "bought" : -1,
                    "pid" : "",
                    "parameters" : {}
                }
            }
        }
    },
nativeplugins/LcPrinter/android/unilcprinterplugin_module-release.aar
Binary files differ
nativeplugins/LcPrinter/package.json
New file
@@ -0,0 +1,25 @@
{
    "name": "LcPrinter",
    "id": "LcPrinter",
    "version": "1.0.1",
    "description": "新版打印插件",
    "_dp_type":"nativeplugin",
    "_dp_nativeplugin":{
        "android": {
            "plugins": [
                {
                    "type": "module",
                    "name": "LcPrinter",
                    "class": "uni.dcloud.io.uniplugin_lcprint_new.PrinterModule"
                }
            ],
             "abis": [
                 "armeabi-v7a",
                 "arm64-v8a",
                 "x86"
             ],
            "integrateType": "aar",
            "minSdkVersion" : 21
        }
    }
}
pages.json
@@ -1676,6 +1676,12 @@
            "style": {
                "navigationBarTitleText": "设备维修记录单列表"
            }
        },
        {
            "path": "pages/tiaomachaima/tiaomachaimaCopy",
            "style": {
                "navigationBarTitleText": "条码拆码3"
            }
        }
pages/ZLGL/QualityReportStep/QualityReportStepBill.vue
@@ -737,7 +737,7 @@
                    let res = await CommonUtils.doRequest2Async({
                        url: "/Gy_Employee/list",
                        data: {
                            sWhere: ` and 禁用标记 = '' order by 部门代码`,
                            sWhere: ` and 禁用标记 = '' `,
                            user: getUserInfo()["Czymc"],
                            Organization: uni.getStorageSync("Organization"),
                        },
pages/ZLGL/WorkSelfCheckBill/WorkSelfCheckBill.vue
@@ -954,7 +954,7 @@
                        data: {
                            sWhere: `  and 组织名称 = '${uni.getStorageSync(
                              "Organization"
                            )}' and 禁用标记 = ''and 审核人 !='' order by 部门代码`,
                            )}' and 禁用标记 = ''and 审核人 !='' `,
                            user: getUserInfo()["Czymc"],
                            Organization: uni.getStorageSync("Organization"),
                        },
pages/ZLGL/checkFlowList/QC_CheckBillflowList.vue
@@ -71,7 +71,7 @@
                    <button class="op3" size="mini" plain @tap.stop="audit(item, 1)">反审核</button>
                    <button class="op3" size="mini" plain @tap.stop="fileUpload(item)">文件上传</button>
                    <button class="op3" size="mini" plain @tap.stop="getImage(item)">预览图片</button>
                    <!-- <button class="op3" size="mini" plain @tap.stop="Reject(item)">驳回</button> -->
                    <button class="op3" size="mini" plain @tap.stop="Reject(item)">驳回</button>
                    <button class="op5" size="mini" plain @tap.stop="operations = -1">取消操作</button>
                </view>
            </uni-card>
@@ -271,11 +271,13 @@
                        })
                        if(mode==1){
                            this.showDialog(item["hmainid"]);
                        }else{
                            setTimeout(() => {
                                this.cmdSearch()
                            }, 2000)
                        }
                        this.$forceUpdate()
                        setTimeout(() => {
                            this.cmdSearch()
                        }, 2000)
                    }else {
                        CommonUtils.showTips({
                            title: '温馨提示',
@@ -352,15 +354,15 @@
            },
            //反审核提交意见
            showDialog(HInterID) {
            async showDialog(HInterID) {
              uni.showModal({
                title: '请提交反审核意见',
                editable: true,
                placeholderText: '请输入内容',
                success: (result) => {
                success: async (result) => {
                  if (result.confirm) {
                    try {
                        let res = CommonUtils.doRequest2Sync({
                        let res = await CommonUtils.doRequest2Sync({
                            url: '/LMES/AuditFlowOpinion',
                            data: {
                                "sWhere": result.content,
@@ -381,9 +383,9 @@
                        if (count > 0) {
                            uni.showToast({
                                icon: 'none',
                                title: Message
                                title: "意见提交成功"
                            })
                            this.cmdSearch();
                        } else {
                            uni.showToast({
                                icon: 'none',
@@ -442,6 +444,7 @@
                    } = res.data
                    if (count > 0) {
                        if(data.length>0){
                            const imageUrl = res.data.data[0]["url"];
                            //正则表达式获取服务器路径倒数第二个内容
                            const regex = /^(.*\/)[^\/]+\/[^\/]*\/?$/;
pages/ZLGL/chuchangjiaoyandan/QC_OutCompCheckBill.vue
@@ -1231,7 +1231,7 @@
                        data: {
                            sWhere: `  and 组织名称 = '${uni.getStorageSync(
              "Organization"
            )}' and 禁用标记 = ''and 审核人 !='' order by 部门代码`,
            )}' and 禁用标记 = ''and 审核人 !='' `,
                            user: getUserInfo()["Czymc"],
                            Organization: uni.getStorageSync("Organization"),
                        },
pages/ZLGL/lailiaojianyan/POStockInCheckBill.vue
@@ -1231,7 +1231,7 @@
                        data: {
                            sWhere: `  and 组织名称 = '${uni.getStorageSync(
              "Organization"
            )}' and 禁用标记 = ''and 审核人 !='' order by 部门代码`,
            )}' and 禁用标记 = ''and 审核人 !='' `,
                            user: getUserInfo()["Czymc"],
                            Organization: uni.getStorageSync("Organization"),
                        },
pages/ZLGL/mojianjianyan/ProcessCheckBill.vue
@@ -1173,7 +1173,7 @@
                    let res = await CommonUtils.doRequest2Async({
                        url: "/Gy_Employee/list",
                        data: {
                            sWhere: ` and 组织名称 = '${uni.getStorageSync("Organization")}' and 禁用标记 = ''and 审核人 !='' order by 部门代码`,
                            sWhere: ` and 组织名称 = '${uni.getStorageSync("Organization")}' and 禁用标记 = ''and 审核人 !='' `,
                            user: getUserInfo()["Czymc"],
                            Organization: uni.getStorageSync("Organization"),
                        },
pages/ZLGL/shoujianjianyan/firstCheckBill.vue
@@ -1237,7 +1237,7 @@
                    let res = await CommonUtils.doRequest2Async({
                        url: "/Gy_Employee/list",
                        data: {
                            sWhere: `  and 组织名称 = '${uni.getStorageSync("Organization")}' and 禁用标记 = ''and 审核人 !='' order by 部门代码`,
                            sWhere: `  and 组织名称 = '${uni.getStorageSync("Organization")}' and 禁用标记 = ''and 审核人 !='' `,
                            user: getUserInfo()["Czymc"],
                            Organization: uni.getStorageSync("Organization"),
                        },
pages/index/index.vue
@@ -337,7 +337,13 @@
                        "id": 26,
                        "hidden": false
                    },
                    {
                        "img": "../../static/icon/icon21.png",
                        "text": "条码拆码",
                        "url": "/pages/tiaomachaima/tiaomachaimaCopy",
                        "id": 25,
                        "hidden": false
                    },
                    
                ],
            }
pages/tiaomachaima/tiaomachaimaCopy.vue
New file
@@ -0,0 +1,703 @@
<template>
    <view class="container">
        <view class="header">
            <view class="item">
                <view class="left">条码编号:</view>
                <view class="right">
                    <input :focus="HBarCodeFocus" v-model="barCodeInfoMeta.barCodeNo" placeholder="请扫描条码"
                         @confirm="searchbarCodeInfo" />
                </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 type="number" name="HSplitNum" v-model="barCodeInfoMeta.splitNum" placeholder="请输入拆码数量" />
                </view>
            </view>
            <view class="item">
                <view class="left">制单人:</view>
                <view class="right">
                    <input type="text" disabled name="HMaker" v-model="barCodeInfoMeta.billMaker"
                        style="background-color: #e4e4e4;" placeholder="请输入制单人" />
                </view>
            </view>
            <view class="operation-zone">
                <button :class="cantSplit ? 'btn-disabled' : 'btn-c'" @click="searchbarCodeInfoMeta"
                    :disabled="cantSplit">拆码</button>
                <button type="default" :class="cantGenerate ? 'btn-disabled' : 'btn-c'" @click="SaveBarCodeCreate"
                    :disabled="cantGenerate">生成</button>
                <button type="default" :class="cantPrint ? 'btn-disabled' : 'btn-c'" @click="PrintHBarCode"
                    :disabled="cantPrint">打印</button>
                    <button type="primary" @click="printerLabel">测试打印</button>
                    <button type="primary" @click="printTest">回纸距离</button>
            </view>
        </view>
        <view class="divide"></view>
        <view class="content">
            <view class="barcode-detail" v-show="CommonUtils.isEmpty(Object.assign(barCodeInfo, {})) === false">
                <view class="title">条码信息</view>
                <uni-card>
                    <view class="detail" style="display: none;">
                        <text>条码ID:</text>{{barCodeInfo['HItemID'] || '0'}}
                    </view>
                    <view class="detail">
                        <text>条码编号:</text>{{barCodeInfo['条码编号'] || ''}}
                    </view>
                    <view class="detail">
                        <text>条码原数量:</text>{{barCodeInfo['数量'] || '0'}}
                    </view>
                    <view class="detail">
                        <text>剩余数量:</text>{{barCodeInfo['剩余数量'] || '0'}}
                    </view>
                    <view class="dWetail">
                        <text>物料编码:</text>{{barCodeInfo['物料代码'] || ''}}
                    </view>
                    <view class="detail">
                        <text>物料名称:</text>{{barCodeInfo['物料名称'] || ''}}
                    </view>
                    <view class="detail">
                        <text>规格型号:</text>{{barCodeInfo['规格型号'] || ''}}
                    </view>
                    <view class="detail">
                        <text>计量单位:</text>{{barCodeInfo['计量单位'] || ''}}
                    </view>
                </uni-card>
            </view>
            <view class="divide"></view>
            <view class="barcode-split" v-show="barCodeSplitInfo.length>0">
                <view class="title">条码拆码</view>
                <view class="barcode-split-list" v-for="(item,index) in barCodeSplitInfo" :key="index">
                    <uni-card @tap="ModityHQty(item)">
                        <view class="detail">
                            <text>条码编号:</text>{{item['HBarCode'] || ''}}
                        </view>
                        <view class="detail split-num">
                            <text>拆分数量:</text>{{item['HSplitNum'] || '0'}}
                        </view>
                        <view class="detail">
                            <text>物料代码:</text>{{item['HNumber'] || ''}}
                        </view>
                        <view class="detail">
                            <text>物料名称:</text>{{item['HName'] || ''}}
                        </view>
                        <view class="detail">
                            <text>规格型号:</text>{{item['HModel'] || ''}}
                        </view>
                        <view class="detail">
                            <text>计量单位:</text>{{barCodeInfo['计量单位'] || ''}}
                        </view>
                    </uni-card>
                </view>
            </view>
        </view>
        <view class="over" v-if="barCodeSplitInfo.length == 0">暂无数据</view>
        <view class="over" v-if="barCodeSplitInfo.length != 0">已到底</view>
    </view>
</template>
<script>
    const printer = uni.requireNativePlugin('LcPrinter');
    const modal = uni.requireNativePlugin('modal');
    var globalEvent = uni.requireNativePlugin('globalEvent');
    // 在全局定义一个变量来标识是否已经初始化
    var isPrinterInitialized = false;
    import {
        getUserInfo
    } from "@/utils/auth.js";
    import {
        CommonUtils
    } from "@/utils/common.js"
    export default {
        data() {
            return {
                CommonUtils,
                userInfo: getUserInfo(),
                serverUrl: uni.getStorageSync('serverUrl') || 'http://47.96.97.237/API',
                barCodeInfoMeta: {
                    barCodeNo: "",
                    splitNum: "",
                    billMaker: getUserInfo().Czymc,
                },
                base64:"",
                barCodeInfo: {//原条码信息
                },
                barCodeSplitInfo: [],//拆码信息
                cantGenerate: true, // 生成按钮初始禁用
                cantPrint: true, // 打印按钮初始禁用
                cantSplit: false, // 拆码按钮初始可用
                HBarCodeFocus: false,
                isPrinting:false,
                printInfo: "" //打印
            };
        },
        methods: {
            //打印机初始化
            initPrinter() {
                // 调用异步方法
                console.log('新版初始化');
                var ret = printer.initPrinter({});
                modal.toast({
                    message: ret,
                    duration: 1.5
                });
                printer.printEnableMark({
                    enable: true
                });
                printer.setConcentration({ //设置打印浓度。font_level 取值范围:1~39。
                    level: 39
                });
                printer.setLineSpacing({
                    spacing: 1
                });
                //add by ljh
                printer.setFontSize({
                    fontSize: 8
                });
                //add end
                printer.getsupportprint();
            },
            printTest() {
                printer.printEnableMark({enable: false});
                console.log('测试回纸距离');
                printer.printBarcode({
                    text: 1234567890123456789,
                    height: 80,
                    barcodeType: 73
                });
                printer.setFeedPaperSpace({ space: 1000});
                printer.setUnwindPaperLen({ length: 60 });
                printer.printLine({
                    line_length: 5
                });
                printer.printGoToNextMark();//标签打印使用,开始走纸
                //printer.start();//热敏打印使用,开始走纸
            },
            printerLabel(item) {
                console.log('测试打印');
                printer.setUnwindPaperLen({ length: 60 });
                printer.setFontSize({
                    fontSize: 1
                });
                printer.printText2({
                    offset: 1,
                    fontSize: 2,
                    isBold: false,
                    isUnderLine: false,
                    content: '出库单号:MATO00049684\r\n',
                });
                printer.printText2({
                    offset: 1,
                    fontSize: 2,
                    isBold: false,
                    isUnderLine: false,
                    content: '供应商名称:慈溪瑞益电子有限公司\r\n'
                });
                printer.printText2({
                    offset: 1,
                    fontSize:2,
                    isBold: false,
                    isUnderLine: false,
                    content: '物料代码:R.06.17.02.18002\r\n'
                });
                printer.printText2({
                    offset: 1,
                    fontSize: 2,
                    isBold: false,
                    isUnderLine: false,
                    content: '物料简称:12SH 出风网 注塑灰011(同GE灰)\r\n'
                });
                printer.printText2({
                    offset: 1,
                    fontSize:2,
                    isBold: false,
                    isUnderLine: false,
                    content: '物料名称:12SH 出风网 注塑灰011(同GE灰)\r\n'
                });
                printer.printText2({
                    offset: 1,
                    fontSize:2,
                    isBold: false,
                    isUnderLine: false,
                    content: '数量:1\r\n'
                });
                printer.printText2({
                    offset: 1,
                    fontSize: 2,
                    isBold: false,
                    isUnderLine: false,
                    content: '工号:1\r\n'
                });
                printer.printText2({
                    offset: 1,
                    fontSize: 2,
                    isBold: false,
                    isUnderLine: false,
                    content: '生产日期:2025-8-13\r\n'
                });
                printer.printText2({
                    offset: 1,
                    fontSize: 2,
                    isBold: false,
                    isUnderLine: false,
                    content: '工号:000001\r\n'
                });
                printer.printQR2({
                    text: 'title',
                    height: 100,
                    offset: 3
                });
                printer.printGoToNextMark();
                console.log('测试打印QR结束');
            },
            doRequest(url, data, resFunction, errFunction, method) {
                uni.showLoading({
                    title: '加载中...'
                })
                uni.request({
                    method: method || "GET",
                    url: this.serverUrl + url,
                    data: data || "",
                    success: (res) => {
                        if (typeof resFunction === 'function') {
                            resFunction.call(this, res)
                        } else if (typeof errFunction === 'undefined') {
                            return
                        } else {
                            throw new TypeError("访问成功回调函数类型异常!")
                        }
                    },
                    fail: (err) => {
                        uni.showToast({
                            icon: "error",
                            title: "接口访问异常!",
                            duration: 2000
                        })
                        if (typeof errFunction === 'function') {
                            errFunction.call(this, err)
                        } else if (typeof errFunction === 'undefined') {
                            return
                        } else {
                            throw new TypeError("访问失败回调函数类型异常!")
                        }
                    }
                })
                uni.hideLoading()
            },
            //光标
            async refreshBarCodeState() {
                this.HBarCodeFocus = false
                await this.$nextTick(() => {
                    this.HBarCodeFocus = true
                    this.barCodeInfoMeta.barCodeNo = ""
                })
            },
            //摄像头调用
            async searchbarCodeInfo() {
                await this.$nextTick()
                let urlEncode =
                    `/Gy_BarCodeBillList/page?sWhere= and 条码编号=''${this.barCodeInfoMeta.barCodeNo}''&user=${getUserInfo()["Czymc"]}&page=1&size=1`
                    .toString()
                if (CommonUtils.isEmpty(this.barCodeInfoMeta.barCodeNo) == true) {
                    return uni.showToast({
                        icon: "fail",
                        title: "条码编号不能为空!"
                    })
                }
                this.doRequest(
                    urlEncode, {},
                    (res) => {
                        console.log(res)
                        let res1 = res.data
                        let {
                            data,
                            count
                        } = res1
                        if (count > 0) {
                            this.barCodeInfo = data[0]
                            this.barCodeSplitInfo = []
                            // 扫描条码后重置按钮状态
                            this.resetButtonState();
                        }else{
                            CommonUtils.showTips({
                                message: "该条码不存在:"+this.barCodeInfoMeta.barCodeNo,
                            })
                            this.barCodeInfoMeta.barCodeNo="";
                        }
                    },
                    (err) => {
                        console.err(err)
                        uni.showToast({
                            icon: "fail",
                            title: err
                        })
                    }
                )
            },
            //拆码按钮调用
            async searchbarCodeInfoMeta() {
                this.cantGenerate = true
                this.cantPrint = true
                this.cantSplit = false // 拆码前确保拆码按钮可用
                if (CommonUtils.isEmpty(this.barCodeInfoMeta.barCodeNo) === true) {
                    return uni.showToast({
                        icon: 'none',
                        title: '条码编号不得为空!'
                    });
                }
                if (CommonUtils.isEmpty(this.barCodeInfoMeta.splitNum, true) === true) {
                    return uni.showToast({
                        icon: 'none',
                        title: '拆分数量不得为空!'
                    });
                }
                if (CommonUtils.isEmpty(this.barCodeInfoMeta.splitNum, true) === true) {
                    return uni.showToast({
                        icon: 'none',
                        title: '拆分数量不得为空!'
                    });
                }
                if (parseFloat(this.barCodeInfoMeta.splitNum) > parseFloat(this.barCodeInfo['数量'])) {
                    return uni.showToast({
                        icon: 'none',
                        title: '拆分数量不能大于条码原数量!'
                    });
                }
                this.doRequest(
                    "/Sc_BarCode/SplitBarCode_Sub", {
                        HBarCodeNo: this.barCodeInfoMeta.barCodeNo,
                    },
                    (res) => {
                        this.barCodeSplitInfo = []
                        if (res.data.count > 0) {
                            if (res.data.data.length < 1) {
                                return uni.showToast({
                                    icon: 'none',
                                    title: Message
                                });
                            }
                            //拆分条码:数量为 splitNum
                            let barCodeItem1 = JSON.parse(JSON.stringify(res.data.data.SubBarCodes[0]));
                            let HSplitNum = this.barCodeInfoMeta.splitNum;
                            this.barCodeSplitInfo.push({
                                HSplitNum: this.barCodeInfoMeta.splitNum,
                                HBarCode: res.data.data.NextBarCode,
                                HNumber: barCodeItem1.HNumber,
                                HName: barCodeItem1.HName,
                                HModel: barCodeItem1.HModel
                            });
                            //更新原先条码数量
                            this.barCodeInfo['剩余数量'] = this.barCodeInfo['数量'] - this.barCodeInfoMeta.splitNum;
                            // 拆码成功,禁用拆码按钮,放开生成按钮
                            this.cantSplit = true;
                            this.cantGenerate = false;
                            this.cantPrint = true;
                            //生成
                            this.SaveBarCodeCreate();
                        } else {
                            uni.showToast({
                                icon: 'none',
                                title: '没有找到对应的单据'
                            });
                        }
                    },
                    (err) => {
                        CommonUtils.showTips({
                            message: "条码拆码出现错误"+err,
                        })
                        console.error(err)
                    }
                )
            },
            //保存方法
            SaveBarCodeCreate() {
                // 校验拆码数量
                let sum = this.barCodeSplitInfo.reduce((acc, obj) => {
                    return acc + obj["HSplitNum"]
                }, 0)
                if (sum > this.barCodeInfo["HQty"]) {
                    return uni.showToast({
                        icon: 'none',
                        title: '拆码数量和不得大于条码数量'
                    });
                }
                let msg =
                    `${this.barCodeInfoMeta["barCodeNo"]};${this.barCodeInfoMeta["splitNum"]};${JSON.stringify(this.barCodeSplitInfo)};${this.billMaker}`
                this.doRequest(
                    "/Sc_BarCode/SplitBarCode_Save", {
                        msg: msg
                    },
                    (res) => {
                        if (res.data.code == 1) {
                            // 生成成功,禁用生成按钮,放开打印按钮
                            this.cantGenerate = true;
                            this.cantPrint = false;
                            this.cantSplit = true;
                            this.barCodeInfoMeta.barCodeNo="";//清空输入框
                            uni.showToast({
                                title: '生成成功!'
                            });
                        } else {
                            this.cantGenerate = false;
                            uni.showToast({
                                title: res.data.Message
                            });
                        }
                    },
                    (err) => {
                        console.log(err)
                        CommonUtils.showTips({
                            message: "条码生成出现错误"+err,
                        })
                    },
                    "POST"
                )
            },
            //打印按钮
            // 父组件中的打印方法
            async PrintHBarCode() {
                // 防止重复点击
                if (this.isPrinting) {
                    uni.showToast({
                        title: '打印中,请稍候...',
                        icon: 'none'
                    });
                    return;
                }
                this.isPrinting = true;
                try {
                    let HBarCodeNoStr = `${this.barCodeSplitInfo[0]['HBarCode']}`;
                    console.log('获取数据', HBarCodeNoStr);
                    // 显示打印中状态
                    uni.showLoading({
                        title: '打印中...',
                        mask: true
                    });
                    // 获取打印数据
                    const printData = await new Promise((resolve, reject) => {
                        uni.request({
                            url: this.serverUrl + '/Sc_BarCode/GetSplitBarCode_SubList',
                            data: {
                                HBarCodeNo: HBarCodeNoStr
                            },
                            success: (res) => {
                                if (res.data.count == 1) {
                                    resolve(res.data.data[0]);
                                } else {
                                    reject(new Error(res.data.Message || '未找到打印数据'));
                                }
                            },
                            fail: (err) => {
                                reject(new Error('接口请求失败'));
                            }
                        });
                    });
                    const item = printData;
                    // 等待打印组件更新
                    await this.$nextTick();
                    // 打印成功后重置状态
                    uni.hideLoading();
                    //this.printerLabel();//打印
                } catch (error) {
                    console.error('打印失败:', error);
                    uni.hideLoading();
                    this.isPrinting = false;
                    uni.showToast({
                        title: error.message || '打印失败',
                        icon: 'error',
                        duration: 2000
                    });
                    CommonUtils.playSound(0);
                }
            },
            toScanCode() {
                var mpaasScanModule = uni.requireNativePlugin("Mpaas-Scan-Module")
                mpaasScanModule.mpaasScan({
                    'hideAlbum': true,
                    'timeoutInterval': '10', //超时时间
                    'timeoutText': '未识别到二维码' //超时提醒
                }, (ret) => {
                    console.log(ret.resp_result)
                    if (this.CommonUtils.isEmpty(ret.resp_result) === false) {
                        console.log('条码内容:' + ret.resp_result);
                        this.barCodeInfoMeta.barCodeNo = ret.resp_result
                        this.searchbarCodeInfo()
                    }
                })
            },
            // 重置按钮状态方法
            resetButtonState() {
                this.cantSplit = false; // 拆码按钮可用
                this.cantGenerate = true; // 生成按钮禁用
                this.cantPrint = true; // 打印按钮禁用
            }
        },
        onLoad() {
            this.HBarCodeFocus = true;
            // 页面初始化时设置按钮状态
            this.resetButtonState();
            // 添加打印状态监听
            if(!isPrinterInitialized){
                globalEvent.addEventListener('onPrintCallback', function(e) {
                    uni.showToast({
                        title: 'state: ' + JSON.stringify(e),
                        duration: 2000
                    });
                    if (e.key == 0) {
                        uni.showToast({
                            title: '打印成功',
                            duration: 2000
                        });
                        //成功后设置状态
                        this.isPrinting = false;
                        //this.resetButtonState();
                    } else if (e.key == 3) {
                        this.isPrinting = false;
                        uni.showToast({
                            title: '缺纸',
                            duration: 2000
                        });
                    }
                });
                globalEvent.addEventListener('getsupportprint', function(e) {
                    console.log('key: ' + JSON.stringify(e));
                    uni.showToast({
                        title: 'key: ' + JSON.stringify(e),
                        duration: 2000
                    });
                });
            }
            //初始化打印
            this.initPrinter();
        },
        onReady() {
        }
    }
</script>
<style lang="scss">
    * {
        box-sizing: border-box;
    }
    input {
        padding: 8rpx 20rpx;
        font-size: 30rpx;
        line-height: 30rpx;
    }
    button {
        padding: 0;
        width: 150rpx;
        font-size: 25rpx;
    }
    .uni-card {
        margin: 0 !important;
    }
    .container {
        .header {
            padding: 20rpx 10rpx;
            display: flex;
            flex-direction: column;
            gap: 20rpx;
            .item {
                display: flex;
                flex-direction: row;
                padding: 0 10rpx;
                gap: 20rpx;
                font-size: 30rpx;
                // height: 1.5rem;
                // justify-content: center;
                align-items: center;
                .left {
                    text-align: right;
                    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 {
                display: flex;
                flex-direction: row;
                justify-content: space-evenly;
                .btn-c {
                    background-color: #3a78ff;
                    color: #fff;
                }
            }
        }
        .divide {
            width: 100%;
            height: 16rpx;
            background-color: #e5e5e5;
        }
        .content {
            flex: 1;
            .barcode-detail,
            .barcode-split {
                padding: 30rpx;
                display: flex;
                flex-direction: column;
                gap: 30rpx;
            }
        }
    }
</style>