You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

79 lines
2.0 KiB

function postForm(formId, url, funcSuccess){
var postData = {};
var validate = [];
$("#"+formId+" input").each(function(index){
var val = $(this).val();
if (val == ""){
validate.push("["+$(this).attr("placeholder")+"]不能为空!");
}
postData[$(this).attr("name")] = val;
});
if(validate.length > 0){
$.messager.alert("Warning", validate.join("<br />"), "warning");
return;
}
$.messager.confirm("Confirm","Submit", function(cr){
if (cr){
$.post(url, postData, function(ret){
if (ret.success){
if(funcSuccess){
funcSuccess(ret);
} else {
$("#app").html("<p class='op-success'>Successfully</p>");
}
}else{
$.messager.alert("Error", ret.errorMsg, "error");
}
})
}
})
}
$(".for-scan").on("focus", "input", function() {
$(this).css("text-transform", "uppercase");
});
$(".for-scan").on("blur", "input", function() {
$(this).val($(this).val().trim().toUpperCase());
});
$(".for-scan").on("keydown", "input", function(){
console.log(event.keyCode);
if (event.keyCode >= 97 && event.keyCode <= 122){
event.keyCode = event.keyCode - 32;
}
if(event.keyCode==13) {
event.keyCode = 9;
var inputs = $(".for-scan").find(":input:visible:not(:disabled):not([readonly])");
console.log(inputs);
var idx = inputs.index(this);
if (idx == inputs.length - 1) {
idx = -1;
} else {
inputs[idx + 1].focus(); // handles submit buttons
}
try {
inputs[idx + 1].select();
}
catch (err) {
// handle objects not offering select
}
return false;
}
});
function showEl(id, b){
if (b) {
$(id).show();
} else {
$(id).hide();
}
}
function enableEl(id, b){
$(id).prop('disabled', !b);
}