llj
2025-11-10 c6be1567e2613ce0fe1262375ac7e3e49aa5964a
app装箱拆箱,小卫组托
4个文件已修改
3个文件已添加
2327 ■■■■■ 已修改文件
pages.json 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/chaixiang/form.vue 632 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/fenbushidiaochudan/table_out.vue 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/index/index.vue 20 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/index/login.vue 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/zhuangxiang/form_mix.vue 729 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/zutuo_xiaowei/form_xiaowei.vue 920 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages.json
@@ -1221,6 +1221,24 @@
            "style": {
                "navigationBarTitleText": "模具故障登记单"
            }
        },
        {
            "path": "pages/chaixiang/form",
            "style": {
                "navigationBarTitleText": "拆箱"
            }
        },
        {
            "path": "pages/zhuangxiang/form_mix",
            "style": {
                "navigationBarTitleText": "装箱"
            }
        },
        {
            "path": "pages/zutuo_xiaowei/form_xiaowei",
            "style": {
                "navigationBarTitleText": "组托-小卫"
            }
        }
    ],
    "tabBar": {
pages/chaixiang/form.vue
New file
@@ -0,0 +1,632 @@
<template>
    <view class="form">
        <view class="form-base-info">
            <view class="form-item">
                <view class="title">箱条码</view>
                <view class="right">
                    <input type="text" :focus="HBarCodePackFocus" v-model="HBarCode_Pack" @confirm="GetMeesageByBarCode_Pack(HBarCode_Pack)" />
                </view>
                <view class="right-icon">
                    <uni-icons class="right-icon" type="scan"
                        style="background-color: #3A78FF;padding: 6rpx;color: #fff;border-radius: 100%;" size="20"
                        @click="toScanCode"></uni-icons>
                </view>
            </view>
        </view>
        <view class="tabs">
            <view :class="tabs == 0 ? 'on':''" @tap="tabs = 0">装箱信息</view>
            <view :class="tabs == 1 ? 'on':''" @tap="tabs = 1">单据信息</view>
        </view>
        <!-- 拆箱信息 -->
        <view v-if="tabs == 0">
            <zb-table id="list-table" :fit="true" :style="{height: `${listTableHeight}px`}" :columns="columns" :data="listData"
                :show-header="true" :border="true" :row-key="row => row.index" @toggleRowSelection="handleSelect"
                @toggleAllSelection="handleSelectAll" />
        </view>
        <!-- 单据信息 -->
        <view v-if="tabs == 1">
            <view class="bill-info">
                <view class="form-item">
                    <view class="title">单据日期</view>
                    <view class="right">
                        <uni-datetime-picker type="date" v-model="hform.HDate">
                            <input type="text" v-model="hform.HDate" />
                        </uni-datetime-picker>
                    </view>
                </view>
            </view>
            <view class="bill-info">
                <view class="form-item">
                    <view class="title">制单人</view>
                    <view class="right disabled">
                        <input type="text" disabled :value="hform.HMaker" />
                    </view>
                </view>
            </view>
            <view class="bill-info">
                <view class="form-item">
                    <view class="title">单据号</view>
                    <view class="right disabled">
                        <input type="text" disabled :value="hform.HBillNo" />
                    </view>
                </view>
            </view>
            <view class="bill-info">
                <view class="form-item">
                    <view class="title">单据ID</view>
                    <view class="right disabled">
                        <input type="text" disabled :value="hform.HInterID" />
                    </view>
                </view>
            </view>
            <view class="bill-info">
                <view class="form-item">
                    <view class="title">组织</view>
                    <view class="right disabled">
                        <input type="text" disabled :value="hform.HStockOrgName" />
                    </view>
                </view>
            </view>
        </view>
        <view class="bottom-btn" id="bottom-btn">
            <button :class="EnableSubmit?'btn-a':'btn-c'" :disabled="!EnableSubmit" size="mini" @tap="cmdSubmit">拆箱</button>
            <view style="flex: 1;"></view>
            <!-- <button class="btn-d" size="mini" @tap="cmdDelete">删除</button> -->
            <button class="btn-c" size="mini" @tap="cmdExit">退出</button>
        </view>
    </view>
</template>
<script>
    import dayjs from 'dayjs'
    import {
        getUserInfo
    } from "../../utils/auth";
    import {
        CommonUtils
    } from "@/utils/common.js"
    import {
        MpaasScan
    } from "@/utils/mpaasScan.js"
    export default {
        data() {
            return {
                EnableSubmit: true,
                // 计算列表高度
                bottomBtnTop: 0,
                listTableTop: 0,
                // 公共变量
                HBarCodePackFocus: false,
                HBarCodeFocus: false,
                HBarCode_Pack: '', //箱条码
                HBarCode: '', // 包条码
                tabs: 0,
                HBillType: '3783',
                HBillSubType: '1', //子类型(1拆箱、2拆托)
                OperationType: 1, //操作类型(1新增、2从缓存列表中返回)
                HMaterNumber_Pack: "", //托条码对应物料代码
                listOption: [],
                listData: [],
                columns: [
                    {
                        name: 'index',
                        label: '序号',
                        width: 60,
                        hidden: true,
                    },
                    {
                        name: '条码编号',
                        label: '条码编号',
                        width: 100,
                    },
                    {
                        name: '数量',
                        label: '数量',
                        width: 100,
                    },
                    {
                        name: '物料代码',
                        label: '物料代码',
                        width: 100,
                    },
                    {
                        name: '物料名称',
                        label: '物料名称',
                        width: 100,
                    },
                    {
                        name: '条码个数',
                        label: '条码个数',
                        width: 100,
                    }
                ],
                selectedRows: [], // 存储选中的数据
                HModName: "Sc_UnPackUnionBill_Packing_PDA",
                ModRightName: "CE_UnPackUnionBill_Packing", //模块权限参数
                titleData: [], //不需要显示的字段
                OperationType: 1, //从缓存列表中返回数据类型(1新增、2从缓存列表中返回)
                HBarCode_Pack_Temp: "", //从缓存列表中返回箱条码
                // 表单提交值
                hform: {
                    HDate: dayjs(new Date()).format('YYYY-MM-DD'),
                    HMaker: getUserInfo()['Czymc'],
                    HBillNo: '',
                    HInterID: '',
                    HStockOrgName: uni.getStorageSync("Organization"),
                    HStockOrgID: uni.getStorageSync("OrganizationID"),
                },
                // 分页模块元数据
                paginationMeta: {
                }
            }
        },
        methods: {
            async HBarCodeFocusRefresh(){
              this.HBarCode = ''
              this.HBarCodeFocus = false
              await this.$nextTick()
              this.HBarCodeFocus = true
            },
            async HBarCodePackFocusRefresh(){
              this.HBarCode_Pack = ''
              this.HBarCodePackFocus = false
              await this.$nextTick()
              this.HBarCodePackFocus = true
            },
            toScanCode() {
                MpaasScan.scanCode((scanCode) => {
                    this.HBarCode_Pack = scanCode
                    this.GetMeesageByBarCode_Pack(HBarCode_Pack)
                })
            },
            GetMeesageByBarCode_Pack(HBarCode) {
                // 获取包条码对应的数据
                let HBarCode_Pack = this.HBarCode_Pack
                let sOldBarCode = this.HBarCode_Pack
                let HDeleteFlag = sOldBarCode.substring(0, 1)
                let sBarCode = sOldBarCode.slice(1)
                if (!HBarCode_Pack) {
                    return uni.showToast({
                        icon: 'none',
                        title: '箱条码为空,请先扫描箱条码',
                    })
                }
                if (HDeleteFlag == '*') {
                    if (!sBarCode) {
                        return uni.showToast({
                            icon: 'none',
                            title: '请扫描要删除的箱条码',
                        })
                    } else {
                        this.HBarCodeFocusRefresh()
                    }
                    CommonUtils.doRequest2({
                        url: '/WEBSController/set_DelPackUnionBill_Temp_Pack_Json',
                        data: {
                            "HInterID": this.hform.HInterID,
                            "HBarCode": sBarCode,
                            "HBillType": this.HBillType
                        },
                        resFunction: (res) => {
                            let {
                                data,
                                count,
                                Message
                            } = res.data
                            if (count == 1) {
                                CommonUtils.playSound(1)
                                this.DisBillEntryList()
                            } else {
                                CommonUtils.playSound(0)
                                uni.showToast({
                                    icon: 'none',
                                    title: Message
                                })
                            }
                        }
                    })
                } else {
                    let sBarCode_b = this.HBarCode_Pack
                    if (!sBarCode_b) {
                        return uni.showToast({
                            icon: 'none',
                            title: '箱条码不能为空,请扫描箱条码',
                        })
                    }
                    CommonUtils.doRequest2({
                        url: '/WEBSController/Get_PackBarCode_UnPackUnionBill_Json',
                        data: {
                            "HBarCode_Pack": sBarCode_b,
                            "HBillSubType": this.HBillSubType
                            //"HBarCode_Pack": HBarCode_Pack,
                        },
                        resFunction: (res) => {
                            let {
                                data,
                                count,
                                Message
                            } = res.data
                            if (count == 1) {
                                CommonUtils.playSound(1)
                                //this.HBarCodeFocusRefresh()
                                this.hform.HInterID=data[0].HInterID
                                this.hform.HBillNo=data[0].HBillNo
                                this.listData = []
                                var codeLength=data.length
                                for (let i = 0; i < codeLength; i++) {
                                    this.listData.push(Object.assign(data[i], {
                                        index: i
                                    }))
                                }
                            } else {
                                CommonUtils.playSound(0)
                                this.HBarCodeFocusRefresh()
                                uni.showToast({
                                    icon: 'none',
                                    title: Message
                                })
                            }
                            console.log(sBarCode_b)
                        }
                    })
                }
            },
            DisBillEntryList() {
                CommonUtils.doRequest2({
                    url: '/WEBSController/Get_PackBarCode_UnPackUnionBill_Json',
                    data: {
                        "HInterID": this.hform.HInterID,
                        "HBillNo": this.hform.HBillNo
                        //"HBillType": this.HBillType
                    },
                    resFunction: (res) => {
                        let {
                            count,
                            data,
                            Message
                        } = res.data
                        if (count == 1) {
                            this.listData = []
                            for (let i = 0; i < data.length; i++) {
                                this.listData.push(Object.assign(data[i], {
                                    index: i
                                }))
                            }
                        } else {
                            // 没有任何记录视为从0开始新增
                            this.listData = []
                        }
                    }
                })
            },
            handleSelect(selected, array) {
                this.selectedRows = array
            },
            handleSelectAll(selected, array) {
                this.selectedRows = array
            },
            getMaxNo() {
                CommonUtils.doRequest2({
                    url: "/WEBSController/GetMaxBillNoAndID_Json",
                    data: {
                        "HBillType": this.HBillType
                    },
                    resFunction: (d) => {
                        console.log('d: ', d);
                        let {
                            count,
                            data,
                            Message
                        } = d.data
                        if (count == 1) {
                            this.hform.HInterID = data[0].HInterID;
                            this.hform.HBillNo = data[0].HBillNo
                        } else {
                            uni.showModal({
                                title: "温馨提示",
                                showCancel: false,
                                content: Message
                            })
                        }
                    }
                })
            },
            submitPreCheck() {
                if (CommonUtils.isEmpty(this.hform.HInterID)) {
                    uni.showToast({
                        icon: 'none',
                        title: '单据内码获取失败,错误的单据内码!'
                    })
                    return false
                }
                if (CommonUtils.isEmpty(this.hform.HBillNo)) {
                    uni.showToast({
                        icon: 'none',
                        title: '单据号获取失败,错误的单据号!'
                    })
                    return false
                }
                if (this.listData.length < 1) {
                    uni.showToast({
                        icon: 'none',
                        title: '没有扫码信息,请先扫描条码,确认无误后再提交!'
                    })
                    return false
                }
                return true
            },
            cmdDelete() {
                console.log('this.selectedRows: ', this.selectedRows);
                if (this.selectedRows.length != 1) {
                    return uni.showToast({
                        icon: 'none',
                        title: '请选择一行记录,进行删除!'
                    })
                }
                uni.showModal({
                    title: '删除确认',
                    content: '确认要删除选中行所有扫码记录?删除后将不可恢复!',
                    success: () => {
                        if (confirm) {
                            CommonUtils.doRequest2({
                                url: '/WEBSController/set_DelPackUnionBill_Temp_Pack_Json',
                                data: {
                                    HInterID: this.hform.HInterID,
                                    HBillType: this.HBillType,
                                    HBarCode: this.selectedRows[0].HBarCode
                                },
                                resFunction: (res) => {
                                    let {
                                        data,
                                        count,
                                        Message
                                    } = res.data
                                    if (count == 1) {
                                        CommonUtils.playSound(1)
                                        uni.showToast({
                                            icon: 'none',
                                            title: Message
                                        })
                                        this.DisBillEntryList()
                                    } else {
                                        CommonUtils.playSound(0)
                                        uni.showToast({
                                            icon: 'none',
                                            title: Message
                                        })
                                    }
                                }
                            })
                        }
                    }
                })
            },
            cmdSubmit() {
                let checkRes = this.submitPreCheck()
                if (!checkRes) {
                    return
                }
                this.EnableSubmit = false
                console.log(this.hform.HInterID)
                console.log(this.hform.HBillNo)
                console.log(this.HBarCode_Pack)
                console.log(this.hform.HMaker)
                CommonUtils.doRequest2({
                    url: '/WEBSController/set_SaveUnPackUnionBill_Json',
                    data: {
                        "HInterID": this.hform.HInterID,
                        "HBillNo": this.hform.HBillNo,
                        "HBarCode_Pack": this.HBarCode_Pack,
                        "HMaker": this.hform.HMaker,
                    },
                    resFunction: (res) => {
                        let {data, count, Message} = res.data
                        if(count == 1){
                            uni.showModal({
                                title: '温馨提示',
                                content: Message,
                                confirmText: "新增",
                                cancelText: '关闭',
                                success: ({confirm,cancel}) => {
                                    if(confirm) {
                                        uni.redirectTo({
                                            url: "/pages/chaixiang/form"
                                        })
                                    }
                                    if(cancel) {
                                        uni.navigateBack()
                                    }
                                }
                            })
                        }else {
                            uni.showToast({
                                icon:'none',
                                title: Message
                            })
                        }
                    }
                })
            },
            cmdExit() {
                uni.navigateBack()
            }
        },
        computed: {
            listTableHeight: {
                get() {
                    return this.bottomBtnTop - this.listTableTop - 10
                }
            }
        },
        async onReady() {
            // #ifndef MP-WEIXIN
            let query = uni.createSelectorQuery().in(this)
            query.select("#bottom-btn")
                .boundingClientRect((data) => {
                    if (data) {
                        this.bottomBtnTop = data.top
                    } else {
                        console.log("未找到#bottom-btn节点");
                    }
                })
                .exec();
            query.select("#list-table")
                .boundingClientRect((data) => {
                    if (data) {
                        this.listTableTop = data.top
                    } else {
                        console.log("未找到#list-table节点");
                    }
                })
                .exec();
            // #endif
        },
        onLoad(e) {
            this.OperationType = e.OperationType || 1
            this.HBarCode_Pack_Temp = e.CommonUtils || ""
            if (this.OperationType == 1) {
                this.getMaxNo()
            } else if (this.OperationType == 2) {
            }
            this.HBarCodePackFocusRefresh()
        }
    }
</script>
<style lang="scss">
    input {
        width: inherit;
        padding: 8rpx 20rpx;
        font-size: 30rpx;
    }
    .form {
        display: flex;
        flex-direction: column;
        gap: 20rpx;
        .form-base-info {
            display: flex;
            flex-direction: column;
            gap: 10rpx;
            box-sizing: border-box;
            padding: 30rpx;
        }
        .bill-info {
            display: flex;
            flex-direction: column;
            gap: 10rpx;
            box-sizing: border-box;
            padding: 16rpx 30rpx;
        }
        .form-item {
            display: flex;
            flex-direction: row;
            gap: 10rpx;
            .title {
                width: 5rem;
                flex-shrink: 0;
            }
            .right {
                flex: 1;
                border-radius: 22rpx;
                border: 1px solid #acacac;
            }
            .disabled {
                border: 1px solid #e4e4e4;
                background-color: #e4e4e4;
            }
            .right-icon {
                flex-shrink: 0;
                display: flex;
                justify-content: center;
                align-items: center;
            }
        }
    }
    .tabs {
        width: 100%;
        display: flex;
        border-bottom: 1px solid #ddd;
        margin: 20rpx 0;
        view {
            width: 25%;
            font-size: 30rpx;
            color: #555;
            text-align: center;
            padding: 16rpx 0;
        }
        .on {
            color: #3a78ff;
            font-weight: bold;
            border-bottom: 3px solid #3a78ff;
        }
    }
    .bottom-btn {
        width: 100%;
        box-sizing: border-box;
        // height: 120rpx;
        position: fixed;
        bottom: 0;
        left: 0;
        background-color: #fff;
        box-shadow: 0 2rpx 10rpx 2rpx rgba(0, 0, 0, 0.4);
        padding: 30rpx 40rpx 40rpx 40rpx;
        display: flex;
        flex-direction: row;
        gap: 10rpx;
        button {
            border-radius: 50rpx;
            width: 180rpx;
            height: 66rpx;
            line-height: 66rpx;
            font-size: 28rpx;
        }
        .btn-a {
            background-color: #3A78FF;
            color: #fff;
        }
        .btn-b {
            background-color: #41a863;
            color: #fff;
        }
        .btn-c {
            background-color: #acacac;
            color: #fff;
            // position: absolute;
            // right: 120rpx;
        }
        .btn-d {
            background-color: #ff8901;
            color: #fff;
        }
    }
</style>
pages/fenbushidiaochudan/table_out.vue
@@ -124,11 +124,11 @@
                serverUrl: uni.getStorageSync('serverUrl') || 'http://47.96.97.237/API',
                tabs: 0,
                urls: '/WEBSController/GetKf_PonderationBillMain_TempList_New_Json',
                MvarReportTitle: '生产领料单缓存列表',
                MvarReportTitle: '分布式调出单缓存列表',
                hform: {
                    HBillNo: '',
                    HSourceBillNo: '',
                    HBillType: 1207,
                    HBillType: 1250,
                    HMaker: uni.getStorageSync('HUserName'),
                    HStockOrgID: uni.getStorageSync('OrganizationID'),
                },
@@ -268,7 +268,7 @@
                this.hform = {
                    HBillNo: '',
                    HSourceBillNo: '',
                    HBillType: 1207,
                    HBillType: 1250,
                    HMaker: uni.getStorageSync('HUserName'),
                    HStockOrgID: uni.getStorageSync('OrganizationID'),
                }
pages/index/index.vue
@@ -267,6 +267,26 @@
                        id: 29,
                        hidden: false,
                    },
                    {
                        img: '../../static/icon/icon16.png',
                        text: '拆箱',
                        url: '/pages/chaixiang/form',
                        id: 30,
                        hidden: false,
                    },{
                        img: '../../static/icon/icon16.png',
                        text: '装箱',
                        url: '/pages/zhuangxiang/form_mix',
                        id: 31,
                        hidden: false,
                    },
                    {
                        img: '../../static/icon/icon16.png',
                        text: '组托-小卫',
                        url: '/pages/zutuo_xiaowei/form_xiaowei',
                        id: 32,
                        hidden: false,
                    },
                ],
