add.vm
5.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
#set($link=${webUtils.getLocalPath("authLevel/list.do")})
#set($page_title="添加认证等级")
#set($crumbs="首页:/home,认证等级:"+$link+",添加认证等级")
#set($upPath=${webUtils.getLocalPath("authLevel/uploadLevelLogo.do")})
<div class="page-content">
<div class="page-header">
<span class="pull-right"><a href="${webUtils.getLocalPath("authLevel/list.do")}"
class="btn btn-white btn-default">返回</a></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 -->
<form class="form-horizontal" role="form" method="post"
action="${webUtils.getLocalPath("authLevel/save.do")}" id="addForm">
<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">
<span class="block input-icon input-icon-right">
<input type="text"
placeholder="等级名称" name="authLevel.levelName" id="levelName"
required
data-bv-message="必须填写!"
data-bv-stringlength-message="超出了最大范围!"
data-bv-stringlength
data-bv-stringlength-max="10"
maxlength="10"
class="width-100"
value="$!{authLevel.levelName}"/>
<i class="ace-icon fa fa-asterisk orange"></i>
</span>
</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" id="authLevelLogo">
<span class="block input-icon input-icon-right">
<input id="uploadFile" class="uploadFile" name="image" type="file" required/>
<input type="hidden" name="authLevel.levelLogo" value="$!{model.levelLogo}"/>
## <div id="picTip"></div>
<div class="file-img">
<img id="imgLevelLogo" width="100" height="100" src="#if(${model.levelLogo}) $!{model.levelLogo}#end"/>
</div>
</span>
<p>图标支持jpg、jpeg、gif、png格式!</p>
</div>
</div>
<div class="clearfix form-actions">
<div class="col-md-offset-3 col-md-9">
<button id="sub" class="btn btn-info" type="button">
<i class="icon-ok bigger-110"></i>
提交
</button>
<a href="${webUtils.getLocalPath("authLevel/list.do")}" class="btn">
<i class="icon-undo bigger-110"></i>
返回
</a>
</div>
</div>
</form>
</div>
</div>
</div>
<script type="text/javascript" src="/assets/js/ajaxfileupload.js" )}"></script>
<script type="text/javascript" src="/assets/js/uploadImg.js" )}"></script>
<script type="text/javascript" >
$("#authLevelLogo").uploadImg({
url: "$upPath",
success: function (data) {
//debugger;
if (data && data.success) {
$("#imgLevelLogo").attr("src", data.message);
$("input[name='authLevel.levelLogo']").val(data.message);
}
else {
alert(data.message);
}
$("input[name='authLevel.levelLogo']").focus();
},
error: function (data) {
//debugger;
alert("上传失败,请重试!");
}
});
$("#sub").click(function () {
var levelName = $.trim($("#levelName").val());
if(levelName.length == 0){
alert("请填写等级名称!");
return;
}
var regHtml = new RegExp("^<(.*)>(.*)<\/(.*)>|<(.*)\/>$");
if(regHtml.test(levelName)){
alert("禁止输入html标签!");
return;
}
var regName = new RegExp("^(([a-zA-Z0-9_-])|([\u4e00-\u9fa5]))+$");
if(!regName.test(levelName)){
alert("名称只允许输入中文、字母、数字、下划线与横线!");
return;
}
$.ajax({
url: "/authLevel/checkName.do?id=&levelName="+levelName,
type : "post",
success : function (data){
if(data.code==1){
var imgLevelLogo = $.trim($("#imgLevelLogo").attr('src'));
if(imgLevelLogo.length == 0){
alert("请选择等级图标!");
return;
}
var form = $("#addForm");
form.submit();
}else{
alert("等级名称已存在,请更换!");
return;
}
}
});
});
</script>