Bläddra i källkod

【增加】在册登记明细:增加“批量生成二维码”功能,修改“打印条码”功能;

新疆影视学院高职
dyy 2 år sedan
förälder
incheckning
6bc3e98540
7 ändrade filer med 229 tillägg och 44 borttagningar
  1. +111
    -1
      Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/AssetManagementSystem/Controllers/Ass_AssetsInfoItemController.cs
  2. +1
    -1
      Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/AssetManagementSystem/Views/Ass_AssetsInfoItem/Index.cshtml
  3. +38
    -4
      Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/AssetManagementSystem/Views/Ass_AssetsInfoItem/Index.js
  4. +39
    -29
      Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/AssetManagementSystem/Views/Ass_AssetsInfoItem/QRPrint.cshtml
  5. +13
    -0
      Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/AssetManagementSystem/Ass_AssetsInfoItem/Ass_AssetsInfoItemEntity.cs
  6. +1
    -1
      Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/AssetManagementSystem/Ass_AssetsInfoItem/Ass_AssetsInfoItemService.cs
  7. +26
    -8
      Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Util/Learun.Util/Web/QRCodeHelper.cs

+ 111
- 1
Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/AssetManagementSystem/Controllers/Ass_AssetsInfoItemController.cs Visa fil

@@ -3,6 +3,11 @@ using System.Data;
using Learun.Application.TwoDevelopment.AssetManagementSystem;
using System.Web.Mvc;
using System.Collections.Generic;
using ZipOneCode.ZipProvider;
using System.Linq;
using System.Drawing;
using System.IO;
using System;

namespace Learun.Application.Web.Areas.AssetManagementSystem.Controllers
{
@@ -64,8 +69,31 @@ namespace Learun.Application.Web.Areas.AssetManagementSystem.Controllers
return View();
}
[HttpGet]
public ActionResult QRPrint()
public ActionResult QRPrint(string keyValue)
{
var lists = new List<Ass_AssetsInfoItemEntity>();
if (!string.IsNullOrEmpty(keyValue))
{
foreach (var item in keyValue.Split(','))
{
var entity = ass_AssetsInfoItemIBLL.GetAss_AssetsInfoItemEntity(item);
if (entity != null)
{
lists.Add(entity);
//读图片
var d = QRCodeHelper.ProcessRequest(entity.AIId, @"~\Content\images\img1.png", "在册登记明细", entity.AIASSName + entity.AICode);
FileStream fs = new FileStream(d.resultImgPath, FileMode.Open, FileAccess.Read);
int length = (int)fs.Length;
byte[] image = new byte[length];
fs.Read(image, 0, length);
var src = "data:image/jepg;base64," + Convert.ToBase64String(image);
entity.ImgBase64String = src;
fs.Close();
}
}
}
ViewBag.Lists = lists;

return View();
}
#endregion
@@ -225,6 +253,88 @@ namespace Learun.Application.Web.Areas.AssetManagementSystem.Controllers
ass_AssetsInfoItemIBLL.SaveEntity(keyValue, entity);
return Success("保存成功!");
}