pages/index/login.vue
@@ -85,7 +85,7 @@
                    "温州海诚光学": 'http://122.228.39.234:7177/API/',
                    "宁波惠康工业": 'http://172.16.72.30:6699/API/',
                    "余姚兴达起动器": 'http://121.37.133.104/API/',
                     //"llj": 'http://localhost:8082/LuBaoAPI/',
                     "李林俊本地测试": 'http://localhost:8082/LuBaoAPI/',
                    "苏州卫智科技": 'http://221.224.60.42:8082/API_WW/',
                    "翁涛涛本地测试": 'http://localhost:81/API/',
                    "陈镐哲本地测试": 'http://localhost:81/API/',
pages/zhuangxiang/form_mix.vue
New file
@@ -0,0 +1,729 @@
<template>
    <view class="form">
        <view class="form-base-info">
            <view class="form-item">
                <view class="title">箱条码</view>
                <view class="right">
                    <input type="text" :focus="HBarCodePackFocus" v-model="HBarCode_Pack"
                        @confirm="GetMeesageByBarCode_Pack(HBarCode_Pack)" />
                </view>
                <view class="right-icon">
                    <uni-icons class="right-icon" :class="[EnableScanBarCodePack?'disabled':'']"  type="scan"
                        style="background-color: #3A78FF;padding: 6rpx;color: #fff;border-radius: 100%;" size="20"
                        @click="toScanCode"></uni-icons>
                </view>
            </view>
            <view class="form-item">
                <view class="title">包条码</view>
                <view class="right">
                    <input type="text" :focus="HBarCodeFocus" v-model="HBarCode"
                        @confirm="GetMeesageByBarCode(HBarCode)" />
                </view>
                <view class="right-icon">
                    <uni-icons type="scan"
                        style="background-color: #3A78FF;padding: 6rpx;color: #fff;border-radius: 100%;" size="20"
                        @click="toScanCode2"></uni-icons>
                </view>
            </view>
        </view>
        <view class="tabs">
            <view :class="tabs == 0 ? 'on':''" @tap="tabs = 0">装箱信息</view>
            <view :class="tabs == 1 ? 'on':''" @tap="tabs = 1">单据信息</view>
        </view>
        <!-- 装箱信息 -->
        <view v-if="tabs == 0">
            <zb-table id="list-table" :checked-highlight="true" :fit="true" :style="{height: `${listTableHeight}px`}" :columns="columns" :data="listData"
                :show-header="true" :border="true" :row-key="row => row.index" @toggleRowSelection="handleSelect"
                @toggleAllSelection="handleSelectAll" @rowClick="onTableRowClickHandler" />
        </view>
        <!-- 单据信息 -->
        <view v-if="tabs == 1">
            <view class="bill-info">
                <view class="form-item">
                    <view class="title">单据日期</view>
                    <view class="right">
                        <uni-datetime-picker type="date" v-model="hform.HDate">
                            <input type="text" v-model="hform.HDate" />
                        </uni-datetime-picker>
                    </view>
                </view>
            </view>
            <view class="bill-info">
                <view class="form-item">
                    <view class="title">制单人</view>
                    <view class="right disabled">
                        <input type="text" disabled :value="hform.HMaker" />
                    </view>
                </view>
            </view>
            <view class="bill-info">
                <view class="form-item">
                    <view class="title">单据号</view>
                    <view class="right disabled">
                        <input type="text" disabled :value="hform.HBillNo" />
                    </view>
                </view>
            </view>
            <view class="bill-info">
                <view class="form-item">
                    <view class="title">单据ID</view>
                    <view class="right disabled">
                        <input type="text" disabled :value="hform.HInterID" />
                    </view>
                </view>
            </view>
            <view class="bill-info">
                <view class="form-item">
                    <view class="title">组织</view>
                    <view class="right disabled">
                        <input type="text" disabled :value="hform.HStockOrgName" />
                    </view>
                </view>
            </view>
            <view class="bill-info">
                <checkbox-group @change="checkboxGroupChangeHandler">
                <view class="form-item" style="justify-content: right;">
                    <view class="title">质量审批</view>
                    <checkbox value="qualityApproval"></checkbox>
                </view>
                </checkbox-group>
            </view>
        </view>
        <view class="bottom-btn" id="bottom-btn">
            <button :class="EnableSubmit?'btn-a':'btn-c'" :disabled="!EnableSubmit" size="mini" @tap="cmdSubmit">提交</button>
            <view style="flex: 1;"></view>
            <button class="btn-d" size="mini" @tap="cmdDelete">删除</button>
            <button class="btn-c" size="mini" @tap="cmdExit">退出</button>
        </view>
    </view>
