<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.startYM" rt-type="month" rt-title="开始年月" rt-required="true" rt-col="3" rt-label-col="2">
        </rt-datetime>
        <rt-datetime ng-model="vm.endYM" 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.search()">查询</button>
        </div>
        <div class="col-sm-1">
            <button class="btn btn-primary" ng-click='vm.actions.export({},"TerminalSalesReportExport","终端纯销明细统计")'>导出
            </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.provinceSelected" theme="bootstrap">
                <ui-select-match>{{ $select.selected.name }}</ui-select-match>
                <ui-select-choices repeat="item in vm.provinceList |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.citySelected" theme="bootstrap">
                <ui-select-match>{{ $select.selected.name }}</ui-select-match>
                <ui-select-choices repeat="item in vm.cityList |filter:$select.search">
                    <span ng-bind-html="item.name | highlight: $select.search"></span>
                </ui-select-choices>
            </ui-select>
        </div>
        <div class="col-sm-1">
            <button class="btn btn-clear btn-small" ng-click="vm.isShowMoreSearch = !vm.isShowMoreSearch">
                            <i ng-if="!vm.isShowMoreSearch" class="fa fa-angle-double-down" style="color:#0099ff;" title="更多查询条件"></i>
            <i ng-if="vm.isShowMoreSearch" class="fa fa-angle-double-up" style="color:#0099ff;" title="隐藏"></i>
            </button>
        </div>
    </div>
    <div class="form-group" ng-hide="!vm.isShowMoreSearch">
        <label class="col-sm-2 control-label">下游类型</label>
        <div class="col-sm-3">
            <ui-select allow-clear ng-model="vm.entTypeSelected" theme="bootstrap">
                <ui-select-match>{{$select.selected.Name}}</ui-select-match>
                <ui-select-choices repeat="item in vm.entTypeList | filter: $select.search">
                    <span ng-bind-html="item.Name| highlight: $select.search"></span>
                </ui-select-choices>
            </ui-select>
        </div>
        <rt-lookup2 rt-label-col="2" rt-title="产品名称" ng-model="vm.products" rt-get-data-name="Product.GetProductSize" rt-order-by="name asc"
            rt-col-list="[{Code:'name',Name:'产品名称'},{Code:'size',Name:'规格'},{Code:'code',Name:'产品编码'}]" rt-multiple="true" rt-col="3"></rt-lookup2>
    </div>
</form>
<div class="row" style="border-top: 1px dotted #d5c4c4; padding-top: 20px">
    <rt-data-grid rt-page-record-count="vm.recordCount" rt-get-data="vm.search()" rt-auto-height=" {{tableMaxHeight}}" rt-page-index="vm.index" rt-page-size="vm.pageSize"
        rt-rows="vm.reportData">
        <table class="table table-condensed table-hover ng-scope" style="white-space: nowrap;">
            <thead>
                <tr id="rt-report-header">
                    <th>上游企业</th>
                    <th>省份</th>
                    <th>城市</th>
                    <th>下游企业</th>
                    <th>下游类型</th>
                    <th>产品名称</th>
                    <th>规格</th>
                    <th ng-repeat="colName in vm.monthColName">{{colName}}</th>
                    <th>产品总销量</th>
                </tr>
            </thead>
            <tbody>
                <tr ng-repeat="row in vm.reportData">
                    <td>{{row.fromaccountidname}}</td>
                    <td>{{row.toprovinceidname}}</td>
                    <td>{{row.tocityidname}}</td>
                    <td>{{row.saleto_entname}}</td>
                    <td>{{row.toenttypename}}</td>
                    <td>{{row.drugidname}}</td>
                    <td>{{row.productsize}}</td>
                    <td ng-repeat="mitem in row.monthList track by $index" class="rt-number-align">{{mitem}}</td>
                    <td class="rt-number-align">{{vm.monthtotal[$index]}}</td>
                </tr>
                <tr ng-if="vm.pagetotal!=undefined">
                    <td colspan="7">合计销量</td>
                    <td ng-repeat="mitem2 in vm.everymonthtotal track by $index"  class="rt-number-align">{{mitem2}}</td>
                    <td class="rt-number-align">{{vm.pagetotal}}</td>
                </tr>
            </tbody>
        </table>
    </rt-data-grid>
    <div class="row" style="padding-top: 15px;width: 100%;"  ng-if="vm.pagetotal!=undefined">
        <span style="float: right;">总计 销量： {{vm.totalSum}}</span>
    </div>
</div>