diff --git a/Antis.Erp.Plat/SERVICES_CONFIG.md b/Antis.Erp.Plat/SERVICES_CONFIG.md
index 990d3ec..e96b9c7 100644
--- a/Antis.Erp.Plat/SERVICES_CONFIG.md
+++ b/Antis.Erp.Plat/SERVICES_CONFIG.md
@@ -88,7 +88,7 @@ python3 -m http.server 8888
"http://localhost:3021",
"http://localhost:3014",
"http://localhost:3015",
- "http://localhost:2015",
+ "http://localhost:2011",
"http://localhost:3009",
"http://localhost:2016",
"http://localhost:3000",
diff --git a/Antis.Erp.Plat/antis-ncc-admin/.env.development b/Antis.Erp.Plat/antis-ncc-admin/.env.development
index d62b8b5..2513186 100755
--- a/Antis.Erp.Plat/antis-ncc-admin/.env.development
+++ b/Antis.Erp.Plat/antis-ncc-admin/.env.development
@@ -1,5 +1,5 @@
# 开发
VUE_CLI_BABEL_TRANSPILE_MODULES = true
-VUE_APP_BASE_API = 'http://localhost:2015'
+VUE_APP_BASE_API = 'http://localhost:2011'
VUE_APP_BASE_WSS = 'ws://localhost:2011/websocket'
diff --git a/Antis.Erp.Plat/antis-ncc-admin/src/views/wtCgthd/Form.vue b/Antis.Erp.Plat/antis-ncc-admin/src/views/wtCgthd/Form.vue
index 3ed94c3..080ed15 100644
--- a/Antis.Erp.Plat/antis-ncc-admin/src/views/wtCgthd/Form.vue
+++ b/Antis.Erp.Plat/antis-ncc-admin/src/views/wtCgthd/Form.vue
@@ -99,6 +99,11 @@
+
+
+
+
+
@@ -364,9 +369,13 @@
if (!item.hasOwnProperty('dyddbh')) {
this.$set(item, 'dyddbh', item.dyddbh || undefined);
}
+ if (!item.hasOwnProperty('thdj')) {
+ this.$set(item, 'thdj', item.thdj || item.dj || undefined);
+ }
});
this.syncDetailWarehouses();
this.updateTotalAmount();
+ this.reloadInboundOrdersForExistingRows();
})
} else {
this.dataForm.wtXsckdMxList = [];
@@ -510,6 +519,7 @@
dw:undefined,
sl:undefined,
dj:undefined,
+ thdj: undefined,
je:undefined,
dyddbh: undefined,
description: undefined,
@@ -527,6 +537,8 @@
},
handleDelWtXsckdMxEntityList(index) {
this.dataForm.wtXsckdMxList.splice(index, 1);
+ // 删除行后,重建下拉缓存索引,避免错位
+ this.rebuildInboundOrdersMap();
// 删除后更新总金额
this.updateTotalAmount();
},
@@ -537,6 +549,7 @@
this.$set(row, 'dyddbh', undefined);
this.$set(row, 'dj', '');
+ this.$set(row, 'thdj', '');
this.$set(row, 'je', '');
await this.loadInboundOrders(row);
@@ -558,10 +571,12 @@
if (!row.spbh || !warehouse) return;
try {
+ const requestData = { spbh: row.spbh, ck: warehouse };
+ console.log('[loadInboundOrders] GET请求参数:', requestData);
const res = await request({
url: '/api/Extend/WtXsckd/GetPurchaseInboundOrders',
method: 'get',
- params: { spbh: row.spbh, ck: warehouse }
+ data: requestData
});
let rawList = [];
if (Array.isArray(res)) {
@@ -582,6 +597,29 @@
console.error('加载入库单列表失败', e);
}
},
+ rebuildInboundOrdersMap() {
+ const oldMap = this.inboundOrdersMap || {};
+ const newMap = {};
+ (this.dataForm.wtXsckdMxList || []).forEach((row, idx) => {
+ const oldIdx = Object.keys(oldMap).find(key => {
+ const list = oldMap[key] || [];
+ return list.some(item => item.orderid === row.dyddbh);
+ });
+ if (oldIdx !== undefined) {
+ this.$set(newMap, idx, oldMap[oldIdx] || []);
+ }
+ });
+ this.inboundOrdersMap = newMap;
+ },
+ async reloadInboundOrdersForExistingRows() {
+ if (!this.dataForm || !Array.isArray(this.dataForm.wtXsckdMxList)) return;
+ const tasks = this.dataForm.wtXsckdMxList
+ .filter(row => row && row.spbh)
+ .map(row => this.loadInboundOrders(row));
+ if (tasks.length > 0) {
+ await Promise.all(tasks);
+ }
+ },
normalizeInboundOrder(item) {
const getVal = (obj, keys) => {
for (const key of keys) {
@@ -604,6 +642,7 @@
const selected = orders.find(o => o.orderid === row.dyddbh);
if (selected) {
this.$set(row, 'dj', selected.dj);
+ this.$set(row, 'thdj', selected.dj);
const sl = parseFloat(row.sl) || 0;
if (sl > 0) {
this.$set(row, 'je', (sl * parseFloat(selected.dj)).toFixed(2));
@@ -629,14 +668,17 @@
},
// 处理主表出库仓库变化,同步更新所有明细行的出库仓库
- handleMainWarehouseChange(value) {
+ async handleMainWarehouseChange(value) {
this.syncDetailWarehouses();
this.inboundOrdersMap = {};
this.dataForm.wtXsckdMxList.forEach(row => {
this.$set(row, 'dyddbh', undefined);
this.$set(row, 'dj', '');
+ this.$set(row, 'thdj', '');
this.$set(row, 'je', '');
});
+ // 关键修复:仓库变化后,自动为已选商品重新加载入库编号
+ await this.reloadInboundOrdersForExistingRows();
this.updateTotalAmount();
},
@@ -688,7 +730,7 @@
// 处理数量变化
handleAmountChange(row) {
const sl = parseFloat(row.sl) || 0;
- const dj = parseFloat(row.dj) || 0;
+ const dj = parseFloat(row.thdj) || 0;
row.je = (sl * dj).toFixed(2);
// 自动更新主表退款金额
@@ -722,10 +764,10 @@
}
},
- // 处理单价变化
- handlePriceChange(row) {
+ // 处理退货单价变化(金额按退货单价计算)
+ handleRefundPriceChange(row) {
const sl = parseFloat(row.sl) || 0;
- const dj = parseFloat(row.dj) || 0;
+ const dj = parseFloat(row.thdj) || 0;
row.je = (sl * dj).toFixed(2);
// 自动更新主表退款金额
@@ -764,8 +806,9 @@
// 自动设置数量为选择的序列号数量
currentRow.sl = selectedSerialNumbers.length.toString()
// 自动计算金额
- if (currentRow.dj) {
- currentRow.je = (parseFloat(currentRow.sl) * parseFloat(currentRow.dj)).toFixed(2)
+ if (currentRow.thdj || currentRow.dj) {
+ const usePrice = parseFloat(currentRow.thdj || currentRow.dj || 0)
+ currentRow.je = (parseFloat(currentRow.sl) * usePrice).toFixed(2)
}
// 更新总金额
diff --git a/Antis.Erp.Plat/netcore/src/Application/NCC.API/Properties/launchSettings.json b/Antis.Erp.Plat/netcore/src/Application/NCC.API/Properties/launchSettings.json
index b050506..1d2d61b 100755
--- a/Antis.Erp.Plat/netcore/src/Application/NCC.API/Properties/launchSettings.json
+++ b/Antis.Erp.Plat/netcore/src/Application/NCC.API/Properties/launchSettings.json
@@ -19,7 +19,7 @@
"commandName": "Project",
"dotnetRunMessages": "true",
"launchBrowser": false,
- "applicationUrl": "http://localhost:2015",
+ "applicationUrl": "http://localhost:2011",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
diff --git a/Antis.Erp.Plat/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/WtXsckdMxCrInput.cs b/Antis.Erp.Plat/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/WtXsckdMxCrInput.cs
index ec73aa3..4f08577 100644
--- a/Antis.Erp.Plat/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/WtXsckdMxCrInput.cs
+++ b/Antis.Erp.Plat/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/WtXsckdMxCrInput.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.Collections.Generic;
namespace NCC.Extend.Entitys.Dto.WtXsckd
@@ -54,6 +54,11 @@ namespace NCC.Extend.Entitys.Dto.WtXsckd
public decimal dj { get; set; }
///
+ /// 退货单价(采购退货业务使用)
+ ///
+ public decimal? thdj { get; set; }
+
+ ///
/// 金额
///
public decimal je { get; set; }
@@ -68,5 +73,10 @@ namespace NCC.Extend.Entitys.Dto.WtXsckd
///
public string mdxx { get; set; }
+ ///
+ /// 已选择的序列号列表
+ ///
+ public List selectedSerialNumbers { get; set; }
+
}
}
diff --git a/Antis.Erp.Plat/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/WtXsckdMxInfoOutput.cs b/Antis.Erp.Plat/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/WtXsckdMxInfoOutput.cs
index 1878d4d..d9614a5 100644
--- a/Antis.Erp.Plat/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/WtXsckdMxInfoOutput.cs
+++ b/Antis.Erp.Plat/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/WtXsckdMxInfoOutput.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.Collections.Generic;
namespace NCC.Extend.Entitys.Dto.WtXsckd
@@ -59,6 +59,11 @@ namespace NCC.Extend.Entitys.Dto.WtXsckd
public decimal dj { get; set; }
///
+ /// 退货单价(采购退货业务使用)
+ ///
+ public decimal? thdj { get; set; }
+
+ ///
/// 金额
///
public decimal je { get; set; }
diff --git a/Antis.Erp.Plat/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Entity/WtXsckdMxEntity.cs b/Antis.Erp.Plat/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Entity/WtXsckdMxEntity.cs
index abb6ab8..ef0eba5 100644
--- a/Antis.Erp.Plat/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Entity/WtXsckdMxEntity.cs
+++ b/Antis.Erp.Plat/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Entity/WtXsckdMxEntity.cs
@@ -72,6 +72,12 @@ namespace NCC.Extend.Entitys
public decimal Dj { get; set; }
///
+ /// 退货单价(采购退货业务使用)
+ ///
+ [SugarColumn(ColumnName = "thdj")]
+ public decimal? Thdj { get; set; }
+
+ ///
/// 金额
///
[SugarColumn(ColumnName = "je")]
diff --git a/Antis.Erp.Plat/netcore/src/Modularity/Extend/NCC.Extend/WtXsckdService.cs b/Antis.Erp.Plat/netcore/src/Modularity/Extend/NCC.Extend/WtXsckdService.cs
index aa68335..0dc0bd2 100644
--- a/Antis.Erp.Plat/netcore/src/Modularity/Extend/NCC.Extend/WtXsckdService.cs
+++ b/Antis.Erp.Plat/netcore/src/Modularity/Extend/NCC.Extend/WtXsckdService.cs
@@ -574,6 +574,94 @@ namespace NCC.Extend.WtXsckd
}
}
}
+ // ✅ 处理采购退货单:扣减在库序列号(Status 0 -> 1)
+ else if (input.djlx == "采购退货单")
+ {
+ Console.WriteLine($"Create方法 - 准备处理采购退货单序列号出库");
+ Console.WriteLine($" - 单据ID: {newEntity.Id}");
+ Console.WriteLine($" - 单据类型: {input.djlx}");
+ Console.WriteLine($" - 出库仓库: {entity.Cjck}");
+
+ if (wtXsckdMxEntityList != null && wtXsckdMxEntityList.Any())
+ {
+ for (int i = 0; i < wtXsckdMxEntityList.Count; i++)
+ {
+ var detail = wtXsckdMxEntityList[i];
+ var inputDetail = (input.wtXsckdMxList != null && input.wtXsckdMxList.Count > i)
+ ? input.wtXsckdMxList[i]
+ : null;
+
+ if (!string.IsNullOrEmpty(detail.Spbh) && int.TryParse(detail.Sl, out int slValue) && slValue > 0)
+ {
+ var outStoreId = !string.IsNullOrEmpty(detail.Ckck) ? detail.Ckck : entity.Cjck;
+ if (string.IsNullOrEmpty(outStoreId))
+ {
+ throw new Exception($"商品 {detail.Spmc} 未指定出库仓库,无法处理采购退货序列号");
+ }
+
+ var warehouseIds = await _db.Queryable()
+ .Where(c => c.Ssmd == outStoreId || c.Id == outStoreId)
+ .Select(c => c.Id)
+ .ToListAsync();
+ if (warehouseIds == null || warehouseIds.Count == 0)
+ {
+ warehouseIds = new List { outStoreId };
+ }
+
+ var selectedSerials = inputDetail?.selectedSerialNumbers?
+ .Where(s => !string.IsNullOrWhiteSpace(s))
+ .Select(s => s.Trim())
+ .Distinct()
+ .ToList() ?? new List();
+
+ List serialsToOut;
+ if (selectedSerials.Count > 0)
+ {
+ serialsToOut = await _db.Queryable()
+ .Where(s => s.Spbh == detail.Spbh
+ && s.Status == 0
+ && warehouseIds.Contains(s.InWarehouse)
+ && selectedSerials.Contains(s.SerialNumber))
+ .Select(s => s.SerialNumber)
+ .ToListAsync();
+
+ if (serialsToOut.Count != slValue)
+ {
+ throw new Exception($"商品 {detail.Spmc} 选择的序列号数量与明细数量不一致,或包含非在库序列号");
+ }
+ }
+ else
+ {
+ serialsToOut = await _db.Queryable()
+ .Where(s => s.Spbh == detail.Spbh
+ && s.Status == 0
+ && warehouseIds.Contains(s.InWarehouse))
+ .OrderBy(s => s.InTime)
+ .Take(slValue)
+ .Select(s => s.SerialNumber)
+ .ToListAsync();
+ if (serialsToOut.Count < slValue)
+ {
+ throw new Exception($"商品 {detail.Spmc} 在仓库可用序列号不足,需{slValue}个,实得{serialsToOut.Count}个");
+ }
+ }
+
+ await _db.Updateable()
+ .SetColumns(it => new WtSerialNumberEntity
+ {
+ Status = 1,
+ OutDjbh = newEntity.Id,
+ OutDjlx = input.djlx,
+ OutWarehouse = outStoreId,
+ OutTime = DateTime.Now,
+ OutOperator = userId ?? ""
+ })
+ .Where(it => serialsToOut.Contains(it.SerialNumber))
+ .ExecuteCommandAsync();
+ }
+ }
+ }
+ }
// 自动生成导购提成记录
if (input.djlx == "销售出库单")
@@ -2882,7 +2970,7 @@ ORDER BY t.`商品编号`;";
if (string.IsNullOrEmpty(detail.Spbh)) continue;
if (!int.TryParse(detail.Sl, out int qty) || qty <= 0) continue;
- decimal returnPrice = detail.Dj;
+ decimal returnPrice = detail.Thdj.HasValue && detail.Thdj.Value > 0 ? detail.Thdj.Value : detail.Dj;
foreach (var whId in warehouseIds)
{
@@ -2910,6 +2998,14 @@ ORDER BY t.`商品编号`;";
"UPDATE wt_sp_cost SET cbj = @cbj, sl = @sl, update_time = NOW() WHERE spbh = @spbh AND ck = @ck",
new { cbj = newCbj, sl = newSl, spbh = detail.Spbh, ck = whId });
+ // 库存口径统一:以序列号在库数量为准
+ var actualCount = await _db.Ado.GetIntAsync(
+ "SELECT COUNT(*) FROM wt_serial_number WHERE spbh = @spbh AND in_warehouse = @ck AND status = 0",
+ new SugarParameter[] { new SugarParameter("@spbh", detail.Spbh), new SugarParameter("@ck", whId) });
+ await _db.Ado.ExecuteCommandAsync(
+ "UPDATE wt_sp_cost SET sl = @sl, update_time = NOW() WHERE spbh = @spbh AND ck = @ck",
+ new { sl = actualCount, spbh = detail.Spbh, ck = whId });
+
await _db.Ado.ExecuteCommandAsync(
"UPDATE wt_xsckd_mx SET cbdj = @cbdj, cbje = @cbje WHERE F_Id = @id",
new { cbdj = returnPrice, cbje = Math.Round(returnPrice * qty, 2), id = detail.Id });
@@ -3067,7 +3163,28 @@ ORDER BY t.`商品编号`;";
if (string.IsNullOrEmpty(detail.Spbh)) continue;
if (!int.TryParse(detail.Sl, out int qty) || qty <= 0) continue;
- decimal returnPrice = detail.Dj;
+ decimal returnPrice = detail.Thdj.HasValue && detail.Thdj.Value > 0 ? detail.Thdj.Value : detail.Dj;
+
+ // 先回退序列号状态(采购退货出库的序列号恢复为在库)
+ var serials = await _db.Queryable()
+ .Where(s => s.OutDjbh == id && s.Spbh == detail.Spbh)
+ .Select(s => s.SerialNumber)
+ .ToListAsync();
+ if (serials.Any())
+ {
+ await _db.Updateable()
+ .SetColumns(it => new WtSerialNumberEntity
+ {
+ Status = 0,
+ OutDjbh = "",
+ OutDjlx = "",
+ OutWarehouse = "",
+ OutTime = null,
+ OutOperator = ""
+ })
+ .Where(it => serials.Contains(it.SerialNumber))
+ .ExecuteCommandAsync();
+ }
foreach (var whId in warehouseIds)
{