</template>
<script>
    import dayjs from 'dayjs'
    import {
        getUserInfo
    } from "../../utils/auth";
    import {
        CommonUtils
    } from "@/utils/common.js"
    import {
        MpaasScan
    } from "@/utils/mpaasScan.js"
    export default {
        data() {
            return {
                // 计算列表高度
                bottomBtnTop: 0,
                listTableTop: 0,
                // 公共变量
                EnableScanBarCodePack: true,
                EnableSubmit: true,
                HBarCodePackFocus: false,
                HBarCodeFocus: false,
                HBarCode_Pack: '', //箱条码
                HBarCode: '', // 包条码
                tabs: 0,
                HBillType: '3783',
                HBillSubType: '1', //子类型(1装箱、2组托)
                OperationType: 1, //操作类型(1新增、2从缓存列表中返回)
                HMaterNumber_Pack: "", //托条码对应物料代码
                listOption: [],
                listData: [],
                columns: [{
                        type: 'selection',
                        fixed: true,
                        width: 50
                    },
                    {
                        name: 'index',
                        label: '序号',
                        width: 60,
                        hidden: true
                    },
                    {
                        name: '条码编号',
                        label: '条码编号',
                        width: 100,
                    },
                    {
                        name: '数量',
                        label: '数量',
                        width: 100,
                    },
                    {
                        name: '物料代码',
                        label: '物料代码',
                        width: 100,
                    },
                    {
                        name: '物料名称',
                        label: '物料名称',
                        width: 100,
                    },
                    {
                        name: '条码个数',
                        label: '条码个数',
                        width: 100,
                    }
                ],
                selectedRows: [], // 存储选中的数据
                HModName: "Sc_PackUnionBill_Packing_PDA",
                ModRightName: "CE_PackUnionBill_Packing", //模块权限参数
                titleData: [], //不需要显示的字段
                OperationType: 1, //从缓存列表中返回数据类型(1新增、2从缓存列表中返回)
                HBarCode_Pack_Temp: "", //从缓存列表中返回箱条码
                // 表单提交值
                hform: {
                    HDate: dayjs(new Date()).format('YYYY-MM-DD'),
                    HMaker: getUserInfo()['Czymc'],
                    HBillNo: '',
                    HInterID: '',
                    HStockOrgName: uni.getStorageSync("Organization"),
                    HStockOrgID: uni.getStorageSync("OrganizationID"),
                    HQualityApproval: false,
                },
                // 分页模块元数据
                paginationMeta: {
                }
            }
        },
        methods: {
            checkboxGroupChangeHandler(e) {
                let checkBoxValues = Array.from(e.detail.value)
                if(checkBoxValues.findIndex(elem => elem == 'qualityApproval') != -1) {
                    this.hform.HQualityApproval = true
                }else {
                    this.hform.HQualityApproval = false
                }
            },
            onTableRowClickHandler(row, index) {
                console.log('row: ',row);
                if(!this.listData[index].checked){
                    this.$set(this.listData[index], 'checked', true)
                }else {
                    this.listData[index].checked = !this.listData[index].checked
                }
            },
            async HBarCodeFocusRefresh() {
                this.HBarCode = ''
                this.HBarCodeFocus = false
                await this.$nextTick()
                this.HBarCodeFocus = true
            },
            async HBarCodePackFocusRefresh() {
                this.HBarCode_Pack = ''
                this.HBarCodePackFocus = false
                await this.$nextTick()
                this.HBarCodePackFocus = true
            },
            toScanCode() {
                MpaasScan.scanCode((scanCode) => {
                    this.HBarCode_Pack = scanCode
                    this.GetMeesageByBarCode_Pack(HBarCode_Pack)
                })
            },
            GetMeesageByBarCode_Pack(HBarCode_Pack) {
                // 获取箱条码对应的数据
                CommonUtils.doRequest2({
                    url: '/WEBSController/Get_PackBarCode_PackUnionBill_New_Json',
                    data: {
                        HInterID: this.hform.HInterID || 0,
                        HBillNo: this.hform.HBillNo,
                        HBillType: this.HBillType,
                        HBillSubType:this.HBillSubType,
                        HBarCode_Pack: this.HBarCode_Pack
                        // HMaker: getUserInfo()['Czymc'],
                        // HStockOrgID: uni.getStorageSync('OrganizationID')
                    },
                    resFunction: (res) => {
                        let {
                            data,
                            count,
                            Message,
                            list
                        } = res.data
                        if (count == 1) {
                            CommonUtils.playSound(1)
                            this.hform.HBillNo = data[0].HBillNo
                            this.hform.HInterID = data[0].HInterID
                            this.HMaterNumber_Pack = data[0].HMaterNumber
                            this.DisBillEntryList();
                            uni.showToast({
                                icon: 'none',
                                title: Message
                            })
                        } else {
                            CommonUtils.playSound(0)
                            this.HBarCodePackFocusRefresh()
                            uni.showToast({
                                icon: 'none',
                                title: Message
                            })
                        }
                    }
                })
            },
            toScanCode2() {
                MpaasScan.scanCode((scanCode) => {
                    this.HBarCode = scanCode
                    GetMeesageByBarCode(scanCode)
                })
            },
            GetMeesageByBarCode(HBarCode) {
                // 获取待组托条码对应的数据
                let HBarCode_Pack = this.HBarCode_Pack
                let sOldBarCode = this.HBarCode
                let HDeleteFlag = sOldBarCode.substring(0, 1)
                let sBarCode = sOldBarCode.slice(1)
                if (!HBarCode_Pack) {
                    return uni.showToast({
                        icon: 'none',
                        title: '包条码不能为空,请先扫描包条码!',
                    })
                }
                if (HDeleteFlag == '*') {
                    if (!sBarCode) {
                        return uni.showToast({
                            icon: 'none',
                            title: '请扫描要删除的条码',
                        })
                    } else {
                        this.HBarCodeFocusRefresh()
                    }
                    CommonUtils.doRequest2({
                        url: '/WEBSController/set_DelPackUnionBill_Temp_Pack_Json',
                        data: {
                            "HInterID": this.hform.HInterID,
                            "HBarCode": sBarCode,
                            "HBillType": this.HBillType
                        },
                        resFunction: (res) => {
                            let {
                                data,
                                count,
                                Message
                            } = res.data
                            if (count == 1) {
                                CommonUtils.playSound(1)
                                this.DisBillEntryList()
                            } else {
                                CommonUtils.playSound(0)
                                uni.showToast({
                                    icon: 'none',
                                    title: Message
                                })
                            }
                        }
                    })
                } else {
                    let sBarCode = this.HBarCode
                    if (!sBarCode) {
                        return uni.showToast({
                            icon: 'none',
                            title: '条码不能为空,请扫描条码!',
                        })
                    }
                    CommonUtils.doRequest2({
                        url: '/WEBSController/Get_BarCode_PackUnionBill_New_Json',
                        data: {
                            "HInterID": this.hform.HInterID,
                            "HBarCode": sBarCode,
                            "HBillType": this.HBillType,
                            "HBillNo": this.hform.HBillNo,
                            "HBillSubType":this.HBillSubType,
                            "HBarCode_Pack": HBarCode_Pack,
                            "HMaker": this.hform.HMaker,
                            "HStockOrgID": this.hform.HStockOrgID,
                            "HMaterNumber_Pack":this.HMaterNumber_Pack
                        },
                        resFunction: (res) => {
                            let {
                                data,
                                count,
                                Message
                            } = res.data
                            if (count == 1) {
                                CommonUtils.playSound(1)
                                this.HBarCodeFocusRefresh()
                                this.DisBillEntryList()
                            } else {
                                CommonUtils.playSound(0)
                                this.HBarCodeFocusRefresh()
                                uni.showToast({
                                    icon: 'none',
                                    title: Message
                                })
                            }
                        }
                    })
                }
            },
            DisBillEntryList() {
                CommonUtils.doRequest2({
                    url: '/WEBSController/GetBillEntry_Tmp_Pack_Json',
                    data: {
                        "HInterID": this.hform.HInterID,
                        "HBillNo": this.hform.HBillNo,
                        "HBillType": this.HBillType
                    },
                    resFunction: (res) => {
                        let {
                            count,
                            data,
                            Message
                        } = res.data
                        if (count == 1) {
                            this.listData = []
                            for (let i = 0; i < data.length; i++) {
                                this.listData.push(Object.assign(data[i], {
                                    index: i
                                }))
                            }
                        } else {
                            // 没有任何记录视为从0开始新增
                            this.listData = []
                        }
                    }
                })
            },
            handleSelect(selected, array) {
                this.selectedRows = array
            },
            handleSelectAll(selected, array) {
                this.selectedRows = array
            },
            getMaxNo() {
                CommonUtils.doRequest2({
                    url: "/WEBSController/GetMaxBillNoAndID_Json",
                    data: {
                        "HBillType": this.HBillType
                    },
                    resFunction: (d) => {
                        console.log('d: ', d);
                        let {
                            count,
                            data,
                            Message
                        } = d.data
                        if (count == 1) {
                            this.hform.HInterID = data[0].HInterID;
                            this.hform.HBillNo = data[0].HBillNo
                        } else {
                            uni.showModal({
                                title: "温馨提示",
                                showCancel: false,
                                content: Message
                            })
                        }
                    }
                })
            },
            submitPreCheck() {
                if (CommonUtils.isEmpty(this.hform.HInterID)) {
                    uni.showToast({
                        icon: 'none',
                        title: '单据内码获取失败,错误的单据内码!'
                    })
                    return false
                }
                if (CommonUtils.isEmpty(this.hform.HBillNo)) {
                    uni.showToast({
                        icon: 'none',
                        title: '单据号获取失败,错误的单据号!'
                    })
                    return false
                }
                if (this.listData.length < 1) {
                    uni.showToast({
                        icon: 'none',
                        title: '没有扫码信息,请先扫描条码,确认无误后再提交!'
                    })
                    return false
                }
                return true
            },
            cmdDelete() {
                console.log('this.selectedRows: ', this.selectedRows);
                if (this.selectedRows.length != 1) {
                    return uni.showToast({
                        icon: 'none',
                        title: '请选择一行记录,进行删除!'
                    })
                }
                uni.showModal({
                    title: '删除确认',
                    content: '确认要删除选中行所有扫码记录?删除后将不可恢复!',
                    success: () => {
                        if (confirm) {
                            CommonUtils.doRequest2({
                                url: '/WEBSController/set_DelPackUnionBill_Temp_Pack_Json',
                                data: {
                                    HInterID: this.hform.HInterID,
                                    HBillType: this.HBillType,
                                    HBarCode: this.selectedRows[0].HBarCode
                                },
                                resFunction: (res) => {
                                    let {
                                        data,
                                        count,
                                        Message
                                    } = res.data
                                    if (count == 1) {
                                        CommonUtils.playSound(1)
                                        uni.showToast({
                                            icon: 'none',
                                            title: Message
                                        })
                                        this.DisBillEntryList()
                                    } else {
                                        CommonUtils.playSound(0)
                                        uni.showToast({
                                            icon: 'none',
                                            title: Message
                                        })
                                    }
                                }
                            })
                        }
                    }
                })
            },
            cmdSubmit() {
                let checkRes = this.submitPreCheck()
                if (!checkRes) {
                    return
                }
                this.EnableSubmit = false
                CommonUtils.doRequest2({
                    url: '/WEBSController/set_SavePackUnionBill_Json',
                    data: {
                        "HInterID": this.hform.HInterID,
                        "HBillType": this.HBillType,
                        "HBillNo": this.hform.HBillNo,
                        "HBarCode_Pack": this.HBarCode_Pack,
                        "HMaker": this.hform.HMaker,
                        "HStockOrgID": this.hform.HStockOrgID
                    },
                    resFunction: (res) => {
                        let {
                            data,
                            count,
                            Message
                        } = res.data
                        if (count == 1) {
                            uni.showModal({
                                title: '温馨提示',
                                content: Message,
                                confirmText: "新增",
                                cancelText: '关闭',
                                success: ({
                                    confirm,
                                    cancel
                                }) => {
                                    if (confirm) {
                                        uni.redirectTo({
                                            url: "/pages/zutuosaoma/form"
                                        })
                                    }
                                    if (cancel) {
                                        uni.navigateBack()
                                    }
                                }
                            })
                        } else {
                            uni.showToast({
                                icon: 'none',
                                title: Message
                            })
                        }
                    }
                })
            },
            cmdExit() {
                uni.navigateBack()
            }
        },
        computed: {
            listTableHeight: {
                get() {
                    return this.bottomBtnTop - this.listTableTop - 10
                }
            }
        },
        async onReady() {
            // #ifndef MP-WEIXIN
            let query = uni.createSelectorQuery().in(this)
            query.select("#bottom-btn")
                .boundingClientRect((data) => {
                    if (data) {
                        this.bottomBtnTop = data.top
                    } else {
                        console.log("未找到#bottom-btn节点");
                    }
                })
                .exec();
            query.select("#list-table")
                .boundingClientRect((data) => {
                    if (data) {
                        this.listTableTop = data.top
                    } else {
                        console.log("未找到#list-table节点");
                    }
                })
                .exec();
            // #endif
        },
        onLoad(e) {
            // 1为 装箱 2为 组托
            this.BarCodeType = e.BarCodeType || 1
            this.OperationType = e.OperationType || 1
            this.HBarCode_Pack = e.HBarCode_Pack_Temp || ""
            if (this.OperationType == 1) {
                this.getMaxNo()
            } else if (this.OperationType == 2) {
                this.GetMeesageByBarCode_Pack(this.HBarCode_Pack)
                this.DisBillEntryList()
                this.tabs = 0
            }
            // 光标默认聚焦在托条码上
            this.HBarCodePackFocusRefresh()
        }
    }
