PPEmptyIn.js 6.33 KB
layui.config({
    base: "/js/"
}).use(['form', 'element', 'vue', 'layer', 'laydate', 'jquery', 'hhweb', 'table', 'utils', 'Universal'], function () {
    var form = layui.form,
        layer = layui.layer,
        element = layui.element,
        laydate = layui.laydate,
        $ = layui.jquery,
        table = layui.table,
        Universal = layui.Universal;

    var AreaName = 'task';
    var TableName = 'TaskDetail';

    var vm = new Vue({
        el: '#PalletForm'
    });
    var selector = {

    };

    var vml = new Array({
        vm: vm,
    });

    Universal.BindSelector($, form, vml, selector);


    //呼叫RGV
    $(document).on("click", "#CallRgv", function () {
        var PalletNo = $('[name = "PalletNo"]').val()
        if (PalletNo != '') {
            layer.alert("确定呼叫RGV准备空板入库?", { icon: 3, shadeClose: true, title: "提示信息" }, function (index) {
                $.ajax({
                    async: false,
                    url: "/" + "task" + "/" + "Task" + "/BulidEmptyContainerBack",
                    type: "post",
                    data: { station: 'PP_SpecialPoint', containerCode: $('[name = "PalletNo"]').val(), type: "PP_EmptyIn_1" },
                    dataType: "json",
                    success: function (result) {
                        if (result.code == 200) {
                            layer.msg("呼叫RGV成功", { icon: 6, shade: 0.4, time: 1000 });
                            $('[name = "PalletNo"]').attr("disabled", "disabled");
                            $('[name = "PalletNo"]').css("background-color", "#eee");
                        }
                        else {
                            layer.alert("失败:" + result.msg, { icon: 5, shadeClose: true, title: "错误信息" }, function (index) { layer.close(index); });
                        }
                    },
                    error: function (errorThrown) {
                        layer.alert(errorThrown, { icon: 2, title: '提示' });
                    }
                })
            });
        }
        else {
            layer.alert("请先扫描托盘号", { icon: 5, shadeClose: true, title: "错误信息" }, function (index) { layer.close(index); });
        }

    });

    //空板入库
    $(document).on("click", "#EmptyIn", function () {
        var PalletNo = $('[name = "PalletNo"]').val()
        if (PalletNo == "") {
            layer.alert("请先扫描托盘号", { icon: 5, shadeClose: true, title: "错误信息" }, function (index) { layer.close(index); });
        }
        else {
            layer.alert("确定入空托盘?<br/>托盘号为:" + PalletNo, { icon: 3, shadeClose: true, title: "提示信息" }, function (index) {
                $.ajax({
                    async: false,
                    url: "/" + "task" + "/" + "Task" + "/BulidEmptyContainerBack",
                    type: "post",
                    data: { station: 'PP_SpecialPoint', containerCode: $('[name = "PalletNo"]').val(), type: "PP_EmptyIn_2" },
                    dataType: "json",
                    success: function (result) {
                        if (result.code == 200) {
                            console.log(result)
                            layer.msg("空板入库成功", { icon: 6, shade: 0.4, time: 1000 });
                            $('[name = "PalletNo"]').val("");
                            $('[name = "PalletNo"]').removeAttr("disabled");
                            $('[name = "PalletNo"]').removeClass("background-color");
                            $('[name = "PalletNo"]').focus();
                        }
                        else {
                            layer.alert("失败:" + result.msg, { icon: 5, shadeClose: true, title: "错误信息" }, function (index) { layer.close(index); });
                        }
                    },
                    error: function (errorThrown) {
                        layer.alert(errorThrown, { icon: 2, title: '提示' });
                    }
                })
            });
        }
    });

    //“托盘号”回车监听
    $('[name = "PalletNo"]').bind("keydown", function (e) {
        if (e.which == 13) {
            ContrastPallet();
            e.preventDefault();
        }
    });

    //根据托盘号对比托盘是否正确
    function ContrastPallet() {
        var PalletNo = $('[name = "PalletNo"]').val();
        if (PalletNo.length == "") {
            layer.alert("托盘号为空,请重新扫描", { icon: 5, shadeClose: true, title: "错误信息" }, function (index) { $('[name = "PalletNo"]').val(""); $('[name = "PalletNo"]').focus(); layer.close(index); });
            return false;
        }
        if (PalletNo.length != 7) {
            layer.alert("托盘号长度不正确,正确托盘号为7位,<br>当前托盘号为" + PalletNo.length + "位,请重新扫描", { icon: 5, shadeClose: true, title: "错误信息" }, function (index) { $('[name = "PalletNo"]').val(""); $('[name = "PalletNo"]').focus(); layer.close(index); });
            return false;
        }
        if (PalletNo.indexOf("PP") != 0 && PalletNo.length == 7) {
            layer.alert("托盘号格式与当前站台不符,请重新扫描托盘号", { icon: 5, shadeClose: true, title: "错误信息" }, function (index) { $('[name = "PalletNo"]').val(""); $('[name = "PalletNo"]').focus(); layer.close(index); });
            return false;
        };
            $.ajax({
                async: false,
                url: "/" + "task" + "/" + "Task" + "/PalletIsNo",
                type: "post",
                data: { Pallet: PalletNo, station: 'PP_SpecialPoint' },
                dataType: "json",
                success: function (result) {
                    if (result.code == 200) {
                        layer.msg("托盘号格式正确", { icon: 6, shade: 0.4, time: 1000 });
                    }
                    else {
                        layer.alert(result.data, { icon: 2, title: '错误' }, function (index) { $('[name = "PalletId"]').val(""); layer.close(index); });
                    }
                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    layer.alert(errorThrown, { icon: 2, title: '提示' });
                }
            });
    }

    //打开页面聚焦“容器管理”
    $(document).ready(function () {
        $('[name = "PalletNo"]').focus();
    });
});