<div class="row rt-margin-bottom-before-box">
    <div class="col-sm-8">
        <div class="btn-group">
            <button class="btn btn-link" ng-show="vm.privilege.IsExport" ng-click='vm.actions.export({
                        "code":"订单编号",
                        "BusinessUnitIdName":"省区/地区",
                        "OwnerIdName":"代表",
                        "accountidName":"客户",
                        "demandonFormat":"交货日期",
                        "paymentonFormat":"付款日期",
                        "transport_typeName":"运输方式",
                        "transport_cost_bornebyName":"运输费用承担", 
                        "payment_typeName":"付款方式", 
                        "sales_order_statusName":"订单状态", 
                        "productidName":"药品名称",
                        "productsize":"规格",
                        "price":"价格",
                        "qty":"数量",
                        "amount":"金额"
                        },"SalesOrderExport",vm.view.selectedView.ViewName)'>
            <i class="fa fa-download"></i> 导出
            </button>
        </div>
    </div>
    <div class="col-sm-4">
        <form class="input-group">
            <input type="search" placeholder="输入客户名称或订单编码快速搜索..." class="form-control" ng-model="vm.view.searchText" />
            <span class="input-group-btn" ng-click="vm.view.search(1)">
                    <button type="submit" class="btn btn-default">
                        <i class="fa fa-search"></i>
                    </button>
                </span>
        </form>
    </div>
</div>

<div ng-show="vm.filter" 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>
    <!-- /.box-header -->
    <!-- form start -->
    <form class="form-horizontal">
        <div class="box-body">

        </div>
        <!-- /.box-body -->
        <div class="box-footer">
            <div class="btn-group pull-right">
                <button class="btn btn-primary" ng-click="vm.view.search(1)">查询</button>
            </div>
        </div>
        <!-- /.box-footer -->
    </form>
</div>

