list.vm 10.8 KB
<link rel="stylesheet" href="/assets/css/auth.css" />
<script type="text/javascript" src="/assets/js/jquery.js"></script>
<script type="text/javascript" src="/assets/js/jQuery-Form.js"></script>
<DIV id="navBar" title="auth">
	<li><a href="$!{contextPath}/">首页</a><span class="divider">></span>
	<a href="$!{contextPath}/titan/auth">认证管理</a></li>
</DIV>

<div class="btn-group pull-right" style="margin-bottom:6px">
	<a class="btn btn-sm btn-primary" href="javascript:void(0)" id="addData"><i class="icon-pencil"></i>新增</a>
</div>

<!-- 表格数据 -->
<table class="table table-striped table-bordered table-condensed grid" style="text-align: center">
	<thead>
		<tr>
			<th #sorting($!{auth} "name")>认证名称</th>
			<th #sorting($!{auth} "authIcon")>认证图标</th>
			<th #sorting($!{auth} "status")>状态</th>
			<th>操作</th>
		</tr>
	</thead>
	<tbody>
#foreach(${item} in ${page.result})
		<tr>
			<td>$!{item.name}</td>
			<td><img src="$!{item.authIcon}" width="30px" height="30px"/></td>
			<td>
				#if($!{item.status} == 2)
					已停用 
				#else
					已启用
				#end	
			</td>
			<td class="textC">
				<div class="btn-group">
					#set($scopeIdstr="")
					#set($i=1)
					#foreach($scope in $!{item.scopeSet})	
					   #set($scopeIdstr = $scopeIdstr + ${scope.getScopeId()})
					   #if($i < $!{item.scopeSet.size()})
					     #set($scopeIdstr = $scopeIdstr + ",")
					   #end
					   #set($i = $i + 1)
					#end	
					<a href="javascript:void(0)" onClick="editData($!{item.id},'$!{item.name}','$!{scopeIdstr}','$!{item.authIcon}')"><i class="icon-pencil"></i>修改</a>
					<a  onClick="changeStates($!{item.id},$!{item.status})" href="javascript:void(0)"><i class="icon-pencil"></i>
						#if($!{item.status} == 2)
        					启用
        				#else
        					停用 
        				#end					
					</a>
				</div>
			</td>
		</tr>
#end
	</tbody>
</table>

<!-- 分页栏 -->

<script>

  $(function(){
  	$('#uploadImg').live('change', function(){
		//请求地址
		jQuery("#imageForm").ajaxSubmit(function(result){
		   if(!result.succ){
		      XUI.window.alert(result.messg);
			  jQuery("#uploadImg").resetForm();
			  return false;
		   }
		   $("#authIcon_id").val(result.messg);
		   $("#icon_id").attr("src",result.messg);
	    });
	});
  
	
   //添加数据
   $("#addData").click(function(){
   		$("#pop_title").html("新增");
		$("#u54").show();
		 var winHeight = document.body.scrollHeight;
		$("#mc_id").show();
		$("#mc_id").height(winHeight);
   });
   
   $("#u71_input").click(function(){
		if(document.getElementById("u71_input").checked){
		   $("#u72_input").attr("checked","checked");
		}else{
		   $("#u72_input").removeAttr("checked");
		}
   });
   $("#u72_input").click(function(){
		if(document.getElementById("u72_input").checked){
		   $("#u71_input").attr("checked","checked");
		}else{
		   $("#u71_input").removeAttr("checked");
		}
   });   
      
   
   
   //提交添加或修改的数据
    $("#u68_input").click(function(){
		var v = $("#addAuthForm");
    	var authName = $("#u65_input").val();
    	if(authName == ""){
			XUI.window.alert("认证名称不能为空!");
			return;
		}
		if(authName.length > 10){
			XUI.window.alert("认证名称长度不能超过10个字符!");
			return;
		}
		var message="请输入合法的认证名称(中文汉字、英文字母(含大小写)、数字、“/,(),&,《》,【】,[],=,+”)";
        var regex=/^[0-9a-zA-Z\u4e00-\u9fa5/()()&《》【】\+=\]\[,]+$/g;
		if (authName=="" || !regex.test(authName)) {
            XUI.window.alert(message);
			return false;
		}
		var authId = $("#authId").val();
		if($("#authIcon_id").val() == ""){
		   XUI.window.alert("请选择认证图片!");
		   return false;
		}
		$.ajax({
                 type : 'post', 
                  url : '$!{contextPath}/titan/auth/checkAuthName?name='+authName+'&authId='+authId,
                  async : false, 
                  success : function(msg){
                    if(msg == "1"){
					  XUI.window.alert("该认证名称已经存在了!");
					  return;
					}else if(msg == "2"){
					   XUI.window.alert("参数错误!");
					   return;
					}else{
					    $("#name_id").val(authName);
					  	var auth_scope="";
                		if(document.getElementById("u71_input").checked){
                		   var dilizy = $("#u71_input").val();
                		    auth_scope = dilizy;
                		}
                		if(document.getElementById("u72_input").checked){
                			var dilidx = $("#u72_input").val();
                			auth_scope = auth_scope + ','+dilidx;
                		}
                		if(document.getElementById("u73_input").checked){
                			var mmdj = $("#u73_input").val();
                			auth_scope = auth_scope + ','+mmdj;
                		}		
                		if(auth_scope !=""){
                		  $("#authScopeId").val(auth_scope);
                		}else{
						   XUI.window.alert("请选择经营范围!");
                		   return;
                		}
                		if($("#authScopeId").val() == ""){
                		   return;
                		}
                        v.submit();
					}
                  } 
         });
    });
	
	$("#u60").click(function(){
	    $("#u65_input").val("");
	    $("#authId").val("");
		$("#authIcon_id").val("");
   	    $("#u71_input").removeAttr("checked");
	    $("#u73_input").removeAttr("checked");
	    $("#u72_input").removeAttr("checked");
		$("#icon_id").attr("src","/img/auth/u45.png");
	    $("#u54").hide();
		$("#mc_id").hide();
	});

   });
   
	//修改数据
   function editData( id, name, scopeIdStr, icon){
	 var winHeight = document.body.scrollHeight;
	$("#mc_id").show();
	$("#mc_id").height(winHeight);   
	 $("#u54").show();
	 $("#pop_title").html("修改");
	 $("#u65_input").val(name);
	 $("#authId").val(id);
	 var scope = scopeIdStr.split(",");
	 for(var i=0;i<scope.length;++i){
	    if(scope[i] == 1){
		   $("#u71_input").prop("checked","checked");
		}else if(scope[i] == 2){
		   $("#u72_input").prop("checked","checked");
		}else if(scope[i] == 4){
		   $("#u73_input").prop("checked","checked");
		}
	 }
	 $("#icon_id").attr("src",icon);
	 $("#authIcon_id").val(icon);
	 $("#authId").val(id);
   }
   
   function changeStates(id,states){
       var content = ""; 
        if(states == 1){
		   content = "确定要停用该认证吗?";
		}else if(states == 2){
		   content = "确定要启用该认证吗?";
		}
        XUI.window.confirm(content, "认证确认窗口", function(){
            $.ajax({
                type : "post",
                url      : "/titan/auth/"+id+"?status="+states,
                success  : function(data){
                    if(data){
                        if(data == "success"){
                            window.location.href =  "/titan/auth";
                        }else{
                            XUI.window.alert("操作失败,请刷新页面重试!");
                        }
                    }
                },
                error : function(){
                    XUI.window.alert("网络错误,请稍后重试");
                }
            });
        });	  
   }
