PalletIn.js 25 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 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576
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 PalletIn = new Vue({
        data: {}
    });


    var mainList = {
        //NoData: function () {
        //    return "<div id='background' style='width:100%;height:100%;background-image:url(../../images/NoData.png);background-repeat:no-repeat;background-size:cover;'>.</div>"
        //},
        mainList: function (vm) {
            table.reload('mainList', {
                url: "/" + "task" + "/" + "Task" + "/StationToInventory"
                , where: { stationCode: vm }
                , method: "post"
                , text: { none: "暂无数据,请扫码容器编号!" }
               // , text: { none: this.NoData() }
            });
        }
    };

    var selector = {
        'TaskType': {
            SelType: "FromDict",
            SelFrom: "taskType",
            SelModel: "TaskType",
            SelLabel: "DictLabel",
            SelValue: "DictValue",
            Dom: [$("[name='TaskType']")]
        },
        'ContainerStatus': {
            SelType: "FromDict",
            SelFrom: "containerStatus",
            SelModel: "ContainerStatus",
            SelLabel: "DictLabel",
            SelValue: "DictValue",
            Dom: [$("[name='ContainerStatus']")]
        },
        'Type': {
            SelType: "FromDict",
            SelFrom: "containerType",
            SelModel: "Type",
            SelLabel: "DictLabel",
            SelValue: "DictValue",
            Dom: [$("[name='Type']")]
        },
        //'Products': {
        //    SelType: "FromDict",
        //    SelFrom: "inventoryStatus",
        //    SelModel: "Products",
        //    SelLabel: "DictLabel",
        //    SelValue: "DictValue",
        //    Dom: [$("[name='Products']")]
        //},
        //'IsPack': {
        //    SelType: "FromDict",
        //    SelFrom: "IsPack",
        //    SelModel: "IsPack",
        //    SelLabel: "DictLabel",
        //    SelValue: "DictValue",
        //    Dom: [$("[name='IsPack']")]
        //},
        //'IsFold': {
        //    SelType: "FromDict",
        //    SelFrom: "containerType",
        //    SelModel: "IsFold",
        //    SelLabel: "DictLabel",
        //    SelValue: "DictValue",
        //    Dom: [$("[name='IsFold']")]
        //},
        
    };

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

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


    //空栈板出库
    $(document).on("click", "#btnEmpty", function () {
        var str = $('[name = "IsShou"]:checked').val();
        if (str == undefined) {
            layer.alert("请选择站台", { icon: 5, shadeClose: true, title: "错误信息" });
        } else if (str == "EntranceStationY01") {
            var type = "p_1";
            $.ajax({
                async: false,
                type: "post",
                url: "/task/Task/EmptyPalletOut",
                data: { station: "ExitStationY01", type: type },
                dataType: "json",
                success: function (result) {
                    if (result.Code == 200) {
                        layer.msg("呼叫空栈板成功", { icon: 6, shade: 0.4, time: 1000 });
                    }
                    else {
                        layer.alert("失败:" + result.Message, { icon: 5, shadeClose: true, title: "错误信息" }, function (index) { $('[name = "PalletId"]').focus(); layer.close(index); });
                    }
                },
                error: function (errorThrown) {
                    layer.alert(errorThrown, { icon: 2, title: '提示' });
                }
            })
        }
        else {
            var type = "p_1";
            $.ajax({
                async: false,
                type: "post",
                url: "/task/Task/EmptyPalletOut",
                data: { station: str, type: type },
                dataType: "json",
                success: function (result) {
                    if (result.Code == 200) {
                        layer.msg("呼叫空栈板成功", { icon: 6, shade: 0.4, time: 1000 });
                    }
                    else {
                        layer.alert("失败:" + result.Message, { icon: 5, shadeClose: true, title: "错误信息" }, function (index) { $('[name = "PalletId"]').focus(); layer.close(index); });
                    }
                },
                error: function (errorThrown) {
                    layer.alert(errorThrown, { icon: 2, title: '提示' });
                }
            })
        }
    });

    //空板入库
    $(document).on("click", "#btnEmptyBack", function () {
        var b = $('[name = "IsShou"]:checked').val();
        if (b == undefined) {
            layer.alert("请选择站台", { icon: 5, shadeClose: true, title: "错误信息" });
        } else if ($('[name = "PalletId"]').val() == "") {
            layer.alert("请扫描托盘号", { icon: 5, shadeClose: true, title: "错误信息" }, function (index) { $('[name = "PalletId"]').focus(); layer.close(index); });
        }
        else {
            layer.open({
                title: '空板回库',
                area: ["300px","250px"],
                type: 1,
                content: $('#PalletEmptyIn'),
                btn: ['提交', '关闭'],
                yes: function (index) {
                    if ($('[name = "Type"]').val() != '') {
                        layer.close(index);
                        $.ajax({
                            async: false,
                            url: "/" + "task" + "/" + "Task" + "/BulidEmptyContainerBack",
                            type: "post",
                            data: { station: $('[name = "IsShou"]:checked').val(), containerCode: $('[name = "PalletId"]').val(), type: $('[name = "Type"]').val() },
                            dataType: "json",
                            success: function (result) {
                                if (result.code == 200) {
                                    layer.msg("空托回库成功", { icon: 6, shade: 0.4, time: 1000 });
                                    $('[name = "PalletId"]').removeAttr("disabled");
                                    $('[name = "PalletId"]').removeClass("not");
                                    $('[name = "ContainerId"]').attr("disabled", "disabled");
                                    $('[name = "ContainerId"]').css("background-color", "#eee");
                                    $('[name = "PalletId"]').val("");
                                    $('[name = "PalletId"]').focus();
                                }
                                else {
                                    layer.alert("失败:" + result.msg, { icon: 5, shadeClose: true, title: "错误信息" }, function (index) { $('[name = "PalletId"]').focus(); layer.close(index); });
                                }
                            },
                            error: function (errorThrown) {
                                layer.alert(errorThrown, { icon: 2, title: '提示' });
                            }
                        })
                    } else {
                        layer.alert("请选择托盘类型", { icon: 5, shadeClose: true, title: "错误信息" });
                    }
                },
                btn2: function (index) {
                    layer.close(index);
                }
            });
        }
    });
    //仓库选择
    $(document).on("click", "#btnstation", function () {
        $('[name = "PalletId"]').val("");
        $('[name = "ContainerId"]').val("");
        $('[name = "Num"]').val("");
        $('[name = "MaterialCode"]').val("");
        $('[name = "SourceCode"]').val("");
        $('[name = "Batch"]').val("");
        $('[name = "PalletId"]').removeAttr("disabled");
        $('[name = "PalletId"]').removeClass("not");
        $('[name = "ContainerId"]').attr("disabled", "disabled");
        $('[name = "ContainerId"]').css("background-color", "#eee");
        layer.open({
            title: '仓库选择',
            //area: ["800px", "400px"],
            type: 1,
            content: $('#Tunnel'),
            btn: ['确认'],
            yes: function (index) {
                layer.close(index);
                $('[name = "PalletId"]').focus();
            }
        });
    });
    //选择仓库,根据仓库显示不同输入框
    $(document).on("click", ".d1", function () {
        if ($("#Juan").is(":checked")) {
            AddStation(0);
            $(".Supplier").hide();
            $(".Customer").show();
            $(".Typesetting").hide();
        }
        if ($("#Pian").is(":checked")) {
            AddStation(1);
            $(".Supplier").hide();
            $(".Customer").hide();
            $(".Typesetting").show();
        }
        if ($("#Tong").is(":checked")) {
            AddStation(2);
            $(".Supplier").show();
            $(".Customer").hide();
            $(".Typesetting").hide();
        }
    });
    function AddStation(data) {
        var Station
        if (data == 0) {
             Station = $("#StationJuan");
        }
        if (data == 1) {
             Station = $("#StationPian");
        }
        if (data == 2) {
             Station = $("#StationTong");
        }
        layer.open({
            title: '站台选择',
            type: 1,
            content: Station,
            btn: ['确认'],
            yes: function (index) {
                $('#btnstation').text($('[name = "IsShou"]:checked').parent().text());
                var a = $('#btnstation').text();
                $('[name = "ContainerId"]').attr("disabled", "disabled");
                $('[name = "ContainerId"]').css("background-color", "#eee");
                if (a.indexOf("暂存") != -1) {
                    $("#btnEmpty").hide();
                    $("#btnEmptyBack").hide();
                    $('[name = "PalletId"]').attr("disabled", "disabled");
                    $('[name = "PalletId"]').css("background-color", "#eee");
                    $('[name = "PalletId"]').val("");
                }
                else {
                    $('[name = "PalletId"]').removeAttr("disabled");
                    $('[name = "PalletId"]').removeClass("background-color");
                    $('[name = "PalletId"]').val("");
                    $('[name = "PalletId"]').focus();
                    $("#btnEmpty").show();
                    $("#btnEmptyBack").show();
                }
                layer.close(index);
            }
        });
    }

    //物料添加
    $(document).on("click", "#btnInventory", function () {
        AddInventory();
    });

    //托盘入库
    $(document).on("click", "#btnPalletIn", function () {
        document.getElementById("attribute").reset();
        var b = $('[name = "IsShou"]:checked').val();
        var Warehouse = $('[name = "HD"]:checked').val();
        var isBuffer = 0;
        if ($('[name = "PalletId"]').val() == "") {
            layer.alert("请扫描托盘号", { icon: 5, shadeClose: true, title: "错误信息" }, function (index) { $('[name = "PalletId"]').focus(); layer.close(index); });
        } else {
            if (Warehouse == "0") {
                $("#Export").show();
                $("#SelfUse").hide();
            }
            else if (Warehouse == "1") {
                $("#Export").hide();
                $("#SelfUse").show();
            }
            else if (Warehouse == "2") {
                $("#Export").hide();
                $("#SelfUse").hide();
            }
            layer.open({
                title: '特殊属性',
                area: ["300px", "250px"],
                type: 1,
                content: $('#Special'),
                btn: ['确认'],
                yes: function (index) {
                    if (b == undefined) {
                        layer.close(index);
                        layer.alert("请选择站台", { icon: 5, shadeClose: true, title: "错误信息" });
                    } else {
                        layer.close(index);
                        if (b == "ProductStationD01") {
                            layer.open({
                                title: '回库选择'
                                , content: '请选择回库地址'
                                , btn: ['立库', '暂存区']
                                , yes: function (index, layero) {
                                    isBuffer = 0;
                                    layer.close(index);
                                }
                                , btn2: function (index, layero) {
                                    isBuffer = 1;
                                    layer.close(index);
                                }, end: function () {
                                    $.ajax({
                                        async: false,
                                        url: "/" + "task" + "/" + "Task" + "/HandTaskIn",
                                        type: "post",
                                        data: {
                                            containerCode: $('[name = "PalletId"]').val(),
                                            station: b,
                                            isBuffer: isBuffer,
                                            isPack: $('[name = "IsPack"]').val(),
                                            isFold: $('[name = "IsFold"]').val(),
                                            status: $('[name = "Products"]').val(),
                                        },
                                        dataType: "json",
                                        success: function (result) {
                                            if (result.code == 200) {
                                                layer.msg("入库成功", { icon: 6, shade: 0.4, time: 1000 });
                                                $('[name = "MaterialNum"]').val("");
                                                $('[name = "Lot"]').val("");
                                                $('[name = "Num"]').val("");
                                                $('[name = "Customer"]').val("");
                                                $('[name = "Batch"]').val("");
                                                $('[name = "Supplier"]').val("");
                                                $('[name = "Typesetting"]').val("");
                                                $('[name = "ContainerId"]').val("");

                                                $('[name = "PalletId"]').removeAttr("disabled");
                                                $('[name = "PalletId"]').removeClass("not");
                                                $('[name = "ContainerId"]').attr("disabled", "disabled");
                                                $('[name = "ContainerId"]').css("background-color", "#eee");
                                                $('[name = "PalletId"]').val("");
                                                $('[name = "PalletId"]').focus();
                                                //mainList.mainList("#");
                                            }
                                            else {
                                                layer.alert("失败:" + result.msg, { icon: 5, shadeClose: true, title: "错误信息" }, function (index) { $('[name = "PalletId"]').focus(); layer.close(index); });
                                            }
                                        },
                                        error: function (XMLHttpRequest, textStatus, errorThrown) {
                                            layer.alert(errorThrown, { icon: 2, title: '提示' });
                                        }
                                    });
                                }
                            });
                        } else {
                            $.ajax({
                                async: false,
                                url: "/" + "task" + "/" + "Task" + "/HandTaskIn",
                                type: "post",
                                data: {
                                    containerCode: $('[name = "PalletId"]').val(),
                                    station: b,
                                    isBuffer: isBuffer,
                                    isPack: $('[name = "IsPack"]').val(),
                                    isFold: $('[name = "IsFold"]').val(),
                                    status: $('[name = "Products"]').val(),
                                },
                                dataType: "json",
                                success: function (result) {
                                    if (result.code == 200) {
                                        layer.msg("入库成功", { icon: 6, shade: 0.4, time: 1000 });
                                        $('[name = "MaterialNum"]').val("");
                                        $('[name = "Lot"]').val("");
                                        $('[name = "Num"]').val("");
                                        $('[name = "Customer"]').val("");
                                        $('[name = "Batch"]').val("");
                                        $('[name = "Supplier"]').val("");
                                        $('[name = "Typesetting"]').val("");
                                        $('[name = "ContainerId"]').val("");

                                        $('[name = "PalletId"]').removeAttr("disabled");
                                        $('[name = "PalletId"]').removeClass("background-color");
                                        $('[name = "ContainerId"]').attr("disabled", "disabled");
                                        $('[name = "ContainerId"]').css("background-color", "#eee");
                                        $('[name = "PalletId"]').val("");
                                        $('[name = "PalletId"]').focus();
                                        //mainList.mainList("#");
                                    }
                                    else {
                                        layer.alert("失败:" + result.msg, { icon: 5, shadeClose: true, title: "错误信息" }, function (index) { $('[name = "PalletId"]').focus(); layer.close(index); });
                                    }
                                },
                                error: function (XMLHttpRequest, textStatus, errorThrown) {
                                    layer.alert(errorThrown, { icon: 2, title: '提示' });
                                }
                            });
                        }
                    }
                }

            });

        }

    });


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

    //“物料编号”回车监听
    $('[name = "ContainerId"]').bind("keydown", function (e) {
        if (e.which == 13) {
            AddInventory();
            e.preventDefault(); //Skip default behavior of the enter key
        }
    });
    //“托盘编号”回车监听
    $('[name = "PalletId"]').bind("keydown", function (e) {
        if (e.which == 13) {
            ContrastPallet();
            e.preventDefault(); //Skip default behavior of the enter key
        }
    });

    //手动添加物料信息
    function AddInventory() {
        var b = $('[name = "IsShou"]:checked').val();
        var C = $('[name = "HD"]:checked').val();
        if (b == undefined) {
            layer.alert("请选择站台", { icon: 5, shadeClose: true, title: "错误信息" });
        } else {
            var str = $('[name = "ContainerId"]').val();
            var strs = str.split('%');
            if (C == 0 && strs.length == 6) {
                $('[name = "MaterialNum"]').val(strs[0]);
                $('[name = "Lot"]').val(strs[1]);
                $('[name = "Num"]').val(strs[3]);
                $('[name = "Customer"]').val(strs[4]);
                $('[name = "Batch"]').val(strs[5]);
                $('[name = "ContainerId"]').val("");
            }
            else if (C == 1 && strs.length == 6) {
                $('[name = "MaterialNum"]').val(strs[0]);
                $('[name = "Lot"]').val(strs[1]);
                $('[name = "Num"]').val(strs[3]);
                $('[name = "Typesetting"]').val(strs[4]);
                $('[name = "Batch"]').val(strs[5]);
                $('[name = "ContainerId"]').val("");

            } else if (C == 2 && strs.length == 5) {
                $('[name = "MaterialNum"]').val(strs[0]);
                $('[name = "Supplier"]').val(strs[1]);
                $('[name = "Batch"]').val(strs[2]);
                $('[name = "Lot"]').val(strs[3]);
                $('[name = "Num"]').val(strs[4]);
            } else {
                layer.alert("失败:扫描错误,请重新扫描" ,{ icon: 5, shadeClose: true, title: "错误信息" }, function (index) { $('[name = "PalletId"]').focus(); layer.close(index);});
            }

            $.ajax({
                async: false,
                url: "/" + "task" + "/" + "Task" + "/AddInventory",
                type: "post",
                data: {
                    containerCode: $('[name = "PalletId"]').val(),
                    station: b ,
                    material: $('[name = "MaterialNum"]').val(),
                    Lot: $('[name = "Lot"]').val(),
                    num: $('[name = "Num"]').val(),
                    Batch: $('[name = "Batch"]').val(),
                    Customer: $('[name = "Customer"]').val(),
                    Typesetting: $('[name = "Typesetting"]').val(),
                    SupplierL: $('[name = "SupplierL"]').val(),
                },
                dataType: "json",
                success: function (result) {
                    if (result.code == 200) {
                        $('[name = "ContainerId"]').val("");
                        layer.msg("入库成功", { icon: 6, shade: 0.4, time: 1000 });
                    }
                    else {
                        $('[name = "MaterialNum"]').val("");
                        $('[name = "Lot"]').val("");
                        $('[name = "Num"]').val("");
                        $('[name = "Customer"]').val("");
                        $('[name = "Batch"]').val("");
                        $('[name = "Supplier"]').val("");
                        $('[name = "Typesetting"]').val("");
                        $('[name = "ContainerId"]').val("");
                        layer.alert("失败:" + result.msg, { icon: 5, shadeClose: true, title: "错误信息" }, function (index) { $('[name = "PalletId"]').focus(); layer.close(index); });
                    }
                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    layer.alert(errorThrown, { icon: 2, title: '提示' });
                }
            });
        }
    }
    //根据托盘号对比托盘是否正确
    function ContrastPallet() {
        var b = $('[name = "IsShou"]:checked').val();
        if (b == undefined) {
            layer.alert("请选择站台", { icon: 5, shadeClose: true, title: "错误信息" });
        } else {
            var str = $('[name = "PalletId"]').val();
          
            $.ajax({
                async: false,
                url: "/" + "task" + "/" + "Task" + "/PalletIsNo",
                type: "post",
                data: { Pallet: str, station: b},
                dataType: "json",
                success: function (result) {
                    if (result.code == 200) {
                        layer.msg("托盘正确", { icon: 6, shade: 0.4, time: 1000 });
                        $('[name = "ContainerId"]').removeAttr("disabled");
                        $('[name = "ContainerId"]').css("background-color", "white");
                        $('[name = "PalletId"]').attr("disabled", "disabled");
                        $('[name = "PalletId"]').css("background-color", "#eee");
                        $('[name = "ContainerId"]').focus();
                    }
                    else {
                        layer.alert(result.data, { icon: 2, title: '错误' }, function (index) { $('[name = "PalletId"]').focus(); layer.close(index); });
                    }
                 
                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    layer.alert(errorThrown, { icon: 2, title: '提示' });
                }
            });
            //mainList.mainList(b);
        }
    }

    function IsDisplay(Ware,Effect) {
        if (Ware == "0") {
            $("#Export").show();
            $("#SelfUse").hide();
        }
        else if (Ware == "1") {
            $("#Export").hide();
            $("#SelfUse").show();
        }
        else if (Ware == "2") {
            $("#Export").hide();
            $("#SelfUse").hide();
        }
    }
});