
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="container">
<div class="page-titleZone flex justify-between align-center align-center">
<p class="main-title flex80">FAQ 등록</p>
<PageNavigation />
</div>
<div class="content-wrap">
<div class="content">
<div class="flex100">
<div class="table-zone">
<table class="form-table">
<colgroup>
<col width="10%" />
<col width="90%" />
</colgroup>
<tbody>
<tr>
<th>질문</th>
<td>
<input
type="text"
class="full-input"
v-model="item.faqQuestion"
/>
</td>
</tr>
<tr>
<th>답변</th>
<td colspan="3">
<textarea
style="height: 130px"
v-model="item.faqAnswer"
></textarea>
</td>
</tr>
</tbody>
</table>
</div>
<div class="flex justify-end">
<button class="blue-btn small-btn" @click="validate">
<span v-if="$isEmpty(faqId)">등록</span>
<span v-else>수정</span>
</button>
<button class="blue-border-btn small-btn" @click="fnMove">
취소
</button>
</div>
</div>
</div>
</div>
</div>
</template>
<script>
import axios from '../../common/defaultAxios.js';
export default {
name: "FaqInsert",
components: {},
data() {
return {
faqId: this.$route.query.faqId,
item: {},
//input type File에서 선택된 파일 목록
tempFile: [],
};
},
mounted() {
this.fnSelectDetail();
},
methods: {
// 상세 조회
fnSelectDetail() {
const vm = this;
// 실행
axios({
url: "/faq",
method: "get",
params: { faqId: this.faqId },
})
.then((response) => {
vm.item = response.data.resultData.vo;
vm.fileList = response.data.resultData.fileList;
})
.catch((error) => {
this.$showAlert(
"에러 발생",
"에러가 발생했습니다. 관리자에게 문의해 주세요."
);
});
},
onEditorChange(v) {
this.item.faqContent = v.html;
},
// 유효성 검사
validate() {
if (this.$isEmpty(this.item.faqQuestion)) {
this.$showAlert("경고", "질문을 입력해주세요.");
return;
}
if (this.$isEmpty(this.item.faqAnswer)) {
this.$showAlert("경고", "답변을 입력해주세요.");
return;
}
// 실행
if (this.$isEmpty(this.faqId)) {
this.fnInsert();
} else {
this.fnUpdate();
}
},
// 등록
fnInsert() {
const vm = this;
// 실행
axios({
url: "/faq",
method: "post",
data: vm.item,
})
.then((response) => {
this.$showAlert("안내", "등록이 완료되었습니다.");
this.$router.push({
path: "/faqView.page",
query: { faqId: response.data.resultData.vo.faqId },
});
})
.catch((error) => {
this.$showAlert(
"에러 발생",
"에러가 발생했습니다. 관리자에게 문의해 주세요."
);
});
},
// 수정
fnUpdate() {
const vm = this;
// 실행
axios({
url: "/faq",
method: "put",
data: vm.item,
})
.then((response) => {
this.$showAlert("안내", "수정이 완료되었습니다.");
this.$router.push({
path: "/faqView.page",
query: { faqId: vm.faqId },
});
})
.catch((error) => {
this.$showAlert(
"에러 발생",
"에러가 발생했습니다. 관리자에게 문의해 주세요."
);
});
},
// 페이지 이동
fnMove() {
if (this.$isEmpty(this.faqId)) {
this.fnMoveToList();
} else {
this.fnMoveToView();
}
},
// 목록
fnMoveToList() {
this.$router.push({
path: "/faqList.page",
});
},
// 취소
fnMoveToView() {
this.$router.push({
path: "/faqView.page",
query: { faqId: this.faqId },
});
},
},
};
</script>