attaFileMaterials.zml 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406
  1. ${Styles.htmlOverflowYAuto()}
  2. ${Scripts.src(zhiqim_uploadlarge.js)}
  3. <script>
  4. <!--
  5. var attaList = ${attaList};
  6. Z.onload(function()
  7. {
  8. for(var i=0; i<attaList.length; i++)
  9. {
  10. var obj = attaList[i];
  11. if ("file" == obj.type && obj.isAdd)
  12. {
  13. initUploader(obj.id, obj.savePath);
  14. }
  15. if ("file" == obj.type)
  16. {
  17. Z("#fileType_Text_"+obj.id).click();//默认选中
  18. }
  19. }
  20. });
  21. function initUploader(fileType, path)
  22. {//文件上传
  23. var designId = Z("#designId").val();
  24. if (Z.Validates.isEmpty(designId))
  25. return;
  26. var upload = new Z.UploadLarge();
  27. upload.elem = "upload_" + fileType;
  28. upload.showResult = false;
  29. upload.fileMd5Target = 1;
  30. upload.fileCopy = true;
  31. upload.maxSizeMiB = 500;
  32. upload.contextPath = "${context.getContextPath()}";
  33. upload.setFileDir(path);
  34. upload.onSelected = function(fileName, fileLength)
  35. {
  36. var ajax = new Z.Ajax();
  37. ajax.setSync();
  38. ajax.setClassName("UploadFilePresenter");
  39. ajax.setMethodName("doCheckFileName");
  40. ajax.addParam(designId);
  41. ajax.addParam(fileType);
  42. if ("EndFile" != fileType)
  43. ajax.addParam(designId + "-" + fileName);
  44. else
  45. ajax.addParam(fileName);
  46. ajax.execute();
  47. if (ajax.responseStatus != 0)
  48. {
  49. Z.alert(ajax.responseText);
  50. return false;
  51. }
  52. if ("EndFile" != fileType)
  53. this.setFileName(designId + "-" + fileName);
  54. else
  55. this.setFileName(fileName);
  56. };
  57. upload.onCompleted = function(fileId){
  58. var ajax = new Z.Ajax();
  59. ajax.setClassName("UploadFilePresenter");
  60. ajax.setMethodName("doUplaodFile");
  61. ajax.addParam(designId);
  62. ajax.addParam(fileId);
  63. ajax.addParam(fileType);
  64. ajax.setFailureAlert();
  65. ajax.setSuccess(function()
  66. {
  67. var dataMap = Z.J.toObject(this.responseText);
  68. Z("#div_" + fileType).html("");//清除;
  69. var html = "";
  70. var data_color = "${zmr_color_class}";
  71. var items = dataMap.attaList;
  72. for(var i=0;i<items.length;i++)
  73. {
  74. /**/
  75. var obj = items[i];
  76. html += '<div id="div_checkbox_'+obj.attaId+'" class="z-text-ellipsis z-w300 z-pointer"';
  77. if ('EndFile'== fileType)
  78. html += 'onclick="showThumImg(\''+obj.attaId+'\',\''+obj.fileType+'\')"';
  79. html += ' title="'+obj.fileName+'">';
  80. html += "<input name='str_" + fileType +"' type='checkbox' value ='" + obj.attaId +"' class='z-checkbox' data-role='z-checkbox' data-class='"+data_color+"'/>";
  81. html += '<span class="z-pd6" onclick="Z(this).parent().find(\'zcover>i.z-checkbox\').click()">'+obj.fileName+'</span><br>';
  82. html += '</div>';
  83. }
  84. Z("#div_" + fileType).htmlc(html);
  85. });
  86. ajax.setLoading(document);
  87. ajax.execute();
  88. };
  89. upload.execute();
  90. }
  91. function doDownFile(type)
  92. {//文件下载
  93. var designId = Z("#designId").val();
  94. if (Z.V.isEmpty(designId))
  95. {
  96. parent.Z.alert("请选择一条订单");
  97. return;
  98. }
  99. var attaIds = Z.FM.getCheckBoxValue("str_" + type, "");
  100. if (Z.V.isEmpty(attaIds))
  101. {
  102. parent.Z.alert("请选择需要下载的文件");
  103. return false;
  104. }
  105. if(${checkeds}){
  106. parent.Z.alert("选中多条订单不支持下载,请重新选择");
  107. return;
  108. }
  109. var delType_desabled = Z("#delete_"+type).attr("disabled");
  110. var downloadType_desabled = Z("#download_"+type).attr("disabled");
  111. Z("#delete_"+type).attr("disabled", true);
  112. Z("#download_"+type).attr("disabled", true);
  113. var ajax = new Z.Ajax();
  114. ajax.setClassName("UploadFilePresenter");
  115. ajax.setMethodName("doDownloadFile");
  116. ajax.addParam("attaId", attaIds);
  117. ajax.setFailure(function(){
  118. Z("#delete_"+type).attr("disabled", delType_desabled);
  119. Z("#download_"+type).attr("disabled", downloadType_desabled);
  120. Z.alert(this.responseText,null, {width:320});
  121. });
  122. ajax.setSuccess(function(){
  123. Z("#delete_"+type).attr("disabled", delType_desabled);
  124. Z("#download_"+type).attr("disabled", downloadType_desabled);
  125. var prefix = Z.l.protocol + "//" + Z.l.host ;
  126. Z.L.href(prefix+"/downFile.htm?attaId=" + attaIds, zCallFrame);
  127. var mainFrame = parent.parent.document.getElementById("mainFrame");
  128. if (mainFrame)
  129. console.log(mainFrame.src);
  130. // window.open(prefix+"/downFile.htm?attaId=" + attaIds, 'downFile');mainFrame
  131. });
  132. ajax.setLoading(document);
  133. ajax.execute();
  134. }
  135. function doDeleteFile(type)
  136. {//删除文件
  137. var designId = Z("#designId").val();
  138. if (Z.V.isEmpty(designId))
  139. {
  140. parent.Z.alert("请选择一条订单");
  141. return;
  142. }
  143. var attaIds = Z.FM.getCheckBoxValue("str_" + type, "");
  144. if (Z.V.isEmpty(attaIds))
  145. {
  146. parent.Z.alert("请选择需要删除的文件");
  147. return ;
  148. }
  149. if(${checkeds}){
  150. parent.Z.alert("选中多条订单不支持删除,请重新选择");
  151. return;
  152. }
  153. Z.confirm("确认删除此文件吗?", function()
  154. {
  155. var arr = Z.AR.toArray(attaIds, ",")
  156. var ajax = new Z.Ajax();
  157. ajax.setClassName("UploadFilePresenter");
  158. ajax.setMethodName("doDeleteFile");
  159. ajax.addParam(attaIds);
  160. ajax.setFailure(function(){Z.alert(this.responseText,null, {width:320});});
  161. ajax.setSuccess(function(){
  162. Z.each(arr, function(id, i){
  163. Z("#div_checkbox_"+id).remove();
  164. });
  165. });
  166. ajax.execute();
  167. }, {width:320});
  168. }
  169. function showThumImg(attaId, suffix)
  170. {
  171. doViewOssFile(attaId);//预览文件
  172. Z("#thumImgs").html("");//清除;
  173. if (suffix != "pdf")
  174. {
  175. var html = "<img class='z-pointer' onclick='showLargeImg(this)' class='z-mg-l10' src= '"+attaId+"-0-endFile'/>";
  176. Z("#thumImgs").html(html);
  177. }
  178. else
  179. {
  180. var ajax = new Z.Ajax();
  181. ajax.setClassName("UploadFilePresenter");
  182. ajax.setMethodName("getPdfPages");
  183. ajax.addParam("attaId", attaId);
  184. ajax.setCallback(function()
  185. {
  186. var html = "";
  187. var page = parseInt(this.responseText);
  188. for (var i=1;i<=page;i++)
  189. {
  190. html += "<img class='z-pointer' width='162' onclick='showLargeImg(this)' class='z-mg-l6' src= '"+attaId+"-"+i+"-endFile'/>";
  191. }
  192. html += "<br>";
  193. Z("#thumImgs").html(html);
  194. });
  195. ajax.execute();
  196. }
  197. }
  198. function doViewOssFile(attaId)
  199. {
  200. var ajax = new Z.Ajax();
  201. ajax.setClassName("UploadFilePresenter");
  202. ajax.setMethodName("doGetOssFileUrl");
  203. ajax.addParam("attaId", attaId);
  204. ajax.setSuccess(function(){
  205. var ossFileUrl = this.responseText;
  206. if (Z.V.isNotEmptyBlank(ossFileUrl))
  207. {
  208. var elem = document.createElement("a");
  209. elem.href = ossFileUrl;
  210. elem.setAttribute("target", "_blank");
  211. elem.click();
  212. }
  213. });
  214. ajax.execute();
  215. }
  216. function showLargeImg(thisImg)
  217. {
  218. var dialog = new parent.Z.Dialog();
  219. dialog.shadow = true;
  220. dialog.title = "图片预览";
  221. //dialog.hasTitle = false;
  222. dialog.fixed = true;
  223. dialog.url = "showLargeImg.htm?imgpath="+thisImg.src;
  224. dialog.width = parent.Z.D.clientWidth()-200;
  225. dialog.height = parent.Z.D.clientHeight()-200;
  226. dialog.execute();
  227. dialog.$background.remove();
  228. }
  229. function doCopyProductInfo(copyType)
  230. {
  231. if (copyType == 1)
  232. {//复制文件名
  233. var designId = "${order.getDesignId()}";
  234. var buyerNick = "${order.getBuyerNick()}";
  235. var reciverName = "${order.getUserContact()}";
  236. var fileName = designId+ "-";
  237. // if (buyerNick.indexOf("-") > 0)
  238. // {
  239. // fileName += reciverName;
  240. // }
  241. // else
  242. // {
  243. fileName += buyerNick;
  244. // }
  245. if (fileName == "-")
  246. return;
  247. Z.copy(fileName);
  248. top.Z.tips("复制成功");
  249. }
  250. else
  251. {//复制信息
  252. if (Z("#copy_content").length == 0)
  253. return;
  254. Z.copy(Z("#copy_content").text());
  255. top.Z.tips("复制成功");
  256. }
  257. }
  258. //-->
  259. </script>
  260. ${Htmls.toCallFrame()}
  261. <input name="designId" id="designId" value="${order.getDesignId()}" type="hidden">
  262. <table class="z-table z-bordered-line z-pd5 zi-bd z-bg-blue z-mg-t20">
  263. <#for item : attaList>
  264. <#if item.getId() == "copy">
  265. <!--复制-->
  266. <tr class="z-h40 z-bg-gray">
  267. <td class="z-bold" colspan="2">产品信息:
  268. <span style="margin-left:100px">
  269. <button type="button" id="copy" class="z-button z-yellow" onclick="doCopyProductInfo(1);">复制文件名</button>
  270. <button type="button" id="copy" class="z-button z-cyan" onclick="doCopyProductInfo();">复制信息</button>
  271. </span>
  272. </td>
  273. </tr>
  274. <tr class="z-h50">
  275. <#if Validates.isNotEmpty(order)>
  276. <td id="copy_content" colspan="2">${order.getDesignId()}-${order.getBuyerNick()}-${order.getOrderText()}</td>
  277. <#else>
  278. <td colspan="2"></td>
  279. </#if>
  280. </tr>
  281. </#if>
  282. <#if item.getId() == "userText">
  283. <!--客户文本-->
  284. <tr class="z-h40 z-bg-gray">
  285. <td class="z-bold" colspan="2">客户文本:</td>
  286. </tr>
  287. <tr class="z-h100">
  288. <td colspan="2">
  289. <textarea class="z-textarea z-w100p z-h100 ${zmr_color_class}" id="userText" name="userText" class="">${order.getUserText()}</textarea>
  290. </td>
  291. </tr>
  292. </#if>
  293. <#if item.getType() == "file">
  294. <!-- 文件资料-->
  295. <tr class="z-h40 z-bg-gray">
  296. <td>
  297. <input type="checkbox" id="box_${item.getId()}" onclick="Z.FM.doSelectCheckBox('str_${item.getId()}', this.checked);" class="z-checkbox z-mg-l2" data-role="z-checkbox" data-class="${zmr_color_class}" > <b id="fileType_Text_${item.getId()}" class="z-pointer" onclick=" Z(this).parent().find('zcover>i.z-checkbox').click();">${item.getName()}</b>
  298. </td>
  299. <td class="z-text-right">
  300. <#if item.getId() == "EndFile" && endFileLink != null>
  301. <button id="copyLink_${item.getId()}" class="z-button z-cyan z-pd3" onclick="Z.copy('${endFileLink}');top.Z.tips('复制成功')">发送链接</span></button>
  302. </#if>
  303. <button id="upload_${item.getId()}" class="z-button z-pd3 ${zmr_color_class}" <#if !item.isAdd()>disabled=true</#if>>添加</button>
  304. <button id="download_${item.getId()}" class="z-button z-orange z-pd3" onclick="doDownFile('${item.getId()}');">下载</button>
  305. <button id="delete_${item.getId()}" class="z-button z-red z-pd3" onclick="doDeleteFile('${item.getId()}');" <#if !item.isDel()>disabled=true</#if>>删除</button>
  306. </td>
  307. </tr>
  308. <tr class="z-h40">
  309. <td colspan="2">
  310. <div id="div_${item.getId()}" class="z-overflow-y-auto <#if item.getName()=="客户素材">z-h100<#elseif item.getName()=="印刷文件">z-h50<#else>z-h60</#if>">
  311. <#for atta : fileList>
  312. <#if Validates.isEqual(atta.getAttaModul(), item.getId())>
  313. <div id="div_checkbox_${atta.getAttaId()}" class="z-text-ellipsis z-w300 z-pointer" onclick="<#if item.getId()=="EndFile"> showThumImg('${atta.getAttaId()}', '${atta.getFileType()}')</#if>" title="${atta.getFileName()}">
  314. <input name="str_${item.getId()}" type="checkbox" data-attaId="${atta.getAttaId()}" data-attaUrl="${atta.getOssUrl()}" data-fileName="${atta.getFileName()}" class="z-checkbox" data-role="z-checkbox" data-class="${zmr_color_class}" value ="${atta.getAttaId()}"><span class="z-pd6" onclick="Z(this).parent().find('zcover>i.z-checkbox').click();">${atta.getFileName()}</span><br>
  315. </div>
  316. </#if>
  317. </#for>
  318. </div>
  319. </td>
  320. </tr>
  321. </#if>
  322. <#if item.getType() == "thumFile">
  323. <!--缩略图-->
  324. <tr class="z-h40 z-bg-gray">
  325. <td class="z-bold" colspan="2">${item.getName()}:</td>
  326. </tr>
  327. <tr height="200px" valign="top">
  328. <td colspan="2">
  329. <div id="thumImgs"><#if Validates.isNotEmpty(item.getSavePath())><img src="${item.getSavePath()}"></#if></div>
  330. </td>
  331. </tr>
  332. </#if>
  333. <#if item.getType() == "firstThumFile">
  334. <!--初稿缩略图-->
  335. <tr class="z-h40 z-bg-gray">
  336. <td class="z-bold" colspan="2">${item.getName()}:</td>
  337. </tr>
  338. <tr height="200px" valign="top">
  339. <td colspan="2">
  340. <#if order != null>
  341. <div><img src="${order.getDesignId()}-FristThumFile.png"></div>
  342. </#if>
  343. </td>
  344. </tr>
  345. </#if>
  346. <#if item.getId() == "userNotice">
  347. <!--注意事项-->
  348. <tr class="z-h40 z-bg-gray">
  349. <td class="z-bold" colspan="2">注意事项:</td>
  350. </tr>
  351. <tr class="z-h80" >
  352. <td colspan="2">
  353. <textarea id="userNotice" name="userNotice" class="z-textarea z-w100p z-h80 ${zmr_color_class}">${order.getUserNotice()}</textarea>
  354. </td>
  355. </tr>
  356. </#if>
  357. </#for>
  358. <!--客服留言-->
  359. <tr class="z-h40 z-bg-gray">
  360. <td class="z-bold" colspan="2">客服留言:</td>
  361. </tr>
  362. <tr class="z-h80">
  363. <td colspan="2">
  364. <textarea id="servicesMessage" name="servicesMessage" class="z-textarea z-w100p z-h80 ${zmr_color_class}">${order.getServicesMessage()}</textarea>
  365. </td>
  366. </tr>
  367. </table>