打印模板管理,设计

This commit is contained in:
Mac mini git server 2024-11-05 23:27:55 +08:00
parent 53dfc9ef1d
commit ad932a7050
15 changed files with 283 additions and 120 deletions

7
.gitignore vendored
View File

@ -41,6 +41,8 @@ bld/
# Visual Studio 2015 cache/options directory
.vs/
.rider/
.idea/
# Uncomment if you have tasks that create the project's static files in wwwroot
#wwwroot/
@ -279,4 +281,7 @@ __pycache__/
/nuget.exe
/demo/WalkingTec.Mvvm.VueDemo/ClientApp/yarn.lock
*.lock
*.DS_Store
.DS_Store
[core]
autocrlf = input

View File

@ -3,7 +3,7 @@
"isRoot": true,
"tools": {
"dotnet-ef": {
"version": "5.0.2",
"version": "6.0.11",
"commands": [
"dotnet-ef"
]

View File

@ -9,7 +9,7 @@ using WalkingTec.Mvvm.Core;
namespace HHWMS.Web
{
/// <summary>
/// WCS接口
/// 提供给WCS调用接口
/// 调用方向 WCS --> WMS
/// </summary>
[Public]
@ -34,46 +34,6 @@ namespace HHWMS.Web
[HttpPost]
public IActionResult RequestIn(WcsRequest request)
{
//var inv = new List<Inventory>();
//for (int i = 0; i < 10; i++)
// inv.Add(new Inventory
// {
// ContainerCode = "test" + i
// });
//_unitwork.BatchAdd<Inventory>(inv);
//_unitwork.DeleteById<Inventory>(1441);
//_unitwork.BatchUpdate<Inventory>(x => x.ID > 1030, x=>new Inventory { Batch = "test"});
// 测试 删除数据 保存到历史表 主子表数据
/*var receipt = _unitwork.Find<ReceiptHeader>(x => x.ID == 3)
.FirstOrDefault();
var details = _unitwork.Find<ReceiptDetail>(x => x.HeaderId == 3)
.ToArray();
var his = _mapper.Map<ReceiptHeaderHistory>(receipt);
var his2 = _mapper.Map<ReceiptDetail[], IEnumerable<ReceiptDetailHistory>>(details);
_unitwork.Add(his);
_unitwork.BatchAdd(his2);*/
/*var receipt = _unitwork.Find<ShipmentHeader>(x => x.ID == 3)
.FirstOrDefault();
var details = _unitwork.Find<ShipmentDetail>(x => x.HeaderId == 3)
.ToArray();
var his = _mapper.Map<ShipmentHeaderHistory>(receipt);
var his2 = _mapper.Map<ShipmentDetail[], IEnumerable<ShipmentDetailHistory>>(details);
_unitwork.Add(his);
_unitwork.BatchAdd(his2);*/
var receipt = _unitwork.Find<TaskHeader>(x => 1==1)
.FirstOrDefault();
var details = _unitwork.Find<TaskDetail>(x => x.HeaderId == receipt.ID)
.ToArray();
var his = _mapper.Map<TaskHeaderHistory>(receipt);
var his2 = _mapper.Map<TaskDetail[], IEnumerable<TaskDetailHistory>>(details);
_unitwork.Add(his);
_unitwork.BatchAdd(his2);
return ApiResult();
}
@ -86,6 +46,5 @@ namespace HHWMS.Web
{
return ApiResult();
}
}
}

View File

@ -5,6 +5,8 @@ using WalkingTec.Mvvm.Core;
using WalkingTec.Mvvm.Mvc;
using WalkingTec.Mvvm.Core.Extensions;
using HHWMS.Web;
using System.DirectoryServices.Protocols;
using System.Web;
namespace HHWMS.Web.Controllers
{
@ -96,6 +98,9 @@ namespace HHWMS.Web.Controllers
}
else
{
//替换 &quot;
vm.Entity.Template = HttpUtility.HtmlDecode(vm.Entity.Template);
vm.DoEdit();
if (!ModelState.IsValid)
{
@ -224,5 +229,12 @@ namespace HHWMS.Web.Controllers
}
#endregion
[ActionDescription("Sys.Print")]
public ActionResult Design(string id)
{
var vm = Wtm.CreateVM<PrintConfigVM>(id);
return PartialView(vm);
}
}
}

