<!--
	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="col-xs-11 col-sm-10">
                                <div class="dataTables_filter">
                                    <label>
                                        <span class="input-group-addon"><i class="glyphicon glyphicon-search"></i></span>
                                        <input type="search" placeholder="姓名/手机号/卡号" data-ng-keyup="getTablePlanList()" ng-model="queryParam.keyword" class="form-control" aria-controls="dt_basic"></label>
                                </div>
                            </div>
                            <div class="col-xs-1 col-sm-2">
                                <button class="btn btn-primary" type="button" data-ng-click="open()">
                                    <i class="fa fa-plus"></i>
                                    新增
                                </button>
                                <button class="btn btn-primary" type="button" data-ng-click="createPlanOrder()">
                                    <i class="fa fa-fast-forward"></i>
                                    手工执行
                                </button>
                            </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 width="120">收货人姓名</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="tablePlan in tablePlanList"  ng-if="tablePlanList.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="tablePlan.planName"></td>
                                    <td>每{{tablePlan.deliveryType}}周/星期{{tablePlan.sendWeekDay}}</td>
                                    <td ng-bind="tablePlan.couponNumber"></td>
                                    <td ng-bind="tablePlan.consigneeName"></td>
                                    <td ng-bind="tablePlan.consigneePhone"></td>
                                    <td ng-bind="tablePlan.consigneeAddress"></td>
                                    <td ng-bind="tablePlan.companyName"></td>
                                    <td ng-bind="tablePlan.managerName"></td>
                                    <td ng-bind="tablePlan.totalSendValue"></td>
                                    <td ng-bind="tablePlan.totalSendValue - tablePlan.sendValue"></td>
                                    <td>
                                        <label class="checkbox">
                                            <input type="checkbox" ng-model="tablePlan.isStop" name="checkbox-inline"
                                                   ng-change="stop($index)"
                                                   data-ng-checked="tablePlan.isStop == 1" data-ng-true-value="1" data-ng-false-value="0">
                                            <i></i>
                                        </label>
                                    </td>
                                    <td ng-bind="tablePlan.beginTime | date: 'yyyy-MM-dd'"></td>
                                    <td>
                                        <div ng-show="show">
                                            <a href="javascript:void(0);" data-ng-click="removeTablePlan($index)" title="删除：{{tablePlan.consigneeName}}">
                                                <span class="glyphicon glyphicon-remove-circle"></span>
                                            </a>
                                            <span> | </span>
                                            <a href="javascript:void(0);" data-ng-click="open($index)" title="编辑：{{tablePlan.consigneeName}}">
                                                <span class="fa fa-pencil"></span>
                                            </a>
                                        </div>
                                    </td>
                                </tr>
                                <tr ng-if="tablePlanList == null || tablePlanList.length == 0">
                                    <td colspan="3">
                                        <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="addTablePlan.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="addTablePlanForm" name="addTablePlanForm" novalidate="">

                <fieldset>
                    <div class="form-group" ng-show="tablePlan.id == null">
                        <label class="col-md-2 control-label">餐桌计划<span class="vaild">*</span></label>
                        <div class="col-md-10 input-group">
                            <select multiple ug-select2 ug-select2-config="ugSelect2Config" style="width: 100%;" required="true" ng-model="tablePlan.cdPlanIds" name="cdPlanId" ng-change="changeSelect()" >
                                <option value="{{basePlan.id}}" ng-repeat="basePlan in basePlanList">{{basePlan.planName}}</option>
                            </select>
                        </div>
                    </div>
                    <div class="form-group" ng-show="tablePlan.id != null">
                        <label class="col-md-2 control-label">餐桌计划<span class="vaild">*</span></label>
                        <div class="col-md-10 input-group">
                            {{tablePlan.planName}}
                        </div>
                    </div>
                    <div class="form-group" ng-show="tablePlan.id != null">
                        <label class="col-md-2 control-label">起效时间<span class="vaild">*</span></label>
                        <div class="col-md-3  input-group">
                            <input type="text" class="form-control"
                                   datepicker-popup="yyyy-MM-dd"
                                   placeholder="起效时间"
                                   ng-model="tablePlan.beginTime"
                                   required="true"
                                   close-text="关闭"
                                   current-text="今日"
                                   clear-text="清除"
                                   is-open="datepickerSetting.beginTime.opened"
                                    />
							<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"  ng-show="tablePlan.id != null">
                        <label class="col-md-2 control-label">配送时间(星期)<span class="vaild">*</span></label>
                        <div class="col-md-4">
                            <input class="form-control" required="true" ng-model="tablePlan.sendWeekDay" name="" placeholder="配送时间（星期几）" type="text">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-md-2 control-label">卡号<span class="vaild">*</span></label>
                        <div class="col-md-6 input-group input-group-md">
                            <input type="text" ng-model="tablePlan.couponNumber"  required="true" placeholder="卡号" name="couponNumber" class="form-control">
                            <span class="input-group-btn">
                                <button class="btn btn-default" data-ng-click="queryMemberByCouponNumber()" type="button">查询</button>
                            </span>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-md-2 control-label">收货人<span class="vaild">*</span></label>
                        <div class="col-md-4">
                            <input class="form-control" required="true" ng-model="tablePlan.consigneeName" name="" placeholder="收货人" type="text">
                        </div>
                        <label class="col-md-2 control-label">收货手机号<span class="vaild">*</span></label>
                        <div class="col-md-4">
                            <input class="form-control" required="true" ng-model="tablePlan.consigneePhone" name="phoneNumber" data-rule-minlength="11" data-rule-maxlength="11" placeholder="手机号"  type="text">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-md-2 control-label">收货地址<span class="vaild">*</span></label>
                        <div class="col-md-10">
                            <input class="form-control" required="true" ng-model="tablePlan.consigneeAddress" name="address" placeholder="收货地址" type="text">
                        </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>
                    <div class="form-group" ng-if="tablePlan.id == null">
                        <div ng-repeat="chooseTablePlan in chooseTablePlans">
                            <div class="form-group">
                                <label class="col-md-2 control-label">{{$index+1}}计划名称</label>
                                <div class="col-md-4">
                                  <span ng-bind="chooseTablePlan.planName"></span>
                                </div>
                                <label class="col-md-2 control-label">起效时间</label>
                                <div class="col-md-4">
                                    <input class="form-control" required="true" ng-model="chooseTablePlan.beginTime"  placeholder="格式:yyyy/mm/dd"  type="date">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-md-2 control-label">是否启动</label>
                                <div class="col-md-4">
                                    <label class="radio radio-inline">
                                        <input type="radio" class="radiobox" value="0" ng-model="chooseTablePlan.isStop" ng-checked="chooseTablePlan.isStop == 0">
                                        <span>启动</span>
                                    </label>
                                    <label class="radio radio-inline">
                                        <input type="radio" class="radiobox" value="1" ng-model="chooseTablePlan.isStop" ng-checked="chooseTablePlan.isStop == 1">
                                        <span>暂停</span>
                                    </label>
                                </div>
                                <label class="col-md-2 control-label">配送时间（星期）<span class="vaild">*</span></label>
                                <div class="col-md-4">
                                    <input class="form-control" required="true" ng-model="chooseTablePlan.sendWeekDay" name="" placeholder="配送时间（星期）" type="text">
                                </div>
                            </div>
                            <hr style="border:1px dashed; height:1px" color="#DDDDDD">
                        </div>
                    </div>
                </fieldset>
            </form>
        </div>
    </div>
    <div class="modal-footer">
        <button class="btn btn-primary" type="submit" data-ng-click="saveOrUpdateTablePlan()">
            <i class="fa fa-save"></i>
            保存
        </button>
        <button class="btn btn-warning" ng-click="cancel()">关闭</button>
    </div>
</script>