Commit 16ee55f9 by anxiaohe

签字

parent d78ed2b8
......@@ -276,4 +276,9 @@ public class MaterialRequisitionController extends BaseController {
}
}
\ No newline at end of file
@RequestMapping(value = "writeSign")
public String writeSign (Model model) {
return "modules/warehouse/materialrequisition/writing";
}
}
<%@ page contentType="text/html;charset=UTF-8" %>
<script>
var errorCode = {
'0': "成功",
'-1': '未找到对应的汉王手写设备',
'-2': '手写模块加载失败',
'-3': '手写模块初始化失败',
'-4': '不支持的图片格式',
'-5': '没有签名数据',
'-6': '无效输入参数',
'-10': '有窗口未签字',
'-11': '请求参数异常',
'-13': '重复启动签字页面',
'-14': '请求格式错误',
'-15': '没有窗口并且者关闭签字设备'
}
var deviceInitParams = {
"nLogo": "签字", // 签字界面title
"nPenwidth": "2", // 写字宽度 0 - 4
"nOrgX": "", // 屏幕x位置
"nOrgY": "", // 屏幕y位置
"width": "500", // 窗口宽度
"height": "300", // 窗口高度
"fingerFap": "1", // 指纹模式 0:只签字(默认值) 1: 签字加指纹 (若设备有指纹模块) 2: 只指纹 (若设备有指纹模块)
"key": "4A05564228DF2C64AF2E137B71A4E7A3" // 必须
}
function getLink () {
return 'http://127.0.0.1:29999';
}
var deviceStartGetSignResultInterval = null;
function getDevice (callback) {
jp.get(getLink() + '/HWPenSign/HWGetDeviceStatus', function (result) {
var code = Number(result.msgID);
if (code === 0) {
deviceInit();
callback && callback(true);
} else {
logErrMsg(code);
callback && callback(false);
clearInterval(deviceStartGetSignResultInterval);
}
})
}
function deviceInit () {
$.ajax({
type: "get",
url: getLink() + "/HWPenSign/HWInitialize",
data: deviceInitParams,
dataType: "jsonp",
success: function(result){
var code = Number(result.msgID);
if (code === 0) {
deviceStartGetSignResultInterval = setInterval(function () {
getDeviceInputImg();
}, 2000);
} else {
// logErrMsg(data.message);
}
},
error: function(){
logErrMsg("Application not started");
}
});
}
function deviceUninstall () {
jp.get(getLink() + '/HWPenSign/HWFinalize', function (result) {
var code = Number(result.msgID);
if (code === 0) {
} else {
logErrMsg(code);
}
})
}
function clearDeviceInput () {
jp.get(getLink() + '/HWPenSign/HWClearPenSign', function (result) {
var code = Number(result.msgID);
if (code === 0) {
} else {
logErrMsg(code);
}
})
}
function getDeviceInputImg () {
$.ajax({
type: "get",
url: getLink() + "/HWPenSign/HWGetSign",
data: {
"nImageType": "3",
"nImageWidth": "",
"nImageHeight": ""
},
dataType: "jsonp",
success: function(result) {
var code = Number(result.msgID);
if (code === 0) {
clearInterval(deviceStartGetSignResultInterval);
window.getSignImg && window.getSignImg(result);
} else if (code === -15) {
debugger
clearInterval(deviceStartGetSignResultInterval);
// logErrMsg(result.msgID);
signWindowClose();
} else {
// logErrMsg(result.msgID);
}
},
error : function(){
console.log("sign error \n");
}
});
}
function clear () {
clearInterval(deviceStartGetSignResultInterval);
clearDeviceInput();
deviceUninstall();
}
function logErrMsg (code) {
code = code ? code.toString() : '';
jp.warning(errorCode[code]);
}
function signWindowClose () {
window.signClose && window.signClose();
}
</script>
......@@ -8,7 +8,7 @@
<%@ include file="/webpage/include/bootstraptable.jsp" %>
<%@include file="/webpage/include/treeview.jsp" %>
<%@include file="goodsList.js" %>
<%@include file="logic.js" %>
<%@include file="/webpage/include/logic.jsp" %>
</head>
<body>
<div class="wrapper wrapper-content">
......
......@@ -7,6 +7,7 @@
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="/webpage/include/taglib.jsp" %>
<%@include file="/webpage/include/logic.jsp" %>
<table id="detail_table"></table>
<script>
var selector = "#detail_table";
......@@ -270,7 +271,7 @@
LODOP = getLodop(document.getElementById('LODOP_OB'),document.getElementById('LODOP_EM'));
}
function onPrint(row) {
function onPrint_(row) {
if(!LODOP){
initLodop();
}
......@@ -292,6 +293,21 @@
LODOP.ADD_PRINT_IMAGE('0%',"0%","100%","100%","<img width='150' border='0' src='"+imgUrl+"' />");
LODOP.PREVIEW();
}
function onPrint (row) {
<%--if(!row){--%>
<%-- var selections = $("#detail_table").bootstrapTable('getSelections');--%>
<%-- selections.forEach(function(item){--%>
<%-- // LODOP.NewPage();--%>
<%-- var imgUrl = "${ctxPath}/" + item.qr.url;--%>
<%-- // LODOP.ADD_PRINT_IMAGE('0%',"0%","100%","100%","<img width='150' border='0' src='"+imgUrl+"' />");--%>
<%-- });--%>
<%-- // LODOP.PREVIEW();--%>
<%-- return;--%>
<%--}--%>
var imgUrl = "${ctxPath}/" + row.qr.url;
_thermal_Image_print_(imgUrl);
}
</script>
<script id="detailTpl" type="text/html">
......
......@@ -379,39 +379,52 @@
return;
}
layer.open({
type: 1,
jp.open({
type: 2,
title: '签名',
auto:true,
area:[800,600],
content: '<div id="signBox" class="sign" contentEditable="true" style="width: 100%;height: 100%;"></div>',
success: function (layero){
$(layero[0]).find("#signBox").focus();
},
btn: ['确认','清空','取消'],
btn1: function(index, layero){
if(ledgerInfoId){
content: '${ctx}/warehouse/materialrequisition/materialRequisition/writeSign',
// success: function (layero){
// $(layero[0]).find("#signBox").focus();
// getDevice();
// },
btn: ['确认','取消'],
btn1: function (index, layero) {
var iframe = layero.find("iframe")[0].contentWindow;
var img = iframe.getImg();
if (!img) {
jp.close(index);
jp.message('请签字');
return;
}
if (ledgerInfoId) {
var i = getTableData().findIndex(function (current) {
return current.ledgerInfo.id === ledgerInfoId;
})
updateRow(i, {
receiver: $(layero[0]).find("#signBox img").attr('src')
receiver: img
})
}else{
} else {
getSelections().forEach(function (item) {
var index = getTableData().findIndex(function (current) {
return current.ledgerInfo.id === item.ledgerInfo.id;
return item.sortId ? item.sortId === current.sortId : item.id === current.id;
})
updateRow(index, {
receiver: $(layero[0]).find("#signBox img").attr('src')
receiver: img
})
});
}
layer.close(index);
jp.close(index);
},
btn2: function (index, layero){
$(layero[0]).find("#signBox").empty().focus();
return false;
var iframe = layero.find("iframe")[0].contentWindow;
iframe.unload();
jp.close(index);
},
cancel (i, layero) {
var iframe = layero.find("iframe")[0].contentWindow;
iframe.unload();
}
})
}
......@@ -433,7 +446,6 @@
renderScanTable();
},
yes: function (index, layero) {
debugger
var selectTableData = getSelectScanTable();
if (!selectTableData.length) {
jp.alert('至少选择一条数据');
......@@ -580,6 +592,10 @@
receiver: ''
})
}
function viewImage (u) {
jp.showPic(u);
}
</script>
<script id="hideTpl" type="text/html">
......@@ -643,7 +659,7 @@
<input type="hidden" name="materialRequisitionInfoList[{{idx}}].receiver" value="{{row.receiver}}">
{{#row.receiver}}
<div class="sign-result">
<img src="{{row.receiver}}" alt="签名" width="100%" />
<img src="{{row.receiver}}" alt="签名" width="100%" onclick="viewImage('{{row.receiver}}')" />
<span class="del-sign" onclick="delSign(this, '{{idx}}')">&times;</span>
</div>
{{/row.receiver}}
......
<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/webpage/include/taglib.jsp" %>
<html>
<head>
<title>手写板</title>
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<meta name="decorator" content="ani"/>
<%@include file="/webpage/include/writingPad.jsp"%>
<style>
.btnBox {
padding: 20px;
}
.startSign {
display: none;
}
.signAgain {
display: none;
}
canvas {
background: #0e90d2;
/*width: 600px;*/
/*height: 400px;*/
/*margin: 0 auto;*/
}
</style>
</head>
<body>
<div class="page">
<div class="btnBox">
<button class="btn btn-success startSign">签字</button>
<button class="btn btn-primary signAgain">重新签字</button>
</div>
<div class="imgBox">
<canvas id="myCanvas"></canvas>
</div>
</div>
<script>
$(".startSign").on('click', function () {
init();
})
$(".signAgain").on('click', function () {
canvasInit();
clear();
init();
base64Str = '';
})
$(document).ready(function () {
init();
canvasInit();
})
function init () {
getDevice(function (result) {
if (result) {
$(".startSign").hide();
} else {
$(".startSign").show();
}
});
}
var base64Str = '';
function getSignImg (result) {
let img = new Image();
img.src = result.message;
base64Str = result.message;
var canvas = document.getElementById("myCanvas");
var ctx = canvas.getContext('2d');
img.onload = function () {
// 等比例缩放图片
var scale = 1;
var tt = 1000; // 可以根据具体的要求去设定
if (this.width > tt || this.height > tt) {
if (this.width > this.height) {
scale = tt / this.width;
} else {
scale = tt / this.height;
}
}
ctx.width = this.width * scale;
ctx.height = this.height * scale; // 计算等比缩小后图片
ctx.drawImage(this, 0, 0, ctx.width, ctx.height); // 加载图片
$(".signAgain").show();
};
}
function canvasInit () {
var canvas = document.getElementById("myCanvas")
canvas.width = document.documentElement.clientWidth;
canvas.height = document.documentElement.clientHeight - 102;
}
function getImg () {
return base64Str;
}
function unload () {
clear()
}
function signClose () {
$(".startSign").show();
}
</script>
</body>
</html>
......@@ -7,7 +7,7 @@
<meta name="decorator" content="ani"/>
<%@ include file="/webpage/include/bootstraptable.jsp"%>
<%@include file="/webpage/include/treeview.jsp" %>
<%@include file="./../goods/logic.js"%>
<%@include file="/webpage/include/logic.jsp" %>
<%@include file="profitWarehousingList.js" %>
</head>
<body>
......
......@@ -265,7 +265,7 @@ $(document).ready(function() {
function initLodop(){
LODOP=getLodop(document.getElementById('LODOP_OB'),document.getElementById('LODOP_EM'));
}
function onPrint(row) {
function onPrint_(row) {
var list = [];
if(!row){
list = $("#qrCodeTable").bootstrapTable('getSelections');
......@@ -293,7 +293,11 @@ function onPrint(row) {
})
}
}
function onPrint (row) {
// jp.loading('loading...');
var imgUrl = "${ctxPath}/" + row.url;
_thermal_Image_print_(imgUrl);
}
function createAllPage(list){
if(!list){
return;
......@@ -304,4 +308,4 @@ function createAllPage(list){
LODOP.ADD_PRINT_IMAGE('0%',"0%","100%","100%","<img width='150' border='0' src='"+imgUrl+"' />");
})
}
</script>
\ No newline at end of file
</script>
......@@ -7,6 +7,7 @@
<meta name="decorator" content="ani"/>
<%@ include file="/webpage/include/bootstraptable.jsp" %>
<%@include file="/webpage/include/treeview.jsp" %>
<%@include file="/webpage/include/logic.jsp" %>
<%@include file="qrCodeList.js" %>
<script>
var projectName = "${ctxStatic}";
......@@ -91,9 +92,9 @@
<i class="fa fa-search-plus"></i> 查看
</button>
</shiro:hasPermission>
<button id="printAll" class="btn btn-primary" disabled onclick="onPrint()">
<i class="fa fa-search-plus"></i> 批量打印
</button>
<%-- <button id="printAll" class="btn btn-primary" disabled onclick="onPrint()">--%>
<%-- <i class="fa fa-search-plus"></i> 批量打印--%>
<%-- </button>--%>
</div>
<!-- 表格 -->
......@@ -116,4 +117,4 @@
</div>
</div>
</body>
</html>
\ No newline at end of file
</html>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment