成品添加单据
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,
|
MaterialName = x.MaterialType,
|
||||||
MaterialSpec = x.MaterialSpec,
|
MaterialSpec = x.MaterialSpec,
|
||||||
CompanyCode = x.CompanyCode,
|
CompanyCode = x.CompanyCode,
|
||||||
|
x.SourceCode,
|
||||||
Batch = x.Batch,
|
Batch = x.Batch,
|
||||||
Qty = (int)x.Qty
|
Qty = (int)x.Qty
|
||||||
})
|
})
|
||||||
@@ -133,39 +134,43 @@ namespace HHWMS.Web.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public ActionResult AddInventory(string containerCode, string materialCode, string company, string sourceCode, decimal qty, string batch)
|
public ActionResult AddInventory([FromBody] SimpleReceiptInModel model)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(containerCode))
|
if (string.IsNullOrEmpty(model.ContainerCode))
|
||||||
{
|
{
|
||||||
return JsonMore(null, 500, "容器编码为空!");
|
return JsonMore(null, 500, "容器编码为空!");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(materialCode))
|
if (string.IsNullOrEmpty(model.MaterialCode))
|
||||||
{
|
{
|
||||||
return JsonMore(null, 500, "物料编码为空!");
|
return JsonMore(null, 500, "物料编码为空!");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (qty <= 0)
|
if (model.Qty <= 0)
|
||||||
{
|
{
|
||||||
return JsonMore(null, 500, "数量必须大于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)
|
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)
|
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 zone = _unitWork.FindSingle<LocationZone>(x => x.ZoneCode == container.Type);
|
||||||
// 创建库存记录
|
// 创建库存记录
|
||||||
var inventory = new Inventory()
|
var inventory = new Inventory()
|
||||||
@@ -177,13 +182,16 @@ namespace HHWMS.Web.Controllers
|
|||||||
MaterialType = material.MaterialType,
|
MaterialType = material.MaterialType,
|
||||||
MaterialSpec = material.MaterialSpec,
|
MaterialSpec = material.MaterialSpec,
|
||||||
MaterialUnit = material.MaterialUnit,
|
MaterialUnit = material.MaterialUnit,
|
||||||
CompanyCode = company,
|
CompanyCode = model.CompanyCode,
|
||||||
SourceCode = sourceCode,
|
SourceCode = model.OrderId,
|
||||||
|
ReceiptDetailId = model.SourceCode, // 优先使用 OrderId
|
||||||
SupplierCode = material.SupplierCode,
|
SupplierCode = material.SupplierCode,
|
||||||
Batch = batch,
|
Batch = model.Batch,
|
||||||
Qty = qty,
|
Qty = model.Qty,
|
||||||
|
BatchCode = batchCode,
|
||||||
TaskStatus = InventoryTaskStatusEnum.Locked,
|
TaskStatus = InventoryTaskStatusEnum.Locked,
|
||||||
CreateTime = DateTime.Now
|
CreateTime = DateTime.Now,
|
||||||
|
CreateBy = Wtm.LoginUserInfo.ITCode
|
||||||
};
|
};
|
||||||
_unitWork.Add(inventory);
|
_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="输入部件名称"
|
placeholder="输入部件名称"
|
||||||
allow-clear
|
allow-clear
|
||||||
@@keydown.enter="$nextTick(() => {
|
@@keydown.enter="$nextTick(() => {
|
||||||
$refs.sourceCodeInput.focus();
|
$refs.sourceCodeSelect.focus();
|
||||||
})"/>/>
|
})"/>/>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
<a-form-item field="sourceCode" label="订单号">
|
<a-form-item field="sourceCode" label="订单号">
|
||||||
<a-input
|
<a-select
|
||||||
v-model="formData.sourceCode"
|
v-model="formData.sourceCode"
|
||||||
placeholder="输入订单号"
|
:options="orderOptions"
|
||||||
ref="sourceCodeInput"
|
placeholder="请选择订单号"
|
||||||
@@keydown.enter="$nextTick(() => {
|
allow-search
|
||||||
$refs.companyCodeInput.focus();
|
ref="sourceCodeSelect"
|
||||||
})"/>
|
@@change="handleOrderSelect">
|
||||||
|
</a-select>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
<a-form-item field="companyCode" label="公司">
|
<a-form-item field="companyCode" label="公司">
|
||||||
<a-auto-complete
|
<a-auto-complete
|
||||||
@@ -126,6 +127,7 @@
|
|||||||
return {
|
return {
|
||||||
loading1: false,
|
loading1: false,
|
||||||
materialOptions: [],
|
materialOptions: [],
|
||||||
|
orderOptions: [],
|
||||||
searchTimer: null,
|
searchTimer: null,
|
||||||
bindList: [],
|
bindList: [],
|
||||||
editModalVisible: false,
|
editModalVisible: false,
|
||||||
@@ -207,6 +209,7 @@
|
|||||||
materialSpec: '',
|
materialSpec: '',
|
||||||
batch: '',
|
batch: '',
|
||||||
sourceCode: '',
|
sourceCode: '',
|
||||||
|
orderId: '',
|
||||||
companyCode: '',
|
companyCode: '',
|
||||||
qty: null
|
qty: null
|
||||||
},
|
},
|
||||||
@@ -294,7 +297,7 @@
|
|||||||
},
|
},
|
||||||
|
|
||||||
searchMaterials(keyword) {
|
searchMaterials(keyword) {
|
||||||
axios.get(`/receipt/SimpleReceiptIn/SearchMaterials?keyword=${encodeURIComponent(keyword)}`)
|
axios.get(`/receipt/ReceiptIn/SearchMaterials?keyword=${encodeURIComponent(keyword)}`)
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
const json = response.data;
|
const json = response.data;
|
||||||
if (json.Code == 200) {
|
if (json.Code == 200) {
|
||||||
@@ -321,6 +324,9 @@
|
|||||||
this.formData.materialCode = selectedMaterial.MaterialCode;
|
this.formData.materialCode = selectedMaterial.MaterialCode;
|
||||||
this.formData.materialName = selectedMaterial.MaterialType;
|
this.formData.materialName = selectedMaterial.MaterialType;
|
||||||
this.formData.materialSpec = selectedMaterial.MaterialSpec;
|
this.formData.materialSpec = selectedMaterial.MaterialSpec;
|
||||||
|
|
||||||
|
// 选择物料后加载订单列表
|
||||||
|
this.loadOrdersByMaterial(selectedMaterial.MaterialCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.$nextTick(() => {
|
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() {
|
handleBind() {
|
||||||
// 表单验证
|
// 表单验证
|
||||||
if (!this.formData.containerCode) {
|
if (!this.formData.containerCode) {
|
||||||
@@ -352,34 +399,29 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 添加到绑定列表
|
// 构建请求数据
|
||||||
const bindItem = {
|
const requestData = {
|
||||||
ContainerCode: this.formData.containerCode,
|
ContainerCode: this.formData.containerCode,
|
||||||
MaterialCode: this.formData.materialCode,
|
MaterialCode: this.formData.materialCode,
|
||||||
MaterialName: this.formData.materialName,
|
MaterialName: this.formData.materialName,
|
||||||
MaterialSpec: this.formData.materialSpec,
|
MaterialSpec: this.formData.materialSpec,
|
||||||
Batch: this.formData.batch,
|
Batch: this.formData.batch,
|
||||||
SourceCode: this.formData.sourceCode,
|
SourceCode: this.formData.sourceCode,
|
||||||
|
OrderId: this.formData.orderId,
|
||||||
CompanyCode: this.formData.companyCode,
|
CompanyCode: this.formData.companyCode,
|
||||||
Qty: this.formData.qty
|
Qty: this.formData.qty
|
||||||
};
|
};
|
||||||
|
|
||||||
// 调用后端添加库存
|
// 调用后端添加库存
|
||||||
let postData = new URLSearchParams();
|
axios.post("/receipt/SimpleReceiptIn/AddInventory", requestData, {
|
||||||
postData.append('containerCode', this.formData.containerCode);
|
headers: {
|
||||||
postData.append('materialCode', this.formData.materialCode);
|
'Content-Type': 'application/json'
|
||||||
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)
|
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
const json = response.data;
|
const json = response.data;
|
||||||
if (json.Code == 200) {
|
if (json.Code == 200) {
|
||||||
// 添加ID到绑定项
|
|
||||||
bindItem.Id = json.Data.Id;
|
|
||||||
this.bindList.unshift(bindItem);
|
|
||||||
this.$message.success("物料绑定成功");
|
this.$message.success("物料绑定成功");
|
||||||
this.saveToHistory('batch', this.formData.batch);
|
this.saveToHistory('batch', this.formData.batch);
|
||||||
// 清空表单
|
// 清空表单
|
||||||
@@ -405,8 +447,10 @@
|
|||||||
this.formData.materialSpec = '';
|
this.formData.materialSpec = '';
|
||||||
this.formData.batch = '';
|
this.formData.batch = '';
|
||||||
this.formData.sourceCode = '';
|
this.formData.sourceCode = '';
|
||||||
|
this.formData.orderId = '';
|
||||||
this.formData.companyCode = '';
|
this.formData.companyCode = '';
|
||||||
this.formData.qty = null;
|
this.formData.qty = null;
|
||||||
|
this.orderOptions = [];
|
||||||
|
|
||||||
// 页面加载完成后,将焦点设置到容器编码输入框
|
// 页面加载完成后,将焦点设置到容器编码输入框
|
||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
|
|||||||
Reference in new issue
Block a user