{extend name="common/common2" /}
{block name="main"}

<style>
    .echarts{
        width: 100%;
        height: 300px;
    }

</style>

<div class="ibox">
    <div class="ibox-content">
        <div class="row">
            <div class="col-xs-3">
                <div class="btn-group pull-left">
                    <a href="javascript:;" onclick="printer()" class="btn btn-sm btn btn-primary"><i class="glyphicon glyphicon-print"></i> 打印</a>
                    <a href="{:url('xyTimeExport')}" class="btn btn-sm btn-danger"><i class="fa fa-cloud-download"> 导出</i></a>
                </div>
            </div>

        </div>
        <div class="echarts" id="echarts"></div>
        <div class="panel-group" id="printer" style="margin-top: 10px">
            <div class="panel panel-default">
                <div class="panel-body">
                    <table class="table table-bordered">
                        <thead>
                        <tr>
<!--                            <th>需求日期</th>-->
                            <th>类型</th>
                            <th>部门</th>
                            <th>员工</th>
                            <th>需求描述</th>
                            <th>状态</th>
                            <th>响应时间</th>
<!--                            <th>完成时间</th>-->
                        </tr>
                        </thead>

                        {foreach $list as $k=>$v}
                        <tbody>
                        <tr>
                            <td>{$v.type_title}</td>
                            <td>{$v.dep}</td>
                            <td>{$v.user_name}</td>
                            <td>{$v.content}</td>
                            {if($v['todo_mode'] == 2)}
                            <td>进行中</td>
                            {elseif($v['todo_mode'] == 3)}
                            <td>已完成</td>
                             {/if}
                            <td>{$v.xy_time}</td>
<!--                            <td>{$v.done_time}</td>-->
                        </tr>
                        </tbody>
                        {/foreach}
                        <tr>
                            <td colspan="2" style="text-align: right"><strong>合计</strong></td>
                            <td colspan="4" style="text-align: right">{$count}</td>
                        </tr>
                    </table>
                </div>


            </div>
        </div>

    </div>

</div>
{/block}
{block name="script"}
<script src="/static/echarts-5.2.2.js"></script>
<script src="/static/browser.js"></script>
<script src="/static/jquery.jqprint-0.3.js"></script>
<script>
    $(function (){
        var url =  '{:url("RepairStatistics/xyTimeEcharts")}';
        $.post(url,{},function (res) {
            if(res.code == 1) {
                var lists = res.data;
                var option;

                option = {
                    xAxis: {
                        type: 'category',
                        data: lists.title
                    },
                    yAxis: {
                        type: 'value'
                    },
                    series: [
                        {
                                data: lists.list,
                                type: 'bar',
                                barWidth :35,
                        }
                    ]
                };
                var myChart = echarts.init(document.getElementById('echarts'));
                myChart.setOption(option);
            }
        })
    })

    function printer(){
        $('#printer').jqprint();
    }


</script>
{/block}