ir.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. <template>
  2. <main>
  3. <section class="visual--section">
  4. <div class="img--wrap">
  5. <picture>
  6. <img src="/img/company/img--about1.jpg" alt="" />
  7. </picture>
  8. </div>
  9. <div class="title--wrap color--white">
  10. <h2>Company</h2>
  11. </div>
  12. </section>
  13. <div class="detail--container">
  14. <section>
  15. <div class="desc--section full--type">
  16. <h3 class="big--title">IR</h3>
  17. </div>
  18. </section>
  19. <div class="content--wrap">
  20. <div class="news--wrap">
  21. <table class="news--table">
  22. <colgroup>
  23. <col style="width:5%">
  24. <col style="width:60%">
  25. <col style="width:10%">
  26. <col style="width:5%" class="view">
  27. </colgroup>
  28. <thead>
  29. <tr>
  30. <th v-for="column in columns" :key="column.key" :class="{ 'view': column.key === 'views' }">
  31. {{ column.label }}
  32. </th>
  33. </tr>
  34. </thead>
  35. <tbody>
  36. <tr v-for="news in paginatedNews" :key="news.id" @click="goToNews(news)">
  37. <td>{{ news.id }}</td>
  38. <td class="ellipsis1">{{ news.title }}{{ news.title }}{{ news.title }}{{ news.title }}{{ news.title }}{{ news.title }}{{ news.title }}</td>
  39. <td class="date">{{ news.date }}</td>
  40. <td class="view">{{ news.views }}</td>
  41. </tr>
  42. </tbody>
  43. </table>
  44. </div>
  45. <!-- 페이지네이션 -->
  46. <div class="pagination--wrap">
  47. <button
  48. class="pagination--btn prev"
  49. @click="goToPage(currentPage - 1)"
  50. :disabled="currentPage === 1"
  51. >
  52. <svg fill="none" xmlns="http://www.w3.org/2000/svg" width="24px" height="24px">
  53. <use href="/img/ico--back--s.svg#main"></use>
  54. </svg>
  55. </button>
  56. <div class="pagination--numbers">
  57. <button
  58. v-for="page in displayPages"
  59. :key="page"
  60. class="pagination--number"
  61. :class="{ active: page === currentPage }"
  62. @click="goToPage(page)"
  63. >
  64. {{ page }}
  65. </button>
  66. </div>
  67. <button
  68. class="pagination--btn next"
  69. @click="goToPage(currentPage + 1)"
  70. :disabled="currentPage === totalPages"
  71. >
  72. <svg fill="none" xmlns="http://www.w3.org/2000/svg" width="24px" height="24px">
  73. <use href="/img/ico--forward--s.svg#main"></use>
  74. </svg>
  75. </button>
  76. </div>
  77. </div>
  78. </div>
  79. </main>
  80. </template>
  81. <script setup>
  82. // 테이블 컬럼 정의
  83. const columns = [
  84. { key: 'id', label: '번호' },
  85. { key: 'title', label: '제목' },
  86. { key: 'date', label: '등록일' },
  87. { key: 'views', label: '조회수' }
  88. ];
  89. // 뉴스 데이터
  90. const newsData = ref([
  91. {
  92. id: 1,
  93. title: '아우디 신형 e-tron GT 출시 소식',
  94. date: '2025-01-15',
  95. views: 1234,
  96. link: '/company/view'
  97. },
  98. {
  99. id: 2,
  100. title: '아우디 콰트로 45주년 기념 이벤트',
  101. date: '2025-01-14',
  102. views: 987,
  103. link: '/company/view'
  104. },
  105. {
  106. id: 3,
  107. title: '아우디 전기차 라인업 확대',
  108. date: '2025-01-13',
  109. views: 2156,
  110. link: '/company/view'
  111. },
  112. {
  113. id: 4,
  114. title: 'Audi Sport 신규 모델 발표',
  115. date: '2025-01-12',
  116. views: 1543,
  117. link: '/company/view'
  118. },
  119. {
  120. id: 5,
  121. title: '아우디 지속가능성 이니셔티브',
  122. date: '2025-01-11',
  123. views: 876,
  124. link: '/company/view'
  125. },
  126. {
  127. id: 6,
  128. title: '아우디 커넥트 서비스 업데이트',
  129. date: '2025-01-10',
  130. views: 1098,
  131. link: '/company/view'
  132. },
  133. {
  134. id: 7,
  135. title: '아우디 디자인 어워드 수상',
  136. date: '2025-01-09',
  137. views: 765,
  138. link: '/company/view'
  139. },
  140. {
  141. id: 8,
  142. title: '아우디 자율주행 기술 발전',
  143. date: '2025-01-08',
  144. views: 1876,
  145. link: '/company/view'
  146. },
  147. {
  148. id: 9,
  149. title: '아우디 RS 시리즈 신규 출시',
  150. date: '2025-01-07',
  151. views: 2341,
  152. link: '/company/view'
  153. },
  154. {
  155. id: 10,
  156. title: '아우디 프리미엄 서비스 소개',
  157. date: '2025-01-06',
  158. views: 654,
  159. link: '/company/view0'
  160. },
  161. {
  162. id: 11,
  163. title: '아우디 e-tron 배터리 기술 혁신',
  164. date: '2025-01-05',
  165. views: 1432,
  166. link: '/company/view1'
  167. },
  168. ]);
  169. const currentPage = ref(1);
  170. const itemsPerPage = 10;
  171. // 전체 페이지 수 계산
  172. const totalPages = computed(() => {
  173. return Math.ceil(newsData.value.length / itemsPerPage);
  174. });
  175. // 현재 페이지에 표시할 뉴스
  176. const paginatedNews = computed(() => {
  177. const start = (currentPage.value - 1) * itemsPerPage;
  178. const end = start + itemsPerPage;
  179. return newsData.value.slice(start, end);
  180. });
  181. // 표시할 페이지 번호 (최대 5개)
  182. const displayPages = computed(() => {
  183. const pages = [];
  184. const maxDisplay = 5;
  185. let startPage = Math.max(1, currentPage.value - 2);
  186. let endPage = Math.min(totalPages.value, startPage + maxDisplay - 1);
  187. if (endPage - startPage < maxDisplay - 1) {
  188. startPage = Math.max(1, endPage - maxDisplay + 1);
  189. }
  190. for (let i = startPage; i <= endPage; i++) {
  191. pages.push(i);
  192. }
  193. return pages;
  194. });
  195. // 페이지 이동
  196. const goToPage = (page) => {
  197. if (page >= 1 && page <= totalPages.value) {
  198. currentPage.value = page;
  199. window.scrollTo({ top: 0, behavior: 'smooth' });
  200. }
  201. };
  202. // 뉴스 클릭 시 이동
  203. const goToNews = (row) => {
  204. navigateTo(row.link);
  205. };
  206. </script>