add.vm 6.22 KB
<script src="/assets/js/jquery.js"></script>
<script src="/assets/js/riotjs/riotjs.js"></script>
<script src="/assets/products/product.search.categroy.js"></script>
<script src="/assets/products/addProductSearchCate.js"></script>
<script type="text/javascript" src="http://static.1n4j.com/static/newStatic/common/js/base/sea.js"></script>
<script type="text/javascript" src="http://static.1n4j.com/static/newStatic/pnr/js/javascript/common/config.js"></script>
<link rel="stylesheet" type="text/css" href="http://static.1n4j.com/static/newStatic/pnr/backstage/css/fancy.css">
	
<DIV id="navBar" title="productSearchCate">
	<li><a href="$!{contextPath}/">首页</a><span class="divider">></span>
		<a href="$!{contextPath}/titan/nhtop">农户置顶排序</a></li>
</DIV>
<input type="hidden" id="searchCid" value="$!{cid}">
<form class="well form-search" name="productSearchCateForm" id="productSearchCateForm" action="/titan/nhtop" method="POST" >

    请选择城市:
    <span id="cityBox"></span>
	<button type="submit" class="btn btn-sm btn-primary"><i class="icon-search icon-white search"></i>搜索</button>
	<button type="button"  class="btn btn-sm btn-primary btn-clear">清除</button>
	<a class="btn btn-sm btn-primary act-fancy" href="#fancyalter" style="float:right">新增区域</a>
</form>


<!-- 表格数据 -->
<table class="table table-striped table-bordered table-condensed grid">
	<thead>
		<tr>
			<th #sorting($!{productSearchSort} "id")>编号</th>
			<th #sorting($!{productSearchSort} "categoryName")>区域名称</th>
			<th #sorting($!{productSearchSort} "ProductSearchSortCount")>推荐商品数量</th>
			<th>操作</th>
		</tr>
	</thead>
	<tbody>
#foreach(${item} in ${page.result})
		<tr>
			<td style="width:20%;text-align:center;vertical-align:middle;">$!{item.id}</td>
			<td style="width:35%;text-align:center;vertical-align:middle;">$!{item.name}</td>
			<td style="width:20%;text-align:center;vertical-align:middle;">$!{item.ProductSearchSortCount}</td>
			<td class="textC" style="width:20%;text-align:center;vertical-align:middle;">
				<div class="btn-group">
					   <a  href="/titan/nhtop/sortlist?cateId=${item.cid}"><i class="icon-eye-open"></i> 添加排序商品</a>
    				   <a  href="javascript:void(0)" onclick="deleteSearchCate($!{item.cid})"><i class="icon-pencil"></i> 删除</a>
				</div>
			</td>
		</tr>
#end
	</tbody>
</table>


<div class="fancyalter" id="fancyalter">
  <h2 class="alterhd">添加区域</h2>
  <div class="alterbd">
        <div class="fancysearch">
            <div class="completethis" id="completethisId" style="width:550px">
                选择城市:
                <span id="city" class="required"></span>
            </div>
        </div>
        <div class="completethis">
		    <a href="#" class="addsucc" id="addsc">确定添加</a>
        </div>
  </div>
</div>

<!-- 分页栏 -->
#showPage($!{page})
<script src="/assets/js/underscore.js"></script>
<script src="/js/common/dilicity.js"></script>
<script>
	$(document).ready(function(){
        $(".btn-clear").click(function(){
//            $("#cityBox select:first option:first").prop("selected", 'selected');
//            $("#cityBox select:first option:first").change();
            window.location.href="/titan/nhtop";
        })
        //添加市场
        $("#addsc").live('click', function(){
            var cateStr = $("#sccid ").val();
            if(cateStr == null || cateStr==""){
                XUI.window.alert("区域必须选择到最后一级!");
                return ;
            }
            $.ajax({
                type : "post",
                dataType : "json",
                url      : "/titan/nhtop/save",
                data : {"cid" : cateStr},
                success  : function(data){
                    if(data.code == "success"){
                        window.location.href="/titan/nhtop";
                    }else{
                        XUI.window.alert(data.result);
                    }
                },
                error    : function(){
                    XUI.window.alert("网络错误,请稍后重试");
                }
            });

        });

        $("#productSearchCateForm").submit(function(){
            var cid = $("#cid").val();
            var isSelect = false;
            $("#cityBox").find("select").each(function () {
                var item = $(this).find("option:selected");
                if (item.val() != "" &&  item.val() !="请选择") {
                    isSelect = true;
                }
            });
            if(isSelect) {
                if (cid) {
                    return true;
                }
                alert("区域必须选择到最后一级!");
                return false;
            }
        })
	});

   function deleteSearchCate(cid){
        XUI.window.confirm("确定要删除排序市场吗?", "删除排序市场", function(){
            $.ajax({
                type : "post",
                dataType : "json",
                url      : "/titan/nhtop/delete",
                data : {cateId : cid},
                success  : function(data){
                    if(data.code == "success"){
                        //XUI.window.alert(" 排序分类已成功删除,若以后还需要对该分类商品进行排序,请重新添加排序分类!");
                        window.location.href="/titan/nhtop";
                    }else{
                        XUI.window.alert(data.result);
                    }
                },
                error    : function(){
                    XUI.window.alert("网络错误,请稍后重试");
                }
            });
        });
    }

 seajs.use(['fancybox'], function(fancybox){
      $(".act-fancy").fancybox({
        scrolling: 'visible',
		afterClose: function(){
            $("#city select:first option:first").prop("selected", 'selected');
            $("#city select:first option:first").change();
//            $("#productCategoryId select:first option:first").change();
		}
      });
  });

    /**
     * 城市选择
     */
    var pcfg = {
        name: "cid",
        #if(${cid})
            val:${cid}
        #end
    };
    $("#cityBox").diliCountry(pcfg);

    /**
     * 城市选择
     */
    var pcfg1 = {
        name: "sccid",
    };
    $("#city").diliCountry(pcfg1);
</script>