<!--
	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">
        <article class="col-xs-2 col-sm-2 col-md-2 col-lg-2">
            <div class="jarviswidget" id="wid-id-0">
                <!-- 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">
                        <!--<div class="widget-body-toolbar bg-color-white">-->
                        <!--<div class="row">-->

                        <!--<div class="col-sm-12 col-md-2 text-align-right">-->
                        <!--</div>-->
                        <!--</div>-->
                        <!--</div>-->
                        <div class="tree">
                            <ul>
                                <li data-ng-repeat="item in itemCategoryList" data-ng-include="'tree_view_table.html'"></li>
                            </ul>
                        </div>
                    </div>
                    <!-- end widget content -->
                </div>
                <!-- end widget div -->
            </div>
        </article>
        <!-- NEW WIDGET START -->
        <article class="col-xs-10 col-sm-10 col-md-10 col-lg-10">
            <!-- 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-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="getItemList()" 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>
                            </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>产品类别</th>
                                    <th width="120">产品编号</th>
                                    <th width="120">产品名称</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="item in itemList" ng-if="itemList.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="item.categoryName"></td>
                                    <td ng-bind="item.itemCode"></td>
                                    <td ng-bind="item.itemName"></td>
                                    <td><span ng-if="item.itemType == 1">常规产品</span><span ng-if="item.itemType == 2">组合产品</span></td>
                                    <td ng-bind="item.spec+item.pricingManner"></td>
                                    <td><span ng-if="item.sellStatus == 0">下架</span><span ng-if="item.sellStatus == 1">上架</span></td>
                                    <td ng-bind="item.sellPrice"></td>
                                    <td ng-bind="item.basePrice"></td>
                                    <td ng-bind="item.memberPrice"></td>
                                    <td>
                                        <div ng-show="show">
                                            <a href="javascript:void(0);" data-ng-click="removeItem($index)" title="删除：{{item.itemName}}">
                                                <span class="glyphicon glyphicon-remove-circle"></span>
                                            </a>
                                            <span> | </span>
                                            <a href="javascript:void(0);" data-ng-click="open($index)" title="编辑：{{item.itemName}}">
                                                <span class="fa fa-pencil"></span>
                                            </a>
                                            <span> | </span>
                                            <a href="javascript:void(0);" data-ng-click="openDetail($index)" title="详情：{{item.itemName}}">
                                                <span class="fa fa-search"></span>
                                            </a>
                                        </div>
                                    </td>
                                </tr>
                                <tr ng-if="itemList == null || itemList.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="addItem.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="addItemForm" name="addItemForm" 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="item.id != null" value="1" ng-model="item.itemType" ng-checked="item.itemType == 1" name="itemType">
                                <span>常规产品</span>
                            </label>
                            <label class="radio radio-inline">
                                <input type="radio" class="radiobox" ng-disabled="item.id != null" value="2" ng-model="item.itemType" ng-checked="item.itemType == 2" name="itemType">
                                <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="2" data-rule-maxlength="20" ng-focus="chooseCategoryModel()" ng-model="item.categoryName" name="itemCode" 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" data-rule-minlength="3" data-rule-maxlength="20" ng-model="item.itemCode" name="itemCode" 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" data-rule-minlength="1" data-rule-maxlength="20" ng-model="item.itemName" name="name" placeholder="产品名称" type="text">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-md-2 control-label">生产地</label>
                        <div class="col-md-10">
                            <input class="form-control" ng-model="item.yieldly" name="yieldly" 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-8">
                            <input class="form-control" required="" data-rule-number="true" ng-model="item.spec" name="spec" placeholder="规格" type="text">
                        </div>
                        <label class="col-md-2"> <input class="form-control" ng-model="item.pricingManner" name="spec" placeholder="" type="text"></label>
                    </div>
                    <div class="form-group">
                        <label class="col-md-2 control-label">销售状态<span class="vaild">*</span></label>
                        <div class="col-md-10">
                            <label class="radio radio-inline">
                                <input type="radio" class="radiobox" value="0" ng-model="item.sellStatus" ng-checked="item.sellStatus == 0" name="sellStatus">
                                <span>下架</span>
                            </label>
                            <label class="radio radio-inline">
                                <input type="radio" class="radiobox" value="1" ng-model="item.sellStatus" ng-checked="item.sellStatus == 1" name="sellStatus">
                                <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">
                            <label class="radio radio-inline">
                                <input type="radio" class="radiobox" value="0" ng-model="item.sellUnit" ng-checked="item.sellUnit == 0" name="sellUnit">
                                <span>计重</span>
                            </label>
                            <label class="radio radio-inline">
                                <input type="radio" class="radiobox" value="1" ng-model="item.sellUnit" ng-checked="item.sellUnit == 1" name="sellUnit">
                                <span>计件</span>
                            </label>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-md-2 control-label">销售属性</label>
                        <div class="col-md-10">
                            <label class="checkbox checkbox-inline">
                                <input type="checkbox" class="checkbox" ng-model="item.xianShiQiangGou"
                                       data-ng-true-value="1"
                                       data-ng-false-value="0"
                                       ng-checked="item.xianShiQiangGou == 1" name="xianShiQiangGou">
                                <span>限时抢购</span>
                            </label>
                            <label class="checkbox checkbox-inline">
                                <input type="checkbox" class="checkbox" ng-model="item.reMaiTuiJian"
                                       data-ng-true-value="1"
                                       data-ng-false-value="0"
                                       ng-checked="item.reMaiTuiJian == 1" name="reMaiTuiJian">
                                <span>热卖推荐</span>
                            </label>
                            <label class="checkbox checkbox-inline">
                                <input type="checkbox" class="checkbox" ng-model="item.xinPinChangXian"
                                       data-ng-true-value="1"
                                       data-ng-false-value="0"
                                       ng-checked="item.xinPinChangXian == 1" name="xinPinChangXian">
                                <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="" data-rule-number="true" ng-model="item.sellPrice" name="sellPrice" placeholder="销售金额" type="text">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-md-2 control-label">进货价格</label>
                        <div class="col-md-10">
                            <input class="form-control" ng-model="item.basePrice" data-rule-number="true" name="basePrice" placeholder="进货价格" type="text">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-md-2 control-label">会员价格</label>
                        <div class="col-md-10">
                            <input class="form-control" ng-model="item.memberPrice" data-rule-number="true" name="memberPrice" placeholder="会员价格" type="text">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-md-2 control-label">采摘人</label>
                        <div class="col-md-10">
                            <input class="form-control" ng-model="item.caizaiUser" name="caizaiUser" placeholder="采摘人" type="text">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-md-2 control-label">检测人</label>
                        <div class="col-md-10">
                            <input class="form-control" ng-model="item.jianceUser" name="jianceUser" placeholder="检测人" type="text">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-md-2 control-label">农残率</label>
                        <div class="col-md-10">
                            <input class="form-control" ng-model="item.nongCanLv" name="nongCanLv" placeholder="农残率" type="text">
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-md-2 control-label">保质期</label>
                        <div class="col-md-10">
                            <input class="form-control" ng-model="item.baoZhiQi" data-rule-number="true" name="baoZhiQi" placeholder="保质期" type="text">
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-md-2 control-label">营养成分</label>
                        <div class="col-md-10">
                            <input class="form-control" ng-model="item.yiYangChenFen" name="yiYangChenFen" placeholder="营养成分" type="text">
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-md-2 control-label">适应人群</label>
                        <div class="col-md-10">
                            <input class="form-control" ng-model="item.shiYiRenQun" name="shiYiRenQun" placeholder="适应人群" type="text">
                        </div>
                    </div>

                    <fieldset class="demo-switcher-1" ng-if="item.itemType == 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="getChildItemList()" ng-model="queryChildParam.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="childItem in childItemList">
                                        <td>{{childItem.categoryName}}</td>
                                        <td>{{childItem.itemCode}}</td>
                                        <td>{{childItem.itemName}}</td>
                                        <td>
                                            <div>
                                                <a href="javascript:void(0);" data-ng-click="openItemNumber($index)" title="选择：{{childItem.itemName}}">
                                                    <span class="fa fa-plus"></span>
                                                </a>
                                            </div>
                                        </td>
                                    </tr>
                                    </tbody>
                                    <!--<tfoot>-->
                                    <!--<tr>-->
                                    <!--<td colspan="4">-->
                                    <!--<ug-pagination page-info="pageInfoSetting" ></ug-pagination>-->
                                    <!--</td>-->
                                    <!--</tr>-->
                                    <!--</tfoot>-->
                                </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 choseChildItemList">
                                        <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="removeChildItem($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="saveOrUpdateItem()">
            <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>

