chenhaozhe
8 小时以前 338fdb77b1690eea511fb604fd985ae31629b9e4
Merge branch 'Dev' of http://101.37.171.70:10101/r/~jhz/STUWMS into Dev

# Conflicts:
# manifest.json
# pages.json
3个文件已添加
11个文件已修改
1843 ■■■■■ 已修改文件
manifest.json 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages.json 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/ZLGL/QualityReportStep/QualityReportStepBill.vue 359 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/ZLGL/mojianjianyan/ProcessCheckBill.vue 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/ZLGL/shoujianjianyan/firstCheckBill.vue 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/ZLGL/xunjianjianyan/PatrolProcCheckBill.vue 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/caigoutuiliaocheck/Kf_POStockInBackBill_Check.vue 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/caigoutuiliaocheck/Kf_POStockInBackBill_CheckList.vue 448 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/index/login.vue 102 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/index/tab2.vue 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/tiaomachaima/tiaomachaimaCopy_HK.vue 389 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/weiwaituiliaocheck/Kf_EntrustOutBackBill_Check.vue 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/weiwaituiliaocheck/Kf_EntrustOutBackBill_CheckList.vue 448 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
utils/Print_HK.js 41 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
manifest.json
@@ -2,8 +2,8 @@
    "name" : "智云LMES",
    "appid" : "__UNI__B002F49",
    "description" : "",
    "versionName" : "3.023",
    "versionCode" : 323,
    "versionName" : "3.026",
    "versionCode" : 326,
    "transformPx" : false,
    /* 5+App特有相关 */
    "app-plus" : {
pages.json
@@ -1954,7 +1954,6 @@
        },
        {
            "path": "pages/ZLGL/QCNoPassProdConclusionBillMain/QCNoPassProdConclusionBillMainList",
            "style": {
                "navigationBarTitleText": "不良品评审单结论单列表"
            }
@@ -2069,6 +2068,21 @@
            {
                "navigationBarTitleText" : "受托加工入库单列表"
            }
        },
        {
            "path": "pages/weiwaituiliaocheck/Kf_EntrustOutBackBill_CheckList",
            "style": {
                "navigationBarTitleText": "委外退料校验缓存"
            }
        },
        {
            "path": "pages/caigoutuiliaocheck/Kf_POStockInBackBill_CheckList",
            "style": {
                "navigationBarTitleText": "采购退料校验缓存列表"
            }
        }
    ],
    "tabBar": {
pages/ZLGL/QualityReportStep/QualityReportStepBill.vue
@@ -4,10 +4,16 @@
        <view class="bill-main-area">
            <!-- 主表页签 -->
            <view class="bill-main-tabs">
                <view :class="mainTabSelected == 1 ? 'selected' : ''" @tap="mainTabSelected = 1">基本信息</view>
                <view :class="mainTabSelected == 2 ? 'selected' : ''" @tap="mainTabSelected = 2">扫描信息</view>
                <view :class="mainTabSelected == 3 ? 'selected' : ''" @tap="mainTabSelected = 3">制单信息</view>
                <view :class="mainTabSelected == 4 ? 'selected' : ''" @tap="mainTabSelected = 4">其他信息</view>
                <view class="tabs-left">
                    <view :class="mainTabSelected == 1 ? 'selected' : ''" @tap="mainTabSelected = 1">基本信息</view>
                    <view :class="mainTabSelected == 2 ? 'selected' : ''" @tap="mainTabSelected = 2">扫描信息</view>
                    <view :class="mainTabSelected == 3 ? 'selected' : ''" @tap="mainTabSelected = 3">制单信息</view>
                    <view :class="mainTabSelected == 4 ? 'selected' : ''" @tap="mainTabSelected = 4">其他信息</view>
                </view>
                <view class="mode-switch-right">
                    <text class="mode-text">{{ directInputMode ? '直接输入' : '双击累加' }}</text>
                    <switch :checked="directInputMode" @change="onModeSwitchChange" color="#3a78ff" style="transform: scale(0.7);" />
                </view>
            </view>
            <!-- 主表内容 -->
            <view class="bill-main-contents">
@@ -292,6 +298,32 @@
        
        <BillListPopupVue ref="billList" :HBillType="hform.HBillType" :HSourceBillType="hform.HSourceBillType"
            :HStockOrgID="hform.HStockOrgID" @BillSelectComplete="HandleBillSelectComplete"></BillListPopupVue>
        <!-- 直接输入数量弹窗 -->
        <uni-popup ref="inputQtyPopup" type="center">
            <view class="input-qty-popup">
                <view class="popup-title">输入不良数量</view>
                <view class="popup-content">
                    <view class="popup-info">
                        <text class="popup-label">不良原因:</text>
                        <text class="popup-value">{{ currentItem && currentItem.不良原因名称 || '' }}</text>
                    </view>
                    <view class="popup-info">
                        <text class="popup-label">当前数量:</text>
                        <text class="popup-value">{{ currentItem && currentItem.num || 0 }}</text>
                    </view>
                    <view class="popup-input-row">
                        <text class="popup-label">输入数量:</text>
                        <input class="popup-input" type="number" v-model="inputQtyValue" placeholder="请输入数量" />
                    </view>
                </view>
                <view class="popup-buttons">
                    <button class="btn-c" size="mini" @tap="cancelInputQty">取消</button>
                    <view style="flex: 1;"></view>
                    <button class="btn-a" size="mini" @tap="confirmInputQty">确认</button>
                </view>
            </view>
        </uni-popup>
    </view>
</template>
@@ -326,7 +358,12 @@
                //上一次点击时间
                lastClickTime: 0,
                operationType: 1,
                // 直接输入模式开关
                directInputMode: true,
                // 弹窗相关
                currentItem: null,
                inputQtyValue: '',
                mainTabSelected: 1,
                subTabSelected: 0,
@@ -435,6 +472,11 @@
            },
            //不良原因单击
            reasonClick(item) {
                // 直接输入模式下,单击直接弹出输入框
                if (this.directInputMode) {
                    this.showDirectInputDialog(item);
                    return;
                }
                const now = Date.now();
                if (now - this.lastClickTime < 300) {
                  // 双击逻辑
@@ -445,6 +487,37 @@
                  this.handleSingleClick(item);
                  this.lastClickTime = now;
                }
            },
            // 模式切换
            onModeSwitchChange(e) {
                this.directInputMode = e.detail.value;
            },
            // 显示直接输入数量的弹窗
            showDirectInputDialog(item) {
                this.currentItem = item;
                this.inputQtyValue = String(item.num || 0);
                this.$refs.inputQtyPopup.open();
            },
            // 取消输入
            cancelInputQty() {
                this.$refs.inputQtyPopup.close();
                this.currentItem = null;
                this.inputQtyValue = '';
            },
            // 确认输入
            confirmInputQty() {
                const inputQty = parseInt(this.inputQtyValue);
                if (isNaN(inputQty) || inputQty < 0) {
                    uni.showToast({
                        title: '请输入有效数量',
                        icon: 'none'
                    });
                    return;
                }
                this.submitBarCodeWithQty(this.currentItem, inputQty);
                this.$refs.inputQtyPopup.close();
                this.currentItem = null;
                this.inputQtyValue = '';
            },
            handleSingleClick(item) {
                console.log('单击:', item.不良原因名称);
@@ -532,7 +605,7 @@
                        }        
                    })
                    this.HBadReasonList = data;
                    this.getHisReportList();//获取历史记录
                } else {
                    CommonUtils.showTips({
                        title: '温馨提示',
@@ -594,6 +667,7 @@
                    this.hform.HProcName= data[0].当前工序
                    this.hform.HDeptID= data[0].HWorkShopID
                    this.getGy_BadReasonList();
                } else {
                    CommonUtils.showTips({
                        title: '温馨提示',
@@ -688,22 +762,25 @@
                        url: "/Sc_QualityReportBill/get_BarCodeDetail",
                        data: {
                            HInterID: this.hform.HInterID,
                        },
                    });
                    let {
                        data,
                        Message,
                        count
                    } = res.data;
                    if (count == 1) {
                        console.log("data: ", data);
                        this.HisReportList = data;
                        // 统计各不良原因的数量并更新到 HBadReasonList
                        this.updateBadReasonNumFromHisReport();
                    } else {
                        this.HisReportList = [];
                        this.clearBadReasonNum();
                        CommonUtils.showTips({
                            title: "温馨提示",
                            message: `获取历史扫码记录失败: ${Message}`,
@@ -715,6 +792,33 @@
                        message: `获取历史扫码记录失败: ${err}`,
                    });
                }
            },
            // 从 HisReportList 统计更新 HBadReasonList 的 num
            updateBadReasonNumFromHisReport() {
                // 先清空所有 num
                this.HBadReasonList.forEach(item => {
                    this.$set(item, 'num', 0);
                });
                // 统计 HisReportList 中各不良原因的数量
                if (this.HisReportList && this.HisReportList.length > 0) {
                    this.HisReportList.forEach(hisItem => {
                        // 根据 HBadReasonID 匹配
                        const matchedItem = this.HBadReasonList.find(
                            badItem => badItem.不良原因代码 == hisItem.HBadReasonNumber
                        );
                        if (matchedItem) {
                            const currentNum = matchedItem.num || 0;
                            this.$set(matchedItem, 'num', currentNum + hisItem.HBadReasonHQty||1);
                        }
                    });
                }
            },
            // 清空 HBadReasonList 的 num
            clearBadReasonNum() {
                this.HBadReasonList.forEach(item => {
                    this.$set(item, 'num', 0);
                });
            },
            //删除历史记录
            delReason(item) {
@@ -948,15 +1052,85 @@
                            title: "保存成功",
                            message: `保存成功`,
                        });
                        if(!item.num){
                            this.$set(item, 'num', 1);
                        }else{
                            this.$set(item, 'num', item.num+1);
                        }
                        console.log(item.num)
                        //this.$set(item, 'num', newValue);
                        // 刷新历史记录,num会自动从HisReportList统计更新
                        this.getHisReportList();
                        this.hasCheckQty=true;
                    } else {
                        CommonUtils.showTips({
                            title: "温馨提示",
                            message: `不良原因保存错误: ${Message}`,
                        });
                    }
                } catch (err) {
                    CommonUtils.showTips({
                        title: "温馨提示",
                        message: `不良原因保存错误: ${err}`,
                    });
                }
            },
            //提交不良原因扫码记录缓存(直接输入数量)
            async submitBarCodeWithQty(item, qty){
                if(!this.checkSubmitValidate()){
                    return
                }
                try {
                    let oMainObject = {
                        HInterID:this.hform.HInterID
                        ,HBillNo:this.hform.HBillNo
                        ,HBillType:this.hform.HBillType
                        ,HDate:new Date()
                        ,HICMOBillNo:this.hform.HICMOBillNo
                        ,HICMOInterID:this.hform.HICMOInterID
                        ,HICMOEntryID:this.hform.HICMOEntryID
                        ,HProcExchBillNo:this.hform.HProcExchBillNo
                        ,HProcExchInterID:this.hform.HProcExchInterID
                        ,HProcExchEntryID:this.hform.HProcExchEntryID
                        ,HProcID:this.hform.HProcID
                        ,HMaterID:this.hform.HMaterID
                        ,HSourceID:this.hform.HSourceID
                        ,HGroupID:this.hform.HGroupID
                        ,HDeptID:this.hform.HDeptID
                        ,HCheckManID:this.hform.HEmpID
                        ,HBadReasonID:item.HItemID
                        ,HBarCode:item.不良原因代码
                        ,HMaker:this.hform.HMaker
                        ,HMakeDate:this.hform.HMakeDate
                        ,HReportType:1
                        ,HSourceBillType:this.hform.HSourceBillType
                        ,HSourceBillNo:this.hform.HSourceBillNo
                        ,HSourceInterID:this.hform.HMainSourceInterID
                        ,HSourceEntryID:this.hform.HMainSourceEntryID
                        ,HBadReasonHQty:qty
                        ,HQty:this.hform.HCheckQty
                    }
                    var sMainStr = JSON.stringify(oMainObject);
                    var oMain = sMainStr + ';' + this.operationType;
                    let res = await CommonUtils.doRequest2Sync({
                        url: "/Sc_QualityReportBill/set_SaveBarCode",
                        data: {
                            oMain: oMain,
                        },
                        method: "POST",
                    });
                    if (!res) {
                        return;
                    }
                    let {
                        count,
                        Message,
                        data
                    } = res.data;
                    if (count == 1) {
                        CommonUtils.showTips({
                            title: "保存成功",
                            message: `保存成功,数量: ${qty}`,
                        });
                        // 刷新历史记录,num会自动从HisReportList统计更新
                        this.getHisReportList();
                        this.hasCheckQty = true;
                    } else {
                        CommonUtils.showTips({
                            title: "温馨提示",
@@ -1074,22 +1248,20 @@
            },
            // 设置为自动
            setAuto() {
                if (uni.getSystemInfoSync().platform === 'android' ||
                      uni.getSystemInfoSync().platform === 'ios') {
                    plus.screen.unlockOrientation();
                }
                //#ifdef APP-PLUS
                plus.screen.unlockOrientation()
                //#endif
            },
            // 设置为竖屏
            setPortrait() {
              if (uni.getSystemInfoSync().platform === 'android' ||
                  uni.getSystemInfoSync().platform === 'ios') {
                //#ifdef APP-PLUS
                plus.screen.lockOrientation('portrait');
              }
              //#endif
            },
            
        },
        async onLoad(e) {
            //this.setAuto();
            this.setAuto();
            this.operationType = e.operationType || 1;
            this.hform.HInterID = e.linterid || 0;
            if (this.operationType == 1) {
@@ -1119,7 +1291,55 @@
        padding: 0;
    }
    .bill-main-tabs,
    .bill-main-tabs {
        box-sizing: border-box;
        width: 100%;
        display: flex;
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        border-bottom: 1px solid #ddd;
        padding: 20rpx 10rpx;
        .tabs-left {
            display: flex;
            flex-direction: row;
            flex-wrap: nowrap;
            gap: 20rpx;
            flex-shrink: 0;
            overflow-x: auto;
            white-space: nowrap;
            view {
                width: auto;
                font-size: 30rpx;
                color: #555;
                text-align: center;
                padding: 16rpx 0;
            }
            .selected {
                color: #3a78ff;
                font-weight: bold;
                border-bottom: 3px solid #3a78ff;
            }
        }
        .mode-switch-right {
            display: flex;
            flex-direction: row;
            align-items: center;
            gap: 10rpx;
            flex-shrink: 0;
            padding-right: 10rpx;
            .mode-text {
                font-size: 24rpx;
                color: #666;
            }
        }
    }
    .bill-sub-tabs {
        box-sizing: border-box;
        width: 100%;
@@ -1148,6 +1368,93 @@
        }
    }
    /* 直接输入数量弹窗样式 */
    .input-qty-popup {
        background-color: #fff;
        border-radius: 20rpx;
        padding: 30rpx;
        width: 600rpx;
        box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.15);
        .popup-title {
            font-size: 32rpx;
            font-weight: bold;
            color: #333;
            text-align: center;
            padding-bottom: 20rpx;
            border-bottom: 1px solid #eee;
        }
        .popup-content {
            padding: 20rpx 0;
            .popup-info {
                display: flex;
                align-items: center;
                padding: 10rpx 0;
                .popup-label {
                    font-size: 28rpx;
                    color: #666;
                    width: 180rpx;
                }
                .popup-value {
                    font-size: 28rpx;
                    color: #333;
                }
            }
            .popup-input-row {
                display: flex;
                align-items: center;
                padding: 15rpx 0;
                margin-top: 10rpx;
                .popup-label {
                    font-size: 28rpx;
                    color: #666;
                    width: 180rpx;
                }
                .popup-input {
                    flex: 1;
                    height: 60rpx;
                    border: 1px solid #acacac;
                    border-radius: 10rpx;
                    padding: 0 15rpx;
                    font-size: 28rpx;
                }
            }
        }
        .popup-buttons {
            display: flex;
            flex-direction: row;
            gap: 10rpx;
            padding-top: 20rpx;
            border-top: 1px solid #eee;
            button {
                border-radius: 50rpx;
                width: 150rpx;
                height: 60rpx;
                line-height: 60rpx;
                font-size: 28rpx;
            }
            .btn-a {
                background-color: #3a78ff;
                color: #fff;
            }
            .btn-c {
                background-color: #acacac;
                color: #fff;
            }
        }
    }
    .bill-main-content,
    .bill-sub-content {
        box-sizing: border-box;
pages/ZLGL/mojianjianyan/ProcessCheckBill.vue
@@ -1492,10 +1492,11 @@
                    HStatus: 1,
                    HSampleSchemeID: "",
                    HUnitID: 0,
                    HInspectVal: "",
                    HInspectVal: "0",
                    HTargetVal: "",
                    HUpLimit: "",
                    HDownLimit: "",
                    HInspectValQ:0,
                    HUpOffSet: "",
                    HDownOffSet: "",
                    HSampleDamageQty: 0,
@@ -1640,6 +1641,7 @@
                        HUpLimit: data["上限值"] || 0,
                        HDownLimit: data["下限值"] || 0,
                        HSampleDamageQty: data["样本破坏数"] || 0,
                        HInspectValQ:  0
                    });
                    await this.$nextTick();
                    this.$refs.listPopup.exit();
@@ -1927,7 +1929,7 @@
                                HStatus: 0,
                                HSampleSchemeID: data[i]["HSampleSchemeID"],
                                HUnitID: data[i]["HUnitID"],
                                HInspectVal: "",
                                HInspectVal: "0",
                                HTargetVal: "",
                                HUpLimit: data[i].上限值,
                                HDownLimit: data[i].下限值,
pages/ZLGL/shoujianjianyan/firstCheckBill.vue
@@ -1487,7 +1487,7 @@
                    HStatus: 1,
                    HSampleSchemeID: "",
                    HUnitID: 0,
                    HInspectVal: "",
                    HInspectVal: "0",
                    HTargetVal: "",
                    HUpLimit: "",
                    HDownLimit: "",
@@ -1504,7 +1504,7 @@
                    HAQL: "",
                    HSamplingType: "",
                    HInspectResultToSee: "",
                    HInspectValQ: "",
                    HInspectValQ: "0",
                    isFocus: false,
                };
                if (resource) {
@@ -1908,7 +1908,7 @@
                                HStatus: 0,
                                HSampleSchemeID: data[i]["HSampleSchemeID"],
                                HUnitID: data[i]["HUnitID"],
                                HInspectVal: "",
                                HInspectVal: "0",
                                HTargetVal: "",
                                HUpLimit: data[i].上限值,
                                HDownLimit: data[i].下限值,
pages/ZLGL/xunjianjianyan/PatrolProcCheckBill.vue
@@ -1373,7 +1373,7 @@
                    HStatus: 1,
                    HSampleSchemeID: "",
                    HUnitID: 0,
                    HInspectVal: "",
                    HInspectVal: "0",
                    HTargetVal: "",
                    HUpLimit: "",
                    HDownLimit: "",
@@ -1792,7 +1792,7 @@
                                HStatus: 0,
                                HSampleSchemeID: data[i]["HSampleSchemeID"],
                                HUnitID: data[i]["HUnitID"],
                                HInspectVal: "",
                                HInspectVal: "0",
                                HTargetVal: "",
                                HUpLimit: data[i].上限值,
                                HDownLimit: data[i].下限值,
pages/caigoutuiliaocheck/Kf_POStockInBackBill_Check.vue
@@ -917,7 +917,7 @@
                                        if (res.confirm) {
                                            console.log('用户点击确定');
                                            uni.redirectTo({
                                                url: '/pages/shengchantuiliaoCheck/MateOutBackCheckBill?OperationType=1'
                                                url: '/pages/caigoutuiliaocheck/Kf_POStockInBackBill_Check?OperationType=1'
                                            })
                                        } else if (res.cancel) {
                                            console.log('用户点击取消');
@@ -954,7 +954,7 @@
                        if (res.confirm) {
                            console.log('用户点击确定');
                            uni.redirectTo({
                                url: '/pages/shengchantuiliaoCheck/MateOutBackCheckBillList'
                                url: '/pages/caigoutuiliaocheck/Kf_POStockInBackBill_CheckList'
                            })
                        } else if (res.cancel) {
                            console.log('用户点击取消');
pages/caigoutuiliaocheck/Kf_POStockInBackBill_CheckList.vue
New file
@@ -0,0 +1,448 @@
<template>
    <view class="content">
        <view class="tabs">
            <view :class="tabs == 0 ? 'on':''" @tap="changeTab(0)">缓存列表</view>
            <view :class="tabs == 1 ? 'on':''" @tap="changeTab(1)">已上传列表</view>
        </view>
        <view style="width: 100%;height: 16rpx;background-color: #e5e5e5;"></view>
        <view class="form" v-if="tabs == 0">
            <view class="buttons" @tap="add">
                <uni-icons type="plus" style="margin-right: 10rpx;" size="22"></uni-icons>新增
            </view>
        </view>
        <view class="form" v-if="tabs == 1">
            <view class="form-item">
                <view class="title">单据号:</view>
                <view class="right">
                    <input v-model="hform.HBillNo" placeholder="请输入单据号" />
                </view>
            </view>
            <view class="buttons">
                <button class="btn-a" size="mini" type="default" @tap="clear">重置</button>
                <button class="btn-c" size="mini" type="default" @tap="search">查询</button>
            </view>
        </view>
        <view style="width: 100%;height: 16rpx;background-color: #e5e5e5;"></view>
        <view class="list" v-for="(item,index) in showList" :key="index" v-if="tabs==0">
            <uni-card :title="item.制单日期.substr(0,10)" :extra="item.单据号" style="margin: 10px;" @tap="showDetail = showDetail==index?-1:index">
                <view class="card-detail">
                    <view class="detail" v-if="item.制单人">
                        <text>制单人:</text>{{item.制单人}}
                    </view>
                    <view class="detail" v-if="item.组织">
                        <text>组织:</text>{{item.组织}}
                    </view>
                </view>
                <view class="more">
                    <view class="part" style="border-right: 1px solid #eee;color: #3a78ff;" @tap.stop="edit(item)">
                        <uni-icons type="compose" style="color: #3a78ff;margin-right: 10rpx;" size="18"></uni-icons>编辑
                    </view>
                    <view class="part" style="color: #da0000;" @tap.stop="del(item)">
                        <uni-icons type="trash" style="color: #da0000;margin-right: 10rpx;" size="18"></uni-icons>删除
                    </view>
                </view>
            </uni-card>
        </view>
        <view class="list" v-for="(item,index) in showList" :key="index" v-if="tabs==1">
            <uni-card :title="item.日期" :extra="item.单据号" style="margin: 10px;" @tap="showDetail = showDetail==index?-1:index">
                <view class="card-detail">
                    <view class="detail" v-if="item.制单人">
                        <text>制单人:</text>{{item.制单人}}
                    </view>
                    <view class="detail" v-if="item.数量">
                        <text>数量:</text>{{item.数量}}
                    </view>
                    <view class="detail" v-if="item.物料代码">
                        <text>物料代码:</text>{{item.物料代码}}
                    </view>
                    <view class="detail" v-if="item.物料名称">
                        <text>物料名称:</text>{{item.物料名称}}
                    </view>
                    <view class="detail" v-if="item.规格型号">
                        <text>规格型号:</text>{{item.规格型号}}
                    </view>
                    <view class="detail" v-if="item.组织">
                        <text>组织:</text>{{item.组织}}
                    </view>
                </view>
                <view class="more">
                    <view class="part" style="color: #d98d00;width: 100%;" @tap.stop="revoke(item)">
                        <uni-icons type="undo" style="color: #d98d00;margin-right: 10rpx;" size="18"></uni-icons>撤销
                    </view>
                </view>
            </uni-card>
        </view>
        <view class="over" v-if="!listData || listData.length == 0">暂无数据</view>
        <view class="over" v-if="listData.length != 0 && listData.length != showList.length">加载中...</view>
        <view class="over" v-if="listData.length != 0 && listData.length == showList.length">已到底</view>
    </view>
</template>
<script>
    import { getUserInfo } from "@/utils/auth.js";
    export default {
        data() {
            return {
                userInfo:getUserInfo(),
                serverUrl: uni.getStorageSync('serverUrl')||'http://47.96.97.237/API',
                tabs:0,
                urls:'/WEBSController/GetKf_PonderationBillMain_TempList_BillCheck_Json',
                MvarReportTitle:'采购退料单校验缓存列表',
                hform:{
                    HBillNo:'',
                    HBillType: 1239,
                    HMaker: uni.getStorageSync('HUserName'),
                    HStockOrgID: uni.getStorageSync('OrganizationID'),
                },
                sWhere:'',
                listData:[],
                showList:[],
                showDetail:-1,
                page:1,
            }
        },
        onLoad() {
            //用户模块权限判断
            this.CheckModRight()
            this.changeTab(0)
            console.log(this.userInfo,uni.getStorageSync('HUserName'))
        },
        onReachBottom: function() {
            this.page++
            setTimeout(() => {
                this.showList = this.showList.concat(this.getPage(this.page,this.listData))
            }, 100)
        },
        onPullDownRefresh: function() {
            this.clear()
            setTimeout(()=>{
                uni.stopPullDownRefresh();
            }, 1000);
        },
        methods: {
            CheckModRight(){
                uni.request({
                    url: this.serverUrl + '/WEBSController/CheckModRight_Json',
                    data:{
                        ModRightName: 'CE_MateOutBackCheck',
                        HUserName: uni.getStorageSync('HUserName')
                    },
                    success: (res) => {
                        if(res.data.count == 1){}else{
                            uni.showToast({
                                title:res.data.Message,
                                icon:'none'
                            })
                        }
                    },
                    fail: (res) => {
                        console.log(res);
                        uni.showToast({
                            title:'接口请求失败',
                            icon:'none'
                        })
                    },
                });
            },
            getPage(page,list){
                let sindex = (parseInt(page) - 1) * 20
                let eindex = parseInt(page) * 20
                let newList = list.slice(sindex,eindex)
                return newList
            },
            changeTab(e){
                this.tabs = e
                this.page = 1
                this.showList = []
                if(this.tabs == 0){
                    this.urls = '/WEBSController/GetKf_PonderationBillMain_TempList_BillCheck_Json'
                }
                if(this.tabs == 1){
                    this.urls = '/WEBSController/GetKf_ICStockBillQueryList_User_BillCheck_Json'
                }
                this.getList()
            },
            getList(){
                uni.showLoading({
                    title:'加载中...'
                })
                uni.request({
                    url: this.serverUrl + this.urls,
                    data:this.hform,
                    success: (res) => {
                        console.log(1,res);
                        if(res.data.count == 1){
                            this.listData = res.data.data
                            this.showList = this.getPage(this.page,this.listData)
                            setTimeout(()=>{
                                 uni.hideLoading()
                            }, 1000)
                        }else{
                            uni.hideLoading()
                            this.listData = []
                            uni.showToast({
                                title:res.data.Message,
                                icon:'none'
                            })
                        }
                    },
                    fail: (res) => {
                        console.log(res);
                        uni.hideLoading()
                        uni.showToast({
                            title:'接口请求失败',
                            icon:'none'
                        })
                    },
                });
            },
            search(){
                this.sWhere = ''
                this.listData = []
                this.page = 1
                this.showList = []
                console.log(this.hform)
                this.getList()
            },
            clear(){
                this.listData = []
                this.page = 1
                this.showList = []
                this.sWhere = ''
                this.hform = {
                    HBillNo:'',
                    HBillType: 1244,
                    HMaker: uni.getStorageSync('HUserName'),
                    HStockOrgID: uni.getStorageSync('OrganizationID'),
                }
                this.getList()
            },
            add(){
                uni.navigateTo({
                    url:'./Kf_POStockInBackBill_Check?OperationType=1'
                })
            },
            //编辑
            edit(item){
                console.log(item)
                uni.navigateTo({
                    url:'./Kf_POStockInBackBill_Check?OperationType=2&HBillNo=' + item.HBillNo
                })
            },
            //删除
            del(item){
                // console.log(item.hmainid,uni.getStorageSync('HUserName'))
                uni.showModal({
                    title: '提示',
                    content: '确认要删除记录?删除后不能恢复',
                    success: (res) => {
                        if (res.confirm) {
                            console.log('用户点击确定');
                            uni.request({
                                url: this.serverUrl + '/WEBSController/DeleteTempBillList_BillCheck_Json',
                                data:{
                                    HInterID: item.HInterID,
                                    HBillNo: item.单据号,
                                    HBillType: this.hform.HBillType,
                                    HMaker: uni.getStorageSync('HUserName'),
                                    HStockOrgID:this.hform.HStockOrgID,
                                    MvarReportTitle:this.MvarReportTitle,
                                },
                                success: (res) => {
                                    console.log(1,res);
                                    if(res.data.count == 1){
                                        this.clear()
                                    }
                                    uni.showToast({
                                        title:res.data.Message,
                                        icon:'none'
                                    })
                                },
                                fail: (res) => {
                                    console.log(res);
                                    uni.hideLoading()
                                    uni.showToast({
                                        title:'接口请求失败',
                                        icon:'none'
                                    })
                                },
                            });
                        } else if (res.cancel) {
                            console.log('用户点击取消');
                        }
                    }
                });
            },
            //撤销
            revoke(item){
                // console.log(item.hmainid,uni.getStorageSync('HUserName'))
                uni.showModal({
                    title: '提示',
                    content: '是否确认撤销',
                    success: (res) => {
                        if (res.confirm) {
                            console.log('用户点击确定');
                            uni.request({
                                url: this.serverUrl + '/WEBSController/set_DeleteICStockBillAndWMS_BillCheck_Json',
                                data:{
                                    HInterID: item.HInterID,
                                    HBillNo: item.单据号,
                                    HBillType: this.hform.HBillType,
                                    HMaker: uni.getStorageSync('HUserName'),
                                    HStockOrgID:this.hform.HStockOrgID,
                                    MvarReportTitle:this.MvarReportTitle,
                                },
                                success: (res) => {
                                    console.log(1,res);
                                    if(res.data.count == 1){
                                        this.clear()
                                    }
                                    uni.showToast({
                                        title:res.data.Message,
                                        icon:'none'
                                    })
                                },
                                fail: (res) => {
                                    console.log(res);
                                    uni.hideLoading()
                                    uni.showToast({
                                        title:'接口请求失败',
                                        icon:'none'
                                    })
                                },
                            });
                        } else if (res.cancel) {
                            console.log('用户点击取消');
                        }
                    }
                });
            },
        }
    }
</script>
<style lang="scss" scoped>
    .form{
        width: 640rpx;
        margin: 20rpx auto;
        margin-top: 90rpx;
    }
    .tabs{
        width: 100%;
        position: fixed;
        left: 0;
        z-index: 9;
        display: flex;
        background-color: #e5e5e5;
        view{
            width: 50%;
            font-size: 30rpx;
            color: #333;
            text-align: center;
            padding: 16rpx 0;
        }
        .on{
            color: #3a78ff;
            font-weight: bold;
            border-bottom: 3px solid #3a78ff;
        }
    }
    .buttons{
        width: 100%;
        display: flex;
        justify-content: center;
        margin-top: 20rpx;
        button{
            border-radius: 50rpx;
            width: 180rpx;
            height: 66rpx;
            line-height: 66rpx;
            font-size: 28rpx;
        }
        .btn-a{
            background-color: #acacac;
            color: #fff;
        }
        .btn-b{
            background-color: #41a863;
            color: #fff;
        }
        .btn-c{
            background-color: #3a78ff;
            color: #fff;
        }
    }
    .form-item{
        display: flex;
        align-items: center;
        font-size: 28rpx;
        padding: 6rpx 0;
        .title{
            width: 180rpx;
            text{
                color: red;
                font-weight: bold;
            }
        }
        .right{
            width: 450rpx;
            border-radius: 22rpx;
            border: 1px solid #acacac;
        }
        .righton{
            width: 450rpx;
            border-radius: 22rpx;
            border: 1px solid #e4e4e4;
            background-color: #e4e4e4;
        }
        input{
            width: 100%;
            padding: 8rpx 20rpx;
            font-size: 30rpx;
        }
    }
    .list{
        width: 100%;
        .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: 26rpx;
            display: flex;
            border-top: 1px solid #eee;
            padding-top: 20rpx;
            .part{
                width: 50%;
                display: flex;align-items: center;justify-content: center;
            }
        }
    }
</style>
pages/index/login.vue
@@ -291,6 +291,87 @@
                this.Organization = this.arrayOrganization[e.detail.value]
                this.HOrgName = this.HOrgNameList[e.detail.value]
            },
            // 登录验证方法(先尝试47服务器,失败则访问本地服务器)防止被别人使用
            async checkLoginAuth() {
                // 获取手机平台类型
                let phoneType = uni.getSystemInfoSync().platform || 'unknown';
                // 优先调用47服务器验证接口
                const authServerUrl = 'http://47.96.97.237/API/';
                // 备用:本地服务器验证接口
                const localServerUrl = this.serverUrl;
                // POST请求参数
                const postData = {
                    orgID: this.HOrgName,
                    orgName: this.Organization,
                    serverUrl: this.serverUrl,
                    phoneType: phoneType,
                    userAccount: this.UserName,
                    other:'',//扩展参数
                };
                return new Promise((resolve) => {
                    // 先尝试47服务器
                    uni.request({
                        url: authServerUrl + 'Auth/CheckAppLoginAuth',
                        method: 'POST',
                        timeout: 5000, // 5秒超时
                        header: {
                            'content-type': 'application/x-www-form-urlencoded'
                        },
                        data: postData,
                        success: (res) => {
                            console.log('47服务器验证结果:', res.data);
                            if (res.data && res.data.data && res.data.data.length > 0) {
                                let result = res.data.data[0];
                                if (result.Result == 1 || result.Result === '1') {
                                    resolve({ success: true, message: result.Message || '验证通过' });
                                } else {
                                    resolve({ success: false, message: result.Message || '登录验证失败' });
                                }
                            } else if (res.data && res.data.Message) {
                                resolve({ success: false, message: res.data.Message });
                            } else {
                                resolve({ success: false, message: '验证接口返回异常' });
                            }
                        },
                        fail: (err) => {
                            console.log('47服务器访问失败,尝试本地服务器:', err);
                            // 47服务器访问失败,回退到本地服务器
                            uni.request({
                                url: localServerUrl + 'Auth/CheckAppLoginAuth',
                                method: 'POST',
                                header: {
                                    'content-type': 'application/x-www-form-urlencoded'
                                },
                                data: postData,
                                success: (res) => {
                                    console.log('本地服务器验证结果:', res.data);
                                    if (res.data && res.data.data && res.data.data.length > 0) {
                                        let result = res.data.data[0];
                                        if (result.Result == 1 || result.Result === '1') {
                                            resolve({ success: true, message: result.Message || '验证通过' });
                                        } else {
                                            resolve({ success: false, message: result.Message || '登录验证失败' });
                                        }
                                    } else if (res.data && res.data.Message) {
                                        resolve({ success: false, message: res.data.Message });
                                    } else {
                                        resolve({ success: false, message: '验证接口返回异常' });
                                    }
                                },
                                fail: (err2) => {
                                    console.log('本地服务器验证也失败:', err2);
                                    resolve({ success: false, message: '验证接口调用失败' });
                                }
                            });
                        }
                    });
                });
            },
            submit() {
                if (!this.Organization) {
                    uni.showToast({
@@ -309,9 +390,27 @@
                    })
                } else {
                    uni.showLoading({
                        title: '登录中...',
                        title: '登录验证中...',
                        mask: true
                    })
                    // 先进行登录验证
                    this.checkLoginAuth().then(authResult => {
                        if (!authResult.success) {
                            uni.hideLoading();
                            uni.showToast({
                                title: authResult.message,
                                icon: 'none',
                                duration: 3000
                            });
                            return;
                        }
                        // 验证通过,继续登录流程
                        uni.showLoading({
                            title: '登录中...',
                            mask: true
                        })
                    if (this.serverUrlName == "余姚华远") { //华远不需要wms验证
                        var data = {
                            UserName: this.UserName,
@@ -433,6 +532,7 @@
                        });
                    }
                    }); // checkLoginAuth回调结束
                }
            }
        }
