PPEmptyIn.js
6.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
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();
    });
});