Blame view

WebMvc/wwwroot/productjs/task/PPEmptyIn.js 6.33 KB
霍尔 authored
1
2
layui.config({
    base: "/js/"
霍尔 authored
3
}).use(['form', 'element', 'vue', 'layer', 'laydate', 'jquery', 'hhweb', 'table', 'utils', 'Universal'], function () {
霍尔 authored
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
    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 = {
霍尔 authored
19
霍尔 authored
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
    };

    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) {
霍尔 authored
42
43
44
                            layer.msg("呼叫RGV成功", { icon: 6, shade: 0.4, time: 1000 });
                            $('[name = "PalletNo"]').attr("disabled", "disabled");
                            $('[name = "PalletNo"]').css("background-color", "#eee");
霍尔 authored
45
46
                        }
                        else {
霍尔 authored
47
                            layer.alert("失败:" + result.msg, { icon: 5, shadeClose: true, title: "错误信息" }, function (index) { layer.close(index); });
霍尔 authored
48
49
50
51
52
53
54
55
56
                        }
                    },
                    error: function (errorThrown) {
                        layer.alert(errorThrown, { icon: 2, title: '提示' });
                    }
                })
            });
        }
        else {
霍尔 authored
57
            layer.alert("请先扫描托盘号", { icon: 5, shadeClose: true, title: "错误信息" }, function (index) { layer.close(index); });
霍尔 authored
58
        }
霍尔 authored
59
霍尔 authored
60
61
62
63
64
    });

    //空板入库
    $(document).on("click", "#EmptyIn", function () {
        var PalletNo = $('[name = "PalletNo"]').val()
霍尔 authored
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
        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;
        };
霍尔 authored
120
121
            $.ajax({
                async: false,
霍尔 authored
122
                url: "/" + "task" + "/" + "Task" + "/PalletIsNo",
霍尔 authored
123
                type: "post",
霍尔 authored
124
                data: { Pallet: PalletNo, station: 'PP_SpecialPoint' },
霍尔 authored
125
126
127
                dataType: "json",
                success: function (result) {
                    if (result.code == 200) {
霍尔 authored
128
                        layer.msg("托盘号格式正确", { icon: 6, shade: 0.4, time: 1000 });
霍尔 authored
129
130
                    }
                    else {
霍尔 authored
131
                        layer.alert(result.data, { icon: 2, title: '错误' }, function (index) { $('[name = "PalletId"]').val(""); layer.close(index); });
霍尔 authored
132
133
                    }
                },
霍尔 authored
134
                error: function (XMLHttpRequest, textStatus, errorThrown) {
霍尔 authored
135
136
                    layer.alert(errorThrown, { icon: 2, title: '提示' });
                }
霍尔 authored
137
138
            });
    }
霍尔 authored
139
140
141
142
143
144

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