<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/webpage/include/taglib.jsp"%>
<html>
<head>
    <title>收入统计</title>
    <meta name="decorator" content="default"/>
    <%@ include file="/webpage/include/echarts.jsp"%>

    <style>
        .widthClass{
            display: inline-block;
        }
        .shows .input-group{
            width: 48%!important;
        }
    </style>
    <style>
        body{
            background-color:transparent;
            filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=#26FFFFFF, endColorstr=#26FFFFFF);
            color:#ffffff;
            background-color:rgba(255,255,255,0);
            height:100%;
        }
    </style>
</head>
<body>
<div class="wrapper wrapper-content">
    <sys:messageJBox content="${message}"/>
    <div class="layui-row">
        <div class="full-width fl">
            <div class="contentShadow layui-row" id="queryDiv">
                <form:form id="searchForm" modelAttribute="workReceiptsRegisterOffice" action="${ctx}/workreceiptsregister/workReceiptsRegister/officelist" method="post" class="form-inline">
                    <%--以下三行照抄--%>
                    <form:hidden path="company.id"/>
                    <div class="commonQuery">

                        <div class="layui-item layui-col-sm6">
                            <label class="layui-form-label">展示方式：</label>
                            <div class="layui-input-block">
                                <form:radiobutton class="i-checks" path="ext" checked="true" label="按部门" id="extleft" value="0"/>
                                <form:radiobutton  class="i-checks" path="ext" id="ext1" label="按月份" value="1"/>
                            </div>
                        </div>
                        <div class="layui-item layui-col-sm6">
                            <label class="layui-form-label">显示样式：</label>
                            <div class="layui-input-block">
                                <input type="radio" class="i-checks" name="extright" checked id="cssExt" value="0">
                                <label for="cssExt">列表</label>
                                <input type="radio" class="i-checks" name="extright" id="cssExt1" value="1">
                                <label for="cssExt1">柱图</label>
                                <input type="radio" class="i-checks" name="extright"  id="cssExt2" value="2">
                                <label for="cssExt2">饼图</label>
                                <input type="radio" class="i-checks" name="extright" id="cssExt3" value="3">
                                <label for="cssExt3">折线图</label>
                            </div>
                        </div>
                    </div>
                    <div class="commonQuery">
                        <div class="layui-item query athird">
                            <label class="layui-form-label">部门：</label>
                            <div class="layui-input-block with-icon">
                                <sys:treeselect id="companyId" name="officeId" value="${workReceiptsRegisterOffice.officeId}" labelName="name" labelValue="${workReceiptsRegisterOffice.name}"
                                                title="部门" url="/sys/office/treeDataAll?type=2" cssClass="form-control layui-input" allowClear="true" notAllowSelectParent="true"/>
                            </div>
                        </div>
                        <div class="layui-item query athird">
                            <label class="layui-form-label">登记日期：</label>
                            <div class="layui-input-block">
                                <input id="receiptDate" name="receiptDate" type="text" readonly="readonly" maxlength="20" class="laydate-icondate form-control layer-date layui-input laydate-icon"
                                       value="${workReceiptsRegisterOffice.receiptDate}"/>
                                </input>
                            </div>
                        </div>
                        <div class="layui-item athird">
                            <div class="input-group">
                                <button id="searchReset" class="fixed-btn searchReset fr" onclick="resetSearchs()">重置</button>
                                <button id="searchQuery" class="fixed-btn searchQuery fr" onclick="search()">查询</button>
                            </div>
                        </div>
                        <div style="    clear:both;"></div>
                    </div>
                </form:form>
            </div>
        </div>

        <div class="full-width fl" id="frametable">
            <div class="contentShadow layui-form contentDetails">
                <div class="nav-btns">
                    <shiro:hasPermission name="workreceiptsregister:workReceiptsRegister:countExport">
                        <table:exportExcel url="${ctx}/workreceiptsregister/workReceiptsRegister/exportOffice"></table:exportExcel><!-- 导出按钮 -->
                    </shiro:hasPermission>
                    <c:choose>
                        <c:when test="${not empty backState}">
                            <a class="nav-btn nav-btn-refresh" onClick="javascript :history.back(-1);"  data-toggle="tooltip" data-placement="left" title="返回"><i class="glyphicon glyphicon-repeat"></i>&nbsp;返回</a>
                        </c:when>
                    </c:choose>
                    <div style="clear: both;"></div>
                </div>
                <table class="oa-table layui-table" id="contentTable"></table>

                <!-- 分页代码 -->
                <%-- <table:page page="${page}"></table:page>--%>
                <div style="clear: both;"></div>
            </div>
        </div>
        <div id="echarts">
            <%--柱图--%>
            <div id="bar_normal" style="position: relative; overflow: hidden; width: 1290px; height: 360px; display: none" class="main000">
                <echarts:bar id="bar_normal" title="收入统计表" xAxisData="${xAxisData}" yAxisData="${yAxisData}" xAxisName="分公司" yAxisName="收款金额(元)"/></div>
            <%--饼图--%>
            <div id="pie"  style="position: relative; overflow: hidden; width: 1290px; height: 360px; display: none" class="main000">
                <echarts:pie id="pie" title="收入统计表" subtitle="" orientData="${orientData}"/></div>
            <%--折线图--%>
            <div id="line_normal" style="position: relative; overflow: hidden; width: 1290px; height: 360px; display: none"  class="main000">
                <echarts:line id="line_normal" title="收入统计表" subtitle="" xAxisData="${xAxisData}" yAxisData="${yAxisData}" xAxisName="公司名称" yAxisName="收款金额（元）" /></div>
        </div>
    </div>
    <div id="changewidth"></div>
