locationstatus.html 24.5 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 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592
<!DOCTYPE HTML>
<html lang="zh" xmlns:th="http://www.thymeleaf.org"
      xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="gray-bg">
<style type="text/css">
    #img_list li{
        font-size: 10px;
        /*width: 50px;*/
        text-align: left;
        margin: 5px 20px 5px 5px;
    }
    #img_list li img{
        height: 35px;
        width: 35px;
    }
    #info_list{
        width: 100%;
        display:inline-block;
    }
    #info_list li{
        margin:8px 3px 0 5px;
    }
    #info_list li span{
        font-size: 12px;
        display: inline-block;
        /*width: 65px;*/
        text-align: center;
    }
    .grid{
        display: inline-block;
        width: 50px;
        height: 50px;
        /*margin: 12px 6px;*/
        margin-bottom: 6px;
        background-size:cover;
        background-image: url("../img/icon/空柜空闲.png");
    }
    #location span{
        display: inline-block;
        text-align: right;
        width: 50px;
        margin-right: 10px;
    }
</style>
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 select-info">
            <form id="container-form">
                <div class="select-list">
                    <ul id="select_info">
                        <li>
                            <select id="locationType" name="locationType" style="width: 100px">
                                <option value="A" selected>立库库位</option>
                                <option value="Q">钱柜库位</option>
                                <option value="PK">平面库位</option>
                            </select>
                        </li>
                        <li>

                            <select id="editable-num" name="num" style="width: 70px">
                            </select>
                        </li>
                        <li>
                            <select id="editable-select" name="col" style="width: 70px">
                                <option value="row" selected></option>
                                <option value="line"></option>
                                <option value="layer"></option>
                            </select>
                        </li>
                        <li>货主编码:
                            <input type="text" name="receiptCompanyCode" id="receiptCompanyCode">
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="Search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>
        <div class="col-sm-12 select-info">
            <form id="receiptHeader-form">
                <div class="select-list">
                    <ul id="img_list" style="">
                        <li>
                            空柜空闲:<img src="../img/icon/空柜空闲.png">
                        </li>
                        <li>
                            空盘空闲:<img src="../img/icon/空盘空闲.png">
                        </li>
                        <li>
                            半盘空闲:<img src="../img/icon/半盘空闲.png">
                        </li>
                        <li>
                            整盘空闲:<img src="../img/icon/整盘空闲.png">
                        </li>
                        <li>
                            空柜锁定:<img src="../img/icon/空柜锁定.png">
                        </li>
                        <li>
                            空盘锁定:<img src="../img/icon/空盘锁定.png">
                        </li>
                        <li>
                            半盘锁定:<img src="../img/icon/半盘锁定.png">
                        </li>
                        <li>
                            整盘锁定:<img src="../img/icon/整盘锁定.png">
                        </li>
                        <li>
                            空柜禁用:<img src="../img/icon/空柜禁用.png">
                        </li>
                        <li>
                            空盘禁用:<img src="../img/icon/空盘禁用.png">
                        </li>
                        <li>
                            半盘禁用:<img src="../img/icon/半盘禁用.png">
                        </li>
                        <li>
                            整盘禁用:<img src="../img/icon/整盘禁用.png">
                        </li>
                    </ul><br><br>
                    <ul id="info_list">
                        <li><span>库位:</span><input type="text" id="code" disabled/></li>
                        <li><span>容器编码:</span><input type="text" id="containerCode" disabled/></li>
                        <li><span>物料信息:<select id="material" style="width: auto"><option></option></select></span></li>
                        <li>&nbsp;&nbsp;&nbsp;&nbsp;</li>
                        <li>
                            <a class="btn btn-success btn-rounded btn-sm" onclick="checkLocationCode()" shiro:hasPermission="inventory:inventory:seeOut"><i class="fa fa-eye"></i>&nbsp;出库查看</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>
        <div class="col-sm-12 select-info">
            <!--style="width: 100%;overflow-x: scroll;white-space:nowrap"-->
            <div id="borderCol" style="overflow-y: scroll;white-space:nowrap">
                <div class="location" id="location">
                    <!--<div class="grid"></div>-->
                </div>
            </div>
        </div>
    </div>
