From 218e046d9339ddf3a729930f6bb7b0b77bbed858 Mon Sep 17 00:00:00 2001
From: lsh <lsh@163.com>
Date: 星期五, 19 十二月 2025 20:01:32 +0800
Subject: [PATCH] 新增并板入库
---
pages/sockroom/sockroom.vue | 1348 ++++++++++++++++++++++++++++++++++++++++-----------------
1 files changed, 942 insertions(+), 406 deletions(-)
diff --git a/pages/sockroom/sockroom.vue b/pages/sockroom/sockroom.vue
index 9f2117f..7d4991d 100644
--- a/pages/sockroom/sockroom.vue
+++ b/pages/sockroom/sockroom.vue
@@ -1,31 +1,32 @@
<template>
<view class="sockpage">
<view class="column">
+ <!-- 鎵樼洏缂栫爜 -->
<view class="form-card">
<view class="form-row">
<view class="label">
<text class="required">*</text>鎵樼洏缂栫爜锛�
</view>
- <view class="picker-wrap" hover-class="picker-hover">
+ <view class="picker-wrap">
<view class="input-box">
<input
- id="pdacode"
- type="text"
- v-model="barcode"
- placeholder="璇锋壂鐮�"
+ type="text"
+ v-model="barcode"
+ placeholder="璇锋壂鐮�"
+ placeholder-class="input-placeholder"
/>
</view>
</view>
</view>
</view>
- <!-- 绠卞瀷鏍忥紙瀵瑰簲鍚庣boxType锛� -->
+ <!-- 绠卞瀷閫夋嫨 -->
<view class="form-card">
<view class="form-row">
<view class="label">
- <text class="required">*</text>绠� 鍨嬶細
+ <text class="required">*</text>绠卞瀷锛�
</view>
- <view class="picker-wrap" hover-class="picker-hover">
+ <view class="picker-wrap">
<picker @change="modePickerChange" :value="index_mode" :range="mode">
<view class="input-box">
<text class="input-placeholder" v-if="!mode.length || !mode[index_mode]">璇烽�夋嫨绠卞瀷</text>
@@ -36,115 +37,236 @@
</view>
</view>
- <view class="form-card">
- <view class="form-row">
- <view class="label">
- <text class="required">*</text>鐗╂枡鐮侊細
- </view>
- <view class="picker-wrap" hover-class="picker-hover">
- <view class="textareainput">
- <textarea
- style="max-height: 15px;overflow: hidden;"
- id="pdacode"
+ <!-- 鐗╂枡鐮佹壂鐮侊紙闅愯棌浣嗗彲鐢級 -->
+ <!-- <view class="form-card" style="height: 0; overflow: hidden; padding: 0; margin: 0;"> -->
+ <view class="form-card" style=" overflow: hidden; padding: 0; margin: 0;">
+ <view class="form-row">
+ <view class="label">
+ <text class="required">*</text>鐗╂枡鐮侊細
+ </view>
+ <view class="picker-wrap">
+ <view class="input-box">
+ <input
type="text"
- v-model="thingCode"
+ v-model="scanBuffer"
placeholder="璇锋壂鐮�"
- @input="handleBarcodeInput"
+ @input="handleMaterialScan"
+ ref="scanInput"
+ />
+ </view>
+ </view>
+ </view>
+ </view>
+
+ <!-- 鐗╂枡淇℃伅 -->
+ <view class="form-card material-card">
+ <view class="card-title">鐗╂枡淇℃伅</view>
+
+ <!-- 澶氱墿鏂欏垪琛� -->
+ <view class="material-list" v-if="matList.length > 0">
+ <view class="material-item" v-for="(mat, index) in matList" :key="mat.id">
+ <view class="material-header">
+ <text class="material-title">鐗╂枡 {{ index + 1 }}</text>
+ <view class="material-actions">
+ <view class="action-btn" @click="removeMaterial(index)">鍒犻櫎</view>
+ </view>
+ </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="mat.position"
+ 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="mat.batch"
+ 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="mat.model"
+ placeholder="璇锋壂鐮佹垨杈撳叆鍗峰彿"
+ placeholder-class="input-placeholder"
+ />
+ </view>
+ <view class="material-item">
+ <text class="material-label">瑙勬牸锛�</text>
+ <input
+ class="material-input"
+ type="text"
+ v-model="mat.matnr"
+ placeholder="璇疯緭鍏ヨ鏍�"
+ placeholder-class="input-placeholder"
+ />
+ </view>
+ <view class="material-item">
+ <text class="material-label">闀垮害锛�</text>
+ <input
+ class="material-input"
+ type="number"
+ v-model="mat.rollExtent"
+ placeholder="璇疯緭鍏ラ暱搴�"
+ placeholder-class="input-placeholder"
+ />
+ </view>
+ <view class="material-item">
+ <text class="material-label">鍑�閲嶏細</text>
+ <input
+ class="material-input"
+ type="number"
+ v-model="mat.weight"
+ placeholder="璇疯緭鍏ュ噣閲�"
+ placeholder-class="input-placeholder"
+ />
+ </view>
+ <view class="material-item">
+ <text class="material-label">姣涢噸锛�</text>
+ <input
+ class="material-input"
+ type="number"
+ v-model="mat.roughWeight"
+ placeholder="璇疯緭鍏ユ瘺閲�"
+ placeholder-class="input-placeholder"
+ />
+ </view>
+ <view class="material-item">
+ <text class="material-label">鎺ュご锛�</text>
+ <input
+ class="material-input"
+ type="number"
+ v-model="mat.joint"
+ placeholder="璇疯緭鍏ユ帴澶存暟"
+ placeholder-class="input-placeholder"
/>
</view>
</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"
- ref="modelInput"
- />
- </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"
- ref="batchInput"
- />
- </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="璇疯緭鍏ラ暱搴�"
- 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="璇疯緭鍏ュ噣閲�"
- 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="璇疯緭鍏ユ瘺閲�"
- 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 class="empty-state" v-else>
+ <view class="empty-icon">馃摝</view>
+ <text class="empty-text">鏆傛棤鐗╂枡淇℃伅</text>
+ <text class="empty-tip">璇锋壂鎻忕墿鏂欑爜娣诲姞鐗╂枡</text>
+ </view>
+
+ <!-- 鎵爜鎸夐挳 -->
+ <view class="scan-btn" @click="focusScanInput">
+ <text class="scan-icon">+</text>
+ <text class="scan-text">鎵爜娣诲姞鐗╂枡</text>
</view>
</view>
+
<!-- 鎿嶄綔鎸夐挳缁� -->
<view class="btn-group">
- <button class="operate-btn submit-btn" @click="submit">鎴愬搧鍏ュ簱</button>
+ <button class="operate-btn submit-btn" @click="submit">缁勬墭</button>
+ </view>
+ </view>
+
+ <!-- 鎵爜纭寮圭獥 -->
+ <view class="modal-mask" v-if="showScanModal" @click="closeModal">
+ <view class="modal-content" @click.stop>
+ <view class="modal-header">
+ <text class="modal-title">鎵爜纭</text>
+ </view>
+ <view class="modal-body">
+ <view class="scan-preview">
+ <text class="scan-label">鎵弿鍒扮墿鏂欙細</text>
+ <text class="scan-code">{{ tempMaterial.model || '鏈煡鐗╂枡' }}</text>
+ </view>
+
+ <view class="preview-grid">
+ <view class="preview-item">
+ <text class="preview-label">绠卞彿锛�</text>
+ <text class="preview-value">{{ tempMaterial.batch || '鏈瘑鍒�' }}</text>
+ </view>
+ <view class="preview-item">
+ <text class="preview-label">鍗峰彿锛�</text>
+ <text class="preview-value">{{ tempMaterial.model || '鏈瘑鍒�' }}</text>
+ </view>
+ <view class="preview-item">
+ <text class="preview-label">瑙勬牸锛�</text>
+ <text class="preview-value">{{ tempMaterial.matnr || '鏈瘑鍒�' }}</text>
+ </view>
+ <view class="preview-item">
+ <text class="preview-label">闀垮害锛�</text>
+ <text class="preview-value">{{ tempMaterial.rollExtent || '鏈瘑鍒�' }}</text>
+ </view>
+ <view class="preview-item">
+ <text class="preview-label">鍑�閲嶏細</text>
+ <text class="preview-value">{{ tempMaterial.weight || '鏈瘑鍒�' }}</text>
+ </view>
+ <view class="preview-item">
+ <text class="preview-label">姣涢噸锛�</text>
+ <text class="preview-value">{{ tempMaterial.roughWeight || '鏈瘑鍒�' }}</text>
+ </view>
+ <view class="preview-item">
+ <text class="preview-label">鎺ュご锛�</text>
+ <text class="preview-value">{{ tempMaterial.joint || '鏈瘑鍒�' }}</text>
+ </view>
+
+ <view class="preview-item full-width">
+ <text class="preview-label">鐗╂枡浣嶇疆锛�</text>
+ <view class="position-selector" @click.stop="togglePositionPicker">
+ <view class="position-display">
+ <text v-if="positionIndex >= 0">{{ positionOptions[positionIndex].label }}</text>
+ <text v-else class="placeholder">璇烽�夋嫨浣嶇疆</text>
+ <text class="position-arrow">鈻�</text>
+ </view>
+ </view>
+ </view>
+
+ <!-- 鏂板锛氳嚜瀹氫箟閫夋嫨鍣ㄥ脊鍑哄眰 -->
+ <view v-if="showPositionPicker" class="custom-picker-overlay" @click.stop="closePositionPicker">
+ <view class="custom-picker-content" @click.stop>
+ <view class="custom-picker-header">
+ <text class="custom-picker-title">閫夋嫨鐗╂枡浣嶇疆</text>
+ <view class="custom-picker-close" @click="closePositionPicker">脳</view>
+ </view>
+ <view class="custom-picker-list">
+ <view
+ v-for="(item, index) in positionOptions"
+ :key="index"
+ class="custom-picker-item"
+ :class="{'selected': positionIndex === index}"
+ @click="selectPosition(index)"
+ >
+ <text class="custom-picker-text">{{ item.label }}</text>
+ <text v-if="positionIndex === index" class="custom-picker-check">鉁�</text>
+ </view>
+ </view>
+ </view>
+ </view>
+ </view>
+ </view>
+ <view class="modal-footer">
+ <button class="modal-btn cancel" @click="cancelAddMaterial">鍙栨秷</button>
+ <button class="modal-btn confirm" @click="confirmAddMaterial">纭畾娣诲姞</button>
+ </view>
</view>
</view>
</view>
</template>
+
<script>
export default {
- onLoad(options){
+ onLoad(options) {
this.checkLoginStatus();
- this.POSTinfo();
+ this.POSTinfo();
},
onShow() {
@@ -158,41 +280,292 @@
}
},
+ onReady() {
+ // 鍦ㄩ〉闈㈠噯澶囧氨缁悗鍒濆鍖栨壂鐮佺洃鍚�
+ setTimeout(() => {
+ this.initScanListener();
+ }, 500);
+ },
+
data() {
return {
- thingCode:'',
- focusState: false,
baseUrl: '',
token: '',
barcode: '',
- palletizingNo: '1',
boxType: '',
- matList: {
- matnr: '',
- maktx: '',
- batch: '',
- model: '',
- position: '1',
- weight: '',
- roughWeight: '',
- anfme: 1.0,
- rollExtent: '',
- joint: 0,
- cutting: 2,
- qualified: 0,
- modelFront: '',
- batchFront: ''
- },
- mode: [],
+ mode: [],
index_mode: 0,
- submitData: {},
+
+ // 鎵爜鐩稿叧
scanBuffer: '',
scanTimeout: null,
- lastScanTime: 0,
- isProcessingScan: false
+
+ // 鐗╂枡鍒楄〃
+ matList: [],
+ materialId: 1,
+
+ // 寮圭獥鐩稿叧
+ showScanModal: false,
+ tempMaterial: {
+ model: '',
+ batch: '',
+ matnr: '',
+ rollExtent: '',
+ weight: '',
+ roughWeight: '',
+ joint: 0,
+ position: '1' // 鏂板锛氱墿鏂欎綅缃紝榛樿鍊间负"1"(宸�)
+ },
+
+ // 鏂板锛氱墿鏂欎綅缃笅鎷夋鐩稿叧鏁版嵁
+ positionIndex: 0, // 榛樿閫変腑绗竴涓�(宸�)
+
+ // 鏂板锛氭帶鍒惰嚜瀹氫箟閫夋嫨鍣ㄦ樉绀�
+ showPositionPicker: false,
+ positionOptions: [
+ { label: '1', value: '1' },
+ { label: '2', value: '2' }
+ ]
}
},
+
methods: {
+ // 鏂板锛氬垏鎹綅缃�夋嫨鍣ㄦ樉绀�
+ togglePositionPicker() {
+ this.showPositionPicker = !this.showPositionPicker;
+ },
+
+ // 鏂板锛氬叧闂綅缃�夋嫨鍣�
+ closePositionPicker() {
+ this.showPositionPicker = false;
+ },
+
+ // 鏂板锛氶�夋嫨浣嶇疆
+ selectPosition(index) {
+ this.positionIndex = index;
+ this.tempMaterial.position = this.positionOptions[index].value;
+ this.closePositionPicker();
+ },
+
+ // 鍒濆鍖栨壂鐮佺洃鍚�
+ initScanListener() {
+ // 鍦╱ni-app涓紝鍙互閫氳繃ref鑾峰彇DOM鑺傜偣锛屼絾瑕佹敞鎰忓钩鍙板樊寮�
+ // 杩欓噷鎴戜滑閫氳繃涓�涓畨鍏ㄧ殑鏂规硶鏉ヨ仛鐒﹁緭鍏ユ
+ this.$nextTick(() => {
+ const input = this.$refs.scanInput;
+ if (input && typeof input.focus === 'function') {
+ input.focus();
+ }
+ });
+ },
+
+ // 鑱氱劍鎵爜杈撳叆妗�
+ focusScanInput() {
+ // 浣跨敤uni-app鐨勫畨鍏ㄦ柟娉�
+ this.$nextTick(() => {
+ const input = this.$refs.scanInput;
+ if (input) {
+ // 鍦╱ni-app涓紝input鍙兘鏄竴涓粍浠跺疄渚�
+ // 鎴戜滑闇�瑕佽幏鍙栧叾DOM鑺傜偣鎴栦娇鐢ㄥ钩鍙扮壒瀹氱殑鏂规硶
+ // 杩欓噷鎴戜滑灏濊瘯璋冪敤focus锛屽鏋滀笉鍙敤鍒欒烦杩�
+ try {
+ if (typeof input.focus === 'function') {
+ input.focus();
+ } else if (input.$el && typeof input.$el.focus === 'function') {
+ // 濡傛灉鏄疺ue缁勪欢瀹炰緥
+ input.$el.focus();
+ }
+ } catch (error) {
+ console.log('鑱氱劍澶辫触锛屼絾涓嶅奖鍝嶅姛鑳�:', error);
+ }
+ }
+ });
+ },
+
+ // 澶勭悊鎵爜杈撳叆
+ handleMaterialScan(e) {
+ const value = e.detail ? e.detail.value : e.target.value;
+
+ // 闃叉姈澶勭悊
+ if (this.scanTimeout) {
+ clearTimeout(this.scanTimeout);
+ }
+
+ this.scanTimeout = setTimeout(() => {
+ if (value && value.trim()) {
+ this.parseBarcodeContent(value.trim());
+ this.showScanModal = true;
+ this.scanBuffer = ''; // 娓呯┖缂撳啿鍖�
+
+ // 姣忔鎵撳紑寮圭獥鏃堕噸缃綅缃�夋嫨涓洪粯璁ゅ��
+ this.positionIndex = 0;
+ this.tempMaterial.position = '1';
+ }
+ }, 300);
+ },
+
+ // 瑙f瀽鏉$爜鍐呭
+ parseBarcodeContent(content) {
+ // const lines = content.split(/\\n/).filter(line => line.trim() !== '');
+ const lines = content.split(' ').filter(line => line.trim().length > 0);
+
+ // 娓呯┖涓存椂鏁版嵁
+ this.tempMaterial = {
+ model: '',
+ batch: '',
+ matnr: '',
+ rollExtent: '',
+ weight: '',
+ roughWeight: '',
+ joint: 0,
+ position: '1' // 閲嶇疆浣嶇疆涓洪粯璁ゅ��
+ };
+
+ // 浣跨敤姝e垯琛ㄨ揪寮忔彁鍙栭敭鍊煎[6,7](@ref)
+ const extractKeyValue = (line) => {
+ const match = line.match(/([^锛歖+)锛�(.+)/);
+ if (match && match.length === 3) {
+ return {
+ key: match[1].trim(),
+ value: match[2].trim()
+ };
+ }
+ return null;
+ };
+
+ // 鎻愬彇鏁板瓧锛堝寘鎷皬鏁帮級[6,7](@ref)
+ const extractNumber = (str) => {
+ const match = str.match(/[\d.]+/);
+ return match ? match[0] : '';
+ };
+
+ // 閬嶅巻姣忎竴琛岋紝瑙f瀽閿�煎
+ lines.forEach(line => {
+ const keyValue = extractKeyValue(line);
+ if (keyValue) {
+ const { key, value } = keyValue;
+
+ switch (key) {
+ case '鍗峰彿':
+ this.tempMaterial.model = value;
+ break;
+ case '绠卞彿':
+ this.tempMaterial.batch = value;
+ break;
+ case '瑙勬牸':
+ this.tempMaterial.matnr = value;
+ break;
+ case '闀垮害':
+ this.tempMaterial.rollExtent = extractNumber(value);
+ break;
+ case '鍑�閲�':
+ this.tempMaterial.weight = extractNumber(value);
+ break;
+ case '姣涢噸':
+ this.tempMaterial.roughWeight = extractNumber(value);
+ break;
+ case '鎺ュご':
+ this.tempMaterial.joint = extractNumber(value) || 0;
+ break;
+ default:
+ // 鍙互澶勭悊鏈煡閿垨蹇界暐
+ break;
+ }
+ }
+ });
+ },
+
+ // 纭娣诲姞鐗╂枡
+ confirmAddMaterial() {
+ this.closePositionPicker();
+ if (!this.tempMaterial.model) {
+ uni.showToast({
+ title: '鍗峰彿涓嶈兘涓虹┖',
+ icon: 'none'
+ });
+ return;
+ }
+
+ // 妫�鏌ユ槸鍚﹀凡瀛樺湪鐩稿悓鐗╂枡
+ const exists = this.matList.some(item =>
+ item.model === this.tempMaterial.model &&
+ item.batch === this.tempMaterial.batch
+ );
+
+ if (exists) {
+ uni.showToast({
+ title: '璇ョ墿鏂欏凡瀛樺湪',
+ icon: 'none'
+ });
+ this.closeModal();
+ return;
+ };
+
+ // 娣诲姞鍒扮墿鏂欏垪琛�
+ const newMaterial = {
+ id: this.materialId++,
+ ...this.tempMaterial,
+ position: (this.matList.length + 1).toString(),
+ cutting: 2,
+ qualified: 0
+ };
+
+ this.matList.push(newMaterial);
+
+ uni.showToast({
+ title: '鐗╂枡娣诲姞鎴愬姛',
+ icon: 'success'
+ });
+
+ this.closeModal();
+ },
+
+ // 鍙栨秷娣诲姞
+ cancelAddMaterial() {
+ this.closeModal();
+ },
+
+ // 鍏抽棴寮圭獥
+ closeModal() {
+ this.showPositionPicker = false;
+ this.showScanModal = false;
+ this.tempMaterial = {
+ model: '',
+ batch: '',
+ matnr: '',
+ rollExtent: '',
+ weight: '',
+ roughWeight: '',
+ joint: 0,
+ position: '1' // 閲嶇疆浣嶇疆
+ };
+
+ // 閲嶇疆浣嶇疆閫夋嫨
+ this.positionIndex = 0;
+
+ // 閲嶆柊鑱氱劍鍒版壂鐮佽緭鍏ユ
+ setTimeout(() => {
+ this.focusScanInput();
+ }, 100);
+ },
+
+ // 鍒犻櫎鐗╂枡
+ removeMaterial(index) {
+ uni.showModal({
+ title: '纭鍒犻櫎',
+ content: '纭畾瑕佸垹闄よ繖涓墿鏂欏悧锛�',
+ success: (res) => {
+ if (res.confirm) {
+ this.matList.splice(index, 1);
+ uni.showToast({
+ title: '鍒犻櫎鎴愬姛',
+ icon: 'success'
+ });
+ }
+ }
+ });
+ },
+
// 妫�鏌ョ櫥褰曠姸鎬�
checkLoginStatus() {
this.token = uni.getStorageSync('token');
@@ -217,7 +590,7 @@
},
// 鑾峰彇绠卞瀷鏁版嵁
- POSTinfo(){
+ POSTinfo() {
if (!this.checkLoginStatus()) return;
uni.showLoading({
@@ -233,27 +606,14 @@
},
success: (res) => {
uni.hideLoading();
- console.log('绠卞瀷鎺ュ彛杩斿洖:', res.data);
- if (res.data && res.data.code === 200) {
- if (Array.isArray(res.data.data)) {
- // 灏濊瘯澶氱鍙兘鐨勫瓧娈靛悕
- this.mode = res.data.data
- .map(item => item.boxSpecs || item.boxType || item.typeName || item.name || '')
- .filter(item => item && item.trim() !== '');
-
- console.log('鎻愬彇鐨勭鍨嬪垪琛�:', this.mode);
-
- if (this.mode.length === 0) {
- uni.showToast({
- title: '鏃犲彲鐢ㄧ鍨�',
- icon: 'none'
- });
- }
- } else {
- console.warn('杩斿洖鏁版嵁鏍煎紡涓嶇锛屼笉鏄暟缁�:', res.data.data);
+ if (res.data && res.data.code === 200 && Array.isArray(res.data.data)) {
+ this.mode = res.data.data
+ .map(item => item.boxSpecs || item.boxType || item.typeName || item.name || '')
+ .filter(item => item && item.trim() !== '');
+ if (this.mode.length === 0) {
uni.showToast({
- title: '鏁版嵁鏍煎紡閿欒',
+ title: '鏃犲彲鐢ㄧ鍨�',
icon: 'none'
});
}
@@ -274,185 +634,63 @@
}
});
},
+
modePickerChange(e) {
this.index_mode = e.detail.value;
this.boxType = this.mode[this.index_mode];
- console.log('閫夋嫨鐨勭鍨�:', this.boxType);
- },
-
- handleBarcodeInput(e) {
- // 鍦╱ni-app涓紝textarea鐨刬nput浜嬩欢鍙兘鏄痚.detail.value
- const value = e.detail ? e.detail.value : e.target.value;
- this.thingCode = value;
- this.parseBarcodeContent(value);
- },
-
- parseBarcodeContent(content) {
- if (!content) return;
-
- // 鎸夎鍒嗗壊鍐呭
- const lines = content.split('\n').filter(line => line.trim() !== '');
-
- console.log('瑙f瀽鐨勮鏁版嵁:', lines);
-
- // 鏍规嵁浣犳彁渚涚殑鏍蜂緥鏍煎紡瑙f瀽
- // 鏍煎紡涓�:
- // 2511080305A22B6 (鍗峰彿)
- // Y251113764 (绠卞彿)
- // 5渭m脳1050mm (瑙勬牸)
- // 8700 m (闀垮害)
- // 418.0 kg (鍑�閲�)
- // 441.0 kg (姣涢噸)
- // 0 涓� (鎺ュご)
-
- if (lines.length >= 7) {
- // 鍗峰彿 (绗竴琛�)
- this.matList.model = lines[0].trim();
-
- // 绠卞彿 (绗簩琛�)
- this.matList.batch = lines[1].trim();
-
- // 瑙勬牸 (绗笁琛�)
- this.matList.matnr = lines[2].trim();
-
- // 闀垮害 (绗洓琛�) - 鎻愬彇鏁板瓧閮ㄥ垎
- const lengthMatch = lines[3].match(/([\d.]+)/);
- if (lengthMatch) {
- this.matList.rollExtent = lengthMatch[1];
- }
-
- // 鍑�閲� (绗簲琛�) - 鎻愬彇鏁板瓧閮ㄥ垎
- const weightMatch = lines[4].match(/([\d.]+)/);
- if (weightMatch) {
- this.matList.weight = weightMatch[1];
- }
-
- // 姣涢噸 (绗叚琛�) - 鎻愬彇鏁板瓧閮ㄥ垎
- const roughWeightMatch = lines[5].match(/([\d.]+)/);
- if (roughWeightMatch) {
- this.matList.roughWeight = roughWeightMatch[1];
- }
-
- // 鎺ュご (绗竷琛�) - 鎻愬彇鏁板瓧閮ㄥ垎
- const jointMatch = lines[6].match(/([\d.]+)/);
- if (jointMatch) {
- this.matList.joint = jointMatch[1];
- }
-
- console.log('瑙f瀽鍚庣殑鏁版嵁:', this.matList);
- } else if (lines.length > 0) {
- // 濡傛灉琛屾暟涓嶅锛屼篃鍙互灏濊瘯鏅鸿兘鍖归厤
- this.autoMatchFields(lines);
- }
- },
-
- // 鏅鸿兘鍖归厤鏂规硶锛岀敤浜庡鐞嗗彲鑳界殑涓嶈鍒欐暟鎹�
- autoMatchFields(lines) {
- lines.forEach((line, index) => {
- line = line.trim();
-
- // 鏍规嵁鍐呭鐗瑰緛鍖归厤
- if (index === 0 && !this.matList.model) {
- // 鍋囪绗竴琛屾�绘槸鍗峰彿
- this.matList.model = line;
- } else if (index === 1 && !this.matList.batch) {
- // 鍋囪绗簩琛屾�绘槸绠卞彿
- this.matList.batch = line;
- } else if (line.includes('渭m') || line.includes('mm') || line.includes('脳')) {
- // 鍖呭惈瑙勬牸鐗瑰緛鐨�
- this.matList.matnr = line;
- } else if (line.includes('m') && line.match(/[\d.]+ m/)) {
- // 闀垮害鐗瑰緛
- const match = line.match(/([\d.]+)/);
- if (match) this.matList.rollExtent = match[1];
- } else if (line.includes('kg') && line.match(/[\d.]+ kg/)) {
- // 閲嶉噺鐗瑰緛锛岄渶瑕佸尯鍒嗗噣閲嶅拰姣涢噸
- const match = line.match(/([\d.]+)/);
- if (match) {
- const weightValue = match[1];
- if (!this.matList.weight) {
- this.matList.weight = weightValue;
- } else if (!this.matList.roughWeight) {
- this.matList.roughWeight = weightValue;
- }
- }
- } else if (line.includes('涓�') && line.match(/[\d.]+ 涓�/)) {
- // 鎺ュご鐗瑰緛
- const match = line.match(/([\d.]+)/);
- if (match) this.matList.joint = match[1];
- }
- });
- },
- // 閲嶇疆琛ㄥ崟
- resetForm() {
- this.barcode = '';
- this.boxType = '';
- this.index_mode = 0;
- this.matList = {
- matnr: '',
- maktx: '',
- batch: '',
- model: '',
- position: '1',
- weight: '',
- roughWeight: '',
- anfme: 1.0,
- rollExtent: '',
- joint: 0,
- cutting: 2,
- qualified: 0,
- modelFront: '',
- batchFront: ''
- };
- this.scanBuffer = '';
- this.focusState = false;
},
// 鎻愪氦鏁版嵁
submit() {
- // 1. 楠岃瘉鐧诲綍
if (!this.checkLoginStatus()) return;
- // 2. 楠岃瘉蹇呭~椤�
+ // 楠岃瘉蹇呭~椤�
if (!this.barcode) {
uni.showToast({title: '璇锋壂鎻忔墭鐩樼紪鐮�', icon: 'none'});
return;
}
-
+
+ this.boxType = 999;
if (!this.boxType) {
uni.showToast({title: '璇烽�夋嫨绠卞瀷', icon: 'none'});
return;
}
- if (!this.matList.model) {
- uni.showToast({title: '璇峰~鍐欏嵎鍙�', icon: 'none'});
+ if (this.matList.length === 0) {
+ uni.showToast({title: '璇疯嚦灏戞坊鍔犱竴涓墿鏂�', icon: 'none'});
return;
}
- if (!this.matList.batch) {
- uni.showToast({title: '璇峰~鍐欑鍙�', icon: 'none'});
- return;
+ // 楠岃瘉姣忎釜鐗╂枡鐨勫繀濉瓧娈�
+ for (let i = 0; i < this.matList.length; i++) {
+ const mat = this.matList[i];
+ if (!mat.model) {
+ uni.showToast({title: `鐗╂枡${i+1}鍗峰彿涓嶈兘涓虹┖`, icon: 'none'});
+ return;
+ }
+ if (!mat.batch) {
+ uni.showToast({title: `鐗╂枡${i+1}绠卞彿涓嶈兘涓虹┖`, icon: 'none'});
+ return;
+ }
}
- // 3. 鍑嗗鏁版嵁
- 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
- };
-
+ // 鍑嗗鎻愪氦鏁版嵁
const submitData = {
barcode: this.barcode,
- palletizingNo: this.palletizingNo,
boxType: this.boxType,
- matList: [matItem]
+ matList: this.matList.map(mat => ({
+ ...mat,
+ weight: mat.weight ? Number(mat.weight) : null,
+ roughWeight: mat.roughWeight ? Number(mat.roughWeight) : null,
+ rollExtent: mat.rollExtent ? Number(mat.rollExtent) : null,
+ joint: mat.joint ? Number(mat.joint) : 0,
+ position: mat.position // 鍖呭惈浣嶇疆淇℃伅
+ }))
};
console.log('鎻愪氦鏁版嵁:', submitData);
- // 4. 鍙戦�佽姹�
+ // 鍙戦�佽姹�
uni.showLoading({
title: '鎻愪氦涓�...',
mask: true
@@ -468,7 +706,6 @@
data: submitData,
success: (res) => {
uni.hideLoading();
- console.log('鎻愪氦杩斿洖:', res.data);
if (res.data.code === 200) {
uni.showToast({
@@ -477,12 +714,13 @@
duration: 2000
});
+ // 娓呯┖琛ㄥ崟
setTimeout(() => {
this.resetForm();
}, 1500);
} else {
uni.showToast({
- title: res.data.message || '鎻愪氦澶辫触',
+ title: res.data.msg || '鎻愪氦澶辫触',
icon: 'none'
});
}
@@ -497,212 +735,510 @@
}
});
},
+
+ // 閲嶇疆琛ㄥ崟
+ resetForm() {
+ this.barcode = '';
+ this.boxType = '';
+ this.index_mode = 0;
+ this.matList = [];
+ this.materialId = 1;
+ }
}
}
</script>
<style scoped>
-/* 鍏ㄥ眬鏍峰紡 */
+
+/* 鐗╂枡浣嶇疆閫夋嫨鍣ㄦ牱寮� */
+.full-width {
+ grid-column: 1 / -1; /* 鍗犳弧鏁磋 */
+ margin-top: 8rpx;
+ position: relative;
+ z-index: 100; /* 纭繚鍦ㄥ脊绐楀唴閮ㄥ眰绾ф甯� */
+}
+
+.position-selector {
+ width: 200rpx;
+ display: flex;
+ justify-content: flex-end;
+}
+
+.position-picker {
+ width: 200rpx;
+}
+
+.position-display {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ padding: 8rpx 16rpx;
+ border: 1rpx solid #e5e7eb;
+ border-radius: 6rpx;
+ background-color: #ffffff;
+ color: #333;
+ font-size: 28rpx;
+ min-height: 40rpx;
+ width: 100%;
+ box-sizing: border-box;
+}
+
+.placeholder {
+ color: #999;
+}
+
+.position-arrow {
+ font-size: 20rpx;
+ color: #666;
+ margin-left: 8rpx;
+}
+/* 鍏ㄥ眬鏍峰紡 - 淇濇寔鍘熸湁椋庢牸 */
.sockpage {
background-color: #f5f7fa;
- padding: 24rpx;
+ padding: 20rpx;
min-height: 100vh;
}
-/* 琛ㄥ崟鍒楀鍣� */
.column {
display: flex;
flex-direction: column;
- gap: 24rpx;
+ gap: 20rpx;
}
-/* 琛ㄥ崟鍗$墖 */
.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;
-}
-.textareainput{
- width: 60%;
- height: 15px;
- font-size: 28rpx;
- padding: 16rpx 12rpx;
- border: 1rpx solid #e5e7eb;
border-radius: 8rpx;
- transition: border-color 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;
+ padding: 20rpx;
+ box-shadow: 0 2rpx 6rpx rgba(0, 0, 0, 0.1);
}
-/* 琛ㄥ崟琛� */
.form-row {
display: flex;
- flex-direction: row;
align-items: center;
- gap: 16rpx;
+ gap: 20rpx;
}
-/* 鏍囩鏍峰紡 */
.label {
font-size: 28rpx;
- color: #374151;
+ color: #333;
font-weight: 500;
min-width: 140rpx;
}
-/* 蹇呭~椤规爣绾� */
.required {
- color: #ef4444;
+ color: #e64340;
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;
+ border-radius: 6rpx;
+ padding: 16rpx 20rpx;
+ background: #fff;
}
-.input-box:focus-within {
- border-color: #f97316;
+.input-placeholder {
+ color: #999;
+ font-size: 28rpx;
}
-/* 杈撳叆鍊兼牱寮� */
.input-value {
- color: #1f2937;
+ color: #333;
+ font-size: 28rpx;
}
-/* 鎵爜鍥炬爣 */
-.scan-icon {
+/* 鐗╂枡淇℃伅鍗$墖 */
+.material-card {
+ padding: 0;
+}
+
+.card-title {
+ font-size: 30rpx;
+ font-weight: 500;
+ color: #333;
+ padding: 20rpx 20rpx 16rpx;
+ border-bottom: 1rpx solid #f0f0f0;
+}
+
+/* 鐗╂枡鍒楄〃 */
+.material-list {
+ padding: 0 20rpx;
+}
+
+.material-item {
+ margin-bottom: 20rpx;
+}
+
+.material-header {
+ display: flex;
+ justify-content: space-between;
+ align-items: center;
+ margin-bottom: 16rpx;
+ padding-bottom: 12rpx;
+ border-bottom: 1rpx solid #f0f0f0;
+}
+
+.material-title {
+ font-size: 28rpx;
+ font-weight: 500;
+ color: #333;
+}
+
+.material-actions {
+ display: flex;
+ gap: 20rpx;
+}
+
+.action-btn {
font-size: 24rpx;
- margin-left: 8rpx;
- color: #6b7280;
+ color: #e64340;
+ padding: 6rpx 12rpx;
+ border-radius: 4rpx;
+ background: #fff0f0;
}
-/* 鐗╂枡淇℃伅缃戞牸甯冨眬 */
+/* 鐗╂枡缃戞牸 */
.material-grid {
display: grid;
grid-template-columns: repeat(2, 1fr);
- gap: 20rpx;
- padding: 24rpx;
+ gap: 16rpx;
}
-/* 鐗╂枡淇℃伅椤� */
.material-item {
display: flex;
flex-direction: column;
gap: 8rpx;
}
-/* 鐗╂枡鏍囩 */
.material-label {
font-size: 26rpx;
- color: #4b5563;
+ color: #666;
}
-/* 鐗╂枡杈撳叆妗� */
.material-input {
- width: 45%;
font-size: 28rpx;
- color: #1f2937;
- padding: 16rpx 12rpx;
+ color: #333;
+ padding: 12rpx;
border: 1rpx solid #e5e7eb;
- border-radius: 8rpx;
+ border-radius: 6rpx;
background-color: #ffffff;
- transition: border-color 0.2s ease;
}
-.material-input:focus {
- border-color: #f97316;
- outline: none;
+/* 绌虹姸鎬� */
+.empty-state {
+ text-align: center;
+ padding: 40rpx 20rpx;
}
-/* 鎸夐挳缁� */
-.btn-group {
- display: flex;
- gap: 20rpx;
- justify-content: center;
- margin-top: 16rpx;
- padding: 8rpx 0;
+.empty-icon {
+ font-size: 60rpx;
+ display: block;
+ margin-bottom: 20rpx;
+ opacity: 0.5;
}
-/* 鎿嶄綔鎸夐挳閫氱敤鏍峰紡 */
-.operate-btn {
- flex: 1;
- max-width: 200rpx;
- height: 80rpx;
- line-height: 80rpx;
+.empty-text {
+ display: block;
font-size: 28rpx;
- font-weight: 500;
- border-radius: 12rpx;
- border: none;
- transition: all 0.2s ease;
- display: flex;
- align-items: center;
- justify-content: center;
+ color: #999;
+ margin-bottom: 10rpx;
+}
+
+.empty-tip {
+ display: block;
+ font-size: 24rpx;
+ color: #ccc;
}
/* 鎵爜鎸夐挳 */
.scan-btn {
- background-color: #3b82f6;
- color: #ffffff;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ gap: 10rpx;
+ padding: 20rpx;
+ margin: 20rpx 20rpx 20rpx;
+ background: #f0f7ff;
+ border: 1rpx dashed #1989fa;
+ border-radius: 8rpx;
+ color: #1989fa;
+ font-size: 28rpx;
}
-.scan-btn:active {
- background-color: #2563eb;
- transform: scale(0.98);
+.scan-icon {
+ font-size: 36rpx;
+ font-weight: bold;
}
-/* 鎻愪氦鎸夐挳 */
-.submit-btn {
- background-color: #f97316;
- color: #ffffff;
+/* 鎸夐挳缁� */
+.btn-group {
+ margin-top: 20rpx;
+ padding: 8rpx 0;
+ text-align: center;
}
-.submit-btn:active {
- background-color: #ea580c;
- transform: scale(0.98);
+.operate-btn {
+ width: 200rpx;
+ height: 80rpx;
+ line-height: 80rpx;
+ font-size: 30rpx;
+ font-weight: 500;
+ border-radius: 8rpx;
+ border: none;
+ background: #333;
+ color: #fff;
}
-/* 閫傞厤灏忓睆骞� */
-@media (max-width: 375px) {
+/* 寮圭獥鏍峰紡 */
+.modal-mask {
+ position: fixed;
+ top: 0;
+ left: 0;
+ right: 0;
+ bottom: 0;
+ background: rgba(0, 0, 0, 0.5);
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ z-index: 1000;
+}
+
+.modal-content {
+ background: #fff;
+ border-radius: 12rpx;
+ width: 600rpx;
+ max-width: 90%;
+ overflow: hidden;
+}
+
+.modal-header {
+ padding: 30rpx 30rpx 20rpx;
+ border-bottom: 1rpx solid #f0f0f0;
+}
+
+.modal-title {
+ font-size: 32rpx;
+ font-weight: 500;
+ color: #333;
+}
+
+.modal-body {
+ padding: 30rpx;
+}
+
+.scan-preview {
+ margin-bottom: 20rpx;
+ padding-bottom: 20rpx;
+ border-bottom: 1rpx solid #f0f0f0;
+}
+
+.scan-label {
+ font-size: 28rpx;
+ color: #666;
+ display: block;
+ margin-bottom: 10rpx;
+}
+
+.scan-code {
+ font-size: 32rpx;
+ color: #333;
+ font-weight: bold;
+ word-break: break-all;
+}
+
+.preview-grid {
+ display: grid;
+ grid-template-columns: repeat(2, 1fr);
+ gap: 15rpx;
+}
+
+.preview-item {
+ display: flex;
+ justify-content: space-between;
+ align-items: center;
+}
+
+.preview-label {
+ font-size: 28rpx;
+ color: #666;
+}
+
+.preview-value {
+ font-size: 28rpx;
+ color: #333;
+ font-weight: 500;
+}
+
+.modal-footer {
+ display: flex;
+ border-top: 1rpx solid #f0f0f0;
+}
+
+.modal-btn {
+ flex: 1;
+ height: 90rpx;
+ line-height: 90rpx;
+ font-size: 30rpx;
+ border: none;
+ background: transparent;
+ border-radius: 0;
+}
+
+.modal-btn.cancel {
+ color: #999;
+ border-right: 1rpx solid #f0f0f0;
+}
+
+.modal-btn.confirm {
+ color: #1989fa;
+ font-weight: 500;
+}
+
+/* 鑷畾涔夐�夋嫨鍣ㄦ牱寮� */
+.custom-picker-overlay {
+ position: fixed;
+ top: 0;
+ left: 0;
+ right: 0;
+ bottom: 0;
+ background-color: rgba(0, 0, 0, 0.5);
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ z-index: 9999; /* 纭繚鍦ㄦ渶涓婂眰 */
+}
+
+.custom-picker-content {
+ background-color: #ffffff;
+ border-radius: 12rpx;
+ width: 600rpx;
+ max-width: 80%;
+ max-height: 70vh;
+ overflow: hidden;
+ box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.15);
+ animation: fadeIn 0.3s ease;
+}
+
+@keyframes fadeIn {
+ from {
+ opacity: 0;
+ transform: translateY(20rpx);
+ }
+ to {
+ opacity: 1;
+ transform: translateY(0);
+ }
+}
+
+.custom-picker-header {
+ display: flex;
+ justify-content: space-between;
+ align-items: center;
+ padding: 30rpx;
+ border-bottom: 1rpx solid #f0f0f0;
+}
+
+.custom-picker-title {
+ font-size: 32rpx;
+ font-weight: 500;
+ color: #333;
+}
+
+.custom-picker-close {
+ font-size: 40rpx;
+ color: #999;
+ line-height: 1;
+ padding: 0 10rpx;
+ cursor: pointer;
+}
+
+.custom-picker-list {
+ max-height: 50vh;
+ overflow-y: auto;
+ padding: 0;
+}
+
+.custom-picker-item {
+ display: flex;
+ justify-content: space-between;
+ align-items: center;
+ padding: 25rpx 30rpx;
+ border-bottom: 1rpx solid #f5f5f5;
+ cursor: pointer;
+ transition: background-color 0.2s;
+}
+
+.custom-picker-item:last-child {
+ border-bottom: none;
+}
+
+.custom-picker-item:hover {
+ background-color: #f8f9fa;
+}
+
+.custom-picker-item.selected {
+ background-color: #f0f7ff;
+ color: #1989fa;
+}
+
+.custom-picker-text {
+ font-size: 30rpx;
+}
+
+.custom-picker-check {
+ font-size: 28rpx;
+ color: #1989fa;
+ font-weight: bold;
+}
+
+/* 寮圭獥鏍峰紡璋冩暣锛岀‘淇濆眰绾у叧绯� */
+.modal-mask {
+ position: fixed;
+ top: 0;
+ left: 0;
+ right: 0;
+ bottom: 0;
+ background: rgba(0, 0, 0, 0.5);
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ z-index: 1000; /* 寮圭獥鍩虹灞傜骇 */
+}
+
+.modal-content {
+ position: relative; /* 纭繚瀛愬厓绱犵浉瀵瑰畾浣� */
+ z-index: 1001; /* 姣旇挋鐗堥珮涓�绾� */
+ background: #fff;
+ border-radius: 12rpx;
+ width: 600rpx;
+ max-width: 90%;
+ overflow: visible; /* 鏀逛负 visible 鍏佽閫夋嫨鍣ㄥ脊鍑� */
+}
+
+/* 鍝嶅簲寮忛�傞厤 */
+@media (max-width: 750rpx) {
.material-grid {
grid-template-columns: 1fr;
}
- .operate-btn {
- max-width: 160rpx;
- height: 72rpx;
- line-height: 72rpx;
- font-size: 26rpx;
+ .preview-grid {
+ grid-template-columns: 1fr;
+ }
+
+ .modal-content {
+ width: 90%;
+ }
+ .custom-picker-content {
+ width: 90%;
+ max-width: 90%;
+ }
+
+ .custom-picker-item {
+ padding: 20rpx 25rpx;
}
}
</style>
\ No newline at end of file
--
Gitblit v1.9.1