<%--
  Created by IntelliJ IDEA.
  User: molinyi
  Date: 2017/11/21 0021
  Time: 下午 2:12
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="tags" tagdir="/WEB-INF/tags" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>
<html>
<head>
    <title>全网监控智能分析平台</title>
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="This is my page">

    <script src="${ctx}/static/artDialog4.1.7/artDialog.source.js?skin=default"></script>
    <script src="${ctx}/static/artDialog4.1.7/plugins/iframeTools.source.js"></script>
    <%--<script type="text/javascript" src="${ctx}/static/js/failureAnalysisDetailTable.js"></script>--%>
    <script type="text/javascript" src="${ctx}/static/js/associatediagosisdetail.js"></script>
    <script type="text/javascript">
        $(document).ready(function(){
           // alert(1);
           // failureTable();
           // initDateDetail();
            //$("#businessSelectAreaDetail").hide();
            //初始化界面
            initTable();
        });
    </script>

</head>
<body>


<div>
    <div class="container">
        <ol class="breadcrumb">
            <li><a href="${ctx}/index">首页</a></li>
            <li>监控运营</li>
            <li class="active">告警关联诊断</li>
        </ol>
    </div>
</div>


<div id="main-container main-tab-container">
    <div id="content" class="container">
        <div class="tab-bar-bt">
            <ul class="nav nav-tabs">
                <li><a id="a_statistics" href="${ctx}/MonitorOperation/AssociateDiagosisConfiguration">关联诊断配置</a></li>
                <li class="active"><a id="a_detail" href="#detail" data-toggle="tab">关联诊断明细</a></li>
            </ul>
        </div>

        <div class="section">

            <div class="tab-content">
                <div class="tab-pane fade in active" id="detail">

                    <div class="row me-row">
                        <div id="slidePushMenus2" class="cbp-spmenu-push">

                            <div class="slideMenu" id="cbp-spmenu-s2" style="">
                                <div class="form">
                                    <tags:GZFX__Dimension_Province_detail/>
                                    <button class="btn btn-primary" onclick="detailSubmit()">提交</button>
                                    <button class="btn btn-warning" onclick="detailReset()">重置</button>

                                </div>
                            </div>

                            <div class="main col-xs-12">
                                <!-- <table id="mainm2" class="mainm" onclick="hideMenu('showLeftPush2','slidePushMenus2')"></table> -->
                                <div id="mainm2" class="mainm"></div>
                                <div class="content clearfix">
                                    <div class="block clearfix">
                                        <button id="showLeftPush2" class="menu-trigger btn btn-default"
                                                onclick="toggleMenu('slidePushMenus2')">
                                            <span class="glyphicon glyphicon-list"></span>
                                        </button>
                                        <div class="slide-menu-tags">
                                            <span id="detailPeriodTag" class="label label-info" data-placement="bottom">最近一个月</span>
                                            <span id="detailDataSourceTag" class="label label-info"
                                                  data-placement="bottom"></span>
                                            <span id="detailChannelTag" class="label label-info"
                                                  data-placement="bottom"></span>
                                            <span id="detailBusinessTag" class="label label-info"
                                                  data-placement="bottom"></span>
                                            <span id="detailProvinceTag" class="label label-info"
                                                  data-placement="bottom"></span>
                                            <span id="detailProviderTag" class="label label-info"
                                                  data-placement="bottom"></span>
                                            <span id="detailXcdStatusTag" class="label label-info"
                                                  data-placement="bottom"></span>
                                            <span id="detailTitleTag" class="label label-info"
                                                  data-placement="bottom"></span>
                                            <span id="detailWarningSourceTag" class="label label-info"
                                                  data-placement="bottom"></span>
                                            <span id="detailFailureIdTag" class="label label-info"
                                                  data-placement="bottom"></span>
                                        </div>
                                        <div class="bt-list-import">
                                            <a href="#" id="gzfxDetailUpload" class="">
                                                <span class="glyphicon glyphicon-import"></span>
                                                <span class="glyphicon-class">导出Excel</span>
                                            </a>
                                        </div>
                                    </div>

                                    <div class="row">
                                        <div class="col-xs-12">
                                            <div class="table-header">
                                                关联诊断结果查询
                                                <%--<shiro:hasAnyRoles name="admin,dataAnalysis,businessAnalysis">
                                                    <div id="time_div"
                                                         style="top: -6px;float: right;height: 0px;position: relative;">
                                                        <button id="deleteFailureBtn"
                                                                class="btn-sm btn btn-primary btn-sm btn-group btn-group-cog"
                                                                onclick="failureDelete()">删除故障
                                                        </button>
                                                    </div>
                                                </shiro:hasAnyRoles>--%>
                                            </div>
                                            <!--写故障明细列表处-->
                                            <table class="table table-hover table-striped"
                                                   id="failureAnalysisDetailTable">

                                            </table>


                                        </div>
                                    </div>
                                </div>

                            </div>
                        </div>
                    </div>

                </div>
                <form action="#" method="get" id="listForm"></form>
                <input type="hidden" id="gzfxDetail" name="gzfxDetail" value='${gzfxDetailInfos}' />
            </div>
        </div>
    </div>
