czt
10 天以前 52ea5fd92596267379be7924deb27de6cb10632b
fzzy-igdss-web/src/main/resources/static/inout/inout-register.js
@@ -1,170 +1,98 @@
//称重-包括空车和满车称重
var layer;
var form;
var table;
var recordData = null;// 业务数据信息
var snapData;//系统抓拍对象信息
var timerWeight;
var paramIntelCard;//设备识别结果
var paramIdCard;//设备识别结果
var curCheckItems = null;// 当前数据的检查项信息
var step = 1;
var snapData;//登记照片
$(function () {
    layui.use(['layer', 'laydate', 'form', 'table', 'util'], function () {
        var util = layui.util;
    layui.use(['layer', 'form'], function () {
        layer = layui.layer;
        form = layui.form;
        table = layui.table;
        layui.laydate.render({
            elem: '#test1',
            theme: '#7b8e9f'
        });
        // 右下角添加固定信息
        util.fixbar({
            bar1: true,
            css: {
                left: 10,
                bottom: 10
            },
            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', '120px'],
                        area: ['1000px', '640px'],
                        content: '../../basic/inout/inout-progress?type=' + type + "&t=" + Math.random()
                    });
                }
            }
        });
        //监听选择数据事件
        table.on('tool(tableListProgressData)', function (obj) {
            var data = obj.data;
            if (obj.event === 'select') {
                //清空表单
                resetForm();
                flushData(data.intelCard, null);
                layer.closeAll();
            }
        // 监听类型选择
        form.on('select(select_type)', function (obj) {
            return changeProgress();
        });
    });
    //显示流程环节
    showProgress();
    initData();
    // 监听重量变化
    $(".weight").blur(function () {
        deAutoByIn(this.name);
    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
    // initInoutWS(companyId, bizType, progress, userId);
});
window.onload = function () {
    //自动连接地磅信息,2.5秒获取一次地磅重量信息
    clearInterval(timerWeight);
    timerWeight = setInterval(function () {
        flushWeight();
    }, 2500);
    // 加载视频
    initVideo(snapDto1, snapDto2, snapDto3);
    //设置地磅
    $("#scaleName").val(weightDto.sort);
    //监听地磅选择
    $("#scaleName").change(function () {
        layer.confirm('调整地磅需重新加载页面,确定调整?', {
            btn: ['确定', '取消']
        }, function () {
            updateWeight();
        });
    });
    initVideo(lprDto, null, null);
};
// socket信息返回處理
function socketOnMessage(packet) {
    //暂无
function initData() {
    if (type) {
        $("#type").val(type);
        var actualVal = $("#type").val();
        console.log("赋值后实际选中值:", actualVal);
        console.log("是否与目标值一致?", actualVal === type);
    }
    showProgress();
}
//点击称重
function weight() {
    // 没有业务数据不可执行
    if (!recordData) {
        alertError("没有查询到业务数据,执行被拒绝!");
/**
 * 控制流程环节显示
 */
function showProgress() {
    if (!inoutProgress) {
        return;
    }
    // 如果是空车称重
    if (InoutProgress.WEIGHT_EMPTY == recordData.progress) {
        form.val("form-data", {
            emptyWeight: weightDto.weight
        });
        form.render();
    if (inoutProgress.indexOf("REGISTER") === -1) {
        $("#rk-progress-register").css("display", "none");
        $("#ck-progress-register").css("display", "none");
    }
    // 如果是满车称重
    if (InoutProgress.WEIGHT_FULL == recordData.progress) {
        form.val("form-data", {
            fullWeight: weightDto.weight
        });
        form.render();
    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");
    }
    // 点击称重自动调用抓拍
    snapData = {
        companyId: companyId,
        deptId: deptId,
        progress: recordData.progress,
        bizType: type,
        bizId: recordData.id,
        plateNum: recordData.plateNum,
        id1: snapDto1.id,
        id2: snapDto2.id,
        id3: snapDto3.id,
        id4: snapDto2.id,
        sort: $("#scaleName").val(),
        weight: weightDto.weight
    };
    //当前AJAX服务为同步服务,返回数据包装照片信息
    var index = layer.load();
    $.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) {
            layer.close(index);
            if (result.code != "0000") {
                alertError(result.msg);
            } else {
                snapData = result.data;
            }
        },
        error: function () {
            layer.close(index);
            alertError("后台调用截图失败,请重新尝试");
        }
    });
    //如果是第二次称重,默认执行自动计算
    if (InoutProgress.WEIGHT_EMPTY == recordData.progress) {
        deAutoByIn("emptyWeight");
    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({
@@ -173,374 +101,159 @@
        url: "http://127.0.0.1:9111/IDCARD",
        data: {},
        dataType: "json",
        // jsonp: "callback",
        // jsonpCallback: "jsonpCallback",
        success: function (json) {
            layer.close(index);
            var data = json;
            if (data.code === "200" || data.code == 200) {
                paramIdCard = data.idNum;
                $("#text-param").text("识别身份证:" + paramIdCard);
                flushData(null, paramIdCard);
            } else {
                alertError("没有读取到身份证信息!");
                // 临时赋值
                $("#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 () {
            alertError("没有读取到身份证信息!");
            layer.alert("身份证读取失败!", {
                offset: ['300px', '300px']
            });
            layer.close(index);
        }
    });
}
function flushByHand() {
    var intelCard = $("#intelCard").val();
    flushData(intelCard, null);
}
/**
 * 手动选择,获取待称重的数据,弹出选择
 * 读取车牌号
 */
function selectByHand() {
    var param = {
        deptId: deptId,
        type: type,
        timer: Math.random()
    };
    $.ajax({
        type: "POST",
        url: "../../basic/inout/list-only-progress",
        dataType: "json",
        contentType: "application/json;charset=UTF-8",
        data: JSON.stringify(param),
        success: function (result) {
            if (result.code != "0000") {
                layer.msg(result.msg);
            } else {
                renderTableProgressData(result.data);
            }
        },
        error: function () {
            layer.msg("系统获取数据出现异常,重新尝试");
        }
    });
}
function flushWeight() {
    var ip = "127.0.0.1";
    if (weightDto.ip) {
        ip = weightDto.ip;
    }
    var port = "9111";
    if (weightDto.port) {
        port = weightDto.port;
    }
    var sn = "WEIGHT";
    if (weightDto.sn) {
        sn = weightDto.sn;
    }
    var url = "http://" + ip + ":" + port + "/" + sn;
    $.ajax({
        type: "GET",
        async: true,
        timeout: 2000,
        url: url,
        data: {},
        dataType: "json",
        success: function (json) {
            var data = json.content;
            if (!data) data = 0.0;
            weightDto.weight = data;
            $("#weightValue").text(data);
            $("#img_scale_statule").attr("src", "/img/web/inout/icon-gree.png");
        },
        error: function () {
            weightDto.weight = 0.0;
            $("#weightValue").text("0.0");
            $("#img_scale_statule").attr("src", "/img/web/inout/icon-red.png");
        }
    });
}
// 点击打印,系统判断是否已经执行完成,如果已经完成,直接打印,如果未完成则先执行完成
function printBill() {
    if (!recordData) {
        alertError("没有获取到业务数据,打印被拒绝!");
        return;
    }
    // 从后台获取模版并打印
    var data = form.val("form-data");
    // 合并更新當前编辑数据
    Object.assign(recordData, data);
function flushPlateNum() {
    var param = JSON.stringify(lprDto);
    var index = layer.load();
    $.ajax({
        type: "POST",
        url: "../../basic/inout/report/bill-weight",
        url: "/inout/api/get-plateNum",
        dataType: "json",
        contentType: "application/json;charset=UTF-8",
        data: JSON.stringify(recordData),
        data: param,
        success: function (result) {
            layer.close(index);
            if (result.code != "0000") {
                alertError(result.msg);
            } else {
                layer.msg("开始渲染打印单……");
                printWeight(result.data);
                $("#plateNum").val(result.data.plateNum);
            }
            layer.close(index);
        },
        error: function () {
            layer.close(index);
            alertError("获取打印模版失败,请联系管理员查看原因");
            alertError("车牌识别失败!");
        }
    });
}
// 表单清空
/**
 * 重置表单
 */
function resetForm() {
    $("#form-data")[0].reset();
    form.render();
    recordData = null;
    weightDto.weight = 0.0;
    $("#weightValue").text("0.0");
    $("#img_scale_statule").attr("src", "/img/web/inout/icon-red.png");
    $("#text-param").val(null);
    // 身份证重置
    $("#id_img_pers").attr("src", "/img/web/inout/rkbk-photo_03.png");
    $("#pz-img").removeClass("kccz-r-img-red");
    $("#pz-text").text("自动抓拍");
}
function flushPage() {
    layer.confirm('确定要刷新页面吗?', {icon: 3, title: '提示'}, function (index) {
        resetForm();
        layer.close(index);
    });
}
//监听表单里的数值变化
document.getElementById('intelCard').addEventListener('input', function (event) {
    var intelCard = $("#intelCard").val();
    if (intelCard.length == 10) {
        flushData(intelCard, null);
/**
 * 完成提交抓图
 */
function submit() {
    var data = form.val("form-data");
    if (!data.type) {
        alertError("出入库类型不能为空");
        return;
    }
});
    if (!data.plateNum) {
        alertError("车牌号不能为空");
        return;
    }
    if (!data.userName) {
        alertError("承运人姓名不能为空");
        return;
    }
// --查询方法,获取身份证号、卡号、车牌号,进行查询
function flushData(intelCard, userIdCard) {
    var index = layer.load();
    var userIdCard = userIdCard;
    var intelCard = intelCard;
    var plateNum = $("#plateNum").val();
    var param = {
        type: type,
    //系统抓拍
    layer.msg("系统自动抓拍记录……");
    snapData = {
        companyId: companyId,
        deptId: deptId,
        progress: progress,
        intelCard: intelCard,
        userId: userIdCard,
        plateNum: plateNum
        bizType: type,
        plateNum: data.plateNum,
        id1: (null != lprDto) ? lprDto.id : null,
        id2: (null != lprDto) ? lprDto.id : null,
    };
    $.ajax({
        sync: false,
        type: "POST",
        url: "../../basic/inout/inout-query",
        url: "../../inout/api/snap-img",
        dataType: "json",
        contentType: "application/json;charset=UTF-8",
        data: JSON.stringify(param),
        data: JSON.stringify(snapData),
        success: function (result) {
            layer.close(index);
            if (result.code != "0000") {
                notifyProgress(result.msg, result.data);
                layer.alert(result.msg);
                submitData(data);
            } else {
                recordData = result.data;
                // 返回的数据进行赋值
                form.val("form-data", recordData);
                form.render();
                snapData = result.data;
                updateEditAndProgress();
                $("#pz-img").addClass("kccz-r-img-red");
                $("#pz-text").text("已拍照");
                submitData(data);
            }
        },
        error: function () {
            layer.close(index);
            alertError("查询失败,请重新尝试");
            layer.msg("后台调用截图失败,请重新尝试!!");
            submitData(data);
        }
    });
}
/**
 * 根据业务数据更新页面中的状态
 * 提交数据
 * @param data
 */
function updateEditAndProgress() {
    if (recordData) {
        if (InoutProgress.WEIGHT_EMPTY == recordData.progress) {
            $("#emptyWeight").removeClass("rkbk-search-input");
            $("#emptyWeight").attr("disabled", false);
function submitData(data) {
    var index = layer.load();
            $("#progress-hand").addClass("active");
            $("#progress-emptyWeight").addClass("active");
            $("#fullWeight").addClass("rkbk-search-input");
            $("#fullWeight").attr("disabled", true);
        }
        if (InoutProgress.WEIGHT_FULL == recordData.progress) {
            $("#fullWeight").removeClass("rkbk-search-input");
            $("#fullWeight").attr("disabled", false);
            $("#progress-hand").removeClass("active");
            $("#progress-emptyWeight").removeClass("active");
            $("#emptyWeight").addClass("rkbk-search-input");
            $("#emptyWeight").attr("disabled", true);
        }
    } else {
        $("#fullWeight").addClass("rkbk-search-input");
        $("#fullWeight").attr("disabled", true);
        $("#emptyWeight").addClass("rkbk-search-input");
        $("#emptyWeight").attr("disabled", true);
        $("#progress-hand").removeClass("active");
        $("#progress-emptyWeight").removeClass("active");
    }
    //根据配置信息设置地磅是否可编辑
    if (weightEditTag && weightEditTag == 'N') {
        $("#fullWeight").addClass("rkbk-search-input");
        $("#fullWeight").attr("disabled", true);
        $("#emptyWeight").addClass("rkbk-search-input");
        $("#emptyWeight").attr("disabled", true);
    }
}
// 当前完成
function submit() {
    if (!recordData) {
        alertError("没有业务数据信息,执行被拒绝");
        return;
    }
    var data = form.val("form-data");
    if (!data.depotId) {
        alertError("提示:装卸仓库必填");
        return;
    }
    if (!data.customerName) {
        alertError("提示:客户名称必填");
        return;
    }
    // 校验-入库满车称重
    if (InoutProgress.WEIGHT_FULL == recordData.progress) {
        if (data.fullWeight <= 0.0) {
            alertError("提示:满车称重信息必填");
            return;
        }
    }
    if (InoutProgress.WEIGHT_EMPTY == recordData.progress) {
        if (data.emptyWeight <= 0.0) {
            alertError("提示:空车称重信息必填");
            return;
        }
        if (!data.foodVariety) {
            alertError("提示:粮食品种必填");
            return;
        }
        if (!data.settleWeight || data.settleWeight <= 0.0) {
            alertError("结算重量不合规,请核对");
            return;
        }
        if (!data.recordWeight || data.recordWeight <= 0.0) {
            alertError("入库重量不合规,请核对");
            return;
        }
    }
    //合并数据
    Object.assign(recordData, data);
    // 获取照片
    var files = [{
        fileName: snapData.fileName1
    }, {
    },{
        fileName: snapData.fileName2
    }, {
        fileName: snapData.fileName3
    }, {
        fileName: snapData.fileName4
    }];
    recordData.files = files;
    var index = layer.load();
    data.files = files;
    $.ajax({
        type: "POST",
        url: "../../basic/inout/submit-weight",
        url: "../../basic/inout/submit-register",
        dataType: "json",
        contentType: "application/json;charset=UTF-8",
        data: JSON.stringify(recordData),
        data: JSON.stringify(data),
        success: function (result) {
            layer.close(index);
            if (result.code != "0000") {
                alertError(result.msg);
                notify(result.msg, result.data);
            } else {
                notify("数据提交成功", result.data);
                if (InoutProgress.WEIGHT_FULL == recordData.progress) {
                    resetForm();
                }
            }
            layer.close(index);
        },
        error: function () {
            layer.close(index);
            alertError("提交失败,请重新尝试");
        }
    });
}
//显示质检信息
function showCheck() {
    if (!recordData) {
        alertError("没有业务数据信息,执行被拒绝");
        return;
    }
    // 获取化验项信息
    flushCheckItem();
    layer.open({
        type: 1,
        title: "质检详细",
        offset: ['120px', '100px'],
        area: ['1000px', '520px'],
        shade: 0,
        content: $('#checkDetail'),
        btnAlign: 'c',
        btn: ['取消'],
        yes: function () {
            layer.closeAll();
        },
        closeBtn: 0
    });
}
/**
 * 刷新化验结果项
 */
function flushCheckItem() {
    curCheckItems = null;
    $.ajax({
        type: "POST",
        url: "../../basic/inout/get-check-item",
        dataType: "json",
        contentType: "application/json;charset=UTF-8",
        data: JSON.stringify(recordData),
        success: function (result) {
            if (result.code != "0000") {
                layer.msg(result.msg);
            } else {
                curCheckItems = result.data;
                // 页面渲染检测项
                renderTableCheckItem();
                // 重置页面
                resetForm();
            }
        },
        error: function () {
            layer.msg("后台异常,请重试或者联系管理员!!");
            layer.close(index);
            layer.alert("提交失败,请重新尝试!!");
        }
    });
}
@@ -578,122 +291,4 @@
    } else {
        layer.alert(msg, {offset: ['300px', '300px']});
    }
}
/**
 * 渲染表格
 */
function renderTableCheckItem() {
    // 清空数据
    $("#tableCheckItem").empty();
    table.render({
        elem: '#tableCheckItem',
        data: curCheckItems,
        page: false,
        even: true,
        cols: [[{
            field: 'standardName',
            title: '检验项目',
            align: 'center',
            width: '13%'
        }, {
            field: 'value',
            title: '检验值',
            align: 'center',
            width: '9%'
        }, {
            field: 'operaSymbolValue',
            title: '标准值',
            align: 'center',
            width: '10%'
        }, {
            field: 'unit',
            title: '单位',
            align: 'center',
            width: '10%'
        }, {
            field: 'deNum',
            title: '扣重',
            align: 'center',
            width: '9%'
        }, {
            field: 'addNum',
            title: '增重',
            align: 'center',
            width: '9%'
        }, {
            field: 'dePrice',
            title: '扣价',
            align: 'center',
            width: '9%'
        }, {
            field: 'addPrice',
            title: '增价',
            align: 'center',
            width: '9%'
        }, {
            field: 'result',
            title: '检验结果',
            align: 'center',
            width: '10%',
            templet: function (item) {
                if (item.result == null) {
                    return "";
                }
                if (item.result == '0') {
                    return "不合格";
                }
                if (item.result == '1') {
                    return "合格";
                }
            }
        }, {
            field: 'remarks',
            title: '备注说明',
            align: 'center'
        }]]
    });
    $("thead tr").css({
        "border-bottom": "2px solid #53adce",
        "background": "#eff4f6"
    });
}
function renderTableProgressData(list) {
    // 清空数据
    $("#tableListProgressData").empty();
    layer.open({
        type: 1,
        title: "选择流程中车辆",
        offset: ['120px', '100px'],
        area: ['1000px', '520px'],
        shade: 0,
        content: $('#listProgressData'),
        closeBtn: 1
    });
    table.render({
        elem: '#tableListProgressData',
        data: list,
        page: true,
        even: true,
        cols: [[
            {type: 'numbers'}, {
                field: 'id',
                title: '单据号',
                align: 'center'
            }, {
                field: 'userName',
                title: '承运人',
                align: 'center'
            }, {
                field: 'plateNum',
                title: '车牌号',
                align: 'center'
            }, {fixed: 'right', title: '选择操作', align: 'center', toolbar: '#barSelectProgress'}]]
    });
    $("thead tr").css({
        "border-bottom": "2px solid #53adce",
        "background": "#eff4f6"
    });
}