新增货架出入库 和打印操作
This commit is contained in:
1 parent
c27a357771
commit
6a1329d74e
17 files changed
+620
-9
No files matched your search
@@ -217,6 +217,7 @@ namespace HHWMS.Web.Controllers
|
||||
|
||||
public class Binding
|
||||
{
|
||||
public int ID { get; set; }
|
||||
public string ReceiptCode { get; set; }
|
||||
public string UniqueCode { get; set; }
|
||||
public string BoxCode { get; set; }
|
||||
|
||||
@@ -0,0 +1,137 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection.Emit;
|
||||
using HHWMS.Web.Models;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using NPOI.SS.Formula.Functions;
|
||||
using WalkingTec.Mvvm.Core;
|
||||
using WalkingTec.Mvvm.Mvc;
|
||||
|
||||
namespace HHWMS.Web.Controllers;
|
||||
|
||||
[Area("receipt")]
|
||||
[ActionDescription("货架入库")]
|
||||
public class ReceiptShelfInController : BaseController
|
||||
{
|
||||
private readonly IUnitWork _unitWork;
|
||||
|
||||
public ReceiptShelfInController(IUnitWork unitWork)
|
||||
{
|
||||
_unitWork = unitWork;
|
||||
}
|
||||
|
||||
#region Search
|
||||
|
||||
[ActionDescription("Sys.Search")]
|
||||
public ActionResult Index()
|
||||
{
|
||||
return PartialView("Index");
|
||||
}
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// 扫描唯一码,并验证,返回入库单明细
|
||||
/// </summary>
|
||||
/// <param name="uniqueCode"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public ActionResult ScanUniqueCode(string uniqueCode)
|
||||
{
|
||||
var receiptDetail = _unitWork.FindSingle<ReceiptDetail>(x => x.UniqueCode.Equals(uniqueCode));
|
||||
if (receiptDetail != null)
|
||||
{
|
||||
if (receiptDetail.Status == ReceiptStatusEnum.收完)
|
||||
{
|
||||
return JsonMore(null, 500, $"{uniqueCode}已全部收完,无需重新绑定!");
|
||||
}
|
||||
return JsonMore(receiptDetail);
|
||||
}
|
||||
return JsonMore(null, 500, $"{uniqueCode}不存在!");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 绑定
|
||||
/// </summary>
|
||||
/// <param name="data"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public ActionResult BindingData(List<Binding> data)
|
||||
{
|
||||
var receiptHeaderList = _unitWork.Find<ReceiptHeader>(x =>
|
||||
data.Select(x => x.ReceiptCode).ToList().Contains(x.ID.ToString()))
|
||||
.Include(x => x.ReceiptDetails).ToList();
|
||||
|
||||
var invList = new List<Inventory>();
|
||||
var listInvtran = new List<InventoryTransaction>();
|
||||
|
||||
// 查找明细,修改对应状态,并且 绑定物料周转箱
|
||||
foreach (Binding item in data.OrderBy(x => x.ReceiptCode))
|
||||
{
|
||||
// 更新入库单明细状态
|
||||
var header = receiptHeaderList.Find(x => x.ID.ToString().Equals(item.ReceiptCode));
|
||||
var receipt = header.ReceiptDetails.First(x => x.UniqueCode.Equals(item.UniqueCode));
|
||||
if (receipt != null)
|
||||
{
|
||||
if (receipt.Status == ReceiptStatusEnum.收完) continue;
|
||||
receipt.CompletedQty += item.BindQty;
|
||||
}
|
||||
if(receipt.CompletedQty == receipt.Qty)
|
||||
{
|
||||
receipt.Status = ReceiptStatusEnum.收完;
|
||||
if (!header.ReceiptDetails.Any(x => x.Status < ReceiptStatusEnum.收完))
|
||||
{
|
||||
header.FirstStatus = ReceiptStatusEnum.收完;
|
||||
}
|
||||
receipt.UpdateTime = DateTime.Now;
|
||||
}
|
||||
|
||||
// 新建库存
|
||||
invList.Add(new Inventory
|
||||
{
|
||||
ZoneCode = ZoneCodeEnum.货架库,
|
||||
UniqueCode = item.UniqueCode,
|
||||
MaterialCode = receipt.MaterialCode,
|
||||
MaterialType = receipt.MaterialType,
|
||||
MaterialName = receipt.MaterialName,
|
||||
MaterialSpec = receipt.MaterialSpec,
|
||||
Batch = receipt.Batch,
|
||||
MaterialUnit = receipt.MaterialUnit,
|
||||
SupplierCode = receipt.SupplierCode,
|
||||
Qty = item.BindQty,
|
||||
Status = "0",
|
||||
TaskStatus = InventoryTaskStatus.无任务,
|
||||
CreateBy = Wtm.LoginUserInfo.ITCode,
|
||||
CreateTime = DateTime.Now
|
||||
}); ;
|
||||
|
||||
foreach (var inv in invList)
|
||||
{
|
||||
listInvtran.Add(new InventoryTransaction
|
||||
{
|
||||
BillType = "in",
|
||||
ZoneCode = inv.ZoneCode,
|
||||
Type = inv.UniqueCode,
|
||||
MaterialCode = inv.MaterialCode,
|
||||
MaterialName = inv.MaterialName,
|
||||
MaterialSpec = inv.MaterialSpec,
|
||||
MaterialUnit = inv.MaterialUnit,
|
||||
MaterialType = inv.MaterialType,
|
||||
Batch = inv.Batch,
|
||||
Lot = inv.Lot,
|
||||
CompanyCode = inv.CompanyCode,
|
||||
LocationCode = inv.LocationCode,
|
||||
SupplierCode = inv.SupplierCode,
|
||||
Qty = inv.Qty,
|
||||
CreateTime = DateTime.Now
|
||||
});
|
||||
}
|
||||
}
|
||||
_unitWork.BatchAdd(invList.ToArray());
|
||||
_unitWork.BatchAdd(listInvtran.ToArray());
|
||||
_unitWork.BatchUpdate(receiptHeaderList.ToArray());
|
||||
return JsonMore(null);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -86,7 +86,7 @@ namespace HHWMS.Web
|
||||
AppointmentTime = x.AppointmentTime,
|
||||
Remark = x.Remark,
|
||||
})
|
||||
.OrderBy(x => x.ID);
|
||||
.OrderByDescending(x => x.ID);
|
||||
return query;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,173 @@
|
||||
<el-row id="slapp">
|
||||
<el-card class="box-card" :span="16">
|
||||
<el-form ref="form" :model="form" label-width="100px">
|
||||
<el-row>
|
||||
<el-col :span="16">
|
||||
<el-form-item label="唯一码" prop="uniqueCode">
|
||||
<el-input v-model="form.uniqueCode"
|
||||
@@change="scanUniqueCode"
|
||||
ref="uniqueCode">
|
||||
</el-input>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-table :data="bindingData" stripe max-height="450" border style="width: 100%">
|
||||
<el-table-column fixed="left" label="操作" width="120" align="center">
|
||||
<template slot-scope="scope">
|
||||
<el-button @@click.native.prevent="deleteRow(scope.$index, bindingData)"
|
||||
type="text"
|
||||
size="small">
|
||||
移除
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="唯一码"
|
||||
align="center"
|
||||
prop="uniqueCode">
|
||||
</el-table-column>
|
||||
<el-table-column label="物料码"
|
||||
align="center"
|
||||
prop="materialCode">
|
||||
</el-table-column>
|
||||
<el-table-column label="名称"
|
||||
align="center"
|
||||
prop="materialName">
|
||||
</el-table-column>
|
||||
<el-table-column label="数量"
|
||||
align="center"
|
||||
prop="bindQty">
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<el-form-item style="float: right">
|
||||
<el-button type="primary" @@click="onSubmit">入库</el-button>
|
||||
<el-button @@click="resetForm('form')">重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-card>
|
||||
</el-row>
|
||||
|
||||
<script>
|
||||
var app = new Vue({
|
||||
el: "#slapp",
|
||||
data() {
|
||||
return {
|
||||
form: {
|
||||
uniqueCode: "",
|
||||
},
|
||||
bindingData: []
|
||||
};
|
||||
},
|
||||
mounted: function () {
|
||||
// 获取所有单据编码
|
||||
// $.ajax({
|
||||
// type: "post",
|
||||
// dataType: "json",
|
||||
// data:{},
|
||||
// url: "/receipt/ReceiptIn/SelectReceiptCode",
|
||||
// success: function (json) {
|
||||
// app.options = json.Data;
|
||||
// },
|
||||
// error: function (json) {
|
||||
// alert("加载失败");
|
||||
// }
|
||||
// });
|
||||
},
|
||||
methods: {
|
||||
|
||||
// 绑定
|
||||
onSubmit() {
|
||||
var _this = this;
|
||||
|
||||
// 提交已绑定数据
|
||||
$.ajax({
|
||||
type: "post",
|
||||
dataType: "json",
|
||||
data: { data: _this.bindingData },
|
||||
url: "/receipt/ReceiptShelfIn/BindingData",
|
||||
success: function (json) {
|
||||
if (json.Code == 200) {
|
||||
_this.$message({
|
||||
message: "入库成功!",
|
||||
});
|
||||
_this.bindingData = [];
|
||||
} else {
|
||||
_this.$message({
|
||||
message: "入库失败!",
|
||||
type: "warning",
|
||||
duration: "10000",
|
||||
});
|
||||
}
|
||||
},
|
||||
error: function (json) {
|
||||
_this.$message({
|
||||
message: "入库失败!",
|
||||
type: "error",
|
||||
duration: "10000",
|
||||
});
|
||||
},
|
||||
});
|
||||
},
|
||||
// 重置
|
||||
resetForm(formName) {
|
||||
this.$refs[formName].resetFields();
|
||||
this.bindingData = [];
|
||||
},
|
||||
// 扫描唯一码
|
||||
scanUniqueCode(data) {
|
||||
var _this = this;
|
||||
|
||||
//1. 判断唯一码是否合理,调用后台,并返回唯一码对应的数量
|
||||
var isExit = this.bindingData.findIndex(function (value) {
|
||||
return value.uniqueCode == data;
|
||||
})
|
||||
if (isExit != -1) {
|
||||
this.$message({
|
||||
message: '唯一码' + data + '已绑定!',
|
||||
type: 'warning'
|
||||
});
|
||||
this.form.uniqueCode = '';
|
||||
return;
|
||||
}
|
||||
$.ajax({
|
||||
type: "post",
|
||||
dataType: "json",
|
||||
data: { uniqueCode: _this.form.uniqueCode },
|
||||
url: "/receipt/ReceiptShelfIn/ScanUniqueCode",
|
||||
success: function (json) {
|
||||
if (json.Code != 200) {
|
||||
_this.$message({
|
||||
message: json.Msg,
|
||||
type: "warning",
|
||||
duration: "10000",
|
||||
});
|
||||
} else {
|
||||
// 3.已扫描增加
|
||||
_this.bindingData.push({
|
||||
receiptCode: json.Data.ReceiptHeaderId,
|
||||
uniqueCode: json.Data.UniqueCode,
|
||||
materialCode: json.Data.MaterialCode,
|
||||
materialName: json.Data.MaterialName,
|
||||
batch: json.Data.Batch,
|
||||
bindQty: json.Data.Qty,
|
||||
});
|
||||
}
|
||||
},
|
||||
error: function (json) {
|
||||
_this.$message({
|
||||
message: "扫描失败!",
|
||||
type: "error",
|
||||
duration: "10000",
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
this.form.uniqueCode = "";
|
||||
},
|
||||
// 删除已绑定行
|
||||
deleteRow(index, rows) {
|
||||
rows.splice(index, 1);
|
||||
},
|
||||
|
||||
},
|
||||
});
|
||||
</script>
|
||||
Reference in new issue
Block a user