/// <summary>
/// 批量生成二维码
/// <summary>
/// <returns></returns>
[HttpPost]
[AjaxOnly]
public ActionResult GetQRCode(string keyValue,Pagination pagination)
{
//TODO:文件夹压缩成zip
//var a = @"D:\Job\test\zip";
//var aa = string.Format(@"{0}.zip", a);
//ZipHelper.CreateZip(a, aa);

//TODO:生成带logo二维码
//var resultImgPath = QRCodeHelper.ProcessRequest("demo", @"~\Content\images\img1.png");

//TODO:生成二维码,并打包
//var dArr = new List<string>();
//for (int i = 0; i < 5; i++)
//{
// var d = QRCodeHelper.ProcessRequest("demo" + i, @"~\Content\images\img1.png", "demo" + i);
// if (dArr.IndexOf(d) == -1)
// {
// dArr.Add(d);
// }
//}
//foreach (var item in dArr)
//{
// ZipHelper.CreateZip(item, item + ".zip");
//}

//图片保存文件夹地址
var dArr = new List<string>();
//明细数据
var lists = new List<Ass_AssetsInfoItemEntity>();
if (!string.IsNullOrEmpty(keyValue))
{
foreach (var item in keyValue.Split(','))
{
var entity = ass_AssetsInfoItemIBLL.GetAss_AssetsInfoItemEntity(item);
if (entity != null)
{
lists.Add(entity);
}
}
}
else
{
var data = ass_AssetsInfoItemIBLL.GetPageList(pagination, "{}");
lists = data.ToList();
}
foreach (var item in lists)
{
var d = QRCodeHelper.ProcessRequest(item.AIId, @"~\Content\images\img1.png", "在册登记明细", item.AIASSName + item.AICode);
if (dArr.IndexOf(d.resultImgDirectoryPath) == -1)
{
dArr.Add(d.resultImgDirectoryPath);
}
}
foreach (var item in dArr)
{
ZipHelper.CreateZip(item, item + ".zip");
}

return Success("操作成功!二维码图片地址为:" + string.Join(",", dArr),dArr);

}
/// <summary>
/// 批量生成二维码下载
/// </summary>
/// <param name="path"></param>
[HttpPost]
public void DownFile(string path)
{
path = string.Format(@"{0}{1}", path, ".zip");
if (FileDownHelper.FileExists(path))
{
FileDownHelper.DownLoadold(path, path.Substring(path.LastIndexOf(@"\") + 1));
}
}
#endregion

}


+ 1
- 1
Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/AssetManagementSystem/Views/Ass_AssetsInfoItem/Index.cshtml Visa fil

@@ -81,7 +81,7 @@
<a id="lr_usedetail" class="btn btn-default"><i class="fa fa-bars"></i>&nbsp;查看使用人员记录</a>
</div>
<div class=" btn-group btn-group-sm">
<a id="lr_getqrcode" class="btn btn-default"><i class="fa fa-plus"></i>&nbsp;生成二维码</a>
<a id="lr_getqrcode" class="btn btn-default"><i class="fa fa-plus"></i>&nbsp;批量生成二维码</a>
</div>
</div>
</div>


+ 38
- 4
Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/AssetManagementSystem/Views/Ass_AssetsInfoItem/Index.js Visa fil

@@ -34,7 +34,7 @@ var bootstrap = function ($, learun) {
nodeClick: function (item) {
page.search({ AIASSClass: item.value });
}
});
});
$('#multiple_condition_query').lrMultipleQuery(function (queryJson) {
page.search(queryJson);
}, 400, 400);
@@ -65,7 +65,8 @@ var bootstrap = function ($, learun) {
height: 80
});
$("#lr_printBar").on('click', function () {
var keyValue = $('#gridtable').jfGridValue('AICode');
//var keyValue = $('#gridtable').jfGridValue('AICode');
var keyValue = $('#gridtable').jfGridValue('AIId');
var AName = $('#gridtable').jfGridValue('AIASSName');
if (learun.checkrow(keyValue)) {
//todo 打印标签
@@ -86,7 +87,7 @@ var bootstrap = function ($, learun) {
learun.layerForm({
id: 'formcardprint',
title: '打印二维码',
url: top.$.rootUrl + '/AssetManagementSystem/Ass_AssetsInfoItem/QRPrint?keyValue=' + keyValue+'&aName='+escape(AName),
url: top.$.rootUrl + '/AssetManagementSystem/Ass_AssetsInfoItem/QRPrint?keyValue=' + keyValue + '&aName=' + escape(AName),
width: 700,
height: 300,
btn: null,
@@ -184,6 +185,39 @@ var bootstrap = function ($, learun) {
}
});

//生成二维码
$('#lr_getqrcode').on('click', function () {
//console.log($('#gridtable')[0].dfop.running);
var keyValue = $('#gridtable').jfGridValue('AIId');
//js方法:
//if (keyValue != null && keyValue != "" && keyValue != undefined) {
// //console.log("有选中");
//} else {
// //console.log("无选中");
// if ($('#gridtable')[0].dfop.running.rowdata.length > 100) {
// learun.alert.warning("最多可以选择100条数据!");
// return false;
// }
// var bb = new Array();
// for (var i = 0; i < $('#gridtable')[0].dfop.running.rowdata.length; i++) {
// bb.push($('#gridtable')[0].dfop.running.rowdata[i]["jfgridRowData"]["AIId"]);
// }
// keyValue = bb.toString();
//}

learun.postForm(top.$.rootUrl + '/AssetManagementSystem/Ass_AssetsInfoItem/GetQRCode', { keyValue: keyValue, pagination: $('#gridtable')[0].dfop.running.pageparam }, function (res) {
//console.log(res);
if (res && res.code == "200") {
//top.layer.alert("二维码图片地址为:" + res.data, { icon: 7, title: "提示", yes: function (index) { layer.close(index) } });

//下载文件
for (var i = 0; i < res.data.length; i++) {
learun.download({ url: top.$.rootUrl + '/AssetManagementSystem/Ass_AssetsInfoItem/DownFile', param: { path: res.data[i], __RequestVerificationToken: $.lrToken }, method: 'POST' });
}
}
});
});

},
// 初始化列表
initGird: function () {
@@ -377,7 +411,7 @@ var bootstrap = function ($, learun) {
mainId: 'AIId',
isMultiselect: true,
isPage: true,
sidx: 'AICodeNum'
sidx: 'AICodeNum',
});
page.search();
},


+ 39
- 29
Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/AssetManagementSystem/Views/Ass_AssetsInfoItem/QRPrint.cshtml Visa fil

@@ -1,4 +1,5 @@
<!DOCTYPE html>
@using Learun.Application.TwoDevelopment.AssetManagementSystem
<!DOCTYPE html>


<html>
@@ -23,38 +24,47 @@
</head>

<body style="">
<div id="qrcodeBox" style="text-align:center;margin-top:20px;">
<div class="qrcodeBox" style="display:inline-block">
<div id="qrcode" style="margin:0 auto 5px;"></div>
<div class="qrcodeTxt" style="font-size:12px;"></div>
<div id="qrcodeBox" style="text-align:center;margin-top:20px;">
@*<div class="qrcodeBox" style="display:inline-block">
<div id="qrcode" style="margin:0 auto 5px;"></div>
<div class="qrcodeTxt" style="font-size:12px;"></div>
</div>*@

@foreach (Ass_AssetsInfoItemEntity item in ViewBag.Lists)
{
<div style="margin-bottom:20px;">
<img src="@item.ImgBase64String"/>
<div style="font-size:12px;">@item.AIASSName@item.AICode</div>
</div>
}

</div>
</div>
<div id="btnprint" type="button" class="btns" value="打印">打印</div>
<script>
//标签打印
var qrcode = new QRCode(document.getElementById("qrcode"), {
width: 80,
height: 80
});
var keyValue = request('keyValue');//二维码
var aName = request('aName');
$('.qrcodeTxt').html(unescape( aName));
$(function () {
qrcode.makeCode(keyValue);
$("#btnprint").on("click", function () {
AddPrintContent3()
});
<div id="btnprint" type="button" class="btns" value="打印">打印</div>
<script>
//标签打印
//var qrcode = new QRCode(document.getElementById("qrcode"), {
// width: 142,
// height: 142
//});
//var keyValue = request('keyValue');//二维码
//var aName = request('aName');
//$('.qrcodeTxt').html(unescape(aName));
$(function () {
//qrcode.makeCode(keyValue);
$("#btnprint").on("click", function () {
AddPrintContent3()
});


});
// 打印表单
});
// 打印表单

function AddPrintContent3() {
$('#btnprint').css('display', 'none')
window.print();
$('#btnprint').css('display', 'block')
}
</script>
function AddPrintContent3() {
$('#btnprint').css('display', 'none')
window.print();
$('#btnprint').css('display', 'block')
}
</script>
</body>

</html>

+ 13
- 0
Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/AssetManagementSystem/Ass_AssetsInfoItem/Ass_AssetsInfoItemEntity.cs Visa fil

@@ -389,6 +389,19 @@ namespace Learun.Application.TwoDevelopment.AssetManagementSystem
/// </summary>
[NotMapped]
public string AIPhoto { get; set; }

/// <summary>
/// 资产名称
/// </summary>
[NotMapped]
public string AName { get; set; }

/// <summary>
/// 批量生成二维码base64字符串
/// </summary>
[NotMapped]
public string ImgBase64String { get; set; }

#endregion
}
}


