print-a2.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270
  1. <template>
  2. <div class="a2-print-page">
  3. <div class="a2-header">
  4. <h1>아우디 공식딜러 고진모터스 영업사원 명단</h1>
  5. </div>
  6. <div v-for="branch in groupedData" :key="branch.id" class="branch-section">
  7. <h2 class="branch-name">{{ branch.name }}</h2>
  8. <div v-for="team in branch.teams" :key="team.id" class="team-section">
  9. <h3 class="team-name">{{ team.name }}</h3>
  10. <div class="staff-grid">
  11. <div v-for="staff in team.staff" :key="staff.id" class="staff-card">
  12. <div class="staff-photo">
  13. <img v-if="staff.photo_url" :src="getImageUrl(staff.photo_url)" :alt="staff.name" />
  14. <img v-else src="/img/audi_logo.png" alt="Audi Logo" class="logo-placeholder" />
  15. </div>
  16. <div class="staff-info">
  17. <div class="staff-position">{{ getPositionName(staff.position) }} {{ staff.name }}</div>
  18. <div class="staff-phone">{{ staff.direct_phone || staff.main_phone }}</div>
  19. </div>
  20. </div>
  21. </div>
  22. </div>
  23. </div>
  24. </div>
  25. </template>
  26. <script setup>
  27. import { ref, onMounted, computed } from 'vue'
  28. definePageMeta({
  29. layout: false
  30. })
  31. const { get } = useApi()
  32. const { getImageUrl } = useImage()
  33. const salesList = ref([])
  34. const showrooms = ref([])
  35. // 직책 이름 가져오기
  36. const getPositionName = (positionCode) => {
  37. const positions = {
  38. 10: '팀장',
  39. 15: '마스터',
  40. 20: '차장',
  41. 30: '과장',
  42. 40: '대리',
  43. 60: '사원'
  44. }
  45. return positions[positionCode] || '-'
  46. }
  47. // 팀 이름 가져오기
  48. const getTeamName = (teamId) => {
  49. if (teamId === 0 || teamId === '0') {
  50. return '마스터팀'
  51. }
  52. return teamId ? `${teamId}팀` : '기타'
  53. }
  54. // 지점별, 팀별로 그룹화
  55. const groupedData = computed(() => {
  56. const branches = {}
  57. salesList.value.forEach(staff => {
  58. const branchId = staff.showroom || 0
  59. const teamId = staff.team ?? 0
  60. // 지점 초기화
  61. if (!branches[branchId]) {
  62. const showroom = showrooms.value.find(s => s.id === branchId)
  63. branches[branchId] = {
  64. id: branchId,
  65. name: showroom ? showroom.name : '미지정',
  66. teams: {}
  67. }
  68. }
  69. // 팀 초기화
  70. if (!branches[branchId].teams[teamId]) {
  71. branches[branchId].teams[teamId] = {
  72. id: teamId,
  73. name: getTeamName(teamId),
  74. staff: []
  75. }
  76. }
  77. // 직원 추가
  78. branches[branchId].teams[teamId].staff.push(staff)
  79. })
  80. // 배열로 변환 및 정렬
  81. return Object.values(branches).map(branch => ({
  82. ...branch,
  83. teams: Object.values(branch.teams).map(team => ({
  84. ...team,
  85. staff: team.staff.sort((a, b) => {
  86. // 마스터(15) 먼저
  87. if (a.position === 15 && b.position !== 15) return -1
  88. if (a.position !== 15 && b.position === 15) return 1
  89. // 그 다음 직급 순서대로 (10, 20, 30, 40, 60)
  90. return a.position - b.position
  91. })
  92. })).sort((a, b) => a.id - b.id)
  93. })).sort((a, b) => a.id - b.id)
  94. })
  95. // 데이터 로드
  96. const loadData = async () => {
  97. // 전시장 목록 로드
  98. const { data: branchData } = await get('/branch/list', { per_page: 1000 })
  99. if (branchData?.success && branchData?.data) {
  100. showrooms.value = branchData.data.items || []
  101. }
  102. // 전체 영업사원 목록 로드
  103. const { data: salesData } = await get('/staff/sales', { per_page: 1000 })
  104. if (salesData?.success && salesData?.data) {
  105. salesList.value = salesData.data.items || []
  106. }
  107. }
  108. onMounted(async () => {
  109. await loadData()
  110. // 데이터 로드 후 자동 출력
  111. setTimeout(() => {
  112. window.print()
  113. }, 500)
  114. })
  115. </script>
  116. <style scoped>
  117. .a2-print-page {
  118. padding: 20px;
  119. background: white;
  120. }
  121. .a2-header {
  122. text-align: center;
  123. margin-bottom: 30px;
  124. padding-bottom: 20px;
  125. border-bottom: 3px solid #000;
  126. }
  127. .a2-header h1 {
  128. font-size: 28px;
  129. font-weight: bold;
  130. margin: 0;
  131. }
  132. .branch-section {
  133. margin-bottom: 40px;
  134. page-break-inside: avoid;
  135. }
  136. .branch-name {
  137. font-size: 24px;
  138. font-weight: bold;
  139. color: #333;
  140. margin-bottom: 20px;
  141. padding: 10px;
  142. background: #f0f0f0;
  143. border-left: 5px solid #000;
  144. }
  145. .team-section {
  146. margin-bottom: 30px;
  147. page-break-inside: avoid;
  148. }
  149. .team-name {
  150. font-size: 20px;
  151. font-weight: bold;
  152. color: #555;
  153. margin-bottom: 15px;
  154. padding: 8px;
  155. background: #f8f8f8;
  156. border-left: 3px solid #666;
  157. }
  158. .staff-grid {
  159. display: grid;
  160. grid-template-columns: repeat(8, 1fr);
  161. gap: 20px;
  162. margin-bottom: 20px;
  163. }
  164. .staff-card {
  165. border: 1px solid #ddd;
  166. padding: 15px;
  167. text-align: center;
  168. background: white;
  169. page-break-inside: avoid;
  170. }
  171. .staff-photo {
  172. width: 100%;
  173. height: 150px;
  174. margin-bottom: 10px;
  175. overflow: hidden;
  176. display: flex;
  177. align-items: center;
  178. justify-content: center;
  179. border: 1px solid #ddd;
  180. }
  181. .staff-photo img {
  182. max-width: 100%;
  183. max-height: 100%;
  184. object-fit: cover;
  185. }
  186. .staff-photo .logo-placeholder {
  187. max-width: 80%;
  188. max-height: 80%;
  189. object-fit: contain;
  190. }
  191. .staff-info {
  192. margin-top: 10px;
  193. }
  194. .staff-position {
  195. font-size: 16px;
  196. font-weight: bold;
  197. color: #333;
  198. margin-bottom: 5px;
  199. }
  200. .staff-phone {
  201. font-size: 13px;
  202. color: #888;
  203. }
  204. /* 인쇄 스타일 */
  205. @media print {
  206. .a2-print-page {
  207. padding: 10mm;
  208. }
  209. .staff-grid {
  210. grid-template-columns: repeat(8, 1fr);
  211. gap: 10px;
  212. }
  213. .staff-card {
  214. padding: 10px;
  215. }
  216. .staff-photo {
  217. height: 120px;
  218. }
  219. .staff-position {
  220. font-size: 14px;
  221. }
  222. .staff-phone {
  223. font-size: 11px;
  224. }
  225. @page {
  226. size: A2;
  227. margin: 10mm;
  228. }
  229. }
  230. </style>