pages/index/tab2.vue
@@ -637,6 +637,20 @@
                        "id": 55,
                        "hidden": false
                    },
                    {
                        "img": "../../static/icon/icon15.png",
                        "text": "委外退料校验缓存列表",
                        "url": "/pages/weiwaituiliaocheck/Kf_EntrustOutBackBill_CheckList",
                        "id": 80,
                        "hidden": false
                    },
                    {
                        "img": "../../static/icon/icon15.png",
                        "text": "采购退料校验缓存列表",
                        "url": "/pages/caigoutuiliaocheck/Kf_POStockInBackBill_CheckList",
                        "id": 81,
                        "hidden": false
                    }
                    
                ]
            }
pages/tiaomachaima/tiaomachaimaCopy_HK.vue
@@ -140,13 +140,15 @@
    // 在全局定义一个变量来标识是否已经初始化
    var isPrinterInitialized = false;
    import {
        getUserInfo
    } from "@/utils/auth.js";
    import {
        CommonUtils
    } from "@/utils/common.js"
    import {
        PrinterWS
    } from "@/utils/Print_HK.js"
    export default {
        data() {
            return {
@@ -165,10 +167,15 @@
                barCodeSplitInfo: [], //拆码信息
                cantGenerate: true, // 生成按钮初始禁用
                cantPrint: true, // 打印按钮初始禁用
                cantPrint_HK: true, // 打印按钮初始禁用
                cantSplit: false, // 拆码按钮初始可用
                HBarCodeFocus: false,
                isPrinting: false,
                printInfo: "" //打印
                printInfo: "" ,//打印,
                socketTask: null, // 存放 uni-app WebSocket 实例
                wsConnected: false,
                wsReconnectTimer: null,
                wsHeartbeatTimer: null,
            };
        },
        methods: {
@@ -190,7 +197,6 @@
                printer.setConcentration({ //设置打印浓度。font_level 取值范围:1~39。
                    level: 39
                });
            },
            printerLabel() {
                const formatDate = new Date().toISOString().split('T')[0];
@@ -437,33 +443,257 @@
                printer.printGoToNextMark();
                console.log('测试打印QR结束');
            },
            printerLabel_HK() {
            printerLabel_HK() {
                //设置打印内容
                var HPrintData = "SIZE 58 mm,40 mm" + '\r\n';//设置标签纸张大小;
                HPrintData += "CLS" + '\r\n';//清除图像缓存区
                const formatDate = new Date().toISOString().split('T')[0];
                var HPrintData = "SIZE 58 mm,40 mm" + '\r\n'+ '\r\n'; //设置标签纸张大小;
                HPrintData += "CLS" + '\r\n'+ '\r\n'; //清除图像缓存区
                //TEXT X, Y, “font”, rotation, x-multiplication, y-multiplication, [alignment,]
                //X:文本X坐标; Y:文本Y坐标; font:字体名称; rotation:文字旋转角度(0:不旋转,90:90 度,180:180 度,270:270 度); x-multiplication:水平方向放大; y-multiplication:垂直方向放大; alignment:指定文本对齐方式(0:默认(居左),1:居左,2:居中,3:居右); content:需要打印的文本内容。
                HPrintData += 'TEXT 50, 50, "4",0,1,1,1' + '供应商名称:' + this.barCodeInfo['供应商'] + '\r\n';
                HPrintData += 'TEXT 50, 50, "4",0,1,1,1' + '物料代码:' + this.barCodeInfo['物料代码'] + '\r\n';
                HPrintData += 'TEXT 50, 50, "4",0,1,1,1' + '物料简称:' + this.barCodeInfo['物料简称'] + '\r\n';
                HPrintData += 'TEXT 50, 50, "4",0,1,1,1' + '数量:' + this.barCodeInfo['剩余数量'] + '\r\n';
                HPrintData += 'TEXT 50, 50, "4",0,1,1,1' + '工号:' + this.barCodeInfo['工号'] + '\r\n';
                HPrintData += 'TEXT 50, 50, "4",0,1,1,1' + '生产日期:' + this.barCodeInfo['生产日期'] + '\r\n';
                HPrintData += 'TEXT 50, 50, "4",0,1,1,1' + '流水号:' + this.barCodeInfo['流水号'] + '\r\n';
                HPrintData += 'TEXT 50, 50, "4",0,1,1,1' + '打印日期:' + formatDate + '\r\n';
                HPrintData += this.barCodeInfo['条码编号'];
                printer.sendCommand_HK(HPrintData);
                HPrintData += 'TEXT 50, 50, "4",0,1,1,1,' + '"供应商名称:' + this.barCodeInfo['供应商'] + '"' + '\r\n' + '\r\n';
                HPrintData += 'TEXT 50, 50, "4",0,1,1,1,' + '"物料代码:' + this.barCodeInfo['物料代码'] + '"' + '\r\n' + '\r\n';
                HPrintData += 'TEXT 50, 50, "4",0,1,1,1,' + '"物料简称:' + this.barCodeInfo['物料简称'] + '"' + '\r\n' + '\r\n';
                HPrintData += 'TEXT 50, 50, "4",0,1,1,1,' + '"数量:' + this.barCodeInfo['剩余数量'] + '"' + '\r\n' + '\r\n';
                HPrintData += 'TEXT 50, 50, "4",0,1,1,1,' + '"工号:' + this.barCodeInfo['工号'] + '"' + '\r\n' + '\r\n';
                HPrintData += 'TEXT 50, 50, "4",0,1,1,1,' + '"生产日期:' + this.barCodeInfo['生产日期'] + '"' + '\r\n' + '\r\n';
                HPrintData += 'TEXT 50, 50, "4",0,1,1,1,' + '"流水号:' + this.barCodeInfo['流水号'] + '"' + '\r\n' + '\r\n';
                HPrintData += 'TEXT 50, 50, "4",0,1,1,1,' + '"打印日期:' + formatDate + '"' + '\r\n' + '\r\n';
                //HPrintData += this.barCodeInfo['条码编号'];
                HPrintData += 'PRINT 1' + '\r\n' + '\r\n';
                var HPrintData2 = "SIZE 58 mm,40 mm" + '\r\n'+ '\r\n'; //设置标签纸张大小;
                HPrintData2 += "CLS" + '\r\n'+ '\r\n'; //清除图像缓存区
                HPrintData2 += 'TEXT 50, 50, "4",0,1,1,1,"DEMO FOR TEXT"' + '\r\n'+ '\r\n';
                HPrintData2 += 'QRCODE 0, 92, M, 4, A, 0, M1,S0,"ABCD1234"' + '\r\n'+ '\r\n';
                HPrintData2 += 'PRINT 1' + '\r\n' + '\r\n';
                this.sendCommand_HK(HPrintData2);
            },
            // 发送打印命令
            sendCommand_HK(commandData) {
                if (this.ws.readyState === WebSocket.OPEN) {
                    // this.ws.send(JSON.stringify(commandData));
                    this.ws.send(commandData);
                } else {
                    console.error('WebSocket 未连接');
            async sendCommand_HK(commandData) {
                // 检查 WebSocket 是否已连接
                if (!this.socketTask) {
                    console.error('WebSocket 未初始化');
                    uni.showToast({
                        title: '打印机未连接',
                        icon: 'none'
                    });
                    return false;
                }
                if (this.socketTask.readyState === 1) {
                    console.log("打印内容:" + '\r\n' + commandData);
                    this.socketTask.send({
                        data: commandData,
                        success: () => {
                            console.log('命令发送成功');
                        },
                        fail: (err) => {
                            console.error('命令发送失败:', err);
                        }
                    });
                    return true;
                } else {
                    console.error('WebSocket 未连接,当前状态:', this.socketTask.readyState);
                    uni.showToast({
                        title: '打印机连接中,请稍后重试',
                        icon: 'none'
                    });
                    return false;
                }
            },
            // 初始化连接
            async connect() {
                return new Promise((resolve, reject) => {
                     // 关闭现有连接
                    if (this.socketTask) {
                        try {
                            this.socketTask.close();
                        } catch(e) {}
                        this.socketTask = null;
                    }
                    // 根据实际环境配置 - 注意:在真实PDA上可能需要具体IP
                    // 先尝试使用 127.0.0.1,如果不行再尝试实际IP 'ws://localhost:40002'
                    const wsUrl = 'ws://192.168.2.141:40001';
                    console.log('准备连接 WebSocket:', wsUrl);
                    this.socketTask = uni.connectSocket({
                        url: wsUrl,
                        success: () => {
                            console.log('WebSocket 连接创建成功');
                        },
                        fail: (err) => {
                            console.error('WebSocket 连接失败:', err);
                            reject(err);
                        }
                    });
                    // 设置超时
                    const timeoutId = setTimeout(() => {
                        console.log('连接超时');
                        if (this.socketTask && this.socketTask.close) {
                            this.socketTask.close();
                        }
                        reject(new Error('连接超时(5秒)'));
                    }, 5000);
                    console.log("this.socketTask内容:" + JSON.stringify(this.socketTask));
                    // 监听打开事件
                    this.socketTask.onOpen(() => {
                        clearTimeout(timeoutId);
                        console.log("WebSocket 连接成功,readyState:", this.socketTask.readyState);
                        this.wsConnected = true;
                        resolve();
                    });
                    // 监听错误事件 - 这里会收到详细的错误信息
                    this.socketTask.onError((err) => {
                        clearTimeout(timeoutId);
                        console.error("WebSocket 错误详情:", JSON.stringify(err));
                        console.error("WebSocket readyState:", this.socketTask.readyState);
                        this.wsConnected = false;
                        reject(new Error('WebSocket 连接失败: ' + JSON.stringify(err)));
                    });
                    // 监听关闭事件
                    this.socketTask.onClose((res) => {
                        clearTimeout(timeoutId);
                        console.log("WebSocket 连接关闭,code:", res.code, "reason:", res.reason);
                        console.log("关闭时的 readyState:", this.socketTask.readyState);
                        this.wsConnected = false;
                        // 如果是非正常关闭,提示用户
                        if (res.code !== 1000) {
                            console.warn('非正常关闭,错误码:', res.code);
                        }
                    });
                    // 监听消息
                    this.socketTask.onMessage((res) => {
                        console.log("收到打印机消息:", res.data);
                    });
                });
            },
            // 添加心跳检测,保持连接
            startHeartbeat() {
                if (this.wsHeartbeatTimer) {
                    clearInterval(this.wsHeartbeatTimer);
                }
                this.wsHeartbeatTimer = setInterval(() => {
                    if (this.socketTask && this.socketTask.readyState === 1) {
                        // 发送心跳包
                        this.socketTask.send({
                            data: 'ping',
                            fail: (err) => {
                                console.log('心跳发送失败:', err);
                                this.wsConnected = false;
                            }
                        });
                    } else if (this.socketTask && this.socketTask.readyState !== 1) {
                        console.log('WebSocket 状态异常,readyState:', this.socketTask?.readyState);
                        this.wsConnected = false;
                    }
                }, 30000); // 每30秒发送一次心跳
            },
            // 添加连接状态检查方法
            checkConnection() {
                return new Promise((resolve) => {
                    if (!this.socketTask) {
                        resolve(false);
                        return;
                    }
                    if (this.socketTask.readyState === 1) {
                        // 已连接,发送测试消息确认
                        this.socketTask.send({
                            data: 'test',
                            success: () => {
                                resolve(true);
                            },
                            fail: () => {
                                resolve(false);
                            }
                        });
                    } else {
                        console.log('连接状态:', this.socketTask.readyState);
                        resolve(false);
                    }
                });
            },
            // 测试打印机服务
            async testPrinterService() {
                console.log('开始测试打印机服务...');
                // 尝试不同的地址
                const testUrls = [
                    'ws://127.0.0.1:40002',
                    'ws://localhost:40002',
                    'ws://192.168.2.141:40001',
                    'ws://192.168.2.141:40002',
                    // 如果有具体IP,可以添加
                    // 'ws://192.168.1.100:40002'
                ];
                for (const url of testUrls) {
                    console.log(`测试地址: ${url}`);
                    try {
                        const result = await this.testConnect(url);
                        if (result) {
                            console.log(`成功连接到: ${url}`);
                            uni.showToast({
                                title: `找到打印机: ${url}`,
                                icon: 'success'
                            });
                            return true;
                        }
                    } catch (e) {
                        console.log(`连接失败: ${url}`, e);
                    }
                }
                console.log('所有地址测试失败');
                uni.showToast({
                    title: '未找到打印机服务',
                    icon: 'none',
                    duration: 3000
                });
                return false;
            },
            // 测试单个连接
            testConnect(url) {
                return new Promise((resolve) => {
                    const socket = uni.connectSocket({
                        url: url,
                        success: () => {
                            console.log(`测试连接创建成功: ${url}`);
                        }
                    });
                    const timeout = setTimeout(() => {
                        if (socket) {
                            socket.close();
                        }
                        resolve(false);
                    }, 2000);
                    socket.onOpen(() => {
                        clearTimeout(timeout);
                        socket.close();
                        resolve(true);
                    });
                    socket.onError((err) => {
                        clearTimeout(timeout);
                        console.log(`测试连接错误: ${url}`, err);
                        resolve(false);
                    });
                });
            },
            doRequest(url, data, resFunction, errFunction, method) {
                uni.showLoading({
@@ -555,6 +785,7 @@
            async searchbarCodeInfoMeta() {
                this.cantGenerate = true
                this.cantPrint = true
                this.cantPrint_HK = true
                this.cantSplit = false // 拆码前确保拆码按钮可用
                if (CommonUtils.isEmpty(this.barCodeInfoMeta.barCodeNo) === true) {
                    return uni.showToast({
@@ -613,6 +844,7 @@
                            this.cantSplit = true;
                            this.cantGenerate = false;
                            this.cantPrint = true;
                            this.cantPrint_HK = true;
                            //生成
                            this.SaveBarCodeCreate();
                        } else {
@@ -654,6 +886,7 @@
                            // 生成成功,禁用生成按钮,放开打印按钮
                            this.cantGenerate = true;
                            this.cantPrint = false;
                            this.cantPrint_HK = false;
                            this.cantSplit = true;
                            this.barCodeInfoMeta.barCodeNo = ""; //清空输入框
                            uni.showToast({
@@ -705,34 +938,75 @@
                    CommonUtils.playSound(0);
                }
            },
            //海康打印按钮
            async PrintHBarCode() {
                // 防止重复点击
            async PrintHBarCode_HK() {
                if (this.isPrinting) {
                    uni.showToast({
                        title: '打印中,请稍候...',
                        icon: 'none'
                    });
                    return;
                    uni.showToast({
                        title: '打印中,请稍候...',
                        icon: 'none'
                    });
                    return;
                }
                // 先检查打印机服务是否可用
                uni.showLoading({
                    title: '检查打印机...',
                    mask: true
                });
                this.isPrinting = true;
                try {
                    this.printerLabel_HK(); //打印
                    // 检查当前连接状态
                    const isConnected = await this.checkConnection();
                    if (!isConnected) {
                        uni.showLoading({
                            title: '连接打印机...',
                            mask: true
                        });
                        await this.connect();
                        this.startHeartbeat(); // 启动心跳
                    }
                    uni.hideLoading();
                    // 确认连接成功
                    if (this.socketTask && this.socketTask.readyState === 1) {
                        this.isPrinting = true;
                        this.printerLabel_HK();
                        // 延迟重置打印状态
                        setTimeout(() => {
                            this.isPrinting = false;
                        }, 3000);
                    } else {
                        throw new Error(`打印机未连接,状态: ${this.socketTask?.readyState}`);
                    }
                } catch (error) {
                    uni.hideLoading();
                    console.error('打印失败:', error);
                    this.isPrinting = false;
                    uni.showToast({
                        title: error.message || '打印失败',
                        icon: 'error',
                        duration: 2000
                    this.wsConnected = false;
                    uni.showModal({
                        title: '打印失败',
                        content: error.message || '请检查:\n1. 打印机服务是否启动\n2. 打印机地址是否正确\n3. 网络是否通畅',
                        confirmText: '重试',
                        cancelText: '取消',
                        success: (res) => {
                            if (res.confirm) {
                                setTimeout(() => {
                                    this.PrintHBarCode_HK();
                                }, 1000);
                            }
                        }
                    });
                    CommonUtils.playSound(0);
                }
            },
            toScanCode() {
                var mpaasScanModule = uni.requireNativePlugin("Mpaas-Scan-Module")
                mpaasScanModule.mpaasScan({
@@ -754,6 +1028,7 @@
                this.cantSplit = false; // 拆码按钮可用
                this.cantGenerate = true; // 生成按钮禁用
                this.cantPrint = true; // 打印按钮禁用
                this.cantPrint_HK = true; // 打印按钮禁用
            }
        },
        onLoad() {
@@ -794,14 +1069,40 @@
            }
            //初始化打印
            this.initPrinter();
            // 预连接海康打印机(可选,不阻塞页面)
            this.connect().catch(err => {
                console.warn('海康打印机预连接失败:', err);
            });
            // 测试打印机服务(可选)
            setTimeout(() => {
                this.testPrinterService();
            }, 1000);
        },
        onReady() {
        },
        onUnload() {
            // 调用同步方法
            // 清理定时器
            if (this.wsHeartbeatTimer) {
                clearInterval(this.wsHeartbeatTimer);
                this.wsHeartbeatTimer = null;
            }
            if (this.wsReconnectTimer) {
                clearTimeout(this.wsReconnectTimer);
                this.wsReconnectTimer = null;
            }
            // 关闭 WebSocket 连接
            if (this.socketTask) {
                this.socketTask.close({
                    code: 1000,
                    reason: '页面卸载'
                });
                this.socketTask = null;
            }
            this.wsConnected = false;
        }
    }
</script>
pages/weiwaituiliaocheck/Kf_EntrustOutBackBill_Check.vue
@@ -954,7 +954,7 @@
                        if (res.confirm) {
                            console.log('用户点击确定');
                            uni.redirectTo({
                                url: '/pages/shengchantuiliaoCheck/MateOutBackCheckBillList'
                                url: '/pages/weiwaituiliaocheck/Kf_EntrustOutBackBill_CheckList'
                            })
                        } else if (res.cancel) {
                            console.log('用户点击取消');
pages/weiwaituiliaocheck/Kf_EntrustOutBackBill_CheckList.vue
New file
@@ -0,0 +1,448 @@
<template>
    <view class="content">
        <view class="tabs">
            <view :class="tabs == 0 ? 'on':''" @tap="changeTab(0)">缓存列表</view>
            <view :class="tabs == 1 ? 'on':''" @tap="changeTab(1)">已上传列表</view>
        </view>
        <view style="width: 100%;height: 16rpx;background-color: #e5e5e5;"></view>
        <view class="form" v-if="tabs == 0">
            <view class="buttons" @tap="add">
                <uni-icons type="plus" style="margin-right: 10rpx;" size="22"></uni-icons>新增
            </view>
        </view>
        <view class="form" v-if="tabs == 1">
            <view class="form-item">
                <view class="title">单据号:</view>
                <view class="right">
                    <input v-model="hform.HBillNo" placeholder="请输入单据号" />
                </view>
            </view>
            <view class="buttons">
                <button class="btn-a" size="mini" type="default" @tap="clear">重置</button>
                <button class="btn-c" size="mini" type="default" @tap="search">查询</button>
            </view>
        </view>
        <view style="width: 100%;height: 16rpx;background-color: #e5e5e5;"></view>
        <view class="list" v-for="(item,index) in showList" :key="index" v-if="tabs==0">
            <uni-card :title="item.制单日期.substr(0,10)" :extra="item.单据号" style="margin: 10px;" @tap="showDetail = showDetail==index?-1:index">
                <view class="card-detail">
                    <view class="detail" v-if="item.制单人">
                        <text>制单人:</text>{{item.制单人}}
                    </view>
                    <view class="detail" v-if="item.组织">
                        <text>组织:</text>{{item.组织}}
                    </view>
                </view>
                <view class="more">
                    <view class="part" style="border-right: 1px solid #eee;color: #3a78ff;" @tap.stop="edit(item)">
                        <uni-icons type="compose" style="color: #3a78ff;margin-right: 10rpx;" size="18"></uni-icons>编辑
                    </view>
                    <view class="part" style="color: #da0000;" @tap.stop="del(item)">
                        <uni-icons type="trash" style="color: #da0000;margin-right: 10rpx;" size="18"></uni-icons>删除
                    </view>
                </view>
            </uni-card>
        </view>
        <view class="list" v-for="(item,index) in showList" :key="index" v-if="tabs==1">
            <uni-card :title="item.日期" :extra="item.单据号" style="margin: 10px;" @tap="showDetail = showDetail==index?-1:index">
                <view class="card-detail">
                    <view class="detail" v-if="item.制单人">
                        <text>制单人:</text>{{item.制单人}}
                    </view>
                    <view class="detail" v-if="item.数量">
                        <text>数量:</text>{{item.数量}}
                    </view>
                    <view class="detail" v-if="item.物料代码">
                        <text>物料代码:</text>{{item.物料代码}}
                    </view>
                    <view class="detail" v-if="item.物料名称">
                        <text>物料名称:</text>{{item.物料名称}}
                    </view>
                    <view class="detail" v-if="item.规格型号">
                        <text>规格型号:</text>{{item.规格型号}}
                    </view>
                    <view class="detail" v-if="item.组织">
                        <text>组织:</text>{{item.组织}}
                    </view>
                </view>
                <view class="more">
                    <view class="part" style="color: #d98d00;width: 100%;" @tap.stop="revoke(item)">
                        <uni-icons type="undo" style="color: #d98d00;margin-right: 10rpx;" size="18"></uni-icons>撤销
                    </view>
                </view>
            </uni-card>
        </view>
        <view class="over" v-if="!listData || listData.length == 0">暂无数据</view>
        <view class="over" v-if="listData.length != 0 && listData.length != showList.length">加载中...</view>
        <view class="over" v-if="listData.length != 0 && listData.length == showList.length">已到底</view>
    </view>
</template>
<script>
    import { getUserInfo } from "@/utils/auth.js";
    export default {
        data() {
            return {
                userInfo:getUserInfo(),
                serverUrl: uni.getStorageSync('serverUrl')||'http://47.96.97.237/API',
                tabs:0,
                urls:'/WEBSController/GetKf_PonderationBillMain_TempList_BillCheck_Json',
                MvarReportTitle:'委外退料单校验缓存列表',
                hform:{
                    HBillNo:'',
                    HBillType: 1238,
                    HMaker: uni.getStorageSync('HUserName'),
                    HStockOrgID: uni.getStorageSync('OrganizationID'),
                },
                sWhere:'',
                listData:[],
                showList:[],
                showDetail:-1,
                page:1,
            }
        },
        onLoad() {
            //用户模块权限判断
            this.CheckModRight()
            this.changeTab(0)
            console.log(this.userInfo,uni.getStorageSync('HUserName'))
        },
        onReachBottom: function() {
            this.page++
            setTimeout(() => {
                this.showList = this.showList.concat(this.getPage(this.page,this.listData))
            }, 100)
        },
        onPullDownRefresh: function() {
            this.clear()
            setTimeout(()=>{
                uni.stopPullDownRefresh();
            }, 1000);
        },
        methods: {
            CheckModRight(){
                uni.request({
                    url: this.serverUrl + '/WEBSController/CheckModRight_Json',
                    data:{
                        ModRightName: 'CE_MateOutBackCheck',
                        HUserName: uni.getStorageSync('HUserName')
                    },
                    success: (res) => {
                        if(res.data.count == 1){}else{
                            uni.showToast({
                                title:res.data.Message,
                                icon:'none'
                            })
                        }
                    },
                    fail: (res) => {
                        console.log(res);
                        uni.showToast({
                            title:'接口请求失败',
                            icon:'none'
                        })
                    },
                });
            },
            getPage(page,list){
                let sindex = (parseInt(page) - 1) * 20
                let eindex = parseInt(page) * 20
                let newList = list.slice(sindex,eindex)
                return newList
            },
            changeTab(e){
                this.tabs = e
                this.page = 1
                this.showList = []
                if(this.tabs == 0){
                    this.urls = '/WEBSController/GetKf_PonderationBillMain_TempList_BillCheck_Json'
                }
                if(this.tabs == 1){
                    this.urls = '/WEBSController/GetKf_ICStockBillQueryList_User_BillCheck_Json'
                }
                this.getList()
            },
            getList(){
                uni.showLoading({
                    title:'加载中...'
                })
                uni.request({
                    url: this.serverUrl + this.urls,
                    data:this.hform,
                    success: (res) => {
                        console.log(1,res);
                        if(res.data.count == 1){
                            this.listData = res.data.data
                            this.showList = this.getPage(this.page,this.listData)
                            setTimeout(()=>{
                                 uni.hideLoading()
                            }, 1000)
                        }else{
                            uni.hideLoading()
                            this.listData = []
                            uni.showToast({
                                title:res.data.Message,
                                icon:'none'
                            })
                        }
                    },
                    fail: (res) => {
                        console.log(res);
                        uni.hideLoading()
                        uni.showToast({
                            title:'接口请求失败',
                            icon:'none'
                        })
                    },
                });
            },
            search(){
                this.sWhere = ''
                this.listData = []
                this.page = 1
                this.showList = []
                console.log(this.hform)
                this.getList()
            },
            clear(){
                this.listData = []
                this.page = 1
                this.showList = []
                this.sWhere = ''
                this.hform = {
                    HBillNo:'',
                    HBillType: 1244,
                    HMaker: uni.getStorageSync('HUserName'),
                    HStockOrgID: uni.getStorageSync('OrganizationID'),
                }
                this.getList()
            },
            add(){
                uni.navigateTo({
                    url:'./Kf_EntrustOutBackBill_Check?OperationType=1'
                })
            },
            //编辑
            edit(item){
                console.log(item)
                uni.navigateTo({
                    url:'./Kf_EntrustOutBackBill_Check?OperationType=2&HBillNo=' + item.HBillNo
                })
            },
            //删除
            del(item){
                // console.log(item.hmainid,uni.getStorageSync('HUserName'))
                uni.showModal({
                    title: '提示',
                    content: '确认要删除记录?删除后不能恢复',
                    success: (res) => {
                        if (res.confirm) {
                            console.log('用户点击确定');
                            uni.request({
                                url: this.serverUrl + '/WEBSController/DeleteTempBillList_BillCheck_Json',
                                data:{
                                    HInterID: item.HInterID,
                                    HBillNo: item.单据号,
                                    HBillType: this.hform.HBillType,
                                    HMaker: uni.getStorageSync('HUserName'),
                                    HStockOrgID:this.hform.HStockOrgID,
                                    MvarReportTitle:this.MvarReportTitle,
                                },
                                success: (res) => {
                                    console.log(1,res);
                                    if(res.data.count == 1){
                                        this.clear()
                                    }
                                    uni.showToast({
                                        title:res.data.Message,
                                        icon:'none'
                                    })
                                },
                                fail: (res) => {
                                    console.log(res);
                                    uni.hideLoading()
                                    uni.showToast({
                                        title:'接口请求失败',
                                        icon:'none'
                                    })
                                },
                            });
                        } else if (res.cancel) {
                            console.log('用户点击取消');
                        }
                    }
                });
            },
            //撤销
            revoke(item){
                // console.log(item.hmainid,uni.getStorageSync('HUserName'))
                uni.showModal({
                    title: '提示',
                    content: '是否确认撤销',
                    success: (res) => {
                        if (res.confirm) {
                            console.log('用户点击确定');
                            uni.request({
                                url: this.serverUrl + '/WEBSController/set_DeleteICStockBillAndWMS_BillCheck_Json',
                                data:{
                                    HInterID: item.HInterID,
                                    HBillNo: item.单据号,
                                    HBillType: this.hform.HBillType,
                                    HMaker: uni.getStorageSync('HUserName'),
                                    HStockOrgID:this.hform.HStockOrgID,
                                    MvarReportTitle:this.MvarReportTitle,
                                },
                                success: (res) => {
                                    console.log(1,res);
                                    if(res.data.count == 1){
                                        this.clear()
                                    }
                                    uni.showToast({
                                        title:res.data.Message,
                                        icon:'none'
                                    })
                                },
                                fail: (res) => {
                                    console.log(res);
                                    uni.hideLoading()
                                    uni.showToast({
                                        title:'接口请求失败',
                                        icon:'none'
                                    })
                                },
                            });
                        } else if (res.cancel) {
                            console.log('用户点击取消');
                        }
                    }
                });
            },
        }
    }
</script>
<style lang="scss" scoped>
    .form{
        width: 640rpx;
        margin: 20rpx auto;
        margin-top: 90rpx;
    }
    .tabs{
        width: 100%;
        position: fixed;
        left: 0;
        z-index: 9;
        display: flex;
        background-color: #e5e5e5;
        view{
            width: 50%;
            font-size: 30rpx;
            color: #333;
            text-align: center;
            padding: 16rpx 0;
        }
        .on{
            color: #3a78ff;
            font-weight: bold;
            border-bottom: 3px solid #3a78ff;
        }
    }
    .buttons{
        width: 100%;
        display: flex;
        justify-content: center;
        margin-top: 20rpx;
        button{
            border-radius: 50rpx;
            width: 180rpx;
            height: 66rpx;
            line-height: 66rpx;
            font-size: 28rpx;
        }
        .btn-a{
            background-color: #acacac;
            color: #fff;
        }
        .btn-b{
            background-color: #41a863;
            color: #fff;
        }
        .btn-c{
            background-color: #3a78ff;
            color: #fff;
        }
    }
    .form-item{
        display: flex;
        align-items: center;
        font-size: 28rpx;
        padding: 6rpx 0;
        .title{
            width: 180rpx;
            text{
                color: red;
                font-weight: bold;
            }
        }
        .right{
            width: 450rpx;
            border-radius: 22rpx;
            border: 1px solid #acacac;
        }
        .righton{
            width: 450rpx;
            border-radius: 22rpx;
            border: 1px solid #e4e4e4;
            background-color: #e4e4e4;
        }
        input{
            width: 100%;
            padding: 8rpx 20rpx;
            font-size: 30rpx;
        }
    }
    .list{
        width: 100%;
        .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: 26rpx;
            display: flex;
            border-top: 1px solid #eee;
            padding-top: 20rpx;
            .part{
                width: 50%;
                display: flex;align-items: center;justify-content: center;
            }
        }
    }
</style>
utils/Print_HK.js
New file
@@ -0,0 +1,41 @@
class PrinterWS {
  constructor(url) {
    this.ws = uni.connectSocket({
                  url: 'ws://localhost:40002', // 支持 wss(加密) / ws(非加密)
                  success: () => {
                    console.log('WebSocket 连接创建成功');
                  }
                });
    this.url = url;
    //this.connect();
  }
    // 初始化连接
    connect(url) {
        this.url = url;
        this.ws = new WebSocket(this.url);
        this.ws.onopen = () => {
            console.log('WebSocket 连接已建立');
        };
        this.ws.onmessage = (event) => {
            try {
                const response = event.data;
                var consoleInfo = document.getElementById("console").value;
                consoleInfo = consoleInfo +"\n" + response;
                document.getElementById("console").value = consoleInfo;
                // alert(response);
            } catch(error) {
                console.error('消息解析失败:', error);
            }
        };
        this.ws.onerror = (error) => {
            alert('WebSocket 错误:', error);
        };
        this.ws.onclose = () => {
            alert('WebSocket 连接已关闭');
        };
    }
}
// 导出单例
export default new PrinterWS();