index.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501
  1. <template>
  2. <div class="mypage-container">
  3. <!-- 헤더 섹션 -->
  4. <div class="mypage-header">
  5. <div class="header-bg"></div>
  6. <div class="header-content">
  7. <div class="profile-section">
  8. <div class="profile-avatar">
  9. <div class="avatar-placeholder">
  10. <i class="mdi mdi-account"></i>
  11. </div>
  12. </div>
  13. <div class="profile-info">
  14. <h1 class="user-name">{{ useAtStore.auth.nickName || useAtStore.auth.companyName || '사용자' }}</h1>
  15. <p class="user-type">{{ memberType === 'INFLUENCER' ? '인플루언서' : memberType === 'VENDOR' ? '벤더사' : '관리자' }}</p>
  16. <div class="user-stats">
  17. <div class="stat-item">
  18. <span class="stat-number">{{ csList.length }}</span>
  19. <span class="stat-label">문의 내역</span>
  20. </div>
  21. <div class="stat-item">
  22. <span class="stat-number">{{ completedInquiries }}</span>
  23. <span class="stat-label">답변 완료</span>
  24. </div>
  25. </div>
  26. </div>
  27. </div>
  28. </div>
  29. </div>
  30. <!-- 대시보드 섹션 -->
  31. <div class="dashboard-section">
  32. <div class="dashboard-cards">
  33. <!-- 빠른 액션 카드 -->
  34. <div class="dashboard-card quick-actions">
  35. <div class="card-header">
  36. <h3>빠른 작업</h3>
  37. <i class="mdi mdi-lightning-bolt"></i>
  38. </div>
  39. <div class="card-content">
  40. <div class="action-buttons">
  41. <v-btn class="action-btn" @click="addLocated()">
  42. <i class="mdi mdi-plus-circle"></i>
  43. <span>문의 등록</span>
  44. </v-btn>
  45. <v-btn class="action-btn" @click="goToCS()">
  46. <i class="mdi mdi-headset"></i>
  47. <span>고객센터</span>
  48. </v-btn>
  49. <v-btn class="action-btn" @click="goToProfile()">
  50. <i class="mdi mdi-account-edit"></i>
  51. <span>프로필 수정</span>
  52. </v-btn>
  53. </div>
  54. </div>
  55. </div>
  56. <!-- 최근 문의 카드 -->
  57. <div class="dashboard-card recent-inquiries">
  58. <div class="card-header">
  59. <h3>최근 문의 내역</h3>
  60. <i class="mdi mdi-message-text"></i>
  61. </div>
  62. <div class="card-content">
  63. <div class="inquiry-list">
  64. <div v-if="recentInquiries.length > 0">
  65. <div
  66. v-for="item in recentInquiries"
  67. :key="item.SEQ"
  68. class="inquiry-item"
  69. @click="toItemDetail(item.SEQ)"
  70. >
  71. <div class="inquiry-info">
  72. <h4>{{ item.TITLE }}</h4>
  73. <p>{{ formatDate(item.REGDATE) }}</p>
  74. </div>
  75. <div class="inquiry-status">
  76. <span :class="getStatusClass(item.STATUS)">
  77. {{ item.STATUS == '0' ? '답변대기' : '답변완료' }}
  78. </span>
  79. </div>
  80. </div>
  81. </div>
  82. <div v-else class="no-inquiries">
  83. <i class="mdi mdi-message-outline"></i>
  84. <p>등록된 문의가 없습니다</p>
  85. </div>
  86. </div>
  87. <div class="view-all">
  88. <v-btn variant="text" @click="goToCS()">전체 보기</v-btn>
  89. </div>
  90. </div>
  91. </div>
  92. <!-- 알림 카드 -->
  93. <div class="dashboard-card notifications">
  94. <div class="card-header">
  95. <h3>알림</h3>
  96. <i class="mdi mdi-bell"></i>
  97. </div>
  98. <div class="card-content">
  99. <div class="notification-list">
  100. <div class="notification-item">
  101. <div class="notification-icon">
  102. <i class="mdi mdi-information"></i>
  103. </div>
  104. <div class="notification-content">
  105. <h4>서비스 업데이트</h4>
  106. <p>새로운 기능이 추가되었습니다!</p>
  107. </div>
  108. </div>
  109. </div>
  110. </div>
  111. </div>
  112. </div>
  113. </div>
  114. <!-- 문의 등록 팝업 -->
  115. <v-dialog v-model="showInquiryModal" max-width="600px" persistent>
  116. <v-card class="inquiry-modal">
  117. <v-card-title class="modal-header">
  118. <h3>문의 등록</h3>
  119. <v-btn icon @click="closeModal" class="close-btn">
  120. <v-icon>mdi-close</v-icon>
  121. </v-btn>
  122. </v-card-title>
  123. <v-card-text class="modal-body">
  124. <form @submit.prevent="submitInquiry">
  125. <div class="form-group">
  126. <label>문의 유형 <span class="required">*</span></label>
  127. <v-select
  128. v-model="inquiryForm.category"
  129. :items="categoryOptions"
  130. variant="outlined"
  131. placeholder="문의 유형을 선택하세요"
  132. class="custom-select"
  133. :rules="[v => !!v || '문의 유형을 선택해주세요']"
  134. ></v-select>
  135. </div>
  136. <div class="form-group">
  137. <label>제목 <span class="required">*</span></label>
  138. <v-text-field
  139. v-model="inquiryForm.title"
  140. variant="outlined"
  141. placeholder="문의 제목을 입력하세요"
  142. class="custom-input"
  143. :rules="[v => !!v || '제목을 입력해주세요']"
  144. ></v-text-field>
  145. </div>
  146. <div class="form-group">
  147. <label>내용 <span class="required">*</span></label>
  148. <v-textarea
  149. v-model="inquiryForm.content"
  150. variant="outlined"
  151. placeholder="문의 내용을 상세히 입력해주세요"
  152. rows="6"
  153. class="custom-textarea"
  154. :rules="[v => !!v || '내용을 입력해주세요']"
  155. ></v-textarea>
  156. </div>
  157. <div class="form-group">
  158. <label>첨부파일</label>
  159. <v-file-input
  160. v-model="inquiryForm.attachments"
  161. variant="outlined"
  162. placeholder="파일을 선택하세요"
  163. hide-details=""
  164. prepend-icon=""
  165. append-inner-icon="mdi-paperclip"
  166. class="custom-file-input mb--30"
  167. accept="image/*,.pdf,.doc,.docx,.hwp"
  168. multiple
  169. show-size
  170. ></v-file-input>
  171. <p class="file-info">* 이미지, PDF, 문서 파일만 업로드 가능 (최대 10MB)</p>
  172. </div>
  173. </form>
  174. </v-card-text>
  175. <v-card-actions class="modal-footer">
  176. <v-btn @click="closeModal" class="cancel-btn">취소</v-btn>
  177. <v-btn @click="submitInquiry" class="submit-btn" :loading="isSubmitting">등록하기</v-btn>
  178. </v-card-actions>
  179. </v-card>
  180. </v-dialog>
  181. </div>
  182. </template>
  183. <script setup>
  184. import "@vuepic/vue-datepicker/dist/main.css";
  185. import dayjs from 'dayjs';
  186. /************************************************************************
  187. | 레이아웃
  188. ************************************************************************/
  189. definePageMeta({
  190. layout: "default",
  191. });
  192. /************************************************************************
  193. | PROPS
  194. ************************************************************************/
  195. const props = defineProps({
  196. propsData: {
  197. type: Object,
  198. default: () => {},
  199. },
  200. });
  201. /************************************************************************
  202. | 스토어
  203. ************************************************************************/
  204. const useDtStore = useDetailStore();
  205. const useAtStore = useAuthStore();
  206. /************************************************************************
  207. | 전역
  208. ************************************************************************/
  209. const memberType = useAtStore.auth.memberType;
  210. const searchModel = ref("");
  211. const selectedRange = ref('all');
  212. const searchStartDate = ref("");
  213. const searchEndDate = ref("");
  214. const dateOptions = [
  215. { label: '오늘', value: 'today' },
  216. { label: '7일', value: '7d' },
  217. { label: '1개월', value: '1m' },
  218. { label: '3개월', value: '3m' },
  219. { label: '전체', value: 'all' },
  220. ]
  221. const datePickerFormat = "yyyy-MM-dd";
  222. const filter = ref("");
  223. const filderArr = ref([
  224. { title: "전체", value: "" },
  225. { title: "제목", value: "title" },
  226. { title: "내용", value: "content" },
  227. { title: "작성자", value: "writer" }
  228. ]);
  229. const { $toast, $log, $dayjs, $eventBus } = useNuxtApp();
  230. const router = useRouter();
  231. const pageId = computed(() => {
  232. return '마이페이지';
  233. });
  234. const csList = ref([]);
  235. // 대시보드 관련 computed
  236. const completedInquiries = computed(() => {
  237. return csList.value.filter(item => item.STATUS === '1').length;
  238. });
  239. const recentInquiries = computed(() => {
  240. return csList.value.slice(0, 3); // 최근 3개만 표시
  241. });
  242. // 문의 등록 팝업 관련
  243. const showInquiryModal = ref(false);
  244. const isSubmitting = ref(false);
  245. const inquiryForm = ref({
  246. category: '',
  247. title: '',
  248. content: '',
  249. attachments: []
  250. });
  251. const categoryOptions = ref([
  252. { title: '기능문의', value: 'D' },
  253. { title: '기타문의', value: 'E' }
  254. ]);
  255. /* eslint-disable */
  256. /* prettier-ignore */
  257. /************************************************************************
  258. | 함수(METHODS)
  259. ************************************************************************/
  260. const isRecentUpdate = (dateStr) => {
  261. const today = new Date();
  262. const updateDate = new Date(dateStr);
  263. const diffDays = (today - updateDate) / (1000 * 60 * 60 * 24);
  264. // 업데이트 날짜가 오늘 날짜 기준 최근 7일인지 확인
  265. return diffDays <= 7;
  266. }
  267. const paginatedItems = computed(() => {
  268. const start = (currentPage.value - 1) * itemsPerPage;
  269. return csList.value.slice(start, start + itemsPerPage);
  270. });
  271. const setDateRange = (range) => {
  272. const today = dayjs();
  273. switch(range) {
  274. case 'today' :
  275. searchStartDate.value = today.format('YYYY-MM-DD');
  276. searchEndDate.value = today.format('YYYY-MM-DD');
  277. selectedRange.value = 'today';
  278. break;
  279. case '7d':
  280. searchStartDate.value = today.subtract(7, 'day').format('YYYY-MM-DD');
  281. searchEndDate.value = today.format('YYYY-MM-DD');
  282. selectedRange.value = '7d';
  283. break;
  284. case '1m':
  285. searchStartDate.value = today.subtract(1, 'month').format('YYYY-MM-DD');
  286. searchEndDate.value = today.format('YYYY-MM-DD');
  287. selectedRange.value = '1m';
  288. break;
  289. case '3m':
  290. searchStartDate.value = today.subtract(3, 'month').format('YYYY-MM-DD');
  291. searchEndDate.value = today.format('YYYY-MM-DD');
  292. selectedRange.value = '3m';
  293. break;
  294. case 'all':
  295. searchStartDate.value = "";
  296. searchEndDate.value = today.format('YYYY-MM-DD');
  297. selectedRange.value = 'all';
  298. break
  299. }
  300. }
  301. const addLocated = () => {
  302. showInquiryModal.value = true;
  303. };
  304. const goToCS = () => {
  305. router.push('/view/common/cs');
  306. };
  307. const goToProfile = () => {
  308. $toast.info('프로필 수정 기능은 준비중입니다.');
  309. };
  310. const toItemDetail = (__EVENT) => {
  311. router.push({
  312. path: "/view/common/cs/detail",
  313. });
  314. useDtStore.boardInfo.seq = __EVENT;
  315. };
  316. const csListGet = async () => {
  317. let _req = {
  318. USER_SEQ : useAtStore.auth.seq,
  319. keyword: '',
  320. filter: '',
  321. startDate: '',
  322. endDate: ''
  323. };
  324. if(useAtStore.auth.seq == 2){
  325. _req.USER_SEQ = 0;
  326. }
  327. await useAxios()
  328. .post("/cs/list", _req)
  329. .then((res) => {
  330. csList.value = res.data;
  331. });
  332. };
  333. const fnSearch = (__KEYWORD, __FILTER) => {
  334. let _req = {
  335. USER_SEQ: useAtStore.auth.seq,
  336. filter: __FILTER,
  337. keyword: __KEYWORD,
  338. startDate: searchStartDate.value ? dayjs(searchStartDate.value).format('YYYY-MM-DD') : '',
  339. endDate: searchEndDate.value ? dayjs(searchEndDate.value).format('YYYY-MM-DD') : ''
  340. };
  341. // 관리자인 경우 모든 문의 조회
  342. if(useAtStore.auth.seq == 2){
  343. _req.USER_SEQ = 0;
  344. }
  345. useAxios()
  346. .post("/cs/search", _req)
  347. .then((res) => {
  348. csList.value = res.data;
  349. currentPage.value = 1; // 검색 후 첫 페이지로 이동
  350. })
  351. .catch((error) => {
  352. console.error('검색 실패:', error);
  353. $toast.error('검색에 실패했습니다.');
  354. });
  355. };
  356. const goToDeliveryDetail = (item) => {
  357. // 제품 정보를 스토어에 저장
  358. useDtStore.boardInfo.seq = item.SEQ;
  359. useDtStore.boardInfo.pageType = "D";
  360. // 배송 관리 페이지로 이동
  361. router.push({
  362. path: "/view/common/deli/detail",
  363. query: {
  364. itemId: item.SEQ,
  365. itemName: item.NAME,
  366. price1: item.PRICE1,
  367. price2: item.PRICE2 || item.PRICE1,
  368. thumbFile: item.THUMB_FILE || ''
  369. }
  370. });
  371. };
  372. const getStatusClass = (status) => {
  373. switch(status) {
  374. case '0':
  375. return 'status-waiting';
  376. case '1':
  377. return 'status-completed';
  378. }
  379. };
  380. const formatDate = (dateStr) => {
  381. if (!dateStr) return '';
  382. const date = new Date(dateStr);
  383. const year = date.getFullYear();
  384. const month = String(date.getMonth() + 1).padStart(2, '0');
  385. const day = String(date.getDate()).padStart(2, '0');
  386. return `${year}.${month}.${day}`;
  387. };
  388. // 팝업 관련 함수들
  389. const closeModal = () => {
  390. showInquiryModal.value = false;
  391. resetForm();
  392. };
  393. const resetForm = () => {
  394. inquiryForm.value = {
  395. category: '',
  396. title: '',
  397. content: '',
  398. attachments: []
  399. };
  400. };
  401. const submitInquiry = async () => {
  402. // 폼 유효성 검사
  403. if (!inquiryForm.value.category) {
  404. $toast.error('문의 유형을 선택해주세요.');
  405. return;
  406. }
  407. if (!inquiryForm.value.title) {
  408. $toast.error('제목을 입력해주세요.');
  409. return;
  410. }
  411. if (!inquiryForm.value.content) {
  412. $toast.error('내용을 입력해주세요.');
  413. return;
  414. }
  415. isSubmitting.value = true;
  416. try {
  417. const formData = new FormData();
  418. formData.append('USER_SEQ', useAtStore.auth.seq);
  419. formData.append('CATEGORY', inquiryForm.value.category);
  420. formData.append('TITLE', inquiryForm.value.title);
  421. formData.append('CONTENT', inquiryForm.value.content);
  422. // 첨부파일 처리
  423. if (inquiryForm.value.attachments && inquiryForm.value.attachments.length > 0) {
  424. inquiryForm.value.attachments.forEach((file, index) => {
  425. formData.append(`files[${index}]`, file);
  426. });
  427. }
  428. await useAxios()
  429. .post("/cs/reg", formData, {
  430. headers: {
  431. 'Content-Type': 'multipart/form-data'
  432. }
  433. })
  434. .then((res) => {
  435. if (res.data.success) {
  436. $toast.success('문의가 성공적으로 등록되었습니다.');
  437. closeModal();
  438. csListGet(); // 목록 새로고침
  439. } else {
  440. $toast.error('문의 등록에 실패했습니다.');
  441. }
  442. });
  443. } catch (error) {
  444. $toast.error('문의 등록 중 오류가 발생했습니다.');
  445. console.error('Error submitting inquiry:', error);
  446. } finally {
  447. isSubmitting.value = false;
  448. }
  449. };
  450. /************************************************************************
  451. | WATCH
  452. ************************************************************************/
  453. onMounted(() => {
  454. csListGet();
  455. // 날짜 초기화
  456. const today = dayjs();
  457. searchEndDate.value = today.format('YYYY-MM-DD');
  458. });
  459. </script>