externalDraftUpload.zml 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. ${Scripts.src(zhiqim_uploadlarge.js)}
  2. <script>
  3. Z.onload(function()
  4. {//初始化上传组件
  5. initHTML5Uploader();
  6. initHTML5Uploader1();
  7. Z("#FUpload_design").next().attr("accept",".cdr");
  8. Z("#ZUploadmultPreview").next().attr("accept","jpg,png");
  9. });
  10. <#var currentDate = DateTimes.getCurrentDate()/>
  11. var designUpload,endUpload,UploadLarge;
  12. var destDir = "/作品库/"+"${typeName}";
  13. var designPath = destDir + "设计文件" + "/" + '${currentDate}';
  14. var pdfPath = destDir + "印刷文件" + "/" + '${currentDate}';
  15. var thumPath = destDir + "缩略图" + "/" + '${currentDate}';
  16. var items;
  17. var uploadEndFile=true;
  18. function initHTML5Uploader()
  19. {
  20. designUpload = new Z.UploadLarge();
  21. designUpload.elem = "FUpload_design";
  22. designUpload.fileMd5Target = 1;
  23. designUpload.fileCopy = true;
  24. designUpload.maxSizeMiB = 150;
  25. designUpload.contextPath = "${context.getContextPath()}";
  26. designUpload.onSelected = function(fileName, fileLength)
  27. {
  28. var ind = fileName.lastIndexOf(".");
  29. if(ind < 0)
  30. {
  31. Z.alert("不合法的文件名格式");
  32. return false;
  33. }
  34. var ext = fileName.substring(fileName.lastIndexOf(".")+1);
  35. var fileFormat = Z("input[name='fileFormat']:checked").val();
  36. if (ext.toUpperCase() != fileFormat)
  37. {
  38. Z.alert("设计文件文件必须是"+fileFormat+"文件");
  39. return false;
  40. }
  41. //设置上传路径
  42. designUpload.setFileDir(designPath);
  43. };
  44. designUpload.onCompleted = function(fileId){
  45. var ajax = new Z.Ajax();
  46. ajax.setClassName("WorksPresenter");
  47. ajax.setMethodName("dotemplateExternalDesignLoad");
  48. ajax.addParam(fileId);
  49. ajax.addParam(${mediaId});
  50. ajax.setFailure(function(){
  51. designUpload.$delete.click();
  52. Z.failure(this.responseText);
  53. });
  54. ajax.setSuccess(function(){
  55. items = this.responseText;
  56. });
  57. ajax.setLoading(document)
  58. ajax.execute();
  59. };
  60. designUpload.execute();
  61. }
  62. function initHTML5Uploader1()
  63. {
  64. upload = new Z.UploadLarge();
  65. upload.elem = "ZUploadmultPreview";
  66. upload.fileMd5Target = 1;
  67. upload.maxSizeMiB = 1;
  68. upload.showResult = false;
  69. upload.fileCopy = true;
  70. upload.multiSelect = true;
  71. upload.dropWrap = "ZUploadLarge"
  72. upload.contextPath = "${context.getContextPath()}";
  73. upload.onPreview = function(fileName,fileLength)
  74. {
  75. var ind;
  76. for (var i in fileName){
  77. ind = fileName[i].name.lastIndexOf(".")
  78. if(ind < 0)
  79. {
  80. Z.alert("不合法的文件名格式");
  81. return false;
  82. }
  83. var ext = fileName[i].name.substring(fileName[i].name.lastIndexOf(".")+1);
  84. if(ext.toUpperCase() != "JPG" && ext.toUpperCase() != "PNG")
  85. {
  86. Z.alert("缩略图文件必须是jpg,png文件");
  87. return false;
  88. }
  89. }
  90. var ajax = new Z.Ajax();
  91. ajax.setSync(false);
  92. ajax.setClassName("WorksPresenter");
  93. ajax.setMethodName("isUploadDesignExternalFile");
  94. ajax.addParam(${mediaId});
  95. ajax.addParam(Z("input[name='fileFormat']:checked").val());
  96. ajax.setFailureAlert();
  97. ajax.setSuccess(function(){
  98. var resp = Z.J.toObject(this.responseText);
  99. if(!Z.T.isNumber(resp)){
  100. uploadEndFile = false;
  101. Z.alert(resp);
  102. }else{
  103. uploadEndFile = true;
  104. items = resp;
  105. }
  106. });
  107. ajax.execute();
  108. //设置上传路径
  109. upload.setFileDir(thumPath);
  110. var classNames = document.getElementsByClassName("Z-UploadLarge-progress-text z-absolute z-w100p z-px10 z-lh16");//innerHTML innerText
  111. for (var i = 0;i < classNames.length;i++){
  112. document.getElementsByClassName("Z-UploadLarge-progress-text z-absolute z-w100p z-px10 z-lh16")[i].innerHTML = "等待上传";
  113. }
  114. };
  115. upload.onCompleted = function(fileId,uploadedList){
  116. var fileIds = "";
  117. for (var i in uploadedList){
  118. fileIds += uploadedList[i].fileId + ",";
  119. }
  120. if(uploadEndFile){
  121. var ajax1 = new Z.Ajax();
  122. ajax1.setClassName("WorksPresenter");
  123. ajax1.setMethodName("doTemplateExternalEndLoad");
  124. ajax1.addParam(fileIds);
  125. ajax1.addParam(items);
  126. ajax1.addParam(thumPath);
  127. ajax1.setFailure(function(){
  128. document.getElementById('ZUploadLarge').innerHTML = "";
  129. Z.failure(this.responseText);
  130. });
  131. ajax1.setSuccess(function(){
  132. Z.success("上传成功", function(){
  133. <#if Validates.isNotEmpty(templateSrc)>
  134. //新建过来的
  135. parent.Z(".z-dialog-shadow").css("display","none");
  136. parent.Z(".z-dialog").css("display","none");
  137. parent.Z("#item_${mediaId}").find("img").click();
  138. <#else>
  139. parent.parent.Z(".z-dialog-shadow").css("display","none");
  140. parent.parent.Z(".z-dialog").css("display","none");
  141. parent.parent.Z("#item_${mediaId}").find("img").click();
  142. </#if>
  143. });
  144. });
  145. ajax1.setLoading(document);
  146. ajax1.execute();
  147. }else{
  148. document.getElementById('ZUploadLarge').innerHTML = "";
  149. }
  150. };
  151. upload.execute();
  152. }
  153. function doUploadmultPreview()
  154. {
  155. upload.upload();
  156. }
  157. function fileTypeSwitcher(fileType){
  158. Z("#FUpload_design").next().attr("accept",fileType);
  159. }
  160. </script>
  161. <div id="uploadDiv"></div>
  162. <table class="z-table z-bordered z-pd10 z-bg-white">
  163. <tr height="80">
  164. <td width="32%" align="center">文件格式(默认CDR):</td>
  165. <td width="68%">
  166. <button type="button" class="z-button z-large zi-bg-white zi-mg-l5" onclick="Z(this).find('zcover>i.z-radio').click()">
  167. <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">
  168. CDR</button>
  169. <button type="button" class="z-button z-large zi-bg-white zi-mg-l5" onclick="Z(this).find('zcover>i.z-radio').click()">
  170. <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" >
  171. PSD</button>
  172. <button type="button" class="z-button z-large zi-bg-white zi-mg-l5" onclick="Z(this).find('zcover>i.z-radio').click()">
  173. <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">
  174. AI</button>
  175. <button type="button" class="z-button z-large zi-bg-white zi-mg-l5" onclick="Z(this).find('zcover>i.z-radio').click()">
  176. <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">
  177. RAR</button>
  178. </td>
  179. </tr>
  180. <tr height="80">
  181. <td width="32%" align="center">设计文件上传:
  182. <div class="z-text-red" style="font-size: 12px;">(最大150MB)</div></td>
  183. <td width="68%"><button id="FUpload_design" type="button" class="z-button z-w200 z-blue">文件上传</button></td>
  184. </tr>
  185. <tr height="80">
  186. <td width="32%" align="center">缩略图上传(jpg、png格式):
  187. <div class="z-text-red" style="font-size: 12px;">(最大1MB)</div></td>
  188. <td width="68%">
  189. <div id="ZUploadLarge" class="z-pd5 z-mg-t10 z-mg-b10" style="display: block; box-shadow: transparent 0px 0px 1px 0px;"></div>
  190. <button id="ZUploadmultPreview" class="z-button z-blue z-w120">选择文件</button>
  191. <button id="ZUploadmultUpload" class="z-button z-w120" onclick="doUploadmultPreview();">上传文件</button>
  192. </td>
  193. </tr>
  194. </table>