var layer; var form; var snapData;//登记照片 $(function () { layui.use(['layer', 'laydate', 'form', 'util'], function () { var util = layui.util; var laydate = layui.laydate; layer = layui.layer; form = layui.form; laydate.render({ elem: '#userBirthday' }); // 右下角添加固定信息 util.fixbar({ bar1: true, css: { right: 10, bottom: 20 }, bgcolor: '#53adce', click: function (type) { if (type === 'bar1') { layer.closeAll(); layer.open({ type: 2, title: false, shadeClose: true, shade: 0.3, closeBtn: 2, offset: ['50px', '50px'], area: ['1000px', '640px'], content: '../../basic/inout/inout-progress?type=' + type + "&t=" + Math.random() }); } } }); }); showProgress(); var rightH = $(".rkbk-left-wrap").height(); $(".rkbk-right-wrap").height(rightH); $(window).resize(function () { var rightH = $(".rkbk-left-wrap").height(); $(".rkbk-right-wrap").height(rightH); }); // 初始化WebSocket initWS(deptId, bizType, progress, userId); }); window.onload = function () { // 加载视频 initVideo(lprDto, null, null); }; //控制流程环节显示 function showProgress() { if (!inoutProgress) { return; } if (inoutProgress.indexOf("REGISTER") == -1) { $("#progress-register").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"); } } // socket信息返回處理 function socketOnMessage(packet) { }; //使用插件读取身份证 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'] // }); alertError("没有获取到身份证信息!"); return; } // 临时赋值 $("#userName").val(data.cnName); $("#userSex").val(data.sex); $("#userNation").val(data.nation); $("#userAddress").val(data.address); //$("#id_img_pers").attr("src",data.Image); var time = data.birthdate; if (time.length == 8) { time = time.substring(0, 4) + "-" + time.substring(4, 6) + "-" + time.substring(6); } $("#userBirthday").val(time); $("#userId").val(data.idNum); if (data.Image) { $("#id_img_pers").attr("src", data.Image); } }, error: function () { layer.alert("身份证读取失败!", { offset: ['300px', '300px'] }); layer.close(index); } }); } //使用插件读取智慧卡号 function flushICCard() { $("#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) { //console.log(json); var data = json.no; //console.log(data); if (data === "not found") { layer.alert("请重新读卡!", {offset: ['300px', '300px']}); } else { $("#intelCard").val(data); } }, error: function () { layer.alert("IC卡读取出错!", {offset: ['300px', '300px']}); } }); } //读取车牌号 function flushPlateNum() { var param = JSON.stringify(lprDto); var index = layer.load(); $.ajax({ type: "POST", url: "../../inout/api/get-plateNum", dataType: "json", contentType: "application/json;charset=UTF-8", data: param, success: function (result) { if (result.code != "0000") { alertError(result.msg); } else { $("#plateNum").val(result.data.plateNum); $("#plateNum2").val(result.data.plateNum); } layer.close(index); }, error: function () { layer.close(index); alertError("车牌识别失败!"); } // success: function (result) { // if (result.code != "0000") { // layer.alert(result.msg, { // offset: ['300px', '300px'] // }); // } else { // if (result.data.errorMsg) { // layer.alert(result.data.errorMsg, { // offset: ['300px', '300px'] // }); // } else { // $("#plateNum").val(result.data.plateNum); // } // } // layer.close(index); // }, // error: function () { // layer.close(index); // layer.alert("车牌识别失败!", { // offset: ['300px', '300px'] // }); // } }); } ///重置车牌识别信息 function resetPlateNum() { var index = layer.load(); var param = JSON.stringify(lprDto); $.ajax({ type: "POST", url: "../../inout/api/reset-lpr", dataType: "json", contentType: "application/json;charset=UTF-8", data: param, success: function (result) { if (result.code != "0000") { layer.alert(result.msg, { offset: ['300px', '300px'] }); } else { layer.alert("重置成功,请重新获取车牌信息", { offset: ['300px', '300px'] }); } layer.close(index); }, error: function () { layer.close(index); layer.alert("重置执行失败", { offset: ['300px', '300px'] }); } }); } // 表单清空 function resetForm() { $("#form-data")[0].reset(); form.render(); // 身份证重置 $("#id_img_pers").attr("src", "../../static/images/rkbk-photo_03.png"); $("#pz-img").removeClass("kccz-r-img-red"); $("#pz-text").text("自动抓拍"); } // 当前完成 function submit() { var data = form.val("form-data"); if (!data.userName) { // notify("承运人信息不能为空", null); alertError("承运人信息不能为空"); return; } if (!data.plateNum) { alertError("车牌号不能为空"); // notify("车牌号不能为空", null); return; } if (!data.intelCard && !data.userId) { alertError("智慧卡号与身份证号不能同时为空"); // notify("智慧卡号与身份证号不能同时为空", null); return; } //系统抓拍 layer.msg("系统自动抓拍记录……"); snapData = { companyId: companyId, deptId: deptId, progress: progress, bizType: bizType, plateNum: data.plateNum, id1: (null != lprDto) ? lprDto.id : null }; $.ajax({ sync: false, type: "POST", url: "../../inout/api/snap-img", dataType: "json", contentType: "application/json;charset=UTF-8", data: JSON.stringify(snapData), success: function (result) { if (result.code != "0000") { layer.alert(result.msg); submitData(data); } else { snapData = result.data; $("#pz-img").addClass("kccz-r-img-red"); $("#pz-text").text("已拍照"); submitData(data); } }, error: function () { layer.msg("后台调用截图失败,请重新尝试!!"); submitData(data); } }); } //执行保存数据 function submitData(data) { var index = layer.load(); var files = [{ fileName: snapData.fileName1 }]; data.files = files; $.ajax({ type: "POST", url: "../../basic/inout/submit-register", dataType: "json", contentType: "application/json;charset=UTF-8", data: JSON.stringify(data), success: function (result) { layer.close(index); if (result.code != "0000") { notify(result.msg, result.data); } else { notify("数据提交成功", result.data); // 重置页面 resetForm(); } }, error: function () { layer.close(index); layer.alert("提交失败,请重新尝试!!"); } }); } /** * 弹出提醒框 * @param msg 提醒信息 * @param data 数据信息,可能为空 */ function notify(msg, data) { if (data) { //赋值 $("#resultMsg").text(msg); $("#resultUserName").text(data.userName); $("#resultPlateNum").text(data.plateNum); if ("IN" == data.type) { $("#resultType").text("入库-" + INOUT_PROGRESS_MSG(data.progress)); } else { $("#resultType").text("出库-" + INOUT_PROGRESS_MSG(data.progress)); } $("#resultIntelCard").text(data.intelCard); layer.open({ type: 1, offset: ['150px', '200px'], area: '450px;', shade: 0.8, id: 'dialog_notify_info', btn: ['确定'], content: $('#dialog-from-notify'), yes: function (index) { layer.closeAll(); } }); } else { layer.alert(msg, {offset: ['300px', '300px']}); } }