From 556bac681562cf38f90ce89cdcdd004227763c91 Mon Sep 17 00:00:00 2001
From: whycq <913841844@qq.com>
Date: 星期四, 17 十月 2024 16:26:49 +0800
Subject: [PATCH] #
---
pages/pakin/confirmPakin.vue | 171 +++++++++++++++++++++++++++++++++++++++++++++++++++++---
1 files changed, 160 insertions(+), 11 deletions(-)
diff --git a/pages/pakin/confirmPakin.vue b/pages/pakin/confirmPakin.vue
index 86ccc4b..2098628 100644
--- a/pages/pakin/confirmPakin.vue
+++ b/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: {
- // 瑙f瀽浜岀淮鐮�
+ 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);
+ // 瑙f瀽鍩烘湰淇℃伅
+ 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();
+ });
+
+ // 瑙f瀽鍗峰彿淇℃伅
+ 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)
+
+ },
+ // 浜屾瑙f瀽
+ 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)
+ }
+ },
+ // 瑙f瀽浜岀淮鐮� -- 寮冪敤
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;
--
Gitblit v1.9.1