###
whycq
2024-10-26 14a3a0f312a69ccb70e530f7aa25ac9bda07d007
###
1个文件已修改
80 ■■■■■ 已修改文件
pages/out/checkOut.vue 80 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/out/checkOut.vue
@@ -3,8 +3,9 @@
        <view class="code">
            <view class="item">
                <view class="code-decs">箱号:</view>
                <input type="text" placeholder=" 扫码 / 输入" v-model="barcode" :focus="barcodeFocus"
                    @input="barcodeInput()">
                <textarea style="background-color: #f0f0f0;max-height: 100rpx;padding: 4px;margin: 4px;"
                    type="textarea" placeholder=" 扫码 / 输入" maxlength="1000" v-model="barcode" :focus="barcodeFocus"
                    @input="analysis()" />
            </view>
        </view>
        <view class="mat-list-title">
@@ -155,13 +156,76 @@
                this.msgType1 = type
                this.$refs.message.open()
            },
            // barcode input 事件
            barcodeInput() {
            analysis() {
                let _this = this
                let newBarcode =  this.barcode
                let barcode =  this.barcode.split(" ")
                this.targetBatch = barcode[1].slice(3)
                this.barcode = barcode[1].slice(3)
                var matObj= {
                    rollNo: '', // 卷号
                    boxNo: '', // 箱号
                    specs: '', // 规格
                    length: '', // 长度
                    netWeight: '', // 净重
                    grossWeight: '', // 毛重
                    splices: '', // 接头 个
                }
                // 创建一个 Map 对象
                const resultMap = new Map();
                // 使用换行符作为分隔符分割字符串
                const lines = this.barcode.split('\n');
                console.log(lines);
                lines.forEach(line => {
                    // 使用中文冒号作为分隔符
                    const match = line.split(':');
                    if (match.length === 2) {
                        const key = match[0].trim(); // 中文部分作为键
                        const value = match[1].trim(); // 后面的字符串作为值
                        resultMap.set(key, value); // 将键值对存入 Map
                    }
                });
                // 输出结果
                console.log(resultMap);
                // 如果需要将 Map 转换为普通对象
                const resultObject = Object.fromEntries(resultMap);
                console.log(resultObject.净重);
                console.log(lines);
                matObj.rollNo = resultObject.卷号
                matObj.boxNo = resultObject.箱号
                matObj.specs = resultObject.规格
                matObj.length = resultObject.长度
                matObj.netWeight = resultObject.净重
                matObj.grossWeight = resultObject.毛重
                matObj.splices = resultObject.接头
                console.log(matObj);
                this.barcodeInput(matObj)
                // this.checkMatObj(matObj)
                this.barcodeFocus = false;
                this.matFocus = false;
                setTimeout(() => {
                    this.matnr = '';
                    this.matFocus = true;
                }, 100);
            },
            checkMatObj(mat) {
                var len = this.dataList.length
                var add = true
                for    (let k of this.dataList) {
                    if (mat.boxNo == k.boxNo) {
                        add = false
                    }
                }
                if (add) {
                    this.dataList.unshift(mat)
                }
            },
            // barcode input 事件
            barcodeInput(code) {
                let _this = this
                let newBarcode =  code
                uni.request({
                    url: _this.baseUrl + '/mobile/wrkDetl/search/batch/auth',
                    header: {'token': uni.getStorageSync('token')},