<script type="text/ng-template" id="tree_view_table.html">
    <span ng-mouseenter="item.show=true" ng-mouseleave="item.show=false">
        <i ng-if="item.nodes && item.nodes.length > 0" class="fa fa-lg fa-plus-circle"></i>
        <a ng-show="item.parentId != null" ng-click="getItemListFormCategory(item.name)">{{item.name}}</a>
        <lable ng-show="item.parentId == null">{{item.name}}</lable>
    </span>
    <ul ng-if="item.nodes && item.nodes.length > 0" class="tree-hide">
        <li data-ng-repeat="item in item.nodes" data-ng-include="'tree_view_table.html'"></li>
    </ul>
</script>

<script type="text/ng-template" id="tree_view.html">
    <span ng-mouseenter="item.show=true" ng-mouseleave="item.show=false">
		<i ng-if="item.nodes && item.nodes.length > 0" class="fa fa-lg fa-plus-circle"></i>
        <a ng-show="item.parentId != null" ng-click="chooseCategory(item)">{{item.name}}</a>
		<lable ng-show="item.parentId == null">{{item.name}}</lable>
    </span>
    <ul ng-if="item.nodes && item.nodes.length > 0" class="tree-hide">
        <li data-ng-repeat="item in item.nodes" data-ng-include="'tree_view.html'"></li>
    </ul>
