add.vm 12.1 KB

#set($page_title="编辑")
#set($crumbs="首页:/home,编辑")

#set($url_save = "/resource/save.do")

<link href="$!{webUtils.getAssetsPath("/css/i-layout.css")}" rel="stylesheet" type="text/css" />
<style type="text/css">
    .width-100{width:344px !important}
</style>

<script type="text/javascript">
    $(document).ready(function(){
        $("#addUrl").click(function(){
            var urlobj = $('#re_url').html();
            $("#urls").append(urlobj);
        });

        $(".delUrl").live("click",function(){
            $(this).parent().remove();
        });
    });
</script>


<div class="page-content">
    <div class="page-header">
        <span class="pull-right">

        </span>
        <h1>
        管理
            <small>
                <i class="icon-double-angle-right"></i>
            功能
            </small>
        </h1>
    </div>
    <!-- /.page-header -->

    <div class="row">
        <div class="col-xs-12">
            <!-- PAGE CONTENT BEGINS -->

            <div id="re_url" class="hidden">
                <div>
                    <div class="form-group url-div">
                        <label class="col-sm-3 control-label no-padding-right"
                               for="form-field-4"> </label>

                        <div class="col-xs-12 col-sm-1">
                            <select required="true" id="method" name="methods" class="form-control url-input">
                                <option value="GET" selected >GET</option>
                                <option value="POST">POST</option>
                                <option value="DELETE">DELETE</option>
                                <option value="PUT">PUT</option>
                            </select>
                        </div>

                        <div class="col-xs-12 col-sm-4">
                            <input type="text" id="form-field-4"
                                   placeholder="URL" name="urls"
                                   value=""
                                   class="width-100 form-control url-input" required="true" >
                        </div>

                        <button class="delUrl btn btn-warning">
                            <i class="icon-ok bigger-110"></i>
                            删除
                        </button>
                    </div>
                </div>
            </div>


            <form id="resourceAdd" class="form-horizontal" role="form" method="post" action="$url_save">
                #if($model.id)
                <input type="hidden" value="$model.id" name="id">
                #end
                #if($req.getParameter("navbarId"))
                    <input type="hidden" value="$req.getParameter("navbarId")" name="navbarId">
                #end


                    <div class="form-group">
                        <label class="col-sm-3 control-label no-padding-right"
                               for="form-field-1"> 权限名称: </label>

                        <div class="col-xs-12 col-sm-4">
                            <input required="true" type="text" id="form-field-1"
                                   placeholder="权限名称" name="resourceName"
                                   value="$!{model.resourceName}"
                                   class="width-100">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label no-padding-right"
                               for="form-field-2"> 权限描述: </label>

                        <div class="col-xs-12 col-sm-4">
                            <input type="text" id="form-field-2"
                                   placeholder="权限描述" name="description"
                                   value="$!{model.description}"
                                   class="width-100">
                        </div>
                    </div>
##                    <div class="form-group">
##                        <label class="col-sm-3 control-label no-padding-right"
##                               for="form-field-3"> 模块: </label>
##
##                        <div class="col-xs-12 col-sm-4">
##                           <select required="true" id="form-field-3" name="navbarId" value="$!{model.navbarId}" class="form-control">
##                           #foreach($navbar in $navbars)
##                           		<option value="$navbar.id" #if($!{model.navbarId} == $navbar.id) selected #end>$navbar.projectName</option>
##                           #end
##                        	</select>
##                        </div>
##                    </div>
##                    <div class="form-group">
##                        <label class="col-sm-3 control-label no-padding-right"
##                               for="form-field-5"> 类型: </label>
##
##                        <div class="col-xs-12 col-sm-4">
##                        	<select id="type" required="true" form-field-4 name="type" value="$!{model.type} class="form-control width-100">
##                        		<option value="1" #if($!{model.type} == 1) selected #end>URL</option>
##                        		<option value="2" #if($!{model.type} == 2) selected #end>API</option>
##                        		<option value="3" #if($!{model.type} == 3) selected #end>FRAGEMENT</option>
##                        	</select>
##                        </div>
##                    </div>
                <input type="hidden" name="type" value="1">

                <div class="form-group url-div">
                    <div>
                        <label class="col-sm-3 control-label no-padding-right"
                               for="form-field-4"> URL: </label>
                    </div>
                    <div class="col-xs-2">
                        <a id="addUrl" class="btn btn-warning">
                            <i class="icon-ok bigger-110"></i>
                            新增
                        </a>
                    </div>
                </div>

