From ad838c4ab6a78aeb850b32a0afff03aacfd3062c Mon Sep 17 00:00:00 2001
From: heshaofeng <heshaofeng@hnkhzn.com>
Date: 星期一, 26 一月 2026 17:07:22 +0800
Subject: [PATCH] 优化手动打印条码功能

---
 项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/Outbound/OutboundController.cs |    6 ++
 项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_DTO/Outbound/PrintFromDataDTO.cs                     |   21 +++++++
 项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_IOutboundService/IOutboundService.cs                 |    2 
 项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_OutboundService/OutboundService.cs                   |   34 +++++++++++
 项目代码/WIDESEA_WMSClient/src/views/outbound/printForm.vue                                     |   83 +++++++++++++++++++--------
 5 files changed, 120 insertions(+), 26 deletions(-)

diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/src/views/outbound/printForm.vue" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/src/views/outbound/printForm.vue"
index 9490e6a..14f0b8f 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/src/views/outbound/printForm.vue"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/src/views/outbound/printForm.vue"
@@ -45,6 +45,8 @@
                 v-model="printForm.barcode"
                 placeholder="璇疯緭鍏ユ壒鍙凤紙鐢熸垚浜岀淮鐮佺敤锛�"
                 clearable
+                @keyup.enter="fetchBarcodeData"  
+                :loading="fetchingData"    
               />
             </el-form-item>
 
@@ -57,7 +59,7 @@
             </el-form-item>
           </el-col>
 
-          <!-- 绗簩鍒� -->
+          
           <el-col :span="12">
             <el-form-item label="渚涘簲鍟嗙紪鐮�" prop="suplierCode">
               <el-input
@@ -104,7 +106,7 @@
           </el-col>
         </el-row>
 
-        <!-- 鎵归噺娣诲姞锛堝彲閫夛級 -->
+        
         <el-form-item label="鎵撳嵃浠芥暟">
           <el-input-number
             v-model="printCopyCount"
@@ -115,7 +117,7 @@
           />
         </el-form-item>
 
-        <!-- 鎿嶄綔鎸夐挳 -->
+        
         <el-form-item class="form-actions">
           <el-button type="primary" @click="submitForm">纭骞舵墦寮�鎵撳嵃寮圭獥</el-button>
           <el-button @click="resetForm">閲嶇疆琛ㄥ崟</el-button>
@@ -123,52 +125,87 @@
       </el-form>
     </el-card>
 
-    <!-- 寮曞叆鎵撳嵃寮圭獥缁勪欢 -->
+    
     <print-view ref="printViewRef" />
   </div>
 </template>
 
 <script>
-// 寮曞叆鎵撳嵃寮圭獥缁勪欢
+
 import printView from "@/extension/outbound/extend/printView.vue";
 import { ElMessage } from "element-plus";
