<div class="box box-primary">
    <div class="box-header with-border">
        <h3 class="box-title">筛选</h3>
        <div class="box-tools pull-right">
            <button type="button" class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i></button>
        </div>
    </div>
    <form class="form-horizontal">
        <div class="box-body">
            <div class="form-group">
                <div class="col-sm-12">
                    <rt-datetime ng-model="vm.eYm" rt-type="month" rt-title="年月" rt-required="true" rt-col="3" rt-label-col="2">
                    </rt-datetime>
                    <label class="col-sm-2 control-label">年月的</label>
                    <div class="col-sm-3">
                        <ui-select allow-clear ng-model="vm.monthAgoSelected" theme="bootstrap">
                            <ui-select-match>{{ $select.selected.name }}</ui-select-match>
                            <ui-select-choices repeat="item in vm.monthAgoList|filter:$select.search">
                                <span ng-bind-html="item.name | highlight: $select.search"></span>
                            </ui-select-choices>
                        </ui-select>
                    </div>
                </div>
            </div>
            <div class="form-group">
                <div class="col-sm-12">
                    <rt-input ng-model="vm.salecount" rt-type="text" rt-placeholder="20" rt-title="均进货量低于" rt-required="false" rt-col="3" rt-label-col="2"></rt-input>
                </div>
            </div>
            <div class="form-group">
                <div class="col-sm-12">
                    <rt-bu-tree-lookup rt-title="部门筛选" rt-multiple="true" ng-model="vm.nodeSelected" rt-col="8" rt-label-col="2"></rt-bu-tree-lookup>
                </div>
            </div>

            <div class="form-group">
                <div class="col-sm-12">
                    <label class="col-sm-2 control-label">药品筛选</label>
                    <button class="btn" ng-class="{'btn-primary': typeSelect==='noProduct', 'btn-default':typeSelect!='noProduct'}" style="margin-left: 15px;float: left;"
                        ng-click="typeSelecttClick('noProduct')">不区分药品</button>
                    <button class="btn" ng-class="{'btn-primary': typeSelect==='Product', 'btn-default':typeSelect!='Product'}" style="margin-left: 15px;float: left;"
                        ng-click="typeSelecttClick('Product')">区分药品规格筛选</button>
                    <div class="col-sm-6" style="margin-left: -5px;" ng-if="typeSelect==='Product'">
                        <rt-lookup2-no-label ng-model="vm.productSelected" rt-get-data-name="Product.GetProductSize" rt-order-by="name asc" rt-col-list="[{Code:'name',Name:'药品名称'},{Code:'code',Name:'编号'},{Code:'size',Name:'药品品规'}]"
                            rt-multiple="true"></rt-lookup2-no-label>
                    </div>

                </div>
            </div>

            <div class="box-footer">
                <div class="btn-group pull-right">
                    <button class="btn btn-primary" ng-click="vm.pageIndex = 1;vm.search();">查询</button>
                    <button class="btn btn-default" ng-if="vm.entType==2&&selectedTab=='detail'&&typeSelect=='Product'" ng-click='vm.actions.export({
                        "entname":"客户名称",
                        "product_categoryidname":"品种",
                        "productsize":"规格",
                        "saleto_business_unit_idName":"省区/地区",
                        "BusinessUnitOwnerIdName":"经理",
                        "OwnerIdName":"代表",
                        "salecount":"当月销售",
                        "avgcount":vm.monthAgoSelected.value==1?"前一月均量":(vm.monthAgoSelected.value==3?"前三月均量":"前六月均量"),
                        "percentSTR":"对比"
                        },"ZombieHostExport","僵尸医院分析明细报表")'>导出
                    </button>
                    <button class="btn btn-default" ng-if="vm.entType==2&&selectedTab=='detail'&&typeSelect=='noProduct'" ng-click='vm.actions.export({
                        "entname":"客户名称",
                        "saleto_business_unit_idName":"省区/地区",
                        "BusinessUnitOwnerIdName":"经理",
                        "OwnerIdName":"代表",
                        "salecount":"当月销售",
                        "avgcount":vm.monthAgoSelected.value==1?"前一月均量":(vm.monthAgoSelected.value==3?"前三月均量":"前六月均量"),
                        "percentSTR":"对比"
                        },"ZombieHostExport","僵尸医院分析明细报表")'>导出
                    </button>
                    <button class="btn btn-default" ng-if="vm.entType==2&&selectedTab=='count'&&typeSelect=='Product'" class="btn btn-primary" ng-click='vm.actions.export({
                        "product_categoryidname":"品种",
                        "productsize":"规格",
                        "saleto_business_unit_idName":"省区/地区",
                        "businessunitowneridname":"经理",
                        "toaccountNum":"僵尸家数"
                                },"ZombieHostExport","僵尸医院分析统计报表")'>
                        导出
                    </button>
                    <button class="btn btn-default" ng-if="vm.entType==2&&selectedTab=='count'&&typeSelect=='noProduct'" class="btn btn-primary" ng-click='vm.actions.export({
                        "saleto_business_unit_idName":"省区/地区",
                        "businessunitowneridname":"经理",
                        "toaccountNum":"僵尸家数"
                                },"ZombieHostExport","僵尸医院分析统计报表")'>
                        导出
                    </button>
                    <button class="btn btn-default" ng-if="vm.entType==3&&selectedTab=='detail'&&typeSelect=='Product'" class="btn btn-primary" ng-click='vm.actions.export({
                        "entname":"客户名称",
                        "product_categoryidname":"品种",
                        "productsize":"规格",
                        "saleto_business_unit_idName":"省区/地区",
                        "BusinessUnitOwnerIdName":"经理",
                        "OwnerIdName":"代表",
                        "salecount":"当月销售",
                        "avgcount":vm.monthAgoSelected.value==1?"前一月均量":(vm.monthAgoSelected.value==3?"前三月均量":"前六月均量"),
                        "percentSTR":"对比"
                        },"ZombieHostExport","僵尸门店分析明细报表")'>导出
                    </button>
                    <button class="btn btn-default" ng-if="vm.entType==3&&selectedTab=='detail'&&typeSelect=='noProduct'" class="btn btn-primary" ng-click='vm.actions.export({
                        "entname":"客户名称",
                        "saleto_business_unit_idName":"省区/地区",
                        "BusinessUnitOwnerIdName":"经理",
                        "OwnerIdName":"代表",
                        "salecount":"当月销售",
                        "avgcount":vm.monthAgoSelected.value==1?"前一月均量":(vm.monthAgoSelected.value==3?"前三月均量":"前六月均量"),
                        "percentSTR":"对比"
                        },"ZombieHostExport","僵尸门店分析明细报表")'>导出
                    </button>
                    <button class="btn btn-default" ng-if="vm.entType==3&&selectedTab=='count'&&typeSelect=='Product'" class="btn btn-primary" ng-click='vm.actions.export({
                        "product_categoryidname":"品种",
                        "productsize":"规格",
                        "saleto_business_unit_idName":"省区/地区",
                        "businessunitowneridname":"经理",
                        "toaccountNum":"僵尸家数"
                                },"ZombieHostExport","僵尸门店分析统计报表")'>
                        导出
                    </button>
                    <button class="btn btn-default" ng-if="vm.entType==3&&selectedTab=='count'&&typeSelect=='noProduct'" class="btn btn-primary" ng-click='vm.actions.export({
                        "saleto_business_unit_idName":"省区/地区",
                        "businessunitowneridname":"经理",
                        "toaccountNum":"僵尸家数"
                                },"ZombieHostExport","僵尸门店分析统计报表")'>
                        导出
                    </button>
                    <button class="btn btn-default" ng-if="vm.entType==4&&selectedTab=='detail'&&typeSelect=='Product'" class="btn btn-primary"
                        ng-click='vm.actions.export({
                        "entname":"客户名称",
                        "product_categoryidname":"品种",
                        "productsize":"规格",
                        "saleto_business_unit_idName":"省区/地区",
                        "BusinessUnitOwnerIdName":"经理",
                        "OwnerIdName":"代表",
                        "drugidName":"药品名称",
                        "salecount":"当月销售",
                        "avgcount":vm.monthAgoSelected.value==1?"前一月均量":(vm.monthAgoSelected.value==3?"前三月均量":"前六月均量"),
                        "percentSTR":"对比"
                        },"ZombieHostExport","僵尸基层医疗机构分析明细报表")'>
                        导出
                    </button>
                    <button class="btn btn-default" ng-if="vm.entType==4&&selectedTab=='detail'&&typeSelect=='noProduct'" class="btn btn-primary"
                        ng-click='vm.actions.export({
                        "entname":"客户名称",
                        "saleto_business_unit_idName":"省区/地区",
                        "BusinessUnitOwnerIdName":"经理",
                        "OwnerIdName":"代表",
                        "salecount":"当月销售",
                        "avgcount":vm.monthAgoSelected.value==1?"前一月均量":(vm.monthAgoSelected.value==3?"前三月均量":"前六月均量"),
                        "percentSTR":"对比"
                        },"ZombieHostExport","僵尸基层医疗机构分析明细报表")'>
                        导出
                    </button>
                    <button class="btn btn-default" ng-if="vm.entType==4&&selectedTab=='count'&&typeSelect=='Product'" class="btn btn-primary" ng-click='vm.actions.export({
                        "product_categoryidname":"品种",
                        "productsize":"规格",
                        "saleto_business_unit_idName":"省区/地区",
                        "businessunitowneridname":"经理",
                        "toaccountNum":"僵尸家数"
                        },"ZombieHostExport","僵尸基层医疗机构分析统计报表")'>
                        导出
                    </button>
                    <button class="btn btn-default" ng-if="vm.entType==4&&selectedTab=='count'&&typeSelect=='noProduct'" class="btn btn-primary" ng-click='vm.actions.export({
                        "saleto_business_unit_idName":"省区/地区",
                        "businessunitowneridname":"经理",
                        "toaccountNum":"僵尸家数"
                        },"ZombieHostExport","僵尸基层医疗机构分析统计报表")'>
                        导出
                    </button>
                </div>
            </div>
        </div>
    </form>
