attaFileList.zml 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403
  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. });
  131. ajax.setLoading(document);
  132. ajax.execute();
  133. }
  134. function doDeleteFile(type)
  135. {//删除文件
  136. var designId = Z("#designId").val();
  137. if (Z.V.isEmpty(designId))
  138. {
  139. parent.Z.alert("请选择一条订单");
  140. return;
  141. }
  142. var attaIds = Z.FM.getCheckBoxValue("str_" + type, "");
  143. if (Z.V.isEmpty(attaIds))
  144. {
  145. parent.Z.alert("请选择需要删除的文件");
  146. return ;
  147. }
  148. if(${checkeds}){
  149. parent.Z.alert("选中多条订单不支持删除,请重新选择");
  150. return;
  151. }
  152. Z.confirm("确认删除此文件吗?", function()
  153. {
  154. var arr = Z.AR.toArray(attaIds, ",")
  155. var ajax = new Z.Ajax();
  156. ajax.setClassName("UploadFilePresenter");
  157. ajax.setMethodName("doDeleteFile");
  158. ajax.addParam(attaIds);
  159. ajax.setFailure(function(){Z.alert(this.responseText,null, {width:320});});
  160. ajax.setSuccess(function(){
  161. Z.each(arr, function(id, i){
  162. Z("#div_checkbox_"+id).remove();
  163. });
  164. });
  165. ajax.execute();
  166. }, {width:320});
  167. }
  168. function showThumImg(attaId, suffix)
  169. {
  170. doViewOssFile(attaId);//预览文件
  171. Z("#thumImgs").html("");//清除;
  172. if (suffix != "pdf")
  173. {
  174. var html = "<img class='z-pointer' onclick='showLargeImg(this)' class='z-mg-l10' src= '"+attaId+"-0-endFile'/>";
  175. Z("#thumImgs").html(html);
  176. }
  177. else
  178. {
  179. var ajax = new Z.Ajax();
  180. ajax.setClassName("UploadFilePresenter");
  181. ajax.setMethodName("getPdfPages");
  182. ajax.addParam("attaId", attaId);
  183. ajax.setCallback(function()
  184. {
  185. var html = "";
  186. var page = parseInt(this.responseText);
  187. for (var i=1;i<=page;i++)
  188. {
  189. html += "<img class='z-pointer' width='162' onclick='showLargeImg(this)' class='z-mg-l6' src= '"+attaId+"-"+i+"-endFile'/>";
  190. }
  191. html += "<br>";
  192. Z("#thumImgs").html(html);
  193. });
  194. ajax.execute();
  195. }
  196. }
  197. function doViewOssFile(attaId)
  198. {
  199. var ajax = new Z.Ajax();
  200. ajax.setClassName("UploadFilePresenter");
  201. ajax.setMethodName("doGetOssFileUrl");
  202. ajax.addParam("attaId", attaId);
  203. ajax.setSuccess(function(){
  204. var ossFileUrl = this.responseText;
  205. if (Z.V.isNotEmptyBlank(ossFileUrl))
  206. {
  207. var elem = document.createElement("a");
  208. elem.href = ossFileUrl;
  209. elem.setAttribute("target", "_blank");
  210. elem.click();
  211. }
  212. });
  213. ajax.execute();
  214. }
  215. function showLargeImg(thisImg)
  216. {
  217. var dialog = new parent.Z.Dialog();
  218. dialog.shadow = true;
  219. dialog.title = "图片预览";
  220. dialog.fixed = true;
  221. dialog.url = "showLargeImg.htm?imgpath="+thisImg.src;
  222. dialog.width = parent.Z.D.clientWidth()-600;
  223. dialog.height = parent.Z.D.clientHeight()-400;
  224. dialog.execute();
  225. dialog.$background.remove();
  226. }
  227. function doCopyProductInfo(copyType)
  228. {
  229. if (copyType == 1)
  230. {//复制文件名
  231. var designId = "${order.getDesignId()}";
  232. var buyerNick = "${order.getBuyerNick()}";
  233. var reciverName = "${order.getUserContact()}";
  234. var fileName = designId+ "-";
  235. // if (buyerNick.indexOf("-") > 0)
  236. // {
  237. // fileName += reciverName;
  238. // }
  239. // else
  240. // {
  241. fileName += buyerNick;
  242. // }
  243. if (fileName == "-")
  244. return;
  245. Z.copy(fileName);
  246. top.Z.tips("复制成功");
  247. }
  248. else
  249. {//复制信息
  250. if (Z("#copy_content").length == 0)
  251. return;
  252. Z.copy(Z("#copy_content").text());
  253. top.Z.tips("复制成功");
  254. }
  255. }
  256. </script>
  257. ${Htmls.toCallFrame()}
  258. <input name="designId" id="designId" value="${order.getDesignId()}" type="hidden">
  259. <table class="z-table z-bordered-line z-pd5 zi-bd z-bg-blue z-mg-t20">
  260. <#for item : attaList>
  261. <#if item.getId() == "copy">
  262. <!--复制-->
  263. <tr class="z-h40 z-bg-gray">
  264. <td class="z-bold" colspan="2">产品信息:
  265. <span style="margin-left:100px">
  266. <button type="button" id="copy" class="z-button z-yellow" onclick="doCopyProductInfo(1);">复制文件名</button>
  267. <button type="button" id="copy" class="z-button z-cyan" onclick="doCopyProductInfo();">复制信息</button>
  268. </span>
  269. </td>
  270. </tr>
  271. <tr class="z-h50">
  272. <#if Validates.isNotEmpty(order)>
  273. <td id="copy_content" colspan="2">${order.getDesignId()}-${order.getBuyerNick()}-${order.getOrderText()}</td>
  274. <#else>
  275. <td colspan="2"></td>
  276. </#if>
  277. </tr>
  278. </#if>
  279. <#if item.getId() == "userText" && Validates.isNotEmptyBlank(order.getUserText())>
  280. <!--客户文本-->
  281. <tr class="z-h40 z-bg-gray">
  282. <td class="z-bold" colspan="2">客户文本</td>
  283. </tr>
  284. <tr class="z-h100">
  285. <td colspan="2">
  286. <textarea class="z-textarea z-w100p z-h100 ${zmr_color_class}" id="userText" name="userText" class="">${order.getUserText()}</textarea>
  287. </td>
  288. </tr>
  289. </#if>
  290. <#if item.getId() == "userNotice" && Validates.isNotEmptyBlank(order.getUserNotice())>
  291. <!--注意事项-->
  292. <tr class="z-h40 z-bg-gray">
  293. <td class="z-bold" colspan="2">注意事项</td>
  294. </tr>
  295. <tr class="z-h80" >
  296. <td colspan="2">
  297. <textarea id="userNotice" name="userNotice" class="z-textarea z-w100p z-h80 ${zmr_color_class}">${order.getUserNotice()}</textarea>
  298. </td>
  299. </tr>
  300. </#if>
  301. <#if item.getType() == "file">
  302. <!-- 文件资料-->
  303. <tr class="z-h40 z-bg-gray">
  304. <td>
  305. <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>
  306. </td>
  307. <td class="z-text-right">
  308. <#if item.getId() == "EndFile" && endFileLink != null>
  309. <button id="copyLink_${item.getId()}" class="z-button z-cyan z-pd3" onclick="Z.copy('${endFileLink}');top.Z.tips('复制成功')">发送链接</span></button>
  310. </#if>
  311. <button id="upload_${item.getId()}" class="z-button z-pd3 ${zmr_color_class}" <#if !item.isAdd()>disabled=true</#if>>添加</button>
  312. <button id="download_${item.getId()}" class="z-button z-orange z-pd3" onclick="doDownFile('${item.getId()}');">下载</button>
  313. <button id="delete_${item.getId()}" class="z-button z-red z-pd3" onclick="doDeleteFile('${item.getId()}');" <#if !item.isDel()>disabled=true</#if>>删除</button>
  314. </td>
  315. </tr>
  316. <tr class="z-h40">
  317. <td colspan="2">
  318. <div id="div_${item.getId()}" class="z-overflow-y-auto <#if item.getName()=="客户素材">z-h100<#elseif item.getName()=="印刷文件">z-h50<#else>z-h60</#if>">
  319. <#for atta : fileList>
  320. <#if Validates.isEqual(atta.getAttaModul(), item.getId())>
  321. <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()}">
  322. <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>
  323. </div>
  324. </#if>
  325. </#for>
  326. </div>
  327. </td>
  328. </tr>
  329. </#if>
  330. <#if item.getType() == "thumFile">
  331. <!--缩略图-->
  332. <tr class="z-h40 z-bg-gray">
  333. <td class="z-bold" colspan="2">${item.getName()}:</td>
  334. </tr>
  335. <tr height="200px" valign="top">
  336. <td colspan="2">
  337. <div id="thumImgs"><#if Validates.isNotEmpty(item.getSavePath())><img src="${item.getSavePath()}"></#if></div>
  338. </td>
  339. </tr>
  340. </#if>
  341. <#if item.getType() == "firstThumFile">
  342. <!--初稿缩略图-->
  343. <tr class="z-h40 z-bg-gray">
  344. <td class="z-bold" colspan="2">${item.getName()}</td>
  345. </tr>
  346. <tr height="200px" valign="top">
  347. <td colspan="2">
  348. <#if order != null>
  349. <div><img style="cursor: pointer;" src="${order.getDesignId()}-FristThumFile.png" onclick='showLargeImg(this)'></div>
  350. </#if>
  351. </td>
  352. </tr>
  353. </#if>
  354. </#for>
  355. <!--客服留言-->
  356. <#if Validates.isNotEmptyBlank(order.getServicesMessage())>
  357. <tr class="z-h40 z-bg-gray">
  358. <td class="z-bold" colspan="2">客服留言</td>
  359. </tr>
  360. <tr class="z-h80">
  361. <td colspan="2">
  362. <textarea id="servicesMessage" name="servicesMessage" class="z-textarea z-w100p z-h80 ${zmr_color_class}">${order.getServicesMessage()}</textarea>
  363. </td>
  364. </tr>
  365. </#if>
  366. </table>