//卡回收
|
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 flushICCard() {
|
var index = layer.load();
|
$("#intelCard").val(null);
|
$.ajax({
|
type: "GET",
|
async: true,
|
url: "http://127.0.0.1:9111/ICCARD",
|
data: {},
|
dataType: "jsonp",
|
jsonp: "callback",
|
jsonpCallback: "jsonpCallback",
|
success: function (json) {
|
layer.close(index);
|
var data = json.no;
|
if (data === "not found") {
|
alertError("请重新读卡!");
|
} else {
|
$("#intelCard").val(data);
|
|
//直接刷新数据
|
flushData();
|
}
|
},
|
error: function () {
|
layer.close(index);
|
alertError("IC卡读取出错!");
|
}
|
});
|
}
|
|
|
//使用插件读取身份证
|
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") {
|
alertError("没有获取到身份证信息!");
|
return;
|
}
|
$("#userId").val(data.idNum);
|
console.log(data)
|
flushData();
|
},
|
error: function () {
|
layer.close(index);
|
alertError("身份证读取失败!");
|
}
|
});
|
}
|
|
// 表单清空
|
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);
|
alertError("查询失败,请重新尝试!")
|
}
|
});
|
}
|
|
// 当前完成
|
function submitData() {
|
if (!recordData) {
|
alertError("没有数据可以提交!");
|
return;
|
}
|
|
// 提交数据比较特殊,不用考虑基本信息提交
|
var index = layer.load();
|
var data = form.val("form-data");
|
Object.assign(recordData, data);
|
|
$.ajax({
|
type: "POST",
|
url: "../../basic/inout/submit-card-back",
|
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("卡片回收失败,请重新尝试!!");
|
}
|
});
|
}
|