heshaofeng
2026-01-26 ad838c4ab6a78aeb850b32a0afff03aacfd3062c
优化手动打印条码功能
已添加1个文件
已修改4个文件
146 ■■■■ 文件已修改
项目代码/WIDESEA_WMSClient/src/views/outbound/printForm.vue 83 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_DTO/Outbound/PrintFromDataDTO.cs 21 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_IOutboundService/IOutboundService.cs 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_OutboundService/OutboundService.cs 34 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/Outbound/OutboundController.cs 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ÏîÄ¿´úÂë/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 {
      // è¡¨å•数据(对应printView所需的参数)
      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("获取数据失败,请检查网络或批号是否正确");
      } 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的open方法,传递参数并打开弹窗
          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;
ÏîÄ¿´úÂë/WMSÎÞ²Ö´¢°æ/WIDESEA_WMSServer/WIDESEA_DTO/Outbound/PrintFromDataDTO.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,21 @@
using 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; }
    }
}
ÏîÄ¿´úÂë/WMSÎÞ²Ö´¢°æ/WIDESEA_WMSServer/WIDESEA_IOutboundService/IOutboundService.cs
@@ -68,5 +68,7 @@
        /// <param name="orderNo"></param>
        /// <returns></returns>
        WebResponseContent RecheckPicking(RecheckPickingDTO pickingDTO);
        WebResponseContent PrintFromData(string barcode);
    }
}
ÏîÄ¿´úÂë/WMSÎÞ²Ö´¢°æ/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 å‡ºåº“分配
ÏîÄ¿´úÂë/WMSÎÞ²Ö´¢°æ/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);
        }
    }
}