<div class="row rt-margin-bottom-before-box">
    <div class="col-sm-8">
        <div class="btn-group">
            <!-- <button class="btn btn-link" ng-disabled="false" ng-show="vm.privilege.IsWrite" ng-click='vm.actions.import({
                            Title:"商业发货",
                            ModuleName:"DeliveryImport",
                            EntityName:"delivery",
                            Columns:[
                                {ColumnName:"year",DisplayName:"年",IsRequired:false,IsKey:false},
                                {ColumnName:"month",DisplayName:"月",IsRequired:false,IsKey:false},
                                {ColumnName:"delivery_date",DisplayName:"发货日期*",IsRequired:true,IsKey:false},
                                {ColumnName:"delivery_no",DisplayName:"发货单号*",IsRequired:true,IsKey:true},
                                {ColumnName:"lotno",DisplayName:"批号",IsRequired:false,IsKey:false},
                                {ColumnName:"agent_accountid",DisplayName:"代理商",IsRequired:false,IsKey:false},
                                {ColumnName:"acc_number",DisplayName:"客户编码",IsRequired:false,IsKey:false},
                                {ColumnName:"accountid",DisplayName:"客户名称*",IsRequired:true,IsKey:false},
                                {ColumnName:"OwnerId",DisplayName:"负责人*",IsRequired:true,IsKey:false},
                                {ColumnName:"BusinessUnitId",DisplayName:"省区/地区",IsRequired:false,IsKey:false},
                                {ColumnName:"erp_code",DisplayName:"药品ERP编码",IsRequired:false,IsKey:false},
                                {ColumnName:"productid",DisplayName:"药品名称*",IsRequired:true,IsKey:true},
                                {ColumnName:"product_size",DisplayName:"药品规格*",IsRequired:true,IsKey:true},
                                {ColumnName:"delivery_count",DisplayName:"发货数量*",IsRequired:true,IsKey:false},
                                {ColumnName:"unit_price",DisplayName:"单价",IsRequired:false,IsKey:false},
                                {ColumnName:"floor_price",DisplayName:"底价",IsRequired:false,IsKey:false},
                                {ColumnName:"delivery_amount",DisplayName:"金额*",IsRequired:true,IsKey:false}
                            ]
                        })'>
                <i class="fa fa-upload"></i> 导入
            </button> -->
            <button class="btn btn-link dropdown-toggle" id="dropdownMenuImportSelect" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"
                ng-show="vm.privilege.IsWrite">
                <i class="fa fa-upload"></i>导入
                <span class="caret"></span>
            </button>
            <ul class="dropdown-menu" aria-labelledby="dropdownMenuImportSelect" ng-show="vm.privilege.IsWrite">
                <li>
                    <a href="javascript:void(0)" ng-click='vm.actions.import({
                            Title:"商业发货",
                            ModuleName:"DeliveryImport",
                            EntityName:"delivery",
                            Columns:[
                                {ColumnName:"year",DisplayName:"年",IsRequired:false,IsKey:false},
                                {ColumnName:"month",DisplayName:"月",IsRequired:false,IsKey:false},
                                {ColumnName:"delivery_date",DisplayName:"发货日期*",IsRequired:true,IsKey:false},
                                {ColumnName:"delivery_no",DisplayName:"发货单号*",IsRequired:true,IsKey:true},
                                {ColumnName:"lotno",DisplayName:"批号",IsRequired:false,IsKey:false},
                                {ColumnName:"agent_accountid",DisplayName:"代理商",IsRequired:false,IsKey:false},
                                {ColumnName:"acc_number",DisplayName:"客户编码",IsRequired:false,IsKey:false},
                                {ColumnName:"accountid",DisplayName:"客户名称*",IsRequired:true,IsKey:false},
                                {ColumnName:"OwnerId",DisplayName:"负责人*",IsRequired:true,IsKey:false},
                                {ColumnName:"BusinessUnitId",DisplayName:"省区/地区",IsRequired:false,IsKey:false},
                                {ColumnName:"erp_code",DisplayName:"药品ERP编码",IsRequired:false,IsKey:false},
                                {ColumnName:"productid",DisplayName:"药品名称*",IsRequired:true,IsKey:true},
                                {ColumnName:"product_size",DisplayName:"药品规格*",IsRequired:true,IsKey:true},
                                {ColumnName:"delivery_count",DisplayName:"发货数量*",IsRequired:true,IsKey:false},
                                {ColumnName:"unit_price",DisplayName:"单价",IsRequired:false,IsKey:false},
                                {ColumnName:"floor_price",DisplayName:"底价",IsRequired:false,IsKey:false},
                                {ColumnName:"delivery_amount",DisplayName:"金额*",IsRequired:true,IsKey:false}
                            ]
                        },1)'>
                        <i class="fa fa-upload"></i>导入(按单号+规格)</a>
                </li>
                <li>
                    <a href="javascript:void(0)" ng-click='vm.actions.import({
                            Title:"商业发货",
                            ModuleName:"DeliveryImport",
                            EntityName:"delivery",
                            Columns:[
                                {ColumnName:"year",DisplayName:"年",IsRequired:false,IsKey:false},
                                {ColumnName:"month",DisplayName:"月",IsRequired:false,IsKey:false},
                                {ColumnName:"delivery_date",DisplayName:"发货日期*",IsRequired:true,IsKey:false},
                                {ColumnName:"delivery_no",DisplayName:"发货单号*",IsRequired:true,IsKey:true},
                                {ColumnName:"lotno",DisplayName:"批号*",IsRequired:true,IsKey:true},
                                {ColumnName:"agent_accountid",DisplayName:"代理商",IsRequired:false,IsKey:false},
                                {ColumnName:"acc_number",DisplayName:"客户编码",IsRequired:false,IsKey:false},
                                {ColumnName:"accountid",DisplayName:"客户名称*",IsRequired:true,IsKey:false},
                                {ColumnName:"OwnerId",DisplayName:"负责人*",IsRequired:true,IsKey:false},
                                {ColumnName:"BusinessUnitId",DisplayName:"省区/地区",IsRequired:false,IsKey:false},
                                {ColumnName:"erp_code",DisplayName:"药品ERP编码",IsRequired:false,IsKey:false},
                                {ColumnName:"productid",DisplayName:"药品名称*",IsRequired:true,IsKey:true},
                                {ColumnName:"product_size",DisplayName:"药品规格*",IsRequired:true,IsKey:true},
                                {ColumnName:"delivery_count",DisplayName:"发货数量*",IsRequired:true,IsKey:false},
                                {ColumnName:"unit_price",DisplayName:"单价",IsRequired:false,IsKey:false},
                                {ColumnName:"floor_price",DisplayName:"底价",IsRequired:false,IsKey:false},
                                {ColumnName:"delivery_amount",DisplayName:"金额*",IsRequired:true,IsKey:false}
                            ]
                        },2)'>
                        <i class="fa fa-upload"></i>导入(按单号+批号+规格)</a>
                </li>
            </ul>
            <button class="btn btn-link" ng-show="vm.privilege.IsExport" ng-click='vm.actions.export({
                        "year":"年",
                        "month":"月",
                        "delivery_date":"发货日期*|datetime|yyyy/MM/dd",
                        "delivery_no":"发货单号*",
                        "lotno":"批号",
                        "acc_number":"客户编码",
                        "accountidName":"客户名称*",
                        "OwnerIdName":"负责人*",
                        "agent_accountidName":"代理商",
                        "provinceidName":"省份",
                        "cityidName":"城市",
                        "BusinessUnitIdName":"省区/地区",
                        "erp_code":"药品ERP编码",
                        "productidName":"药品名称*",
                        "product_size":"药品规格*",
                        "unit_price":"单价",
                        "amountOfmoney":"金额",
                        "delivery_count":"发货数量*",
                        "product_package":"件包装",
                        "package_qty":"件数",
                        "floor_price":"底价",
                        "floorOfmoney":"底价金额"
                        })'>
                <i class="fa fa-download"></i> 导出
            </button>
            <button class="btn btn-link" ng-click="vm.actions.del()" ng-show="vm.privilege.IsDelete">
                <i class="fa fa-trash"></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 class="box box-primary">
    <div class="box-header with-border" 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}}
                </button>
            </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;vm.bigDepSelected = null;">
                        <a href="javascript:void(0)">所有事业部</a>
                    </li>
                    <li ng-repeat="item in vm.buidList" ng-click="vm.buidSelected = item;vm.bigDepSelected = null;">
                        <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-click="vm.filter = !vm.filter" ng-class="{true: 'active', false:'inactive'}[vm.filter]">
                <i class="fa fa-filter"></i> 更多筛选
                <i class="fa fa-angle-double-down"></i>
            </button>
        </div>
    </div>
    <div ng-show="vm.filter" class="box box-widget">
        <!-- form start -->
        <form class="form-horizontal">
            <div class="box-body">
                <div class="form-group">
                    <rt-datetime ng-model="vm.sYm" rt-required="true" rt-type="month" rt-title="开始年月" rt-col="3" rt-label-col="2"></rt-datetime>
                    <rt-datetime ng-model="vm.eYm" rt-required="true" rt-type="month" 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">
                    <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 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.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">
                    <label class="col-sm-2 control-label">客户名称</label>
                    <div class="col-sm-3">
                        <input type="search" placeholder="请输入客户名称" class="form-control" ng-model="vm.accountName" />
                    </div>
                    <label class="col-sm-2 control-label">负责人名称</label>
                    <div class="col-sm-3">
                        <input type="search" placeholder="请输入负责人" class="form-control" ng-model="vm.ownerIdName" />
                    </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}}"
                id="delivery_table">
                <table class="table table-hover ">
                    <thead>
                        <tr>
                            <th>
                                <rt-header-checkbox></rt-header-checkbox>
                            </th>
                            <th rt-field-code="year">年</th>
                            <th rt-field-code="month">月</th>
                            <th rt-field-code="CreatedOn">上传时间</th>
                            <th rt-field-code="delivery_no">发货单号</th>
                            <th rt-field-code="delivery_date">发货日期</th>
                            <th rt-field-code="lotno">批号</th>
                            <th rt-field-code="agent_accountid">代理商</th>
                            <th rt-field-code="accountidName">客户名称</th>
                            <th rt-field-code="acc_number">客户编码</th>
                            <th rt-field-code="OwnerIdName">负责人</th>
                            <th rt-field-code="BusinessUnitIdName">省区/地区</th>
                            <th rt-field-code="provinceidName">省份</th>
                            <th rt-field-code="cityidName">城市</th>
                            <th rt-field-code="productidName">药品名称</th>
                            <th rt-field-code="product_size">药品规格</th>
                            <th rt-field-code="delivery_count">发货数量</th>
                            <th rt-field-code="unit_price">单价</th>
                            <th>金额</th>
                            <th>件包装</th>
                            <th rt-field-code="package_qty">件数</th>
                            <th rt-field-code="floor_price">底价</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>{{ row.year }}</td>
                            <td>{{ row.month }}</td>
                            <td>{{ row.CreatedOn|date:'yyyy-MM-dd HH:mm:ss' }}</td>
                            <td>{{ row.delivery_no }}</td>
                            <td>{{ row.delivery_date|date:'yyyy-MM-dd'}}</td>
                            <td>{{ row.lotno }}</td>
                            <td>{{ row.agent_accountid.Name }}</td>
                            <td>{{ row.accountid.Name }}</td>
                            <td>{{ row.acc_number}}</td>
                            <td>{{ row.OwnerId.Name}}</td>
                            <td>{{ row.BusinessUnitId.Name }}</td>
                            <td>{{ row.provinceid.Name}}</td>
                            <td>{{ row.cityid.Name}}</td>
                            <td>{{ row.productid.Name}}</td>
                            <td>{{ row.product_size}}</td>
                            <td>{{ row.delivery_count}}</td>
                            <td>{{ row.unit_price | currency:"￥" }}</td>
                            <td>{{ row.delivery_amount|toFixNumber:2}}</td>
                            <td>{{ row.product_package}}</td>
                            <td>{{ row.package_qty}}</td>
                            <td>{{ row.floor_price | currency:"￥" }}</td>
                            <td>{{ row.floor_price*row.delivery_count|toFixNumber:2}}</td>
                        </tr>
                    </tbody>
                </table>
            </rt-data-grid>
            <div class="row" style="padding-top: 15px;width: 100%;">
                <span style="float: right;">本页合计 金额： {{vm.sumPrice | toFixNumber: 2 }} 元、销量： {{vm.sumCount}} ，总计 金额： {{vm.totalPrice?vm.totalPrice:0}}
                    元、销量： {{vm.totalCount?vm.totalCount:0}}</span>
            </div>
            <!-- 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>
<!-- div[.editview] -->