View File

@ -25,6 +25,14 @@ namespace HHWMS.Web
this.MakeStandardAction("PrintConfig", GridActionStandardTypesEnum.BatchDelete, Localizer["Sys.BatchDelete"], "configs", dialogWidth: 800),
this.MakeStandardAction("PrintConfig", GridActionStandardTypesEnum.Import, Localizer["Sys.Import"], "configs", dialogWidth: 800),
this.MakeStandardAction("PrintConfig", GridActionStandardTypesEnum.ExportExcel, Localizer["Sys.Export"], "configs"),
// 打印模板设计
this.MakeAction("PrintConfig","Design",Localizer["Sys.Design"],Localizer["Sys.Design"],GridActionParameterTypesEnum.SingleId,"configs")
.SetShowDialog(true)
.SetMax(),
// 打印预览
this.MakeAction("PrintConfig","PrintPreview",Localizer["Sys.Print"],Localizer["Sys.Print"],GridActionParameterTypesEnum.SingleId,"configs")
.SetShowDialog(false)
.SetOnClickScript("print"),
};
}
@ -35,7 +43,7 @@ namespace HHWMS.Web
this.MakeGridHeader(x => x.Name),
this.MakeGridHeader(x => x.Template),
this.MakeGridHeader(x => x.TestData),
this.MakeGridHeaderAction(width: 200)
this.MakeGridHeaderAction(width: 300)
};
}

View File

