<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.sYm" rt-type="month" rt-title="年月" rt-required="true" rt-col="3" rt-label-col="2"></rt-datetime>
        <rt-picklist    rt-title="商业级别"
                        rt-label-col="2"
                        rt-col="3"
                        ng-model="vm.accLevelSelected"
                        rt-required="true"
                        rt-options="vm.picklist.acc_level"></rt-picklist>
        <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({
                        "BusinessUnitIdName":"省区/地区",
                        "productidName":"品种",
                        "accountnumber":"商业编码",
                        "accountidName":"商业公司",
                        "acc_levelName":"商业级别",
                        "OwnerIdName":"商务代表",
                        "inv_qty":"期初库存",
                        "in_qty":"当月购进",
                        "out_qty":"当月销售",
                        "theory_qty":"理论库存结余",
                        "safe_inv_qty":"安全库存",
                        "diff_qty":"差异值"
                        },"PsiExport","商业进销存")'>导出</button>
        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-2 control-label"><span style="color:red;">*</span>事业部</label>
        <div class="col-sm-8">
            <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>

        <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">
        <label class="col-sm-2 control-label"><span style="color:red;"></span>业务线/大区</label>
        <div class="col-sm-8">
            <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" ng-hide="!vm.isShowMoreSearch">
        <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"
                ng-click="vm.ClickBusiness()">
                <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>
    <div class="form-group" ng-hide="!vm.isShowMoreSearch">
        <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.productSelected">
                <ui-select-match>{{$item.name}}</ui-select-match>
                <ui-select-choices repeat="item in vm.productList | filter: {name: $select.search}">
                    <span ng-bind-html="item.name | highlight: $select.search"></span>
                </ui-select-choices>
            </ui-select>
        </div>
    </div>
    <div class="form-group" ng-hide="!vm.isShowMoreSearch">
        <rt-lookup2 rt-title="商业公司" rt-multiple="true" rt-disabled="vm.form.data.StateCode.Value == 1" ng-model="vm.accSelected"
            rt-get-data-name="Account.GetAccountByBigDepAndUnit" rt-order-by="name asc" rt-col-list="[{Code:'name',Name:'商业公司'},{Code:'accountnumber',Name:'编号'}]"
            rt-params="{'@accType':1,'@bigDepId':vm.bigDepSelected?vm.bigDepSelected.id:'','@DepId':vm.paramUnitids,'in@DepId':vm.paramUnitids}"
            rt-col="8"></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-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>省区/地区</th>
                    <th>品种</th>
                    <th>商业编码</th>
                    <th>商业公司</th>
                    <th>商业级别</th>
                    <th>商务代表</th>
                    <th>期初库存</th>
                    <th>当月购进</th>
                    <th>当月销售</th>
                    <th>理论库存结余</th>
                    <th>安全库存</th>
                    <th>差异值</th>
                </tr>
            </thead>
            <tbody>
                <tr ng-repeat="row in vm.data">
                    <td>{{row.BusinessUnitIdName}}</td>
                    <td>{{row.productidName}}</td>
                    <td>{{row.accountnumber }}</td>
                    <td>{{row.accountidName}}</td>
                    <td>{{row.acc_levelName}}</td>
                    <td>{{row.OwnerIdName}}</td>
                    <td>{{row.inv_qty}}</td>
                    <td>{{row.in_qty}}</td>
                    <td>{{row.out_qty}}</td>
                    <td>{{row.theory_qty}}</td>
                    <td>{{row.safe_inv_qty}}</td>
                    <td>{{row.diff_qty}}</td>
                </tr>
            </tbody>
        </table>
    </rt-data-grid>
</div>