<div class="box box-primary">
    <div class="box-header" style="cursor: move;">
        <div class="pull-left">
            <div class="btn-group">
                <button class="btn btn-default dropdown-toggle" id="dropdownMenuViewSelect" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                    {{vm.view.selectedView.ViewName}}
                    <span class="caret"></span>
                </button>
                <ul class="dropdown-menu" aria-labelledby="dropdownMenuViewSelect">
                    <li ng-repeat="view in vm.view.list track by view.Id" ng-click="vm.view.select(view)"><a href="javascript:void(0)">{{view.ViewName}}</a>
                    </li>
                </ul>
            </div>
            <div class="btn-group">
                <button class="btn btn-default dropdown-toggle" id="dropdownMenuBuSelect" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                    {{vm.buidSelected==null?"所有事业部":vm.buidSelected.name}}
                    <span class="caret"></span>
                </button>
                <ul class="dropdown-menu" aria-labelledby="dropdownMenuBuSelect">
                    <li ng-click="vm.buidSelected = null;"><a href="javascript:void(0)">所有事业部</a></li>
                    <li ng-repeat="item in vm.buidList" ng-click="vm.buidSelected = item;"><a href="javascript:void(0)">{{item.name}}</a>
                    </li>
                </ul>
            </div>
            <div class="btn-group">
                <button class="btn btn-default dropdown-toggle" id="dropdownMenuBigDepartSelect" data-toggle="dropdown" aria-haspopup="true"
                    aria-expanded="false">
                    {{vm.bigDepSelected==null?"所有业务线/大区":vm.bigDepSelected.name}}
                    <span class="caret"></span>
                </button>
                <ul class="dropdown-menu" aria-labelledby="dropdownMenuBigDepartSelect">
                    <li ng-click="vm.bigDepSelected = null;"><a href="javascript:void(0)">所有业务线/大区</a></li>
                    <li ng-repeat="item in vm.bigDepList" ng-click="vm.bigDepSelected = item;"><a href="javascript:void(0)">{{item.name}}</a></li>
                </ul>
            </div>
            <button class="btn btn-default" ng-class="{true:'active',false:'inactive'}[vm.view.isShowSearchList]" ng-click="vm.view.isShowSearchList = !vm.view.isShowSearchList;overHeightTable();">
                <i class="fa fa-filter"></i> 更多筛选 <i class="fa fa-angle-double-down"></i>
            </button>
        </div>
    </div>

    <div ng-show="vm.view.isShowSearchList" class="box box-widget">
        <!-- /.box-header -->
        <!-- form start -->
        <form class="form-horizontal">
            <div class="box-body">
                <div class="form-group">
                    <rt-datetime ng-model="vm.sYm" rt-type="date" rt-title="订单日期-从" rt-col="3" rt-label-col="2"></rt-datetime>
                    <rt-datetime ng-model="vm.eYm" rt-type="date" rt-title="订单日期-到" rt-col="3" rt-label-col="2"></rt-datetime>
                    <div class="btn-group" class="col-sm-2">
                        <button class="btn btn-primary" ng-click="vm.view.search(1)">查询</button>
                    </div>
                </div>
                <div class="form-group">
                    <rt-lookup2 rt-title="客户"
                    ng-model="vm.accountid" rt-get-data-name="Account.GetAccount" rt-order-by="name asc"
                    rt-col-list="[{Code:'name',Name:'客户名称'},{Code:'accountnumber',Name:'编号'}]" rt-col="3"></rt-lookup2>
                </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>
            </div>
        </form>
    </div>

    <div class="nav-tabs-custom">
        <div class="tab-content">
            <rt-data-grid rt-page-record-count="vm.page.recordCount"  rt-page-index="vm.page.index" rt-page-size="vm.page.size" rt-get-data="vm.view.search()" rt-sort-field="vm.view.sortField"
                rt-rows="vm.data" rt-selected-ids="vm.view.selectedIds" rt-auto-height="{{vm.view.autoHeight}}">
                <table class="table table-hover">
                    <thead>
                        <tr>
                            <th>
                                <rt-header-checkbox></rt-header-checkbox>
                            </th>
                            <!-- @@ 视图表头 -->
                            <th rt-field-code="code">订单编号</th>
                            <th rt-field-code="BusinessUnitIdName">省区/地区</th>
                            <th rt-field-code="OwnerIdName">代表</th>
                            <th rt-field-code="accountidName">客户</th>
                            <th rt-field-code="demandon">交货日期</th>
                            <th rt-field-code="paymenton">付款日期</th>
                            <th rt-field-code="transport_typeName">运输方式</th>
                            <th rt-field-code="transport_cost_bornebyName">运输费用承担</th>
                            <th rt-field-code="payment_typeName">付款方式</th>
                            <th rt-field-code="sales_order_statusName">订单状态</th>
                            <th>总金额</th>
                            <th>照片</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr ng-repeat="row in vm.data track by row.Id">
                            <td>
                                <rt-data-checkbox value="{{row.Id}}" />
                            </td>
                            <!-- @@ 视图列表值 -->
                            <td ng-if="vm.view.type=='default'">
                                <a id="{{row.Id}}" data-toggle="sidebar" data-target=".sidebar-right" ui-sref=".edit({id:row.Id})" ui-sref-opts="{location:true}">{{row.code}}</a>
                            </td>
                            <td ng-if="vm.view.type=='grid'">
                                <a href="javascript:;" ng-click="vm.actions.showForm(row.Id)">{{row.code}}</a>
                            </td>
                            <td>{{row.BusinessUnitId.Name}}</td>
                            <td>
                                {{row.OwnerId.Name}}
                            </td>
                            <td>
                                {{row.accountid.Name}}
                            </td>
                            <td>
                                {{row.demandon | date:"yyyy-MM-dd"}}
                            </td>
                            <td>
                                {{row.paymenton | date:"yyyy-MM-dd"}}
                            </td>
                            <td>
                                {{row.transport_typeName}}
                            </td>
                            <td>
                                {{row.transport_cost_bornebyName}}
                            </td>
                            <td>
                                {{row.payment_typeName}}
                            </td>
                            <td>
                                {{row.sales_order_status.Name}}
                            </td>
                            <td>
                                {{row.sumPrice}}
                            </td>
                            <td>
                                <a href="javascript:;" ng-click="vm.showImage(row.Id)">浏览</a>
                                <!--<span ng-if="row.photo4==0">-</span>-->
                            </td>
                        </tr>
                    </tbody>
                </table>
            </rt-data-grid>
            <!-- rt-data-grid  -->
        </div>
    </div>
</div>

<div class="sidebar sidebar-right sidebar-animate rt-shadow-border-left content-wrapper" ng-if="vm.view.type=='default'">
    <div ui-view class="content"></div>
</div>