</div>

<script type="text/javascript">
    //判断是否重置了
    var judge = true ;
    //onloading 确认标签
    var failureId = "${failureId}";
    var driProvinceId = "${driProvinceId}";
    var driProviderId = "${driProviderId}";
    var driDateVal = "${driDateVal}";
    if(failureId!=""){
        $("#detailPeriodTag").empty();
        $("#detailFailureIdTag").text("故障ID:"+failureId);
    }
    if(driProvinceId!=""){
        $("#detailProvinceTag").text("省份").append($("<span class='badge'></span>").text("1")).attr('data-original-title',$(".provinceDetail[value="+driProvinceId+"]").attr("title")).tooltip();
    }


    //条件筛选后的标签改变
    if("${filterDataSource}"!="" && "${filterBusiness}"!="" && "${filterChannel}"!="" && "${filterProvince}"!="" && "${filterProvider}"!=""){
        var filterTimeTag = "${filterTimeTag}";
        $("#detailPeriodTag").text("时间范围").attr('data-original-title',(filterTimeTag.split("-").length>1)?filterTimeTag:"").tooltip();
        $("#detailDataSourceTag").text("数据来源").append($("<span class='badge'></span>").text("${filterDataSource}".split(" ").length)).attr('data-original-title',"${filterDataSource}").tooltip();
        //渠道刷选项
        $("#detailChannelTag").text("渠道").append($("<span class='badge'></span>").text("${filterChannel}".split(" ").length)).attr('data-original-title',"${filterChannel}").tooltip();

        //业务刷选项
        $("#detailBusinessTag").text("业务").append($("<span class='badge'></span>").text("${filterBusiness}".split(" ").length)).attr('data-original-title',"${filterBusiness}").tooltip();

        //省份筛选项
        $("#detailProvinceTag").text("省份").append($("<span class='badge'></span>").text("${filterProvince}".split(" ").length)).attr('data-original-title',"${filterProvince}").tooltip();

        //集成商筛选项
        $("#detailProviderTag").text("集成商").append($("<span class='badge'></span>").text("${filterProvider}".split(" ").length)).attr('data-original-title',"${filterProvider}").tooltip();
        if("${filterWarningSource}"!=""){
            //故障来源
            $("#detailWarningSourceTag").text("故障来源").append($("<span class='badge'></span>").text("${filterWarningSource}".split(" ").length)).attr('data-original-title',"${filterWarningSource}").tooltip();
        }
    }else if("${filterBusiness}"=="" && "${filterDataSource}"!="" && "${filterChannel}"!="" && "${filterProvince}"!="" && "${filterProvider}"!=""){
        var filterTimeTag = "${filterTimeTag}";
        $("#detailPeriodTag").text("时间范围").attr('data-original-title',(filterTimeTag.split("-").length>1)?filterTimeTag:"").tooltip();
        $("#detailDataSourceTag").text("数据来源").append($("<span class='badge'></span>").text("${filterDataSource}".split(" ").length)).attr('data-original-title',"${filterDataSource}").tooltip();
        //渠道刷选项
        $("#detailChannelTag").text("渠道").append($("<span class='badge'></span>").text("${filterChannel}".split(" ").length)).attr('data-original-title',"${filterChannel}").tooltip();

        //省份筛选项
        $("#detailProvinceTag").text("省份").append($("<span class='badge'></span>").text("${filterProvince}".split(" ").length)).attr('data-original-title',"${filterProvince}").tooltip();

        //集成商筛选项
        $("#detailProviderTag").text("集成商").append($("<span class='badge'></span>").text("${filterProvider}".split(" ").length)).attr('data-original-title',"${filterProvider}").tooltip();
    }else if("${filterBusiness}"=="" && "${filterDataSource}"=="" && "${filterChannel}"=="" && "${filterProvince}"!="" && "${filterProvider}"!=""){
        //省份筛选项
        $("#detailProvinceTag").text("省份").append($("<span class='badge'></span>").text("${filterProvince}".split(" ").length)).attr('data-original-title',"${filterProvince}").tooltip();

        //集成商筛选项
        $("#detailProviderTag").text("集成商").append($("<span class='badge'></span>").text("${filterProvider}".split(" ").length)).attr('data-original-title',"${filterProvider}").tooltip();
    }

