
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 style="width:15%">제목</th>
<td><input type="text" name="" id="techTitle" v-model="post.post_title"></td>
</tr>
<tr>
<th style="width:15%">카테고리</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>
<input type="radio" name="category" id="service" value="service"
style="display:none" v-model="post.ctgry_nm">
<label for="service" class="category">서비스</label>
</div>
</div>
</td>
</tr>
<tr v-if="post.ctgry_nm == 'service'">
<th style="width:15%">기술문서 필수내용</th>
<td>
<div class="atech-grid">
<input type="date" name="" id="date" data-placeholder="배포날짜 (ex : 2023-11-17)" required
aria-required="true" v-model="post.tech_doc_dt">
<input type="text" name="" id="keyword" placeholder="키워드[키워드간의 구분은 쉼표로 할 수 있습니다]"
v-model="post.tech_doc_keyword">
<input style="grid-column: 1 / span 2;" type="Text" name="" id="link_url"
placeholder="링크를 입력해주세요" v-model="post.link_url">
</div>
</td>
</tr>
<tr v-if="post.ctgry_nm != 'service'">
<th>기술문서 필수내용</th>
<td>
<div class="atech-grid">
<input type="text" name="" id="techName" placeholder="기술문서명" v-model="post.tech_doc_nm">
<input type="text" name="" id="version" placeholder="버전"
v-model="post.tech_doc_version">
<input type="date" name="" id="date" placeholder="배포날짜 (ex : 2023-11-17)"
v-model="post.tech_doc_dt">
<input type="text" name="" id="keyword" placeholder="키워드[키워드간의 구분은 쉼표로 할 수 있습니다]"
v-model="post.tech_doc_keyword">
<input style="grid-column: 1 / span 2;" type="Text" name="" id="techContent"
placeholder="주요내용(20자 내외)" v-model="post.tech_doc_main_content">
</div>
</td>
</tr>
<tr v-if="post.ctgry_nm != 'service'">
<th>내용</th>
<td><textarea name="smart" id="smart" style="width:100%"></textarea></td>
</tr>
<tr class="file-zone" v-if="post.ctgry_nm != 'service'">
<th>표지이미지</th>
<td>
<div class="join-sub-input join-imgbox"
@click="openFileInput('thumbnail', 'thumbnailInput')">
<p>595 X 841</p>
<img v-if="thumbnailPreview" :src="thumbnailPreview" />
<input type="file" name="file" id="file" accept="image/*" ref="thumbnailInput"
style="display: none" @change="fileUpload">
</div>
<p class="text-info">※ 표지이미지 크기는 최소크기 595 x 841 픽셀 이상 등록 가능합니다.</p>
</td>
</tr>
<tr class="file-zone" v-if="post.ctgry_nm != 'service'">
<th>첨부파일</th>
<td>
<div class="btn-upload" @click="openFileInput('attach', 'attachInput')">파일 업로드</div>
<input type="file" name="file" id="file" ref="attachInput" style="display: none"
@change="fileUpload">
<ul class="file-list"
v-for="(file, idx) in fileList.filter(file => file.file_ty === 'attach')" :key="idx">
<li> {{ file.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,
notice_yn: 'N',
tech_doc_nm: null,
tech_doc_version: null,
tech_doc_main_content: null,
tech_doc_keyword: null,
tech_doc_dt: null,
},
fileList: [],
filecount: 0,
oEditors: [], // oEditors는 스마트에디터용
fileInputRef: null,
thumbnailPreview: null,
};
},
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].file);
formData.append('file_ty', vm.fileList[i].file_ty);
}
formData.append("post", JSON.stringify(vm.post));
axios({
// url: '/post/postFileInsert.file',
url: '/post/newsFileInsert.file',
method: 'post',
headers: {
'Content-Type': 'multipart/form-data',
},
data: formData
}).then(function (response) {
let result = response.data;
if (result > 0) {
alert("등록을 완료하였습니다.");
vm.postSelectListPage()
} else {
alert("등록 실패, 관리자에게 문의해주세요.");
}
}).catch(function (error) {
console.log("postFileInsert - 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) {
let result = response.data;
if (result > 0) {
alert("등록을 완료하였습니다.");
vm.postSelectListPage()
} else {
alert("등록 실패, 관리자에게 문의해주세요.");
}
}).catch(function (error) {
console.log("noticeInsert - error : ", error);
alert("등록 오류, 관리자에게 문의해주세요.");
});
}
},
//등록 유효성 검사
postInsertCheck: function () {
if (this.post.ctgry_nm !== 'service') {
const oEditors = this.oEditors;
oEditors.getById["smart"].exec("UPDATE_CONTENTS_FIELD", []);
// 스마트에디터의 iframe에 있는 내용을 textarea로.
this.post.post_content = document.getElementById("smart").value;
const hasThumbnail = this.fileList.some(item => item.file_ty === 'thumbnail');
if (COMMON_UTIL.isEmpty(this.post.post_title) === false) {
alert("제목을 입력해주세요.");
document.getElementById("techTitle").focus();
return false;
}
if (COMMON_UTIL.isEmpty(this.post.ctgry_nm) === false) {
alert("카테고리를 선택해주세요.");
document.getElementById("api").focus();
return false;
}
if (COMMON_UTIL.isEmpty(this.post.tech_doc_nm) === false) {
alert("기술문서명을 입력해주세요");
document.getElementById("techName").focus();
return false;
}
if (COMMON_UTIL.isEmpty(this.post.tech_doc_version) === false) {
alert("버전을 입력해주세요");
document.getElementById("version").focus();
return false;
}
if (COMMON_UTIL.isEmpty(this.post.tech_doc_dt) === false) {
alert("배포날짜를 입력해주세요");
document.getElementById("date").focus();
return false;
}
if (COMMON_UTIL.isEmpty(this.post.tech_doc_keyword) === false) {
alert("키워드를 입력해주세요");
document.getElementById("keyword").focus();
return false;
}
if (COMMON_UTIL.isEmpty(this.post.tech_doc_main_content) === false) {
alert("주요내용을 입력해주세요");
document.getElementById("techContent").focus();
return false;
}
if (COMMON_UTIL.isEmpty(this.post.post_content) === false || this.post.post_content === "<p><br></p>") {
alert("내용을 입력해주세요.");
document.getElementById("smart").focus();
return false;
}
if (!hasThumbnail) {
alert("표지이미지를 등록해주세요");
return false;
}
} else {
if (COMMON_UTIL.isEmpty(this.post.post_title) === false) {
alert("제목을 입력해주세요.");
document.getElementById("techTitle").focus();
return false;
}
if (COMMON_UTIL.isEmpty(this.post.ctgry_nm) === false) {
alert("카테고리를 선택해주세요.");
document.getElementById("api").focus();
return false;
}
if (COMMON_UTIL.isEmpty(this.post.tech_doc_dt) === false) {
alert("배포날짜를 입력해주세요");
document.getElementById("date").focus();
return false;
}
if (COMMON_UTIL.isEmpty(this.post.link_url) === false) {
alert("링크를 입력해주세요");
document.getElementById("link_url").focus();
return false;
}
if (!this.post.link_url.startsWith('http://') && !this.post.link_url.startsWith('https://')) {
alert("링크는 http:// 또는 https://로 시작해야합니다.");
document.getElementById("link_url").focus();
return false;
}
}
this.postInsert();
},
//파일업로드
fileUpload: function () {
const MIN_WIDTH = 595;
const MIN_HEIGHT = 841;
const file = this.$refs[this.fileInputRef].files[0];
const fileItem = { file, file_ty: this.file_ty };
if (this.file_ty === 'thumbnail') {
const thumbnailIndex = this.fileList.findIndex(file => file.file_ty === 'thumbnail');
if (thumbnailIndex !== -1) {
this.fileList.splice(thumbnailIndex, 1);
}
let reader = new FileReader();
reader.onload = (e) => {
this.thumbnailPreview = e.target.result;
// 이미지크기 확인
const img = new Image();
img.src = this.thumbnailPreview;
img.onload = () => {
if (img.width < MIN_WIDTH || img.height < MIN_HEIGHT) {
alert("썸네일 이미지 크기는 최소 " + MIN_WIDTH + "픽셀" + "x" + MIN_HEIGHT + "픽셀" + "입니다.");
this.thumbnailPreview = null;
this.$refs.thumbnailInput.value = ''
}
// // Continue adding the thumbnail to the fileList
// this.fileList.push(fileItem);
// this.filecount += 1;
// console.log("file::::", this.fileList);
};
};
reader.readAsDataURL(file);
}
this.fileList.push(fileItem);
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 (file_ty, inputRef) {
this.file_ty = file_ty;
this.fileInputRef = inputRef;
this.$refs[inputRef].click();
},
},
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>