<!--
	The ID "widget-grid" will start to initialize all widgets below 
	You do not need to use widgets if you dont want to. Simply remove 
	the <section></section> and you can use wells or panels instead 
	-->

<!-- widget grid -->
<section id="widget-grid" class="">

    <!-- row -->
    <div class="row">

        <!-- NEW WIDGET START -->
        <article class="col-xs-12 col-sm-12 col-md-12 col-lg-12">

            <!-- Widget ID (each widget will need unique ID)-->
            <div class="jarviswidget" id="wid-id-4">
                <!-- widget options:
                usage: <div class="jarviswidget" id="wid-id-0" data-widget-editbutton="false">

                data-widget-colorbutton="false"
                data-widget-editbutton="false"
                data-widget-togglebutton="false"
                data-widget-deletebutton="false"
                data-widget-fullscreenbutton="false"
                data-widget-custombutton="false"
                data-widget-collapsed="true"
                data-widget-sortable="false"

                -->
                <header>
                    <span class="widget-icon"> <i class="fa fa-table"></i> </span>
                    <h2>订单列表</h2>
                </header>
                <!-- widget div-->
                <div>
                    <!-- widget edit box -->
                    <div class="jarviswidget-editbox">
                        <!-- This area used as dropdown edit box -->
                    </div>
                    <!-- end widget edit box -->
                    <!-- widget content -->
                    <div class="widget-body no-padding">
                        <div class="dt-toolbar">
                            <div class="row">
                                <div class="col-sm-3">
                                    <div class="dataTables_filter">
                                        <label>
                                            <span class="input-group-addon"><i class="glyphicon glyphicon-search"></i></span>
                                            <input type="search" placeholder="订单编号/手机号码/收货人" data-ng-keyup="getOrderList()" ng-model="queryParam.keyword" class="form-control" aria-controls="dt_basic"></label>
                                    </div>
                                </div>
                                <div class="col-sm-3">
                                    <div class="dataTables_filter">
                                        <label>
                                            <span class="input-group-addon"><i class="glyphicon glyphicon-search"></i></span>
                                            <input type="search" placeholder="卡号" data-ng-keyup="getOrderList()" ng-model="queryParam.couponNumber" class="form-control" aria-controls="dt_basic"></label>
                                    </div>
                                </div>
                                <div class="col-sm-3">
                                    <div class="dataTables_filter">
                                        <div class="dataTables_filter">
                                            <select ug-select2 style="width: 250px;" ng-model="queryParam.managerId" ng-change="getOrderList()" name="managerId">
                                                <option value="">--请选择客服经理--</option>
                                                <option value="{{manager.customerMangerId}}" ng-repeat="manager in managers">{{manager.customerManger}}</option>
                                            </select>
                                        </div>
                                    </div>
                                </div>
                                <div class="col-md-3">
                                    <div class="input-group">
                                        <input type="text" class="form-control" datepicker-popup="yyyy-MM-dd" datepicker-localdate
                                               placeholder="下单起始日期"
                                               ng-model="queryParam.orderCreateTimeStart"
                                               close-text="关闭"
                                               current-text="今日"
                                               clear-text="清除"
                                               is-open="datepickerSetting.orderCreateTimeStart.opened"
                                               ng-required="true"/>
                                        <div class="input-group-btn">
                                            <button type="button" class="btn btn-default" ng-click="openDate($event, 0)"><i class="glyphicon glyphicon-calendar"></i></button>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="row">
                                <div class="col-md-3">
                                    <div class="input-group">
                                        <input type="text" class="form-control" datepicker-popup="yyyy-MM-dd" datepicker-localdate
                                               placeholder="下单截止日期"
                                               ng-model="queryParam.orderCreateTimeEnd"
                                               close-text="关闭"
                                               current-text="今日"
                                               clear-text="清除"
                                               is-open="datepickerSetting.orderCreateTimeEnd.opened"
                                               ng-required="true"/>
                                        <div class="input-group-btn">
                                            <button type="button" class="btn btn-default" ng-click="openDate($event, 1)"><i class="glyphicon glyphicon-calendar"></i></button>
                                        </div>
                                    </div>
                                </div>
                                <div class="col-sm-3">
                                    <button class="btn btn-primary" type="button" data-ng-click="getOrderList()">
                                        <i class="fa fa-refresh"></i>
                                        刷新
                                    </button>
                                    <button class="btn btn-primary" type="button" ui-sref="order_create">
                                        <i class="fa fa-plus"></i>
                                        新增订单
                                    </button>
                                </div>
                            </div>
                        </div>
                        <div class="table-responsive">
                            <table class="table table-striped table-condensed table-hover smart-form has-tickbox">
                                <thead>
                                <tr>
                                    <th>
                                        <label class="checkbox">
                                            <input type="checkbox" name="checkbox-inline">
                                            <i></i>
                                        </label>
                                    </th>
                                    <th width="120">订单编号</th>
                                    <th>订单类型</th>
                                    <th>卡/劵号</th>
                                    <th>订购日期</th>
                                    <th>配送日期</th>
                                    <th>订单状态</th>
                                    <th>付款方式</th>
                                    <th>附加付款方式</th>
                                    <th>总金额</th>
                                    <th>优惠金额</th>
                                    <th>付款金额</th>
                                    <th>附加付款金额</th>
                                    <th>客户信息</th>
                                    <th>客户经理</th>
                                    <th>下单人</th>
                                    <th>备注</th>
                                    <th>是否有下架商品</th>
                                    <th width="80">操作</th>
                                </tr>
                                </thead>
                                <tbody>
                                <tr ng-repeat="order in orderList" ng-if="orderList.length > 0" ng-mouseenter="show=true" ng-mouseleave="show=false">
                                    <td>
                                        <label class="checkbox">
                                            <input type="checkbox" name="checkbox-inline">
                                            <i></i>
                                        </label>
                                    </td>
                                    <td ng-bind="order.orderNo" style="background:red;" ng-if="order.xiajia == 1"></td>
                                    <td ng-bind="order.orderNo" ng-if="order.xiajia == 0"></td>
                                    <td ng-bind="order.orderTypeDesc"></td>
                                    <td ng-bind="order.couponNumber"></td>
                                    <td ng-bind="order.createTime | date: 'yyyy-MM-dd'"></td>
                                    <td ng-bind="order.appointmentTime | date: 'yyyy-MM-dd'"></td>
                                    <td ng-bind="order.orderStatusDesc"></td>
                                    <td ng-bind="order.paymentModeDesc"></td>
                                    <td ng-bind="order.otherPaymentModeDesc"></td>
                                    <td ng-bind="order.totalAmount + order.discountPrice"></td>
                                    <td ng-bind="order.discountPrice"></td>
                                    <td ng-bind="order.totalAmount"></td>
                                    <td ng-bind="0-order.otherPayAmount"></td>
                                    <td ng-bind="order.consigneeName"></td>
                                    <td ng-bind="order.managerName"></td>
                                    <td ng-bind="order.createUser"></td>
                                    <td ng-bind="order.remark"></td>
                                    <td ng-if="order.xiajia == 1">有</td>
                                    <td ng-if="order.xiajia == 0">无</td>
                                    <td width="180">
                                        <a ng-show="show" href="javascript:void(0);" data-ng-click="viewOrder($index)" title="查看：{{order.orderDesc}}">
                                            <span class="fa fa-eye"></span>
                                        </a>
                                        <a ng-show="show" ng-if="order.orderStatus <2" href="javascript:void(0);" ui-sref="order_update({id:order.id, orderNo:order.orderNo})" title="编辑：{{order.orderDesc}}">
                                            <span class="fa fa-edit"></span>
                                        </a>
                                        <a ng-show="show" ng-if="order.orderStatus ==1" href="javascript:void(0);" data-ng-click="cancelOrder($index)" title="取消：{{order.orderDesc}}">
                                            <span class="fa fa-recycle"></span>
                                        </a>
                                    </td>
                                </tr>
                                <tr ng-if="orderList == null || orderList.length == 0">
                                    <td colspan="11">
                                        <div>暂无数据</div>
                                    </td>
                                </tr>
                                </tbody>
                            </table>
                        </div>
                        <div class="dt-toolbar-footer">
                            <div class="col-xs-12 col-sm-12">
                                <ug-pagination page-info="pageInfoSetting"></ug-pagination>
                            </div>
                        </div>
                    </div>
                    <!-- end widget content -->
                </div>
                <!-- end widget div -->
            </div>
            <!-- end widget -->

        </article>
        <!-- WIDGET END -->

    </div>

    <!-- end row -->

