yjryu / KERIS star
Stormen123 2023-11-17
231117 사용자단 기술문서 수정
@72c397e417ec2ddff8a93dade0b5e977c52360ae
client/views/pages/user/Data/Technology.vue
--- client/views/pages/user/Data/Technology.vue
+++ client/views/pages/user/Data/Technology.vue
@@ -22,7 +22,7 @@
                             <p class="date">{{ yyyymmdd(item.reg_dt) }}</p>
                         </div>
                         <div>
-                            <button class="blue-btn" @click="goToPage3">바로가기</button>
+                            <button class="blue-btn" @click="goToPage3(item)">바로가기</button>
                         </div>
                     </li>
                     <li class="tech-box-sec ">
@@ -248,7 +248,7 @@
         }
     },
     methods: {
-        goToPage3() {
+        goToPage3(item) {
             this.$router.push({ path:'/TechnologyOne.page', query: { 'post_id': item.post_id, 'file_id': item.file_id, 'bbs_id': item.bbs_id }});
         },
 
@@ -276,14 +276,6 @@
             return COMMON_UTIL.yyyymmdd(date);
         },
 
-        //게시글 상세조회 페이지로 이동
-        postSelectOnePage: function (item) {
-            this.$router.push({ path: '/TechSelectOne.page', query: { 'post_id': item.post_id, 'file_id': item.file_id, 'bbs_id': item.bbs_id } });
-        },
-
-        postInsertPage: function () {
-            this.$router.push({ path: '/adm/techInsert.page', query: {} })
-        },
     },
     watch: {
 
client/views/pages/user/Data/TechnologyOne.vue
--- client/views/pages/user/Data/TechnologyOne.vue
+++ client/views/pages/user/Data/TechnologyOne.vue
@@ -8,31 +8,31 @@
                     <h1>기술문서</h1>
                 </div>
                 <div class="tech-report">
-                    <h2>2022년 온라인 콘텐츠 활용 교과서 선도학교 교권 역량 효과성 분석</h2>
-                    <button>기술문서 다운받기</button>
+                    <h2>{{ post.post_title }}</h2>
+                    <button @click="downloadFile()">기술문서 다운받기</button>
 
                 </div>
                 <div class="tech-info">
                     <span class="tech-info-img">
-                        <img src="../../../../resources/jpg/tech-img.png" alt="기술문서 이미지">
+                        <img :src=src alt="기술문서 이미지">
                     </span>
                     <div class="tech-txt-wrap">
                         <ul>
                             <li style="border-top: 1px solid #e5e5e5 ;">
-                                <strong>연구책임자</strong>
-                                <p>정종원</p>
+                                <strong>기술문서명</strong>
+                                <p>{{ post.tech_doc_nm }}</p>
                             </li>
                             <li>
-                                <strong>연구진</strong>
-                                <p> 안성훈, 최준석, 이정태, 나화정, 민예슬</p>
+                                <strong>버전</strong>
+                                <p> {{ post.tech_doc_version }}</p>
+                            </li>
+                            <li>
+                                <strong>주요내용</strong>
+                                <p>{{ post.tech_doc_main_content }}</p>
                             </li>
                             <li>
                                 <strong>키워드</strong>
-                                <p>온라인콘텐츠;선도학교;교원역량</p>
-                            </li>
-                            <li>
-                                <strong>담당부서</strong>
-                                <p>디지털교과서부</p>
+                                <p>{{ post.tech_doc_keyword }}</p>
                             </li>
 
                         </ul>
@@ -40,23 +40,215 @@
 
                 </div>
             </div>
+            <div>
+                <div colspan="2" style="border-bottom: 1px solid #007aff;">
+                    <div id="viewer" ref="viewer" class="viewer"></div>
+                </div>
+            </div>
+            <div class="article-list">
+                    <ul>
+                        <li><span class="next">다음글</span>
+                            <span>
+                                <span v-if="nextPost" @click="movePost(nextPost)" class="sub-content-title">
+                                    {{ nextPost.post_title }}
+                                </span>
+                                <span v-else class="sub-content-title">다음글이 없습니다.</span>
+                            </span>
+                        </li>
+                        <li><span class="prev">이전글</span>
+                            <span>
+                                <span v-if="prevPost" @click="movePost(prevPost)" class="sub-content-title">
+                                    {{ prevPost.post_title }}
+                                </span>
+                                <span v-else class="sub-content-title">이전글이 없습니다.</span>
+                            </span>
+                        </li>
+                    </ul>
+                </div>
             <div class="tech-btn">
                 <button @click="goToPage4">목록</button>
             </div>
         </div>
     </div>
 </template>
-
 <script>
+import axios from 'axios';
+import COMMON_UTIL from '../../../../resources/js/commonUtil.js';
+import { useRoute } from 'vue-router';
+import Viewer from '@toast-ui/editor/dist/toastui-editor-viewer';
+import '@toast-ui/editor/dist/toastui-editor.css';
+import '@toast-ui/editor/dist/i18n/ko-kr';
+import * as FileSaver from 'file-saver';
+
 export default {
     data() {
         return {
+            post: {
+                post_id: null,
+                post_title: null,
+                post_content: null,
+                notice_yn: null,
+                notice_start_dt: null,
+                notice_end_dt: null,
+                reg_dt: null,
+                mdfcn_dt: null,
+                link_url: null,
+                view_cnt: null,
+                file_id: null,
+                bbs_id: '3',
+                rgtr_id: null,
+                mdfr_id: null,
+                ctgry_nm: null,
+                tech_doc_nm: null,
+                tech_doc_version: null,
+                tech_doc_main_content: null,
+                tech_doc_keyword: null,
+            },
+            prevPost: {
+                post_id: null,
+                post_title: null,
+                file_id: null,
+            },
+            nextPost: {
+                post_id: null,
+                post_title: null,
+                file_id: null,
+            },
+            fileList: [],
+            oEditors: [], // oEditors는 스마트에디터용
+            route: useRoute(),
+            thumbnailFileList: [],
+            attachFileList: [],
+            src: null,
         }
     },
     methods: {
         goToPage4() {
             this.$router.push('/Technology.page')
-        }
+        },
+
+        postSelectOne: function () {
+            const vm = this;
+            axios({
+                url: '/post/postSelectOne.json',
+                method: 'post',
+                hearder: {
+                    'Content-Type': "application/json; charset=UTF-8",
+                },
+                data: {
+                    'post_id': vm.route.query.post_id,
+                    'file_id': vm.route.query.file_id,
+                    'bbs_id': vm.route.query.bbs_id
+                }
+            }).then(function (response) {
+                vm.prevPost = response.data.postSelectOne.prevPost;
+                vm.post = response.data.postSelectOne.post;
+                vm.nextPost = response.data.postSelectOne.nextPost;
+                if (response.data.selectFileList.length != 0) {
+                    vm.fileList = response.data.selectFileList;
+                    vm.thumbnailFileList = [];
+                    vm.attachFileList = [];
+                    for (let i = 0; i < vm.fileList.length; i++) {
+                        if (vm.fileList[i].file_ty === 'thumbnail') {
+                            vm.thumbnailFileList.push(vm.fileList[i]);
+                        } else {
+                            vm.attachFileList.push(vm.fileList[i]);
+                        }
+                    }
+                    vm.src = 'http://localhost:8080' + vm.thumbnailFileList[0].file_path.replace('C:', '') + '/thumbnail_' + vm.thumbnailFileList[0].file_nm + '.' + vm.thumbnailFileList[0].file_extn_nm
+                }
+                vm.getViewer(vm.post.post_content)
+            }).catch(function (error) {
+                console.log("error - ", error)
+                alert("게시글 상세보기 조회 오류, 관리자에게 문의하세요.");
+            })
+        },
+        getViewer(data) {
+            this.viewer = new Viewer({
+                el: this.$refs.viewer,
+                initialEditType: 'wysiwyg',
+                previewStyle: 'vertical',
+                initialValue: data,
+                customHTMLRenderer: {
+                    htmlBlock: {
+                        iframe(node) {
+                            return [
+                                { type: 'openTag', tagName: 'iframe', outerNewLine: true, attributes: node.attrs },
+                                { type: 'html', content: node.childrenHTML },
+                                { type: 'closeTag', tagName: 'iframe', outerNewLine: true },
+                            ];
+                        },
+                    }
+                },
+            });
+        },
+
+        downloadFile: function () {
+            const vm = this;
+            let path = vm.attachFileList[0].file_path.replace('C:', '') + '/' + vm.attachFileList[0].file_nm + '.' + vm.attachFileList[0].file_extn_nm;
+            console.log(path);
+            axios({
+                url: '/file/downloadFile.json',
+                method: 'post',
+                headers: {
+                    "Content-Type": "application/x-www-form-urlencoded",
+                },
+                responseType: 'blob',
+                data: `file_path=${encodeURIComponent(path)}`
+            }).then((response) => {
+                const blob = new Blob([response.data]);
+
+                const isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
+
+                if (isSafari) {
+                    FileSaver.saveAs(blob,  vm.attachFileList[0].real_file_nm);
+                } else {
+                    const url = window.URL.createObjectURL(blob);
+                    const a = document.createElement('a');
+                    a.style.display = 'none';
+                    a.href = url;
+                    a.download =  vm.attachFileList[0].real_file_nm;
+                    document.body.appendChild(a);
+                    a.click();
+                    window.URL.revokeObjectURL(url);
+                }
+
+                this.$router.go(0);
+
+            }).catch(function (error) {
+                console.log('error - ', error)
+                alert('에러발생');
+            });
+        },
+
+        movePost: function (post1) {
+            const vm = this;
+            console.log('------------이동-----------')
+            console.log(vm.route)
+            axios({
+                url: '/post/postSelectOne.json',
+                method: 'post',
+                hearder: {
+                    'Content-Type': "application/json; charset=UTF-8",
+                },
+                data: {
+                    'post_id': post1.post_id,
+                    'file_id': post1.file_id,
+                    'bbs_id': post1.bbs_id
+                }
+            }).then(function (response) {
+                vm.prevPost = response.data.postSelectOne.prevPost;
+                vm.post = response.data.postSelectOne.post;
+                vm.nextPost = response.data.postSelectOne.nextPost;
+                vm.fileList = response.data.selectFileList;
+
+
+                vm.getViewer(vm.post.post_content)
+            }).catch(function (error) {
+                console.log("error - ", error)
+                alert("게시글 상세보기 조회 오류, 관리자에게 문의하세요.");
+            })
+        },
     },
     watch: {
 
@@ -66,6 +258,7 @@
     },
     mounted() {
         console.log('Technology mounted');
+        this.postSelectOne();
     }
 }
 </script>
Add a comment
List