</script>

<script type="text/ng-template" id="chooseCategory.html">
    <div class="modal-header">
        <h3 class="modal-title">选择类别</h3>
    </div>
    <div class="modal-body">
        <div class="widget-body">
            <div class="tree">
                <ul>
                    <li data-ng-repeat="item in itemCategoryList" data-ng-include="'tree_view.html'"></li>
                </ul>
            </div>
        </div>
    </div>
    <div class="modal-footer">
        <button class="btn btn-warning" ng-click="cancel()">关闭</button>
    </div>
</script>

<!--商品详情页-->
<script type="text/ng-template" id="itemDetail.html">
    <div class="modal-header">
        <h3 class="modal-title">商品详情</h3>
    </div>
    <div class="modal-body">
        <!--//图片-->
        <div ng-if="imageList.length <5">
            <input ux-upload ux-upload-config="fileUploadConfig" id="file" ng-model="fileUrl" type="file" multiple="true">
        </div>

        <div class="margin-top-5">
            <span ng-repeat="image in imageList">
                <img src="{{image.path}}" width="80px" height="80px">
                <a href="javascript:void(0);" data-ng-click="removeItemImage($index)">删除</a>
                <a href="javascript:void(0);" ng-if="image.isDefault != 1" data-ng-click="updateDefault($index)">设定为封面</a>
            </span>
        </div>

        <div ueditor="editor" ng-required="true" ng-model="currentItem.itemDetailContent" id="editor"></div>
    </div>
    <div class="modal-footer">
        <button class="btn btn-primary" ng-click="saveItemDetail()">保存</button>
        <button class="btn btn-warning" ng-click="cancel()">关闭</button>
    </div>
</script>