</script>


<script type="text/javascript">

    function writeLable(){
        if(judge == true){
            $("#detailPeriodTag").text("最近一个月");
            $("#detailDataSourceTag").empty();
            $("#detailChannelTag").empty();
            $("#detailBusinessTag").empty();
            $("#detailProvinceTag").empty();
            $("#detailProviderTag").empty();
            $("#detailXcdStatusTag").empty();
            $("#detailWarningSourceTag").empty();
        }else{
            if($("#titleText").val()!=""){
                $("#detailPeriodTag").empty();
                $("#detailDataSourceTag").empty();
                $("#detailChannelTag").empty();
                $("#detailBusinessTag").empty();
                $("#detailProvinceTag").empty();
                $("#detailProviderTag").empty();
                $("#detailXcdStatusTag").empty();
                $("#detailWarningSourceTag").empty();
                $('#detailTitleTag').text("故障标题:"+$("#titleText").val());
            }else{
                $('#detailTitleTag').empty();
                $("#detailWarningSourceTag").text("故障来源").append($("<span class='badge'></span>").text(getStatsWarningSourceCheckedValues().length)).attr('data-original-title',getStatsWaringSourceCheckedTitles()).tooltip();
                $("#detailXcdStatusTag").text("协查单状态:"+getXcdStatusTitle());
                $("#detailPeriodTag").text((getDetailPeriodStr()=="")?"最近一个月":"时间范围").attr('data-original-title',getDetailPeriodStr()).tooltip();
                //数据来源刷选项
                $("#detailDataSourceTag").text("数据来源").append($("<span class='badge'></span>").text(getDetailDataSourceCheckedTexts().length)).attr('data-original-title',getDetailDataSourceCheckedTitles()).tooltip();
                //渠道刷选项
                $("#detailChannelTag").text("渠道").append($("<span class='badge'></span>").text(getDetailChannelCheckedValues().length)).attr('data-original-title',getDetailChannelCheckedTitles()).tooltip();
                //业务刷选项
                $("#detailBusinessTag").text("业务").append($("<span class='badge'></span>").text(getDetailBusinessCheckedValues().length)).attr('data-original-title',getDetailBusinessCheckedTitlesString()).tooltip();
                //省份筛选项
                $("#detailProvinceTag").text("省份").append($("<span class='badge'></span>").text(getDetailProvinceCheckedValues().length)).attr('data-original-title',getDetailProvinceCheckedTitles()).tooltip();
                //集成商筛选项
                $("#detailProviderTag").text("集成商").append($("<span class='badge'></span>").text(getDetailProviderCheckedValues().length)).attr('data-original-title',getDetailProviderCheckedTitles()).tooltip();
            }
        }

    }


    function detailSubmit(){

        var detailProvinceSum = getDetailProvinceCheckedValues().length;

        if(detailProvinceSum==0) {
            $.alert("省份的选择不能为空");
        }else{
            var detailProvince = getDetailProvinceCheckedValueString();
            var dimension=getDetailCheckeddDimension();
            //alert(dimension+"-pi-");
//            alert(detailProvince);
            //var href="${ctx}/MonitorOperation/FailureAnalysisDetail/changeTable?detailProvince="+detailProvince+"&detailProvider="+detailProvider+"&xcdStatus="+xcdStatus+"&detailDataSource="+detailDataSource+"&detailChannel="+detailChannel+"&detailBusiness="+detailBusiness+"&detailWarningSource="+detailWarningSource+"&failureTitle="+"-1";
           /* $.ajax({
                type : 'GET',
                contentType : 'application/json',
                url: encodeURI(encodeURI(href))+"&detailTime="+detailTime,//href,
                dataType : 'text',
                beforeSend: function(data) {
                },
                success: function(data) {
                    $("#gzfxDetail").val(data);
                    failureTable();
                    checkFailureIds=[];
                    $("#deleteFailureBtn").attr("disabled", true);
                    toggleMenu('slidePushMenus2');//隐藏筛选项
                }
            });*/
            toggleMenu('slidePushMenus2');//隐藏筛选项
        }
        writeLable();

    }

    //重置detail中的筛选项
    function detailReset(){
        detail_Province_Reset();
        detail_Dimension_Reset();
        judge = true;
    }

    //把故障明细统计列表导出为Excel格式
    $("#gzfxDetailUpload").click(function(){
        //upLoadExcel
        var listForm=$("#listForm");
        listForm.attr("method","post");
        listForm.attr("action","${ctx}/MonitorOperation/FailureAnalysisDetail/upLoadGzfxDetailExcel");
        listForm.submit();
        listForm.attr("action","#");
    });

</script>

</body>
</html>