</section>
<!-- end widget grid -->


<script type="text/ng-template" id="viewOrderDetail.html">
    <div class="modal-header">
        <h3 class="modal-title">订单明细</h3>
    </div>
    <div class="modal-body">
        <div class="widget-body">

            <form class="form-horizontal">
                <div class="form-group">
                    <div class="col-md-12">
                        <label class="control-label col-md-2">订单编号：</label>
                        <div class="col-md-4">
                            <label class="control-label" ng-bind="order.orderNo"></label>
                        </div>
                    </div>
                    <div class="col-md-12">
                        <label class="control-label col-md-2">订单类型：</label>
                        <div class="col-md-4">
                            <label class="control-label" ng-bind="order.orderTypeDesc"></label>
                        </div>
                    </div>
                    <div class="col-md-12">
                        <label class="control-label col-md-2">订单状态：</label>
                        <div class="col-md-4">
                            <label class="control-label" ng-bind="order.orderStatusDesc"></label>
                        </div>
                    </div>
                    <div class="col-md-12">
                        <label class="control-label col-md-2">订购时间：</label>
                        <div class="col-md-4">
                            <label class="control-label" ng-bind="order.createTime | date: 'yyyy-MM-dd HH:mm:ss'"></label>
                        </div>
                    </div>
                    <div class="col-md-12">
                        <label class="control-label col-md-2">客户姓名：</label>
                        <div class="col-md-4">
                            <label class="control-label" ng-bind="order.consigneeName"></label>
                        </div>
                    </div>
                    <div class="col-md-12">
                        <label class="control-label col-md-2">客户手机：</label>
                        <div class="col-md-4">
                            <label class="control-label" ng-bind="order.consigneePhone"></label>
                        </div>
                    </div>
                    <div class="col-md-12">
                        <label class="control-label col-md-2">收货人：</label>
                        <div class="col-md-4">
                            <label class="control-label" ng-bind="order.consigneeName"></label>
                        </div>
                    </div>
                    <div class="col-md-12">
                        <label class="control-label col-md-2">联系方式：</label>
                        <div class="col-md-4">
                            <label class="control-label" ng-bind="order.consigneePhone"></label>
                        </div>
                    </div>
                    <div class="col-md-12">
                        <label class="control-label col-md-2">收货地址：</label>
                        <div class="col-md-10">
                            <label class="control-label" ng-bind="order.consigneeAddress"></label>
                        </div>
                    </div>
                    <div class="col-md-12">
                        <label class="control-label col-md-2">付款方式：</label>
                        <div class="col-md-10">
                            <label class="control-label" ng-bind="order.paymentModeDesc"></label>
                        </div>
                    </div>
                    <div class="col-md-12">
                        <label class="control-label col-md-2">客户要求：</label>
                        <div class="col-md-10">
                            <label class="control-label" ng-bind="order.remark1"></label>
                            <label class="control-label" ng-bind="order.remark2"></label>
                        </div>
                    </div>
                    <div class="col-md-12">
                        <label class="control-label col-md-2">商品详情：</label>
                        <div class="table-responsive col-md-10" style="padding-top: 10px;">
                            <table class="table table-bordered">
                                <thead>
                                <tr>
                                    <th>名称</th>
                                    <th class="text-align-right">单价</th>
                                    <th class="text-align-right">份数</th>
                                    <th class="text-align-right">总价</th>
                                </tr>
                                </thead>
                                <tbody>
                                <tr ng-repeat="choseItem in order.itemList">
                                    <td>{{choseItem.itemName}}</td>
                                    <td class="text-align-right">{{choseItem.itemPrice | number:2}}</td>
                                    <td class="text-align-right">{{choseItem.itemQty | number:2}}</td>
                                    <td class="text-align-right">{{choseItem.itemQty * choseItem.itemPrice | number:2}}</td>
                                </tr>
                                </tbody>
                                <tfoot>
                                <tr>
                                    <td colspan="2">合计</td>
                                    <td class="text-align-right">{{totalItem.totalNumber | number:2}}</td>
                                    <td class="text-align-right">{{totalItem.totalPrice | number:2}}</td>
                                </tr>
                                </tfoot>
                            </table>
                        </div>
                    </div>
                </div>
            </form>
        </div>
    </div>
    <div class="modal-footer">
        <button class="btn btn-warning" ng-click="cancel()">关闭</button>
    </div>