</script>
<style lang="scss">
    input {
        width: inherit;
        padding: 8rpx 20rpx;
        font-size: 30rpx;
    }
    .form {
        display: flex;
        flex-direction: column;
        gap: 20rpx;
        .form-base-info {
            display: flex;
            flex-direction: column;
            gap: 10rpx;
            box-sizing: border-box;
            padding: 30rpx;
        }
        .bill-info {
            display: flex;
            flex-direction: column;
            gap: 10rpx;
            box-sizing: border-box;
            padding: 16rpx 30rpx;
        }
        .form-item {
            display: flex;
            flex-direction: row;
            gap: 10rpx;
            .title {
                width: 5rem;
                flex-shrink: 0;
            }
            .right {
                flex: 1;
                border-radius: 22rpx;
                border: 1px solid #acacac;
            }
            .disabled {
                border: 1px solid #e4e4e4;
                background-color: #e4e4e4;
            }
            .right-icon {
                flex-shrink: 0;
                display: flex;
                justify-content: center;
                align-items: center;
            }
        }
    }
    .tabs {
        width: 100%;
        display: flex;
        border-bottom: 1px solid #ddd;
        margin: 20rpx 0;
        view {
            width: 25%;
            font-size: 30rpx;
            color: #555;
            text-align: center;
            padding: 16rpx 0;
        }
        .on {
            color: #3a78ff;
            font-weight: bold;
            border-bottom: 3px solid #3a78ff;
        }
    }
    .bottom-btn {
        width: 100%;
        box-sizing: border-box;
        // height: 120rpx;
        position: fixed;
        bottom: 0;
        left: 0;
        background-color: #fff;
        box-shadow: 0 2rpx 10rpx 2rpx rgba(0, 0, 0, 0.4);
        padding: 30rpx 40rpx 40rpx 40rpx;
        display: flex;
        flex-direction: row;
        gap: 10rpx;
        button {
            border-radius: 50rpx;
            width: 180rpx;
            height: 66rpx;
            line-height: 66rpx;
            font-size: 28rpx;
        }
        .btn-a {
            background-color: #3A78FF;
            color: #fff;
        }
        .btn-b {
            background-color: #41a863;
            color: #fff;
        }
        .btn-c {
            background-color: #acacac;
            color: #fff;
            // position: absolute;
            // right: 120rpx;
        }
        .btn-d {
            background-color: #ff8901;
            color: #fff;
        }
    }