+ 1
- 1
Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/AssetManagementSystem/Ass_AssetsInfoItem/Ass_AssetsInfoItemService.cs Visa fil

@@ -274,7 +274,7 @@ namespace Learun.Application.TwoDevelopment.AssetManagementSystem
t.AContent
");
strSql.Append(" FROM Ass_AssetsInfoItem a LEFT JOIN dbo.Ass_AssetsInfo t ON a.AId=t.AId ");
strSql.Append(" WHERE a.AIASSState<>2 ");
strSql.Append(" WHERE (a.AIASSState <> 2 or a.AIASSState is null) ");
var queryParam = queryJson.ToJObject();
// 虚拟参数
var dp = new DynamicParameters(new { });


+ 26
- 8
Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Util/Learun.Util/Web/QRCodeHelper.cs Visa fil

@@ -7,6 +7,7 @@ using System.IO;
using System.Text;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Collections.Generic;

namespace Learun.Util
{
@@ -16,11 +17,16 @@ namespace Learun.Util
/// 生成带图片的二维码
/// </summary>
/// <param name="qrcodeText">二维码内容</param>
/// <param name="imagePath">二维码上图片地址</param>
public static string ProcessRequest(string qrcodeText,string imagePath,string savePath)
/// <param name="imagePath">二维码上logo图片地址</param>
/// <param name="savePath"></param>
/// <param name="imageName">二维码图片名称</param>
public static Result ProcessRequest(string qrcodeText,string imagePath,string savePath,string imageName)
{
//最终图片保存路径
var resultImgPath = string.Empty;
//最终图片文件夹保存路径
var resultImgDirectoryPath = string.Empty;

if (!string.IsNullOrEmpty(qrcodeText))
{
QRCodeEncoder qrCodeEncoder = new QRCodeEncoder();
@@ -35,13 +41,15 @@ namespace Learun.Util
CombinImage(image, HttpContext.Current.Server.MapPath(imagePath)).Save(MStream1, System.Drawing.Imaging.ImageFormat.Png);
//保存图片到本地文件夹
System.Drawing.Image img = System.Drawing.Image.FromStream(MStream1);
//string imgPath = System.IO.Path.Combine(Config.GetValue("AnnexesFile"), "带logo图片二维码", DateTime.Now.ToString("yyyyMMddHHmm"));
string imgPath = System.IO.Path.Combine(Config.GetValue("AnnexesFile"), "带logo图片二维码", savePath);
if (!System.IO.Directory.Exists(imgPath))
//string imgDirectoryPath = System.IO.Path.Combine(Config.GetValue("AnnexesFile"), "带logo图片二维码", DateTime.Now.ToString("yyyyMMddHHmm"));
string imgDirectoryPath = System.IO.Path.Combine(Config.GetValue("AnnexesFile"), "带logo图片二维码", savePath);
if (!System.IO.Directory.Exists(imgDirectoryPath))
{
System.IO.Directory.CreateDirectory(imgPath);
System.IO.Directory.CreateDirectory(imgDirectoryPath);
}
img.Save(System.IO.Path.Combine(imgPath, qrcodeText+".png"), System.Drawing.Imaging.ImageFormat.Png);
string imgPath = System.IO.Path.Combine(imgDirectoryPath, imageName + ".png");
img.Save(imgPath, System.Drawing.Imaging.ImageFormat.Png);
resultImgDirectoryPath = imgDirectoryPath;
resultImgPath = imgPath;

//HttpContext.Current.Response.ClearContent();
@@ -55,7 +63,13 @@ namespace Learun.Util
//HttpContext.Current.Response.Flush();
//HttpContext.Current.Response.End();

return resultImgPath;
var result = new Result()
{
resultImgPath = resultImgPath,
resultImgDirectoryPath = resultImgDirectoryPath
};

return result;
}
/// <summary>
/// 调用此函数后使此两种图片合并,类似相册,有个
@@ -111,5 +125,9 @@ namespace Learun.Util
return false;
}
}
public class Result {
public string resultImgPath { get; set; }
public string resultImgDirectoryPath { get; set; }
}
}
}

Laddar…
Avbryt
Spara