##                <div class="form-group url-div">
##                    <div>
##                        <label class="col-sm-3 control-label no-padding-right"
##                               for="form-field-4"> </label>
##                    </div>
                #if($null != $!{resUrls} && 0 != $!{resUrls.size()})
                    <div id="urls">
                        #foreach($obj in $!{resUrls})
                            <div>
                                <div class="form-group url-div">
                                    <label class="col-sm-3 control-label no-padding-right"
                                           for="form-field-4"> </label>
                                    <div class="col-xs-12 col-sm-1">
                                        <select required="true" id="method" name="methods" value="$!{obj.method} class="form-control url-input">
                                        <option value="GET" #if($!{obj.method} == "GET") selected #end>GET</option>
                                        <option value="POST" #if($!{obj.method} == "POST") selected #end>POST</option>
                                        <option value="DELETE" #if($!{obj.method} == "DELETE") selected #end>DELETE</option>
                                        <option value="PUT" #if($!{obj.method} == "PUT") selected #end>PUT</option>
                                        </select>
                                    </div>
##                                        <label class="col-sm-3 control-label no-padding-right"
##                                               for="form-field-4"> URL: </label>

                                    <div class="col-xs-12 col-sm-4">
                                        <input type="text" id="form-field-4"
                                               placeholder="URL" name="urls"
                                               value="$!{obj.url}"
                                               class="width-100 form-control url-input" required="true" >
                                    </div>

                                    <button class="delUrl btn btn-warning">
                                        <i class="icon-ok bigger-110"></i>
                                        删除
                                    </button>
                                </div>
                            </div>
                        #end
                    </div>
                #else
                    <div id="urls">
                        <div>
                            <div class="form-group url-div">
                                <label class="col-sm-3 control-label no-padding-right"
                                       for="form-field-4"> </label>

                                <div class="col-xs-12 col-sm-1">
                                    <select required="true" id="method" name="methods" class="form-control url-input">
                                        <option value="GET" selected >GET</option>
                                        <option value="POST">POST</option>
                                        <option value="DELETE">DELETE</option>
                                        <option value="PUT">PUT</option>
                                    </select>
                                </div>

                                <div class="col-xs-12 col-sm-4">
                                    <input type="text" id="form-field-4"
                                           placeholder="URL" name="urls"
                                           value=""
                                           class="width-100 form-control url-input" required="true" >
                                </div>

                                <button class="delUrl btn btn-warning">
                                    <i class="icon-ok bigger-110"></i>
                                    删除
                                </button>
                            </div>
                        </div>
                    </div>
                #end
##                </div>


            ##                    <div class="form-group">
##                        <label class="col-sm-3 control-label no-padding-right"
##                               for="form-field-6">启用/禁用: </label>
##
##                        <div class="col-xs-12 col-sm-4">
##                           <select required="true" id="form-field-5" name="status" value="$!{model.status} class="form-control">
####                        		<option value="2" #if($!{model.status} == 2) selected #end>未认领</option>
##                        		<option value="1" #if($!{model.status} == 1) selected #end>启用</option>
##                        		<option value="0" #if($!{model.status} == 0) selected #end>禁用</option>
##                        	</select>
##                        </div>
##                    </div>
                <input type="hidden" name="status" value="1">

                <div class="clearfix form-actions">
                    <div class="col-md-offset-3 col-md-9">
                        <button class="btn btn-info" type="submit" id="submit">
                            <i class="icon-ok bigger-110"></i>
                            提交
                        </button>

                        &nbsp; &nbsp; &nbsp;
                        <a class="btn btn-info" href="javascript:history.back()">
                            <i class="icon-undo bigger-110"></i>
                            返回
                        </a>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>

<script src="$!{webUtils.getAssetsPath('/js/jquery.validate.min.js')}"></script>
<script src="$!{webUtils.getAssetsPath('/js/jquery.validate.extend.js')}"></script>
<script>
	$(document).ready(function(){
	
		if(3 == $('#type').val())
			$('.url-div').css("display","none");
			
  		$("#type").change(function(){
  			if(3 == this.value) {
  				$('.url-div').css("display","none");
				return;
			} 
			$('.url-div').css("display","block");
  		});
  		
  		
  		$("#submit").click(function(){
  			if(3 == $('#type').val()) {
  				$(".url-input").removeAttr("required");
  			}
  		});
	});
</script>