</style>
pages/zutuo_xiaowei/form_xiaowei.vue
New file
@@ -0,0 +1,920 @@
<template>
    <view class="form">
        <view class="form-base-info">
            <view class="form-item">
                <view class="title">条码</view>
                <view class="right">
                    <input type="text" :focus="HBarCodeFocus" v-model="HBarCode"
                        @confirm="GetMeesageByBarCode(HBarCode)" />
                </view>
                <view class="right-icon">
                    <uni-icons type="scan"
                        style="background-color: #3A78FF;padding: 6rpx;color: #fff;border-radius: 100%;" size="20"
                        @click="toScanCode2"></uni-icons>
                </view>
            </view>
        </view>
        <view class="tabs">
            <view :class="tabs == 0 ? 'on':''" @tap="tabs = 0">装箱信息</view>
            <view :class="tabs == 1 ? 'on':''" @tap="tabs = 1">单据信息</view>
            <!-- 删除这行多余的代码 -->
            <!-- <view :class="tabs == 'closeResultTable' ? 'on':''" @tap="tabs = 1">单据信息</view> -->
        </view>
        <!-- 装箱信息 -->
        <view v-if="tabs == 0">
            <zb-table id="list-table" :checked-highlight="true" :fit="true" :style="{height: `${listTableHeight}px`}" :columns="columns" :data="listData"
                :show-header="true" :border="true" :row-key="row => row.index" @toggleRowSelection="handleSelect"
                @toggleAllSelection="handleSelectAll" @rowClick="onTableRowClickHandler" />
        </view>
        <!-- 单据信息 -->
        <view v-if="tabs == 1">
            <view class="bill-info">
                <view class="form-item">
                    <view class="title">单据日期</view>
                    <view class="right">
                        <uni-datetime-picker type="date" v-model="hform.HDate">
                            <input type="text" v-model="hform.HDate" />
                        </uni-datetime-picker>
                    </view>
                </view>
            </view>
            <view class="bill-info">
                <view class="form-item">
                    <view class="title">制单人</view>
                    <view class="right disabled">
                        <input type="text" disabled :value="hform.HMaker" />
                    </view>
                </view>
            </view>
            <view class="bill-info">
                <view class="form-item">
                    <view class="title">单据号</view>
                    <view class="right disabled">
                        <input type="text" disabled :value="hform.HBillNo" />
                    </view>
                </view>
            </view>
            <view class="bill-info">
                <view class="form-item">
                    <view class="title">单据ID</view>
                    <view class="right disabled">
                        <input type="text" disabled :value="hform.HInterID" />
                    </view>
                </view>
            </view>
            <view class="bill-info">
                <view class="form-item">
                    <view class="title">组织</view>
                    <view class="right disabled">
                        <input type="text" disabled :value="hform.HStockOrgName" />
                    </view>
                </view>
            </view>
            <view class="bill-info">
                <checkbox-group @change="checkboxGroupChangeHandler">
                <view class="form-item" style="justify-content: right;">
                    <view class="title">质量审批</view>
                    <checkbox value="qualityApproval"></checkbox>
                </view>
                </checkbox-group>
            </view>
        </view>
        <view class="bottom-btn" id="bottom-btn">
            <button :class="EnableSubmit?'btn-a':'btn-c'" :disabled="!EnableSubmit" size="mini" @tap="cmdSubmit">提交</button>
            <view style="flex: 1;"></view>
            <button class="btn-d" size="mini" @tap="cmdDelete">删除</button>
            <button class="btn-c" size="mini" @tap="cmdExit">退出</button>
        </view>
        <view v-if="showResultTable" class="result-modal">
            <view class="modal-mask" @tap="closeResultTable"></view>
            <view class="modal-content">
                <view class="modal-header">
                    <text class="modal-title">装箱结果</text>
                    <uni-icons type="close" size="20" @tap="closeResultTable"></uni-icons>
                </view>
                <view class="modal-body">
                    <zb-table
                        :fit="true"
                        :style="{height: '400px'}"
                        :columns="resultTableColumns"
                        :data="resultTableData"
                        :show-header="true"
                        :border="true"
                        :row-key="row => row.index" />
                </view>
                <view class="modal-footer">
                    <button class="btn-a" size="mini" @tap="toAddNew">新增</button>
                    <view style="flex: 1;"></view>
                    <button class="btn-c" size="mini" @tap="closeResultTable">关闭</button>
                </view>
            </view>
        </view>
    </view>
