<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <link rel="icon" type="image/x-icon" href="{{ url_for('static', filename='favicon.ico') }}"/>
    <link rel="stylesheet" href="{{ url_for('static', filename='lib/easyui/themes/bootstrap/easyui.css') }}">
    <link rel="stylesheet" href="{{ url_for('static', filename='lib/easyui/themes/icon.css') }}">
    <link rel="stylesheet" href="{{ url_for('static', filename='css/auto.css') }}">
    <title>测试用例报告</title>
    <!-- 引入 echarts.js -->
    <script type="text/javascript" src="{{ url_for('static', filename='lib/echarts.min.js') }}"></script>
    <script src="{{ url_for('static', filename='lib/easyui/jquery.min.js') }}"></script>
    <script src="{{ url_for('static', filename='lib/easyui/jquery.easyui.min.js') }}"></script>
    <!-- 自定义js库 -->
    <script type="text/javascript" src="{{ url_for('static', filename='lib/auto.js') }}"></script>
</head>
<body>
<div class="easyui-layout" data-options="fit:true">
    <div data-options="region:'north',split:true" style="height:200px">
        <div id="casetotal" style="height:150px;margin: 0 auto"></div>
        <div id="casecount" style="height:20px;margin: 0 auto;padding:10px">
            <h5>用例总数：{{autoratio.total}} ,场景总数：{{autoratio.suites}}, 自动化率：{{autoratio.ratio}}%</h5>
        </div>
    </div>
    <div data-options="region:'center'">
        <div class="easyui-layout" data-options="fit:true">
            <div data-options="region:'north',split:true" style="height:400px">
                <div class="easyui-layout" data-options="fit:true">
                    <div data-options="region:'west',split:true" style="width:60%">
                        <div id="submodule" style="height:400px;margin: 0 auto;"></div>
                    </div>
                    <div data-options="region:'center'">
                        <div class="easyui-tabs" data-options="plain:true, pill:true,justified:true">
                            <div title="今天" style="padding:10px">
                                <table id="dayly_list" class="easyui-datagrid" style="width:100%;height:auto;"
                                       data-options="singleSelect:true,
                                       fitColumns:true,
                                       url:'/api/v1/report?key={{dir}}&request=caseinfo&method=day',
                                       method:'get' "
                                >
                                    <thead>
                                    <tr>
                                        <th data-options="field:'case',align:'center' , halign: 'center'">用例数</th>
                                        <th data-options="field:'caseresult',align:'center' , halign: 'center'">结果
                                        </th>
                                        <th data-options="field:'nothing',align:'center' , halign: 'center'">|</th>
                                        <th data-options="field:'suite',align:'center' , halign: 'center'">场景数</th>
                                        <th data-options="field:'suiteresult',align:'center' , halign: 'center'">结果
                                        </th>
                                        <th data-options="field:'time',align:'center' , halign: 'center'">时间</th>
                                    </tr>
                                    </thead>
                                </table>
                            </div>
                            <div title="本周" style="padding:10px">
                                <table id="weekly_list" class="easyui-datagrid" style="width:100%;height:auto;"
                                       data-options="singleSelect:true,
                                       fitColumns:true,
                                       url:'/api/v1/report?key={{dir}}&request=caseinfo&method=week',
                                       method:'get' "
                                >
                                    <thead>
                                    <tr>
                                        <th data-options="field:'case',align:'center' , halign: 'center'">用例数</th>
                                        <th data-options="field:'caseresult',align:'center' , halign: 'center'">结果
                                        </th>
                                        <th data-options="field:'nothing',align:'center' , halign: 'center'">|</th>
                                        <th data-options="field:'suite',align:'center' , halign: 'center'">场景数</th>
                                        <th data-options="field:'suiteresult',align:'center' , halign: 'center'">结果
                                        </th>
                                        <th data-options="field:'time',align:'center' , halign: 'center'">时间</th>
                                    </tr>
                                    </thead>
                                </table>
                            </div>
                            <div title="总计" style="padding:10px">
                                <table id="total_list" class="easyui-datagrid" style="width:100%;height:auto;"
                                       data-options="singleSelect:true,
                                       fitColumns:true,
                                       url:'/api/v1/report?key={{dir}}&request=caseinfo&method=total',
                                       method:'get' "
                                >
                                    <thead>
                                    <tr>
                                        <th data-options="field:'case',align:'center' , halign: 'center'">用例数</th>
                                        <th data-options="field:'caseresult',align:'center' , halign: 'center'">结果
                                        </th>
                                        <th data-options="field:'nothing',align:'center' , halign: 'center'">|</th>
                                        <th data-options="field:'suite',align:'center' , halign: 'center'">场景数</th>
                                        <th data-options="field:'suiteresult',align:'center' , halign: 'center'">结果
                                        </th>
                                        <th data-options="field:'time',align:'center' , halign: 'center'">时间</th>
                                    </tr>
                                    </thead>
                                </table>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>


