From 960b33fa24c47a330e51a2c24859d681ae62caeb Mon Sep 17 00:00:00 2001
From: huangxiaoqiang <huangxiaoqiang@hnkhzn.com>
Date: 星期四, 16 四月 2026 10:09:49 +0800
Subject: [PATCH] 重构任务与库存模型,增强日志管理与区域接口

---
 Code Management/PDA-FG/pages/Outbound/Outbound.vue |  204 +++++++++++++++++++++++++++++++++++++++++++--------
 1 files changed, 172 insertions(+), 32 deletions(-)

diff --git a/Code Management/PDA-FG/pages/Outbound/Outbound.vue b/Code Management/PDA-FG/pages/Outbound/Outbound.vue
index 382140d..4558b64 100644
--- a/Code Management/PDA-FG/pages/Outbound/Outbound.vue
+++ b/Code Management/PDA-FG/pages/Outbound/Outbound.vue
@@ -2,74 +2,214 @@
 	<view>
 		<uni-segmented-control :current="current" :values="items" @clickItem="onClickItem">
 		</uni-segmented-control>
+		
 		<view v-show="current === 0">
 			<view style="padding: 5%;">
-				<uni-forms label-width="120">
-					<uni-forms-item label="鍑哄簱鍖哄煙">
-						<uni-data-select :focus="!istrue" v-model="AreaId" :localdata="range"
-							placeholder="璇疯緭閫夋嫨缁堢偣鍖哄煙"></uni-data-select>
+				<uni-forms label-width="120">					
+					<!-- <uni-forms-item label="鍑哄簱鍖哄煙">
+						<picker mode="selector" :range="areaNames" @change="onAreaChange">
+							<view style="padding: 10px; background-color: #fff; border: 1px solid #dcdfe6; border-radius: 4px; min-height: 16px; line-height: 16px;">
+								{{ selectedAreaName || '璇烽�夋嫨鍑哄簱鍖哄煙' }}
+							</view>
+						</picker>
+					</uni-forms-item> -->
+					<uni-forms-item label="鍑哄簱璧风偣">
+						<uni-easyinput type="text" v-model="SourceAddress" placeholder="璇疯緭鍏ュ嚭搴撹捣鐐�"
+							ref="targetInput" />
 					</uni-forms-item>
 					<uni-forms-item label="鍑哄簱缁堢偣">
-						<uni-easyinput type="text" :focus="addressFocus" v-model="TargetAddress" placeholder="璇疯緭鍏ヨ捣鐐�"
-							ref='midInput' />
+						<uni-easyinput type="text" v-model="TargetAddress" placeholder="璇疯緭鍏ュ嚭搴撶粓鐐�"
+							ref="targetInput" />
 					</uni-forms-item>
 				</uni-forms>
-				<button @click="InboundTask" type="primary" size="default" style="margin-top: 2%;">鍑哄簱</button>
+				
+				<button @click="outboundTask" type="primary" size="default" style="margin-top: 2%;" :disabled="isLoading">
+					{{ isLoading ? '澶勭悊涓�...' : '鍑哄簱' }}
+				</button>
 			</view>
 		</view>
+		
 		<u-toast ref="luToast" />
 	</view>
 </template>
 
 <script>
 	const innerAudioContext = uni.createInnerAudioContext();
