#
lty
2025-07-29 036dd5123cb4e700d6e0f707d9eac342bbe191fc
#
1个文件已添加
852 ■■■■■ 已修改文件
pages/pakin/boxPakin.vue 852 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/pakin/boxPakin.vue
New file
@@ -0,0 +1,852 @@
<template>
    <view>
        <view class="code">
            <view class="text-box">
                <view class="text-title">入库站:</view>
                <input type="text-title" placeholder=" 扫码 / 输入" v-model="sta" disabled="">
            </view>
            <view class="text-box">
                <view class="text-title">托盘码:</view>
                <input type="text-title" placeholder=" 扫码 / 输入" v-model="barcode" :focus="barcodeFocus"
                    @input="barcodeInput()">
            </view>
            <view class="text-box">
              <view class="text-title">木箱尺寸:</view>
              <view class="attr-row">
                <picker
                  :range="batchOptions"
                  :value="selectedBatchIndex"
                  @change="onPropChangeBatch"
                  class="half-box"
                >
                  <view class="picker-box">
                    <text>{{ matData.batch || '请选择尺寸' }}</text>
                  </view>
                </picker>
                <input
                  type="text"
                  v-model="matData.batch"
                  placeholder="手动输入其他尺寸"
                  class="half-box"
                />
              </view>
            </view>
            <view class="text-box">
              <view class="text-title">木箱备注:</view>
              <view class="attr-row">
                <picker
                  :range="memoOptions"
                  :value="selectedMemoIndex"
                  @change="onPropChangeMemo"
                  class="half-box"
                >
                  <view class="picker-box">
                    <text>{{ matData.memo || '请选择备注' }}</text>
                  </view>
                </picker>
                <input
                  type="text"
                  v-model="matData.memo"
                  placeholder="手动输入其他备注"
                  class="half-box"
                />
              </view>
            </view>
            <view class="text-box">
                <view class="text-title"><text>数量</text></view>
                <view class="text-title">
                    <view>
                        <uni-number-box :value="matData.anfme" :max="2" :step="1"  color="#747474" @change="changeValue"/>
                    </view>
                </view>
            </view>
        </view>
        <!-- 底部操作按钮 -->
        <view class="buttom">
            <button size="mini" @click="reset('warn')">重置</button>
            <button size="mini" type="primary" @click="combConfirm('warn')">确认</button>
        </view>
        <!-- 确认组托 -->
        <view>
            <uni-popup ref="combConfirm" type="dialog">
                <uni-popup-dialog :type="msgType" cancelText="取消" confirmText="确认" :title="title" :content="content"
                    @confirm="comb" @close="combClose"></uni-popup-dialog>
            </uni-popup>
        </view>
        <!-- 确认重置 -->
        <view>
            <uni-popup ref="resetConfirm" type="dialog">
                <uni-popup-dialog :type="msgType" cancelText="取消" confirmText="确认" :title="title" :content="content"
                    @confirm="resetConfirm" @close="resetClose"></uni-popup-dialog>
            </uni-popup>
        </view>
        <view>
            <!-- 提示信息弹窗 -->
            <uni-popup ref="message" type="message">
                <uni-popup-message :type="msgType1" :message="messageText" :duration="2000"></uni-popup-message>
            </uni-popup>
        </view>
    </view>
