From f7569ddaccd8bf4c0b121747caacade0a75a36c2 Mon Sep 17 00:00:00 2001
From: zhou zhou <3272660260@qq.com>
Date: 星期四, 18 十二月 2025 08:32:30 +0800
Subject: [PATCH] #

---
 pages.json                  |    6 
 pages/sockroom/sockroom.vue |  545 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 551 insertions(+), 0 deletions(-)

diff --git a/pages.json b/pages.json
index ff85347..74da072 100644
--- a/pages.json
+++ b/pages.json
@@ -84,6 +84,12 @@
 			}
 		},
 		{
+			"path": "pages/sockroom/sockroom",
+			"style": {
+				"navigationBarTitleText": "缁勬墭鍏ュ簱"
+			}
+		},
+		{
 			"path": "pages/order/orderPakin",
 			"style": {
 				"navigationBarTitleText": "璁㈠崟鍏ュ簱"
diff --git a/pages/sockroom/sockroom.vue b/pages/sockroom/sockroom.vue
new file mode 100644
index 0000000..f5199ee
--- /dev/null
+++ b/pages/sockroom/sockroom.vue
@@ -0,0 +1,545 @@
+<template>
+	<view class="sockpage">
+		<view class="column">
+			<!-- 鎵樼洏缂栫爜鏍忥紙瀵瑰簲鍚庣barcode锛� -->
+			<view class="form-card">
+				<view class="form-row">
+					<view class="label">
+						<text class="required">*</text>鎵樼洏缂栫爜锛�
+					</view>
+					<view class="picker-wrap" @click="scan" hover-class="picker-hover">
+						<view class="input-box">
+							<text class="input-placeholder" v-if="!barcode">鐐瑰嚮鎵爜褰曞叆</text>
+							<text class="input-value" v-else>{{barcode}}</text>
+						</view>
+						<view class="scan-icon">馃摲</view>
+					</view>
+				</view>
+			</view>
+			
+			<!-- 绠卞瀷鏍忥紙瀵瑰簲鍚庣boxType锛� -->
+			<view class="form-card">
+				<view class="form-row">
+					<view class="label">
+						<text class="required">*</text>绠�    鍨嬶細
+					</view>
+					<view class="picker-wrap" hover-class="picker-hover">
+						<picker @change="modePickerChange" :value="index_mode" :range="mode">
+							<view class="input-box">
+								<text class="input-placeholder" v-if="!mode.length || !mode[index_mode]">璇烽�夋嫨绠卞瀷</text>
+								<text class="input-value" v-else>{{mode[index_mode]}}</text>
+							</view>
+						</picker>
+					</view>
+				</view>
+			</view>
+			
+			<!-- 鐗╂枡淇℃伅杈撳叆鏍忥紙瀵瑰簲鍚庣MatList锛� -->
+			<view class="form-card material-card">
+				<view class="card-title">鐗╂枡淇℃伅</view>
+				<view class="material-grid">
+					<view class="material-item">
+						<text class="material-label"><text class="required">*</text>鍗峰彿锛�</text>
+						<input 
+							class="material-input" 
+							type="text" 
+							v-model="matList.model"
+							placeholder="璇疯緭鍏ュ嵎鍙�"
+							placeholder-class="input-placeholder"
+						/>
+					</view>
+					<view class="material-item">
+						<text class="material-label"><text class="required">*</text>绠卞彿锛�</text>
+						<input 
+							class="material-input" 
+							type="text" 
+							v-model="matList.batch"
+							placeholder="璇疯緭鍏ョ鍙�"
+							placeholder-class="input-placeholder"
+						/>
+					</view>
+					<view class="material-item">
+						<text class="material-label">瑙勬牸锛�</text>
+						<input 
+							class="material-input" 
+							type="text" 
+							v-model="matList.matnr"
+							placeholder="璇疯緭鍏ヨ鏍�"
+							placeholder-class="input-placeholder"
+						/>
+					</view>
+					<view class="material-item">
+						<text class="material-label">闀垮害锛�</text>
+						<input 
+							class="material-input" 
+							type="number" 
+							v-model="matList.rollExtent"
+							placeholder="璇疯緭鍏ラ暱搴�(m)"
+							placeholder-class="input-placeholder"
+						/>
+					</view>
+					<view class="material-item">
+						<text class="material-label">鍑�閲嶏細</text>
+						<input 
+							class="material-input" 
+							type="number" 
+							v-model="matList.weight"
+							placeholder="璇疯緭鍏ュ噣閲�(kg)"
+							placeholder-class="input-placeholder"
+						/>
+					</view>
+					<view class="material-item">
+						<text class="material-label">姣涢噸锛�</text>
+						<input 
+							class="material-input" 
+							type="number" 
+							v-model="matList.roughWeight"
+							placeholder="璇疯緭鍏ユ瘺閲�(kg)"
+							placeholder-class="input-placeholder"
+						/>
+					</view>
+					<view class="material-item">
+						<text class="material-label">鎺ュご锛�</text>
+						<input 
+							class="material-input" 
+							type="number" 
+							v-model="matList.joint"
+							placeholder="璇疯緭鍏ユ帴澶存暟"
+							placeholder-class="input-placeholder"
+						/>
+					</view>
+				</view>
+			</view>
+			
+			<!-- 鎿嶄綔鎸夐挳缁� -->
+			<view class="btn-group">
+				<button class="operate-btn scan-btn" @click="scantwo">鎵揣鐗╃爜</button>
+				<button class="operate-btn submit-btn" @click="submit">鎴愬搧鍏ュ簱</button>
+			</view>
+		</view>
+	</view>
+</template>
+
+<script>
+import { onLoad } from '../../uni_modules/uview-ui/libs/mixin/mixin'
+
+export default {
+	onLoad(){
+		// 鍏堣鍙栫紦瀛橈紝鍐嶆墽琛岃姹�
+		this.baseUrl = uni.getStorageSync('baseUrl');
+		this.token = uni.getStorageSync('token');
+		// 椤甸潰鍔犺浇鏃� mode 涓虹┖锛岃皟鐢ㄦ帴鍙e悗鎵嶅~鍏呮暟鎹�
+		this.POSTinfo(); 
+	},
+	data() {
+		return {
+			baseUrl: '',
+			barcodeNum:'',
+			barcode: '', // 鎵樼洏鐮�
+			palletizingNo: '1', // 鐮佸灈浣嶇紪鍙�
+			boxType: '', // 鏈ㄧ绫诲瀷
+			matList: {
+				matnr: '', // 瑙勬牸
+				maktx: '', // 鐗╂枡鍚嶇О
+				batch: '', // 鏈ㄧ缂栧彿
+				model: '', // 鍗风紪鍙�
+				position: '1', // 鏈ㄧ鐮佸灈浣嶇疆
+				weight: '', // 鍑�閲�
+				roughWeight: '', // 姣涢噸
+				anfme: 1.0, // 榛樿鍊�1.0
+				rollExtent: '', // 鍗烽暱搴�
+				joint: 0, // 鎺ュご
+				cutting: 2, // 榛樿鈥滃惁鈥�
+				qualified: 0, // 榛樿鈥滃惁鈥�
+				modelFront: '', // 鍒嗗垏鍓嶇缂栧彿
+				batchFront: '' ,// 鍒嗗垏鍓嶅嵎鍙�
+			},
+			// 鍏抽敭1锛氬垵濮嬪寲 mode 涓虹┖鏁扮粍 鈫� 椤甸潰鍔犺浇鏃剁鍨嬫棤鏁版嵁
+			mode: [], 
+			index_mode: 0,
+			index_num: 0,
+			submitData: {} // 鏈�缁堟彁浜ょ粰鍚庣鐨勬暟鎹�
+		}
+	},
+	methods: {
+		POSTinfo(){
+			uni.request({
+				url: this.baseUrl + '/mobile/box/type/complete/auth/v2',
+				method:'POST',
+				header: {
+					'Content-Type': 'application/json'
+				},
+				success:(res)=>{
+					// 鎺ュ彛杩斿洖鍚庢墠濉厖绠卞瀷鏁版嵁
+					this.mode = res.data.data.map(item => item.boxSpecs || '').filter(item => item);
+					console.log('鎻愬彇鐨勭鍨嬫暟鎹�:', this.mode);
+				},
+				fail:(err)=>{
+					console.error('鑾峰彇绠卞瀷澶辫触:', err)
+				}
+			})
+		},
+		modePickerChange(e) {
+			this.index_mode = e.detail.value;
+			this.boxType = this.mode[this.index_mode]; // 鍚屾鍒癰oxType
+		},
+		numPickerChange(e) {
+			this.index_num = e.detail.value
+		},
+		// 鍏抽敭2锛氫慨鏀归噸缃柟娉� 鈫� 娓呯┖ mode 鍙婄浉鍏崇姸鎬�
+		resetForm() {
+			this.barcodeNum = '';
+			this.barcode = ''; 
+			this.boxType = ''; 
+			this.index_mode = 0; 
+			this.index_num = 0; 
+			this.submitData = {}; 
+			// 娓呯┖ mode 鏁扮粍 鈫� 绠卞瀷閫夋嫨鍣ㄦ仮澶嶆棤鏁版嵁鐘舵��
+			this.mode = [];
+			// 閲嶇疆鐗╂枡淇℃伅锛堜繚鐣欓粯璁ゅ�硷級
+			this.matList = {
+				matnr: '',
+				maktx: '',
+				batch: '',
+				model: '',
+				position: '1', 
+				weight: '',
+				roughWeight: '',
+				anfme: 1.0, 
+				rollExtent: '',
+				joint: 0, 
+				cutting: 2, 
+				qualified: 0, 
+				modelFront: '',
+				batchFront: ''
+			};
+			// 鍙�夛細閲嶇疆鍚庨噸鏂拌姹傜鍨嬫暟鎹紙鏍规嵁闇�姹傞�夋嫨锛�
+			// this.POSTinfo();
+		},
+		submit(){
+		    // 鏍¢獙蹇呭~椤�
+		    if(!this.barcode) return uni.showToast({title: '璇锋壂鎻忔墭鐩樼紪鐮�', icon: 'none'})
+		    if(!this.boxType) return uni.showToast({title: '璇烽�夋嫨绠卞瀷', icon: 'none'})
+		    if(!this.matList.model || !this.matList.batch) return uni.showToast({title: '璇峰~鍐欏嵎鍙�/绠卞彿', icon: 'none'})
+		    
+		    // 鏁版嵁绫诲瀷杞崲
+		    const matItem = {
+		        ...this.matList,
+		        weight: this.matList.weight ? Number(this.matList.weight) : null,
+		        roughWeight: this.matList.roughWeight ? Number(this.matList.roughWeight) : null,
+		        rollExtent: this.matList.rollExtent ? Number(this.matList.rollExtent) : null,
+		        joint: this.matList.joint ? Number(this.matList.joint) : 0,
+		        anfme: 1.0,
+		        cutting: 2,
+		        qualified: 0
+		    }
+		    
+		    // 缁勮鎻愪氦鏁版嵁
+		    this.submitData = {
+		        barcode: this.barcode,
+		        palletizingNo: this.palletizingNo,
+		        boxType: this.boxType,
+		        matList: [matItem]
+		    }
+		    console.log('淇绫诲瀷鍚庣殑鎻愪氦鏁版嵁锛�', this.submitData)
+		    
+		    // 鎻愪氦璇锋眰
+		    uni.request({
+		        url: this.baseUrl + '/mobile/truss/comd/auth/v2',
+		        method: 'POST',
+		        header: {'Content-Type': 'application/json'},
+		        data: this.submitData,
+		        success: (res) => {
+		            console.log('鍚庣杩斿洖锛�', res)
+		            uni.showToast({title:'鎻愪氦鎴愬姛',icon: 'success'})
+		            // 鎻愪氦鎴愬姛鍚庨噸缃墍鏈夋暟鎹�
+		            this.resetForm();
+		            // 鍙�夛細閲嶇疆鍚庨噸鏂版媺鍙栫鍨嬫暟鎹紝鏂逛究涓嬫鎿嶄綔
+		            // setTimeout(() => {
+		            //     this.POSTinfo();
+		            // }, 300);
+		        },
+		        fail: (err) => {
+		            console.error('璇锋眰澶辫触璇︽儏锛�', err)
+		            uni.showToast({title:'鎻愪氦澶辫触',icon: 'none'})
+		        },
+		        complete: (res) => {
+		            console.log('璇锋眰瀹屾垚鐘舵�侊細', res)
+		        }
+		    })
+		},
+		scan(){
+			uni.scanCode({
+				autoDecodeCharSet: true,
+				scanType: ['barCode'],
+				onlyFromCamera: true,
+				continuousScan: false,
+				camera: 'back',
+				timeout: 5000,
+				success: (res) => {
+					this.barcodeNum = res.result
+					this.barcode = res.result
+					uni.showToast({title: `鎵樼洏缂栫爜鎵爜鎴愬姛`,icon: 'success'})
+				},
+				fail: (err) => {
+					uni.showToast({title: '鎵爜澶辫触鎴栧彇娑�',icon: 'none'})
+				}
+			})
+		},
+		parseQrCodeText(text) {
+			const result = {};
+			const regMap = {
+				model: /鍗峰彿锛�(.+)/,
+				batch: /绠卞彿锛�(.+)/,
+				matnr: /瑙勬牸锛�(.+)/,
+				rollExtent: /闀垮害锛�(.+?)\s*m/,
+				weight: /鍑�閲嶏細(.+?)\s*kg/,
+				roughWeight: /姣涢噸锛�(.+?)\s*kg/,
+				joint: /鎺ュご锛�(.+?)\s*涓�/
+			};
+			Object.keys(regMap).forEach(key => {
+				const match = text.match(regMap[key]);
+				if (match && match[1]) {
+					result[key] = match[1].trim();
+				}
+			});
+			return result;
+		},
+		scantwo(){
+			uni.scanCode({
+				autoDecodeCharSet:true,
+				scanType: ['qrCode'], 
+				success: (res) => {
+					const qrResult = res.result.trim();
+					this.barcodeNum = qrResult;
+					let parseResult = {};
+					
+					try {
+						parseResult = JSON.parse(qrResult);
+						parseResult = {
+							model: parseResult.鍗峰彿 || '',
+							batch: parseResult.绠卞彿 || '',
+							matnr: parseResult.瑙勬牸 || '',
+							rollExtent: (parseResult.闀垮害 || '').replace(/\s*m/g, '') || '',
+							weight: (parseResult.鍑�閲� || '').replace(/\s*kg/g, '') || '',
+							roughWeight: (parseResult.姣涢噸 || '').replace(/\s*kg/g, '') || '',
+							joint: (parseResult.鎺ュご || '').replace(/\s*涓�/g, '') || ''
+						};
+					} catch (e) {
+						parseResult = this.parseQrCodeText(qrResult);
+					}
+					
+					this.matList = { ...this.matList, ...parseResult };
+					uni.showToast({title: `鐗╂枡淇℃伅鎵爜鎴愬姛`,icon: 'success'});
+				},
+				fail: (err) => {
+					uni.showToast({title: '鎵爜澶辫触鎴栧彇娑�',icon: 'none'})
+				}
+			})
+		}
+	}
+}
+</script>
+
+<style scoped>
+/* 鍏ㄥ眬鏍峰紡 */
+.sockpage {
+	background-color: #f5f7fa;
+	padding: 24rpx;
+	min-height: 100vh;
+}
+
+/* 琛ㄥ崟鍒楀鍣� */
+.column {
+	display: flex;
+	flex-direction: column;
+	gap: 24rpx;
+}
+
+/* 琛ㄥ崟鍗$墖 */
+.form-card {
+	background: #ffffff;
+	border-radius: 12rpx;
+	box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.06);
+	padding: 24rpx;
+	transition: all 0.2s ease;
+}
+
+/* 鐗╂枡淇℃伅鍗$墖鐗规畩鏍峰紡 */
+.material-card {
+	padding: 0;
+}
+
+.card-title {
+	font-size: 30rpx;
+	font-weight: 500;
+	color: #1f2937;
+	padding: 24rpx 24rpx 16rpx;
+	border-bottom: 1rpx solid #f0f0f0;
+}
+
+/* 琛ㄥ崟琛� */
+.form-row {
+	display: flex;
+	flex-direction: row;
+	align-items: center;
+	gap: 16rpx;
+}
+
+/* 鏍囩鏍峰紡 */
+.label {
+	font-size: 28rpx;
+	color: #374151;
+	font-weight: 500;
+	min-width: 140rpx;
+}
+
+/* 蹇呭~椤规爣绾� */
+.required {
+	color: #ef4444;
+	margin-right: 4rpx;
+}
+
+/* 閫夋嫨鍣ㄥ鍣� */
+.picker-wrap {
+	flex: 1;
+	display: flex;
+	align-items: center;
+	justify-content: space-between;
+}
+
+/* 閫夋嫨鍣╤over鎬� */
+.picker-hover {
+	background-color: #f9fafb;
+	border-radius: 8rpx;
+}
+
+/* 杈撳叆妗嗗鍣� */
+.input-box {
+	flex: 1;
+	font-size: 28rpx;
+	padding: 16rpx 12rpx;
+	border: 1rpx solid #e5e7eb;
+	border-radius: 8rpx;
+	transition: border-color 0.2s ease;
+}
+
+.input-box:focus-within {
+	border-color: #f97316;
+}
+
+/* 鍗犱綅绗︽牱寮� */
+.input-placeholder {
+	color: #9ca3af;
+}
+
+/* 杈撳叆鍊兼牱寮� */
+.input-value {
+	color: #1f2937;
+}
+
+/* 鎵爜鍥炬爣 */
+.scan-icon {
+	font-size: 24rpx;
+	margin-left: 8rpx;
+	color: #6b7280;
+}
+
+/* 鐗╂枡淇℃伅缃戞牸甯冨眬 */
+.material-grid {
+	display: grid;
+	grid-template-columns: repeat(2, 1fr);
+	gap: 20rpx;
+	padding: 24rpx;
+}
+
+/* 鐗╂枡淇℃伅椤� */
+.material-item {
+	display: flex;
+	flex-direction: column;
+	gap: 8rpx;
+}
+
+/* 鐗╂枡鏍囩 */
+.material-label {
+	font-size: 26rpx;
+	color: #4b5563;
+}
+
+/* 鐗╂枡杈撳叆妗� */
+.material-input {
+	font-size: 28rpx;
+	color: #1f2937;
+	padding: 16rpx 12rpx;
+	border: 1rpx solid #e5e7eb;
+	border-radius: 8rpx;
+	background-color: #ffffff;
+	transition: border-color 0.2s ease;
+}
+
+.material-input:focus {
+	border-color: #f97316;
+	outline: none;
+}
+
+/* 鎸夐挳缁� */
+.btn-group {
+	display: flex;
+	gap: 20rpx;
+	justify-content: center;
+	margin-top: 16rpx;
+	padding: 8rpx 0;
+}
+
+/* 鎿嶄綔鎸夐挳閫氱敤鏍峰紡 */
+.operate-btn {
+	flex: 1;
+	max-width: 200rpx;
+	height: 80rpx;
+	line-height: 80rpx;
+	font-size: 28rpx;
+	font-weight: 500;
+	border-radius: 12rpx;
+	border: none;
+	transition: all 0.2s ease;
+	display: flex;
+	align-items: center;
+	justify-content: center;
+}
+
+/* 鎵爜鎸夐挳 */
+.scan-btn {
+	background-color: #3b82f6;
+	color: #ffffff;
+}
+
+.scan-btn:active {
+	background-color: #2563eb;
+	transform: scale(0.98);
+}
+
+/* 鎻愪氦鎸夐挳 */
+.submit-btn {
+	background-color: #f97316;
+	color: #ffffff;
+}
+
+.submit-btn:active {
+	background-color: #ea580c;
+	transform: scale(0.98);
+}
+
+/* 閫傞厤灏忓睆骞� */
+@media (max-width: 375px) {
+	.material-grid {
+		grid-template-columns: 1fr;
+	}
+	
+	.operate-btn {
+		max-width: 160rpx;
+		height: 72rpx;
+		line-height: 72rpx;
+		font-size: 26rpx;
+	}
+}
+</style>
\ No newline at end of file

--
Gitblit v1.9.1