</div>
<script src="${ctxStatic}/layer-v2.3/layui/layui.all.js" charset="utf-8"></script>
<script>
    layui.use('table', function(){
        layui.table.render({
            limit:${list.size()},
            elem: '#contentTable'
            ,page: false
            ,cols: [[
                {field:'officeName',align:'center',title: '${colName}', templet:function(d){
                        if(d.officeName!='合计'&&'${colName}'!="月份"){
                            var xml = "<a class=\"attention-info\" onclick=\"isSign('"+d.id+"','"+d.sign+"')\" >" +
                                "<span title=" + d.officeName + ">" + d.officeName + "</span></a>";
                            return xml;
                        }else{
                            return "<span title='"+ d.officeName +"'>" + d.officeName + "</span>";
                        }
                    }}
                ,{field:'money',align:'center', title: '收款金额', templet:function(d){
                        return "<span title='"+ d.money +"'>" + d.money + "</span>";
                    }}
            ]]
            ,data: [
                <c:if test="${ not empty list}">
                <c:forEach items="${list}" var="workReceiptsRegisterCompany" varStatus="index">
                <c:if test="${index.index != 0}">,</c:if>
                {
                    "id":"${workReceiptsRegisterCompany.id}",
                    "comId":"${workReceiptsRegisterOffice.id}",
                    "officeName":<c:choose>
                        <c:when test="${colName == '月度'}">
                        "${workReceiptsRegisterCompany.datestr}"
                    </c:when>
                    <c:otherwise>
                    "${workReceiptsRegisterCompany.name}"
                    </c:otherwise>
                    </c:choose>
                    ,"money":"<fmt:formatNumber value="${workReceiptsRegisterCompany.receiptAmt}" pattern="#,#00.00"/>"
                }
                </c:forEach>
                </c:if>
            ]
        });
    })
    resizeListTable();
</script>


<script>
    function isSign(officeId){
        $.ajax({
            type:'post',
            url:'${ctx}/workreimbursementcount/workInvoiceCount/officeSignlist',
            data:{
                "officeId":officeId
            },
            success:function(data){
                if(data==0){
                    window.location.href='${ctx}/workreceiptsregister/workReceiptsRegister/infolist?officeId='+officeId;
                }else{
                    window.location.href='${ctx}/workreceiptsregister/workReceiptsRegister/officelist?companyId='+officeId;
                }
            }
        })
    }
    function resetSearchs(){//重置，页码清零
        $("#extleft").iCheck('check');
        $("#pageNo").val(0);
        $("#searchForm div.query input").val("");
        $("#searchForm div.query select").val("");
        $("#searchForm").submit();
        return false;
    }
    resizeListWindow1();
    $(window).resize(function(){
        resizeListWindow1();
    });
</script>
<script type="text/javascript">
    $(document).ready(function() {
        $("#cus_name").show();
        $("#cus_name").siblings().hide();
        $("#frametable").show();//列表

        $("input[name='extright']").on('ifChecked', function(event){
            var obj=$("input:radio[name='extright']:checked").val();
            changeStyle(obj);
        });
        //搜索框收放
        $('#moresee').click(function(){
            if($('#moresees').is(':visible'))
            {
                $('#moresees').slideUp(0,resizeListWindow1);
                $('#moresee i').removeClass("glyphicon glyphicon-menu-up").addClass("glyphicon glyphicon-menu-down");
            }else{
                $('#moresees').slideDown(0,resizeListWindow1);
                $('#moresee i').removeClass("glyphicon glyphicon-menu-down").addClass("glyphicon glyphicon-menu-up");
            }
        });

        laydate.render({
            elem: '#receiptDate', //目标元素。由于laydate.js封装了一个轻量级的选择器引擎，因此elem还允许你传入class、tag但必须按照这种方式 '#id .class'
            event: 'focus', //响应事件。如果没有传入event，则按照默认的click
            type : 'date',
            format:'yyyy'
        });
        var companyId = $(document.getElementById("company.id")).val();
    });
    function switchInput(obj){
        $("#"+obj).show();
        $("#"+obj).siblings().hide();
    }

    function changeStyle(obj){
        if(obj==0){
            $("#frametable").show();//列表
            $("#bar_normal").hide();//柱图
            $("#pie").hide();//饼图
            $("#line_normal").hide();//折线
        }else if(obj==1){
            $("#frametable").hide();//列表
            $("#bar_normal").show();//柱图
            $("#pie").hide();//饼图
            $("#line_normal").hide();//折线
        }else if(obj==2){
            $("#frametable").hide();//列表
            $("#bar_normal").hide();//柱图
            $("#pie").show();//饼图
            $("#line_normal").hide();//折线
        }else if(obj==3){
            $("#frametable").hide();//列表
            $("#bar_normal").hide();//柱图
            $("#pie").hide();//饼图
            $("#line_normal").show();//折线
        }
    }
</script>
</body>
</html>
