NouYouLocationMonitor.js 17.4 KB
layui.config({
    base: "/js/"
}).use(['layer', 'jquery', 'form', 'table', 'Universal'], function () {
    var layer = layui.layer,
        $ = layui.jquery,
        table = layui.table,
        Universal = layui.Universal,
        form = layui.form;

    //初始加载
    $(document).ready(function () {
        form.render();
        Init();
        //setInterval(Speak, 10000);
    });

    function Init() {
        var xop = 450;
        var add = 100;
        xop += add;
        $('#canvas_op').drawText({
            layer: true,
            fillStyle: '#000',
            strokeWidth: 2,
            x: xop, y: 25,
            fontSize: '20pt',
            fontFamily: 'Verdana, sans-serif',
            text: '空仓位:'
        })
        xop += add - 20;
        $('#canvas_op').drawRect({
            layer: true,
            strokeStyle: '#000',
            strokeWidth: 1,
            x: xop, y: 25,
            width: 50,
            height: 50
        });
        $('#canvas_op').drawText({
            layer: true,
            fillStyle: "#000",
            x: xop, y: 25,
            fontSize: 30,
            text: "空"
        });
        xop += add + 20;
        $('#canvas_op').drawText({
            layer: true,
            fillStyle: '#4A4AFF',
            strokeWidth: 2,
            x: xop, y: 25,
            fontSize: '20pt',
            fontFamily: 'Verdana, sans-serif',
            text: '空托盘:'
        })
        xop += add - 20;
        $('#canvas_op').drawRect({
            layer: true,
            fillStyle: '#4A4AFF',
            x: xop, y: 25,
            width: 50,
            height: 50
        });
        xop += add + 20;
        $('#canvas_op').drawText({
            layer: true,
            fillStyle: '#00EC00',
            strokeWidth: 2,
            x: xop, y: 25,
            fontSize: '20pt',
            fontFamily: 'Verdana, sans-serif',
            text: '有货托盘:'
        })
        xop += add - 10;
        $('#canvas_op').drawRect({
            layer: true,
            fillStyle: '#00EC00',
            x: xop, y: 25,
            width: 50,
            height: 50
        });
        xop += add + 20;
        $('#canvas_op').drawText({
            layer: true,
            fillStyle: '#7E354D',
            strokeWidth: 2,
            x: xop, y: 25,
            fontSize: '20pt',
            fontFamily: 'Verdana, sans-serif',
            text: '任务中:'
        })
        xop += add - 20;
        $('#canvas_op').drawRect({
            layer: true,
            fillStyle: '#7E354D',
            x: xop, y: 25,
            width: 50,
            height: 50
        });
    }

    function GetRoadWay(stk, line) {
        $.ajax({
            async: false,
            url: "/monitor/NouYouLocationMonitor/GetLocData",
            type: "post",
            data: { roadway: stk, line: line },
            dataType: "json",
            success: function (data) {
                $('#canvas_num').drawText({
                    layer: true,
                    fillStyle: '#000',
                    strokeWidth: 2,
                    x: 900, y: 25,
                    fontSize: '20pt',
                    fontFamily: 'Verdana, sans-serif',
                    text: data.data
                })
            }
        });

        var x = 300;
        var y = 10;
        var width = 40;
        var height = 40;

        if (stk == 4) {
            x = 300
        }

        $.ajax({
            async: false,
            url: "/monitor/NouYouLocationMonitor/GetRoadway",
            type: "post",
            data: { roadway: stk, line: line },
            dataType: "json",
            success: function (data) {
                var arr = data.data;
                var ymax = (arr[0].Layer + 1) * height;
                arr.forEach(function (e) {
                    if (e.Row == 1) {
                        $('#canvas_location').drawText({
                            layer: true,
                            fillStyle: "#000",
                            x: x, y: ymax - (y + height * e.Layer),
                            fontSize: 20,
                            text: e.Layer
                        });
                    }

                    if (e.Layer == 1) {
                        $('#canvas_location').drawText({
                            layer: true,
                            fillStyle: "#000",
                            x: x + width * e.Row, y: ymax,
                            fontSize: 20,
                            text: e.Row
                        });
                    }

                    if (e.Status != "empty") {
                        var color = '#ffffff'
                        if (e.Status == "some") {
                            color = '#00EC00'
                        } else if (e.Status == "emptycontainer") {
                            color = '#4A4AFF'
                        } else if (e.Status == "lock") {
                            color = '#7E354D'
                        }
                        $('#canvas_location').drawRect({
                            layer: true,
                            strokeStyle: '#000',
                            strokeWidth: 1,
                            x: x + width * e.Row, y: ymax - (y + height * e.Layer),
                            width: width,
                            height: height
                        });
                        $('#canvas_location').drawRect({
                            layer: true,
                            name: e.Code,
                            fillStyle: color,
                            x: x + width * e.Row, y: ymax - (y + height * e.Layer),
                            width: width / 2,
                            height: height / 2,
                            click: function (res) {
                                layer.open({
                                    title: '物料信息',
                                    type: 1,
                                    skin: 'layui-layer-rim',
                                    area: ['1000px', '480px'],
                                    content: $('#inv'),
                                    btnAlign: 'c',
                                    maxmin: true,
                                    minStack: false, //最小化不堆叠在左下角
                                    id: 'page1', //定义 ID,防止重复弹出
                                    min: function (layero, index) {
                                        layer.msg('阻止了默认的最小化');
                                        layer.style(index, { top: 'auto', bottom: 0 });
                                        return false;
                                    }, success: function (layero, index) {
                                        table.reload('mainList', {
                                            url: "/monitor/NouYouLocationMonitor/GetInve"
                                            , where: { code: res.name, type: e.Type, roadway: stk }
                                            , height: 400
                                            , method: "post"
                                            , page: true
                                            , text: { none: "无数据" }
                                        });
                                    },
                                    //btn: ['库存出库', '关闭'],
                                    //yes: function (index) {
                                    //    var checkStatus = table.checkStatus('mainList');
                                    //    console.log(checkStatus);
                                    //    var count = checkStatus.data.length;//选中的行数
                                    //    var data1 = checkStatus.data;
                                    //    if (count < 1) {
                                    //        layer.alert("请至少选择一条数据", { icon: 5, shade: 0.4, time: 1000 });
                                    //        return;
                                    //    }
                                    //    $("#selectLoad").empty();
                                    //    var list;
                                    //    $.ajax({
                                    //        async: true,
                                    //        type: "post",
                                    //        url: "/receipt/ReceiptHeader/LoadStation",
                                    //        data: { list: data1 },
                                    //        dataType: "json",
                                    //        success: function (result) {
                                    //            if (result.code == 200) {
                                    //                list = result.data;
                                    //                var html;
                                    //                var IsExistence = 0;
                                    //                for (var i = 0; i < list.length; i++) {
                                    //                    var a = list[i].Code;
                                    //                    if (a.indexOf("BufferStationD0") == 0 && IsExistence == 0) {
                                    //                        IsExistence = 1;
                                    //                        html += "<option class='select_Station' value='" + list[i].Code + "'>" + list[i].Name + "</option>";
                                    //                    }
                                    //                    else if (a.indexOf("BufferStationD0") == 0 && IsExistence == 1) {
                                    //                        continue;
                                    //                    } else if (a == "ProductStationC01" || a == "ProductStationC04" || a == "ProductStationC05" || a == "ProductStationC08" || a == "ExitStationD01") {
                                    //                        continue;
                                    //                    } else if (a == "ExitStationY01") {
                                    //                        html += "<option class='select_Station' value='" + list[i].Code + "'>排版房</option>";
                                    //                        continue;
                                    //                    }
                                    //                    else {
                                    //                        html += "<option class='select_Station' value='" + list[i].Code + "'>" + list[i].Name + "</option>";
                                    //                    }
                                    //                }
                                    //                $("#selectLoad").append(html);
                                    //                layer.open({
                                    //                    type: 1,
                                    //                    //  skin: 'layui-layer-molv',
                                    //                    btnAlign: 'c',
                                    //                    moveType: 1, //拖拽模式,0或者1
                                    //                    title: "选择站台并出库", //不显示标题
                                    //                    area: ['600px', '400px'], //宽高
                                    //                    content: $('#tanchuang'), //捕获的元素
                                    //                    scrollbar: true,
                                    //                    btn: ['库存出库', '关闭'],
                                    //                    yes: function (index_1, layero) {
                                    //                        $.ajax({
                                    //                            url: "/inventory/inventory/GoodsOut",
                                    //                            type: "POST",
                                    //                            data: { Table_entitys: data1, Station: $("#selectLoad").val() },
                                    //                            dataType: "json",
                                    //                            success: function (result) {
                                    //                                if (result.Code == 200) {
                                    //                                    layer.msg("出库任务创建成功!", { icon: 6, shade: 0.4, time: 1000 });
                                    //                                    layer.close(index_1);
                                    //                                    mainList.mainList();
                                    //                                } else {
                                    //                                    layer.alert(result.Message, { icon: 5, shadeClose: true, title: "错误信息" });
                                    //                                }
                                    //                            },
                                    //                            error: function (XMLHttpRequest, textStatus, errorThrown) {
                                    //                                layer.alert(errorThrown, { icon: 2, title: '提示' });
                                    //                            }
                                    //                        });
                                    //                    },
                                    //                    cancel: function (index_1) {
                                    //                        layer.close(index_1);
                                    //                    }
                                    //                });
                                    //            } else {
                                    //                layer.alert("请选择相同仓库类型的库存出库", { icon: 5, shadeClose: true, title: "错误信息" });
                                    //            }
                                    //        },
                                    //        error: function (XMLHttpRequest, textStatus, errorThrown) {
                                    //            layer.alert(errorThrown, { icon: 2, title: '提示' });
                                    //        }
                                    //    });
                                    //    //最后关闭弹出层
                                    //    layer.close(index);
                                    //},
                                    //cancel: function () {
                                    //    //右上角关闭回调
                                    //}
                                });
                            }
                        });
                    }
                    else {
                        $('#canvas_location').drawRect({
                            layer: true,
                            strokeStyle: '#000',
                            strokeWidth: 1,
                            x: x + width * e.Row, y: ymax - (y + height * e.Layer),
                            width: width,
                            height: height
                        });
                        $('#canvas_location').drawText({
                            layer: true,
                            fillStyle: "#000",
                            x: x + width * e.Row, y: ymax - (y + height * e.Layer),
                            fontSize: 20,
                            text: "空"
                        });
                    }
                });
            }
        });
    }
    //根据巷道获取列
    form.on('select(roadway)', function (data) {
        //获取当前选中下拉项的 value值
        var value = data.value;
        $.ajax({
            async: false,
            url: "/monitor/NouYouLocationMonitor/GetLine",
            type: "post",
            data: { roadway: value },
            dataType: "json",
            success: function (res) {
                arr = res.data;
                var str;
                arr.forEach(function (e) {
                    var ELine;
                    if (e.Key.Line == 1) {
                        ELine = 'A';
                    } else if (e.Key.Line == 2) {
                        ELine = 'B';
                    } else if (e.Key.Line == 3) {
                        ELine = 'C';
                    }
                    else if (e.Key.Line == 4) {
                        ELine = 'D';
                    }
                    str += "<option value=\"" + e.Key.Line + "\">" + ELine + "</option> ";
                });
                $("#line").html(str);

                var Lab = "立库侧面展示图";
                var S;
                if (value == 1) {
                    S = "铜箔";
                } else if (value == 2) {
                    S = "PP片";
                } else if (value == 3) {
                    S = "PP卷";
                }
                $("#lab").html(S + Lab);
            }
        });
        form.render();
    });

    //监听提交
    form.on('submit(sv)', function (data) {
        $('#canvas_location').remove();
        $("#canvas_div").before("<canvas id=\"canvas_location\" width=\"3000\" height=\"800\"></canvas>");
        $('#canvas_num').remove();
        $("#canvas_num_div").before("<canvas id=\"canvas_num\" width=\"3000\" height=\"50\"></canvas>");
        GetRoadWay(data.field.roadway, data.field.line);
        return false;
    });
});