Commit d11ac164 by anxiaohe

台账信息明细扫码功能

parent 9aff9718
...@@ -316,7 +316,8 @@ $(document).ready(function() { ...@@ -316,7 +316,8 @@ $(document).ready(function() {
jp.get("${ctx}/warehouse/goods/goods/printQr?goodsInfoId="+id, function (res) { jp.get("${ctx}/warehouse/goods/goods/printQr?goodsInfoId="+id, function (res) {
if (res.success) { if (res.success) {
var row = res.body.goodsInfo.qrCode; var row = res.body.goodsInfo.qrCode;
console.log(row) var imgUrl = "${ctxPath}/" + row.url;
jp.showPic(imgUrl);
} }
jp.close(); jp.close();
}) })
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
<link rel="stylesheet" href="${ctxStatic}/plugin/bootstrapTable/bootstrap-table.min.css"> <link rel="stylesheet" href="${ctxStatic}/plugin/bootstrapTable/bootstrap-table.min.css">
<script type="text/javascript" src="${ctxStatic}/plugin/bootstrapTable/bootstrap-table.min.js"></script> <script type="text/javascript" src="${ctxStatic}/plugin/bootstrapTable/bootstrap-table.min.js"></script>
<script type="text/javascript" src="${ctxStatic}/plugin/bootstrapTable/bootstrap-table-zh-CN.js"></script> <script type="text/javascript" src="${ctxStatic}/plugin/bootstrapTable/bootstrap-table-zh-CN.js"></script>
<script type="text/javascript" src="${ctxStatic}/common/js/big.js"></script>
</head> </head>
<body> <body>
<div class="wrapper wrapper-content"> <div class="wrapper wrapper-content">
......
<%@ page contentType="text/html;charset=UTF-8" %> <%@ page contentType="text/html;charset=UTF-8" %>
<script> <script>
$(document).ready(function() { $(document).ready(function() {
$('#ledgerTable').bootstrapTable({ $('#ledgerTable').bootstrapTable({
//请求方法 //请求方法
...@@ -84,13 +84,14 @@ $(document).ready(function() { ...@@ -84,13 +84,14 @@ $(document).ready(function() {
onShowSearch: function () { onShowSearch: function () {
$("#search-collapse").slideToggle(); $("#search-collapse").slideToggle();
}, },
columns: [{ columns: [
{
checkbox: true checkbox: true
} }
,{ ,{
field: 'name', field: 'type.name',
title: '物资名称', title: '品名',
sortable: true, sortable: true,
sortName: 'name' sortName: 'name'
,formatter:function(value, row , index){ ,formatter:function(value, row , index){
...@@ -100,13 +101,13 @@ $(document).ready(function() { ...@@ -100,13 +101,13 @@ $(document).ready(function() {
} }
,{ ,{
field: 'type.name', field: 'type.code',
title: '品名代码', title: '代码',
sortable: true, sortable: true,
sortName: 'type.name' sortName: 'type.name'
} },
,{ {
field: 'model', field: 'model',
title: '型号', title: '型号',
sortable: true, sortable: true,
...@@ -212,13 +213,13 @@ $(document).ready(function() { ...@@ -212,13 +213,13 @@ $(document).ready(function() {
}); });
function getIdSelections() { function getIdSelections() {
return $.map($("#ledgerTable").bootstrapTable('getSelections'), function (row) { return $.map($("#ledgerTable").bootstrapTable('getSelections'), function (row) {
return row.id return row.id
}); });
} }
function deleteAll(){ function deleteAll(){
jp.confirm('确认要删除该台账信息记录吗?', function(){ jp.confirm('确认要删除该台账信息记录吗?', function(){
jp.loading(); jp.loading();
...@@ -232,44 +233,52 @@ $(document).ready(function() { ...@@ -232,44 +233,52 @@ $(document).ready(function() {
}) })
}) })
} }
//刷新列表 //刷新列表
function refresh(){ function refresh(){
$('#ledgerTable').bootstrapTable('refresh'); $('#ledgerTable').bootstrapTable('refresh');
} }
function add(){ function add(){
jp.openSaveDialog("新增台账","${ctx}/warehouse/ledger/ledger/form/add", '1200', '800'); jp.openSaveDialog("新增台账","${ctx}/warehouse/ledger/ledger/form/add", '1200', '800');
} }
function edit(id){ function edit(id){
if(id == undefined){ if(id == undefined){
id = getIdSelections(); id = getIdSelections();
} }
jp.openSaveDialog("编辑台账","${ctx}/warehouse/ledger/ledger/form/edit?id=" + id, '1200', '800'); jp.openSaveDialog("编辑台账","${ctx}/warehouse/ledger/ledger/form/edit?id=" + id, '1200', '800');
} }
function view(id){//没有权限时,不显示确定按钮 function view(id){//没有权限时,不显示确定按钮
if(id == undefined){ if(id == undefined){
id = getIdSelections(); id = getIdSelections();
} }
jp.openViewDialog("查看台账","${ctx}/warehouse/ledger/ledger/form/view?id=" + id,'1200', '800'); jp.openViewDialog("查看台账","${ctx}/warehouse/ledger/ledger/form/view?id=" + id,'1200', '800');
} }
function detailFormatter(index, row) { function detailFormatter(index, row) {
var htmltpl = $("#ledgerChildrenTpl").html().replace(/(\/\/\<!\-\-)|(\/\/\-\->)/g,""); var htmltpl = $("#ledgerChildrenTpl").html().replace(/(\/\/\<!\-\-)|(\/\/\-\->)/g,"");
var html = Mustache.render(htmltpl, { var html = Mustache.render(htmltpl, {
idx:row.id idx:row.id
}); });
$.get("${ctx}/warehouse/ledger/ledger/countLedger?id="+row.id, function(ledger){ $.get("${ctx}/warehouse/ledger/ledger/detail?id="+row.id, function(ledger){
var ledgerChild1RowIdx = 0, ledgerChild1Tpl = $("#ledgerChild1Tpl").html().replace(/(\/\/\<!\-\-)|(\/\/\-\->)/g,""); var ledgerChild1RowIdx = 0, ledgerChild1Tpl = $("#ledgerChild1Tpl").html().replace(/(\/\/\<!\-\-)|(\/\/\-\->)/g,"");
var data1 = ledger.countLedgerInfoList; var data1 = ledger.ledgerInfoList;
for (var i=0; i<data1.length; i++){ for (var i=0; i<data1.length; i++){
var item = data1[i];
data1[i].dict = {}; data1[i].dict = {};
item.infoSum = new Big(item.num).times(item.amount).toNumber();
item.shelvesNames = item.shelvesList.map(function (e) {
return e.name
}).join(',');
item.warehouseNames = item.warehouseList.map(function (e) {
return e.name;
}).join(',');
addRow('#ledgerChild-'+row.id+'-1-List', ledgerChild1RowIdx, ledgerChild1Tpl, data1[i]); addRow('#ledgerChild-'+row.id+'-1-List', ledgerChild1RowIdx, ledgerChild1Tpl, data1[i]);
ledgerChild1RowIdx = ledgerChild1RowIdx + 1; ledgerChild1RowIdx = ledgerChild1RowIdx + 1;
} }
...@@ -278,13 +287,241 @@ $(document).ready(function() { ...@@ -278,13 +287,241 @@ $(document).ready(function() {
}) })
return html; return html;
} }
function addRow(list, idx, tpl, row){ function addRow(list, idx, tpl, row){
$(list).append(Mustache.render(tpl, { $(list).append(Mustache.render(tpl, {
idx: idx, delBtn: true, row: row idx: idx, delBtn: true, row: row
})); }));
}
function getTable () {
return $("#scan_detail_table");
}
function getScanIpt () {
return document.getElementById("scanIpt");
}
var inputMethodCnType = false;
// var allFocus = debounce(function () {
// var elem = getScanIpt();
// elem.focus();
// }, 300);
var scanIptFocusTimer = null;
function viewScanData () {
layer.open({
type: 1,
title: '扫码',
auto: true,
area: ['1200','600'],
content: $("#scanTpl").html(),
success: function () {
var ipt = getScanIpt();
ipt.addEventListener('change', scanDataChange);
// ipt.addEventListener('blur', allFocus);
ipt.addEventListener('compositionstart', iptCompositionstart);
ipt.addEventListener('compositionend', iptCompositionend);
scanIptGetFocusStart();
$("#scanIpt").focus();
renderScanTable();
document.addEventListener('visibilitychange', pageVisible);
},
cancel: function () {
var ipt = getScanIpt();
ipt.removeEventListener('change', scanDataChange);
// ipt.removeEventListener('blur', allFocus);
ipt.removeEventListener('compositionstart', iptCompositionstart);
scanIptGetFocusStop();
document.removeEventListener('visibilitychange', pageVisible);
},
btn:['关闭']
})
}
function scanDataChange () {
var elem = getScanIpt();
var val = $(elem).val();
if (!val) {
return;
}
try {
var json = JSON.parse(val);
var params = "qrId=" + json.code;
getScanData(
{ qrId: json.code },
function (list) {
var table = getTable();
var tableData = table.bootstrapTable('getData');
list = list.filter(function (item) {
var i = tableData.find(function (e) {
return e.id === item.id;
})
return !i;
});
if (!list.length) {
jp.alert('请勿重复扫码');
return;
}
table.bootstrapTable('append', list);
}
);
} catch (e) {}
setTimeout(function () {
$(elem).val('');
$(elem).blur();
}, 100)
}
function iptCompositionstart () {
inputMethodCnType = true;
}
function iptCompositionend () {
var ipt = getScanIpt();
if (inputMethodCnType) {
jp.alert('请将输入法设置为英文');
inputMethodCnType = false;
ipt.value = '';
}
}
function iptFocus (ipt) {
var timer = setInterval(function () {
if (ipt !== document.activeElement) {
ipt.focus();
}
}, 400);
return timer;
}
function debounce (callback, timeout = 500) {
let timer = null;
return function (...arg) {
const content = this;
if (timer) {
clearTimeout(timer);
} else {
callback.apply(content, arg);
}
timer = setTimeout(function () {
clearTimeout(timer);
timer = null;
}, timeout)
}
}
function renderScanTable () {
getTable().bootstrapTable('destroy').bootstrapTable({
data: [],
columns: [
{
field: 'type.name',
title: '品名',
sortable: true,
sortName: 'type.name'
},
{
field: 'type.code',
title: '代码',
sortable: true,
sortName: 'type.code'
},
{
field: 'code',
title: '入库单'
},
{
field: 'batchNum',
title: '批次号',
},
{
field: 'amount',
title: '单价'
},
{
field: "type.unit",
title: '单位'
},
{
field: 'model',
title: '型号',
sortable: true,
sortName: 'model'
},
{
field: 'num',
title: '数量'
},
{
field: 'sum',
title: '总价',
sortName: 'sum',
formatter (v, row) {
return new Big(row.num).times(row.amount).toNumber()
} }
},
]
})
}
function searchScanData () {
var code = $("#scan-code").val();
getScanData(
{ code: code },
function (list) {
getTable().bootstrapTable('load', list);
}
)
}
function refreshScanData () {
$("#scan-code").val('');
searchScanData();
}
function getScanData (params, callback) {
var paramsStr = "qrId=" + (params.qrId || '') + "&code=" + (params.code || '');
jp.get("${ctx}/warehouse/ledger/ledger/findByQrOrCode?" + paramsStr, function (result) {
if (result && result.rows) {
callback && callback(result.rows.filter(Boolean));
// var list = result.rows.filter(Boolean).filter(function (item) {
// var i = tableData.find(function (e) {
// return e.id === item.id;
// })
// return !i;
// });
// if (!list.length) {
// jp.alert('请勿重复扫码');
// return;
// }
// table.bootstrapTable('append', list);
}
})
}
function pageVisible () {
var state = document.visibilityState;
if (state === 'visible') {
scanIptGetFocusStart();
} else if (state === 'hidden') {
scanIptGetFocusStop();
}
}
function scanIptGetFocusStart () {
var ipt = getScanIpt();
if (ipt) {
scanIptFocusTimer = iptFocus(ipt);
}
}
function scanIptGetFocusStop () {
if (scanIptFocusTimer) {
clearInterval(scanIptFocusTimer);
scanIptFocusTimer = null;
}
}
</script> </script>
<script type="text/template" id="ledgerChildrenTpl">//<!-- <script type="text/template" id="ledgerChildrenTpl">//<!--
...@@ -297,13 +534,16 @@ $(document).ready(function() { ...@@ -297,13 +534,16 @@ $(document).ready(function() {
<table class="ani table"> <table class="ani table">
<thead> <thead>
<tr> <tr>
<th>品名代码</th> <th>品名</th>
<th>代码</th>
<th>数量</th>
<th>单位</th>
<th>型号</th> <th>型号</th>
<th>单价</th>
<th>总价</th>
<th>批次号</th> <th>批次号</th>
<th>货架</th> <th>货架</th>
<th>仓库</th> <th>仓库</th>
<th>数量</th>
<th>总价</th>
</tr> </tr>
</thead> </thead>
<tbody id="ledgerChild-{{idx}}-1-List"> <tbody id="ledgerChild-{{idx}}-1-List">
...@@ -311,30 +551,40 @@ $(document).ready(function() { ...@@ -311,30 +551,40 @@ $(document).ready(function() {
</table> </table>
</div> </div>
</div>//--> </div>//-->
</script> </script>
<script type="text/template" id="ledgerChild1Tpl">//<!-- <script type="text/template" id="ledgerChild1Tpl">//<!--
<tr> <tr>
<td> <td>
{{row.type.name}} {{row.type.name}}
</td> </td>
<td> <td>
{{row.type.code}}
</td>
<td>
{{row.num}}
</td>
<td>
{{row.type.unit}}
</td>
<td>
{{row.model}} {{row.model}}
</td> </td>
<td> <td>
{{row.batchNum}} {{row.amount}}
</td> </td>
<td> <td>
{{row.shelvesNames}} {{row.infoSum}}
</td> </td>
<td> <td>
{{row.warehouseNames}} {{row.batchNum}}
</td> </td>
<td> <td>
{{row.num}} {{row.shelvesNames}}
</td> </td>
<td> <td>
{{row.sum}} {{row.warehouseNames}}
</td> </td>
</tr>//--> </tr>//-->
</script> </script>
...@@ -8,6 +8,18 @@ ...@@ -8,6 +8,18 @@
<%@ include file="/webpage/include/bootstraptable.jsp"%> <%@ include file="/webpage/include/bootstraptable.jsp"%>
<%@include file="/webpage/include/treeview.jsp" %> <%@include file="/webpage/include/treeview.jsp" %>
<%@include file="ledgerList.js" %> <%@include file="ledgerList.js" %>
<script type="text/javascript" src="${ctxStatic}/common/js/big.js"></script>
<style>
#scanIpt {
position: absolute;
top: -10000px;
left: 0;
opacity: 0;
}
.scan-content {
padding: 10px;
}
</style>
</head> </head>
<body> <body>
<div class="wrapper wrapper-content"> <div class="wrapper wrapper-content">
...@@ -53,7 +65,7 @@ ...@@ -53,7 +65,7 @@
</div> </div>
<!-- 工具栏 --> <!-- 工具栏 -->
<%-- <div id="toolbar">--%> <div id="toolbar">
<%-- <shiro:hasPermission name="warehouse:ledger:ledger:add">--%> <%-- <shiro:hasPermission name="warehouse:ledger:ledger:add">--%>
<%-- <button id="add" class="btn btn-primary" onclick="add()">--%> <%-- <button id="add" class="btn btn-primary" onclick="add()">--%>
<%-- <i class="glyphicon glyphicon-plus"></i> 新建--%> <%-- <i class="glyphicon glyphicon-plus"></i> 新建--%>
...@@ -82,7 +94,10 @@ ...@@ -82,7 +94,10 @@
<%-- <i class="fa fa-search-plus"></i> 查看--%> <%-- <i class="fa fa-search-plus"></i> 查看--%>
<%-- </button>--%> <%-- </button>--%>
<%-- </shiro:hasPermission>--%> <%-- </shiro:hasPermission>--%>
<%-- </div>--%> <button class="btn btn-default" onclick="viewScanData()">
<i class="fa fa-search-plus"></i> 查看二维码数据
</button>
</div>
<!-- 表格 --> <!-- 表格 -->
<table id="ledgerTable" data-toolbar="#toolbar"></table> <table id="ledgerTable" data-toolbar="#toolbar"></table>
...@@ -102,6 +117,31 @@ ...@@ -102,6 +117,31 @@
</ul> </ul>
</div> </div>
</div> </div>
</div>
<script type="type/template" id="scanTpl">
<div class="scan-content">
<input type="text" id="scanIpt" />
<div id="scan-searchForm-box" class="collapse show">
<div class="accordion-inner">
<form:form id="scan-searchForm" class="form form-horizontal well clearfix">
<div class="col-xs-12 col-sm-6 col-md-4">
<label class="label-item single-overflow pull-left" title="数量:">编号:</label>
<%-- <form:input path="code" htmlEscape="false" class=" form-control"/>--%>
<input type="text" id="scan-code" class="form-control" onfocus="scanIptGetFocusStop()" onblur="scanIptGetFocusStart()" />
</div>
<div class="col-xs-12 col-sm-6 col-md-4">
<div style="margin-top:26px">
<a id="scan-search" class="btn btn-primary btn-rounded btn-bordered btn-sm" onclick="searchScanData()"><i class="fa fa-search"></i> 查询</a>
<a id="scan-reset" class="btn btn-primary btn-rounded btn-bordered btn-sm" onclick="refreshScanData()"><i class="fa fa-refresh"></i> 重置</a>
</div>
</div>
</form:form>
</div>
</div>
<div class="scan-data-content">
<table id="scan_detail_table"></table>
</div>
</div> </div>
</script>
</body> </body>
</html> </html>
...@@ -450,6 +450,7 @@ ...@@ -450,6 +450,7 @@
* @param elem * @param elem
*/ */
function onScanChange(elem){ function onScanChange(elem){
// console.log($(elem).val());
try{ try{
var json = JSON.parse($(elem).val()); var json = JSON.parse($(elem).val());
var qrCodeId = json.code; var qrCodeId = json.code;
...@@ -573,7 +574,7 @@ ...@@ -573,7 +574,7 @@
<label>扫码结果:</label> <label>扫码结果:</label>
</div> </div>
<div class="col-xs-10"> <div class="col-xs-10">
<input type="text" id="scanResult" class="form-control" onchange="onScanChange(this)"> <input type="text" id="scanResult" class="form-control" style="ime-mode: active" onchange="onScanChange(this)">
<span class="text-danger">请切换英文输入法</span> <span class="text-danger">请切换英文输入法</span>
</div> </div>
</div> </div>
......
...@@ -36,6 +36,11 @@ ...@@ -36,6 +36,11 @@
</style> </style>
<script type="text/javascript" src="${ctxStatic}/plugin/bootstrapTable/bootstrap-table.min.js"></script> <script type="text/javascript" src="${ctxStatic}/plugin/bootstrapTable/bootstrap-table.min.js"></script>
<script type="text/javascript" src="${ctxStatic}/plugin/bootstrapTable/bootstrap-table-zh-CN.js"></script> <script type="text/javascript" src="${ctxStatic}/plugin/bootstrapTable/bootstrap-table-zh-CN.js"></script>
<style>
#scanResult {
-ms-ime-mode: inactive;
}
</style>
</head> </head>
<body> <body>
<div class="wrapper wrapper-content"> <div class="wrapper wrapper-content">
......
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