</template>
<script>
    import dayjs from 'dayjs'
    import {
        getUserInfo
    } from "../../utils/auth";
    import {
        CommonUtils
    } from "@/utils/common.js"
    import {
        MpaasScan
    } from "@/utils/mpaasScan.js"
import getdateTime from '../../utils/getdateTime';
    export default {
        data() {
            return {
                // 计算列表高度
                bottomBtnTop: 0,
                listTableTop: 0,
                // 公共变量
                EnableScanBarCodePack: true,
                EnableSubmit: true,
                HBarCodePackFocus: false,
                HBarCodeFocus: false,
                HBarCode_Pack: '', //箱条码
                HBarCode: '', // 包条码
                tabs: 0,
                HBillType: '3783',
                HBillSubType: '1', //子类型(1装箱、2组托)
                OperationType: 1, //操作类型(1新增、2从缓存列表中返回)
                HMaterNumber_Pack: "", //托条码对应物料代码
                listOption: [],
                listData: [],
                columns: [{
                        type: 'selection',
                        fixed: true,
                        width: 50
                    },
                    {
                        name: 'index',
                        label: '序号',
                        width: 60,
                        hidden: true
                    },
                    {
                        name: '条码编号',
                        label: '条码编号',
                        width: 100,
                    },
                    {
                        name: '数量',
                        label: '数量',
                        width: 100,
                    },
                    {
                        name: '物料代码',
                        label: '物料代码',
                        width: 100,
                    },
                    {
                        name: '物料名称',
                        label: '物料名称',
                        width: 100,
                    },
                    {
                        name: '条码个数',
                        label: '条码个数',
                        width: 100,
                    }
                ],
                selectedRows: [], // 存储选中的数据
                HModName: "Sc_PackUnionBill_Packing_PDA",
                ModRightName: "CE_PackUnionBill_Packing", //模块权限参数
                titleData: [], //不需要显示的字段
                OperationType: 1, //从缓存列表中返回数据类型(1新增、2从缓存列表中返回)
                HBarCode_Pack_Temp: "", //从缓存列表中返回箱条码
                //展示表单
                showResultTable: false, // 控制结果表格显示
                    resultTableData: [], // 结果表格数据
                    resultTableColumns: [
                      {
                        name: '栈板码',
                        label: '栈板码',
                        width: 120,
                      },
                      {
                        name: '中箱码',
                        label: '中箱码',
                        width: 120,
                      },
                      {
                        name: '日期',
                        label: '日期',
                        width: 100,
                      },
                      {
                        name: '物料',
                        label: '物料',
                        width: 100,
                      }
                    ],
                //
                // 表单提交值
                hform: {
                    HDate: dayjs(new Date()).format('YYYY-MM-DD'),
                    HMaker: getUserInfo()['Czymc'],
                    HInterID: '',
                    HStockOrgName: uni.getStorageSync("Organization"),
                    HStockOrgID: uni.getStorageSync("OrganizationID"),
                    HQualityApproval: false,
                    HMainID:'',
                    HSubID:'',
                    HSourceBillSEQ:'',
                    HBillNo:'',
                    HMaterNumber:'',
                    HMaterID:'',
                    HMaterName:'',
                    HMaterModel:'',
                    HCusModel:'',
                    HCusMaterName:'',
                    HEmpID:getUserInfo()['Czybm'],
                    HEmpNumber:uni.getStorageSync("HEmpNumber"),
                    HEmpName:getUserInfo()['Czymc'],
                    HGroupID:0,
                    HGroupNumber:'',
                    HGroupName:'',
                    HMTONo:'',
                    HCheckEmpName:'',
                    HExpiryDate:dayjs(new Date()).format('YYYY-MM-DD'),
                    HExpirationDateFlag:0,
                    HRemark:'',
                    HCoilNO:'',
                    HFurnaceNO:'',
                    HFactory:'',
                    HAuxQty:0,
                    HheatNO:'',
                    HProduceDate:dayjs(new Date()).format('YYYY-MM-DD'),
                    HSPID:0,
                    HSPCode:'',
                    HSPName:'',
                    HWHID:0,
                    HWHCode:'',
                    HWHName:'',
                    HQtyMust:0,
                    HQty:1,
                    HBQty:1,
                    HMinQty:1,
                    HPackQty:0,
                    HPrice:0,
                    HMoney:0,
                    HUseLife:0,
                    HLeaveLife:0,
                    HDesignLife:0,
                    //托条码:
                },
                // 分页模块元数据
                paginationMeta: {
                }
            }
        },
        methods: {
            checkboxGroupChangeHandler(e) {
                let checkBoxValues = Array.from(e.detail.value)
                if(checkBoxValues.findIndex(elem => elem == 'qualityApproval') != -1) {
                    this.hform.HQualityApproval = true
                }else {
                    this.hform.HQualityApproval = false
                }
            },
            onTableRowClickHandler(row, index) {
                console.log('row: ',row);
                if(!this.listData[index].checked){
                    this.$set(this.listData[index], 'checked', true)
                }else {
                    this.listData[index].checked = !this.listData[index].checked
                }
            },
            async HBarCodeFocusRefresh() {
                this.HBarCode = ''
                this.HBarCodeFocus = false
                await this.$nextTick()
                this.HBarCodeFocus = true
            },
            async HBarCodePackFocusRefresh() {
                this.HBarCode_Pack = ''
                this.HBarCodePackFocus = false
                await this.$nextTick()
                this.HBarCodePackFocus = true
            },
            toScanCode2() {
                MpaasScan.scanCode((scanCode) => {
                    this.HBarCode = scanCode
                    GetMeesageByBarCode(scanCode)
                })
            },
            GetMeesageByBarCode(HBarCode) {
                // 获取待组托条码对应的数据
                let HBarCode_Pack = this.HBarCode_Pack
                let sOldBarCode = this.HBarCode
                let HDeleteFlag = sOldBarCode.substring(0, 1)
                let sBarCode = sOldBarCode.slice(1)
                if (HDeleteFlag == '*') {
                    if (!sBarCode) {
                        return uni.showToast({
                            icon: 'none',
                            title: '请扫描要删除的条码',
                        })
                    } else {
                        this.HBarCodeFocusRefresh()
                    }
                    CommonUtils.doRequest2({
                        url: '/WEBSController/set_DelPackUnionBill_Temp_Pack_Json',
                        data: {
                            "HInterID": this.hform.HInterID,
                            "HBarCode": sBarCode,
                            "HBillType": this.HBillType
                        },
                        resFunction: (res) => {
                            let {
                                data,
                                count,
                                Message
                            } = res.data
                            if (count == 1) {
                                CommonUtils.playSound(1)
                                this.DisBillEntryList()
                            } else {
                                CommonUtils.playSound(0)
                                uni.showToast({
                                    icon: 'none',
                                    title: Message
                                })
                            }
                        }
                    })
                } else {
                    let sBarCode = this.HBarCode
                    if (!sBarCode) {
                        return uni.showToast({
                            icon: 'none',
                            title: '条码不能为空,请扫描条码!',
                        })
                    }
                    CommonUtils.doRequest2({
                        url: '/WEBSController/get_BarCode_PackUnionBill_New_Json_xiaowei',
                        data: {
                            "HInterID": this.hform.HInterID,
                            "HBarCode": sBarCode,
                            "HBillType": this.HBillType,
                            "HBillSubType":this.HBillSubType,
                            "HBarCode_Pack":'',
                            "HBillNo": this.hform.HBillNo,
                            "HMaterNumber_Pack":this.HMaterNumber_Pack,
                            "HMaker": this.hform.HMaker,
                            "HStockOrgID": this.hform.HStockOrgID
                        },
                        resFunction: (res) => {
                            let {
                                data,
                                count,
                                Message
                            } = res.data
                            if (count == 1) {
                                CommonUtils.playSound(1)
                                console.log(sBarCode)
                                this.FindMaterial(sBarCode)
                                this.HBarCodeFocusRefresh()
                                this.DisBillEntryList()
                            } else {
                                CommonUtils.playSound(0)
                                this.HBarCodeFocusRefresh()
                                uni.showToast({
                                    icon: 'none',
                                    title: Message
                                })
                            }
                        }
                    })
                }
            },
            FindMaterial(sBarCode)
            {
                CommonUtils.doRequest2({
                    url: '/Gy_Material/findMaterialByNumber',
                    data: {
                        "HbarCode": sBarCode,
                        "HSTOCKORGID": this.HStockOrgID,
                    },
                    resFunction: (res) => {
                        let {
                            count,
                            data,
                            Message
                        } = res.data
                        if (count == 1) {
                            console.log(res.data)
                            this.hform.HMaterID=data[0].HMaterID
                            this.hform.HMaterName=data[0].HMaterName
                            this.hform.HMaterModel=data[0].HMaterModel
                        }else {
                                uni.showToast({
                                    icon: 'none',
                                    title: Message
                                })
                            }
                    }
                })
            },
            DisBillEntryList() {
                CommonUtils.doRequest2({
                    url: '/WEBSController/GetBillEntry_Tmp_Pack_Json',
                    data: {
                        "HInterID": this.hform.HInterID,
                        "HBillNo": this.hform.HBillNo,
                        "HBillType": this.HBillType
                    },
                    resFunction: (res) => {
                        let {
                            count,
                            data,
                            Message
                        } = res.data
                        if (count == 1) {
                            this.listData = []
                            for (let i = 0; i < data.length; i++) {
                                this.listData.push(Object.assign(data[i], {
                                    index: i
                                }))
                            }
                        } else {
                            // 没有任何记录视为从0开始新增
                            this.listData = []
                        }
                    }
                })
            },
            handleSelect(selected, array) {
                this.selectedRows = array
            },
            handleSelectAll(selected, array) {
                this.selectedRows = array
            },
            getMaxNo() {
                CommonUtils.doRequest2({
                    url: "/WEBSController/GetMaxBillNoAndID_Json",
                    data: {
                        "HBillType": this.HBillType
                    },
                    resFunction: (d) => {
                        console.log('d: ', d);
                        let {
                            count,
                            data,
                            Message
                        } = d.data
                        if (count == 1) {
                            this.hform.HInterID = data[0].HInterID;
                            this.hform.HBillNo = data[0].HBillNo
                        } else {
                            uni.showModal({
                                title: "温馨提示",
                                showCancel: false,
                                content: Message
                            })
                        }
                    }
                })
            },
            submitPreCheck() {
                if (CommonUtils.isEmpty(this.hform.HInterID)) {
                    uni.showToast({
                        icon: 'none',
                        title: '单据内码获取失败,错误的单据内码!'
                    })
                    return false
                }
                if (CommonUtils.isEmpty(this.hform.HBillNo)) {
                    uni.showToast({
                        icon: 'none',
                        title: '单据号获取失败,错误的单据号!'
                    })
                    return false
                }
                if (this.listData.length < 1) {
                    uni.showToast({
                        icon: 'none',
                        title: '没有扫码信息,请先扫描条码,确认无误后再提交!'
                    })
                    return false
                }
                return true
            },
            cmdDelete() {
                console.log('this.selectedRows: ', this.selectedRows);
                if (this.selectedRows.length != 1) {
                    return uni.showToast({
                        icon: 'none',
                        title: '请选择一行记录,进行删除!'
                    })
                }
                uni.showModal({
                    title: '删除确认',
                    content: '确认要删除选中行所有扫码记录?删除后将不可恢复!',
                    success: () => {
                        if (confirm) {
                            CommonUtils.doRequest2({
                                url: '/WEBSController/set_DelPackUnionBill_Temp_Pack_Json',
                                data: {
                                    HInterID: this.hform.HInterID,
                                    HBillType: this.HBillType,
                                    HBarCode: this.selectedRows[0].HBarCode
                                },
                                resFunction: (res) => {
                                    let {
                                        data,
                                        count,
                                        Message
                                    } = res.data
                                    if (count == 1) {
                                        CommonUtils.playSound(1)
                                        uni.showToast({
                                            icon: 'none',
                                            title: Message
                                        })
                                        this.DisBillEntryList()
                                    } else {
                                        CommonUtils.playSound(0)
                                        uni.showToast({
                                            icon: 'none',
                                            title: Message
                                        })
                                    }
                                }
                            })
                        }
                    }
                })
            },
            getBarCode_pack() {
                return new Promise((resolve, reject) => {
                    var sMainStr = JSON.stringify(this.hform);
                    var omain = sMainStr + ';' + this.hform.HStockOrgName + ';' + this.hform.HEmpName;
                    CommonUtils.doRequest2({
                        url: '/Sc_BarCode/Sub_SaveBill_xiaowei',
                        method: 'POST',
                        data: {
                            "msg": omain
                        },
                        resFunction: (res) => {
                            let { data, count, Message } = res.data;
                            if (count == 1) {
                                console.log('条码生成成功:', res.data.data[0]['条码编号']);
                                this.HBarCode_Pack = res.data.data[0]['条码编号'];
                                resolve(this.HBarCode_Pack); // 解析Promise
                            } else {
                                uni.showToast({
                                    icon: 'none',
                                    title: Message || '条码生成失败'
                                });
                                this.EnableSubmit = true;
                                reject(Message);
                            }
                        },
                        errorFunction: (error) => {
                            console.error('请求失败:', error);
                            uni.showToast({
                                icon: 'none',
                                title: '网络请求失败'
                            });
                            this.EnableSubmit = true;
                            reject(error);
                        }
                    });
                });
            },
            async cmdSubmit() {
              let checkRes = this.submitPreCheck()
              if (!checkRes) {
                return
              }
              this.EnableSubmit = false
              try {
                await this.getBarCode_pack();
                console.log('获取到的条码:', this.HBarCode_Pack);
                // 使用 await 确保提交完成后再获取数据
                await CommonUtils.doRequest2({
                  url: '/WEBSController/set_SavePackUnionBill_Json',
                  data: {
                    "HInterID": this.hform.HInterID,
                    "HBillType": this.HBillType,
                    "HBillNo": this.hform.HBillNo,
                    "HBarCode_Pack": this.HBarCode_Pack,
                    "HMaker": this.hform.HMaker,
                    "HStockOrgID": this.hform.HStockOrgID
                  },
                  resFunction: async (res) => {
                    let { data, count, Message } = res.data
                    if (count == 1) {
                      // 等待数据获取完成后再显示表格
                      await this.getResultTableData();
                    } else {
                      uni.showToast({
                        icon: 'none',
                        title: Message
                      })
                      this.EnableSubmit = true;
                    }
                  }
                })
              } catch (error) {
                console.error('提交失败:', error);
                this.EnableSubmit = true;
              }
            },
            getResultTableData() {
              console.log('开始获取结果数据,条码:', this.HBarCode_Pack);
              CommonUtils.doRequest2({
                url: '/WEBSController/get_SavePackUnion_xiaowei',
                data: {
                  "HBarCode_Pack": this.HBarCode_Pack
                },
                resFunction: (res) => {
                  console.log('结果接口返回:', res);
                  let { data, count, Message } = res.data
                  if (count == 1) {
                    console.log('获取到结果数据:', data);
                    this.resultTableData = data;
                    this.showResultTable = true; // 显示结果表格
                    console.log('showResultTable 设置为:', this.showResultTable);
                  } else {
                    uni.showToast({
                      icon: 'none',
                      title: Message || '获取数据失败'
                    })
                    this.EnableSubmit = true;
                  }
                }
              })
            },
                // 新增方法
                toAddNew() {
                  // 重置数据,准备新增
                  this.showResultTable = false;
                  this.resultTableData = [];
                  this.HBarCode_Pack = '';
                  this.HBarCode = '';
                  this.listData = [];
                  this.getMaxNo(); // 重新获取新的单据号
                  this.HBarCodePackFocusRefresh(); // 重新聚焦
                },
                // 关闭结果表格
                closeResultTable() {
                  this.showResultTable = false;
                  uni.navigateBack();
                },
            cmdExit() {
                uni.navigateBack()
            }
        },
        computed: {
            listTableHeight: {
                get() {
                    return this.bottomBtnTop - this.listTableTop - 10
                }
            }
        },
        async onReady() {
            // #ifndef MP-WEIXIN
            let query = uni.createSelectorQuery().in(this)
            query.select("#bottom-btn")
                .boundingClientRect((data) => {
                    if (data) {
                        this.bottomBtnTop = data.top
                    } else {
                        console.log("未找到#bottom-btn节点");
                    }
                })
                .exec();
            query.select("#list-table")
                .boundingClientRect((data) => {
                    if (data) {
                        this.listTableTop = data.top
                    } else {
                        console.log("未找到#list-table节点");
                    }
                })
                .exec();
            // #endif
        },
        onLoad(e) {
            // 1为 装箱 2为 组托
            this.BarCodeType = e.BarCodeType || 1
            this.OperationType = e.OperationType || 1
            this.HBarCode_Pack = e.HBarCode_Pack_Temp || ""
            if (this.OperationType == 1) {
                this.getMaxNo()
            } else if (this.OperationType == 2) {
               // this.GetMeesageByBarCode_Pack(this.HBarCode_Pack)
                this.DisBillEntryList()
                this.tabs = 0
            }
            // 光标默认聚焦在托条码上
            this.HBarCodePackFocusRefresh()
        }
    }
