From 5a09430e31d6a513aa98df39ecf306e0b9a6bb7c Mon Sep 17 00:00:00 2001 From: risingLee <871066422@qq.com> Date: Tue, 6 Jan 2026 15:05:24 +0800 Subject: [PATCH] =?UTF-8?q?=E6=89=B9=E9=87=8F=E6=B7=BB=E5=8A=A0=E6=8C=89?= =?UTF-8?q?=E9=92=AE=EF=BC=9A=E5=8F=AA=E6=9C=89=E5=BD=93=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E9=80=9A=E8=BF=87"=E6=9F=A5=E7=9C=8B=E6=A0=B7=E5=93=81"?= =?UTF-8?q?=E8=BF=9B=E5=85=A5=EF=BC=88=E6=9C=89receiptId=E5=8F=82=E6=95=B0?= =?UTF-8?q?=EF=BC=89=E6=97=B6=E6=89=8D=E6=98=BE=E7=A4=BA=20=E6=89=B9?= =?UTF-8?q?=E9=87=8F=E6=B7=BB=E5=8A=A0=E5=AF=B9=E8=AF=9D=E6=A1=86=EF=BC=9A?= =?UTF-8?q?=E5=8C=85=E5=90=AB=E6=A0=B7=E5=93=81=E5=9E=8B=E5=8F=B7=E3=80=81?= =?UTF-8?q?=E7=A1=AC=E4=BB=B6=E7=89=88=E6=9C=AC=E5=8F=B7=E5=92=8CSN?= =?UTF-8?q?=E5=8F=B7=E8=BE=93=E5=85=A5=E6=A1=86=20=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E5=AE=8C=E6=88=90=E5=8A=9F=E8=83=BD=EF=BC=9A=E5=9E=8B=E5=8F=B7?= =?UTF-8?q?=E5=92=8C=E7=89=88=E6=9C=AC=E5=8F=B7=E9=83=BD=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E8=87=AA=E5=8A=A8=E5=AE=8C=E6=88=90=20=E6=89=B9=E9=87=8F?= =?UTF-8?q?=E5=88=9B=E5=BB=BA=EF=BC=9A=E8=BE=93=E5=85=A5=E5=A4=9A=E4=B8=AA?= =?UTF-8?q?SN=E5=8F=B7=EF=BC=8C=E6=AF=8F=E4=B8=AA=E9=83=BD=E4=BC=9A?= =?UTF-8?q?=E7=BB=A7=E6=89=BF=E7=9B=B8=E5=90=8C=E7=9A=84=E5=9E=8B=E5=8F=B7?= =?UTF-8?q?=E5=92=8C=E7=89=88=E6=9C=AC=E5=8F=B7=20=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E5=88=B7=E6=96=B0=EF=BC=9A=E6=B7=BB=E5=8A=A0=E6=88=90=E5=8A=9F?= =?UTF-8?q?=E5=90=8E=E8=87=AA=E5=8A=A8=E5=88=B7=E6=96=B0=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/views/warehouse/sample/index.vue | 124 ++++++++++++++++++ 1 file changed, 124 insertions(+) diff --git a/ruoyi-fastapi-frontend/src/views/warehouse/sample/index.vue b/ruoyi-fastapi-frontend/src/views/warehouse/sample/index.vue index fa876fc..2754277 100644 --- a/ruoyi-fastapi-frontend/src/views/warehouse/sample/index.vue +++ b/ruoyi-fastapi-frontend/src/views/warehouse/sample/index.vue @@ -68,6 +68,16 @@ v-hasPermi="['warehouse:sample:add']" >新增 + + 批量添加样品 + 取 消 + + + + + + + + 提示:该型号将应用于所有批量添加的样品 + + + + + + 提示:该版本号将应用于所有批量添加的样品 + + + + + + 提示:每行输入一个SN号,系统将自动为每个SN号创建一条样品记录 + + + + + @@ -251,6 +306,14 @@ export default { title: "", // 是否显示弹出层 open: false, + // 批量添加样品对话框 + batchSampleOpen: false, + // 批量添加样品文本 + batchSampleText: "", + // 批量添加样品型号 + batchSampleModel: "", + // 批量添加硬件版本号 + batchHardwareVersion: "", // 入库单ID(从路由参数获取) receiptId: null, // 入库单号(从路由参数获取) @@ -387,6 +450,67 @@ export default { handleBack() { this.$router.push('/warehouse/receipt'); }, + /** 批量添加样品 */ + handleBatchAddSample() { + if (!this.receiptId) { + this.$modal.msgWarning("请先选择入库单"); + return; + } + this.batchSampleText = ""; + this.batchSampleModel = ""; + this.batchHardwareVersion = ""; + this.batchSampleOpen = true; + }, + /** 提交批量添加样品 */ + async submitBatchSample() { + if (!this.batchSampleText || !this.batchSampleText.trim()) { + this.$modal.msgWarning("请输入样品SN号"); + return; + } + + // 按行分割文本 + const lines = this.batchSampleText.split('\n'); + let addedCount = 0; + let failedCount = 0; + + // 处理每一行 + for (const line of lines) { + const sn = line.trim(); + // 跳过空行 + if (sn) { + try { + // 创建样品对象 + const sampleData = { + receiptId: this.receiptId, + receiptNo: this.receiptNo, + sampleModel: this.batchSampleModel || null, + sampleSn: sn, + hardwareVersion: this.batchHardwareVersion || null, + externalStatus: null, + testItems: null, + testDeadline: null, + status: '0', + remark: null + }; + + // 调用API添加样品 + await addSample(sampleData); + addedCount++; + } catch (error) { + console.error(`添加样品 ${sn} 失败:`, error); + failedCount++; + } + } + } + + if (addedCount > 0) { + this.$modal.msgSuccess(`成功添加 ${addedCount} 条样品记录${failedCount > 0 ? `,失败 ${failedCount} 条` : ''}`); + this.batchSampleOpen = false; + this.getList(); // 刷新列表 + } else { + this.$modal.msgError("添加样品失败,请检查输入"); + } + }, /** 查询样品型号建议 */ querySampleModel(queryString, cb) { // 从 sampleList 中提取不重复的样品型号