</div>
<div th:include="include :: footer"></div>
<script th:inline="javascript">
    var prefix = ctx + "config/location";
    var grid_row;
    var grid_line;
    var grid_layer;
    var list_info;
    var grid_rest="../img/icon/空柜空闲.png";
    var grid_empty="../img/icon/空盘空闲.png";
    var grid_half="../img/icon/半盘空闲.png";
    var grid_all="../img/icon/整盘空闲.png";
    var grid_emp_waing="../img/icon/空柜禁用.png";
    var grid_empty_waring="../img/icon/空盘禁用.png";
    var grid_half_waring="../img/icon/半盘禁用.png";
    var grid_all_waring="../img/icon/整盘禁用.png";
    var grid_emp_lock="../img/icon/空柜锁定.png";
    var grid_empty_lock="../img/icon/空盘锁定.png";
    var grid_half_lock="../img/icon/半盘锁定.png";
    var grid_all_lock="../img/icon/整盘锁定.png";
    var rel_empty="../img/icon/空.png";
    var grid_num_1=0;
    var grid_num_2=0;
    var grid_num_3=0;
    var grid_num_4=0;
    var grid_num_5=0;
    var grid_num_6=0;
    var grid_num_7=0;
    var grid_num_8=0;
    var grid_num_9=0;
    var grid_num_10=0;
    var grid_num_11=0;
    var grid_num_12=0;
    $(function() {
        resetAjax("A");

        //库位类型和行列层选择
        $("#editable-select").change(function () {
            let num=$("#editable-select").val();
            $("#editable-num").children().remove();
            if (num === "row") {
                for (let i = 1; i <= grid_row; i++) {
                    $("#editable-num").append("<option value='"+i+"'>"+i+"</option>")
                }
            }
            else if (num === "line") {
                for (let i = 1; i <= grid_line; i++) {
                    $("#editable-num").append("<option value='"+i+"'>"+i+"</option>")
                }
            }
            else if (num === "layer") {
                for (let i = 1; i <= grid_layer; i++) {
                    $("#editable-num").append("<option value='"+i+"'>"+i+"</option>")
                }
            }
        });

        $("#locationType").change(function () {
           let type=$("#locationType").val();
            resetAjax(type);
        });

        //页面初始化请求
        function resetAjax(type){
            $.ajax({
                url:prefix+"/getAllLocation",
                type:"post",
                data:{
                    type:type
                },
                success:function (res) {
                    grid_row=res.data.maxRow;
                    grid_line=res.data.maxLine;
                    grid_layer=res.data.maxLayer;
                    //初始格子
                    $("#location").children().remove();
                    for (let i = 1; i <= grid_layer; i++) {
                        // var index=i+1;<span style='margin-top:30px'>第"+ index +"行</span>
                        $(".location").append("<br>");
                        for (let j = 1; j <= grid_line; j++) {
                            $(".location").append("<img data-i='1' data-j="+j+" data-k="+ i +" class='grid' onmouseover='lays(this)' onmouseout='Mclose(this)' onclick='gridMsg(this)'>");
                        }
                    }
                    let num=$("#editable-select").val();
                    $("#editable-num").children().remove();
                    if (num === "row") {
                        for (let i = 1; i <= grid_row; i++) {
                            $("#editable-num").append("<option value='"+i+"'>"+i+"</option>")
                        }
                    }
                    else if (num === "line") {
                        for (let i = 1; i <= grid_line; i++) {
                            $("#editable-num").append("<option value='"+i+"'>"+i+"</option>")
                        }
                    }
                    else if (num === "layer") {
                        for (let i = 1; i <= grid_layer; i++) {
                            $("#editable-num").append("<option value='"+i+"'>"+i+"</option>")
                        }
                    }
                    changeMargin();
                    Search();
                }
            });
        }


        //监听浏览器宽度的改变
        window.onresize = function(){
            changeMargin();
            border()
        };
        changeMargin();
        border()
    });

    //边框高度
    function border() {
        let box_height=$("#borderCol").offset().top;
        let window_height=$(window).height()-20;
        $("#borderCol").css({"height":window_height-box_height});
    }

    //格子宽度
    function changeMargin() {
        let box_width=document.getElementById("location").offsetWidth;
        box_width=box_width-80;
        let num=$("#editable-select").val();
        let grid_width;
        if (num === "layer" || num === "row") {
            grid_width=box_width/grid_line;
        }
        else if (num === "line") {
            grid_width=box_width/grid_row;
        }
        if (grid_width >= 50) {
            $(".grid").css({"width":"50px","height":"50px"});
        }
        else if (grid_width <= 20) {
            $(".grid").css({"width":"20px","height":"20px"});
        }
        else {
            $(".grid").css({"width":grid_width,"height":grid_width});
        }
    }

    //tips信息
    function lays(x) {
        let $j=$(x);
        let row=$j.attr("data-i");
        let line=$j.attr("data-j");
        let layers=$j.attr("data-k");
        row=parseInt(row);
        line=parseInt(line);
        layers=parseInt(layers);
        if (list_info) {
            for (let i = 0; i < list_info.length; i++) {
                if (list_info[i].iRow === row && list_info[i].iColumn === line && list_info[i].iLayer === layers) {
                    let str_info='';
                    let container_code='';
                    if (list_info[i].containerCode) {
                        container_code="<br>容器编码:"+ list_info[i].containerCode+"";
                        if (list_info[i].materialName) {
                            for (let j = 0; j < list_info[i].materialName.length; j++) {
                                let list_batch=list_info[i].batch[j]===null?"无":list_info[i].batch[j]===""?"无":list_info[i].batch[j];
                                str_info=str_info + "<br>批次:"+ list_batch +",物料名称:"+ list_info[i].materialName[j] +",物料编码:"+ list_info[i].materialCode[j] +
                                    ",数量:"+ list_info[i].qty[j] +""
                            }
                        }
                    }
                    let code=list_info[i].code===null?"无":list_info[i].code;
                    layer.tips("第"+row+"行,第"+line+"列,第"+ layers +"层<br>库位:"+ code + container_code + str_info + ""
                        ,$j,{tips:[1,"rgb(28,132,198)"],time:0,area:'auto',maxWidth: '1000'});
                }
            }
        }else {return ""}
    }

    //关闭tips
    function Mclose(x) {
        let index = layer.tips();
        layer.close(index);
    }

    //搜索平面库位
    function Search() {
        let index=$("#editable-select").val();
        let num=$("#editable-num").val();
        let locationType=$("#locationType").val();
        $("#code").val("");
        $("#containerCode").val("");
        $("#material").children().remove();
        $("#material").append("<option>无</option>");
        let data;
        if (index === "row") {
            data={type:locationType, row:num};
            $("#location").children().remove();
            for (let i = 1; i <= grid_layer; i++) {
                $(".location").append("<br><span>第"+ i+"层</span>");
                for (let j = 1; j <= grid_line; j++) {
                    $(".location").append("<img data-i="+num+" data-j="+j+" data-k="+i+" class='grid' onmouseover='lays(this)' onmouseout='Mclose(this)' onclick='gridMsg(this)'>");
                }
            }
            changeMargin();
            ajaxGrid(index,data);
        }
        else if (index === "line") {
            data={type:locationType, line:num};
            $("#location").children().remove();
            for (let k = 1; k <= grid_layer; k++) {
                $(".location").append("<br><span>第"+ k+"层</span>");
                for (let l = 1; l <= grid_row; l++) {
                    $(".location").append("<img data-i="+l+" data-j="+num+" data-k="+k+" class='grid' onmouseover='lays(this)' onmouseout='Mclose(this)' onclick='gridMsg(this)'>");
                }
            }
            changeMargin();
            ajaxGrid(index,data);
        }
        else if (index === "layer") {
            data={type:locationType, layer:num};
            $("#location").children().remove();
            for (let m = 1; m <= grid_row; m++) {
                $(".location").append("<br><span>第"+ m+"行</span>");
                for (let n = 1; n <= grid_line; n++) {
                    $(".location").append("<img data-i="+m+" data-j="+n+" data-k="+num+" class='grid' onmouseover='lays(this)' onmouseout='Mclose(this)' onclick='gridMsg(this)'>");
                }
            }
            changeMargin();
            ajaxGrid(index,data);
        }
    }
    
    //库位信息请求和状态显示
    function ajaxGrid(x, info) {
        let load=layer.msg('加载中', {icon: 16,shade: 0.4,time: false});
        $.ajax({
            url:prefix+"/getLocationInfo",
            type:"post",
            data:info,
            success:function (res) {
                if (res.code===200||res.data||res.msg==="成功") {
                    grid_num_1 = 0;
                    grid_num_2 = 0;
                    grid_num_3 = 0;
                    grid_num_4 = 0;
                    grid_num_5 = 0;
                    grid_num_6 = 0;
                    grid_num_7 = 0;
                    grid_num_8 = 0;
                    grid_num_9 = 0;
                    grid_num_10 = 0;
                    grid_num_11 = 0;
                    grid_num_12 = 0;
                    if (x === "row") {
                        for (let i = 0; i < res.data.length; i++) {
                            let index=res.data[i].iColumn+((res.data[i].iLayer-1)*grid_line);
                            index=index-1;
                            resShow(res,index,i);
                        }
                        clearLocation(grid_line,grid_layer);
                        layer.close(load);
                    }
                    else if (x === "line") {
                        for (let i = 0; i < res.data.length; i++) {
                            let index=res.data[i].iRow+((res.data[i].iLayer-1)*grid_row);
                            index=index-1;
                            resShow(res,index,i);
                        }
                        clearLocation(grid_row,grid_layer);
                        layer.close(load);
                    }
                    else if (x === "layer") {
                        for (let i = 0; i < res.data.length; i++) {
                            let index=res.data[i].iColumn+((res.data[i].iRow-1)*grid_line);
                            index=index-1;
                            resShow(res,index,i);
                        }
                        clearLocation(grid_line,grid_row);
                        layer.close(load);
                    }
                }
                else if (res.msg !== "成功"||res.code!==200) {
                    layer.close(load);
                    layer.open({
                        title: '错误',
                        content: res.msg
                    });
                }
                list_info=res.data;
            },
            error:function (req, msg) {
                console.log(msg);
            }
        })
    }

    //库位请求的结果显示
    function resShow(res, index ,i) {
                if (res.data[i].deleted === false) {
                    console.log(res.data[i].userDef3);
                    if (res.data[i].userDef3 === "1") {
                        $(".grid").eq(index).attr({"src": grid_rest, "isTrue": 1});
                        grid_num_1 = grid_num_1 + 1;
                    } else if (res.data[i].userDef3 === "2") {
                        $(".grid").eq(index).attr({"src": grid_empty, "isTrue": 1});
                        grid_num_2 = grid_num_2 + 1;
                    } else if (res.data[i].userDef3 === "3") {
                        $(".grid").eq(index).attr({"src": grid_half, "isTrue": 1});
                        grid_num_3 = grid_num_3 + 1;
                    } else if (res.data[i].userDef3 === "4") {
                        $(".grid").eq(index).attr({"src": grid_all, "isTrue": 1});
                        grid_num_4 = grid_num_4 + 1;
                    } else if (res.data[i].userDef3 === "5") {
                        $(".grid").eq(index).attr({"src": grid_emp_lock, "isTrue": 1});
                        grid_num_5 = grid_num_5 + 1;
                    } else if (res.data[i].userDef3 === "6") {
                        $(".grid").eq(index).attr({"src": grid_empty_lock, "isTrue": 1});
                        grid_num_6 = grid_num_6 + 1;
                    } else if (res.data[i].userDef3 === "7") {
                        $(".grid").eq(index).attr({"src": grid_half_lock, "isTrue": 1});
                        grid_num_7 = grid_num_7 + 1;
                    } else if (res.data[i].userDef3 === "8") {
                        $(".grid").eq(index).attr({"src": grid_all_lock, "isTrue": 1});
                        grid_num_8 = grid_num_8 + 1;
                    } else if (res.data[i].userDef3 === "9") {
                        $(".grid").eq(index).attr({"src": grid_emp_waing, "isTrue": 1});
                        grid_num_9 = grid_num_9 + 1;
                    } else if (res.data[i].userDef3 === "10") {
                        $(".grid").eq(index).attr({"src": grid_empty_waring, "isTrue": 1});
                        grid_num_10 = grid_num_10 + 1;
                    } else if (res.data[i].userDef3 === "11") {
                        $(".grid").eq(index).attr({"src": grid_half_waring, "isTrue": 1});
                        grid_num_11 = grid_num_11 + 1;
                    } else if (res.data[i].userDef3 === "12") {
                        $(".grid").eq(index).attr({"src": grid_all_waring, "isTrue": 1});
                        grid_num_12 = grid_num_12 + 1;
                    }
                }
                else if (res.data[i].deleted === true) {
                    $(".grid").eq(i).attr({"src": rel_empty, "onmouseover": "", "onclick": ""});
                }
    }

    //清除将数据库中没有的库位
    function clearLocation(x, y) {
        for (let j = 0; j < x * y; j++) {
            let sta=$(".grid").eq(j).attr("isTrue");
            if (sta !== "1") {
                $(".grid").eq(j).attr({"src": rel_empty,"onmouseover": "","onclick": ""});
            }
        }
    }

    //点击显示当前库位信息
    function gridMsg(msg) {
        let $j=$(msg);
        let row=$j.attr("data-i");
        let line=$j.attr("data-j");
        let layers=$j.attr("data-k");
        row=parseInt(row);
        line=parseInt(line);
        layers=parseInt(layers);
        if (list_info) {//缓存查询
            for (let i = 0; i < list_info.length; i++) {
                if (list_info[i].iRow === row && list_info[i].iColumn === line && list_info[i].iLayer === layers) {
                    if (list_info[i].materialName) {
                        $("#material").children().remove();
                        for (let j = 0; j < list_info[i].materialName.length; j++) {
                            let list_batch=list_info[i].batch[j]===null?"无":list_info[i].batch[j]===""?"无":list_info[i].batch[j];
                            let str_info="批次:"+ list_batch +"/ 物料名称:"+ list_info[i].materialName[j] +"/ 物料编码:"+ list_info[i].materialCode[j] +
                                "/ 数量:"+ list_info[i].qty[j] +"";
                            $("#material").append("<option>"+ str_info +"</option>");
                        }
                    }
                    else {
                        $("#material").children().remove();
                        $("#material").append("<option>无</option>");
                    }
                    $("#code").val(list_info[i].code);
                    $("#containerCode").val(list_info[i].containerCode===""?"无":list_info[i].containerCode);
                }
            }
        }else {return ""}
        //接口查询
    //     $.ajax({
    //         url:prefix+"/getLocationInfo",
    //         type:"post",
    //         data:{
    //             type:"L",
    //             row:row,
    //             line:line,
    //             layer:layers,
    //             grid:1
    //         },
    //         success:function (res) {
    //             $("#row_info").val(res.data[0].row);
    //             $("#line_info").val(res.data[0].line);
    //             $("#layer_info").val(res.data[0].layer);
    //             $("#id").val(res.data[0].id);
    //             $("#code").val(res.data[0].code);
    //             $("#warehouseId").val(res.data[0].warehouseId);
    //             $("#warehouseCode").val(res.data[0].warehouseCode);
    //             $("#rowIndex").val(res.data[0].rowIndex);
    //             $("#roadway").val(res.data[0].roadway);
    //             $("#type").val(res.data[0].type);
    //             $("#containerId").val(res.data[0].containerId);
    //             $("#containerCode").val(res.data[0].containerCode);
    //             $("#zoneId").val(res.data[0].zoneId);
    //             $("#zoneCode").val(res.data[0].zoneCode);
    //             $("#status").val(res.data[0].userDef3);
    //             $("#lastCycleCountDate").val(res.data[0].lastCycleCountDate);
    //             $("#created").val(res.data[0].created);
    //             $("#createdBy").val(res.data[0].createdBy);
    //             $("#lastUpdated").val(res.data[0].lastUpdated);
    //             $("#lastUpdatedBy").val(res.data[0].lastUpdatedBy);
    //             $("#enable").val(res.data[0].enable);
    //         }
    //     });
    }

    //出库查看
    function checkLocationCode() {
        let data = $("#code").val();
        if (data) {
            $.modal.loading("正在处理中,请稍后...");
            $.ajax({
                url:prefix + "/checkLocationCode",
                type:'post',
                datatype:'json',
                data:{
                    locationCode:data
                },
                success: function (result) {
                    if (result.code == web_status.SUCCESS) {
                        $.modal.msgSuccess(result.msg);
                    } else {
                        $.modal.alertError(result.msg)
                    }
                    $.modal.closeLoading()
                }
            })
        }
        else{
            layer.tips('请选择库位!',$("#code"),{tips:[1,"rgb(28,132,198)"],time:3000,area:'auto',maxWidth: '1000'})
        }
    }
</script>
</body>
</html>