var layer; var form; var snapData;//登记照片 $(function () { layui.use(['layer', 'form'], function () { layer = layui.layer; form = layui.form; // 监听类型选择 form.on('select(select_type)', function (obj) { return changeProgress(); }); }); initData(); 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); }); }); window.onload = function () { // 加载视频 initVideo(lprDto, null, null); }; function initData() { if (type) { $("#type").val(type); var actualVal = $("#type").val(); console.log("赋值后实际选中值:", actualVal); console.log("是否与目标值一致?", actualVal === type); } showProgress(); } /** * 控制流程环节显示 */ function showProgress() { if (!inoutProgress) { return; } if (inoutProgress.indexOf("REGISTER") === -1) { $("#rk-progress-register").css("display", "none"); $("#ck-progress-register").css("display", "none"); } if (inoutProgress.indexOf("WEIGHT_FULL") === -1) { $("#rk-progress-fullWeight").css("display", "none"); $("#ck-progress-fullWeight").css("display", "none"); } if (inoutProgress.indexOf("HANDLE") === -1) { $("#rk-progress-hand").css("display", "none"); $("#ck-progress-hand").css("display", "none"); } if (inoutProgress.indexOf("WEIGHT_EMPTY") === -1) { $("#rk-progress-emptyWeight").css("display", "none"); $("#ck-progress-emptyWeight").css("display", "none"); } if (inoutProgress.indexOf("CARD_BACK") === -1) { $("#rk-progress-cardBack").css("display", "none"); $("#ck-progress-cardBack").css("display", "none"); } if (type === "IN") { $("#rk_progress").css("display", "block"); $("#ck_progress").css("display", "none"); } if (type === "OUT") { $("#ck_progress").css("display", "block"); $("#rk_progress").css("display", "none"); } } /** * 切换流程 * @param obj */ function changeProgress() { type = $("#type").val(); showProgress(); } /** * 读取身份证 */ function flushIdCard() { var index = layer.load(); $.ajax({ type: "GET", async: true, url: "http://127.0.0.1:9111/IDCARD", data: {}, dataType: "json", success: function (json) { layer.close(index); var data = json; if (data.code === "200" || data.code == 200) { // 临时赋值 $("#userName").val(data.cnName); $("#userAddress").val(data.address); $("#userId").val(data.idNum); if (data.Image) { $("#id_img_pers").attr("src", data.Image); } }else{ alertError("没有获取到身份证信息!"); return; } }, error: function () { layer.alert("身份证读取失败!", { offset: ['300px', '300px'] }); layer.close(index); } }); } /** * 读取车牌号 */ 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("车牌识别失败!"); } }); } /** * 重置表单 */ 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.type) { alertError("出入库类型不能为空"); return; } if (!data.plateNum) { alertError("车牌号不能为空"); return; } if (!data.userName) { alertError("承运人姓名不能为空"); return; } //系统抓拍 layer.msg("系统自动抓拍记录……"); snapData = { companyId: companyId, deptId: deptId, progress: progress, bizType: type, plateNum: data.plateNum, id1: (null != lprDto) ? lprDto.id : null, id2: (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); } }); } /** * 提交数据 * @param data */ function submitData(data) { var index = layer.load(); var files = [{ fileName: snapData.fileName1 },{ fileName: snapData.fileName2 }]; 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']}); } }