#
whycq
2024-10-17 556bac681562cf38f90ce89cdcdd004227763c91
#
1个文件已修改
171 ■■■■■ 已修改文件
pages/pakin/confirmPakin.vue 171 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/pakin/confirmPakin.vue
@@ -13,14 +13,22 @@
            </view>
            <view class="item">
                <view class="code-decs">物料码:</view>
                <input type="text" placeholder=" 扫码 / 输入" v-model="matnr" :focus="matFocus" @input="analysis()">
                <textarea style="background-color: #f0f0f0;max-height: 100rpx;padding: 4px;margin: 4px;" type="textarea" placeholder=" 扫码 / 输入" maxlength="1000" v-model="matnr" :focus="matFocus" @input="analysis2()" />
                <view class="item-right">
                    <!-- <button></button>
                    <text style="text-align: right;color: #409EFF;" @click="selectMat()">提取+</text>
                    <uni-icons type="right" color="#c1c1c1"></uni-icons> -->
                </view>
            </view>
        </view>
        <!-- <view>
            <view style="display: flex;">
                <view>托盘码:</view>
                <input type="text" placeholder=" 扫码 / 输入" v-model="barcode" :focus="barcodeFocus"
                    @input="barcodeInput()">
            </view>
            <view style="display: flex;">
                <view>托盘码:</view>
                <textarea style="background-color: #ffff7f;" type="textarea" placeholder=" 扫码 / 输入" maxlength="1000" v-model="matnr" :focus="matFocus" @input="analysis2()" />
            </view>
        </view> -->
        <view class="mat-list-title">
            商品列表
        </view>
@@ -191,7 +199,149 @@
            this.token = uni.getStorageSync('token');
        },
        methods: {
            // 解析二维码
            analysis2() {
                const data = this.matnr
                const parseData = (data) => {
                    const lines = data.split('\n');
                    const t = {
                        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;
                            else if (key.startsWith('净重')) roll[index].netWeight = value;
                            else if (key.startsWith('毛重')) roll[index].grossWeight = value;
                            else if (key.startsWith('接头')) roll[index].splices = value;
                            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);
                this.secAnalysis(result)
            },
            // 二次解析
            secAnalysis(data) {
                let rolls = data.rolls
                let nedata = {
                    packageGroupNo: data.packageGroupNo,
                    rollType: data.rollType,
                    boxType: data.boxType,
                    thickness: data.thickness,
                    wideInWidth: data.wideInWidth,
                    totalGrossWeight: data.totalGrossWeight,
                    totalNetWeight: data.totalNetWeight,
                }
                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];
                        else if (key.startsWith('净重')) roll.netWeight = item[key];
                        else if (key.startsWith('毛重')) roll.grossWeight = item[key];
                        else if (key.startsWith('接头')) roll.splices = item[key];
                        else if (key.startsWith('分切时间')) roll.fqTime = item[key];
                    })
                    let newObj = {...nedata,...roll}
                    if (this.dataList.length > 0) this.checkAdd(newObj)
                    else this.dataList.push(newObj);
                }
                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.packagingGroupNumber == k.packagingGroupNumber && newMat.rollNo == k.rollNo) {
                        add = false
                    }
                }
                if (add) {
                    this.dataList.unshift(newMat)
                }
            },
            // 解析二维码 -- 弃用
            analysis() {
                let _this = this
                var matObj= {
@@ -213,7 +363,7 @@
                const resultMap = new Map();
                
                // 使用换行符作为分隔符分割字符串
                const lines = this.matnr.split(' ');
                const lines = this.matnr.split(':');
                console.log(lines);
                lines.forEach(line => {
                    // 使用中文冒号作为分隔符
@@ -585,9 +735,6 @@
                            that.resst();
                            that.messageText = "组托成功"
                            that.messageToggle('success')
                            const innerAudioContext = uni.createInnerAudioContext();
                            innerAudioContext.src = '/static/music/pakinOk.mp3';
                            innerAudioContext.play()
                        } else if (res.code == 403) {
                            that.messageText = res.msg
                            that.messageToggle('error')
@@ -636,6 +783,9 @@
<style>
    @import url('../../static/css/wms.css/wms.css');
    .list:first-child {
        margin-top: 340rpx;
    }
    .code {
        width: 100%;
        position: fixed;
@@ -647,7 +797,6 @@
    .item {
        display: flex;
        align-items: center;
        height: 70rpx;
        margin-left: 20rpx;
        border-bottom: 1px solid #DCDFE6;
    }
@@ -679,7 +828,7 @@
        width: 100%;
        background-color: white;
        position: fixed;
        margin-top: 200rpx;
        margin-top: 230rpx;
        z-index: 9;
        /* border-top: 1px solid #DCDFE6; */
        text-align: center;