index.vue 16 KB

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