物料条码打印
This commit is contained in:
1 parent
9d6c5639b5
commit
2aa869f1d2
7 files changed
+174
-4
No files matched your search
@@ -0,0 +1,93 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using HHWMS.Web.Models;
|
||||
using ICSharpCode.SharpZipLib.Core;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using WalkingTec.Mvvm.Core;
|
||||
using WalkingTec.Mvvm.Core.Extensions;
|
||||
using WalkingTec.Mvvm.Mvc;
|
||||
|
||||
namespace HHWMS.Web.Controllers
|
||||
{
|
||||
[Area("configs")]
|
||||
[ActionDescription("无单打印")]
|
||||
public partial class Print2Controller : BaseController
|
||||
{
|
||||
private readonly IUnitWork _unitwork;
|
||||
|
||||
public Print2Controller(IUnitWork unitwork)
|
||||
{
|
||||
_unitwork = unitwork;
|
||||
}
|
||||
|
||||
#region Search
|
||||
|
||||
[ActionDescription("Sys.Search")]
|
||||
public ActionResult Index()
|
||||
{
|
||||
var vm = Wtm.CreateVM<ReceiptDetail2VM>();
|
||||
return PartialView(vm);
|
||||
}
|
||||
#endregion Search
|
||||
|
||||
[HttpPost]
|
||||
[ActionDescription("Sys.Create")]
|
||||
[FixConnection(CsName = "hangyong")]
|
||||
public ActionResult Create(ReceiptDetail2VM vm)
|
||||
{
|
||||
if (string.IsNullOrEmpty(vm.Entity.MaterialCode))
|
||||
{
|
||||
return FFResult().Alert("物料必选!");
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(vm.Entity.Batch))
|
||||
{
|
||||
return FFResult().Alert("批次信息不能为空!");
|
||||
}
|
||||
var warehouseId = Wtm.LoginUserInfo.Groups.FirstOrDefault().GroupCode;
|
||||
var dc = Wtm.CreateDC(cskey: "hangyong");
|
||||
Wtm.DC = dc;
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return PartialView(vm);
|
||||
}
|
||||
else
|
||||
{
|
||||
var _unit = new UnitWork(Wtm);
|
||||
var header = new ReceiptHeader2
|
||||
{
|
||||
WarehouseId = int.Parse(warehouseId),
|
||||
Code = _unitwork.GetSerialNumber("SDR"),
|
||||
Type = "SDR",
|
||||
FirstStatus = 0,
|
||||
LastStatus = 0,
|
||||
TotalLines = 1,
|
||||
TotalQty = 0,
|
||||
};
|
||||
_unit.Add(header);
|
||||
|
||||
vm.Entity.WarehouseId = header.WarehouseId;
|
||||
vm.Entity.ReceiptId = header.ID;
|
||||
vm.Entity.ReceiptCode = header?.Code;
|
||||
vm.Entity.Status = 0;
|
||||
var mater = dc.Set<Material2>()
|
||||
.FirstOrDefault(x => x.ID == int.Parse(vm.Entity.MaterialCode));
|
||||
vm.Entity.MaterialCode = mater?.Code;
|
||||
vm.Entity.Lot = mater?.Specification;
|
||||
vm.Entity.Unit = mater?.MasterUnit;
|
||||
vm.DoAdd();
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
vm.DoReInit();
|
||||
return PartialView(vm);
|
||||
}
|
||||
else
|
||||
{
|
||||
return FFResult().Message("Ok!");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
@model HHWMS.Web.ReceiptDetail2VM
|
||||
@inject IStringLocalizer<Program> Localizer;
|
||||
|
||||
<wt:form vm="@Model">
|
||||
<wt:row items-per-row="ItemsPerRowEnum.One">
|
||||
<wt:row id="selector">
|
||||
<wt:selector field="Entity.MaterialCode" list-vm="MaterialList"
|
||||
text-bind="MaterialList.EntityList[0].Code"
|
||||
submit-func="test">
|
||||
<wt:searchpanel vm="MaterialList" expanded="true">
|
||||
<wt:row items-per-row=" ItemsPerRowEnum.Two">
|
||||
<wt:textbox field="MaterialList.Searcher.Code" />
|
||||
<wt:textbox field="MaterialList.Searcher.Name" />
|
||||
<wt:textbox field="MaterialList.Searcher.Specification" />
|
||||
</wt:row>
|
||||
</wt:searchpanel>
|
||||
</wt:selector>
|
||||
</wt:row>
|
||||
<wt:textbox field="Entity.MaterialName"/>
|
||||
<wt:textbox field="Entity.Batch" />
|
||||
<wt:textbox field="Entity.Qty" />
|
||||
<wt:combobox field="Entity.InventoryStatus" items="InventoryStatus" />
|
||||
</wt:row>
|
||||
<wt:hidden field="Entity.ReceiptId" />
|
||||
<wt:row align="AlignEnum.Right">
|
||||
@* <wt:submitbutton submit-url="/configs/Print2/Create" /> *@
|
||||
<wt:button click="print()" text="打印" />
|
||||
@* <wt:closebutton /> *@
|
||||
</wt:row>
|
||||
</wt:form>
|
||||
<script>
|
||||
var value = {};
|
||||
let template = { "panels": [{ "index": 0, "height": 50, "width": 80, "paperHeader": 43.5, "paperFooter": 141.73228346456693, "printElements": [{ "options": { "left": 3, "top": 3, "height": 40, "width": 220, "field": "lot", "textAlign": "center", "textContentVerticalAlign": "middle", "fontFamily": "Microsoft YaHei", "fontSize": 8, "fontWeight": "bold" }, "printElementType": { "type": "text" } }, { "options": { "left": 3, "top": 3, "height": 130, "width": 220, "borderWidth": "1.5", "borderStyle": "solid" }, "printElementType": { "type": "rect" } }, { "options": { "left": 3, "top": 42, "height": 9, "width": 219 }, "printElementType": { "type": "hline" } }, { "options": { "left": 135, "top": 42, "height": 90, "width": 9 }, "printElementType": { "type": "vline" } }, { "options": { "left": 3, "top": 43.5, "height": 28.5, "width": 132, "field": "code", "testData": "1324123412341234123", "textAlign": "center", "textContentVerticalAlign": "middle", "fontFamily": "Microsoft YaHei", "fontSize": 12, "fontWeight": "bold" }, "printElementType": { "type": "text" } }, { "options": { "left": 138, "top": 46.5, "height": 79.5, "width": 81, "textType": "qrcode", "field": "qrcode", "testData": "1234123413234132" }, "printElementType": { "type": "text" } }, { "options": { "left": 3, "top": 72, "height": 30, "width": 132, "field": "qty", "testData": "5555", "textAlign": "center", "textContentVerticalAlign": "middle", "fontFamily": "Microsoft YaHei", "fontSize": 12, "fontWeight": "bold" }, "printElementType": { "type": "text" } }, { "options": { "left": 3, "top": 72, "height": 9, "width": 132 }, "printElementType": { "type": "hline" } }, { "options": { "left": 3, "top": 102, "height": 9, "width": 132 }, "printElementType": { "type": "hline" } }, { "options": { "left": 4.5, "top": 102, "height": 28.5, "width": 132, "field": "batch", "testData": "HYB2202030003", "textAlign": "center", "textContentVerticalAlign": "middle", "fontFamily": "Microsoft YaHei", "fontSize": 12, "fontWeight": "bold" }, "printElementType": { "type": "text" } }], "paperNumberLeft": 196.5, "paperNumberTop": 118.5, "paperNumberDisabled": true }] };
|
||||
|
||||
let printData = [];
|
||||
|
||||
function test(val) {
|
||||
$('#ReceiptDetail2VM_Entity_MaterialName').val(val[0].Name);
|
||||
value = val[0];
|
||||
console.log(value);
|
||||
ReceiptDetail2VM_Entity_InventoryStatus.setValue([val[0].ClassA]);
|
||||
}
|
||||
function print(){
|
||||
var batch = $('#ReceiptDetail2VM_Entity_Batch').val();
|
||||
var qty = $('#ReceiptDetail2VM_Entity_Qty').val();
|
||||
console.log(value.Code)
|
||||
if (value.Code == undefined) {
|
||||
layer.alert("物料必选");
|
||||
return;
|
||||
}
|
||||
if (batch == "") {
|
||||
layer.alert("批次必填");
|
||||
return;
|
||||
}
|
||||
if (qty == "") {
|
||||
layer.alert("数量必填");
|
||||
return;
|
||||
}
|
||||
|
||||
printData.push({
|
||||
lot: value.Name + '|' + value.Specification,
|
||||
code: value.Code,
|
||||
batch: batch,
|
||||
qty: qty,
|
||||
qrcode: 'MT.' + value.Code + '@@@@LT.' + batch + '@@@@QT.' + qty
|
||||
})
|
||||
|
||||
hiprint.init();
|
||||
var hiprintTemplate = new hiprint.PrintTemplate({
|
||||
template: template
|
||||
});
|
||||
hiprintTemplate.print(printData);
|
||||
printData = [];
|
||||
}
|
||||
</script>
|
||||
@@ -99,7 +99,7 @@ namespace HHWMS.Web.Controllers
|
||||
}
|
||||
}
|
||||
|
||||
[ActionDescription("Sys.Create")]
|
||||
[ActionDescription("Sys.Create2")]
|
||||
public ActionResult Create2()
|
||||
{
|
||||
var vm = Wtm.CreateVM<ReceiptDetail2VM>();
|
||||
@@ -107,7 +107,7 @@ namespace HHWMS.Web.Controllers
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[ActionDescription("Sys.Create")]
|
||||
[ActionDescription("Sys.Create2")]
|
||||
[FixConnection(CsName = "hangyong")]
|
||||
public ActionResult Create2(ReceiptDetail2VM vm)
|
||||
{
|
||||
|
||||
@@ -36,6 +36,7 @@ namespace HHWMS.Web
|
||||
this.MakeGridHeader(x => x.Type),
|
||||
this.MakeGridHeader(x => x.Name).SetWidth(150),
|
||||
this.MakeGridHeader(x => x.MasterUnit),
|
||||
this.MakeGridHeader(x => x.Specification).SetHide(),
|
||||
this.MakeGridHeader(x => x.ClassA).SetHide(),
|
||||
this.MakeGridHeaderAction(width: 200)
|
||||
};
|
||||
|
||||
@@ -29,6 +29,7 @@ namespace HHWMS.Web
|
||||
public String ClassA { get; set; }
|
||||
public String ClassB { get; set; }
|
||||
public String ClassC { get; set; }
|
||||
[Display(Name = "Inventory.MaterialSpec")]
|
||||
public String Specification { get; set; }
|
||||
public String Brand { get; set; }
|
||||
public String Size { get; set; }
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<wt:selector field="Entity.MaterialCode" list-vm="MaterialList"
|
||||
text-bind="MaterialList.EntityList[0].Code"
|
||||
submit-func="test">
|
||||
<wt:searchpanel vm="MaterialList">
|
||||
<wt:searchpanel vm="MaterialList" expanded="true">
|
||||
<wt:row items-per-row=" ItemsPerRowEnum.Two">
|
||||
<wt:textbox field="MaterialList.Searcher.Code" />
|
||||
<wt:textbox field="MaterialList.Searcher.Name" />
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<wt:selector field="Entity.MaterialCode" list-vm="MaterialList"
|
||||
text-bind="MaterialList.EntityList[0].Code"
|
||||
submit-func="test">
|
||||
<wt:searchpanel vm="MaterialList">
|
||||
<wt:searchpanel vm="MaterialList" expanded="true">
|
||||
<wt:row items-per-row=" ItemsPerRowEnum.Two">
|
||||
<wt:textbox field="MaterialList.Searcher.Code" />
|
||||
<wt:textbox field="MaterialList.Searcher.Name" />
|
||||
|
||||
Reference in new issue
Block a user