</div>

<div class="box box-primary" style="float:left;">
    <div class="box-header with-border">
        <h4 class="box-title" style="font-size: 14px;">
            <ul class="nav nav-tabs">
                <li class="active" ng-click="selectTab('detail')">
                    <a href="#c1" onclick="return false;" data-toggle="tab">明细</a>
                </li>
                <li ng-click="selectTab('count')">
                    <a href="#c2" onclick="return false;" data-toggle="tab">统计</a>
                </li>
            </ul>
        </h4>
        <div class="box-tools pull-right">
            <button type="button" class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i></button>
        </div>
    </div>
    <div class="box-body active" id="c1" ng-if="selectedTab=='detail'">
        <rt-data-grid rt-page-record-count="vm.recordCount" rt-page-index="vm.pageIndex" rt-page-size="vm.pageSize" rt-get-data="vm.search()"
            rt-rows="vm.data" rt-auto-height=" {{tableMaxHeight}}">
            <table class="table table-condensed table-hover ng-scope" style="white-space: nowrap;">
                <thead>
                    <tr id="rt-report-header">
                        <th class="rt-text-align">客户名称</th>
                        <th class="rt-text-align" ng-if="vm.showType=='showProduct'">品种</th>
                        <th class="rt-text-align" ng-if="vm.showType=='showProduct'">规格</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">{{vm.monthAgoSelected.name}}均量</th>
                        <th class="rt-number-align">对比</th>
                    </tr>
                </thead>
                <tbody>
                    <tr ng-repeat="row in vm.data">
                        <td class="rt-text-align">{{row.entname}}</td>
                        <td class="rt-text-align" ng-if="vm.showType=='showProduct'">{{row.product_categoryidname}}</td>
                        <td class="rt-text-align" ng-if="vm.showType=='showProduct'">{{row.productsize}}</td>
                        <td class="rt-text-align">{{row.saleto_business_unit_idName}}</td>
                        <td class="rt-text-align">{{row.BusinessUnitOwnerIdName}}</td>
                        <td class="rt-text-align">{{row.OwnerIdName}}</td>
                        <td class="rt-number-align">{{row.salecount}}</td>
                        <td class="rt-number-align">{{row.avgcount}}</td>
                        <td class="rt-number-align">{{row.percent|toFixNumber:2}}%</td>
                    </tr>
                </tbody>
            </table>

        </rt-data-grid>
    </div>

    <div class="box-body" id="c2" ng-if="selectedTab=='count'">
        <rt-data-grid rt-page-record-count="vm.recordCount" rt-page-index="vm.pageIndex" rt-page-size="vm.pageSize" rt-get-data="vm.search()"
            rt-rows="vm.data" rt-auto-height=" {{tableMaxHeight}}">
            <table class="table table-condensed table-hover ng-scope" style="white-space: nowrap;">
                <thead>
                    <tr id="rt-report-header">
                        <th class="rt-text-align" ng-if="vm.showType=='showProduct'">品种</th>
                        <th class="rt-text-align" ng-if="vm.showType=='showProduct'">规格</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.data">
                        <td class="rt-text-align" ng-if="vm.showType=='showProduct'">{{row.product_categoryidname}}</td>
                        <td class="rt-text-align" ng-if="vm.showType=='showProduct'">{{row.productsize}}</td>
                        <td class="rt-text-align">{{row.saleto_business_unit_idName}}</td>
                        <td class="rt-text-align">{{row.businessunitowneridname}}</td>
                        <td class="rt-number-align">{{row.toaccountNum}}</td>
                    </tr>
                </tbody>
            </table>
        </rt-data-grid>
    </div>
</div>