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>
This diff is collapsed.
<#--上传控件-->
<#--上传控件-->
<#--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>
This diff is collapsed.
This diff is collapsed.
<!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
This diff is collapsed.
This diff is collapsed.
<!DOCTYPE html>
<html lang="en">
<head>
<META HTTP-EQUIV="Refresh" CONTENT="120">
</head>
<body>
***><***
</body>
</html>
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
<@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>
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