</script>
<style lang="scss">
    input {
        width: inherit;
        padding: 8rpx 20rpx;
        font-size: 30rpx;
    }
    .form {
        display: flex;
        flex-direction: column;
        gap: 20rpx;
        .form-base-info {
            display: flex;
            flex-direction: column;
            gap: 10rpx;
            box-sizing: border-box;
            padding: 30rpx;
        }
        .bill-info {
            display: flex;
            flex-direction: column;
            gap: 10rpx;
            box-sizing: border-box;
            padding: 16rpx 30rpx;
        }
        .form-item {
            display: flex;
            flex-direction: row;
            gap: 10rpx;
            .title {
                width: 5rem;
                flex-shrink: 0;
            }
            .right {
                flex: 1;
                border-radius: 22rpx;
                border: 1px solid #acacac;
            }
            .disabled {
                border: 1px solid #e4e4e4;
                background-color: #e4e4e4;
            }
            .right-icon {
                flex-shrink: 0;
                display: flex;
                justify-content: center;
                align-items: center;
            }
        }
    }
    .tabs {
        width: 100%;
        display: flex;
        border-bottom: 1px solid #ddd;
        margin: 20rpx 0;
        view {
            width: 25%;
            font-size: 30rpx;
            color: #555;
            text-align: center;
            padding: 16rpx 0;
        }
        .on {
            color: #3a78ff;
            font-weight: bold;
            border-bottom: 3px solid #3a78ff;
        }
    }
    .bottom-btn {
        width: 100%;
        box-sizing: border-box;
        // height: 120rpx;
        position: fixed;
        bottom: 0;
        left: 0;
        background-color: #fff;
        box-shadow: 0 2rpx 10rpx 2rpx rgba(0, 0, 0, 0.4);
        padding: 30rpx 40rpx 40rpx 40rpx;
        display: flex;
        flex-direction: row;
        gap: 10rpx;
        button {
            border-radius: 50rpx;
            width: 180rpx;
            height: 66rpx;
            line-height: 66rpx;
            font-size: 28rpx;
        }
        .btn-a {
            background-color: #3A78FF;
            color: #fff;
        }
        .btn-b {
            background-color: #41a863;
            color: #fff;
        }
        .btn-c {
            background-color: #acacac;
            color: #fff;
            // position: absolute;
            // right: 120rpx;
        }
        .btn-d {
            background-color: #ff8901;
            color: #fff;
        }
    }
    .result-modal {
      position: fixed;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      z-index: 9999;
      .modal-mask {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.5);
      }
      .modal-content {
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        width: 90%;
        max-width: 700rpx;
        background: #fff;
        border-radius: 20rpx;
        overflow: hidden;
        .modal-header {
          padding: 30rpx;
          border-bottom: 1px solid #eee;
          display: flex;
          justify-content: space-between;
          align-items: center;
          .modal-title {
            font-size: 32rpx;
            font-weight: bold;
          }
        }
        .modal-body {
          padding: 30rpx;
          max-height: 60vh;
          overflow-y: auto;
        }
        .modal-footer {
          padding: 30rpx;
          border-top: 1px solid #eee;
          display: flex;
          align-items: center;
        }
      }
    }
</style>