@ -0,0 +1,202 @@
@model HHWMS.Web.PrintConfigVM
@inject IStringLocalizer<Program> Localizer;
<wt:form vm="@Model">
<wt:textbox field="Entity.Template" />
<wt:hidden field="Entity.ID" />
<wt:row align="AlignEnum.Right">
<wt:submitbutton submit-url="/configs/PrintConfig/Edit"/>
<wt:closebutton />
</wt:row>
</wt:form>
<link href="/hiprint/content/bootstrap.min.css" rel="stylesheet">
<!-- 单独使用无需引入 -->
<script src="/hiprint/custom/custom-etype-provider.js"></script>
<wt:row>
<!-- 列表 -->
<div class="layui-col-xs1 layui-col-md1" style="padding-right:0px;">
<div class="rect-printElement-types hiprintEpContainer">
<ul class="hiprint-printElement-type">
<li>
<span class="title"><code>拖拽列表</code></span>
<ul>
<li>
<a class="ep-draggable-item" tid="testModule.text" style="">
<span class="glyphicon glyphicon-text-width"
aria-hidden="true"></span>
<span class="glyphicon-class">文本</span>
</a>
</li>
<li>
<a class="ep-draggable-item" tid="testModule.image" style="">
<span class="glyphicon glyphicon-picture"
aria-hidden="true"></span>
<span class="glyphicon-class">图片</span>
</a>
</li>
<li>
<a class="ep-draggable-item" tid="testModule.longText">
<span class="glyphicon glyphicon-subscript"
aria-hidden="true"></span>
<span class="glyphicon-class">长文</span>
</a>
</li>
<li>
<a class="ep-draggable-item" tid="testModule.tableCustom" style="">
<span class="glyphicon glyphicon-th" aria-hidden="true"></span>
<span class="glyphicon-class">表格</span>
</a>
</li>
<li>
<a class="ep-draggable-item" tid="testModule.html">
<span class="glyphicon glyphicon-header"
aria-hidden="true"></span>
<span class="glyphicon-class">html</span>
</a>
</li>
</ul>
</li>
<li>
<span class="title">辅助</span>
<ul>
<li>
<a class="ep-draggable-item" tid="testModule.hline" style="">
<span class="glyphicon glyphicon-resize-horizontal"
aria-hidden="true"></span>
<span class="glyphicon-class">横线</span>
</a>
</li>
<li>
<a class="ep-draggable-item" tid="testModule.vline" style="">
<span class="glyphicon glyphicon-resize-vertical"
aria-hidden="true"></span>
<span class="glyphicon-class">竖线</span>
</a>
</li>
<li>
<a class="ep-draggable-item" tid="testModule.rect">
<span class="glyphicon glyphicon-unchecked"
aria-hidden="true"></span>
<span class="glyphicon-class">矩形</span>
</a>
</li>
<li>
<a class="ep-draggable-item" tid="testModule.oval">
<span class="glyphicon glyphicon-record"
aria-hidden="true"></span>
<span class="glyphicon-class">椭圆</span>
</a>
</li>
</ul>
</li>
</ul>
</div>
</div>
<!-- 内容 -->
<div class="layui-col-xs8 layui-col-md8">
<div class="hiprint-toolbar" style="margin-top:15px;">
<ul>
<li><a class="hiprint-toolbar-item" onclick="setPaper('A3')">A3</a></li>
<li><a class="hiprint-toolbar-item" onclick="setPaper('A4')">A4</a></li>
<li><a class="hiprint-toolbar-item" onclick="setPaper('A5')">A5</a></li>
<li><a class="hiprint-toolbar-item" onclick="setPaper('B3')">B3</a></li>
<li><a class="hiprint-toolbar-item" onclick="setPaper('B4')">B4</a></li>
<li><a class="hiprint-toolbar-item" onclick="setPaper('B5')">B5</a></li>
<li><a class="hiprint-toolbar-item"><input type="text" id="customWidth"
style="width: 50px;height: 19px;border: 0px;"
placeholder="宽/mm" /></a></li>
<li><a class="hiprint-toolbar-item"><input type="text" id="customHeight"
style="width: 50px;height: 19px;border: 0px;"
placeholder="高/mm" /></a></li>
<li><a class="hiprint-toolbar-item"
onclick="setPaper($('#customWidth').val(),$('#customHeight').val())">自定义</a>
</li>
<li><a class="hiprint-toolbar-item" onclick="rotatePaper()">旋转</a></li>
<li><a class="hiprint-toolbar-item" onclick="clearTemplate()">清空</a></li>
<li>
<a id="A4_directPrint" class="btn hiprint-toolbar-item " style="color: #fff;
background-color: #d9534f;
border-color: #d43f3a;">
打印
</a>
</li>
</ul>
<div style="clear:both;"></div>
</div>
<div id="hiprint-printTemplate" class="hiprint-printTemplate" style="margin-top:20px;">
</div>
<div style="padding-top:15px;">
<button type="button" class="btn btn-primary"
id="A4_getJson_toTextarea">生成json到textarea</button>
</div>
<textarea class="layui-textarea" id="A4_textarea_json"></textarea>
</div>
<!-- 属性 -->
<div class="layui-col-xs3 layui-col-md3">
<div id="PrintElementOptionSetting" style="margin-top:10px;"></div>
</div>
</wt:row>
<script>
var l = $('[name="Entity.Template"]').val();
var hiprintTemplate;
$(document).ready(function () {
// 默认值
var customPrintJson = JSON.parse(l);
var printData = {}
//初始化打印插件
hiprint.init({
providers: [new customElementTypeProvider()]
});
//设置左侧拖拽事件
hiprint.PrintElementTypeManager.buildByHtml($('.ep-draggable-item'));
hiprintTemplate = new hiprint.PrintTemplate({
template: customPrintJson,
settingContainer: '#PrintElementOptionSetting',
paginationContainer: '.hiprint-printPagination'
});
//打印设计
hiprintTemplate.design('#hiprint-printTemplate');
$('#A4_directPrint').click(function () {
hiprintTemplate.print(printData);
});
$('#A4_getJson_toTextarea').click(function () {
$('#A4_textarea_json').html(JSON.stringify(hiprintTemplate.getJson()));
$('[name="Entity.Template"]').val(JSON.stringify(hiprintTemplate.getJson()));
})
});
//调整纸张
var setPaper = function (paperTypeOrWidth, height) {
hiprintTemplate.setPaper(paperTypeOrWidth, height);
}
//旋转
var rotatePaper = function () {
hiprintTemplate.rotatePaper();
}
var clearTemplate = function () {
hiprintTemplate.clear();
}
</script>