</template>
<script>
    export default {
        data() {
            return {
                batchOptions: [], // 对应 tagId=7 尺寸
                memoOptions: [],  // 对应 tagId=8 备注
                matData: {
                  batch: '',
                  memo: '',
                  anfme: 0
                },
                selectedBatchIndex: 0,
                selectedMemoIndex: 0,
                baseUrl: '',
                token: '',
                barcode: '',
                dataList: [],
                count: 0,
                rowNum: '',
                matnr: '',
                batch: '',
                weight: '',
                msgType1: 'success',
                msgType: 'success',
                messageText: '',
                title: '',
                content: '',
                barcodeFocus: true,
                matFocus: false,
                removeNum: 0,
                specs:'',
                manuDate:'',
                model:'',
                length:'',
                volume:'',
                sta:3050,
                list:["左","中","右"],
                index:0,
                selectedValue:'左'
            }
        },
        onLoad() {
        },
        onShow() {
            this.baseUrl = uni.getStorageSync('baseUrl');
            this.token = uni.getStorageSync('token');
        },
        mounted() {
          this.getMemoOptions();
        },
        methods: {
              onPropChangeBatch(e) {
                this.selectedBatchIndex = e.detail.value;
                this.matData.batch = this.batchOptions[e.detail.value];
              },
              onPropChangeMemo(e) {
                this.selectedMemoIndex = e.detail.value;
                this.matData.memo = this.memoOptions[e.detail.value];
              },
            getMemoOptions() {
              const that = this;
              uni.request({
                url: that.baseUrl + '/mobile/pdaGetMemo',
                method: 'POST',
                header: {
                    'token': uni.getStorageSync('token')
                },
                success(res) {
                  if (res.statusCode === 200) {
                    let data = res.data;
                    data.forEach(item => {
                      if (item.tagId === '7') {
                        that.batchOptions = item.memos;
                      } else if (item.tagId === '8') {
                        that.memoOptions = item.memos;
                      }
                    });
                  } else {
                    uni.showToast({ title: '获取下拉数据失败', icon: 'none' });
                  }
                }
              });
            },
            analysis2() {
                const data = this.matnr
                const parseData = (data) => {
                    const lines = data.split('\n');
                    const t = {
                        boxPos: '左',
                        packageGroupNo: '',
                        rollType: '',
                        boxType: '',
                        thickness: '',
                        wideInWidth: '',
                        totalGrossWeight: '',
                        totalNetWeight: '',
                        rolls: []
                    };
                    // console.log(lines);
                    // 解析基本信息
                    lines.forEach(line => {
                        if (line.startsWith('包装组号:')) t.packageGroupNo = line.split(':')[1].trim();
                        else if (line.startsWith('管芯类型:')) t.rollType = line.split(':')[1].trim();
                        else if (line.startsWith('木箱类型:')) t.boxType = line.split(':')[1].trim();
                        else if (line.startsWith('厚度:')) t.thickness = line.split(':')[1].trim();
                        else if (line.startsWith('宽幅:')) t.wideInWidth = line.split(':')[1].trim();
                        else if (line.startsWith('总毛重:')) t.totalGrossWeight = line.split(':')[1].trim();
                        else if (line.startsWith('总净重:')) t.totalNetWeight = line.split(':')[1].trim();
                    });
                    // 解析卷号信息
                    let rollData = {};
                    let roll = {
                        rollNo: '',
                        boxNo: '',
                        specs: '',
                        length: '',
                        splices: '',
                        netWeight: '',
                        grossWeight: '',
                        fqTime: '',
                    }
                    lines.forEach(line => {
                        const match = line.match(/卷号(\d+):(.+)/) || line.match(/箱号(\d+):(.+)/) || line.match(/规格(\d+):(.+)/) ||
                                      line.match(/长度(\d+):(.+)/) || line.match(/净重(\d+):(.+)/) || line.match(/毛重(\d+):(.+)/) ||
                                      line.match(/接头(\d+):(.+)/) || line.match(/分切时间(\d+):(.+)/);
                        if (match) {
                            const index = match[1]; // 获取序号
                            const key = match[0].split(':')[0]; // 获取参数名称
                            const value = match[2].trim(); // 获取参数值
                            // 初始化卷信息对象
                            if (!rollData[index]) rollData[index] = {};
                            rollData[index][key] = value;
                            if (!roll[index]) roll[index] = {};
                            if (key.startsWith('卷号')) roll[index].rollNo = value;
                            else if (key.startsWith('箱号')) roll[index].boxNo = value;
                            else if (key.startsWith('规格')) roll[index].specs = value;
                            else if (key.startsWith('长度')) roll[index].length = value.replace(/[^0-9]/ig, "");
                            else if (key.startsWith('净重')) roll[index].netWeight = value.replace(/[^0-9]/ig, "");
                            else if (key.startsWith('毛重')) roll[index].grossWeight = value.replace(/[^0-9]/ig, "");
                            else if (key.startsWith('接头')) roll[index].splices = value.replace(/[^0-9]/ig, "");
                            else if (key.startsWith('分切时间')) roll[index].fqTime = value;
                            // 如果有所有参数,则将其推入 rolls 数组
                            if (Object.keys(rollData[index]).length === 8) { // 所有字段都已经填充
                                t.rolls.push(rollData[index]);
                                rollData[index] = {}; // 重置以准备下一个卷
                            }
                        }
                    });
                    return t;
                };
                const result = parseData(data);
                // console.log(result);
                this.secAnalysis(result)
                // if (this.dataList.length > 0) this.checkAdd(result)
                // else this.dataList.push(result);
                // this.focuss()
            },
            oo() {
                let pp = {
                    palletizingNo: 3050,
                    barcode: 80009991,
                    boxList: {
                        boxPos: '左',
                        packageGroupNo: data.packageGroupNo,
                        rollType: data.rollType,
                        boxType: data.boxType,
                        thickness: data.thickness,
                        wideInWidth: data.wideInWidth,
                        totalGrossWeight: data.totalGrossWeight,
                        totalNetWeight: data.totalNetWeight,
                        rolls: [
                            {
                                rollNo: '',
                                boxNo: '',
                                specs: '',
                                length: '',
                                splices: '',
                                netWeight: '',
                                grossWeight: '',
                                fqTime: '',
                            },
                            {}
                        ],
                    }
                }
            },
            // 二次解析
            secAnalysis(data) {
                let rolls = data.rolls
                let nedata = {
                    boxPos: '左',
                    packageGroupNo: data.packageGroupNo,
                    rollType: data.rollType,
                    boxType: data.boxType,
                    thickness: data.thickness,
                    wideInWidth: data.wideInWidth,
                    totalGrossWeight: data.totalGrossWeight,
                    totalNetWeight: data.totalNetWeight,
                    rolls: [],
                }
                for    (let item of rolls) {
                    let roll = {
                        rollNo: '',
                        boxNo: '',
                        specs: '',
                        length: '',
                        splices: '',
                        netWeight: '',
                        grossWeight: '',
                        fqTime: '',
                    }
                    Object.keys(item).forEach(key=>{
                        if (key.startsWith('卷号')) roll.rollNo = item[key];
                        else if (key.startsWith('箱号')) roll.boxNo = item[key];
                        else if (key.startsWith('规格')) roll.specs = item[key];
                        else if (key.startsWith('长度')) roll.length = item[key].replace(/[^0-9]/ig, "");
                        else if (key.startsWith('净重')) roll.netWeight = item[key].replace(/[^0-9]/ig, "");
                        else if (key.startsWith('毛重')) roll.grossWeight = item[key].replace(/[^0-9]/ig, "");
                        else if (key.startsWith('接头')) roll.splices = item[key].replace(/[^0-9]/ig, "");
                        else if (key.startsWith('分切时间')) roll.fqTime = item[key];
                    })
                    nedata.rolls.push(roll)
                }
                if (this.dataList.length > 0) this.checkAdd(nedata)
                else this.dataList.push(nedata);
                this.focuss()
            },
            // 确认添加
            checkAdd(newMat) {
                // let mats = this.dataList
                // for (let item of mats) {
                //     if (item.packagingGroupNumber != newMat.packagingGroupNumber) {
                //         if (item.rollNo == newMat.rollNo)
                //     } this.dataList.push(newMat);
                // }
                var len = this.dataList.length
                var add = true
                for    (let k of this.dataList) {
                    if (newMat.packageGroupNo == k.packageGroupNo) {
                        add = false
                    }
                }
                if (add) {
                    if (this.dataList.length == 2) return
                    this.dataList.unshift(newMat)
                }
                if (this.dataList.length == 2) {
                    this.dataList[0].boxPos = '左'
                    this.dataList[1].boxPos = '右'
                    this.list = ['左','右']
                }
            },
            onChange(e,index) {
                if (this.dataList.length == 2) {
                    this.list = ['左','右']
                } else {
                    this.list = ['左','中','右']
                }
                if (this.dataList.length == 2) {
                    this.dataList[index].boxPos = this.list[e.detail.value];
                    if (index == 0) {
                        if (e.detail.value == 0) {
                            this.dataList[1].boxPos = this.list[1];
                        } else {
                            this.dataList[1].boxPos = this.list[0];
                        }
                    } else {
                        if (e.detail.value == 0) {
                            this.dataList[0].boxPos = this.list[1];
                        } else {
                            this.dataList[0].boxPos = this.list[0];
                        }
                    }
                } else {
                    this.dataList[index].boxPos = this.list[e.detail.value];
                }
                console.log(e,index)
            },
            // onChange(e,item) {
            //     console.log(e,item)
            //       this.item.boxPos = this.list[e.detail.value];
            //     },
            messageToggle(type) {
                this.msgType1 = type
                this.$refs.message.open()
            },
            // barcode input 事件
            barcodeInput() {
                // 不设置定时器 会出现扫入的字符串不全
                setTimeout(() => {
                    var len = this.barcode.length
                    // if (len != 6) {
                    //     uni.showToast({
                    //         title: '托盘码有误请重试',
                    //         icon: "none",
                    //         position: 'top'
                    //     });
                    //     this.barcodeFocuss()
                    //     return;
                    // }
                    this.focuss()
                }, 200)
            },
            // 托盘码有误重置
            barcodeFocuss() {
                let that = this;
                that.barcodeFocus = false;
                setTimeout(() => {
                    that.barcode = '';
                    that.barcodeFocus = true;
                }, 100);
            },
            // 商品光标清空重置
            focuss() {
                this.barcodeFocus = false;
                this.matFocus = false;
                setTimeout(() => {
                    this.matnr = '';
                    this.matFocus = true;
                }, 100);
            },
            // 搜索物料
            findMat() {
                let that = this
                let barcode =  this.matnr.split(" ")
                let packageGroupNo = barcode[11].slice(5)
                console.log(barcode)
                let mat = {}
                mat.packageGroupNo = packageGroupNo
                mat.boxPos = '左'
                that.dataList.unshift(mat)
                setTimeout(() => {
                    this.matnr = '';
                    this.matFocus = true;
                }, 100);
            },
            selectMat() {
                let that = this
                uni.navigateTo({
                    url: "../mat/matQuery",
                    success: function(res) {
                        // 通过eventChannel向被打开页面传送数据   向另外一个页面传递值的
                        res.eventChannel.emit('commonUrl', {
                            commonUrl: ''
                        })
                    },
                    events: {
                        // 为指定事件添加一个监听器,获取被打开页面传送到当前页面的数据  另外一个页面传过来的
                        acceptDataFromOpenedPage: function(data) {
                            that.matnr = data.data
                            that.findMat(that.matnr)
                        },
                    },
                });
                that.matnr = ''
            },
            checkMat(mat) {
                var len = this.dataList.length
                var add = true ,sameItem = false
                for (var i = 0; i < len; i++) {
                    if (mat.matnr == this.dataList[i].matnr) {
                        for (var j = 0; j < len; j++) {
                            if (mat.batch == this.dataList[j].batch) {
                                sameItem = true
                            }
                        }
                        // 相同物料 不同批号  新加列表
                        if (mat.batch != this.dataList[i].batch) {
                            this.$forceUpdate() // 强制刷新
                            if (sameItem) {
                                add = false
                            } else {
                                add = true
                            }
                        } else {
                            // 相同物料相同批号 数量累加
                            this.dataList[i].anfme += mat.anfme
                            this.$forceUpdate() // 强制刷新
                            add = false
                        }
                    }
                }
                if (add) {
                    this.dataList.unshift(mat)
                }
                this.$forceUpdate() // 强制刷新
            },
            // 修改批号
            revise(item, i) {
                this.matnr = this.dataList[i].matnr
                this.batch = this.dataList[i].batch
                this.weight = this.dataList[i].weight
                this.specs = this.dataList[i].specs
                this.manuDate = this.dataList[i].manuDate
                this.model = this.dataList[i].model
                this.length = this.dataList[i].length
                this.volume = this.dataList[i].volume
                this.rowNum = i
                this.eject()
            },
            eject(type) {
                this.type = type
                this.$refs.revise.open(type)
            },
            // 列表移除按钮
            remove(item, i, type) {
                this.removeNum  = i
                this.msgType = type
                this.title = '警告'
                this.content = '是否移除当前商品!'
                this.$refs.alertDialog.open(i)
            },
            // 确认移除
            removeConfirm() {
                this.messageText = "移除成功"
                this.messageToggle('success')
                this.dataList.splice(this.removeNum, 1)
            },
            // 取消移除
            removeClose() {
                this.$refs.alertDialog.close()
            },
            reviseConfirm() {
                this.dataList[this.rowNum].anfme = this.count
                this.dataList[this.rowNum].batch = this.batch
                this.dataList[this.rowNum].weight = this.weight
                this.matnr = ''
                this.messageText = "修改成功"
                this.messageToggle('success')
                this.$refs.revise.close()
            },
            reviseClose() {
                this.$refs.revise.close()
            },
            changeValue(value) {
                this.matData.anfme = value
            },
            combConfirm(type) {
                this.msgType = type
                this.title = '警告'
                this.content = '是否确认!'
                this.$refs.combConfirm.open()
            },
            combClose() {
                this.$refs.combConfirm.close()
            },
            comb() {
                uni.vibrateShort();
                let that = this;
                if (that.barcode === '') {
                    this.messageText = "请扫描托盘条码"
                    this.messageToggle('error')
                    return;
                }
                if (that.matData.batch.length === 0) {
                    this.messageText = "请选择木箱尺寸"
                    this.messageToggle('error')
                    return;
                }
                if (that.matData.memo.length === 0) {
                    this.messageText = "请选择木箱备注"
                    this.messageToggle('error')
                    return;
                }
                uni.request({
                    url: that.baseUrl + '/mobile/pdaBoxIn',
                    data: JSON.stringify({
                        palletizingNo: that.sta,
                        barcode: that.barcode,
                        batch: that.matData.batch,
                        memo: that.matData.memo,
                        anfme: that.matData.anfme
                    }),
                    method: 'POST',
                    header: {
                        'token': uni.getStorageSync('token')
                    },
                    success(result) {
                        var res = result.data
                        if (res.code === 200) {
                            that.resst();
                            that.messageText = "成功"
                            that.messageToggle('success')
                        } else if (res.code == 403) {
                            that.messageText = res.msg
                            that.messageToggle('error')
                            setTimeout(() => {
                                uni.reLaunch({
                                    url: '../login/login'
                                });
                            }, 1000);
                        } else {
                            that.messageText = res.msg
                            that.messageToggle('error')
                        }
                    }
                });
            },
            reset(type) {
                this.msgType = type
                this.title = '警告'
                this.content = '是否重置!'
                this.$refs.resetConfirm.open()
            },
            // 确认重置
            resetConfirm() {
                this.matData = []
                this.messageText = "重置完成"
                this.messageToggle('success')
            },
            // 取消重置
            resetClose() {
            },
            // 清空
            resst() {
                this.matData = []
                this.barcode = ''
                this.barcodeFocuss()
            },
        }
    }
