<!--
	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 uniqu e 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-3 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="getCouponCategoryList()" ng-model="queryParam.keyword" class="form-control" aria-controls="dt_basic">
                                    </label>
								</div>
							</div>
                            <div class="col-xs-3 col-sm-3">
                                <div class="dataTables_filter">
                                    <label>
                                        <select ug-select2 style="width: 250px;" ng-change="getCouponCategoryList()" ng-model="queryParam.categoryType" name="categoryType">
                                            <option value="">--请选择--</option>
                                            <option value="1">卡</option>
                                            <option value="2">劵</option>
                                        </select>
                                    </label>
                                </div>
                            </div>
							<div class="col-xs-12 col-sm-12">
								<button class="btn btn-primary" type="button" data-ng-click="open()">
									<i class="fa fa-plus"></i>
									新增
								</button>
							</div>
						</div>
						<div class="table-responsive">
							<table class="table table-striped table-condensed table-hover smart-form has-tickbox">
								<thead>
								<tr>
                                    <th>类别类型</th>
                                    <th width="120">类别名称</th>
									<th width="80">操作</th>
								</tr>
								</thead>
								<tbody>
								<tr ng-repeat="couponCategory in couponCategoryList | orderBy:'categoryType'"   ng-if="couponCategoryList.length > 0" ng-mouseenter="show=true" ng-mouseleave="show=false">
                                    <td>
                                        <span ng-if="couponCategory.categoryType == 1">卡</span>
                                        <span ng-if="couponCategory.categoryType == 2">消费券</span>
                                        <!--<span ng-if="couponCategory.categoryType == 3">采摘劵</span>-->
                                    </td>
                                    <td ng-bind="couponCategory.categoryName"></td>
                                    <td>
                                        <div ng-show="show">
                                            <a href="javascript:void(0);" data-ng-click="removeCouponCategory(couponCategory)" title="删除：{{couponCategory.couponCategoryName}}">
                                                <span class="glyphicon glyphicon-remove-circle"></span>
                                            </a>
                                            <span> | </span>
                                            <a href="javascript:void(0);" data-ng-click="open(couponCategory)" title="编辑：{{couponCategory.couponCategoryName}}">
                                                <span class="fa fa-pencil"></span>
                                            </a>
                                        </div>
                                    </td>
								</tr>
								<tr ng-if="couponCategoryList == null || couponCategoryList.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="addCouponCategory.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="addCouponCategoryForm" name="addCouponCategoryForm" novalidate="">

				<fieldset>
                    <div class="form-group">
                        <label class="col-md-2 control-label">类别类型：</label>
                        <div class="col-md-10">
                            <label class="radio radio-inline">
                                <input type="radio" class="radiobox" ng-disabled="couponCategory.id != null" value="1" ng-model="couponCategory.categoryType" ng-checked="couponCategory.categoryType == 1" name="categoryType">
                                <span>卡</span>
                            </label>
                            <label class="radio radio-inline">
                                <input type="radio" class="radiobox" ng-disabled="couponCategory.id != null" value="2" ng-model="couponCategory.categoryType" ng-checked="couponCategory.categoryType == 2" name="categoryType">
                                <span>消费劵</span>
                            </label>
                            <!--<label class="radio radio-inline">-->
                                <!--<input type="radio" class="radiobox" value="3" ng-model="couponCategory.categoryType" ng-checked="couponCategory.categoryType == 3" name="categoryType">-->
                                <!--<span>采摘劵</span>-->
                            <!--</label>-->
                        </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" data-rule-minlength="1" data-rule-maxlength="20" ng-model="couponCategory.categoryName" name="name" placeholder="类别名称" type="text">
                        </div>
                    </div>
                    <fieldset class="demo-switcher-1" ng-if="couponCategory.categoryType == 2">
                        <legend>选择产品</legend>
                        <div class="row">
                            <div class="row">
                                <div class="col-xs-11 col-sm-10">
                                    <div class="dataTables_filter" style="width : 35%;">
                                        <label>
                                            <span class="input-group-addon"><i class="glyphicon glyphicon-search"></i></span>
                                            <input type="search" placeholder="产品分类/编号/名称" data-ng-keyup="getItemList()" ng-model="queryParam.keyword" class="form-control" aria-controls="dt_basic">
                                        </label>
                                    </div>
                                </div>
                            </div>
                            <div class="table-responsive col-md-6">

                                <table class="table table-bordered">
                                    <thead>
                                    <tr>
                                        <th colspan="4">可选择产品</th>
                                    </tr>
                                    </thead>
                                    <thead>
                                    <tr>
                                        <th>分类</th>
                                        <th>编号</th>
                                        <th>名称</th>
                                        <th>操作</th>
                                    </tr>
                                    </thead>
                                    <tbody>
                                    <tr data-ng-repeat="item in itemList">
                                        <td>{{item.categoryName}}</td>
                                        <td>{{item.itemCode}}</td>
                                        <td>{{item.itemName}}</td>
                                        <td>
                                            <div>
                                                <a href="javascript:void(0);" data-ng-click="openItemNumber($index)" title="订购：{{couponCategory.couponCategoryName}}">
                                                    <span class="fa fa-plus"></span>
                                                </a>
                                            </div>
                                        </td>
                                    </tr>
                                    </tbody>
                                </table>

                            </div>
                            <div class="table-responsive col-md-6">
                                <table class="table table-bordered">
                                    <thead>
                                    <tr>
                                        <th colspan="5">已选择产品</th>
                                    </tr>
                                    <tr>
                                        <th>分类</th>
                                        <th>编号</th>
                                        <th>名称</th>
                                        <th>份数</th>
                                        <th>操作</th>
                                    </tr>
                                    </thead>
                                    <tbody>
                                    <tr ng-repeat="choseItem in choseItemList" ng-class="{'tdred':choseItem.sellStatus == 0}">
                                        <td>{{choseItem.categoryName}}</td>
                                        <td>{{choseItem.itemCode}}</td>
                                        <td>{{choseItem.itemName}}</td>
                                        <td>{{choseItem.count}}</td>
                                        <td>
                                            <div>
                                                <a href="javascript:void(0);" data-ng-click="removeItem($index)" title="移除：{{choseItem.itemName}}">
                                                    <span class="glyphicon glyphicon-trash"></span>
                                                </a>
                                            </div>
                                        </td>
                                    </tr>
                                    </tbody>
                                </table>
                            </div>
                        </div>
                    </fieldset>
					<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="saveOrUpdateCouponCategory()">
			<i class="fa fa-save"></i>
			保存
		</button>
		<button class="btn btn-warning" ng-click="cancel()">关闭</button>
	</div>
</script>

<script type="text/ng-template" id="addItemNumber.html">
    <div class="modal-header">
        <h3 class="modal-title">【{{orderItem.itemName}}】</h3>
    </div>
    <div class="modal-body">
        <div class="widget-body">

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

                <fieldset>

                    <div class="form-group">
                        <label class="col-md-2 control-label">组合份数</label>
                        <div class="col-md-10 input-group">
                            <input class="form-control" required data-rule-number="true" ng-model="orderItem.number" name="number" 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>
                </fieldset>
            </form>
        </div>
    </div>
    <div class="modal-footer">
        <button class="btn btn-primary" type="submit" data-ng-click="saveItemNumber()">
            <i class="fa fa-save"></i>
            确定
        </button>
        <button class="btn btn-warning" ng-click="cancel()">取消</button>
    </div>
</script>