<form class="form-horizontal">
    <div class="form-group">
        <rt-datetime ng-model="vm.sYM" rt-type="date" rt-title="日期从" rt-required="true" rt-col="3" rt-label-col="1">
        </rt-datetime>
        <rt-datetime ng-model="vm.eYM" rt-type="date" rt-title="到" rt-required="true" rt-col="3" rt-label-col="1">
        </rt-datetime>
        <div class="col-sm-1">
            <button class="btn btn-primary" ng-click="vm.showReportButton()">查询</button>
        </div>
        <div class="col-sm-1">
            <button class="btn btn-primary" ng-click='vm.actions.export({},"TrainingActivitiesReportExport",(selectedTab=="detail"?"门店培训活动明细":(selectedTab=="groupByAccount"?"门店培训活动按门店统计":(selectedTab=="groupByOwner"?"门店培训活动按代表统计":"门店培训活动按部门统计"))))'>导出
            </button>
        </div>
        <div class="col-sm-1">
            <button class="btn btn-clear btn-small" ng-click="vm.isShowMoreSearch=!vm.isShowMoreSearch;complateTableheight();">
                    <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">
        <rt-bu-tree-lookup rt-title="部门" rt-multiple="true" ng-model="vm.nodeSelected" rt-col="3" rt-label-col="1"></rt-bu-tree-lookup>
        <rt-lookup2 rt-title="代表" rt-multiple="true" ng-model="vm.ownerSelected" rt-get-data-name="UserInfo.GetUserByOption2"
            rt-order-by="name asc" rt-col-list="[{Code:'name',Name:'姓名'},{Code:'code',Name:'编号'}]" rt-params="{'@buId':'','@bigDepId':'','in@depId':vm.nodeSelected?vm.nodeSelected.ids:''}"
            rt-col="3" rt-label-col="1"></rt-lookup2>
    </div>

    <div class="form-group" ng-hide="!vm.isShowMoreSearch">
        <rt-input rt-type="text" rt-title="活动名称" rt-col="3" rt-label-col="1" ng-model="vm.srhdname"></rt-input>
    </div>
</form>

<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('groupByAccount')">
        <a href="#c2" onclick="return false;" data-toggle="tab">按门店统计</a>
    </li>
    <li ng-click="selectTab('groupByOwner')">
        <a href="#c3" onclick="return false;" data-toggle="tab">按代表统计</a>
    </li>
    <li ng-click="selectTab('groupByBus')">
        <a href="#c4" onclick="return false;" data-toggle="tab">按部门统计</a>
    </li>
</ul>

<div class="row active" style="border-top: 1px dotted #d5c4c4; padding-top: 20px" id="c1" ng-if="selectedTab=='detail'">
    <div class="col-sm-30">
        <rt-data-grid rt-page-record-count="vm.recordCount" rt-get-data="vm.showReport()" rt-page-index="vm.index" rt-page-size="vm.pageSize" rt-rows="vm.reportData">
            <table class="table table-hover" style="white-space:nowrap;" id="rt-report-header">
                <thead>
                    <tr id="rt-report-header">
                        <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-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>
                    </tr>
                </thead>
                <tbody>
                    <tr ng-repeat="row in vm.reportData">
                        <!-- 判断数据为空时，将数据设置为“-” -->
                        <td class="rt-text-align">
                            {{row.hdname == null ? "-" : row.hdname}}
                        </td>
                        <td class="rt-text-align">
                            {{row.BusinessUnitIdName == null ? "-" : row.BusinessUnitIdName}}
                        </td>
                        <td class="rt-text-align">
                            {{row.OwnerIdName == null ? "-" : row.OwnerIdName}}
                        </td>
                        <td class="rt-text-align">{{row.accountIdName == null ? "-" : row.accountIdName}}</td>
                        <td class="rt-text-align">{{row.contactIdName == null ? "-" : row.contactIdName}}</td>
                        <td class="rt-text-align">{{row.CreatedOn == null ? "-" : row.CreatedOn | date:'yyyy-MM-dd HH:mm'}}</td>
                        <td class="rt-text-align">{{row.mobiletelephone == null ? "-" : row.mobiletelephone}}</td>
                        <td class="rt-text-align">{{row.exam_end_time == null ? "-" : row.exam_end_time | date:'yyyy-MM-dd HH:mm'}}</td>
                        <td class="rt-text-align">{{row.reward_content == null ? "-" : row.reward_content}}</td>
                        <td class="rt-number-align">{{row.reward_fee == null ? "-" : row.reward_fee| toFixNumber:2 }}</td>
                    </tr>
                </tbody>
            </table>
        </rt-data-grid>
    </div>
