Commit a480376d authored by ms-dev's avatar ms-dev
Browse files

优化结构

parent cd4672a3
<#--模态框按钮区域 废弃-->
<#macro modalButtonarea>
<div class="modal-footer">
<#nested/>
</div>
</#macro>
<#--警告的模态框-->
<#macro warn modalName>
<div id="warn${modalName}Dialog" class="modal fade ${modalName}" tabindex="-1" data-focus-on="input:first">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true"></button>
<h4 class="modal-title" id="warn${modalName}Title">警告!</h4>
</div>
<div class="modal-body" id="warn${modalName}Body">
<#nested/>
</div>
<div class="modal-footer">
<button type="button" data-dismiss="modal" class="btn btn-default">关闭</button>
<button type="button" id="warn${modalName}Ok" class="btn btn-primary right" >确定</button>
</div>
</div>
</div>
</div>
</#macro>
<#--模块框 modalName废弃属性-->
<#macro modal id="" title="标题" style="" height="300" resetFrom=true modalName="" size="S">
<#if style!="">
<#assign _style="${style}">
<#elseif size=="S">
<#assign _style="width:450px;height:150px;">
<#elseif size=="M">
<#assign _style="width:600px;height:500px;">
<#elseif size=="L">
<#assign _style="width:900px;height:650px;">
</#if>
<div class="modal fade ${modalName}${id}" id="${modalName}${id}" >
<div class="modal-dialog" style="${_style};">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
<h4 class="modal-title" id="${modalName}${id}Title">
${title}
</h4>
</div>
<#nested/>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
<script>
<#if resetFrom>
$(function(){
$('#${modalName}${id}').on('hide.bs.modal', function (event) {
if ($("#${modalName}${id} form").length>0) {
$("#${modalName}${id} form").data('bootstrapValidator').resetForm(true);
$("#${modalName}${id} form")[0].reset();
}
})
});
</#if>
</script>
</#macro>
<#--模态框内容 height属性废弃, 直接在style里面修改-->
<#macro modalBody style="" height="">
<div class="modal-body" style="${style}">
<#nested/>
</div>
</#macro>
<#--模态框按钮区域-->
<#macro modalButton>
<div class="modal-footer">
<#nested/>
</div>
</#macro>
<#--通用弹窗-->
<#--modalName:弹出窗的名称-->
<#--调用方法open弹出窗口名称,例如:窗口名称 abc ,调用openabc('展示内容','标题')-->
<#--注意使用的时候,message的内容只能是id或字符串对象-->
<#macro modalDialog modalName>
<div class="modal fade" id="${modalName}Dialog" style="overflow-y: hidden;">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
<h4 class="modal-title" id="${modalName}Title">
</h4>
</div>
<!--startprint-->
<div class="modal-body" id="${modalName}Body">
</div>
<!--添加其他信息-
<div class="modal-footer" id="${modalName}Footer">
</div>
-->
<!--endprint-->
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
<script>
function open${modalName}(message,title) {
if (title) {
$("#${modalName}Title").html(title);
}
try {
if (message) {
message.show();
}
} catch(e){
<@ms.notify msg= "文本" type= "warning" />
}
$("#${modalName}Body ").html(message);
$('#${modalName}Dialog').modal();
}
function close${modalName}() {
$('#warn${modalName}Dialog').modal('hide');
}
</script>
</#macro>
<#--通用警告弹窗-->
<#--warnModal:弹出窗的名称-->
<#--调用方法open弹出窗口名称,例如:窗口名称 abc ,调用openabc('展示内容','标题','点击确定按钮之后回调方法,如果没有则不会显示确认按钮')-->
<#macro warnModal modalName>
<div id="warn${modalName}Dialog" class="modal fade" tabindex="-1" data-focus-on="input:first">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true"></button>
<h4 class="modal-title" id="warn${modalName}Title">警告!</h4>
</div>
<div class="modal-body" id="warn${modalName}Body">
</div>
<div class="modal-footer">
<button type="button" data-dismiss="modal" class="btn btn-default">关闭</button>
<button type="button" id="warn${modalName}Ok" class="btn btn-primary right" style="display:none">确定</button>
</div>
</div>
</div>
</div>
<script>
function warn${modalName}(message,title,func) {
if (title) {
$("#warn${modalName}Title").html(title);
}
if(func) {
$("#warn${modalName}Ok ").show();
$("#warn${modalName}Ok ").one("click",function(){
eval(func);
});
}
$("#warn${modalName}Body ").html(message);
$('#warn${modalName}Dialog').modal();
}
function closewarn${modalName}() {
$('#warn${modalName}Dialog').modal('hide');
}
</script>
</#macro>
<#--后台的UI界面通用区域定义-->
<#macro html5 width="100%" style="">
<!DOCTYPE html>
<html lang="en">
<head>
<#include "/include/macro.ftl"/>
<#include "/include/meta.ftl"/>
</head>
<body>
<div class="ms-content">
<div class="ms-content-body" style="width:${width};${style}">
<#nested/>
<div class='notifications ms-notifications top-right'></div>
</div>
</div>
</body>
</html>
</#macro>
<#macro nav title="板块名称" back=false style="">
<div class="ms-content-body-title" style="${style}">
<strong>${title}</strong>
<#nested/>
<#if back>
<@ms.backButton/>
</#if>
</div>
</#macro>
<#--面板-->
<#macro panel style="">
<div class="ms-content-body-panel" style="${style}">
<#nested/>
</div>
</#macro>
<#--面板导航-->
<#macro panelNav empty=false>
<div class="ms-content-body-panel-nav" <#if empty>style=" padding: 0;"</#if>>
<#nested/>
</div>
</#macro>
<#--提示-->
<#macro notify msg="提示信息" type="warning">
$('.ms-notifications').offset({top:43}).notify({
type:'${type}',
message: { text:'${msg}' }
}).show();
</#macro>
\ No newline at end of file
<label class="ms-radio" style="padding-right:10px"><input type="radio"<#rt/>
value="${rkey}"<#rt/>
<#if onclick?? && onclick!=""> onclick="${onclick}"</#if><#rt/>
<#if disabled?? && disabled> disabled="disabled" </#if><#rt/>
<#if (rkey?string=="" && (!value?? || value?string=="")) || (value?? && value?string!="" && value?string==rkey?string)> checked="checked"</#if><#rt/>
<#include "/include/ui/common-attributes.ftl"/><#rt/>
/> ${rvalue} </label> <#if hasNext> </#if>
<#--
<select><option></option></select>
-->
<#macro select
list=[] value="" multiple=false listKey="" listValue="" listDeep=""
label="" validation="" colon=":" hasColon="true" readonly=""
id="" name="" class="form-control" style="" size="" title="" disabled=false
labelStyle=""
width=""
help=""
helpDirection=""
default=""
defaultValue=""
select2=false
>
<div class="form-group ms-form-group">
<#include "/include/ui/control.ftl"/><#rt/>
<div class="col-sm-9 ms-form-control ms-from-group-input" <#if width!=""> style="width:${width}px"</#if><#rt/>>
<select<#rt/>
<#if id!=""> id="${id}"</#if><#rt/>
<#if multiple>multiple="multiple"</#if><#rt/>
<#if readonly!=""> readonly="${readonly}"</#if><#rt/>
<#include "/include/ui/common-attributes.ftl"/><#rt/>
><#rt/>
<#if default?has_content>
<option value="<#if value?has_content>${value}</#if>">${default}</option>
</#if>
<#if list?is_sequence><#--LIST-->
<#if listKey!="" && listValue!="">
<#list list as item>
<#local rkey=item[listKey]>
<#local rvalue=item[listValue]>
<option value="${rkey}" <#if rkey?string==value?string> selected="selected"</#if>>${rvalue}</option><#rt/>
</#list>
<#else>
<#list list as item>
<option value="${item}" <#if item?string==value?string> selected="selected"</#if>>${item}</option><#rt/>
</#list>
</#if>
<#else>
<#list list?keys as key>
<#local rkey=key/>
<#local rvalue=list[key]/>
<option value="${rkey}" <#if rkey?string==value?string> selected="selected"</#if>>${rvalue}</option><#rt/>
</#list>
</#if>
</select>
</div>
</div>
<#if select2>
<script>
$(function() {
$("select[name='${name}']").select2({width: "${width}px"});
$("select[name='${name}']").select2().val("${value}").trigger("change");;
})
</script>
</#if>
</#macro>
<#macro select2 name list value="" multiple=false listKey="" listValue="" listDeep="" default="请选择"
label="" validation="" colon=":" hasColon="true" readonly=""
class="form-control" style="" size="" title="" disabled=false
labelStyle=""
width=""
>
<select id="${name}" name="${name}">
<option></option>
</select>
<script>
$(function() {
$("#${name}").select2():
})
</script>
</#macro>
<#--表格列表-->
<#--head:表格头部标题,数值格式-->
<#--head:表格头部标题-->
<#macro table head="" filed="" listItem="" editField="" editJs="" checkbox="" id="" dateformat="yyyy-MM-dd">
<script>
<#if checkbox?has_content>
$(function() {
$("input[name='allCheck${checkbox}']").on("click",function(){
if(this.checked){
$("input[name='${checkbox}']").each(function(){
this.checked=true;
});
}else{
$("input[name='${checkbox}']").each(function(){this.checked=false;});
}
});
})
</#if>
</script>
<table class="table table-hover">
<!--表格栏目属性 开始-->
<thead>
<tr>
<#if checkbox?has_content>
<th class="text-center" width="10">
<input type="checkbox" name="allCheck${checkbox}">
</th>
</#if>
<#if head?has_content>
<#list head as h>
<#if h?html?length gt 5 && h?html?substring(0,6)=="&lt;th">
${h}
<#elseif h?contains(",") && h?split(",")[1]?eval gt 0>
<th width="${h?split(",")[1]}">
${h?split(",")[0]}
</th>
<#else>
<th>
${h}
</th>
</#if>
</#list>
</#if>
</tr>
<#if filed?has_content && listItem?has_content>
<#list listItem?eval as item>
<tr>
<#if checkbox?has_content >
<td>
<input type="checkbox" name="${checkbox}" value="${item[checkbox]}">
</td>
</#if>
<#list filed as f>
<td>
<#if editField?seq_contains(f)>
<a href="javascript:${editJs}(${item[checkbox]})">${item[f]}</a>
<#else>
<#if item[f]?has_content && item[f]?is_date>
${item[f]?string(dateformat)}
<#else>
${item[f]?default('-')}
</#if>
</#if>
</td>
</#list>
</tr>
</#list>
<#if listItem?eval?size==0>
<tr>
<td colspan="${filed?size+1}"><@ms.nodata content="暂无数据" /></td>
</tr>
</#if>
</#if>
</thead>
<!--表格栏目属性 结束-->
<tbody id=${id}>
<#nested/>
</tbody>
</table>
</#macro>
\ No newline at end of file
<#--
<textarea name="textarea"></textarea>
-->
<#macro textarea
name
wrap="soft"
readonly=""
cols=""
rows=""
value=""
label=""
title=""
required="false"
id=""
class="form-control"
style=""
size=""
disabled=false
maxlength=""
placeholder=""
validation=""
labelStyle=""
width=""
help=""
helpDirection=""
colSm=""
>
<div class="form-group ms-form-group">
<#include "/include/ui/control.ftl"/><#rt/>
<div class="ms-form-control ms-from-group-input col-sm-9" style="<#if width!="">width:${width}px;</#if>"<#rt/>>
<textarea<#rt/>
<#if id!=""> id="${id}"</#if><#rt/>
<#if wrap!=""> wrap="${wrap}"</#if><#rt/>
<#if readonly!=""> readonly="${readonly}"</#if><#rt/>
<#if cols!=""> cols="${cols}"</#if><#rt/>
<#if rows!=""> rows="${rows}"</#if><#rt/>
<#include "/include/ui/common-attributes.ftl"/><#rt/>
><#if value?? && value!="">${value!?html}</#if></textarea>
</div>
</div>
</#macro>
<#--
<input type="t"/>
-->
<#macro time id="" name="" value=""
label="" title="" size="" labelStyle="" width=""
class="form-control" style="" readonly="" disabled=false maxlength="" minlength="" placeholder="" validation=""
help=""
helpDirection=""
>
<div class="form-group ms-form-group">
<#include "/include/ui/control.ftl"/><#rt/>
<div class="control-group col-sm-9 ms-from-group-input" style="min-widht:200px;<#if width!="">width:${width}px</#if>"<#rt/>>
<div class="controls">
<div class="input-prepend input-group date" <#if id!=""> id="${id}"<#elseif name!="">id="${name}"</#if><#rt/>
data-date="" data-date-format="hh:ii" data-link-format="hh:ii">
<span class="add-on input-group-addon"><i class="glyphicon glyphicon-time"></i></span>
<input type="text"<#rt/>
<#if maxlength!=""> maxlength="${maxlength}"</#if><#rt/>
<#if readonly!=""> readonly="${readonly}"</#if><#rt/>
<#if value?? && value?string!=""> value="${value?html}"</#if><#rt/>
<#include "/include/ui/common-attributes.ftl"/><#rt/>/>
</div>
</div>
</div>
</div>
<script>
$(function(){
$('#${name}').datetimepicker({
language: 'cn',
todayBtn: 1,
autoclose: true,
todayHighlight: 1,
format: 'hh:ii',
startView: 1,
minView: 0,
maxView: 1,
forceParse: 0,
});
});
</script>
</#macro>
<#-- 树形控件,以input下拉框的形式显示(官网:http://www.ztree.me/v3/main.php#_zTreeInfo) -->
<#-- treeId(必须):树形加载和控制区域的ID,一张页面同时加载多个树形时必须用该值进行区分 -->
<#-- json(必须):需要加载成树形的数据,数据结构为:[{categoryId:1,categoryCategoryId:0,categoryTitle:""},{categoryId:2,categoryCategoryId:1,categoryTitle:""}] -->
<#-- jsonId(必须):json数据中ID名称,如:categoryId -->
<#-- jsonPid(必须):json数据中关联的父ID,如:categoryCategoryId -->
<#-- jsonName(必须):json数据中需要显示的数据名称,如:categoryTitle -->
<#-- jsonUrl:如过json数据中存在跳转地址则直接将字段名称填入点击树形时可自动跳转 -->
<#-- addNodesName:增加顶级根节点,直接传入根节点名称即可。如:顶级分类 -->
<#-- buttonText:选择框加载的默认提示信息 -->
<#-- inputName(必须):隐藏input框的name值,用于保存选中数据的ID -->
<#-- inputValue:隐藏input框的val默认值,适用用于加载初始化数据 -->
<#-- inputId:隐藏input框的id值,用于保存选中数据的ID -->
<#-- selectParent:用户选择父节点时的提示信息,当该值存在时,用户不能选择存在子节点的父节点,并提示传入的值,当该值不存在时用户可以选择任意 -->
<#-- clickZtreeId: 选择节点后触发的事件-->
<#-- expandAll:控制节点数据显示的时候是全部展开还是全部折叠(true[默认]:全部展开,false:全部折叠)。 -->
<#-- showIcon:是否显示文件夹图标,true:显示;false(默认):不显示 -->
<#-- 内置函数调用方法说明:
调用对象的函数名: zTreeObj${treeId}(treeId为自定义的ID名称);
/**
* 根据节点数据的属性搜索,获取条件完全匹配的单一节点数据 JSON 对象
* 如有重复则返回最近的一条。
* @param key:需要精确匹配的属性名称
* @param value:需要精确匹配的属性值,可以是任何类型,只要保证与 key 指定的属性值保持一致即可
* @param parentNodeJSON:搜索范围,指定在某个父节点下的子节点中进行搜索忽略此参数,为null时表示在全部节点中搜索
* @return JSON
*/
zTreeObj${treeId}.getNodeByParam(key,value,parentNode);
/**
* 获取根节点数据,既获取PID=0的数据集合
* @return ArrayList(json)
*/
zTreeObj${treeId}.getNodes();
/**
* 根据节点数据的属性搜索,获取条件完全匹配的节点数据 JSON 对象集合
* @param key:需要精确匹配的属性名称
* @param value:需要精确匹配的属性值,可以是任何类型,只要保证与 key 指定的属性值保持一致即可
* @param parentNode:可以指定在某个父节点下的子节点中搜索,为null时表示在全部节点中搜索
* @return ArrayList(json)
*/
zTreeObj${treeId}.getNodesByParam(key,value,parentNode);
-->
<#--废弃,推荐使用inputTree 参考input_tree.ftl-->
<#macro treeInput treeId="" json="" jsonId="" jsonPid="" jsonName="" jsonUrl="" addNodesName="" buttonText="" inputName="" inputValue="" inputId="" selectParent="" clickZtreeId="" expandAll="true" showIcon="false" >
<!-- css样式开始 -->
<style type="text/css">
.ztree${treeId}{width:100%;max-height: 240px;overflow:auto;}
.ztree${treeId} li a{padding:0}
</style>
<!-- css样式结束 -->
<!-- 初始化样式开始 -->
<div class="dropdown" id="${treeId}">
<button type="text" id="treeLabel${treeId}" class="form-control dropdown-toggle" data-toggle="dropdown" aria-expanded="true" style="text-align:left">
${buttonText?default('请选择')}
</button>
<input type="hidden" <#if inputName?has_content>name="${inputName}"</#if> <#if inputId?has_content>id="${inputId}"</#if> value="${inputValue?default(0)}">
<ul class="ztree ztree${treeId} dropdown-menu" role="menu" id="treeDome${treeId}" aria-labelledby="treeLabel${treeId}">
</ul>
</div>
<!-- 初始化样式结束 -->
<!-- js操作方法开始 input -->
<script>
//初始化树形数据
var zNodes${treeId} = <#if json?has_content>${json}<#else>[]</#if>;
//初始化树形结构
var setting${treeId} = {
view:{//控制视图
fontCss:{"white-space":"normal","display":"initial","word-break":"break-all"},
showIcon:${showIcon},//是否显示节点文件夹图标
showLine:true,//是否显示借点连接线
expandSpeed:"",//折叠时的动画速度,参考jquery中动画效果的speed参数,三种预定速度之一的字符串("slow", "normal", or "fast")
},
data: {//控制显示数据
simpleData: {
enable: true,//是否采用简单数据模式 (Array)
idKey:"${jsonId}",//节点ID名称
pIdKey:"${jsonPid}",//父节点ID名称
},
key:{
name:"${jsonName}",//节点数据保存节点名称的属性名称。
url:"${jsonUrl}",//节点跳转地址属性
}
},
callback: {//控制获取选择的节点数据
beforeClick:<#if selectParent?has_content>beforeClick${treeId}<#else>null</#if>,//用于捕获单击节点之前的事件回调函数,并且根据返回值确定是否允许单击操作
onClick:getZtreeId${treeId},//用于捕获节点被点击的事件回调函数
},
check:{//控制节点的选中方式(暂时未启用,根据后期需求再做调整)
autoCheckTrigger:true,//是否触发自动勾选
enable:false,//节点上是否显示选择框,false:不显示,true:显示。
chkStyle:"checkbox",//勾选框类型(checkbox[默认值] radio)
chkboxType:{"Y":"ps","N":"ps"},//设置勾选关联关系
},
};
var zTreeObj${treeId}="";
$(function(){
//自定义顶级栏目
<#if addNodesName?has_content>
zNodes${treeId}[zNodes${treeId}.length] = {${jsonName}:"${addNodesName}",${jsonId}:0,${jsonPid}:0};
</#if>
//加载树形
$.fn.zTree.init($("#treeDome${treeId}"),setting${treeId},zNodes${treeId});
//zTree内部函数对象,主要用户调用zTree内部方法
zTreeObj${treeId} = $.fn.zTree.getZTreeObj("treeDome${treeId}");
//展开(true)/折叠(false)全部节点(zTree内部方法)
zTreeObj${treeId}.expandAll(${expandAll});
//加载默认节点
<#if inputValue?has_content>
zTreeObj${treeId}.selectNode(zTreeObj${treeId}.getNodeByParam("${jsonId}",${inputValue},null));
</#if>
//当属性为折叠时,控制下拉菜单的开启和关闭
<#if expandAll = "false">
$("body").on("click",function(e) {
e = window.event || e; // 兼容IE7
//获取当前点击事件对象
var objZtree = $(e.srcElement||e.target);
//获取当前点击事件ID,并对点击的子节点ID进行切割获取自定义ID
var objZtreeId = objZtree.attr("id");
//当用户点击选择框时还原下拉框属性
if(objZtreeId != undefined && objZtreeId.split("_")[0] == "treeLabel${treeId}"){
$("#treeDome${treeId}").attr("style","");
return ;
}
//切割获取到的ID判断点击事件是否产生在下拉框
if(objZtreeId != undefined && objZtreeId.split("_")[0] == "treeDome${treeId}"){
$("#treeDome${treeId}").attr("style","display:block");
}else{
$("#treeDome${treeId}").attr("style","display:none");
}
});
</#if>
});
<#if selectParent?has_content>
//对节点选择进行限制,用户只能选择子节点
function beforeClick${treeId}(treeId,treeNode) {
var check = (treeNode && !treeNode.isParent);
if (!check){
$("#treeLabel${treeId}").text("${selectParent}");
};
return check;
}
</#if>
//获取树形中选中的值,将选择值加载到隐藏框中
function getZtreeId${treeId}(event,treeId,treeNode){
var booleanClick = true;
//用于捕获节点被点击的事件回调函数
<#if clickZtreeId?has_content>
booleanClick=${clickZtreeId};
</#if>
if(booleanClick==false){
return;
}
//将用户选择数据ID加载到隐藏框
$("#${treeId} input[name='${inputName}']").val(treeNode.${jsonId});
//将用户选择数据的名称加载到输入框
$("#treeLabel${treeId}").text(treeNode.${jsonName});
}
</script>
<!-- js操作方法结束 -->
</#macro>
<#------------------------------------------------------------------------------------------------------------------------------------------------------------------>
<#--
getZtreeId:外部重写JS方法:
/**
* 外部点击树形节点时触发的事件,(传入参数必须与下述参数名保持一致)
* event:获取到的触发事件
* treeId:载体ID,这里为:treeDome${treeId}
* treeNode:内置函数对象,这里可直接调用内置函数方法
* treeNode.${jsonId}:获取点击的树形节点的ID
* treeNode.${jsonName}:获取点击树形节点的名称
* .....
*/
getZtreeId${treeId}(event,treeId,treeNode);
-->
<#-- 树形控件,以input下拉框的形式显示(官网:http://www.ztree.me/v3/main.php#_zTreeInfo) -->
<#-- treeId(必须):树形加载和控制区域的ID,一张页面同时加载多个树形时必须用该值进行区分 -->
<#-- json(必须):需要加载成树形的数据,数据结构为:[{categoryId:1,categoryCategoryId:0,categoryTitle:""},{categoryId:2,categoryCategoryId:1,categoryTitle:""}] -->
<#-- jsonId(必须):json数据中ID名称,如:categoryId -->
<#-- jsonPid(必须):json数据中关联的父ID,如:categoryCategoryId -->
<#-- jsonName(必须):json数据中需要显示的数据名称,如:categoryTitle -->
<#-- jsonUrl:如过json数据中存在跳转地址则直接将字段名称填入点击树形时可自动跳转 -->
<#-- addNodesName:增加顶级根节点,直接传入根节点名称即可。如:顶级分类 -->
<#-- expandAll:控制节点数据显示的时候是全部展开还是全部折叠(true[默认]:全部展开,false:全部折叠)。 -->
<#-- showIcon:是否显示文件夹图标,true:显示;false(默认):不显示 -->
<#-- 内置函数调用方法说明:
调用对象的函数名: zTreeObj${treeId}(treeId为自定义的ID名称);
/**
* 根据节点数据的属性搜索,获取条件完全匹配的单一节点数据 JSON 对象
* 如有重复则返回最近的一条。
* @param key:需要精确匹配的属性名称
* @param value:需要精确匹配的属性值,可以是任何类型,只要保证与 key 指定的属性值保持一致即可
* @param parentNodeJSON:搜索范围,指定在某个父节点下的子节点中进行搜索忽略此参数,为null时表示在全部节点中搜索
* @return JSON
*/
zTreeObj${treeId}.getNodeByParam(key,value,parentNode);
/**
* 获取根节点数据,既获取PID=0的数据集合
* @return ArrayList(json)
*/
zTreeObj${treeId}.getNodes();
/**
* 根据节点数据的属性搜索,获取条件完全匹配的节点数据 JSON 对象集合
* @param key:需要精确匹配的属性名称
* @param value:需要精确匹配的属性值,可以是任何类型,只要保证与 key 指定的属性值保持一致即可
* @param parentNode:可以指定在某个父节点下的子节点中搜索,为null时表示在全部节点中搜索
* @return ArrayList(json)
*/
zTreeObj${treeId}.getNodesByParam(key,value,parentNode);
-->
<#macro tree id="ztree${.now?string('yyyyMMddhhmmss')}" type="default" data=[] url="" idKey="" pIdKey="" text="" label="" treeId="" json="" jsonId="" jsonPid="" jsonName="" jsonUrl="" validation="" addNodesName="" expandAll="true" showIcon="false" getZtreeId="" ischeck="false" help="">
<#if type="checkbox">
<ul id="${id}" class="ztree"></ul>
<SCRIPT type="text/javascript">
<!--
var ${id};
ms.post("${url}",null,function(json){
var setting = {
check: {
enable: true,
chkboxType: { "Y" : "ps", "N" : "ps" }
},
data: {
simpleData: {
enable: true,//是否采用简单数据模式 (Array)
idKey:"${idKey}",//节点ID名称
pIdKey:"${pIdKey}",//父节点ID名称
},
key:{
name:"${text}"//节点数据保存节点名称的属性名称。
}
}
};
$(document).ready(function(){
$.fn.zTree.init($("#${id}"), setting, json);
${id} = $.fn.zTree.getZTreeObj("${id}");
${id}.expandAll(true);
});
});
//-->
</SCRIPT>
<#elseif type=="default"> <#--默认调用方式在4.5.5将废弃-->
<!-- 初始化样式开始 -->
<div class="form-group ms-form-group ">
<#include "/include/ui/control.ftl"/><#rt/>
<div class="ms-form-control <#if label!="">col-sm-9</#if>">
<ul class="ztree" id="treeDome${treeId}">
</ul>
</div>
</div>
<!-- 初始化样式结束 -->
<!-- js操作方法开始 tree-->
<script>
//初始化树形数据
var zNodes${treeId} = ${json?default('[]')};
var zTreeObj${treeId};
//初始化树形结构
var setting${treeId} = {
view:{//控制视图
fontCss:{"white-space":"normal","display":"initial","word-break":"break-all"},
showIcon:${showIcon},//是否显示节点文件夹图标
showLine:true,//是否显示借点连接线
expandSpeed:"fast",//折叠时的动画速度,参考jquery中动画效果的speed参数,三种预定速度之一的字符串("slow", "normal", or "fast")
},
data: {//控制显示数据
simpleData: {
enable: true,//是否采用简单数据模式 (Array)
idKey:"${jsonId}",//节点ID名称
pIdKey:"${jsonPid}",//父节点ID名称
},
key:{
name:"${jsonName}",//节点数据保存节点名称的属性名称。
url:"${jsonUrl}",//节点跳转地址属性
}
},
callback: {//控制获取选择的节点数据
onClick:<#if getZtreeId?has_content>getZtreeId${treeId}<#else>null</#if>,//用于捕获节点被点击的事件回调函数
},
check:{//控制节点的选中方式(暂时未启用,根据后期需求再做调整)
autoCheckTrigger:true,//是否触发自动勾选
enable:${ischeck},//节点上是否显示选择框,false:不显示,true:显示。
chkStyle:"checkbox",//勾选框类型(checkbox[默认值] radio)
chkboxType:{"Y":"ps","N":"ps"},//设置勾选关联关系
},
};
$(function(){
//自定义顶级栏目
<#if addNodesName?has_content>
zNodes${treeId}[zNodes${treeId}.length] = {${jsonName}:"${addNodesName}",${jsonId}:0,${jsonPid}:0};
</#if>
//加载树形
$.fn.zTree.init($("#treeDome${treeId}"),setting${treeId},zNodes${treeId});
//zTree内部函数对象,主要用户调用zTree内部方法
zTreeObj${treeId} = $.fn.zTree.getZTreeObj("treeDome${treeId}");
//展开(true)/折叠(false)全部节点(zTree内部方法)
zTreeObj${treeId}.expandAll(${expandAll});
});
<#if getZtreeId?has_content>
function getZtreeId${treeId}(event,treeId,treeNode){
${getZtreeId};
}
</#if>
</script>
<!-- js操作方法结束 -->
</#if>
</#macro>
<#-------------------------------------------------------------------------- -->
<#-- 树形控件,树形结构table 格式-->
<#-- tbodyId(必须) 需要进行委派的容器Id, 如要委派到tbody的id值-->
<#-- treeId(必须):树形加载和控制区域的ID,一张页面同时加载多个树形时必须用该值进行区分 -->
<#-- json(必须):需要加载成树形的数据,数据结构为:[{categoryId:1,categoryCategoryId:0,categoryTitle:""},{categoryId:2,categoryCategoryId:1,categoryTitle:""}] -->
<#-- jsonId(必须):json数据中ID名称,如:categoryId -->
<#-- jsonPid(必须):json数据中关联的父ID,如:categoryCategoryId -->
<#-- jsonName(必须):json数据中需要显示的数据名称,如:categoryTitle -->
<#-- tmplBefored是否插入节点图标之前 false不插入, true插入-->
<#-- #befored${treeId} 在节点图标之前需要插入列表属性,如果要使用必须tmplBefored="true"-->
<#-- #after${treeId}(必须) 在节点图标之后需要插入列表属性-->
<#-- 该结构中调用方法简略说明,如果需要其他更改,请添加方法:
clickDome${treeId},展开节点|关闭节点
getChilds${treeId},获取当前点击的子节点
removeChilds${treeId},/移除点击节点的所有子节点
-->
<#macro treeTable tbodyId="" treeId="" json="" jsonId="" jsonPid="" jsonName="" style="" tmplBefored="false">
<ul class="ztreeTable" id="treeDome${treeId}" style="display:none">
</ul>
<!-- 列表HTML模版开始 -->
<script id="treeTableTmpl${treeId}" type="text/x-jquery-tmpl">
<tr data-id="{{= ${jsonId}}}" id="columnTitle{{= ${jsonId}}}" >
<td>{{= ${jsonId}}}</td>
<#if tmplBefored== "true" >
{{tmpl($data) '#befored${treeId}'}}
</#if>
<td>
<a class="btn btn-xs red tooltips switch-list columnTitle" data-id="{{= ${jsonId}}}" onclick="clickDome${treeId}(this)" data-parentId="{{= ${jsonPid}}}" data-toggle="tooltip" data-original-title="查看子节点">
<i class="glyphicon glyphicon-folder-close"></i>
</a>
{{= ${jsonName}}}
</td>
{{tmpl($data) '#after${treeId}'}}
</tr>
</script>
<!-- 列表HTML模版结束 -->
<!-- js操作方法开始 -->
<script>
var zTreeObj${treeId}; //zTree内部函数对象变量,主要用户调用zTree内部方法
//初始化树形结构
var setting${treeId} = {
data: {//控制显示数据
simpleData: {
enable: true,//是否采用简单数据模式 (Array)
idKey:"${jsonId}",//节点ID名称
pIdKey:"${jsonPid}",//父节点ID名称
},
key:{
name:"${jsonName}",//节点数据保存节点名称的属性名称。
}
},
};
$(function(){
//初始化树形数据
var zNodes${treeId} = ${json?default('[]')};
//加载树形
$.fn.zTree.init($("#treeDome${treeId}"),setting${treeId},zNodes${treeId});
//zTree内部函数对象,主要用户调用zTree内部方法
zTreeObj${treeId} = $.fn.zTree.getZTreeObj("treeDome${treeId}");
//获取zTree中的数据对象
var zTreeList = zTreeObj${treeId}.getNodes();
//将内容委派到其中
$("#treeTableTmpl${treeId}").tmpl(zTreeList).appendTo("#${tbodyId}");
});
//展开节点|关闭节点
function clickDome${treeId}(obj){
var columnId = $(obj).attr("data-id");//当前点击的节点
var booleanBeging= true; //用来处理是否展开/关闭节点
$(".columnTitle").each(function(){ //判断是否存在子节点
if($(this).attr("data-parentId")==columnId){
booleanBeging=false;
return false;
}
});
//判断节点文件夹关闭图标是否存在,存在则显示打开的文件夹图标
if($(obj).find(".glyphicon").hasClass("glyphicon-folder-close")){
$(obj).find(".glyphicon").removeClass("glyphicon-folder-close");
$(obj).find(".glyphicon").addClass("glyphicon-folder-open");
}else if($(obj).find(".glyphicon").hasClass("glyphicon-folder-open")){//判断节点文件夹打开图标是否存在,存在则显示关闭的文件夹图标
$(obj).find(".glyphicon").removeClass("glyphicon-folder-open")
$(obj).find(".glyphicon").addClass("glyphicon-folder-close");
}
if(booleanBeging==true){
getChilds${treeId}(columnId);//获取当前点击的子节点
}else{
removeChilds${treeId}(columnId);//移除点击节点的子节点
}
}
//获取当前点击的子节点
function getChilds${treeId}(jsonId){
//拿到所有节点,比对该节点内是否存在父节点id跟当前点击节点id一致,累加到数组内容,循环完毕后委派到html
var rootNodes=zTreeObj${treeId}.getNodes(); //获取根节点
var allNodes=zTreeObj${treeId}.transformToArray(rootNodes); //很据跟节点获取所有节点
var selectNodes; //选中的节点
var arrayNodes = new Array(); //需要委派的节点
for(var i=0;i<allNodes.length;i++){//将所有节点选中
zTreeObj${treeId}.selectNode(allNodes[i],true);
}
selectNodes=zTreeObj${treeId}.getSelectedNodes();
for(var j=0;j<selectNodes.length;j++){ //判断是否是当前点击的节点的子节点
if(selectNodes[j].${jsonPid}== jsonId ){
arrayNodes.push(selectNodes[j]);
}
}
$("#treeTableTmpl${treeId}").tmpl(arrayNodes).insertAfter("#columnTitle"+jsonId);
//文字首行缩进
$(".columnTitle").each(function(){
var id = $(this).attr("data-id");
var curChilds = zTreeObj${treeId}.getNodesByParam("${jsonId}",id,null);
var indent = curChilds[0].level;
$(this).parents("td").css("text-indent",(indent*5)+"px");
});
}
//移除点击节点的子节点
function removeChilds${treeId}(jsonId){
$(".columnTitle").each(function(){
if($(this).attr("data-parentId")==jsonId){
removeChilds${treeId}($(this).attr("data-id"));
$("#columnTitle"+$(this).attr("data-id")).detach();
}
});
}
</script>
<!-- js操作方法结束 -->
</#macro>
<#--上传控件-->
<#--上传控件-->
<#--path:上传路径,文件夹是在ms属性配置文件里面配置,会自动增加当前appId-->
<#--uploadFloderPath:如果path路径无法满足可以使用这个参数重新定义上传路径-->
<#--inputName:name值-->
<#--filetype:上传规则-->
<#--size:上传数量-->
<#--msg:提示信息-->
<#--imgs:默认显示的图片-->
<#--maxSize:默认文件大小 单位m-->
<#--如果是反复显示图片需要调用showImgs(imgs地址可以包含"|"符合,input的名称)-->
<#macro uploadImg path inputName size="1" uploadFloderPath="" filetype="*.jpg;*.png;*.gif;*.bmp;*.jpeg" msg="" imgs="" maxSize="1">
<div id="ms__uploadPic_${inputName}">
<style>
.msUploadImgs{margin: 0;padding: 0;list-style: none;}
.msUploadImgs li {list-style:none;float: left;text-align: center;border: 1px solid #F3F3F3;margin: 8px; width:100px;}
.msUploadImgs img {width:100%; height:100px;}
.msUploadImgs li span {cursor: pointer;}
.divUploader{clear:both}
</style>
<ul class="msUploadImgs">
<#if imgs!="">
<#list imgs?split("|") as img>
<#if img!="">
<li id="SWFUpload_9_${img_index}">
<div class="displayimg">
<img src="${basePath}/${img}">
</div>
<span class="front-cover" onclick="removePreview${inputName}(this,'${img}'+'|')"><a class="btn btn-xs red tooltips " data-original-title="点击删除图片"><i class="glyphicon glyphicon-trash"></i></a>
</span>
</li>
</#if>
</#list>
</#if>
</ul>
<div class="divUploader"><input type="button" id="up_file_${inputName}" />
<#if msg!="">
<div class="alert alert-warning alert-dismissable">${msg}</div>
</#if>
</div>
<input type="hidden" size="100" name="${inputName}" id="${inputName}" value="${imgs?default('')}" />
</div>
<script type="text/javascript">
$(function () {
$('#ms__uploadPic_${inputName}').swfupload({
upload_url: "${basePath}/file/upload.do",
post_params:{"uploadPath":"${path}","uploadFloderPath":"${uploadFloderPath}","isRename":"true","maxSize":"${maxSize}","allowedFile":"${filetype}","allowedFile":""},
file_size_limit: ${maxSize?default("1")}*1024,
file_types: "${filetype?default("*.jpg;*.png;*.gif;*.bmp;*.jpeg")}",
file_types_description: "Image files",
file_upload_limit: ${size?default("5")},
flash_url: "${basePath}/static/plugins/jquery.swfupload/1.0.0/swfupload.swf",
button_image_url: static+"/plugins/jquery.swfupload/1.0.0/button.png",
button_width: 92,
button_height: 34,
button_placeholder: $('#up_file_${inputName}')[0],
debug: false
})
.bind('fileQueued', function (event, file) {
if ($("#ms__uploadPic_${inputName} .msUploadImgs").children().length>=${size?default("5")}) {
$(this).swfupload('cancelUpload');
<@ms.notify msg= "最多上传${size}个文件!" type= "warning" />
} else {
var listitem = '<li id="' + file.id + '"><div class="displayimg"><img src="'+static+'/plugins/jquery.swfupload/1.0.0/load.gif" /></div><span class="front-cover">0%</span></li>';
$('#ms__uploadPic_${inputName} ul').append(listitem);
$(this).swfupload('startUpload');
}
})
.bind('fileQueueError', function (event, file, errorCode, message) {
if (errorCode==-130) {
<@ms.notify msg= "文件类型错误!" type= "warning" />
} else if (errorCode==-100) {
<@ms.notify msg= "最多上传${size}个文件!" type= "warning" />
} else {
<@ms.notify msg= "上传图片过多或上传图片过大!" type= "warning" />
}
})
.bind('uploadStart', function (event, file) {
$('#ms__uploadPic_${inputName} ul li#' + file.id).find('span.front-cover').text('0%');
})
.bind('uploadProgress', function (event, file, bytesLoaded) {
var percentage = Math.round((bytesLoaded / file.size) * 100);
$('#ms__uploadPic_${inputName} ul li#' + file.id).find('span.front-cover').text(percentage + '%');
})
.bind('uploadSuccess', function (event, file, serverData) {
var item = $('#ms__uploadPic_${inputName} ul li#' + file.id);
item.find('div.displayimg').html('<img src="${basePath}/' + serverData + '" />');
item.find('span.front-cover').html('<a class="btn btn-xs red tooltips " data-original-title="点击删除图片"><i class="glyphicon glyphicon-trash"></i></a>');
if($('#${inputName}').val()!=""){
$('#${inputName}').val($('#${inputName}').val() + "|"+ serverData )
}else{
$('#${inputName}').val(serverData )
}
$('#ms__uploadPic_${inputName} ul li#' + file.id + ' span.front-cover').bind('click', function () {
$('#ms__uploadPic_${inputName} ul li#' + file.id + '').slideUp('fast');
var swfu = $.swfupload.getInstance('#ms__uploadPic_${inputName}');
var stats = swfu.getStats();
stats.successful_uploads--;
swfu.setStats(stats);
//判断保存图片的输入框中是否存在"|"如果存在则表示图片至少要两张
if ($('#${inputName}').val().indexOf("|")<0) {
$('#${inputName}').val($('#${inputName}').val().replace(serverData, ""));
}else{
$('#${inputName}').val($('#${inputName}').val().replace(serverData+"|", ""));
}
$('#ms__uploadPic_${inputName} ul li#' + file.id).remove();
setInputValue${inputName}();
});
})
.bind('uploadComplete', function (event, file) {
$(this).swfupload('startUpload');
})
});
// 设置文本框的值 用于提交数据
function setInputValue${inputName}(){
var value = "";
// 设置文本的值
$("#ms__uploadPic_${inputName}").find("ul li .displayimg img").each(function(){
var src = $(this).attr('src').replace('${basePath}/', '');
value += src + '|';
});
// 删除最后一个"|"
if (value){
value = value.slice(0, -1);
}
$('#${inputName}').val(value);
}
function removePreview${inputName}(uid,imgPath) {
var swfu = $.swfupload.getInstance('#ms__uploadPic_${inputName}');
var stats = swfu.getStats();
stats.successful_uploads--;
swfu.setStats(stats);
//imgPath=imgPath.replace("|","")
//判断保存图片的输入框中是否存在"|"如果存在则表示图片至少要两张
//if ($('#${inputName}').val().indexOf("|")<0) {
//$('#${inputName}').val($('#${inputName}').val().replace(imgPath, ""));
// }else{
//$('#${inputName}').val($('#${inputName}').val().replace(imgPath+"|", ""));
// }
//var obj=$("#ms__uploadPic_${inputName}").find("ul li:last");
//var imgSrcPath = obj.find(".displayimg img").attr("src").replace("${basePath}/","");
//判断是否删除的是最后一张,如果是则删除时不含"|"
//if(imgSrcPath==imgPath.replace("|","")){
//$('#${inputName}').val($('#${inputName}').val().replace("|"+imgPath.replace("|",""), ""));
//}
$('#ms__uploadPic_${inputName} ul li#' + uid.parentNode.id).slideUp('fast',function() {
$(this).remove();
setInputValue${inputName}();
});
}
/**
*提供给弹窗显示图片使用
*/
function showImgs${inputName}(imgs,inputName) {
//var swfu = $.swfupload.getInstance('#ms__uploadPic_'+inputName);
//var stats = swfu.getStats();
$(".msUploadImgs").children().remove();
if (imgs) {
var _imgs = imgs.split("\|");
for (i=0;i<_imgs.length;i++) {
if (_imgs[i]!="") {
var imgLi = '<li id="SWFUpload_9_'+i+'">';
imgLi+='<div class="displayimg">';
imgLi+='<img src="${basePath}/'+_imgs[i]+'">';
imgLi+='</div>';
imgLi+='<span class="front-cover" onclick="removePreview${inputName}(this,\''+_imgs[i]+'\'+'|')"><a class="btn btn-xs red tooltips " data-original-title="点击删除图片"><i class="glyphicon glyphicon-trash"></i></a>';
imgLi+='</span>';
imgLi+='</li>';
$(".msUploadImgs").append(imgLi);;
//stats.successful_uploads++;
//swfu.setStats(stats);
}
}
}
}
</script>
</#macro>
<#--上传控件-->
<#--path:上传路径,文件夹是在ms属性配置文件里面配置,会自动增加当前appId-->
<#--uploadFloderPath:如果path路径无法满足可以使用这个参数重新定义上传路径-->
<#--inputName:name值-->
<#--filetype:上传规则-->
<#--size:上传数量-->
<#--msg:提示信息-->
<#--callBack:回调提示信息-->
<#--isRename:是否重命名true:将使用时间命名,否则使用上传是文件名,可能会出现同名称覆盖的问题,中文也会存在问题-->
<#--maxSize:默认文件大小 单位m-->
<#macro uploadFile path inputName uploadFloderPath="" size=1 filetype="*.zip,*.rar,*.doc,*.xls,*.doc,*.txt,*.pdf" msg="" maxSize="10" callBack="" isRename=false>
<div id="ms__uploadPic_${inputName}">
<div class="divUploader"><input type="button" id="up_file_${inputName}" />
<#if msg!="">
<div class="alert alert-warning alert-dismissable">${msg}</div>
</#if>
</div>
<input type="hidden" size="100" name="${inputName}" id="${inputName}" value="${imgs?default('')}" />
</div>
<script type="text/javascript">
$(function () {
$('#ms__uploadPic_${inputName}').swfupload({
upload_url: "${basePath}/file/upload.do",
post_params:{"uploadPath":"/${path}","uploadFloderPath":"${uploadFloderPath}","isRename":"${isRename?default("true")}","maxSize":"${maxSize}","allowedFile":"${filetype}","allowedFile":""},
file_size_limit: ${maxSize?default("1")}*1024,
file_types: "${filetype?default("*.jpg;*.png;*.gif;*.bmp;*.jpeg;*.zip;*.rar")}",
file_upload_limit: ${size?default("5")},
flash_url: "${basePath}/static/plugins/jquery.swfupload/1.0.0/swfupload.swf",
button_image_url: static+"/plugins/jquery.swfupload/1.0.0/button_file.png",
button_width: 92,
button_height: 34,
button_placeholder: $('#up_file_${inputName}')[0],
debug: false
})
.bind('fileQueued', function (event, file) {
if ($("#ms__uploadPic_${inputName} .msUploadImgs").children().length>=${size?default("5")}) {
$(this).swfupload('cancelUpload');
<@ms.notify msg= "上传图片过多或上传图片过大!" type= "warning" />
} else {
$(this).swfupload('startUpload');
}
})
.bind('fileQueueError', function (event, file, errorCode, message) {
if (errorCode==-130) {
<@ms.notify msg= "文件类型错误!" type= "warning" />
} else if (errorCode==-100) {
<@ms.notify msg= "最多上传${size}个文件!" type= "warning" />
} else {
//alert(errorCode+'上传图片过多或上传图片过大!');
<@ms.notify msg= "上传文件过大!" type= "warning" />
}
<#if callBack!="">
eval("${callBack}(errorCode)");
</#if>
})
.bind('uploadStart', function (event, file) {
$('#ms__uploadPic_${inputName} ul li#' + file.id).find('span.front-cover').text('0%');
})
.bind('uploadProgress', function (event, file, bytesLoaded) {
var percentage = Math.round((bytesLoaded / file.size) * 100);
})
.bind('uploadSuccess', function (event, file, serverData) {
$('#${inputName}').val(serverData);
<#if callBack!="">
eval("${callBack}(serverData)");
<#else>
<@ms.notify msg= "上传成功" type= "success" />
</#if>
})
.bind('uploadComplete', function (event, file) {
$(this).swfupload('startUpload');
})
});
</script>
</#macro>
<#-- plupload 图片上传组件 -->
<#-- path 图片上传地址-->
<#-- triggerBtnId 触发上传对话框的dom元素id-->
<#-- imgId 放置图片的的标签id 为空的话不显示 -->
<#-- container 用来指定Plupload所创建的html结构的父容器,默认为前面指定的browse_button的父元素。该参数的值可以是一个元素的id,也可以是DOM元素本身。-->
<#-- filetype 图片文件类型用 , 隔开-->
<#-- maxSize 文件最大值 单位 M-->
<#macro pluploadImg path triggerBtnId imgId="" filetype="*.jpg;*.png;*.gif;*.bmp;*.jpeg" maxSize="1" callback="" isRename=true>
<#assign onlyId = triggerBtnId />
<script type="text/javascript">
var ms__uploader_${onlyId} = new plupload.Uploader({
runtimes: 'html5',
browse_button: '${triggerBtnId}',
url: "${basePath}/upload", // 接收上传请求的servlet地址
multi_selection: false, // 只能选择1个文件
filters : {
max_file_size : '${maxSize}mb',
mime_types: [{title:"ImageFiles", extensions:"jpg,gif,png,bmp,jpeg"}]
},
// 上传服务器数据 post
multipart_params: {
"uploadPath": "/${path}",
"isRename": "${isRename?default("true")}",
"maxSize": ${maxSize},
"allowedFile": "${filetype?default('*.jpg;*.png;*.gif;*.bmp;*.jpeg')}"
}
});
//在实例对象上调用init()方法进行初始化
ms__uploader_${onlyId}.init();
// 初始化方法
ms__uploader_${onlyId}.bind('Init', function(loader){
});
// 用户添加文件, 开始的时候立即添加
ms__uploader_${onlyId}.bind('FilesAdded', function(up, files){
uploader.start();
});
// 队列中所有文件被上传完
ms__uploader_${onlyId}.bind('UploadComplete', function(up, file){
});
// 当一个文件开始上传的时候触发
ms__uploader_${onlyId}.bind('UploadFile', function(up, file){
});
// 文件上传成功的时候触发
ms__uploader_${onlyId}.bind('FileUploaded', function(uploader, file, result){
if (result.status == 200){
// 图片的服务器路径
var imgUrl = result.response;
$('#${imgId}').attr('src', '${basePath}/' + imgUrl);
}
else{
$('.ms-notifications').offset({top:43}).notify({
type:'success',
message: { text:'上传失败,请求返回码:' + result.status }
}).show();
}
<#if callback != "" >
eval("${callBack}(result)");
</#if>
});
</script>
</#macro>
<!DOCTYPE html>
<html lang="zh">
<head>
<title><#if app?has_content>${app.basicTitle}<#else>MS</#if>管理系统</title>
<link rel="bookmark" href="favicon.ico"/>
<#include "/include/macro.ftl"/>
<#include "/include/meta.ftl"/>
<script src="http://cdn.mingsoft.net/model/4.6.0/ms.mstore.client.min.js"></script>
</head>
<script type="text/javascript">
$(function(){
var menuJson=${modelList};
$('.dropdown-toggle').dropdown();
//加载头部菜单
manager.topMenu.initMenu(menuJson);
//点击头部菜单从左侧显示当前菜单子菜单
$(".ms-menu-list").delegate(".ms-menu-detail","click",function(){
manager.topMenu.showChildMenu($(this),menuJson);
});
//获取管理员帐号
$("#editLoginPassword").click(function() {
$.ajax({
type: "post",
dataType: "json",
url: "${managerPath}/editPassword.do",
success: function(msg){
var json =JSON.parse(msg.resultMsg);
$(".editLoginPassword input[name='managerName']").val(json);
//$(".editLoginPassword").modal();
}
});
});
//修改密码
$("#editLoginPasswordButton").click(function() {
var vobj = $("#updatePasswordFrom").data('bootstrapValidator').validate();
if(vobj.isValid()){
$(this).postForm("#updatePasswordFrom",{func:function(data) {
if(data.result){
alert("密码修改成功!");
location.reload();
}else{
alert(data.resultMsg);
}
}});
} else {
alert("表单验证失败");
}
});
//退出系统
$("#loginOutBtn").click(function() {
//$(this).request({func:function(data) {
// location.reload();
//}});
window.location.href="${managerPath}/logout"
});
$(".ms-menu-child li a").each(function() {
var tag = "?";
if ($(this).data("url").indexOf("?") > 0) {
tag="&";
}
$(this).data("url", "${managerPath}/"+$(this).data("url")+tag+"modelId="+$(this).data("id")+"&modelTitle="+encodeURI($(this).data("title")));
});
});
</script>
<body class="over-hide theme-index" >
<!--顶部开始 -->
<div class="ms-top">
<!--头部LOGO-->
<div class="ms-top-logo">
<img src="${skin_manager_logo}"/>
<!--span class="slideMenu">
<span class="icon iconfont icon-open">&#xe823;</span>
<span class="icon iconfont icon-close" style="display: none;">&#xe80d;</span>
</span-->
</div>
<!--头部一级菜单-->
<div class="ms-top-menu">
<div class="menu-default">
<#noparse>
<script id="ms-menu-list-tmpl" type="text/x-jquery-tmpl">
{{if modelModelId==0}}
<li data-model-id="${modelId}" data-model-icon="${modelIcon}" class="ms-menu-detail">${modelTitle}</li>
{{/if}}
</script>
</#noparse>
<ul class="ms-menu-list">
</ul>
<span class="glyphicon glyphicon-menu-hamburger openMenu"></span>
</div>
</div>
<!--头部用户信息/进入MStore-->
<div class="ms-top-user">
<div class="dropdown">
<div id="dLabel" class="ms-top-info" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<span class="glyphicon glyphicon-user"></span>
${Session.manager_session.managerName}
<span class="caret"></span>
</div>
<ul class="dropdown-menu" role="menu" aria-labelledby="dLabel">
<li role="presentation" data-toggle="modal" data-target="#editLoginPassword">
<a role="menuitem" tabindex="-1"><span class="glyphicon glyphicon-cog"></span> 修改密码</a>
</li>
<li role="presentation" data-toggle="modal" data-target="#loginOut">
<a role="menuitem" tabindex="-1"><span class="glyphicon glyphicon-off"></span> 退出</a>
</li>
</ul>
</div>
<div class="ms-top-mstore" data-toggle="tooltip" data-placement="bottom" title="点击进入Mstore">
<span class="glyphicon glyphicon-th-large animated"></span>
<span class="mstore-update"></span>
</div>
</div>
</div>
<#noparse>
<script id="ms-menu-tmpl" type="text/x-jquery-tmpl">
{{if modelModelId==0}}
<div class="ms-menu-parent" data-model-id="${modelId}">
<div class="ms-menu-parent-header ms-menu-parent-active">
<div class="ms-menu-parent-title" data-flag="true">
<i class="icon iconfont icon-logo">${modelIcon}</i>
${modelTitle}
</div>
<span class="closeMenu">×</span>
</div>
<ul class="ms-menu-child child-list${modelId}" id="tab-tools">
</ul>
</div>
{{/if}}
</script>
<script id="ms-menu-child-tmpl" type="text/x-jquery-tmpl">
<li><a style="cursor: pointer;" data-title='${modelTitle}' data-url='${modelUrl}' data-id='${modelId}'><!--span class="caret"></span-->${modelTitle}</a></li>
</script>
</#noparse>
<!--左边菜单开始-->
<div class="ms-menu-div">
<div class="slideMenu">
<span class="icon iconfont icon-open">&#xe823;</span>
<span class="icon iconfont icon-close" style="display: none;">&#xe80d;</span>
</div>
</div>
<div class="ms-menu">
<div class="ms-menu-none"></div>
<!--span class="slideMenu glyphicon glyphicon-tasks"></span-->
</div>
<!--左边菜单结束-->
<!--右边开始-->
<div class="ms-content">
<div class="wellcome">
<h2>欢迎进入MS系统</h2>
<p>欢迎加群: 221335098 或到
<a href="http://ms.mingsoft.net/mbbs/main.do" target="_blank" style="text-decoration: none;">官方论坛进行技术交流</a>
</p>
</div>
<div class="easyui-tabs">
</div>
</div>
<!--右边结束-->
<!--修改登录密码模态框-->
<@ms.modal id="editLoginPassword" title="修改密码">
<@ms.modalBody>
<@ms.form isvalidation=true name="updatePasswordFrom" action="${managerPath}/updatePassword.do">
<@ms.text name="managerName" width="280" label="账号:" title="managerName" value="" readonly="readonly" validation={"required":"true", "data-bv-notempty-message":"必填项目"} />
<@ms.password width="280" name="oldManagerPassword" label="旧密码:" title="managerPassword" validation={"required":"true","minlength":"6","maxlength":"20","data-bv-notempty-message":"必填项目","data-bv-stringlength-message":"6-20个字符以内!"}/>
<@ms.password width="280" name="newManagerPassword" label="新密码:" title="managerPassword" validation={"required":"true", "minlength":"6","maxlength":"20", "data-bv-notempty-message":"必填项目","data-bv-stringlength-message":"6-20个字符以内!"}/>
</@ms.form>
</@ms.modalBody>
<@ms.modalButton>
<@ms.savebutton value="更新密码" id="editLoginPasswordButton"/>
</@ms.modalButton>
</@ms.modal>
<@ms.modal id="loginOut" title="退出提示!">
<@ms.modalBody>
确认退出?
</@ms.modalBody>
<@ms.modalButton>
<@ms.button value="确认退出" id="loginOutBtn" url="${managerPath}/loginOut.do"/>
</@ms.modalButton>
</@ms.modal>
</body>
</html>
\ No newline at end of file
<!DOCTYPE html>
<html lang="en">
<head>
<#include "/include/meta.ftl"/>
<title><#if app?has_content>${app.appName}<#else>MS</#if>管理系统${managerViewPath}</title>
<link rel="shortcut icon" href="${static}/global/images/ms.ico"/>
<link rel="bookmark" href="${static}/global/images/ms.icoo"/>
<script type="text/javascript" src="http://cdn.mingsoft.net/plugins/vue/2.3.3/vue.min.js"></script>
<script type="text/javascript" src="http://cdn.mingsoft.net/plugins/validator/5.5.0/validator.min.js"></script>
<link rel="stylesheet/less" type="text/css" href="${static}/skin/manager/${manager_ui}/less/login.less" media="all" />
<script type="text/javascript" src="http://cdn.mingsoft.net/plugins/less/2.5.3/less.min.js" ></script>
<script>
if(top.location != location){
top.location.href= location.href;
}
</script>
</head>
<style>
.gray{background:#92908E}
</style>
<body>
<#if app?has_content>
<div id="mcms-login">
<img src="${static}/skin/manager/${manager_ui}/images/pic.png" class="login-images login-float" />
<div class="login-form-container login-float">
<div class="login-title">
<span class="login-chinese-title">账号登录 /</span>
<span class="login-english-title">User login</span>
</div>
<div class="ms-login-error-text">
<img src="${static}/skin/manager/${manager_ui}/images/error.png" v-show="errorText != ''" />
<span v-text="errorText" v-show="errorText != ''"></span>
</div>
<form class="form-horizontal" id="loginForm" action="${managerPath}/checkLogin.do">
<input type="text" maxlength="12" class="login-people-name" :class="{'ms-error':error == 'peopleName'}" id="managerName" name="managerName" @blur="checkPeopleName" @keyup="chanageBackgroundColor" placeholder="用户名" v-model="peopleName" />
<input type="password" maxlength="20" class="login-people-name" :class="{'ms-error':error == 'peoplePassword'}" id="managerPassword" name="managerPassword" @blur="checkPeoplePassword" @keyup="chanageBackgroundColor" placeholder="密码" v-model="peoplePassword" />
<div class="login-code">
<input type="text" onKeyUp ="value=value.replace(/[\W]/g,'')" maxlength="4" class="login-float login-code-input" :class="{'ms-error':error == 'rand_code'}" id="rand_code" name="rand_code" @blur="checkCode" @keyup="chanageBackgroundColor" placeholder="验证码" v-model="code" />
<img id="ms-login-code" class="login-code-img login-float" src="${basePath}/code" @click="changeCode"/>
<p class="login-float login-code-text">
<span>看不清?</span><br/>
<spna class="login-code-change" @click="changeCode">换一张</span>
</p>
</div>
<p class="login-remmember-password">
<input id="remember" type="checkbox" name="" />
<label class="login-remember" for="remember">记住密码</label>
</p>
<div id="login-button" class="login-button" v-on:click="toLogin">登录</div>
</form>
</div>
</div>
<#else>
<div id="errorDisplay">
<img src="${static}/skin/manager/${manager_ui}/images/errorDisplay.png"/>
<div class="errorData">
<p >系统配置异常,请手动去掉WEB-INF/ms.install.bak文件的后缀.bak,再重启系统进入登录界面进行初始化</p>
</div>
<div>
</#if>
</body>
<script>
var loginForm = new Vue({
el:'#mcms-login',
data:{
isRight: true,
errorText:"",//错误提示
error:"",//输入框错误的显示
peopleName:"",//用户名输入框
peoplePassword:"",//密码输入框
code:"",//验证码
},
watch: {
peopleName: function() {
var pattern = /[^\w\u4E00-\u9FA5]/ig;
if(!validator.isNull(this.peopleName) && this.peopleName.indexOf(" ") < 0 && validator.isLength(this.peopleName, {min:6,max:20}) && pattern.test(this.peopleName) == false && this.error == 'peopleName'){
this.errorText = "";
this.error = "";
}
},
peoplePassword: function() {
if(!validator.isNull(this.peoplePassword) && this.peoplePassword.indexOf(" ") < 0 && validator.isLength(this.peoplePassword, {min:6,max:20}) && this.error == 'peoplePassword'){
this.errorText = "";
this.error = "";
}
},
code: function(){
if(!validator.isNull(this.code) && this.code.length == 4 && this.error == 'rand_code'){
this.errorText = "";
this.error = "";
}
}
},
mounted: function() {
var _this = this;
//页面初始化时,如果帐号密码cookie存在则填充
if($.cookie('managerName') && $.cookie('managerPassword')){
_this.peopleName = $.cookie('managerName');
_this.peoplePassword = $.cookie('managerPassword');
$("#remember").attr("checked",true);
}
//检测浏览器版本
if (navigator.userAgent.toLowerCase().indexOf("msie") > 0) {
alert("您当前的浏览器版本太低,建议使用IE8以上版本浏览器,推荐使用Chrome浏览器");
}
//js监听回车键
document.onkeydown = function(e) {
e = e ? e : window.event;
var keyCode = e.which ? e.which : e.keyCode;
if (keyCode == 13) {
_this.login();
}
}
},
methods:{
//错误提示显示
errorShow:function(msg,type){
this.errorText = msg;
this.error = type;
},
changeCode:function(){
$("#ms-login-code").attr("src","${basePath}/code?t="+new Date().getTime())
},
//判断用户名
checkPeopleName:function(){
var pattern = /[^\w\u4E00-\u9FA5]/ig;
if(validator.isNull(this.peopleName)){
this.errorShow("用户名不能为空",'peopleName');
this.isRight = false;
return;
}else if(this.peopleName.indexOf(" ") >= 0) {
this.errorShow("用户名不能包含空格",'peopleName');
this.isRight = false;
return;
}else if(!validator.isLength(this.peopleName, {min:3,max:12})){
this.errorShow("用户名为3~12个字符",'peopleName');
this.isRight = false;
return;
}else if(pattern.test(this.peopleName)){
this.errorShow("用户名不能包含特殊字符",'peopleName');
this.isRight = false;
return;
}
},
//判断密码
checkPeoplePassword:function(){
if(validator.isNull(this.peoplePassword)){
this.errorShow("密码不能为空",'peoplePassword');
this.isRight = false;
return;
}else if(!validator.isLength(this.peoplePassword, {min: 6,max: 20})){
this.errorShow("密码长度在6~20位之间!",'peoplePassword');
this.isRight = false;
return;
}else if(this.peoplePassword.indexOf(" ") >=0){
this.errorShow("密码是不能包含空格",'peoplePassword');
this.isRight = false;
return;
}
},
//判断验证码
checkCode:function(){
if(validator.isNull(this.code)){
this.errorShow("验证码不能为空",'rand_code');
this.isRight = false;
return;
}else if(this.code.length != 4){
this.errorShow("验证码为4位!",'rand_code');
this.isRight = false;
return;
}
},
//登录判断验证
checkLogin:function(){
this.checkPeoplePassword();
this.checkPeopleName();
this.checkCode();
},
//验证登录数据
login:function(){
loginForm.checkLogin();
if(this.isRight){
$("#login-button").html("正在登录");
$("#login-button").attr("style","pointer-events: none;");
$(this).postForm("#loginForm",{loadingText:"正在登录中..",func:function(data) {
if(data.result){
location.href=base+"${baseManager}/index.do";
}else{
alert(data.resultMsg);
$("#ms-login-code").attr("src","${basePath}/code?t="+new Date().getTime())
$("#login-button").html("登录");
$("#login-button").attr("style","pointer-events: auto;");
$("#login-button").css({"background-color":"#0099ff"});
};
}});
}else{
this.isRight=true;
}
},
//删除cookies
delCookies: function(names){
for(i=0;i<names.length;i++){
$.cookie(names[i],null,{ expires: -1 });
}
},
//删除并且修改cookies
delAndSetCookies: function(names,values,date){
this.delCookies(names);
for(i=0;i<values.length;i++){
$.cookie(names[i], values[i], { expires: date });
}
},
//改变登录按钮背景色
chanageBackgroundColor: function(){
if($("#managerName").val().length >= 3 && $("#managerPassword").val().length >= 6 && $("#rand_code").val().length == 4){
$("#login-button").css({"background-color":"#0099ff"});
}else{
$("#login-button").css({"background-color":"#eeeeee"});
}
},
//点击登录方法
toLogin: function(){
var names=new Array('managerName','managerPassword');
var values=new Array($("#managerName").val(),$("#managerPassword").val());
if($("#remember").is(":checked")){
this.delAndSetCookies(names,values,1);
}else{
this.delCookies(names);
}
this.login();
}
}
})
</script>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<title>铭飞MCMS</title>
<meta content="IE=edge" http-equiv="X-UA-Compatible" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<style>
body{ height: 100%;}
</style>
</head>
<body>
</body>
</html>
\ No newline at end of file
<!DOCTYPE html>
<html lang="en">
<head>
<#include "/include/macro.ftl"/>
<#include "/include/meta.ftl"/>
</head>
<body>
<@ms.content>
<@ms.contentBody>
<@ms.contentNav title="管理员管理">
<@ms.panelNavBtnGroup>
<@ms.panelNavBtnAdd id="totalAdd" title=""/>
<@ms.panelNavBtnDel id="totalDelete"/>
</@ms.panelNavBtnGroup>
</@ms.contentNav >
<@ms.contentPanel>
<@ms.table head=['账号','昵称','密码','角色名称',"<th style='text-align:center'>添加时间</th>"] checkbox="checkbox">
<#if listManager?has_content>
<#list listManager as manager>
<tr>
<td style="text-align:center;width:10%;">
<#if manager.managerName != managerSession.managerName>
<input type="checkbox" name="checkbox" value="${manager.managerId?c?default(0)}">
</#if>
</td>
<td style="width:10%">
<#if manager.managerName != managerSession.managerName>
<a class="btn btn-xs tooltips updateModalBtn" data-toggle="tooltip" data-id="${manager.managerId?c?default(0)}" data-original-title="编辑">
${manager.managerName?default("暂无")}
</a>
<#else>
${manager.managerName?default("暂无")}
</#if>
</td>
<td style="width:10%">${manager.managerNickName?default("暂无")}</td>
<td style="width:25%">${manager.managerPassword?default("暂无")}</td>
<td style="width:10%" >${manager.roleName?default("暂无")}</td>
<td class="text-center">${manager.managerTime?string("yyyy-MM-dd HH:mm:ss")}</td>
</tr>
</#list>
<#else>
<tr>
<td colspan="5" class="text-left">
<@ms.nodata/>
</td>
</tr>
</#if>
</@ms.table>
<@showPage page=page/>
</@ms.contentPanel>
</@ms.contentBody>
<!--=================模态框部分开始=================-->
<!--修改/保存的模态框开始-->
<@ms.modal modalName="update" title="">
<@ms.modalBody height="250">
<@ms.form isvalidation=true name="updateManager" id="updateManager" action="">
<@ms.text name="managerName" label="账号" title="账号" maxlength="30" placeholder="请输入账号" validation={"required":"true", "data-bv-notempty-message":"账号不能为空"}/>
<@ms.text name="managerNickName" label="昵称" title="昵称" maxlength="30" placeholder="请输入昵称" validation={"required":"true", "data-bv-notempty-message":"昵称不能为空"}/>
<@ms.text name="managerPassword" label="密码" title="密码" maxlength="100" placeholder="请输入密码"/>
<@ms.select name="managerRoleID" label="选择角色" list=listRole id="orderStatus" listKey="roleId" listValue="roleName" value="" style="width:57%" validation={"required":"true", "data-bv-notempty-message":"角色不能为空"}/>
<input type="hidden" class="managerPeopleID" name="managerPeopleID" value="0"/>
<input type="hidden" class="oldManagerName" name="oldManagerName" value=""/>
</@ms.form>
</@ms.modalBody>
<@ms.modalButton>
<@ms.savebutton id="updateButton"/>
</@ms.modalButton>
</@ms.modal>
<!--修改/保存的模态框结束-->
<!--多选删除的模态框开始-->
<@ms.modal modalName="deleteAll" title="批量删除管理员">
<@ms.modalBody>
您确定删除您所勾选的管理员吗?
</@ms.modalBody>
<@ms.modalButton>
<@ms.button value="返回" id="closeDelete"/>
<@ms.button class="btn btn-danger" id="deleteButton" value="删除"/>
</@ms.modalButton>
</@ms.modal>
<!--多选删除的模态框结束-->
<!--单个删除的模态框开始-->
<@ms.modal modalName="deleteRadio" title="删除管理员">
<@ms.modalBody>
您确定删除您所勾选的管理员吗?
</@ms.modalBody>
<@ms.modalButton>
<@ms.button value="返回" id="closeRadio"/>
<@ms.button class="btn btn-danger" id="deleteRadio" value="删除"/>
</@ms.modalButton>
</@ms.modal>
<!--单个删除的模态框结束-->
<@ms.modal modalName="managerPageModel" title="主页面绑定">
<@ms.modalBody>
<@ms.form isvalidation=true name="managerPageForm" id="managerPageForm" class="form-inline" action="${managerPath}/managerModelPage/save.do">
<@ms.text name="managerModelPageUrl" label="主界面地址:" title="主界面地址:" size="5" maxlength="30" placeholder="请输入主页面地址"/>
<@ms.select name="managerModelPageModelId" label="选择模块" list=listManager id="orderStatus" listKey="managerRoleID" listValue="roleName" value="" style="width:57%"/>
<input type="hidden" name="managerModelPagemanagerId">
</@ms.form>
</@ms.modalBody>
<@ms.modalButton>
<@ms.button value="返回" id="closeSaveUrl"/>
<@ms.savebutton id="saveUrl"/>
</@ms.modalButton>
</@ms.modal>
<!--=================模态框部分结束=================-->
</@ms.content>
<script>
var URL='';
//模态框的操作
$(function () {
$("#totalAdd").click(function(){
$("#updateTitle").text("新增管理员");
$("#updateButton").text("保存");
URL="${managerPath}/manager/save.do";
$(".update").modal();
});
$("#closeUpdate").click(function(){
$(".update").modal("hide");
});
$("#closeDelete").click(function(){
$(".deleteAll").modal("hide");
});
$("#closeRadio").click(function(){
$(".deleteRadio").modal("hide");
});
$("#closeSaveUrl").click(function(){
$(".managerPageModel").modal("hide");
});
});
//全选
$("#allCheck").on("click",function(){
if(this.checked){
$("input[name='checkbox']").each(function(){this.checked=true;});
}else{
$("input[name='checkbox']").each(function(){this.checked=false;});
}
});
//点击更新按钮
$("#updateButton").click(function() {
var formData = $("#updateManager").serialize();
var vobj = $("#updateManager").data('bootstrapValidator').validate();
var buttonHtml = $("#updateButton").html();
if(vobj.isValid()){
$.ajax({
type: "post",
dataType: "json",
url: URL,
data: formData,
beforeSend:function(){
$("#updateButton").text($("#updateButton").text()+"中");
$("#updateButton").attr("disabled",true);
},
success: function(msg){
if(msg.result==true){
$('.ms-notifications').offset({top:43}).notify({
type:'success',
message: { text:buttonHtml+"成功" }
}).show();
location.reload();
}else{
$('.ms-notifications').offset({top:43}).notify({
type:'warning',
message: { text:msg.resultMsg }
}).show();
$("#updateButton").text(buttonHtml);
$("#updateButton").attr("disabled",false);
}
},error: function(){
<@ms.notify msg= "数据请求失败,请检查请求地址和参数是否正确" type= "danger" />
location.href = base+"${baseManager}/role/add.do";
}
});
}
});
$(".updateModalBtn").click(function(){
$("#updateTitle").text("编辑管理员");
$("#updateButton").text("更新");
//找到点击的id
var managerId = $(this).attr("data-id");
URL="${managerPath}/manager/"+managerId+"/edit.do";
$.ajax({
type: "post",
dataType:"json",
url: URL,
data: "managerId=" + managerId,
success: function(msg){
if(msg.manager != null){
$("input[name='managerName']").val(msg.manager.managerName);
$("input[name='oldManagerName']").val(msg.manager.managerName);
$("input[name='managerNickName']").val(msg.manager.managerNickName);
$("input[name='managerPassword']").val(msg.manager.managerPassword);
$("input[name='managerRoleID']").val(msg.manager.managerRoleID);
$("select[name=managerRoleID]").find("option[value="+msg.manager.managerRoleID+"]").attr("selected",true);
}
},error: function(){
<@ms.notify msg= "系统异常" type= "danger" />
}
});
URL = "${managerPath}/manager/update.do?managerId="+managerId;
$(".update").modal();
});
$("#totalDelete").click(function(){
var radioData = $("input[name='checkbox']").serialize();
if(radioData!=""){
$(".deleteAll").modal();//打开
}else{
<@ms.notify msg= "请选择需要删除的管理员!" type= "warning" />
}
});
//批量删除管理员
$("#deleteButton").click(function(){
var count = 0;
var checkboxData = $("input[name='checkbox']").serialize();
$("input[name='checkbox']").each(function(){
if(this.checked==true){
count++;
}
});
if(checkboxData.length != 0) {
$.ajax({
type: "post",
dataType: "json",
url: base+"${baseManager}/manager/allDelete.do",
data: checkboxData,
beforeSend:function(){
$("#deleteButton").text("删除中");
$("#deleteButton").attr("disabled",true);
},
success: function(msg){
<@ms.notify msg= "删除管理员成功" type= "success" />
if($("tbody tr").length == count && msg != 1){
location.href = base+"${baseManager}/manager/queryList.do?pageNo="+(msg-1);
}else{
location.href = base+"${baseManager}/manager/queryList.do?pageNo="+msg;
}
},error: function(){
<@ms.notify msg= "批量删除管理员失败" type= "danger" />
$(".deleteAll").modal("hide");
}
});
} else {
<@ms.notify msg= "删除失败,请先选择管理员" type= "danger" />
$(".deleteAll").modal("hide");
}
});
var radioManagerId
$(".delete").click(function(){
radioManagerId = $(this).attr("data-id");
$(".deleteRadio").modal();
});
//删除单个
$("#deleteRadio").click(function(){
$.ajax({
type: "post",
dataType: "json",
url: "${managerPath}/manager/"+radioManagerId+"/delete.do",
data: "managerId=" + radioManagerId,
success: function(msg){
if(msg != 0) {
<@ms.notify msg= "删除管理员成功" type= "success" />
if($("tbody tr").length==0 && msg != 1){
location.href = base+"${baseManager}/manager/queryList.do?pageNo="+(msg-1);
}else{
location.href = base+"${baseManager}/manager/queryList.do?pageNo="+msg;
}
} else {
<@ms.notify msg= "删除管理员失败" type= "danger" />
$(".closeModal").click();
}
},error: function(){
<@ms.notify msg= "系统异常" type= "danger" />
}
});
});
//点击弹出管理员主界面新增或更新弹出框
$(".addPage").click(function(){
var managerModelPageModelId = $(this).attr("data-id");
$("input[name='managerModelPagemanagerId']").val($(this).attr("data-id"));
//查询该管理员的模块信息
$.ajax({
type: "post",
dataType: "json",
url: base+"${baseManager}/model/"+$(this).attr("data-id")+"/queryModelByRoleId.do",
data:$("#managerPageForm").serialize(),
success: function(msg){
if(msg.result){
var modelJson =jQuery.parseJSON( msg.resultMsg);
$("select[name='managerModelPageModelId']").html("");
for (i=0;i<modelJson.length;i++) {
if (modelJson[i].modelModelId==0) {
$("select[name='managerModelPageModelId']").append("<option value="+modelJson[i].modelId+">"+modelJson[i].modelTitle+"</option>");
}
}
}
}
});
//查询该管理员是否绑定主界面
var modelId=0;
queryModelPage(modelId,managerModelPageModelId);
$(".managerPageModel").modal();
});
//查询模块是否绑定主界面
function queryModelPage(modelId,managerModelPageModelId){
$.ajax({
type: "post",
dataType: "json",
url: "${managerPath}/managerModelPage/"+modelId+"/getEntity.do",
data:"managerModelPageModelId="+managerModelPageModelId,
success: function(msg){
if(msg.result){
var json =jQuery.parseJSON(msg.resultMsg);
alert(msg);
$("input[name='managerModelPageUrl']").val(json.managerModelPageUrl);
}
}
});
}
//点击保存时,开始主界面信息的保存
$("#saveUrl").click(function(){
$.ajax({
type: "post",
dataType: "json",
url: "${managerPath}/managerModelPage/save.do",
data:$("#managerPageForm").serialize(),
beforeSend:function(){
$("#saveUrl").text("保存中");
$("#saveUrl").attr("disabled",true)
},
success: function(msg){
if(msg){
<@ms.notify msg= "保存成功!" type= "success" />
location.href = base+"${baseManager}/manager/queryList.do";
}
}
});
});
</script>
</body>
</html>
<@ms.html5>
<@ms.nav title="菜单管理"></@ms.nav>
<@ms.panel>
<div id="toolbar">
<@ms.panelNav>
<@ms.buttonGroup>
<@shiro.hasPermission name="model:save"><@ms.panelNavBtnAdd title="" id="addModelBtn"/></@shiro.hasPermission>
<@shiro.hasPermission name="model:del"><@ms.panelNavBtnDel title="" id="delModelBtn"/></@shiro.hasPermission>
</@ms.buttonGroup>
</@ms.panelNav>
</div>
<table id="modelList"
data-show-refresh="true"
data-show-columns="true"
data-show-export="true"
data-method="post"
data-side-pagination="server">
</table>
</@ms.panel>
<!--添加模块-->
<@ms.modal modalName="addEditModel" title="添加模块">
<@ms.modalBody height="350">
<@ms.form isvalidation=true name="addEditForm" action="" method="post" >
<@ms.formRow label="父级菜单">
<@ms.treeInput treeId="modelInputTree" json="${parentModelList?default('')}" jsonId="modelId" jsonPid="modelModelId" jsonName="modelTitle" addNodesName="顶级模块" buttonText="顶级模块" inputName="modelModelId" inputValue="0" clickZtreeId="clickZtreeId(event,treeId,treeNode);" expandAll="true" showIcon="true"/>
</@ms.formRow>
<@ms.text name="modelTitle" label="标题" title="模块标题" placeholder="请输入模块标题" value="" validation={"required":"true", "data-bv-notempty-message":"请输入模块标题!","data-bv-stringlength":"true","minlength":"1","maxlength":"10","data-bv-stringlength-message":"模块标题为1-10个字符!"} />
<@ms.text name="modelIcon" label="图标" title="模块图标" placeholder="请输入模块图标" value="" validation={"maxlength":"20","data-bv-stringlength-message":"模块图标为1-20个字符!"}/>
<@ms.text name="modelUrl" label="链接地址" title="模块链接地址" placeholder="请输入模块链接地址" value="" validation={"maxlength":"255","data-bv-stringlength-message":"模块链接地址为1-255个字符!"}/>
<#assign isMenu=[{"id":"0","name":"否"},{"id":"1","name":"是"}]>
<@ms.text name="modelSort" label="排序" title="模块排序" width="165px;" value="" placeholder="请输入排序" validation={"required":"true","maxlength":"5", "data-bv-notempty-message":"请输入模块排序!"}/>
<@ms.select name="modelIsMenu" style="width: 25%;" id="modelMenuSelect" list=isMenu listKey="id" listValue="name" label="是否是菜单" value="0" title="是否是菜单" />
<@ms.hidden name="modelId" value="" id="hideModelId"/>
</@ms.form>
</@ms.modalBody>
<@ms.modalButton>
<@ms.button value="" id="addEditBtn"/>
</@ms.modalButton>
</@ms.modal>
<@ms.modal modalName="delModel" title="模块数据删除" >
<@ms.modalBody>删除此模块
<@ms.modalButton>
<!--模态框按钮组-->
<@ms.button value="删除" class="btn btn-danger rightDelete" id="deleteModelBtn" />
</@ms.modalButton>
</@ms.modalBody>
</@ms.modal>
</@ms.html5>
<script>
var modelId;
var postMessage;
$(function(){
$("#modelList").bootstrapTable({
url:"${managerPath}/model/list.do",
contentType : "application/x-www-form-urlencoded",
queryParamsType : "undefined",
toolbar: "#toolbar",
idField: 'modelId',
treeShowField: 'modelTitle',
parentIdField: 'modelModelId',
columns: [{ checkbox: true},
{
field: 'modelIcon',
title: '模块图标',
align: 'center',
formatter:function(value,row,index) {
if(value != null){
return "<i class='iconfont'>"+value+"</i>";
}else{
return "";
}
}
},{
field: 'modelTitle',
title: '模块标题',
formatter:function(value,row,index) {
<@shiro.hasPermission name="model:update">
return "<a style='cursor:pointer;text-decoration:none;' onclick='editModal("+row.modelId+")'>" + value + "</a>";
</@shiro.hasPermission>
<@shiro.lacksPermission name="model:update">
return value;
</@shiro.lacksPermission>
}
},{
field: 'modelUrl',
title: '模块连接地址',
formatter:function(value,row,index) {
if(value == null){
return "";
}else{
return value;
}
}
},{
field: 'isChild',
title: '菜单类型'
},{
field: 'modelSort',
title: '模块的排序'
},{
field: 'modelIsMenu',
title: '模块是否是菜单',
align: 'center',
formatter:function(value,row,index) {
if(value == 0){
return "否";
}else if(value == 1){
return "是";
}else{
return "";
}
}
}]
})
})
//新增模块
$("#addModelBtn").click(function(){
$("#addEditForm").data("bootstrapValidator").validate();
var isValid = $("#addEditForm").data("bootstrapValidator").isValid();
if(!isValid) {
<@ms.notify msg= "数据提交失败,请检查数据格式!" type= "warning" />
return;
}
postMessage="保存成功!";
$("#addEditBtn").text("保存");
$("#addEditForm").attr("action","${managerPath}/model/save.do");
$("#addEditForm")[0].reset();
$(".addEditModel").modal();
$("input[name='modelSort']").val(0);
$("#hideModelId").attr("disabled",true);
});
//编辑模块
function editModal(id){
$("#addEditForm").data("bootstrapValidator").validate();
var isValid = $("#addEditForm").data("bootstrapValidator").isValid();
if(!isValid) {
<@ms.notify msg= "数据提交失败,请检查数据格式!" type= "warning" />
return;
}
var editUrl="${managerPath}/model/get.do?modelId="+id;
$(this).request({url:editUrl,type:"json",method:"post",func:function(data){
var model = data.model;
// 给表单赋值
if(model!=null){
$("input[name='modelId']").val(model.modelId);
if(model.modelIcon!=undefined){
$("input[name='modelIcon']").val(model.modelIcon);
}
if(model.modelModelId==0){
$("#treeLabelmodelInputTree").text("顶级模块");
}else{
$("#treeLabelmodelInputTree").text(data.parentModel.modelTitle);
}
$("#modelMenuSelect").get(0).selectedIndex = model.modelIsMenu;
$("input[name='modelTitle']").val(model.modelTitle);
$("input[name='modelSort']").val(model.modelSort);
$("input[name='modelUrl']").val(model.modelUrl);
$("input[name='isChild']").val(model.isChild);
$("#modelMenuSelect option[value="+model.modelMenu+"]").attr("selected",true);
$("input[name='modelModelId']").val(model.modelModelId);
$(".addEditModel").modal();
postMessage="更新成功!";
$("#addEditBtn").text("更新");
$("#hideModelId").attr("disabled",false);
$("#hideModelId").val(model.modelId);
$("#addEditForm").attr("action","${managerPath}/model/update.do");
}
}});
}
//提交表单
$("#addEditBtn").on("click",function(){
var vobj = $("#addEditForm").data('bootstrapValidator').validate();
if(vobj.isValid()){
$(this).postForm("#addEditForm",{func:function(msg) {
if(msg.result){
<@ms.notify msg="更新成功!" type="success"/>
location.reload();
}else{
$('.ms-notifications').offset({top:43}).notify({
type:'warning',
message: { text:msg.resultMsg }
}).show();
}
}});
}
});
//删除按钮
$("#delModelBtn").click(function(){
//获取checkbox选中的数据
var rows = $("#modelList").bootstrapTable("getSelections");
//没有选中checkbox
if(rows.length <= 0){
<@ms.notify msg="请选择需要删除的记录" type="warning"/>
}else{
$(".delModel").modal();
}
})
$("#deleteModelBtn").click(function(){
var rows = $("#modelList").bootstrapTable("getSelections");
$(this).text("正在删除...");
$(this).attr("disabled","true");
var ids = "";
for(var i=0;i<rows.length;i++){
if(ids == ""){
ids = rows[i].modelId;
}else{
ids = ids+","+rows[i].modelId
}
}
$.ajax({
type: "post",
url: "${managerPath}/model/delete.do?ids="+ids,
dataType: "json",
contentType: "application/json",
success:function(msg) {
if(msg.result == true) {
<@ms.notify msg= "删除成功" type= "success" />
}else {
<@ms.notify msg= "删除失败" type= "danger" />
}
location.reload();
}
})
});
//查询功能
function search(){
var search = $("form[name='searchForm']").serializeJSON();
var params = $('#modelList').bootstrapTable('getOptions');
params.queryParams = function(params) {
$.extend(params,search);
return params;
}
$("#modelList").bootstrapTable('refresh', {query:$("form[name='searchForm']").serializeJSON()});
}
//排除添加功能按钮
function clickZtreeId(event,treeId,treeNode){
if (treeNode.modelIsMenu==0) {
<@ms.notify msg= "不能将功能按钮添加为菜单" type= "danger" />
return false;
}
}
</script>
\ No newline at end of file
<!DOCTYPE html>
<html lang="en">
<head>
<META HTTP-EQUIV="Refresh" CONTENT="120">
</head>
<body>
***><***
</body>
</html>
\ No newline at end of file
<@ms.html5>
<@ms.nav title="角色设置" back=true>
<@ms.saveButton id="save"/>
<@ms.resetButton id="reset" value="重置" onclick=" " />
</@ms.nav>
<@ms.panel>
<@ms.form isvalidation=true name="saveRoleFrom" style="width: 55%" action="">
<@ms.text name="roleName" label="角色名称:" title="角色名称" maxlength="30" validation={"required":"true", "data-bv-notempty-message":"请填写标题"}/>
<#if flag == false><input type="hidden" name="roleId" value="${role.roleId}"/><input type="hidden" id="oldRoleName" name="oldRoleName" value="${role.roleName}"/></#if>
<!-- 树形模块菜单开始 -->
<#if listModel?has_content>
<@ms.tree label="模块列表:" treeId="tree" json="${listModel?default('')}" jsonId="modelId" jsonPid="modelModelId" jsonName="modelTitle" showIcon="true" expandAll="true" ischeck="true"/>
<#else>
<@ms.treeInput treeId="errorTree" buttonText="暂无数据"/>
</#if>
<!-- 树形模块菜单结束 -->
</@ms.form>
<#if !listModel?has_content>
<@ms.nodata/>
</#if>
</@ms.panel>
</@ms.html5>
<script type="text/javascript">
<#if flag == true>
$("input[name='roleName']").attr("placeholder","请输入角色名称")
<#else>
$("input[name='roleName']").val("${role.roleName}");
</#if>
$(function () {
//前端验证角色名称是否存在
$("input[name='roleName']").blur(function(){
var oldRoleName = $("#oldRoleName").length;
var roleName = $(this).val();
if((oldRoleName != 0 && $("#oldRoleName").val() != roleName) || (oldRoleName == 0)){
$.ajax({
type: "post",
dataType: "json",
url: "${managerPath}/role/judgeRoleNameExist.do",
data: "roleName=" + roleName,
success: function(msg){
if(msg){
<@ms.notify msg= "该角色名称已存在,请再次输入" type= "warning" />
$("input[name='roleName']").val(null);
}
}
});
}
});
//点击重置按钮取消树形菜单的选中
$("#reset").click(function(){
zTreeObjtree.checkAllNodes(false);
});
//更新角色时勾选出该角色所拥有的模块
var nodes = zTreeObjtree.transformToArray(zTreeObjtree.getNodes());
<#if listSelModel?has_content>
<#list listSelModel as selModel>
for(i=0; i<nodes.length; i++){
if(nodes[i].modelId==${selModel.modelId}){
zTreeObjtree.checkNode(nodes[i], true, false);
}
}
</#list>
</#if>
//声明需要获取的树形菜单的每一个子节点的id
var modelId = new Array();
//保存按钮点击提交表单
$("#save").click(function(){
if($("#saveRoleFrom").data('bootstrapValidator').validate().isValid()){
$(this).attr("disabled","true");
var nodes = zTreeObjtree.getCheckedNodes(true);
for(var i=0; i<nodes.length; i++){
modelId[i] = nodes[i].modelId;
}
if(modelId==""||modelId==null||modelId==undefined){
<@ms.notify msg= "请选择功能模块!" type= "warning"/>
$("#save").removeAttr("disabled");
return;
}
var URL = "${managerPath}/role/<#if flag == true>save<#else>update</#if>.do";
$.ajax({
type: "post",
dataType: "json",
url: URL,
data: $("#saveRoleFrom").serialize() + "&modelId=" + modelId,
beforeSend:function(){
$("#save").attr("disabled",true);
},
success: function(msg){
if(msg.result){
<#if flag == true>
<@ms.notify msg= "保存成功" type= "success" />
<#else>
<@ms.notify msg= "更新成功" type= "warning" />
</#if>
location.href = "${managerPath}/role/queryList.do";
} else {
$('.ms-notifications').offset({top:43}).notify({
type:'warning',
message: { text:msg.resultMsg }
}).show();
}
$("#save").removeAttr("disabled");
},error: function(){
<@ms.notify msg= "操作失败" type= "danger" />
$("#save").removeAttr("disabled");
location.href = "${managerPath}/role/queryList.do";
}
});
}
});
});
</script>
<!DOCTYPE html>
<html lang="en">
<head>
<#include "/include/meta.ftl"/>
<#include "/include/macro.ftl"/>
<style>
</style>
</head>
<body>
<@ms.content>
<@ms.contentBody>
<@ms.contentNav title="角色管理">
<@ms.panelNavBtnGroup>
<@ms.panelNavBtnAdd id="totalAdd"/>
<@ms.panelNavBtnDel id="totalDelete"/>
</@ms.panelNavBtnGroup>
</@ms.contentNav>
<@ms.contentPanel>
<@ms.table head=['<input type="checkbox" id="allCheck"/>,10','编号,50','角色名称']>
<#if listRole?has_content>
<#list listRole as role>
<tr>
<td>
<#if role.roleId!=managerRoleId>
<input type="checkbox" name="ids" value="${role.roleId?c?default(0)}">
</#if>
</td>
<input type="hidden" name="${role.roleId?c?default(0)}" />
<td>${role.roleId?c?default(0)}</td>
<td><a href="${managerPath}/role/${role.roleId}/edit.do" target="_self">${role.roleName?default("匿名")}</a></td>
</tr>
</#list>
<#else>
<tr>
<td colspan="4" class="text-center">
<a href="${managerPath}/role/add.do"><@ms.nodata/></a>
</td>
</tr>
</#if>
</@ms.table>
<@showPage page=page/>
</@ms.contentPanel>
</@ms.contentBody>
<!--=================模态框部分开始=================-->
<!--删除的模态框开始-->
<@ms.modal modalName="delete" title="删除角色">
<@ms.modalBody>
确定删除该角色吗?
</@ms.modalBody>
<@ms.modalButton>
<@ms.button value="返回" id="closeDelete"/>
<@ms.button class="btn btn-danger" id="deleteButton" value="删除"/>
</@ms.modalButton>
</@ms.modal>
<!--删除的模态框结束-->
<!--多选删除的模态框开始-->
<@ms.modal modalName="deleteAll" title="多选删除角色">
<@ms.modalBody>
您确定删除您所勾选的角色么?
</@ms.modalBody>
<@ms.modalButton>
<@ms.button value="返回" id="closeAllDelete"/>
<@ms.button class="btn btn-danger" id="deleteButtonAll" value="删除"/>
</@ms.modalButton>
</@ms.modal>
<!--多选删除的模态框结束-->
<!--=================模态框部分结束=================-->
</@ms.content>
<script type="text/javascript">
//触发模态框事件或者是模态框中按钮的事件
$(function(){
var roleId;
//删除角色
$(".del-btn").on("click",function(){
roleId = $(this).attr("data-id");
$(".delete").modal();
});
$("#deleteButton").click(function(){
deleteRole(roleId);
});
$("#closeDelete").click(function(){
$(".delete").modal("hide");
});
$("#totalDelete").click(function(){
$(".deleteAll").modal();
});
$("#closeAllDelete").click(function(){
$(".deleteAll").modal("hide");
});
//全选
$("#allCheck").on("click",function(){
if(this.checked){
$("input[name='ids']").each(function(){this.checked=true;});
}else{
$("input[name='ids']").each(function(){this.checked=false;});
}
});
//批量删除
$("#deleteButtonAll").on("click",function(){
batchDelete();
});
});
//删除角色
function deleteRole(roleId){
//拼接ajax地址
var URL="${managerPath}/role/"+roleId+"/delete.do";
$("#deleteButtonAll").text("删除中");
$("#deleteButtonAll").attr("disabled",true);
$(this).request({url:URL,data:"roleId=" + roleId,type:"json",method:"post",func:function(msg) {
//回调处理方式
if(msg != 0) {
$("input[name="+roleId+"]").parent().remove();
<@ms.notify msg= "删除角色成功!" type= "success" />
if($("tbody tr").length==0 && msg != 1){
location.href = base+"${baseManager}/role/queryList.do?pageNo="+(msg-1);
}else{
location.href = base+"${baseManager}/role/queryList.do?pageNo="+msg;
}
} else {
<@ms.notify msg= "删除失败" type= "danger"/>
}
location.reload();
}});
}
//批量删除角色
function batchDelete(){
var count = 0;
var ids = $("input[name='ids']").serialize();
$("input[name='ids']").each(function(){
if(this.checked==true){
count++;
}
});
if(ids.length != 0) {
var URL= "${managerPath}/role/allDelete.do";
$("#deleteButtonAll").text("删除中");
$("#deleteButtonAll").attr("disabled",true);
$(this).request({url:URL,data:ids,type:"json",method:"post",func:function(msg) {
if(msg != 0) {
<@ms.notify msg= "批量删除成功" type= "success" />
if($("tbody tr").length == count && msg != 1){
location.href = base+"${baseManager}/role/queryList.do?pageNo="+(msg-1);
}else{
location.href = base+"${baseManager}/role/queryList.do?pageNo="+msg;
}
} else {
<@ms.notify msg= "删除角色失败" type= "danger"/>
$("#deleteButtonAll").text("删除");
$("#deleteButtonAll").attr("disabled",false);
$(".deleteAll").modal("hide");
}
}});
} else {
<@ms.notify msg= "删除失败,请先选择管理员" type= "warning" />
$(".deleteAll").modal("hide");
}
}
$("#totalAdd").click(function(){
location.href = "${managerPath}/role/add.do"
});
</script>
</body>
</html>
<@ms.html5>
<@ms.nav title="编辑模版文件" back=true>
<@ms.savebutton id="update" value="修改"/>
</@ms.nav>
<@ms.panel>
<@ms.form name="form" id="editFileForm">
<!--文件名称-->
<@ms.text label="文件名称" value="${name?default('')}" readonly="readonly"/>
<@ms.hidden value="${fileName}" name="fileName" />
<!--文件内容-->
<@ms.textarea name="fileContent" label="文件内容" wrap="Soft" rows="21" size="" value="${fileContent}"/>
<@ms.hidden id="fileName" value="${fileName}" />
<@ms.hidden id="fileNamePrefix" value="${fileNamePrefix}" />
</@ms.form>
</@ms.panel>
</@ms.html5>
<script type="text/javascript">
$(function () {
//修改文件
$("#update").on("click",function(){
var formData = $("#editFileForm").serialize();
var URL=base+"${baseManager}/template/writeFileContent.do"
var oldFileName = $("#fileName").val();
var fileNamePrefix = $("#fileNamePrefix").val();
$(this).text("修改中");
$(this).attr("disabled",true);
$(this).request({url:URL,type:"json",method:"post",data:formData+"&oldFileName="+oldFileName+"&fileNamePrefix="+fileNamePrefix,func:function(msg) {
//回调处理方式
if(msg.result){
<@ms.notify msg= "修改模版文件成功" type= "success" />
} else {
<@ms.notify msg= "修改模版文件失败" type= "warning" />
}
var fileNameUrl = $(".fileNamePrefix").val();
$("#update").text("修改");
$("#update").attr("disabled",false);
}});
});
});
</script>
<@ms.html5>
<@ms.nav title="文件列表" back=true></@ms.nav>
<@ms.panel>
<@shiro.hasPermission name="template:upload"><@ms.uploadFile uploadFloderPath="${uploadFileUrl}" path="" inputName="file" size="20" filetype="*.htm;*.html;*.jpg;*.gif;*.png;*.css;*.js;*.ico;*.swf;*.less" msg="建议上传5M以下htm/html/css/js/jpg/gif/png/swf文件" maxSize="5" callBack="refresh" isRename="false"/></@shiro.hasPermission>
<@ms.table head=['<th class="text-center">图标</th>','模板名称',"<th style='width:20%;text-align:center'>类型</th>","<th class='text-center' style='width:10%;'>操作</th>"]>
<#if fileNameList?has_content>
<#list fileNameList as fileName>
<tr>
<td style="width:10%" class="pic text-center"></td>
<td style="width:35%" class="name">${fileName?replace("\\","/")}</td>
<td class="text-center type"></td>
<td style="width:10%;text-align:center">
<@shiro.hasPermission name="template:del">
<a class="btn btn-xs tooltips deleteIcon" data-toggle="tooltip" data-title="${fileName?replace("\\","/")}" data-original-title="删除">
<i class="glyphicon glyphicon-trash" style="color:#428BCA"></i>
</a>
</@shiro.hasPermission>
<@shiro.hasPermission name="template:update">
<a class="btn btn-xs tooltips editFileBtn" data-toggle="tooltip" data-title="templets/${websiteId}/${fileName?replace("\\","/")}" data-original-title="编辑">
<i class="glyphicon glyphicon-pencil" style="color:#428BCA"></i>
</a>
</@shiro.hasPermission>
</td>
</tr>
</#list>
<#else>
<tr>
<td colspan="5" class="text-left">
<@ms.nodata/>
</td>
</tr>
</#if>
</@ms.table>
</@ms.panel>
</@ms.html5>
<!--=================模态框部分开始=================-->
<@ms.modal modalName="delete" title="删除评论">
<@ms.modalBody>
确定删除该模板吗?
</@ms.modalBody>
<@ms.modalButton>
<@ms.button value="返回" id="closeDelete"/>
<@ms.button class="btn btn-danger" id="deleteButton" value="删除"/>
</@ms.modalButton>
</@ms.modal>
<!--=================模态框部分结束=================-->
<script type="text/javascript">
var fileName;
var isSuccess = false;
var fileUrl;
var skinFolderName = "${uploadFileUrl?replace("\\","/")}";
var interval;
function refresh(e){
<@ms.notify msg= "上传成功!" type= "success" />
location.reload();
}
function chat() {
var temp = $(".deleteIcon").attr("data-title");
if(temp == null || temp == ""){
temp = $(".editFileBtn").attr("data-title");
}
if(temp != null && temp != ""){
temp = temp.substring(0,temp.lastIndexOf("/"));
} else {
temp = skinFolderName.substring(skinFolderName.indexOf("/"));
temp = temp.substring(temp.indexOf("/"));
}
//若上传的为zip压缩文件则直接解压
if($("#file").val().substring($("#file").val().lastIndexOf(".")+1) == "zip"){
$.ajax({
type: "post",
url: base+"${baseManager}/template/unZip.do",
data: "fileUrl=" + fileUrl,
success: function(msg){
location.href=base+"${baseManager}/template/showChildFileAndFolder.do?skinFolderName="+temp;
fileName = temp + fileUrl.substring(fileUrl.lastIndexOf("/"));
//deleteTempletsFile();
$("#deleteButton").click();
}
});
} else {
location.href=base+"${baseManager}/template/showChildFileAndFolder.do?skinFolderName="+temp;
}
}
//删除模版文件
$("#deleteButton").click(function(){
var URL = base+"${baseManager}/template/deleteTemplateFile.do";
var DATA = "fileName=" + fileName;
$(this).request({url:URL,data:DATA,type:"json",method:"post",func:function(msg) {
if(msg != 0) {
<@ms.notify msg= "删除模版文件成功" type= "success" />
location.reload();
} else {
<@ms.notify msg= "删除模版文件失败" type= "warning" />
}
}});
});
$(function () {
//加载页面时启动定时器
//若为文件夹,则左侧显示文件夹图标;若为文件,则左侧显示文件图标,且稍向右偏移
$(".name").each(function(i){
var temp = $(this).html();
if(temp.indexOf(".") >= 0){
$(this).parent().find(".pic").prepend("<span class='glyphicon glyphicon-file'></span>")
$(this).parent().find(".type").prepend("文件")
} else {
$(this).parent().find(".pic").prepend("<span class='glyphicon glyphicon-folder-close'></span>")
$(this).parent().find(".type").prepend("文件夹")
$(this).parent().find(".editFileBtn").attr("data-original-title","打开文件夹");
$(this).parent().find(".editFileBtn").find(".glyphicon").removeClass("glyphicon-pencil");
$(this).parent().find(".editFileBtn").find(".glyphicon").addClass("glyphicon-log-in");
$(this).parent().find(".deleteIcon").remove();
}
var suffix = temp.substring(temp.lastIndexOf(".")+1);
if(suffix == "jpg" || suffix == "gif" || suffix == "png"){
$(this).parent().find(".type").prepend("图像")
$(this).parent().find(".editFileBtn").remove();
}
});
//编辑模版文件,若为文件夹,则跳至显示子文件和子文件夹action;若为文件,则直接读取代码内容,且跳至模版文件修改页面
$("table").delegate(".editFileBtn","click",function(){
fileName = $(this).attr("data-title");
if(fileName.indexOf(".") >= 0){
location.href = base+"${baseManager}/template/readFileContent.do?fileName="+encodeURIComponent(fileName);
} else {
location.href=base+"${baseManager}/template/showChildFileAndFolder.do?skinFolderName="+encodeURIComponent(fileName);
}
});
//点击返回按钮,关闭模态框
$("#closeDelete").click(function() {
$(".delete").modal("hide");
})
//删除模版
$("table").delegate(".deleteIcon","click",function(){
fileName = $(this).attr("data-title");
$(".delete").modal();
});
});
</script>
\ No newline at end of file
<@ms.html5>
<@ms.nav title="模板管理"></@ms.nav>
<@ms.panel>
<@shiro.hasPermission name="template:upload"><@ms.uploadFile path="" uploadFloderPath="templets/${websiteId}/" inputName="websiteStyle" size="10" filetype="*.zip" msg="建议上传30M以下的zip文件,模版名称不能使用中文,zip的压缩方式为:存储" maxSize="30" callBack="setUrl" isRename="false"/></@shiro.hasPermission>
<@ms.table head=['<th class="text-center">图标</th>','模板名称',"<th style='width:20%;text-align:center'>类型</th>","<th class='text-center' style='width:10%;'>操作</th>"]>
<#if folderNameList?has_content>
<#list folderNameList as folderName>
<tr>
<td style="width:7%" class="pic text-center"><span class='glyphicon glyphicon-folder-close'></span></td>
<td style="width:35%">${folderName}</td>
<td class="text-center">文件夹</td>
<td style="width:10%;text-align:center">
<@shiro.hasPermission name="template:del">
<a class="btn btn-xs tooltips deleteIcon" data-toggle="tooltip" data-title="${folderName}" data-original-title="删除">
<i class="glyphicon glyphicon-trash" style="color:#428BCA"></i>
</a>
</@shiro.hasPermission>
<@shiro.hasPermission name="template:update">
<a class="btn btn-xs tooltips" href="${managerPath}/template/showChildFileAndFolder.do?skinFolderName=templets/${websiteId}/${folderName}" data-toggle="tooltip" target="_self" data-original-title="打开文件夹" >
<i class="glyphicon glyphicon-log-in" style="color:#428BCA"></i>
</a>
</@shiro.hasPermission>
</td>
</tr>
</#list>
<#else>
<tr>
<td colspan="5" class="text-left">
<@ms.nodata/>
</td>
</tr>
</#if>
</@ms.table>
</@ms.panel>
</@ms.html5>
<!--=================模态框部分开始=================-->
<@ms.modal modalName="delete" title="删除模板">
<@ms.modalBody>
确定删除该模板吗?
</@ms.modalBody>
<@ms.modalButton>
<@ms.button value="返回" id="closeDelete"/>
<@ms.button class="btn btn-danger" id="deleteButton" value="删除"/>
</@ms.modalButton>
</@ms.modal>
<!--=================模态框部分结束=================-->
<script type="text/javascript">
var name;
var fileUrl;
function setUrl(e){
fileUrl = e;
$.ajax({
type: "post",
url: base+"${baseManager}/template/unZip.do",
data: "fileUrl=" + fileUrl,
success: function(msg){
<@ms.notify msg= "模版上传成功!" type= "success" />
location.href=base+"${baseManager}/template/queryTemplateSkin.do"
}
});
}
//点击返回按钮,关闭模态框
$("#closeDelete").click(function() {
$(".delete").modal("hide");
})
//点击删除按钮进行删除模版
$("#deleteButton").click(function(){
var URL = base+"${baseManager}/template/delete.do";
var DATA = "fileName=" + name;
$(this).attr("disabled",true);
$(this).text("删除中");
$(this).request({url:URL,data:DATA,type:"json",method:"post",func:function(msg) {
if(msg){
<@ms.notify msg= "删除模版成功" type= "success" />
location.href=base+"${baseManager}/template/queryTemplateSkin.do"
} else {
<@ms.notify msg= "删除模版失败" type= "warning" />
$("#deleteButton").attr("disabled",false);
$("#deleteButton").text("删除");
}
}});
});
//删除模版
$("table").delegate(".deleteIcon","click",function(){
name = $(this).attr("data-title");
$(".delete").modal();
});
</script>
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment