//卡回收
|
var layer;
|
var form;
|
var recordData = null;
|
$(function() {
|
layui.use([ 'layer', 'laydate', 'form' ], function() {
|
layer = layui.layer;
|
form = layui.form;
|
layui.laydate.render({
|
elem : '#test1',
|
theme : '#7b8e9f'
|
});
|
|
});
|
|
showProgress();
|
});
|
|
//控制流程环节显示
|
function showProgress() {
|
if(!inoutProgress){
|
return;
|
}
|
|
if(inoutProgress.indexOf("REGISTER") == -1){
|
$("#progress-register").css("display", "none");
|
}
|
if(inoutProgress.indexOf("CHECK") == -1){
|
$("#progress-check").css("display", "none");
|
}
|
if(inoutProgress.indexOf("WEIGHT_FULL") == -1){
|
$("#progress-fullWeight").css("display", "none");
|
}
|
if(inoutProgress.indexOf("HANDLE") == -1){
|
$("#progress-hand").css("display", "none");
|
}
|
if(inoutProgress.indexOf("WEIGHT_EMPTY") == -1){
|
$("#progress-emptyWeight").css("display", "none");
|
}
|
if(inoutProgress.indexOf("CARD_BACK") == -1){
|
$("#progress-cardBack").css("display", "none");
|
}
|
}
|
|
//新的读卡方式
|
function flushICCard() {
|
$("#intelCard").val(null);
|
resetForm();
|
$.ajax({
|
type: "GET",
|
async: true,
|
url: "http://127.0.0.1:9111/ICCARD",
|
data: {},
|
dataType: "jsonp",
|
jsonp: "callback",
|
jsonpCallback: "jsonpCallback",
|
success: function (json) {
|
//console.log(json);
|
var data = json.no;
|
//console.log(data);
|
if (data === "not found") {
|
layer.alert("请重新读卡!", {offset: ['300px', '300px']});
|
} else {
|
$("#intelCard").val(data);
|
flushData();
|
}
|
},
|
error: function () {
|
layer.alert("IC卡读取出错!", {offset: ['300px', '300px']});
|
}
|
});
|
}
|
|
// 使用插件获取省份证
|
function flushIdCard() {
|
var index = layer.load();
|
$.ajax({
|
type: "GET",
|
async: true,
|
url: "http://127.0.0.1:9111/IDCARD",
|
data: {},
|
dataType: "jsonp",
|
jsonp: "callback",
|
jsonpCallback: "jsonpCallback",
|
success: function (json) {
|
layer.close(index);
|
var data = json.content;
|
if (data === "not found") {
|
layer.alert("没有读取到身份证信息,请手动录入!", {
|
offset: ['300px', '300px']
|
});
|
return;
|
}
|
$("#userId").val(data.idNum);
|
flushData();
|
},
|
error: function () {
|
layer.alert("身份证读取失败,请手动录入!", {
|
offset: ['300px', '300px']
|
});
|
layer.close(index);
|
}
|
});
|
}
|
|
// 打印过磅单
|
function printBill() {
|
if (!recordData) {
|
layer.alert("没有获取到业务数据,不支持打印!");
|
return;
|
}
|
|
if(InoutProgress.CARD_BACK != recordData.progress){
|
layer.alert("当前数据不完整,不支持打印!");
|
return;
|
}
|
|
//从后台获取模版并打印
|
var index = layer.load();
|
$.ajax({
|
type : "POST",
|
url : "../../basic/inout-report/inout-bill-weight",
|
dataType : "json",
|
contentType : "application/json;charset=UTF-8",
|
data : JSON.stringify(recordData),
|
success : function(result) {
|
if (result.code != "0000") {
|
layer.msg(result.msg);
|
} else {
|
layer.msg("开始渲染打印单……");
|
printWeight(result.data);
|
}
|
layer.close(index);
|
},
|
error : function() {
|
layer.close(index);
|
layer.msg("获取打印模版失败,请联系管理员查看原因!!");
|
}
|
});
|
}
|
|
// 打印抽样单
|
function showCheck() {
|
if (null == recordData) {
|
layer.alert("没有获取到业务数据,无法查看!");
|
}
|
}
|
|
// 表单清空
|
function resetForm() {
|
$("#form-data")[0].reset();
|
$("#form-basic")[0].reset();
|
|
form.render();
|
|
recordData = null;
|
}
|
|
// 更新数据信息
|
function flushData() {
|
var index = layer.load();
|
var plateNum = $("#plateNum").val();
|
var userId2 = $("#userId").val();
|
var intelCard = $("#intelCard").val();
|
var param = {
|
type : type,
|
progress : progress,
|
userId: userId2,
|
intelCard: intelCard,
|
plateNum : plateNum
|
};
|
|
$.ajax({
|
type : "POST",
|
url : "../../basic/inout/inout-query-back",
|
dataType : "json",
|
contentType : "application/json;charset=UTF-8",
|
data : JSON.stringify(param),
|
success : function(result) {
|
if (result.code != "0000") {
|
layer.alert(result.msg);
|
} else {
|
recordData = result.data;
|
// 返回的数据进行赋值
|
form.val("form-data", recordData);
|
form.val("form-basic", recordData);
|
form.render();
|
}
|
layer.close(index);
|
},
|
error : function() {
|
layer.close(index);
|
layer.alert("查询失败,请重新尝试!!");
|
}
|
});
|
}
|
|
// 当前完成
|
function submit() {
|
if (!recordData) {
|
layer.alert("没有数据可以提交!!!");
|
return;
|
}
|
|
// 提交数据比较特殊,不用考虑基本信息提交
|
var index = layer.load();
|
var data = form.val("form-data");
|
Object.assign(recordData, data);
|
|
$.ajax({
|
type : "POST",
|
url : "../../basic/inout/inout-back-submit",
|
dataType : "json",
|
contentType : "application/json;charset=UTF-8",
|
data : JSON.stringify(recordData),
|
success : function(result) {
|
if (result.code != "0000") {
|
layer.msg(result.msg);
|
} else {
|
layer.alert("卡片回收成功!");
|
// 重置页面
|
resetForm();
|
}
|
layer.close(index);
|
},
|
error : function() {
|
layer.close(index);
|
layer.msg("卡片回收失败,请重新尝试!!");
|
}
|
});
|
}
|