<style>
    .form-group .control-label {
        font-weight: 500;
        color: #555;
    }

    #rt-report-header th {
        text-align: center;
        vertical-align: inherit;
        border: 1px solid #f0f0f0;
        color: #555;
        font-weight: 500;
    }

    #rt-report-header tr,
    td {
        text-align: center;
        vertical-align: inherit;
        border: 1px solid #f0f0f0;
        color: #555;
        font-weight: 500;
    }
</style>
<form class="form-horizontal">
    <div class="form-group">
        <rt-datetime ng-model="vm.yM" rt-type="month" rt-title="计算年月" rt-required="true" rt-col="3" rt-label-col="2">
        </rt-datetime>
        <div class="col-sm-1">
            <button class="btn btn-primary" ng-click="vm.query()">查询计算结果</button>
        </div>
        <div class="col-sm-1">
            <button class="btn btn-primary" style="margin-left: 50px;" ng-click="vm.calculate()">计算</button>
        </div>
        <div class="col-sm-1">
            <button class="btn btn-primary" style="margin-left: 50px;" rt-col="2" ng-click='vm.actions.export({},"DrugFlowSettleExport","流向计算")'>导出</button>
        </div>
    </div>
</form>



<div class="nav-tabs-custom">
    <ul class="nav nav-tabs">
        <li class="active" ng-click="vm.chooseTab('line')">
            <a href="#c1" onclick="return false;" data-toggle="tab">代理商结算明细</a>
        </li>
        <li ng-click="vm.chooseTab('sum')">
            <a href="#c2" onclick="return false;" data-toggle="tab">代理商结算汇总</a>
        </li>
        <li ng-click="vm.chooseTab('busline')">
            <a href="#c3" onclick="return false;" data-toggle="tab">商业结算明细</a>
        </li>
        <li ng-click="vm.chooseTab('bussum')">
            <a href="#c4" onclick="return false;" data-toggle="tab">商业结算汇总</a>
        </li>
        <li ng-click="vm.chooseTab('agentsline')">
            <a href="#c5" onclick="return false;" data-toggle="tab">代表结算明细</a>
        </li>
        <li ng-click="vm.chooseTab('agentssum')">
            <a href="#c6" onclick="return false;" data-toggle="tab">代表结算汇总</a>
        </li>
    </ul>
    <div class="tab-content">
        <div class="tab-pane active" id="c1" style="border-top: 1px dotted #d5c4c4; padding-top: 20px;">
            <rt-data-grid rt-page-record-count="vm.lineRecordCount" rt-page-index="vm.pageIndex" rt-page-size="vm.pageSize" rt-get-data="vm.query()" rt-rows="vm.lineData"
                rt-auto-height="{{tableMaxHeight}} ">
                <table class="table table-condensed table-hover ng-scope" style="white-space:nowrap;" id="rt-report-header">
                    <thead>
                        <tr>
                            <th rowspan="3">省区</th>
                            <th rowspan="3">办事处</th>
                            <th rowspan="3">代理商</th>
                            <th rowspan="3">药品</th>
                            <th rowspan="3">规格</th>
                            <th rowspan="3">商业</th>
                            <th rowspan="3">终端</th>
                            <th rowspan="3">日期</th>
                            <th rowspan="3">数量</th>
                            <th rowspan="3">金额</th>
                            <th rowspan="3">结算规则说明</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr ng-repeat="row in vm.lineData ">
                            <td>{{row.bigdepartidName}}</td>
                            <td>{{row.businessunitidName}}</td>
                            <td>{{row.owneridName}}</td>
                            <td>{{row.productidName}}</td>
                            <td>{{row.productsize}}</td>
                            <td>{{row.from_accountidName}}</td>
                            <td>{{row.to_accountidName}}</td>
                            <td>{{row.billdate| date:'yyyy-MM-dd'}}</td>
                            <td>{{row.saleto_count|toFixNumber:2}}</td>
                            <td>{{row.settle_amount|toFixNumber:2}}</td>
                            <td>{{row.settle_cal_rule_desc}}</td>
                        </tr>
                    </tbody>
                </table>
            </rt-data-grid>
        </div>

        <div class="tab-pane" id="c2" style="border-top: 1px dotted #d5c4c4; padding-top: 20px;">
            <rt-data-grid rt-page-record-count="vm.sumRecordCount" rt-page-index="vm.pageIndex" rt-page-size="vm.pageSize" rt-get-data="vm.query()" rt-rows="vm.sumData"
                rt-auto-height="{{tableMaxHeight}} ">
                <table class="table table-condensed table-hover ng-scope" style="white-space:nowrap;" id="rt-report-header">
                    <thead>
                        <tr>
                            <th rowspan="3">省区</th>
                            <th rowspan="3">办事处</th>
                            <th rowspan="3">代理商</th>
                            <th rowspan="3">金额</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr ng-repeat="row in vm.sumData ">
                            <td>{{row.bigdepartidName}}</td>
                            <td>{{row.businessunitidName}}</td>
                            <td>{{row.owneridName}}</td>
                            <td>{{row.settle_amount|toFixNumber:2}}</td>
                        </tr>
                    </tbody>
                </table>
            </rt-data-grid>
        </div>

        <div class="tab-pane" id="c3" style="border-top: 1px dotted #d5c4c4; padding-top: 20px;">
            <rt-data-grid rt-page-record-count="vm.buslineRecordCount" rt-page-index="vm.pageIndex" rt-page-size="vm.pageSize" rt-get-data="vm.query()" rt-rows="vm.buslineData"
                rt-auto-height="{{tableMaxHeight}} ">
                <table class="table table-condensed table-hover ng-scope" style="white-space:nowrap;" id="rt-report-header">
                    <thead>
                        <tr>
                            <th rowspan="3">省区</th>
                            <th rowspan="3">办事处</th>
                            <th rowspan="3">代表</th>
                            <th rowspan="3">商业</th>
                            <th rowspan="3">日期</th>
                            <th rowspan="3">回款金额</th>
                            <th rowspan="3">结算金额</th>
                            <th rowspan="3">结算公式</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr ng-repeat="row in vm.buslineData ">
                            <td>{{row.bigdepartidName}}</td>
                            <td>{{row.businessunitidName}}</td>
                            <td>{{row.owneridName}}</td>
                            <td>{{row.from_accountidName}}</td>
                            <td>{{row.billdate| date:'yyyy-MM-dd'}}</td>
                            <td>{{row.saleto_count|toFixNumber:2}}</td>
                            <td>{{row.settle_amount|toFixNumber:2}}</td>
                            <td>{{row.settle_cal_rule_desc}}</td>
                        </tr>
                    </tbody>
                </table>
            </rt-data-grid>
        </div>

        <div class="tab-pane" id="c4" style="border-top: 1px dotted #d5c4c4; padding-top: 20px;">
            <rt-data-grid rt-page-record-count="vm.bussumRecordCount" rt-page-index="vm.pageIndex" rt-page-size="vm.pageSize" rt-get-data="vm.query()" rt-rows="vm.bussumData"
                rt-auto-height="{{tableMaxHeight}} ">
                <table class="table table-condensed table-hover ng-scope" style="white-space:nowrap;" id="rt-report-header">
                    <thead>
                        <tr>
                            <th rowspan="3">省区</th>
                            <th rowspan="3">办事处</th>
                            <th rowspan="3">代表</th>
                            <th rowspan="3">结算金额</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr ng-repeat="row in vm.bussumData ">
                            <td>{{row.bigdepartidName}}</td>
                            <td>{{row.businessunitidName}}</td>
                            <td>{{row.owneridName}}</td>
                            <td>{{row.settle_amount|toFixNumber:2}}</td>
                        </tr>
                    </tbody>
                </table>
            </rt-data-grid>
        </div>

        <div class="tab-pane" id="c5" style="border-top: 1px dotted #d5c4c4; padding-top: 20px;">
            <rt-data-grid rt-page-record-count="vm.agentslineRecordCount" rt-page-index="vm.pageIndex" rt-page-size="vm.pageSize" rt-get-data="vm.query()" rt-rows="vm.agentslineData"
                rt-auto-height="{{tableMaxHeight}} ">
                <table class="table table-condensed table-hover ng-scope" style="white-space:nowrap;" id="rt-report-header">
                    <thead>
                        <tr>
                            <th rowspan="3">省区</th>
                            <th rowspan="3">办事处</th>
                            <th rowspan="3">代表</th>
                            <th rowspan="3">药品</th>
                            <th rowspan="3">规格</th>
                            <th rowspan="3">商业</th>
                            <th rowspan="3">终端</th>
                            <th rowspan="3">日期</th>
                            <th rowspan="3">数量</th>
                            <th rowspan="3">结算金额</th>
                            <th rowspan="3">结算规则说明</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr ng-repeat="row in vm.agentslineData ">
                            <td>{{row.bigdepartidName}}</td>
                            <td>{{row.businessunitidName}}</td>
                            <td>{{row.owneridName}}</td>
                            <td>{{row.productidName}}</td>
                            <td>{{row.productsize}}</td>
                            <td>{{row.from_accountidName}}</td>
                            <td>{{row.to_accountidName}}</td>
                            <td>{{row.billdate| date:'yyyy-MM-dd'}}</td>
                            <td>{{row.saleto_count|toFixNumber:2}}</td>
                            <td>{{row.settle_amount|toFixNumber:2}}</td>
                            <td>{{row.settle_cal_rule_desc}}</td>
                        </tr>
                    </tbody>
                </table>
            </rt-data-grid>
        </div>

        <div class="tab-pane" id="c6" style="border-top: 1px dotted #d5c4c4; padding-top: 20px;">
            <rt-data-grid rt-page-record-count="vm.agentssumRecordCount" rt-page-index="vm.pageIndex" rt-page-size="vm.pageSize" rt-get-data="vm.query()" rt-rows="vm.agentssumData"
                rt-auto-height="{{tableMaxHeight}} ">
                <table class="table table-condensed table-hover ng-scope" style="white-space:nowrap;" id="rt-report-header">
                    <thead>
                        <tr>
                            <th rowspan="3">省区</th>
                            <th rowspan="3">办事处</th>
                            <th rowspan="3">代表</th>
                            <th rowspan="3">结算金额</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr ng-repeat="row in vm.agentssumData ">
                            <td>{{row.bigdepartidName}}</td>
                            <td>{{row.businessunitidName}}</td>
                            <td>{{row.owneridName}}</td>
                            <td>{{row.settle_amount|toFixNumber:2}}</td>
                        </tr>
                    </tbody>
                </table>
            </rt-data-grid>
        </div>
    </div>
</div>

<div class="sidebar sidebar-right sidebar-animate rt-shadow-border-left content-wrapper" ng-if="vm.view.type=='default'">
    <div ui-view class="content"></div>
</div>