+	
 	export default {
 		data() {
 			return {
-				barcodeFocus:true,
-				PalletCode: "",
+				// 琛ㄥ崟鏁版嵁
+				SourceAddress:"",
+				TargetAddress: "",
+				AreaId: "",
+				selectedAreaName: "",
+				
+				// 鍖哄煙鏁版嵁
+				areaList: [],      // 鍘熷鍖哄煙鏁版嵁 [{id, name}]
+				areaNames: [],     // 鍖哄煙鍚嶇О鏁扮粍锛堢敤浜巔icker鏄剧ず锛�
+				
+				// UI鎺у埗
 				items: ['鍑哄簱'],
-				current: 0
+				current: 0,
+				barcodeFocus: true,
+				addressFocus: false,
+				isLoading: false,   // 鍔犺浇鐘舵��
 			}
 		},
+		
 		onLoad() {
-			
+			this.QueryAreaInfo();
+			// 鑷姩鑱氱劍鍒版墭鐩樻潯鐮佽緭鍏ユ
+			setTimeout(() => {
+				this.barcodeFocus = true;
+			}, 100);
 		},
+		
 		methods: {
+			// 鍒嗘閫夋嫨鍣ㄧ偣鍑讳簨浠�
 			onClickItem(e) {
-				if (this.current != e.currentIndex) {
+				if (this.current !== e.currentIndex) {
 					this.current = e.currentIndex;
 				}
 			},
+			
+			// 鎾斁璇煶鎻愮ず
 			voiceSpeech(src) {
-				innerAudioContext.src = src; // '../../static/success.mp3';
+				innerAudioContext.src = src;
 				innerAudioContext.play();
 			},
-			InboundTask() {
-				if (this.PalletCode.length <= 0) {
-					this.$refs.luToast.show({
-						title: "鎵樼洏鏉$爜涓嶈兘涓虹┖",
-						type: "error"
-					})
-					return;
-				}
-				this.$u.post('/api/Task/OutBoundTaskAsync?palletCode='+this.PalletCode+'&remark=""').then(res => {
-					if (res.status) {
-						this.$refs.luToast.show({
-							title: res.message,
-							type: "success"
-						})
-						this.PalletCode = "";
-						this.barcodeFocus=true;
+			
+			// 鏌ヨ鍖哄煙淇℃伅
+			QueryAreaInfo() {
+				this.$u.post('/api/Dt_AreaInfo/QueryAreaInfo').then(res => {
+					if (res.status && res.data && Array.isArray(res.data)) {
+						this.areaList = res.data;
+						this.areaNames = this.areaList.map(item => item.name);
+						
+						// 鍙�夛細鏄剧ず鍔犺浇鎴愬姛鎻愮ず锛堥潤榛樺姞杞斤紝涓嶅脊toast锛�
+						console.log('鍖哄煙鏁版嵁鍔犺浇鎴愬姛', this.areaList);
 					} else {
 						this.$refs.luToast.show({
-							title: res.message,
+							title: res.message || "鍔犺浇鍖哄煙鏁版嵁澶辫触",
 							type: "error"
-						})
+						});
 					}
-				})
+				}).catch(err => {
+					console.error('QueryAreaInfo error:', err);
+					this.$refs.luToast.show({
+						title: "缃戠粶璇锋眰澶辫触锛岃妫�鏌ョ綉缁�",
+						type: "error"
+					});
+				});
 			},
+			
+			// 鍖哄煙閫夋嫨浜嬩欢
+			onAreaChange(e) {
+				const index = e.detail.value;
+				if (this.areaList[index]) {
+					this.selectedAreaName = this.areaList[index].name;
+					this.AreaId = this.areaList[index].id;
+				}
+			},
+			
+			// 鍑哄簱浠诲姟
+			outboundTask() {
+				// 1. 琛ㄥ崟楠岃瘉
+				if (!this.TargetAddress || this.TargetAddress.trim() === "") {
+					this.$refs.luToast.show({
+						title: "鍑哄簱缁堢偣鐐逛笉鑳戒负绌�",
+						type: "error"
+					});
+					// 閲嶆柊鑱氱劍
+					this.barcodeFocus = true;
+					return;
+				}
+				if (!this.SourceAddress || this.SourceAddress.trim() === "") {
+					this.$refs.luToast.show({
+						title: "鍑哄簱璧风偣涓嶈兘涓虹┖",
+						type: "error"
+					});
+					// 閲嶆柊鑱氱劍
+					this.barcodeFocus = true;
+					return;
+				}
+				// 鍙�夛細楠岃瘉鍑哄簱鍖哄煙
+				// if (!this.AreaId) {
+				// 	this.$refs.luToast.show({
+				// 		title: "璇烽�夋嫨鍑哄簱鍖哄煙",
+				// 		type: "error"
+				// 	});
+				// 	return;
+				// }
+				
+				// 闃叉閲嶅鎻愪氦
+				if (this.isLoading) return;
+				this.isLoading = true;
+				
+				// 鏋勫缓璇锋眰鍙傛暟
+				const params = {
+					Position: this.SourceAddress.trim(),
+					TargetAddress: this.TargetAddress,
+					// AreaId: this.AreaId,
+				};
+				
+				// 鍙戦�佽姹�
+				this.$u.post('/api/Task/RequestOutboundTaskAsync', params).then(res => {
+					this.isLoading = false;
+					
+					if (res.status) {
+						this.$refs.luToast.show({
+							title: res.message || "鍑哄簱浠诲姟鍒涘缓鎴愬姛",
+							type: "success"
+						});
+						
+						// 鎾斁鎴愬姛鎻愮ず闊�
+						this.voiceSpeech('../../static/success.mp3');
+						
+						// 閲嶇疆琛ㄥ崟
+						this.SourceAddress = "";
+						this.TargetAddress = "";
+						// 淇濈暀鍖哄煙閫夋嫨锛屼笉娓呯┖
+						// this.AreaId = "";
+						// this.selectedAreaName = "";
+						
+						// 閲嶆柊鑱氱劍鍒版墭鐩樻潯鐮佽緭鍏ユ
+						this.barcodeFocus = false;
+						this.$nextTick(() => {
+							this.barcodeFocus = true;
+						});
+					} else {
+						this.$refs.luToast.show({
+							title: res.message || "鍑哄簱浠诲姟鍒涘缓澶辫触",
+							type: "error"
+						});
+						// 澶辫触鏃堕噸鏂拌仛鐒�
+						this.barcodeFocus = true;
+					}
+				}).catch(err => {
+					this.isLoading = false;
+					console.error('OutboundTask error:', err);
+					this.$refs.luToast.show({
+						title: "缃戠粶璇锋眰澶辫触锛岃閲嶈瘯",
+						type: "error"
+					});
+					this.barcodeFocus = true;
+				});
+			},
+			
+			// 閲嶇疆琛ㄥ崟锛堝闇�鎵嬪姩閲嶇疆锛�
+			resetForm() {
+				this.PalletCode = "";
+				this.TargetAddress = "";
+				this.barcodeFocus = true;
 			}
+		},
+		
+		// 椤甸潰鍗歌浇鏃堕攢姣侀煶棰�
+		onUnload() {
+			innerAudioContext.destroy();
+		}
 	}
 </script>
 

--
Gitblit v1.9.3