#
whycq
2024-10-18 03645d5014de64266f030ab2711a862d3ffc642e
#
2个文件已修改
192 ■■■■■ 已修改文件
pages/pakin/confirmPakin.vue 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/pakin/repairPakin.vue 186 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/pakin/confirmPakin.vue
@@ -13,7 +13,9 @@
            </view>
            <view class="item">
                <view class="code-decs">物料码:</view>
                <textarea style="background-color: #f0f0f0;max-height: 100rpx;padding: 4px;margin: 4px;" type="textarea" placeholder=" 扫码 / 输入" maxlength="1000" v-model="matnr" :focus="matFocus" @input="analysis2()" />
                <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">
                </view>
            </view>
@@ -333,7 +335,7 @@
                var len = this.dataList.length
                var add = true 
                for    (let k of this.dataList) {
                    if (newMat.packagingGroupNumber == k.packagingGroupNumber && newMat.rollNo == k.rollNo) {
                    if (newMat.packageGroupNo == k.packageGroupNo && newMat.rollNo == k.rollNo) {
                        add = false
                    }
                }
pages/pakin/repairPakin.vue
@@ -12,7 +12,9 @@
            </view>
            <view class="item">
                <view class="code-decs">物料码:</view>
                <input type="text" placeholder=" 扫码 / 输入" v-model="matnr" :focus="matFocus" @input="findMat()">
                <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>
        </view>
        <view class="mat-list-title">
@@ -171,9 +173,182 @@
            this.token = uni.getStorageSync('token');
        },
        methods: {
            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;
                            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);
                // console.log(result);
                // this.secAnalysis(result)
                if (this.dataList.length > 0) this.checkAdd(result)
                else this.dataList.push(result);
                this.focuss()
            },
            // 二次解析
            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.packageGroupNo == k.packageGroupNo) {
                        add = false
                    }
                }
                if (add) {
                    this.dataList.unshift(newMat)
                }
                if (this.dataList.length == 2) {
                    this.dataList[0].boxPos = '左'
                    this.dataList[1].boxPos = '右'
                    this.list = ['左','右']
                }
            },
            onChange(e,index) {
                console.log(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)
@@ -442,13 +617,13 @@
    }
    
    .list:first-child {
        margin-top: 420rpx;
        margin-top: 350rpx;
    }
    .code {
        width: 100%;
        position: fixed;
        min-height: 300rpx;
        min-height: 100rpx;
        background-color: #FFF;
        z-index: 10;
    }
@@ -456,7 +631,6 @@
    .item {
        display: flex;
        align-items: center;
        height: 100rpx;
        margin-left: 20rpx;
        border-bottom: 1px solid #DCDFE6;
    }
@@ -488,7 +662,7 @@
        width: 100%;
        background-color: white;
        position: fixed;
        margin-top: 300rpx;
        margin-top: 230rpx;
        z-index: 9;
        /* border-top: 1px solid #DCDFE6; */
        text-align: center;