attaFileList.zml 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405
  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.fixed = true;
  222. dialog.url = "showLargeImg.htm?imgpath="+thisImg.src;
  223. dialog.width = parent.Z.D.clientWidth()-600;
  224. dialog.height = parent.Z.D.clientHeight()-400;
  225. dialog.execute();
  226. dialog.$background.remove();
  227. }
  228. function doCopyProductInfo(copyType)
  229. {
  230. if (copyType == 1)
  231. {//复制文件名
  232. var designId = "${order.getDesignId()}";
  233. var buyerNick = "${order.getBuyerNick()}";
  234. var reciverName = "${order.getUserContact()}";
  235. var fileName = designId+ "-";
  236. // if (buyerNick.indexOf("-") > 0)
  237. // {
  238. // fileName += reciverName;
  239. // }
  240. // else
  241. // {
  242. fileName += buyerNick;
  243. // }
  244. if (fileName == "-")
  245. return;
  246. Z.copy(fileName);
  247. top.Z.tips("复制成功");
  248. }
  249. else
  250. {//复制信息
  251. if (Z("#copy_content").length == 0)
  252. return;
  253. Z.copy(Z("#copy_content").text());
  254. top.Z.tips("复制成功");
  255. }
  256. }
  257. </script>
  258. ${Htmls.toCallFrame()}
  259. <input name="designId" id="designId" value="${order.getDesignId()}" type="hidden">
  260. <table class="z-table z-bordered-line z-pd5 zi-bd z-bg-blue z-mg-t20">
  261. <#for item : attaList>
  262. <#if item.getId() == "copy">
  263. <!--复制-->
  264. <tr class="z-h40 z-bg-gray">
  265. <td class="z-bold" colspan="2">产品信息:
  266. <span style="margin-left:100px">
  267. <button type="button" id="copy" class="z-button z-yellow" onclick="doCopyProductInfo(1);">复制文件名</button>
  268. <button type="button" id="copy" class="z-button z-cyan" onclick="doCopyProductInfo();">复制信息</button>
  269. </span>
  270. </td>
  271. </tr>
  272. <tr class="z-h50">
  273. <#if Validates.isNotEmpty(order)>
  274. <td id="copy_content" colspan="2">${order.getDesignId()}-${order.getBuyerNick()}-${order.getOrderText()}</td>
  275. <#else>
  276. <td colspan="2"></td>
  277. </#if>
  278. </tr>
  279. </#if>
  280. <#if item.getId() == "userText" && Validates.isNotEmptyBlank(order.getUserText())>
  281. <!--客户文本-->
  282. <tr class="z-h40 z-bg-gray">
  283. <td class="z-bold" colspan="2">客户文本</td>
  284. </tr>
  285. <tr class="z-h100">
  286. <td colspan="2">
  287. <textarea class="z-textarea z-w100p z-h100 ${zmr_color_class}" id="userText" name="userText" class="">${order.getUserText()}</textarea>
  288. </td>
  289. </tr>
  290. </#if>
  291. <#if item.getId() == "userNotice" && Validates.isNotEmptyBlank(order.getUserNotice())>
  292. <!--注意事项-->
  293. <tr class="z-h40 z-bg-gray">
  294. <td class="z-bold" colspan="2">注意事项</td>
  295. </tr>
  296. <tr class="z-h80" >
  297. <td colspan="2">
  298. <textarea id="userNotice" name="userNotice" class="z-textarea z-w100p z-h80 ${zmr_color_class}">${order.getUserNotice()}</textarea>
  299. </td>
  300. </tr>
  301. </#if>
  302. <#if item.getType() == "file">
  303. <!-- 文件资料-->
  304. <tr class="z-h40 z-bg-gray">
  305. <td>
  306. <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>
  307. </td>
  308. <td class="z-text-right">
  309. <#if item.getId() == "EndFile" && endFileLink != null>
  310. <button id="copyLink_${item.getId()}" class="z-button z-cyan z-pd3" onclick="Z.copy('${endFileLink}');top.Z.tips('复制成功')">发送链接</span></button>
  311. </#if>
  312. <button id="upload_${item.getId()}" class="z-button z-pd3 ${zmr_color_class}" <#if !item.isAdd()>disabled=true</#if>>添加</button>
  313. <button id="download_${item.getId()}" class="z-button z-orange z-pd3" onclick="doDownFile('${item.getId()}');">下载</button>
  314. <button id="delete_${item.getId()}" class="z-button z-red z-pd3" onclick="doDeleteFile('${item.getId()}');" <#if !item.isDel()>disabled=true</#if>>删除</button>
  315. </td>
  316. </tr>
  317. <tr class="z-h40">
  318. <td colspan="2">
  319. <div id="div_${item.getId()}" class="z-overflow-y-auto <#if item.getName()=="客户素材">z-h100<#elseif item.getName()=="印刷文件">z-h50<#else>z-h60</#if>">
  320. <#for atta : fileList>
  321. <#if Validates.isEqual(atta.getAttaModul(), item.getId())>
  322. <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()}">
  323. <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>
  324. </div>
  325. </#if>
  326. </#for>
  327. </div>
  328. </td>
  329. </tr>
  330. </#if>
  331. <#if item.getType() == "thumFile">
  332. <!--缩略图-->
  333. <tr class="z-h40 z-bg-gray">
  334. <td class="z-bold" colspan="2">${item.getName()}:</td>
  335. </tr>
  336. <tr height="200px" valign="top">
  337. <td colspan="2">
  338. <div id="thumImgs"><#if Validates.isNotEmpty(item.getSavePath())><img src="${item.getSavePath()}"></#if></div>
  339. </td>
  340. </tr>
  341. </#if>
  342. <#if item.getType() == "firstThumFile">
  343. <!--初稿缩略图-->
  344. <tr class="z-h40 z-bg-gray">
  345. <td class="z-bold" colspan="2">${item.getName()}</td>
  346. </tr>
  347. <tr height="200px" valign="top">
  348. <td colspan="2">
  349. <#if order != null>
  350. <div><img style="cursor: pointer;" src="${order.getDesignId()}-FristThumFile.png" onclick='showLargeImg(this)'></div>
  351. </#if>
  352. </td>
  353. </tr>
  354. </#if>
  355. </#for>
  356. <!--客服留言-->
  357. <#if Validates.isNotEmptyBlank(order.getServicesMessage())>
  358. <tr class="z-h40 z-bg-gray">
  359. <td class="z-bold" colspan="2">客服留言</td>
  360. </tr>
  361. <tr class="z-h80">
  362. <td colspan="2">
  363. <textarea id="servicesMessage" name="servicesMessage" class="z-textarea z-w100p z-h80 ${zmr_color_class}">${order.getServicesMessage()}</textarea>
  364. </td>
  365. </tr>
  366. </#if>
  367. </table>