view.html 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <!DOCTYPE html>
  2. <html lang="en" xmlns:th=http://www.thymeleaf.org>
  3. <head>
  4. <meta charset="utf-8"/>
  5. <meta name="viewport" content="width=device-width,initial-scale=1"/>
  6. <meta name="theme-color" content="#000000"/>
  7. <meta name="description" content="포항시 교통정보센터입니다"/>
  8. <meta http-equiv="X-UA-Compatible" content="IE=edge"/>
  9. <title>포항시 교통정보센터</title>
  10. <th:block th:include="/include/head.html"></th:block>
  11. <link rel="stylesheet" th:href="@{/css/notice.css}">
  12. </head>
  13. <body id="body">
  14. <th:block th:include="/include/header.html"></th:block>
  15. <div class="noticeWrap">
  16. <div class="container view">
  17. <h2 class="header">공지사항</h2>
  18. <div class="content view">
  19. <div class="view-box">
  20. <div>
  21. <input class="title" th:value="${notice.getBSubject()}" readonly>
  22. <div class="b_content"></div>
  23. <!-- <textarea class="b_content" rows="19" th:text="${notice.getBContent()}" readonly></textarea>-->
  24. <div class="attach-box">
  25. <div class="attach">
  26. <div th:if="${notice.getAttachFile() == '||' or #strings.isEmpty(notice.getAttachFile())}">첨부파일 없음</div>
  27. <div class="attach-file" th:if="${notice.getAttachFile() != '||' and not #strings.isEmpty(notice.getAttachFile())}"
  28. th:each="item, i : ${#strings.arraySplit(notice.getAttachFile(), '|')}"
  29. th:text="${item}" th:title="${item + ' 다운로드'}"
  30. th:onclick="attachFileDownload([[${i.index}]], [[${notice}]], [[${item}]])"
  31. ></div>
  32. </div>
  33. <div class="list-btn" onclick="movePath('/notice/list')">목록</div>
  34. </div>
  35. </div>
  36. </div>
  37. </div>
  38. </div>
  39. </div>
  40. <th:block th:include="/include/footer.html"></th:block>
  41. </body>
  42. </html>
  43. <script th:inline="javascript">
  44. // let isMobile = /iPhone|iPad|iPod|Android/i.test(navigator.userAgent);
  45. //
  46. // if (isMobile) {
  47. // $('.b_content').attr('rows', 10);
  48. // }
  49. const notice = [[${notice}]];
  50. $('.b_content').html(notice.b_content);
  51. function attachFileDownload(index, notice, fileName) {
  52. let attachFileId = notice.attach_file_id;
  53. if (attachFileId && attachFileId.split('|').length > 0) {
  54. attachFileId = attachFileId.split('|')[index];
  55. }
  56. const param = {
  57. boardNo : notice.board_no,
  58. fileId : attachFileId,
  59. }
  60. getDataAsync('/api/notice/attach', 'POST', param, null, (jsonData)=>{
  61. const attachFile = jsonData.attach_file;
  62. const ext = fileName.substring(fileName.lastIndexOf('.') + 1, fileName.length);
  63. if (attachFile.length > 0) {
  64. if (!ext) {
  65. return alert("파일 확장자명이 잘못 되었습니다.");
  66. }
  67. const file = new Blob([attachFile], {type: "application/" + ext});
  68. const link = document.createElement('a');
  69. link.href = window.URL.createObjectURL(file);
  70. link.download = fileName;
  71. link.click();
  72. }
  73. else {
  74. alert(jsonData.message);
  75. }
  76. }, null);
  77. }
  78. </script>