<style>
    #rt-report-table > thead > tr > th {
        vertical-align: inherit;
        border: 1px solid #f0f0f0;
        color: #555;
        font-weight: 500;
        white-space: nowrap;
    }
    
    #rt-report-table > tbody > tr > td {
        vertical-align: inherit;
        border: 1px solid #f0f0f0;
        color: #555;
        font-weight: 500;
        white-space: nowrap;
    }
</style>
<div class="row">
    <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-5">
            </div>
            <div class="col-sm-1">
                <button class="btn btn-primary" ng-click="vm.showReportButton()">查询</button>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label">事业部</label>

            <div class="col-sm-3">
                <ui-select allow-clear ng-model="vm.buidSelected" theme="bootstrap">
                    <ui-select-match>{{ $select.selected.name }}</ui-select-match>
                    <ui-select-choices repeat="item in vm.buidList|filter:$select.search">
                        <span ng-bind-html="item.name | highlight: $select.search"></span>
                    </ui-select-choices>
                </ui-select>
            </div>
            <label class="col-sm-2 control-label">业务线/大区</label>

            <div class="col-sm-3">
                <ui-select allow-clear ng-model="vm.bigDepSelected" theme="bootstrap">
                    <ui-select-match>{{ $select.selected.name }}</ui-select-match>
                    <ui-select-choices repeat="item in vm.bigDepList |filter:$select.search">
                        <span ng-bind-html="item.name | highlight: $select.search"></span>
                    </ui-select-choices>
                </ui-select>
            </div>

        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label">省区/地区</label>
            <div class="col-sm-8">
                <ui-select class="form" multiple allow-clear sortable="true" theme="bootstrap" close-on-select="false" ng-model="vm.businessUnitSelected">
                    <ui-select-match>{{$item.name}}</ui-select-match>
                    <ui-select-choices repeat="item in vm.businessUnitList | filter: {name: $select.search}">
                        <span ng-bind-html="item.name | highlight: $select.search"></span>
                    </ui-select-choices>
                </ui-select>
            </div>
        </div>
    </form>
</div>

<ul class="nav nav-tabs">
    <li class="active" ng-click="selectTab('tab1')">
        <a href="#c1" onclick="return false;" data-toggle="tab">结算汇总</a>
    </li>
    <li ng-click="selectTab('tab2')">
        <a href="#c2" onclick="return false;" data-toggle="tab">结算明细</a>
    </li>
    <button style="margin-top: 5px; float: right;margin-right: 65px;" ng-show="vm.isShow=='sum'" class="col-sm-1 btn btn-primary"
        ng-click='vm.actions.export({
                "business_unit_idName":"部门",
                "from_owneridName":"代表",
                "fromaccountidName":"商业",
                "total_price_number":"开票金额"
                },"BizAccountReportSumExport","商业开票金额汇总")'>导出
        </button>
        <button style="margin-top: 5px; float: right;margin-right: 65px;" ng-show="vm.isShow=='detail'" class="col-sm-1 btn btn-primary"
            ng-click='vm.actions.export({
                "business_unit_idName":"部门",
                "from_owneridName":"代表",
                "fromaccountidName":"商业",
                "toaccountidName":"终端客户",
                "drugidName":"品种",
                "saleto_count":"数量",
                "invoice_price_number":"开票价格",
                "total_price_number":"开票金额"
                },"BizAccountReportDetailExport","商业开票金额明细")'>导出
            </button>
</ul>

<div class="tab-content">
    <div class="row" ng-show="vm.isShow=='sum'">
        <rt-data-grid rt-page-record-count="vm.recordSumCount" rt-get-data="vm.showReport()" rt-page-index="vm.index" rt-page-size="vm.pageSize" rt-rows="vm.reportSumData">
            <table class="table table-condensed table-hover ng-scope" style="white-space: nowrap;" id="rt-report-table">
                <thead>
                    <tr>
                        <th class="rt-text-align">部门</th>
                        <th class="rt-text-align">代表</th>
                        <th class="rt-text-align">商业</th>
                        <th class="rt-number-align">计算金额</th>
                    </tr>
                </thead>
                <tbody>
                    <tr ng-repeat="row in vm.reportSumData">
                        <td class="rt-text-align">
                            {{row.business_unit_idName == null ? '-' : row.business_unit_idName}}
                        </td>
                        <td class="rt-text-align">
                            {{row.from_owneridName == null ? '-' : row.from_owneridName}}
                        </td>
                        <td class="rt-text-align">
                            {{row.fromaccountidName == null ? '-' : row.fromaccountidName}}
                        </td>
                        <td class="rt-number-align">
                            {{row.total_price == null ? 0 : row.total_price|toFixNumber:2}}
                        </td>
                    </tr>
                </tbody>
            </table>
        </rt-data-grid>
    </div>
    <div class="row" ng-show="vm.isShow=='detail'">
        <rt-data-grid rt-page-record-count="vm.recordDetailCount" rt-get-data="vm.showReport()" rt-page-index="vm.index" rt-page-size="vm.pageSize" rt-rows="vm.reportDetailData">
            <table class="table table-condensed table-hover ng-scope" style="white-space: nowrap;" id="rt-report-table">
                <thead>
                    <tr>
                        <th class="rt-text-align">部门</th>
                        <th class="rt-text-align">代表</th>
                        <th class="rt-text-align">商业</th>
                        <th class="rt-text-align">终端客户</th>
                        <th class="rt-text-align">品种</th>
                        <th class="rt-number-align">数量</th>
                        <th class="rt-number-align">开票价格</th>
                        <th class="rt-number-align">开票金额</th>
                    </tr>
                </thead>
                <tbody>
                    <tr ng-repeat="row in vm.reportDetailData">
                        <td class="rt-text-align">
                            {{row.business_unit_idName == null ? '-' : row.business_unit_idName}}
                        </td>
                        <td class="rt-text-align">
                            {{row.from_owneridName == null ? '-' : row.from_owneridName}}
                        </td>
                        <td class="rt-text-align">
                            {{row.fromaccountidName == null ? '-' : row.fromaccountidName}}
                        </td>
                        <td class="rt-text-align">
                            {{row.toaccountidName == null ? '-' : row.toaccountidName}}
                        </td>
                        <td class="rt-text-align">{{row.drugidName}}</td>
                        <td class="rt-number-align">{{row.saleto_count|toFixNumber:1}}</td>
                        <td class="rt-number-align">{{row.invoice_price|toFixNumber:2}}</td>
                        <td class="rt-number-align">{{row.total_price|toFixNumber:2}}</td>
                    </tr>
                </tbody>
            </table>
        </rt-data-grid>
    </div>
</div>