成品添加单据
This commit is contained in:
1 parent
287453691b
commit
00119151c9
2 files changed
+134
-35
No files matched your search
@@ -71,6 +71,7 @@ namespace HHWMS.Web.Controllers
|
||||
MaterialName = x.MaterialType,
|
||||
MaterialSpec = x.MaterialSpec,
|
||||
CompanyCode = x.CompanyCode,
|
||||
x.SourceCode,
|
||||
Batch = x.Batch,
|
||||
Qty = (int)x.Qty
|
||||
})
|
||||
@@ -133,39 +134,43 @@ namespace HHWMS.Web.Controllers
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public ActionResult AddInventory(string containerCode, string materialCode, string company, string sourceCode, decimal qty, string batch)
|
||||
public ActionResult AddInventory([FromBody] SimpleReceiptInModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (string.IsNullOrEmpty(containerCode))
|
||||
if (string.IsNullOrEmpty(model.ContainerCode))
|
||||
{
|
||||
return JsonMore(null, 500, "容器编码为空!");
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(materialCode))
|
||||
if (string.IsNullOrEmpty(model.MaterialCode))
|
||||
{
|
||||
return JsonMore(null, 500, "物料编码为空!");
|
||||
}
|
||||
|
||||
if (qty <= 0)
|
||||
if (model.Qty <= 0)
|
||||
{
|
||||
return JsonMore(null, 500, "数量必须大于0!");
|
||||
}
|
||||
|
||||
// 查询容器
|
||||
var container = _unitWork.FindSingle<Container>(u => u.Code == containerCode);
|
||||
var container = _unitWork.FindSingle<Container>(u => u.Code == model.ContainerCode);
|
||||
if (container == null)
|
||||
{
|
||||
return JsonMore(null, 500, $"库内没有编码为 {containerCode} 的容器!");
|
||||
return JsonMore(null, 500, $"库内没有编码为 {model.ContainerCode} 的容器!");
|
||||
}
|
||||
|
||||
// 查询物料信息
|
||||
var material = _unitWork.FindSingle<Material>(x => x.MaterialCode == materialCode);
|
||||
var material = _unitWork.FindSingle<Material>(x => x.MaterialCode == model.MaterialCode);
|
||||
if (material == null)
|
||||
{
|
||||
return JsonMore(null, 500, $"未找到物料编码为 {materialCode} 的物料信息!");
|
||||
return JsonMore(null, 500, $"未找到物料编码为 {model.MaterialCode} 的物料信息!");
|
||||
}
|
||||
|
||||
var batchCode = _unitWork.Find<MaterialProcess>(x => x.MaterialCode == material.MaterialCode)
|
||||
.OrderByDescending(x => x.ProcessOrder)
|
||||
.FirstOrDefault()
|
||||
?.ProcessCode;
|
||||
var zone = _unitWork.FindSingle<LocationZone>(x => x.ZoneCode == container.Type);
|
||||
// 创建库存记录
|
||||
var inventory = new Inventory()
|
||||
@@ -177,13 +182,16 @@ namespace HHWMS.Web.Controllers
|
||||
MaterialType = material.MaterialType,
|
||||
MaterialSpec = material.MaterialSpec,
|
||||
MaterialUnit = material.MaterialUnit,
|
||||
CompanyCode = company,
|
||||
SourceCode = sourceCode,
|
||||
CompanyCode = model.CompanyCode,
|
||||
SourceCode = model.OrderId,
|
||||
ReceiptDetailId = model.SourceCode, // 优先使用 OrderId
|
||||
SupplierCode = material.SupplierCode,
|
||||
Batch = batch,
|
||||
Qty = qty,
|
||||
Batch = model.Batch,
|
||||
Qty = model.Qty,
|
||||
BatchCode = batchCode,
|
||||
TaskStatus = InventoryTaskStatusEnum.Locked,
|
||||
CreateTime = DateTime.Now
|
||||
CreateTime = DateTime.Now,
|
||||
CreateBy = Wtm.LoginUserInfo.ITCode
|
||||
};
|
||||
_unitWork.Add(inventory);
|
||||
|
||||
@@ -542,4 +550,51 @@ namespace HHWMS.Web.Controllers
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 成品入库请求模型
|
||||
/// </summary>
|
||||
public class SimpleReceiptInModel
|
||||
{
|
||||
/// <summary>
|
||||
/// 托盘编码
|
||||
/// </summary>
|
||||
public string ContainerCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 物料编码
|
||||
/// </summary>
|
||||
public string MaterialCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 物料名称(图号)
|
||||
/// </summary>
|
||||
public string MaterialName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 物料规格
|
||||
/// </summary>
|
||||
public string MaterialSpec { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 部件名称(批次)
|
||||
/// </summary>
|
||||
public string Batch { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 订单号(上游单号)
|
||||
/// </summary>
|
||||
public string SourceCode { get; set; }
|
||||
public string OrderId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 公司
|
||||
/// </summary>
|
||||
public string CompanyCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 数量
|
||||
/// </summary>
|
||||
public decimal Qty { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -30,17 +30,18 @@
|
||||
placeholder="输入部件名称"
|
||||
allow-clear
|
||||
@@keydown.enter="$nextTick(() => {
|
||||
$refs.sourceCodeInput.focus();
|
||||
$refs.sourceCodeSelect.focus();
|
||||
})"/>/>
|
||||
</a-form-item>
|
||||
<a-form-item field="sourceCode" label="订单号">
|
||||
<a-input
|
||||
<a-select
|
||||
v-model="formData.sourceCode"
|
||||
placeholder="输入订单号"
|
||||
ref="sourceCodeInput"
|
||||
@@keydown.enter="$nextTick(() => {
|
||||
$refs.companyCodeInput.focus();
|
||||
})"/>
|
||||
:options="orderOptions"
|
||||
placeholder="请选择订单号"
|
||||
allow-search
|
||||
ref="sourceCodeSelect"
|
||||
@@change="handleOrderSelect">
|
||||
</a-select>
|
||||
</a-form-item>
|
||||
<a-form-item field="companyCode" label="公司">
|
||||
<a-auto-complete
|
||||
@@ -126,6 +127,7 @@
|
||||
return {
|
||||
loading1: false,
|
||||
materialOptions: [],
|
||||
orderOptions: [],
|
||||
searchTimer: null,
|
||||
bindList: [],
|
||||
editModalVisible: false,
|
||||
@@ -207,6 +209,7 @@
|
||||
materialSpec: '',
|
||||
batch: '',
|
||||
sourceCode: '',
|
||||
orderId: '',
|
||||
companyCode: '',
|
||||
qty: null
|
||||
},
|
||||
@@ -294,7 +297,7 @@
|
||||
},
|
||||
|
||||
searchMaterials(keyword) {
|
||||
axios.get(`/receipt/SimpleReceiptIn/SearchMaterials?keyword=${encodeURIComponent(keyword)}`)
|
||||
axios.get(`/receipt/ReceiptIn/SearchMaterials?keyword=${encodeURIComponent(keyword)}`)
|
||||
.then((response) => {
|
||||
const json = response.data;
|
||||
if (json.Code == 200) {
|
||||
@@ -321,6 +324,9 @@
|
||||
this.formData.materialCode = selectedMaterial.MaterialCode;
|
||||
this.formData.materialName = selectedMaterial.MaterialType;
|
||||
this.formData.materialSpec = selectedMaterial.MaterialSpec;
|
||||
|
||||
// 选择物料后加载订单列表
|
||||
this.loadOrdersByMaterial(selectedMaterial.MaterialCode);
|
||||
}
|
||||
|
||||
this.$nextTick(() => {
|
||||
@@ -328,6 +334,47 @@
|
||||
});
|
||||
},
|
||||
|
||||
// 根据物料加载订单列表
|
||||
loadOrdersByMaterial(materialCode) {
|
||||
if (!materialCode) {
|
||||
this.formData.sourceCode = '';
|
||||
this.orderOptions = [];
|
||||
return;
|
||||
}
|
||||
|
||||
this.orderOptions = [];
|
||||
const postData = new URLSearchParams();
|
||||
postData.append('materialCode', materialCode);
|
||||
|
||||
axios.post('/receipt/ReceiptIn/GetOrdersByMaterial', postData)
|
||||
.then((response) => {
|
||||
const json = response.data;
|
||||
if (json.Code == 200) {
|
||||
this.orderOptions = json.Data || [];
|
||||
if (this.orderOptions.length === 0) {
|
||||
this.$message.warning('该物料暂无关联订单');
|
||||
}
|
||||
} else {
|
||||
this.$message.error(json.Msg || '获取订单列表失败');
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error('获取订单列表失败:', error);
|
||||
this.$message.error('获取订单列表失败: ' + (error.message || '网络错误'));
|
||||
});
|
||||
},
|
||||
|
||||
// 处理订单选择
|
||||
handleOrderSelect(value) {
|
||||
const selectedOrder = this.orderOptions.find(item => item.value === value);
|
||||
if (selectedOrder) {
|
||||
this.formData.orderId = selectedOrder.label; // 设置 OrderId 为订单号
|
||||
}
|
||||
this.$nextTick(() => {
|
||||
this.$refs.companyCodeInput?.focus();
|
||||
});
|
||||
},
|
||||
|
||||
handleBind() {
|
||||
// 表单验证
|
||||
if (!this.formData.containerCode) {
|
||||
@@ -352,34 +399,29 @@
|
||||
}
|
||||
}
|
||||
|
||||
// 添加到绑定列表
|
||||
const bindItem = {
|
||||
// 构建请求数据
|
||||
const requestData = {
|
||||
ContainerCode: this.formData.containerCode,
|
||||
MaterialCode: this.formData.materialCode,
|
||||
MaterialName: this.formData.materialName,
|
||||
MaterialSpec: this.formData.materialSpec,
|
||||
Batch: this.formData.batch,
|
||||
SourceCode: this.formData.sourceCode,
|
||||
OrderId: this.formData.orderId,
|
||||
CompanyCode: this.formData.companyCode,
|
||||
Qty: this.formData.qty
|
||||
};
|
||||
|
||||
// 调用后端添加库存
|
||||
let postData = new URLSearchParams();
|
||||
postData.append('containerCode', this.formData.containerCode);
|
||||
postData.append('materialCode', this.formData.materialCode);
|
||||
postData.append('company', this.formData.companyCode);
|
||||
postData.append('sourceCode', this.formData.sourceCode);
|
||||
postData.append('qty', this.formData.qty);
|
||||
postData.append('batch', this.formData.batch);
|
||||
|
||||
axios.post("/receipt/SimpleReceiptIn/AddInventory", postData)
|
||||
axios.post("/receipt/SimpleReceiptIn/AddInventory", requestData, {
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
})
|
||||
.then((response) => {
|
||||
const json = response.data;
|
||||
if (json.Code == 200) {
|
||||
// 添加ID到绑定项
|
||||
bindItem.Id = json.Data.Id;
|
||||
this.bindList.unshift(bindItem);
|
||||
|
||||
this.$message.success("物料绑定成功");
|
||||
this.saveToHistory('batch', this.formData.batch);
|
||||
// 清空表单
|
||||
@@ -405,8 +447,10 @@
|
||||
this.formData.materialSpec = '';
|
||||
this.formData.batch = '';
|
||||
this.formData.sourceCode = '';
|
||||
this.formData.orderId = '';
|
||||
this.formData.companyCode = '';
|
||||
this.formData.qty = null;
|
||||
this.orderOptions = [];
|
||||
|
||||
// 页面加载完成后,将焦点设置到容器编码输入框
|
||||
this.$nextTick(() => {
|
||||
|
||||
Reference in new issue
Block a user