Commit f98316e2 by 胡懿

Merge branches 'hy' and 'master' of 47.92.228.5:huyi/warehouse into hy

parents a40ff95f b6ae5746
......@@ -354,7 +354,7 @@ function delRow(obj, prefix){
openGridSelectDialog:function(params, yesFuc){
top.layer.open({
type: 2,
area: ['800px', '500px'],
area: ['1200px', '600px'],
title: params.title,
auto:true,
name:'friend',
......@@ -367,7 +367,8 @@ function delRow(obj, prefix){
jp.warning("必须选择一条数据!");
return;
}
yesFuc(items);
var result = yesFuc(items);
if (result === false) return;
top.layer.close(index);//关闭对话框。
},
cancel: function(index){
......
......@@ -180,7 +180,9 @@ $(function(){
return this.optional(element) || /^[A-Za-z0-9_-]+$/.test(value);
}, "判断是否为合法字符(a-zA-Z0-9-_)");
jQuery.validator.addMethod('positiveInteger', function (value, element) {
return this.optional(element) || /^[1-9]\d*$/.test(value);
})
//身份证号码的验证规则
function isIdCardNo(num){
......
<style>
#scanIpt_ {
position: absolute;
top: -10000px;
left: 0;
opacity: 0;
}
</style>
<input id="scanIpt_" type="text" />
<script>
// function Scan () {
// this.scanIptFocusTimer$ = null;
// this.inputMethodCnType$ = false;
//
// $(document).ready(function () {
// var ipt = getScanIpt();
// document.addEventListener('visibilitychange', pageVisible);
// ipt.addEventListener('change', scanDataChange);
// ipt.addEventListener('compositionstart', iptCompositionstart);
// ipt.addEventListener('compositionend', iptCompositionend);
// scanIptGetFocusStart();
// })
// }
var scanIptFocusTimer$ = null;
var inputMethodCnType$ = false;
var focusStop = true;
$(document).ready(function () {
$(document.body).on('focusin', function (e) {
var dom = e.target;
if (dom.id === 'scanIpt_') return;
scanIptGetFocusStop();
})
$(document.body).on('focusout', function (e) {
var dom = e.target;
if (dom.id === 'scanIpt_') return;
scanIptGetFocusStart();
})
})
function scanStart () {
var ipt = getScanIpt();
focusStop = false;
ipt.focus();
document.addEventListener('visibilitychange', pageVisible);
ipt.addEventListener('change', scanDataChange);
ipt.addEventListener('compositionstart', iptCompositionstart);
ipt.addEventListener('compositionend', iptCompositionend);
scanIptGetFocusStart();
// var allFormDom = $("input, select, textarea");
// allFormDom.on('focus', function () {
// if (this.id === 'scanIpt_') return;
// scanIptGetFocusStop();
// })
// allFormDom.on('blur', function () {
// if (this.id === 'scanIpt_') return;
// scanIptGetFocusStart();
// })
}
function scanStop () {
focusStop = true;
var ipt = getScanIpt();
ipt.removeEventListener('change', scanDataChange);
ipt.removeEventListener('compositionstart', iptCompositionstart);
scanIptGetFocusStop();
document.removeEventListener('visibilitychange', pageVisible);
}
window.onbeforeunload = function (e) {
scanStop();
}
// $(document).ready(function () {
// var ipt = getScanIpt();
// document.addEventListener('visibilitychange', pageVisible);
// ipt.addEventListener('change', scanDataChange);
// ipt.addEventListener('compositionstart', iptCompositionstart);
// ipt.addEventListener('compositionend', iptCompositionend);
// })
function getScanIpt () {
return document.getElementById("scanIpt_");
}
function pageVisible () {
var state = document.visibilityState;
if (state === 'visible') {
scanIptGetFocusStart();
} else if (state === 'hidden') {
scanIptGetFocusStop();
}
}
function scanIptGetFocusStart () {
if (focusStop) return;
var ipt = getScanIpt();
if (ipt) {
scanIptFocusTimer$ = iptFocus(ipt);
}
}
function scanIptGetFocusStop () {
if (scanIptFocusTimer$) {
clearInterval(scanIptFocusTimer$);
scanIptFocusTimer$ = null;
}
}
function iptFocus () {
var ipt = getScanIpt();
var timer = setInterval(function () {
if (ipt !== document.activeElement && scanIptFocusTimer$) {
ipt.focus();
}
}, 300);
return timer;
}
function iptCompositionstart () {
inputMethodCnType = true;
}
function iptCompositionend () {
var ipt = getScanIpt();
if (inputMethodCnType$) {
jp.alert('请将输入法设置为英文');
inputMethodCnType$ = false;
ipt.value = '';
}
}
function scanDataChange () {
var elem = getScanIpt();
var val = $(elem).val();
if (!val) {
return;
}
try {
window.scanIptChangeCallback && window.scanIptChangeCallback(val);
} catch (e) {}
setTimeout(function () {
$(elem).val('');
$(elem).blur();
}, 100)
}
</script>
......@@ -66,7 +66,16 @@ $(document).ready(function() {
,{
field: '${fieldKeys[status.index]}',
title: '${fieldLabels[status.index]}',
sortable: true
sortable: true,
formatter (val, row, index) {
var result = val;
var key = '${fieldKeys[status.index]}';
if (top.gridSelectColumnFormatterMap && top.gridSelectColumnFormatterMap[key] && top.gridSelectColumnFormatterMap[key].formatter) {
result = top.gridSelectColumnFormatterMap[key].formatter(val, row, index);
}
return result;
},
events: (top.gridSelectColumnFormatterMap && top.gridSelectColumnFormatterMap['${fieldKeys[status.index]}']) ? top.gridSelectColumnFormatterMap['${fieldKeys[status.index]}'].events : {}
}
</c:forEach>
......
......@@ -107,14 +107,14 @@
sortName: 'type.name'
},
// {
// field: 'model',
// title: '型号',
// sortable: true,
// sortName: 'model'
//
// }
{
field: 'model',
title: '型号',
sortable: true,
sortName: 'model'
}
,{
field: 'sum',
title: '总价',
sortable: true,
......@@ -303,9 +303,9 @@ function getScanIpt () {
return document.getElementById("scanIpt");
}
// 判断是否是中文输入法
var inputMethodCnType = false;
// input持续获取焦点
var scanIptFocusTimer = null;
// var inputMethodCnType = false;
// // input持续获取焦点
// var scanIptFocusTimer = null;
function viewScanData () {
layer.open({
......@@ -315,35 +315,31 @@ function viewScanData () {
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();
// var ipt = getScanIpt();
// ipt.addEventListener('change', scanDataChange);
// // ipt.addEventListener('blur', allFocus);
// ipt.addEventListener('compositionstart', iptCompositionstart);
// ipt.addEventListener('compositionend', iptCompositionend);
// scanIptGetFocusStart();
// $("#scanIpt").focus();
scanStart();
renderScanTable();
document.addEventListener('visibilitychange', pageVisible);
// 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);
// var ipt = getScanIpt();
// ipt.removeEventListener('change', scanDataChange);
// // ipt.removeEventListener('blur', allFocus);
// ipt.removeEventListener('compositionstart', iptCompositionstart);
// scanIptGetFocusStop();
// document.removeEventListener('visibilitychange', pageVisible);
scanStop();
},
btn:['关闭']
})
}
function scanDataChange () {
var elem = getScanIpt();
var val = $(elem).val();
if (!val) {
return;
}
try {
function scanIptChangeCallback (val) {
var json = JSON.parse(val);
var params = "qrId=" + json.code;
getScanData(
......@@ -364,25 +360,54 @@ function scanDataChange () {
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 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 () {
......@@ -393,21 +418,21 @@ function iptFocus (ipt) {
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 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({
......@@ -499,27 +524,27 @@ function getScanData (params, callback) {
})
}
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;
}
}
// 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 type="text/template" id="ledgerChildrenTpl">//<!--
......
......@@ -8,6 +8,7 @@
<%@ include file="/webpage/include/bootstraptable.jsp"%>
<%@include file="/webpage/include/treeview.jsp" %>
<%@include file="ledgerList.js" %>
<%@include file="../../../include/scan.jsp" %>
<script type="text/javascript" src="${ctxStatic}/common/js/big.js"></script>
<style>
#scanIpt {
......
......@@ -9,6 +9,7 @@
<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}/common/js/big.js"></script>
<%@include file="../../../include/scan.jsp" %>
<style>
.sign-result{
width: 80px;
......@@ -30,6 +31,10 @@
.sign:focus-visible {
outline: none;
}
.scan-data-content {
padding: 10px;
}
</style>
</head>
<body>
......@@ -146,5 +151,30 @@
}
</script>
<script type="text/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>
</script>
</body>
</html>
......@@ -204,6 +204,10 @@
return res;
}
window.onbeforeunload = function () {
delete top.selectStorageData;
}
/**
* 手动添加明细
* @param selector
......
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