View File

@ -6,4 +6,24 @@
<wt:textbox field="Searcher.Name" />
</wt:row>
</wt:searchpanel>
<wt:grid vm="@Model" url="/configs/PrintConfig/Search"/>
<wt:grid vm="@Model" url="/configs/PrintConfig/Search" height="400"/>
<script>
// 打印模板,打印预览
function print(id, data) {
var printData = eval('(' + data[0].TestData.replace(/&quot;/g, '"') + ')')
hiprint.init();
var hiprintTemplate = new hiprint.PrintTemplate({
template: JSON.parse(data[0].Template.replace(/&quot;/g, '"'))
});
hiprintTemplate.print([printData]);
printData = {};
}
</script>

View File

@ -0,0 +1,10 @@
@model HHWMS.Web.PrintConfigVM
@inject IStringLocalizer<Program> Localizer;
<script>
import {hiprint, defaultElementTypeProvider} from 'vue-plugin-hiprint'
hiprint.init({
providers: [new defaultElementTypeProvider()]
})
</script>

View File

@ -29,7 +29,6 @@ namespace HHWMS.Web.Controllers
return View();
}
[AllowAnonymous]
public IActionResult PIndex()
{
@ -43,8 +42,8 @@ namespace HHWMS.Web.Controllers
return PartialView();
}
[AllowAnonymous]
public IActionResult GetActionChart()
{
var areas = GlobaInfo.AllModule.Select(x => x.Area).Distinct();
@ -69,6 +68,7 @@ namespace HHWMS.Web.Controllers
var rv = data.ToChartData();
return Json(rv);
}
[AllowAnonymous]
public IActionResult GetModelChart()
{
@ -100,6 +100,7 @@ namespace HHWMS.Web.Controllers
var rv = data.ToChartData();
return Json(rv);
}
[AllowAnonymous]
public IActionResult GetSampleChart()
{
@ -166,27 +167,7 @@ namespace HHWMS.Web.Controllers
{
return JsonMore(UserSessionManager.AllSignined().ToList());
}
//[AllowAnonymous]
//public github GetGithubInfo()
//{
// var rv = Wtm.ReadFromCache<github>("githubinfo", () =>
// {
// var s = Wtm.CallAPI<github>("github", "repos/dotnetcore/wtm", 60).Result;
// return s.Data;
// }, 1800);
// return rv;
//}
//public class github
//{
// public int stargazers_count { get; set; }
// public int forks_count { get; set; }
// public int subscribers_count { get; set; }
// public int open_issues_count { get; set; }
//}
}
}

View File

@ -138,7 +138,7 @@ namespace HHWMS.Web
{
public DataContext CreateDbContext(string[] args)
{
return new DataContext("Server=(localdb)\\mssqllocaldb;Database=HHWMS;Trusted_Connection=True;MultipleActiveResultSets=true", DBTypeEnum.SqlServer);
return new DataContext("Server=127.0.0.1;Port=3306;Database=WMS;Uid=root;Password=abc123*;Character Set=utf8mb4;", DBTypeEnum.MySql);
}
}
}

View File