</script>
<style>
    @import url('../../static/css/wms.css/wms.css');
    .picker {
      padding: 10px;
      height: 40rpx;
      width: 40rpx;
      display: flex;
      align-items: center;
      justify-content: center;
      background-color: #5fbf8e;
      color: #FFF;
      border-radius: 50%;
    }
    .desc {
        min-height: 40rpx;
        display: flex;
        align-items: center;
        width: 20%;
    }
    .left-item {
        display: flex;
        flex-wrap: wrap;
        width: 75%;
        margin: 1px 1px 1px 1px;
        /* color: #409EFF; */
    }
    .list:first-child {
        margin-top: 350rpx;
    }
    .code {
        width: 100%;
        position: fixed;
        min-height: 100rpx;
        background-color: #FFF;
        z-index: 10;
    }
    .item {
        display: flex;
        align-items: center;
        margin-left: 20rpx;
        border-bottom: 1px solid #DCDFE6;
    }
    .item input {
        height: 50rpx;
        line-height: 50rpx;
        /* font-family: PingFang SC; uniapp 默认字体不居中 */
        font-size: 36upx;
        font-family: PingFang SC;
        width: 55vw;
    }
    .code-decs {
        width: 20vw;
        font-size: 18px;
        color: #303133;
    }
    .item-right {
        margin-left: auto;
        margin-right: 20rpx;
    }
    .mat-list-title {
        height: 80rpx;
        line-height: 80rpx;
        width: 100%;
        background-color: white;
        position: fixed;
        margin-top: 230rpx;
        z-index: 9;
        /* border-top: 1px solid #DCDFE6; */
        text-align: center;
        box-shadow: 0px 0px 10px 0px rgba(0, 0, 0, 0.2);
    }
    .attr-row {
      display: flex;
      flex-direction: row;
      justify-content: space-between;
      align-items: center;
    }
    .half-box {
      width: 50%;
      box-sizing: border-box;
      border: 1rpx solid #ccc;
      height: 60rpx;
      border-radius: 8rpx;
      background-color: #f9f9f9;
      font-size: 24rpx;
      display: flex;
      align-items: center;
      padding: 0 10rpx;
      /* 统一字体大小,左右内边距,去掉上下内边距确保垂直居中 */
    }
    .picker-box {
      width: 100%;
      /* 让picker内容撑满盒子 */
      height: 60rpx;
      line-height: 60rpx;
      /* 行高垂直居中 */
    }
    input.half-box {
      border: none;
      outline: none;
      /* 去掉input默认边框 */
      background-color: transparent;
      /* 背景透明,让input背景跟父盒子一致 */
      font-size: 24rpx;
      /* 继承字体大小 */
      height: 60rpx;
      line-height: 60rpx;
      /* 让文字垂直居中 */
    }
    .container {
        width: 100%;
        height: 100%;
        background-color: #ffffff;
    }
    .text-box {
        height: 100rpx;
        line-height: 100rpx;
        margin-top: 20rpx;
        margin-left: 10%;
        width: 80%;
        font-size: 32rpx;
        font-weight: 400;
        color: #434343;
        border-bottom: 1rpx solid #e8e8e8;
    }
    .text-box:last-child {
        border-bottom: none;
    }
    .text-box .text-title {
        width: 30%;
        height: 100rpx;
        float: left;
        display: inline-block;
    }
    .text-box .text-title:last-child {
        display: inline-block;
        margin-left: 2%;
        width: 72%;
        font-size: 30rpx;
        font-weight: 400;
        color: #747474;
        display: flex;
        align-items: center;
    }
    .text-box .text-title:last-child input {
        border-bottom: 1rpx solid #e8e8e8 ;
        width: 100%;
    }
    .text-title input {
        text-align: center;
        border: 1rpx solid #e8e8e8;
        border-radius: 5rpx;
        padding: 5rpx;
        font-size: 28rpx;
        color: #747474;
    }
    .text-title text {
        font-size: 28rpx;
        color: #434343;
    }
    .text-title year{
        display: inline-block;
        margin-left: 2%;
        width: 72%;
        font-size: 30rpx;
        font-weight: 400;
        color: #747474;
    }
    .foot {
        width: 100%;
        height: 100rpx;
        line-height: 100rpx;
        background-color: rgba(255,255,255,1);
        position: fixed;
        bottom: 0%;
        border-top: 1px solid #d8d8d8;
        z-index: 1;
    }
    .text-box {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-top: 20rpx;
        margin-left: 10%;
        width: 80%;
        border-bottom: 1rpx solid #e8e8e8;
        padding-bottom: 10rpx;
    }
    /* 标签部分样式 */
    .label {
        width: 20%;
        font-size: 30rpx;
        color: #434343;
    }
</style>