AddLocation.js 3.58 KB
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" + "/TemStationToInventory"
                , where: { line: $('[name = "line"]').val(), row: $('[name = "row"]').val(), layer: $('[name = "layer"]').val(),roadway: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']")]
        }
    };

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

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

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

    //“容器编号”回车监听
    $('[name = "ContainerId"]').bind("keydown", function (e) {
        var b = $('[name = "IsShou"]:checked').val();
        if (e.which == 13) {
            var str = $(this).val();
            var strs = str.split('%');
            $('[name = "Num"]').val(strs[3]);
            $('[name = "MaterialCode"]').val(strs[0]);
            $('[name = "SourceCode"]').val(strs[1]);
            $('[name = "Batch"]').val(strs[2]);
            $(this).val('');
            $(this).focus();
            $.ajax({
                async: false,
                url: "/" + "task" + "/" + "Task" + "/TemAddInventory",
                type: "post",
                data: { line: $('[name = "line"]').val(), row: $('[name = "row"]').val(), layer: $('[name = "layer"]').val(), material: strs[0], batch: strs[2], roadway: b, num: strs[3], sourceCode: strs[1] },
                dataType: "json",
                success: function (result) {
                    if (result.code == 200) {
                        layer.msg("成功", { icon: 6, shade: 0.4, time: 1000 });
                    }
                    else {
                        layer.alert("失败:" + result.msg, { icon: 5, shadeClose: true, title: "错误信息" });
                    }
                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    layer.alert(errorThrown, { icon: 2, title: '提示' });
                }
            });
            mainList.mainList(b);
            e.preventDefault(); //Skip default behavior of the enter key
        }
    });
});