</script>


<script type="text/ng-template" id="addOrder.html">
    <div class="modal-header">
        <h3 class="modal-title">订单信息</h3>
    </div>
    <div class="modal-body">
        <div class="widget-body">

            <form class="form-horizontal" ug-validate="addOrderForm" name="addOrderForm" novalidate="">

                <fieldset>

                    <div class="form-group">
                        <label class="col-md-2 control-label">类型</label>
                        <div class="col-md-10 input-group">
                            <label class="radio radio-inline">
                                <input type="radio" class="radiobox" ng-model="order.orderType" value="0" ng-checked="order.orderType==0" name="orderType">
                                <span>卡</span>
                            </label>
                            <label class="radio radio-inline">
                                <input type="radio" class="radiobox" ng-model="order.orderType" value="1" ng-checked="order.orderType==1" name="orderType">
                                <span>券</span>
                            </label>
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-md-2 control-label">描述</label>
                        <div class="col-md-10 input-group">
                            <input class="form-control" ng-model="order.id" name="id" type="hidden">
                            <input class="form-control" ng-model="order.orderDesc" name="orderDesc" placeholder="描述" type="text">
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-md-2 control-label">卡号</label>
                        <div class="col-md-10 input-group">
                            <input class="form-control" ng-model="order.orderNumber" name="orderNumber" placeholder="卡号" type="text">
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-md-2 control-label">数值</label>
                        <div class="col-md-10 input-group">
                            <input class="form-control" ng-model="order.orderValue" name="orderValue" placeholder="可用金额/可用次数" type="text">
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-md-2 control-label">起始时间</label>
                        <div class="col-md-10 input-group">
                            <input type="text" class="form-control"
                                   datepicker-popup="yyyy-MM-dd"
                                   placeholder="起始日期"
                                   ng-model="order.beginTime"
                                   close-text="关闭"
                                   current-text="今日"
                                   clear-text="清除"
                                   is-open="datepickerSetting.beginTime.opened"
                                   ng-required="true"/>
							<span class="input-group-btn">
                                <button type="button" class="btn btn-default" ng-click="open($event, 0)"><i class="glyphicon glyphicon-calendar"></i></button>
							</span>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-md-2 control-label">截止日期</label>
                        <div class="col-md-10 input-group">
                            <input type="text" class="form-control" datepicker-popup="yyyy-MM-dd"
                                   placeholder="截止日期"
                                   ng-model="order.endTime"
                                   close-text="关闭"
                                   current-text="今日"
                                   clear-text="清除"
                                   is-open="datepickerSetting.endTime.opened"
                                   ng-required="true"/>
							<span class="input-group-btn">
                                <button type="button" class="btn btn-default" ng-click="open($event, 1)"><i class="glyphicon glyphicon-calendar"></i></button>
							</span>
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-md-2 control-label">是否已使用</label>
                        <div class="col-md-10 input-group">
                            <label class="radio radio-inline">
                                <input type="radio" class="radiobox" ng-model="order.isUsed" value="0" ng-checked="order.isUsed==0" name="isUsed">
                                <span>未使用</span>
                            </label>
                            <label class="radio radio-inline">
                                <input type="radio" class="radiobox" ng-model="order.isUsed" value="1" ng-checked="order.isUsed==1" name="isUsed">
                                <span>已使用</span>
                            </label>
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-md-2 control-label">是否有效</label>
                        <div class="col-md-10 input-group">
                            <label class="radio radio-inline">
                                <input type="radio" class="radiobox" ng-model="order.isUseful" value="0" ng-checked="order.isUseful==0" name="isUseful">
                                <span>无效</span>
                            </label>
                            <label class="radio radio-inline">
                                <input type="radio" class="radiobox" ng-model="order.isUseful" value="1" ng-checked="order.isUseful==1" name="isUseful">
                                <span>有效</span>
                            </label>
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-md-2 control-label">是否赠送</label>
                        <div class="col-md-10 input-group">
                            <label class="radio radio-inline">
                                <input type="radio" class="radiobox" ng-model="order.isGift" value="0" ng-checked="order.isGift==0" name="isGift">
                                <span>否</span>
                            </label>
                            <label class="radio radio-inline">
                                <input type="radio" class="radiobox" ng-model="order.isGift" value="1" ng-checked="order.isGift==1" name="isGift">
                                <span>是</span>
                            </label>
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-md-2 control-label">备注</label>
                        <div class="col-md-10 input-group">
                            <textarea class="form-control" ng-model="order.notes" rows="5" name="notes" placeholder="备注"></textarea>
                        </div>
                    </div>

                    <div class="form-group" ng-if="errors">
                        <label class="col-md-2 control-label"></label>
                        <div class="col-md-10 error">
                            {{errors.message}}
                        </div>
                    </div>
                </fieldset>
            </form>
        </div>
    </div>
    <div class="modal-footer">
        <button class="btn btn-primary" type="submit" data-ng-click="saveOrder()">
            <i class="fa fa-save"></i>
            保存
        </button>
        <button class="btn btn-warning" ng-click="cancel()">关闭</button>
    </div>
</script>