</script>

<div style="width:100%; height:100%; opacity:0.5; background:#000; z-index:99; position: absolute; top: 0; display:none" id="mc_id"></div>

<div id="u54" style="display:none; z-index:999">
        <div class="panel_state" id="u54_state0">
          <div class="panel_state_content" id="u54_state0_content">
            <div id="u55">
              <img src="/img/auth/u55.png" class="img " id="u55_img">
              <div class="text" id="u56">
                <p><span>&nbsp;</span></p>
              </div>
            </div>
            <div  id="u57">
              <img src="/img/auth/u57.png" class="img " id="u57_img">
              <div class="text" id="u58">
                <p><span style="font-family:'Arial Normal', 'Arial';font-weight:400;">&nbsp; &nbsp; </span><span id="pop_title" style="font-family:'Arial Negreta', 'Arial';font-weight:700;">新增</span></p>
              </div>
            </div>
            <div  id="u59" style="cursor: pointer;">
              <div class="text" id="u60">
                <p><span>×</span></p>
              </div>
            </div>
            <div  id="u61">
              <div class="text" id="u62">
                <p><span>认证名称:</span></p>
              </div>
            </div>
            <div  id="u63">
              <div class="text" id="u64">
                <p><span>认证</span><span>图片</span><span>:</span></p>
              </div>
            </div>

            <div  id="u65">
              <input type="text" name="name" id="u65_input">
            </div>
            <div class="ax_html__" id="u67">
                <!-- <input type="file" value="上传" name="authIconFile" id="u67_input"> -->
                <form id="imageForm" action="/titan/auth/uploadAuthIcon" enctype="multipart/form-data" method="POST">
                    <input name="image" type="file" id="uploadImg" value="上传图片" accept="image/gif,image/jpeg,image/png,image/jpg,image/bmp" style="line-height: normal;width:200px;"/>
                </form>
            </div>
            <div  id="u681">
                <img src="/img/auth/u45.png" width="70px" height="60px" id="icon_id"></img>
			</div>	
            <div class="ax_html__" id="u68" style="cursor: pointer;">
              <input type="button" value="提交" id="u68_input" tabindex="0">
            </div>

            <div class="ax_文本" id="u69">
              <div class="text" id="u70">
                <p><span>运营范围</span><span></span><span>:</span></p>
              </div>
            </div>
            <div class="ax_复选框" id="u71">
              <label for="u71_input">
                <div class="text" id="u72">
                  <p><span>自营</span></p>
                </div>
              </label>
              <input type="checkbox" value="1" id="u71_input">
            </div>

            <div class="ax_复选框" id="u75">
              <label for="u72_input">
                <div class="text" id="u76">
                  <p><span>代销</span></p>
                </div>
              </label>
              <input type="checkbox" value="2" id="u72_input">
            </div>
			
            <div class="ax_复选框" id="u73">
              <label for="u73_input">
                <div class="text" id="u74">
                  <p><span>买卖对接</span></p>
                </div>
              </label>
              <input type="checkbox" value="4" id="u73_input">
			  <form id="addAuthForm" action="/titan/auth/save" method="post">
    			  <input name="authScope" id="authScopeId" type="hidden">
    			  <input name="id" id="authId" type="hidden">
				  <input type="hidden" name="name" id="name_id">
				 <input type="hidden" name="authIcon" id="authIcon_id">
			  </form>
            </div>
          </div>
        </div>