
File name
Commit message
Commit date
File name
Commit message
Commit date
File name
Commit message
Commit date
File name
Commit message
Commit date
File name
Commit message
Commit date
File name
Commit message
Commit date
<template>
<div class="tech-wrap">
<div class="content-box">
<div class="title-wrap">
<div class="flex-start">
<img src="../../../../resources/jpg/tech-logo.png" alt="기술문서 아이콘" class="title-icon">
<h2 class="main-title">기술문서</h2>
</div>
</div>
<div class="content-wrap">
<table class="insert-table">
<tbody>
<tr>
<th>제목</th>
<td><input type="text" name="" id="techTitle" v-model="post.post_title"></td>
</tr>
<tr>
<th>카테고리</th>
<td>
<div class="flex-start">
<div>
<input type="radio" name="category" id="api" value="api" style="display:none"
v-model="post.ctgry_nm">
<label for="api" class="category">API</label>
</div>
<div>
<input type="radio" name="category" id="tech" value="tech" style="display:none"
v-model="post.ctgry_nm">
<label for="tech" class="category">기술리포트</label>
</div>
<div>
<input type="radio" name="category" id="issue" value="standard" style="display:none"
v-model="post.ctgry_nm">
<label for="issue" class="category">기술규격문서</label>
</div>
</div>
</td>
</tr>
<tr>
<th>기술문서 필수내용</th>
<td>
<div class="atech-grid">
<input type="text" name="" id="techName" placeholder="기술문서명">
<input type="text" name="" id="version" placeholder="버전">
<input type="text" name="" id="techContent" placeholder="주요내용(20자 내외)">
<input type="text" name="" id="keyword" placeholder="키워드">
</div>
</td>
</tr>
<tr>
<th>내용</th>
<td><textarea name="smart" id="smart" style="width:100%"></textarea></td>
</tr>
<tr class="file-zone">
<th>표지이미지</th>
<td>
<div class="btn-upload" @click="openFileInput">표지 이미지 업로드</div>
<input type="file" name="file" id="file" ref="fileInput" style="display: none"
@change="fileUpload()">
<ul v-for="(file, idx) in fileList" :key="idx" class="file-list">
<li> {{ file.name }} <button @click="fileRemove(idx)" class="aclose-btn">X</button></li>
</ul>
</td>
</tr>
<tr class="file-zone">
<th>첨부파일</th>
<td>
<div class="btn-upload" @click="openFileInput">파일 업로드</div>
<input type="file" name="file" id="file" ref="fileInput" style="display: none"
@change="fileUpload()">
<ul v-for="(file, idx) in fileList" :key="idx" class="file-list">
<li> {{ file.name }} <button @click="fileRemove(idx)" class="aclose-btn">X</button></li>
</ul>
</td>
</tr>
</tbody>
</table>
<div class="btn-wrap">
<button class="dark-gray-btn" @click="postSelectListPage()">이전</button>
<button class="blue-btn" @click="postInsertCheck()">등록</button>
</div>
</div>
</div>
</div>
</template>
<script>
import axios from 'axios';
import COMMON_UTIL from '../../../../resources/js/commonUtil.js';
export default {
data() {
return {
post: {
bbs_id: '3',
post_title: null,
post_content: null,
link_url: null,
// 카테고리가 없는 게시판에서는 null로 설정 부탁합니다!
ctgry_nm: null,
},
fileList: [],
filecount: 0,
oEditors: [], // oEditors는 스마트에디터용
};
},
methods: {
//게시글 및 첨부파일 등록
postInsert: function () {
const vm = this;
let formData = new FormData();
if (vm.fileList.length > 0) {
for (let i = 0; i < vm.fileList.length; i++) {
formData.append('file', vm.fileList[i]);
console.log(formData.get('file'));
}
formData.append("post", JSON.stringify(vm.post));
axios({
url: '/post/postFileInsert.file',
method: 'post',
headers: {
'Content-Type': 'multipart/form-data',
},
data: formData
}).then(function (response) {
console.log("qnaInsert - response : ", response);
let result = response.data;
if (result > 0) {
alert("등록을 완료하였습니다.");
vm.postSelectListPage()
} else {
alert("등록 실패, 관리자에게 문의해주세요.");
}
}).catch(function (error) {
console.log("qnaInsert - error : ", error);
alert("등록 오류, 관리자에게 문의해주세요.");
});
} else {
axios({
url: '/post/postInsert.json',
method: 'post',
headers: {
'Content-Type': "application/json; charset=UTF-8",
},
data: vm.post
}).then(function (response) {
console.log("noticeInsert - response : ", response);
let result = response.data;
if (result > 0) {
alert("등록을 완료하였습니다.");
vm.postSelectListPage()
} else {
alert("등록 실패, 관리자에게 문의해주세요.");
}
}).catch(function (error) {
console.log("noticeInsert - error : ", error);
alert("등록 오류, 관리자에게 문의해주세요.");
});
}
},
//등록 유효성 검사
postInsertCheck: function () {
const oEditors = this.oEditors;
oEditors.getById["smart"].exec("UPDATE_CONTENTS_FIELD", []);
// 스마트에디터의 iframe에 있는 내용을 textarea로.
this.post.post_content = document.getElementById("smart").value;
console.log(document.getElementById("smart").value);
console.log(this.post.post_content);
console.log(COMMON_UTIL.isEmpty(this.post.post_title));
if (COMMON_UTIL.isEmpty(this.post.post_title) === false) {
alert("제목을 입력해주세요.");
return false;
}
if (COMMON_UTIL.isEmpty(this.post.ctgry_nm) === false) {
alert("카테고리를 선택해주세요.");
return false;
}
if (COMMON_UTIL.isEmpty(this.post.post_content) === false || this.post.post_content === "<p><br></p>") {
alert("내용을 입력해주세요.");
return false;
}
this.postInsert();
},
//파일업로드
fileUpload: function () {
this.fileList[this.filecount] = this.$refs.fileInput.files[0]
this.filecount += 1
},
//파일업로드 중 업로드 파일 삭제
fileRemove(idx) {
this.fileList.splice(idx, 1);
this.filecount = this.fileList.length;
},
//게시글 리스트로 이동
postSelectListPage: function () {
this.$router.push({ path: '/adm/techSelectList.page' });
},
// 파일 업로드 커스텀을 위한 함수
openFileInput: function () {
this.$refs.fileInput.click(); // 파일 업로드 input 요소를 클릭
},
},
watch: {},
computed: {},
components: {},
mounted() {
// 스마트 에디터 적용
const oEditors = this.oEditors;
nhn.husky.EZCreator.createInIFrame({
oAppRef: oEditors,
elPlaceHolder: "smart",
sSkinURI: "/client/smarteditor2-2.8.2.3/SmartEditor2Skin.html",
htParams: {
bUseToolbar: true, // 툴바 사용 여부 (true:사용/ false:사용하지 않음)
bSkipXssFilter: true,
bUseVerticalResizer: true,
bUseModeChanger: true
},
fCreator: "createSEditor2"
});
}
};
</script>