<script type="text/javascript">

    // 基于准备好的dom，初始化echarts实例

    var submoduleChart = echarts.init(document.getElementById('submodule'));
    var caseTotalChart = echarts.init(document.getElementById('casetotal'));

    // 指定图表的配置项和数据


        var    submodule = {
            title : {
                text: '子模块自动化率',
                x:'center'
            },
            tooltip : {
                trigger: 'axis',
                axisPointer : {            // 坐标轴指示器，坐标轴触发有效
                    type : 'shadow'        // 默认为直线，可选为：'line' | 'shadow'
                }
            },
            legend: {
                orient : 'vertical',
                x : 'left',
                data:['Auto Cases', 'Hand Cases']
            },
            toolbox: {
                show : true,
                feature : {
                    mark : {show: true},
                    dataView : {show: true, readOnly: false},
                    magicType : {show: true, type: ['line', 'bar', 'stack', 'tiled']},
                    restore : {show: true},
                    saveAsImage : {show: true}
                }
            },
            calculable : true,
            xAxis : [
                {
                    type : 'value'
                }
            ],
            yAxis : [
                {
                    type : 'category',
                    data : {{modulesinfo.modules|safe}}
                }
            ],
            series : [
                {
                    name:'自动化用例',
                    type:'bar',
                    stack: 'Total',
                    itemStyle : { normal: {label : {show: true, position: 'insideRight'}}},
                    data: {{modulesinfo.auto|safe}}
                },
                {
                    name:'手工用例',
                    type:'bar',
                    stack: 'Total',
                    itemStyle : { normal: {label : {show: true, position: 'insideRight'}}},
                    data: {{modulesinfo.hand|safe}}
                }
            ]
        };


        var    casetotal = {
            title : {
                text: '整体自动化率',
                x:'center'
            },
            tooltip : {
                trigger: 'axis',
                axisPointer : {            // 坐标轴指示器，坐标轴触发有效
                    type : 'shadow'        // 默认为直线，可选为：'line' | 'shadow'
                }
            },
            legend: {
                orient : 'vertical',
                x : 'left',
                data:['AutoCases', 'HandCases']
            },
            toolbox: {
                show : true,
                feature : {
                    mark : {show: true},
                    dataView : {show: true, readOnly: false},
                    magicType : {show: true, type: ['line', 'bar', 'stack', 'tiled']},
                    restore : {show: true},
                    saveAsImage : {show: true}
                }
            },
            calculable : true,
            xAxis : [
                {
                    type : 'value'
                }
            ],
            yAxis : [
                {
                    type : 'category',
                    data : ['{{autoratio.ratio}}'+'%']
                }
            ],
            series : [
                {
                    name:'Auto-Case',
                    type:'bar',
                    stack: 'Total',
                    itemStyle : { normal: {label : {show: true, position: 'insideRight'}}},
                    data:[{{autoratio.auto}}]
                },
                {
                    name:'Hand-Case',
                    type:'bar',
                    stack: 'Total',
                    itemStyle : { normal: {label : {show: true, position: 'insideRight'}}},
                    data:[{{autoratio.hand}}]
                }
            ]
        };





    // 使用刚指定的配置项和数据显示图表。
    //myChart1.setOption(option1);
    //myChart2.setOption(option2);
    submoduleChart.setOption(submodule);
    caseTotalChart.setOption(casetotal);
    //myChart5.setOption(option5);

</script>
</body>
</html>