StationHandTask.js 4.61 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 = 'StationHandTask';
    var TableName = 'StationHandTask';

    var vm = new Vue({
        el: '#PalletForm'
    });

    var PalletIn = new Vue({
        data: {}
    });

    var selector = {
    };

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

    Universal.BindSelector($, form, vml, selector);
    var list;
    //请求可以被清除的站台
    function ReStation() {
        var html = "<option class='select_Station' value=''>请选择需要清空的站台</option>";;
        $.ajax({
            async: true,
            type: "post",
            url: "/HandTask/HandTask/RequestStation",
            dataType: "json",
            success: function (result) {
                if (result.code == 200) {
                    list = result.data;
                    for (var i = 0; i < list.length; i++)
                    {
                        html += "<option class='select_Station'value='" + i + "'>站台号:  " + list[i].Name + "</option>";
                    }
                    $("#Station").html(html);
                    form.render();
                }
                else if (result.code == 300) {
                    layer.alert(result.msg, { icon: 5, shade: 0.4,});
                    return;
                }
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                layer.alert(errorThrown, { icon: 2, title: '提示' });
            }
        });
    };
    //点击清除按钮
    $(document).on("click", "#BtnGo", function () {
        var Stk = $("#Station  option:selected");
        var a = Stk.val();
        var Pallet = list[a];
        $("[name = 'DelName']").val("");
        layer.open({
            title: '输入姓名或姓名首字母',
            area: ["300px", "350px"],
            type: 1,
            content: $('#DeleteName'),
            btn: ['确认'],
            yes: function (index) {
                var name = $("[name = 'DelName']").val();
                if (name == "") {
                    layer.alert("输入姓名或姓名首字母!!", { icon: 2, title: '提示' });
                } else {
                    layer.close(index);
                    layer.open({
                        title: '确定信息',
                        area: '300px;',
                        type: 1,
                        content: "<h2 class='c1'>清空站台为:</h2><br><h2 class='c3'>" + Pallet.Name + "<h2><br><h2  class='c1'>该站台上的托盘号为:</h2><br><h2 class='c3'>" + Pallet.Containercode + "</h2>",
                        btn: ['确认'],
                        btnAlign: 'c', //按钮居中
                        yes: function (index) {
                            layer.alert("确定清除站台数据??", { icon: 3, shadeClose: true, title: "提示信息" }, function (index) {
                                $.ajax({
                                    async: false,
                                    url: "/" + "HandTask" + "/" + "HandTask" + "/EmptyStation",
                                    type: "post",
                                    data: { code: Pallet.Code,Name:name },
                                    dataType: "json",
                                    success: function (result) {
                                        if (result.code == 200) {
                                            layer.closeAll();
                                            layer.msg(result.msg, { icon: 6, shade: 0.4, time: 1000 });
                                            ReStation();
                                        }
                                        else {
                                            layer.alert("失败:" + result.msg, { icon: 5, shadeClose: true, title: "错误信息" });
                                        }

                                    },
                                    error: function (XMLHttpRequest, textStatus, errorThrown) {
                                        layer.alert(errorThrown, { icon: 2, title: '提示' });
                                    }
                                });
                            });
                        }
                    });
                }
            }
        });
        
    });

    $(document).ready(function () {
        ReStation();
    })
});