212 行
8.5 KiB
Plaintext
212 行
8.5 KiB
Plaintext
${Scripts.src(zhiqim_uploadlarge.js)}
|
|
<script>
|
|
Z.onload(function()
|
|
{//初始化上传组件
|
|
initHTML5Uploader();
|
|
initHTML5Uploader1();
|
|
Z("#FUpload_design").next().attr("accept",".cdr");
|
|
Z("#ZUploadmultPreview").next().attr("accept","jpg,png");
|
|
});
|
|
<#var currentDate = DateTimes.getCurrentDate()/>
|
|
var designUpload,endUpload,UploadLarge;
|
|
var destDir = "/作品库/"+"${typeName}";
|
|
var designPath = destDir + "设计文件" + "/" + '${currentDate}';
|
|
var pdfPath = destDir + "印刷文件" + "/" + '${currentDate}';
|
|
var thumPath = destDir + "缩略图" + "/" + '${currentDate}';
|
|
var items;
|
|
var uploadEndFile=true;
|
|
function initHTML5Uploader()
|
|
{
|
|
designUpload = new Z.UploadLarge();
|
|
designUpload.elem = "FUpload_design";
|
|
designUpload.fileMd5Target = 1;
|
|
designUpload.fileCopy = true;
|
|
designUpload.maxSizeMiB = 150;
|
|
designUpload.contextPath = "${context.getContextPath()}";
|
|
designUpload.onSelected = function(fileName, fileLength)
|
|
{
|
|
var ind = fileName.lastIndexOf(".");
|
|
if(ind < 0)
|
|
{
|
|
Z.alert("不合法的文件名格式");
|
|
return false;
|
|
}
|
|
|
|
var ext = fileName.substring(fileName.lastIndexOf(".")+1);
|
|
var fileFormat = Z("input[name='fileFormat']:checked").val();
|
|
if (ext.toUpperCase() != fileFormat)
|
|
{
|
|
Z.alert("设计文件文件必须是"+fileFormat+"文件");
|
|
return false;
|
|
}
|
|
|
|
//设置上传路径
|
|
designUpload.setFileDir(designPath);
|
|
};
|
|
designUpload.onCompleted = function(fileId){
|
|
var ajax = new Z.Ajax();
|
|
ajax.setClassName("WorksPresenter");
|
|
ajax.setMethodName("dotemplateExternalDesignLoad");
|
|
ajax.addParam(fileId);
|
|
ajax.addParam(${mediaId});
|
|
ajax.setFailure(function(){
|
|
designUpload.$delete.click();
|
|
Z.failure(this.responseText);
|
|
});
|
|
ajax.setSuccess(function(){
|
|
items = this.responseText;
|
|
});
|
|
ajax.setLoading(document)
|
|
ajax.execute();
|
|
};
|
|
|
|
designUpload.execute();
|
|
}
|
|
|
|
function initHTML5Uploader1()
|
|
{
|
|
upload = new Z.UploadLarge();
|
|
upload.elem = "ZUploadmultPreview";
|
|
upload.fileMd5Target = 1;
|
|
upload.maxSizeMiB = 1;
|
|
upload.showResult = false;
|
|
upload.fileCopy = true;
|
|
upload.multiSelect = true;
|
|
upload.dropWrap = "ZUploadLarge"
|
|
upload.contextPath = "${context.getContextPath()}";
|
|
upload.onPreview = function(fileName,fileLength)
|
|
{
|
|
var ind;
|
|
for (var i in fileName){
|
|
ind = fileName[i].name.lastIndexOf(".")
|
|
|
|
if(ind < 0)
|
|
{
|
|
Z.alert("不合法的文件名格式");
|
|
return false;
|
|
}
|
|
|
|
var ext = fileName[i].name.substring(fileName[i].name.lastIndexOf(".")+1);
|
|
if(ext.toUpperCase() != "JPG" && ext.toUpperCase() != "PNG")
|
|
{
|
|
Z.alert("缩略图文件必须是jpg,png文件");
|
|
return false;
|
|
}
|
|
}
|
|
|
|
var ajax = new Z.Ajax();
|
|
ajax.setSync(false);
|
|
ajax.setClassName("WorksPresenter");
|
|
ajax.setMethodName("isUploadDesignExternalFile");
|
|
ajax.addParam(${mediaId});
|
|
ajax.addParam(Z("input[name='fileFormat']:checked").val());
|
|
ajax.setFailureAlert();
|
|
ajax.setSuccess(function(){
|
|
var resp = Z.J.toObject(this.responseText);
|
|
if(!Z.T.isNumber(resp)){
|
|
uploadEndFile = false;
|
|
Z.alert(resp);
|
|
}else{
|
|
uploadEndFile = true;
|
|
items = resp;
|
|
}
|
|
});
|
|
ajax.execute();
|
|
|
|
//设置上传路径
|
|
upload.setFileDir(thumPath);
|
|
//var html = '<div id="ZUploadmultPreviewResult" class="z-w100p z-h80" style="display:none"></div>'
|
|
//Z("#uploadDiv").html(html);
|
|
//uploadmultpreview.buildPreviewHtml("ZUploadmultPreviewResult");
|
|
//var zupl = document.getElementById('ZUploadmultPreviewLocation');
|
|
//var zupr = document.getElementById('ZUploadmultPreviewResult');
|
|
//zupl.appendChild(zupr);
|
|
//upload.buildPreviewHtml('ZUploadmultPreviewLocation');
|
|
var classNames = document.getElementsByClassName("Z-UploadLarge-progress-text z-absolute z-w100p z-px10 z-lh16");//innerHTML innerText
|
|
for (var i = 0;i < classNames.length;i++){
|
|
document.getElementsByClassName("Z-UploadLarge-progress-text z-absolute z-w100p z-px10 z-lh16")[i].innerHTML = "等待上传";
|
|
}
|
|
};
|
|
upload.onCompleted = function(fileId,uploadedList){
|
|
var fileIds = "";
|
|
for (var i in uploadedList){
|
|
fileIds += uploadedList[i].fileId + ",";
|
|
}
|
|
if(uploadEndFile){
|
|
var ajax1 = new Z.Ajax();
|
|
ajax1.setClassName("WorksPresenter");
|
|
ajax1.setMethodName("doTemplateExternalEndLoad");
|
|
ajax1.addParam(fileIds);
|
|
ajax1.addParam(items);
|
|
ajax1.addParam(thumPath);
|
|
ajax1.setFailure(function(){
|
|
document.getElementById('ZUploadLarge').innerHTML = "";
|
|
Z.failure(this.responseText);
|
|
});
|
|
ajax1.setSuccess(function(){
|
|
Z.success("上传成功", function(){
|
|
<#if Validates.isNotEmpty(templateSrc)>
|
|
//新建过来的
|
|
parent.Z(".z-dialog-shadow").css("display","none");
|
|
parent.Z(".z-dialog").css("display","none");
|
|
parent.Z("#item_${mediaId}").find("img").click();
|
|
<#else>
|
|
parent.parent.Z(".z-dialog-shadow").css("display","none");
|
|
parent.parent.Z(".z-dialog").css("display","none");
|
|
parent.parent.Z("#item_${mediaId}").find("img").click();
|
|
</#if>
|
|
});
|
|
});
|
|
ajax1.setLoading(document);
|
|
ajax1.execute();
|
|
}else{
|
|
document.getElementById('ZUploadLarge').innerHTML = "";
|
|
}
|
|
};
|
|
upload.execute();
|
|
}
|
|
|
|
function doUploadmultPreview()
|
|
{
|
|
upload.upload();
|
|
}
|
|
|
|
function fileTypeSwitcher(fileType){
|
|
Z("#FUpload_design").next().attr("accept",fileType);
|
|
}
|
|
|
|
</script>
|
|
<div id="uploadDiv"></div>
|
|
<table class="z-table z-bordered z-pd10 z-bg-white">
|
|
<tr height="80">
|
|
<td width="32%" align="center">文件格式(默认CDR):</td>
|
|
<td width="68%">
|
|
<button type="button" class="z-button z-large zi-bg-white zi-mg-l5" onclick="Z(this).find('zcover>i.z-radio').click()">
|
|
<input type="radio" id="cdrFormat" name="fileFormat" class="z-radio" checked data-class="${zmr_color_class}" data-role="z-radio" onclick="Z.E.stop();fileTypeSwitcher('.cdr');" value="CDR">
|
|
CDR</button>
|
|
<button type="button" class="z-button z-large zi-bg-white zi-mg-l5" onclick="Z(this).find('zcover>i.z-radio').click()">
|
|
<input type="radio" id="psdFormat" name="fileFormat" class="z-radio" data-class="${zmr_color_class}" data-role="z-radio" onclick="Z.E.stop();fileTypeSwitcher('.psd');" value="PSD" >
|
|
PSD</button>
|
|
<button type="button" class="z-button z-large zi-bg-white zi-mg-l5" onclick="Z(this).find('zcover>i.z-radio').click()">
|
|
<input type="radio" id="aiFormat" name="fileFormat" class="z-radio" data-class="${zmr_color_class}" data-role="z-radio" onclick="Z.E.stop();fileTypeSwitcher('.ai');" value="AI">
|
|
AI</button>
|
|
<button type="button" class="z-button z-large zi-bg-white zi-mg-l5" onclick="Z(this).find('zcover>i.z-radio').click()">
|
|
<input type="radio" id="rarFormat" name="fileFormat" class="z-radio" data-class="${zmr_color_class}" data-role="z-radio" onclick="Z.E.stop();fileTypeSwitcher('.rar');" value="RAR">
|
|
RAR</button>
|
|
</td>
|
|
</tr>
|
|
<tr height="80">
|
|
<td width="32%" align="center">设计文件上传:
|
|
<div class="z-text-red" style="font-size: 12px;">(最大150MB)</div></td>
|
|
<td width="68%"><button id="FUpload_design" type="button" class="z-button z-w200 z-blue">文件上传</button></td>
|
|
</tr>
|
|
<tr height="80">
|
|
<td width="32%" align="center">缩略图上传:
|
|
<div class="z-text-red" style="font-size: 12px;">(最大1MB)</div></td>
|
|
<td width="68%">
|
|
<div id="ZUploadLarge" class="z-pd5 z-mg-t10 z-mg-b10" style="display: block; box-shadow: transparent 0px 0px 1px 0px;"></div>
|
|
<button id="ZUploadmultPreview" class="z-button z-blue z-w120">选择文件</button>
|
|
<button id="ZUploadmultUpload" class="z-button z-w120" onclick="doUploadmultPreview();">上传文件</button>
|
|
</td>
|
|
</tr>
|
|
</table> |