define(['jquery', 'bootstrap', 'backend', 'addtabs', 'table', 'echarts', 'echarts-theme', 'template'], function ($, undefined, Backend, Datatable, Table, Echarts, undefined, Template) {

    var Controller = {
        index: function () {

            //清除所有故障
            $(document).on("click", ".btn-all-fault", function () {
                var simNum = $(".simNum1").val();
                $.ajax({
                    url: Config.url_type+"/sim/debug/debugClearAllFault/"+simNum,
                    type: 'get',
                    success: function (data) {
                        console.log(data);
                        if(data.code==200){
                            var text = '';
                            text += '<span class="text-success">'+data.msg+'</span>';
                            $(".content1").html(text);
                        }else{
                            var text = '';
                            text += '<span class="text-danger">'+data.msg+'</span>';
                            $(".content1").html(text);
                        }
                    }
                });
            });


            //清除一个故障
            $(document).on("change", ".simNum2", function () {
                var customValue = $('.simNum2 option:selected').attr('text');
                $.ajax({
                    url: 'expet/getbindHardwareMsg/ids/'+customValue,
                    type: 'get',
                    success: function (data) {
                        if(data.code==1){
                            $(".bindHardwareMsg2").html(data.msg)
                        }else{
                            Layer.alert(data.msg);
                            return;
                        }
                    }
                });
            });
            $(document).on("click", ".btn-one-fault", function () {
                var simNum2 = $(".simNum2").val();
                var bindHardwareMsg2 = $(".bindHardwareMsg2").val();
                if(!bindHardwareMsg2){
                    Layer.alert('选择故障编号');
                    return;
                }
                $.ajax({
                    url: Config.url_type+"/sim/debug/debugClearOneFault/"+simNum2+"/"+bindHardwareMsg2,
                    type: 'get',
                    success: function (data) {
                        console.log(data);
                        if(data.code==200){
                            var text = '';
                            text += '<span class="text-success">'+data.msg+'</span>';
                            $(".content2").html(text);
                        }else{
                            var text = '';
                            text += '<span class="text-danger">'+data.msg+'</span>';
                            $(".content2").html(text);
                        }
                    }
                });
            });



            //读取全部故障位置数据
            $(document).on("click", ".btn-alldata", function () {
                var simNum3 = $(".simNum3").val();
                $.ajax({
                    url: Config.url_type+"/sim/debug/debugReadAllFaultResistance/"+simNum3,
                    type: 'get',
                    success: function (data) {
                        console.log(data);
                        if(data.code==200){
                            var text = '';
                            text += '<span class="text-success">'+data.msg+'</span>';
                            $(".content3").html(text);
                        }else{
                            var text = '';
                            text += '<span class="text-danger">'+data.msg+'</span>';
                            $(".content3").html(text);
                        }
                    }
                });
            });


            //读取一个故障位置数据
            $(document).on("change", ".simNum4", function () {
                var customValue = $('.simNum4 option:selected').attr('text');
                $.ajax({
                    url: 'expet/getbindHardwareMsg/ids/'+customValue,
                    type: 'get',
                    success: function (data) {
                        if(data.code==1){
                            $(".bindHardwareMsg4").html(data.msg)
                        }else{
                            Layer.alert(data.msg);
                            return;
                        }
                    }
                });
            });
            $(document).on("click", ".btn-onedata", function () {
                var simNum4 = $(".simNum4").val();
                var bindHardwareMsg4 = $(".bindHardwareMsg4").val();
                $.ajax({
                    url: Config.url_type+"/sim/debug/debugReadOneFaultResistance/"+simNum4+"/"+bindHardwareMsg4,
                    type: 'get',
                    success: function (data) {
                        console.log(data);
                        if(data.code==200){
                            var text = '';
                            text += '<span class="text-success">'+data.msg+'</span>';
                            $(".content4").html(text);
                        }else{
                            var text = '';
                            text += '<span class="text-danger">'+data.msg+'</span>';
                            $(".content4").html(text);
                        }
                    }
                });
            });



            //读取模拟器类型序列号
            $(document).on("click", ".btn-simnum", function () {
                var simNum5 = $(".simNum5").val();
                $.ajax({
                    url: Config.url_type+"/sim/debug/debugReadSimType/"+simNum5,
                    type: 'get',
                    success: function (data) {
                        console.log(data);
                        if(data.code==200){
                            var text = '';
                            text += '<span class="text-success">'+data.msg+'</span>';
                            $(".content5").html(text);
                        }else{
                            var text = '';
                            text += '<span class="text-danger">'+data.msg+'</span>';
                            $(".content5").html(text);
                        }
                    }
                });
            });




            //下发所有故障
            $(document).on("click", ".btn-allxiafa", function () {
                var simNum6 = $(".simNum6").val();
                $.ajax({
                    url: Config.url_type+"/sim/debug/debugWriteAllFault/"+simNum6,
                    type: 'get',
                    success: function (data) {
                        console.log(data);
                        if(data.code==200){
                            var text = '';
                            text += '<span class="text-success">'+data.msg+'</span>';
                            $(".content6").html(text);
                        }else{
                            var text = '';
                            text += '<span class="text-danger">'+data.msg+'</span>';
                            $(".content6").html(text);
                        }
                    }
                });
            });

            //下发一个故障
            $(document).on("change", ".simNum7", function () {
                var customValue = $('.simNum7 option:selected').attr('text');
                $.ajax({
                    url: 'expet/getbindHardwareMsg/ids/'+customValue,
                    type: 'get',
                    success: function (data) {
                        if(data.code==1){
                            $(".bindHardwareMsg7").html(data.msg)
                        }else{
                            Layer.alert(data.msg);
                            return;
                        }
                    }
                });
            });
            $(document).on("click", ".btn-onexiafa", function () {
                var simNum7 = $(".simNum7").val();
                var bindHardwareMsg7 = $(".bindHardwareMsg7").val();
                $.ajax({
                    url: Config.url_type+"/sim/debug/debugWriteOneFault/"+simNum7+"/"+bindHardwareMsg7,
                    type: 'get',
                    success: function (data) {
                        console.log(data);
                        if(data.code==200){
                            var text = '';
                            text += '<span class="text-success">'+data.msg+'</span>';
                            $(".content7").html(text);
                        }else{
                            var text = '';
                            text += '<span class="text-danger">'+data.msg+'</span>';
                            $(".content7").html(text);
                        }
                    }
                });
            });



        }
    };

    return Controller;
});