@ -1,5 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Description>HHWMS</Description>
@ -8,52 +7,18 @@
<AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
<UserSecretsId>b42c99ff-8994-49cd-9a66-5b513ed15a0a</UserSecretsId>
<Product>HHWMS</Product>
<Copyright>Copyright © WeiHai.com 2024</Copyright>
<Copyright>Copyright © TaoLian.com 2024</Copyright>
<PackageProjectUrl />
<RepositoryUrl />
<PackageReleaseNotes />
</PropertyGroup>
<Import Project="..\common.props" />
<ItemGroup>
<Compile Remove="Migrations\**" />
<Compile Remove="wwwroot\hiprint\vue-plugin-hiprint\**" />
<Content Remove="Migrations\**" />
<Content Remove="wwwroot\hiprint\vue-plugin-hiprint\**" />
<EmbeddedResource Remove="Migrations\**" />
<EmbeddedResource Remove="wwwroot\hiprint\vue-plugin-hiprint\**" />
<None Remove="Migrations\**" />
<None Remove="wwwroot\hiprint\vue-plugin-hiprint\**" />
</ItemGroup>
<ItemGroup>
<Folder Include="wwwroot\layuiadmin\lib\extend\" />
<Folder Include="wwwroot\upload\" />
<Folder Include="IOT\" />
<Folder Include="Migrations\" />
</ItemGroup>
<ItemGroup>
<None Include="Areas\_Admin\Views\InterfaceLog\BatchDelete.cshtml" />
<None Include="Areas\_Admin\Views\InterfaceLog\BatchEdit.cshtml" />
<None Include="Areas\_Admin\Views\InterfaceLog\Create.cshtml" />
<None Include="Areas\_Admin\Views\InterfaceLog\Delete.cshtml" />
<None Include="Areas\_Admin\Views\InterfaceLog\Details.cshtml" />
<None Include="Areas\_Admin\Views\InterfaceLog\Edit.cshtml" />
<None Include="Areas\_Admin\Views\InterfaceLog\Import.cshtml" />
<None Include="Areas\_Admin\Views\InterfaceLog\Index.cshtml" />
<None Include="Areas\_Admin\Views\JobLog\BatchDelete.cshtml" />
<None Include="Areas\_Admin\Views\JobLog\BatchEdit.cshtml" />
<None Include="Areas\_Admin\Views\JobLog\Create.cshtml" />
<None Include="Areas\_Admin\Views\JobLog\Delete.cshtml" />
<None Include="Areas\_Admin\Views\JobLog\Details.cshtml" />
<None Include="Areas\_Admin\Views\JobLog\Edit.cshtml" />
<None Include="Areas\_Admin\Views\JobLog\Import.cshtml" />
<None Include="Areas\_Admin\Views\JobLog\Index.cshtml" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="12.0.0" />
<PackageReference Include="EfCore.SchemaCompare" Version="6.0.0" />
@ -76,8 +41,9 @@
<PackageReference Include="WalkingTec.Mvvm.TagHelpers.LayUI" Version="6.4.1-alpha" />
<PackageReference Include="Z.EntityFramework.Plus.EFCore" Version="6.102.1.1" />
</ItemGroup>
<ProjectExtensions><VisualStudio><UserProperties appsettings_1json__JsonSchema="" /></VisualStudio></ProjectExtensions>
</Project>
<ProjectExtensions>
<VisualStudio>
<UserProperties appsettings_1json__JsonSchema="" />
</VisualStudio>
</ProjectExtensions>
</Project>

View File

@ -99,7 +99,12 @@ app.UseEndpoints(endpoints =>
pattern: "{controller=Home}/{action=Index}/{id?}");
endpoints.MapHub<StockTickerHub>("/stocks");
});
// 添加以下代码以确保响应是UTF-8编码
app.Use(async (context, next) =>
{
context.Response.ContentType = "text/html; charset=utf-8";
await next.Invoke();
});
app.UseWtmContext();
// Configure the HTTP request pipeline.

View File

@ -18,7 +18,7 @@
},
"HHWMS.Web": {
"commandName": "Project",
"launchBrowser": true,
"launchBrowser": false,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development",
"ASPNETCORE_HOSTINGSTARTUPASSEMBLIES": "Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation"

View File

@ -19,10 +19,11 @@
});
}
/*
// 存储定时器ID
var timerId = setInterval(function() {
// 你的代码逻辑
isTokenExpired();
}, 10000); // 每10000毫秒执行一次
*/
</script>

View File

@ -104,12 +104,6 @@
"LoginPath": "/Login/Login"
},
"Domains": {
"github": {
"Address": "https://api.github.com"
},
"github2": {
"Address": "https://api.github.com"
},
"WCS": {
"Address": "http://10.18.97.205:1111/api/WcsWebApi/"
}