+import http from '@/api/http.js'
 
 export default {
   name: "PrintInputPage",
   components: { printView },
   data() {
     return {
-      // 琛ㄥ崟鏁版嵁锛堝搴攑rintView鎵�闇�鐨勫弬鏁帮級
       printForm: {
-        materialCode: "", // 鏂欏彿
-        suplierCode: "", // 渚涘簲鍟嗙紪鐮�
-        materialName: "", // 鍝佸悕
-        pruchaseOrderNo: "", // 閲囪喘鍗曞彿
-        materialSpec: "", // 瑙勬牸
-        quantity: "", // 鏁伴噺/鎬绘暟
-        barcode: "", // 鎵瑰彿锛堜簩缁寸爜鍐呭锛�
-        batchNo: "", // 鎵规
-        factoryArea: "", // 鍘傚尯
-        date: "", // 鏃ユ湡锛堥粯璁ゅ綋鍓嶆棩鏈燂級
+        materialCode: "", 
+        suplierCode: "", 
+        materialName: "", 
+        pruchaseOrderNo: "", 
+        materialSpec: "", 
+        quantity: "", 
+        barcode: "", 
+        batchNo: "", 
+        factoryArea: "", 
+        date: "", 
       },
-      // 鎵撳嵃浠芥暟锛堟敮鎸佹壒閲忕敓鎴愬鏉$浉鍚屾暟鎹級
+      
       printCopyCount: 1,
-      // 琛ㄥ崟楠岃瘉瑙勫垯
+      
       formRules: {
         materialCode: [{ required: true, message: "璇疯緭鍏ユ枡鍙�", trigger: "blur" }],
         materialName: [{ required: true, message: "璇疯緭鍏ュ搧鍚�", trigger: "blur" }],
         barcode: [{ required: true, message: "璇疯緭鍏ユ壒鍙�", trigger: "blur" }],
         date: [{ required: true, message: "璇烽�夋嫨鏃ユ湡", trigger: "change" }],
       },
+      
+      fetchingData: false
     };
   },
   mounted() {
-    // 鍒濆鍖栭粯璁ゆ棩鏈熶负褰撳ぉ
     const today = new Date();
     this.printForm.date = `${today.getFullYear()}-${(today.getMonth() + 1).toString().padStart(2, "0")}-${today.getDate().toString().padStart(2, "0")}`;
   },
   methods: {
-    // 鎻愪氦琛ㄥ崟锛屾墦寮�鎵撳嵃寮圭獥
+    async fetchBarcodeData() {
+      if (!this.printForm.barcode.trim()) {
+        return;
+      }
+
+      try {
+        
+        this.fetchingData = true;
+        
+        const response = await http.post(
+          `/api/Outbound/PrintFromData?barcode=` + this.printForm.barcode.trim()
+        );
+        const data = response.data;
+        if (data) {
+          this.printForm.materialCode = data.materialCode || "";
+          this.printForm.suplierCode = data.suplierCode || "";
+          this.printForm.materialName = data.materialName || "";
+          this.printForm.pruchaseOrderNo = data.pruchaseOrderNo || "";
+          this.printForm.materialSpec = data.materialSpec || "";
+          this.printForm.quantity = data.quantity || "";
+          this.printForm.batchNo = data.batchNo || "";
+          this.printForm.factoryArea = data.factoryArea || "";
+          
+          
+          ElMessage.success("宸叉牴鎹壒鍙疯嚜鍔ㄥ~鍏呮暟鎹�");
+        } else {
+          ElMessage.info("鏈煡璇㈠埌璇ユ壒鍙峰搴旂殑鐗╂枡鏁版嵁");
+        }
+      } catch (error) {
+        console.error("鑾峰彇鎵瑰彿鏁版嵁澶辫触锛�", error);
+        ElMessage.error("鑾峰彇鏁版嵁澶辫触锛岃妫�鏌ョ綉缁滄垨鎵瑰彿鏄惁姝g‘");
+      } finally {
+        this.fetchingData = false;
+      }
+    },
     submitForm() {
       this.$refs.printFormRef.validate((valid) => {
         if (!valid) {
@@ -177,13 +214,10 @@
         }
 
         try {
-          // 鏋勯�犳墦鍗版暟鎹紙鏀寔澶氫唤锛�
           const printData = [];
           for (let i = 0; i < this.printCopyCount; i++) {
             printData.push({ ...this.printForm });
           }
-
-          // 璋冪敤printView鐨刼pen鏂规硶锛屼紶閫掑弬鏁板苟鎵撳紑寮圭獥
           this.$refs.printViewRef.open(printData);
           ElMessage.success(`宸茬敓鎴� ${this.printCopyCount} 浠芥墦鍗版暟鎹紝鍗冲皢鎵撳紑鎵撳嵃寮圭獥`);
         } catch (error) {
@@ -193,10 +227,9 @@
       });
     },
 
-    // 閲嶇疆琛ㄥ崟
+    
     resetForm() {
       this.$refs.printFormRef.resetFields();
-      // 閲嶇疆鍚庢仮澶嶉粯璁ゆ棩鏈�
       const today = new Date();
       this.printForm.date = `${today.getFullYear()}-${(today.getMonth() + 1).toString().padStart(2, "0")}-${today.getDate().toString().padStart(2, "0")}`;
       this.printCopyCount = 1;
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_DTO/Outbound/PrintFromDataDTO.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_DTO/Outbound/PrintFromDataDTO.cs"
new file mode 100644
index 0000000..cca3c3d
--- /dev/null
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_DTO/Outbound/PrintFromDataDTO.cs"
@@ -0,0 +1,21 @@
+锘縰sing System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace WIDESEA_DTO.Outbound
+{
+    public class PrintFromDataDTO
+    {
+        public string materialCode { get; set; }
+        public string materialName { get; set; }
+        public string materialSpec { get; set; }
+        public string factoryArea { get; set; }
+        public string suplierCode { get;set; }
+        public string pruchaseOrderNo { get; set; }
+        public decimal quantity { get; set; }
+        public string batchNo { get; set; }
+        public DateTime date { get; set; }
+    }
+}
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_IOutboundService/IOutboundService.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_IOutboundService/IOutboundService.cs"
index 25a8875..410afa4 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_IOutboundService/IOutboundService.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_IOutboundService/IOutboundService.cs"
@@ -68,5 +68,7 @@
         /// <param name="orderNo"></param>
         /// <returns></returns>
         WebResponseContent RecheckPicking(RecheckPickingDTO pickingDTO);
+
+        WebResponseContent PrintFromData(string barcode);
     }
 }
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_OutboundService/OutboundService.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_OutboundService/OutboundService.cs"
index 26c2a23..9ec56f5 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_OutboundService/OutboundService.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_OutboundService/OutboundService.cs"
@@ -22,6 +22,7 @@
 using WIDESEA_DTO.Base;
 using WIDESEA_DTO.Basic;
 using WIDESEA_DTO.CalcOut;
+using WIDESEA_DTO.Outbound;
 using WIDESEA_DTO.ReturnMES;
 using WIDESEA_IBasicService;
 using WIDESEA_IOutboundService;
@@ -62,6 +63,8 @@
         private readonly IESSApiService _eSSApiService;
         private readonly IRepository<Dt_AllocateOrder> _allocateOrderRepository;
         private readonly IRepository<Dt_AllocateMaterialInfo> _allocateMaterialInfoRepository;
+        public readonly IRepository<Dt_InboundOrderDetail> _inboundOrderDetailRepository;
+        public readonly IRepository<Dt_InboundOrder> _inboundOrderRepository;
 
         private Dictionary<string, string> stations = new Dictionary<string, string>
         {
@@ -75,7 +78,7 @@
             {"3-1","3-5" },
         };
 
-        public OutboundService(IMapper mapper, IUnitOfWorkManage unitOfWorkManage, IRepository<Dt_OutboundOrderDetail> detailRepository, IRepository<Dt_OutboundOrder> outboundRepository, IRepository<Dt_OutStockLockInfo> outboundLockInfoRepository, IRepository<Dt_StockInfo> stockInfoRepository, IRepository<Dt_StockInfoDetail> stockDetailRepository, IRepository<Dt_StockQuantityChangeRecord> stockChangeRepository, IRepository<Dt_StockInfoDetail_Hty> stockDetailHistoryRepository, IBasicService basicService, IOutboundOrderDetailService outboundOrderDetailService, IOutboundOrderService outboundOrderService, IOutStockLockInfoService outboundStockLockInfoService, IFeedbackMesService feedbackMesService, IRepository<Dt_Task> taskRepository, ILocationInfoService locationInfoService, IESSApiService eSSApiService, IRepository<Dt_AllocateOrder> allocateOrderRepository, IRepository<Dt_AllocateMaterialInfo> allocateMaterialInfoRepository)
+        public OutboundService(IMapper mapper, IUnitOfWorkManage unitOfWorkManage, IRepository<Dt_OutboundOrderDetail> detailRepository, IRepository<Dt_OutboundOrder> outboundRepository, IRepository<Dt_OutStockLockInfo> outboundLockInfoRepository, IRepository<Dt_StockInfo> stockInfoRepository, IRepository<Dt_StockInfoDetail> stockDetailRepository, IRepository<Dt_StockQuantityChangeRecord> stockChangeRepository, IRepository<Dt_StockInfoDetail_Hty> stockDetailHistoryRepository, IBasicService basicService, IOutboundOrderDetailService outboundOrderDetailService, IOutboundOrderService outboundOrderService, IOutStockLockInfoService outboundStockLockInfoService, IFeedbackMesService feedbackMesService, IRepository<Dt_Task> taskRepository, ILocationInfoService locationInfoService, IESSApiService eSSApiService, IRepository<Dt_AllocateOrder> allocateOrderRepository, IRepository<Dt_AllocateMaterialInfo> allocateMaterialInfoRepository, IRepository<Dt_InboundOrderDetail> inboundOrderDetailRepository, IRepository<Dt_InboundOrder> inboundOrderRepository)
         {
             _mapper = mapper;
             _unitOfWorkManage = unitOfWorkManage;
@@ -98,6 +101,35 @@
             _eSSApiService = eSSApiService;
             _allocateOrderRepository = allocateOrderRepository;
             _allocateMaterialInfoRepository = allocateMaterialInfoRepository;
+            _inboundOrderDetailRepository = inboundOrderDetailRepository;
+            _inboundOrderRepository = inboundOrderRepository;
+        }
+
+        public WebResponseContent PrintFromData (string barcode)
+        {
+            var detail = _inboundOrderDetailRepository.QueryFirst(x => x.Barcode == barcode);
+            if(detail == null)
+            {
+                return WebResponseContent.Instance.Error();
+            }
+
+            var inbound = _inboundOrderRepository.QueryFirst(x=>x.Id ==  detail.OrderId);
+            if(inbound == null)
+            {
+                return WebResponseContent.Instance.Error();
+            }
+            var printFormData = new PrintFromDataDTO { 
+                materialCode = detail.Barcode,
+                materialName = detail.MaterielName,
+                materialSpec = detail.Unit,
+                batchNo = detail.BatchNo,
+                pruchaseOrderNo = inbound.UpperOrderNo,
+                factoryArea = inbound.FactoryArea,
+                suplierCode = inbound.SupplierId,
+                quantity = detail.BarcodeQty
+            };
+
+            return WebResponseContent.Instance.OK(data:printFormData);
         }
 
         #region 鍑哄簱鍒嗛厤
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/Outbound/OutboundController.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/Outbound/OutboundController.cs"
index 9bc1b43..3b155bd 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/Outbound/OutboundController.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/Outbound/OutboundController.cs"
@@ -120,5 +120,11 @@
         {
             return _outboundService.RecheckPicking(pickingDTO);
         }
+
+        [HttpPost, Route("PrintFromData"), AllowAnonymous]
+        public WebResponseContent PrintFromData(string barcode)
+        {
+            return _outboundService.PrintFromData(barcode);
+        }
     }
 }

--
Gitblit v1.9.3