</div>

<div class="row" style="border-top: 1px dotted #d5c4c4; padding-top: 20px" id="c2" ng-if="selectedTab=='groupByAccount'">
    <div class="col-sm-30">
        <rt-data-grid rt-page-record-count="vm.recordCount" rt-get-data="vm.showReport()" rt-page-index="vm.index" rt-page-size="vm.pageSize" rt-rows="vm.reportData">
            <table class="table table-hover" style="white-space:nowrap;" id="rt-report-header">
                <thead>
                    <tr id="rt-report-header">
                        <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>
                    </tr>
                </thead>
                <tbody>
                    <tr ng-repeat="row in vm.reportData">
                        <!-- 判断数据为空时，将数据设置为“-” -->
                        <td class="rt-text-align">
                            {{row.hdname == null ? "-" : row.hdname}}
                        </td>
                        <td class="rt-text-align">
                            {{row.BusinessUnitIdName == null ? "-" : row.BusinessUnitIdName}}
                        </td>
                        <td class="rt-text-align">
                            {{row.OwnerIdName == null ? "-" : row.OwnerIdName}}
                        </td>
                        <td class="rt-text-align">{{row.accountIdName == null ? "-" : row.accountIdName}}</td>
                        <td class="rt-number-align">{{row.reward_qty_total}}</td>
                        <td class="rt-number-align">{{row.reward_fee_total| toFixNumber:2 }}</td>
                    </tr>
                </tbody>
            </table>
        </rt-data-grid>
    </div>
</div>

<div class="row" style="border-top: 1px dotted #d5c4c4; padding-top: 20px" id="c3" ng-if="selectedTab=='groupByOwner'">
    <div class="col-sm-30">
        <rt-data-grid rt-page-record-count="vm.recordCount" rt-get-data="vm.showReport()" rt-page-index="vm.index" rt-page-size="vm.pageSize" rt-rows="vm.reportData">
            <table class="table table-hover" style="white-space:nowrap;" id="rt-report-header">
                <thead>
                    <tr id="rt-report-header">
                        <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>
                    </tr>
                </thead>
                <tbody>
                    <tr ng-repeat="row in vm.reportData">
                        <!-- 判断数据为空时，将数据设置为“-” -->
                        <td class="rt-text-align">
                            {{row.hdname == null ? "-" : row.hdname}}
                        </td>
                        <td class="rt-text-align">
                            {{row.BusinessUnitIdName == null ? "-" : row.BusinessUnitIdName}}
                        </td>
                        <td class="rt-text-align">{{row.OwnerIdName == null ? "-" : row.OwnerIdName}}</td>
                        <td class="rt-number-align">{{row.reward_qty_total}}</td>
                        <td class="rt-number-align">{{row.reward_fee_total| toFixNumber:2 }}</td>
                    </tr>
                </tbody>
            </table>
        </rt-data-grid>
    </div>
</div>

<div class="row" style="border-top: 1px dotted #d5c4c4; padding-top: 20px" id="c4" ng-if="selectedTab=='groupByBus'">
    <div class="col-sm-30">
        <rt-data-grid rt-page-record-count="vm.recordCount" rt-get-data="vm.showReport()" rt-page-index="vm.index" rt-page-size="vm.pageSize" rt-rows="vm.reportData">
            <table class="table table-hover" style="white-space:nowrap;" id="rt-report-header">
                <thead>
                    <tr id="rt-report-header">
                        <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>
                    </tr>
                </thead>
                <tbody>
                    <tr ng-repeat="row in vm.reportData">
                        <!-- 判断数据为空时，将数据设置为“-” -->
                        <td class="rt-text-align">
                            {{row.hdname == null ? "-" : row.hdname}}
                        </td>
                        <td class="rt-text-align">
                            {{row.bigDeptIdName == null ? "-" : row.bigDeptIdName}}
                        </td>
                        <td class="rt-text-align">
                            {{row.BusinessUnitIdName == null ? "-" : row.BusinessUnitIdName}}
                        </td>
                        <td class="rt-number-align">{{row.reward_qty_total}}</td>
                        <td class="rt-number-align">{{row.reward_fee_total| toFixNumber:2 }}</td>
                    </tr>
                </tbody>
            </table>
        </rt-data-grid>
    </div>
</div>