274 lines
11 KiB
Plaintext
274 lines
11 KiB
Plaintext
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
|
|
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
|
|
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
|
|
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
|
|
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
|
|
<%@ taglib prefix="ui" uri="http://www.winbit.kr/ctl/ui"%>
|
|
<%@ taglib prefix="f" uri="/WEB-INF/tlds/f.tld"%>
|
|
<jsp:include page="/WEB-INF/views/comm/Include.jsp"/>
|
|
<%--
|
|
Class Name : temp.jsp
|
|
Description : 반품 환불 상품q&a 모달
|
|
Modification Information
|
|
|
|
수정일 수정자 수정내용
|
|
------- -------- ---------------------------
|
|
2024-04-25 김혜인 최초 생성
|
|
--%>
|
|
<%--
|
|
** 필요값 goodsInnb 상품고유번호
|
|
id = pop의 onclick 함수 적용하기
|
|
모달 div 영역 잡아주기
|
|
등록 스크립트 함수 부모jsp에 붙히기
|
|
--%>
|
|
<!DOCTYPE html>
|
|
<html lang="ko">
|
|
<script>
|
|
$(document).ready(function () {
|
|
fn_collect_event();
|
|
});
|
|
const fn_pop_regist = (goodsInnb) =>{
|
|
if(!goodsInnb){ /*나중에 지울거 (등록 대상 상품고유번호 연결시 삭제)*/
|
|
goodsInnb = '1023';
|
|
}
|
|
$.ajax({
|
|
type: "post",
|
|
data: {
|
|
authDv : "REGIST",
|
|
reqUrl : "refnd",
|
|
reqDv : "refnd",
|
|
bbsId : "goods_qna",
|
|
goodsInnb : goodsInnb,
|
|
regusr : "1325382", /*나중에 지울거*/
|
|
mbrDvCd : "GC" /*나중에 지울거*/
|
|
},
|
|
url: "/sopmal/csc/selectBbscttAuth",
|
|
success: function (data) {
|
|
/*파일중복제거*/
|
|
$(document).find("input[type=file]").remove();
|
|
|
|
/*모달중복제거*/
|
|
fn_close_modal("qna-pop");
|
|
$("#modalDv").html(data);
|
|
|
|
//내용 텍스트 <br>태그 엔터값으로 replace
|
|
const textarea = $("textarea[name=cn]");
|
|
let cn = textarea.attr("placeholder");
|
|
cn = fn_remove_tag(cn);
|
|
textarea.attr("placeholder", cn);
|
|
|
|
$("#qna-pop").modal();
|
|
fn_set_niceSelect_datePicker("#qna-pop");
|
|
}
|
|
});
|
|
}
|
|
/*textarea내 태그 제거 함수*/
|
|
const fn_remove_tag = (cn) => {
|
|
cn = cn.replaceAll(/<br>/ig, '\n');
|
|
cn = cn.replaceAll(/<\/br>/ig, '\n');
|
|
cn = cn.replaceAll(/<br \/>/ig, '\n');
|
|
//내용 내 태그 없애기
|
|
cn = cn.replace(/<\/?[^>]+(>|$)/g, "");
|
|
return cn;
|
|
}
|
|
/*********************************************************
|
|
* 게시글 등록
|
|
*********************************************************/
|
|
const fn_regist_bbsctt = function () {
|
|
let url = '<c:url value="/sopmal/csc/insertBbscttRegist"/>';
|
|
let saveForm = $('#bbsRegForm');
|
|
let formData = new FormData();
|
|
//파일 업로드
|
|
if($("#contact-dropzone").length > 0){
|
|
let myDropzone = Dropzone.forElement("#contact-dropzone");
|
|
myDropzone.files.forEach(function (file) {
|
|
formData.append("files", file);
|
|
});
|
|
}
|
|
$('.checkbox input[type="checkbox"]').each(function () {
|
|
if (!$(this).prop('checked')) {
|
|
fn_ctrl_disable([".checkbox"],);
|
|
}
|
|
});
|
|
//폼 내 input값 append
|
|
saveForm.serializeArray().forEach(function (item) {
|
|
formData.append(item.name, item.value);
|
|
});
|
|
//사용자 등록 시 노출 여부 Y
|
|
formData.append("expsrAt", "Y");
|
|
if($("#slangFlterUseAt").val() === 'Y'){
|
|
let mskgSlang = "<c:out value = "${resultMap.bbsInfo.maskSlang}"/>";
|
|
formData.append("mskgSlang", mskgSlang);
|
|
}
|
|
if (confirm('게시글을 <spring:message code="confirm.common.insert"/>')) {
|
|
$.ajax({
|
|
type: 'post',
|
|
url: url,
|
|
enctype:"multipart/form-data",
|
|
data: formData,
|
|
processData: false,
|
|
contentType: false,
|
|
success: function (result) {
|
|
$("#result-alert").modal();
|
|
},
|
|
error:function(){
|
|
fn_ctrl_disable("",[".checkbox"]);
|
|
}
|
|
});
|
|
}
|
|
}
|
|
|
|
/*************************************************************
|
|
이벤트 함수
|
|
*************************************************************/
|
|
const fn_collect_event = () => {
|
|
//분류 change시 hidden value값 set
|
|
$(document).on('change', '#qesitmNmC', function () {
|
|
$("#qesitmInnb").val("");
|
|
$("#qesitmNm").val("");
|
|
$("#answCn").val("");
|
|
const option = $('option:selected', this);
|
|
const qesitmInnb = $(option).attr('qesitm-innb');
|
|
const answCn = $(option).attr('answ-Cn');
|
|
const qesitmNm = $(option).attr('qesitm-nm');
|
|
if ($(this).val() !== "") {
|
|
$("#qesitmInnb").val(qesitmInnb);
|
|
$("#answCn").val(answCn);
|
|
$("#qesitmNm").val(qesitmNm);
|
|
$("#qesitmAt").val("Y");
|
|
} else {
|
|
$("#qesitmInnb").val("");
|
|
$("#answCn").val("");
|
|
$("#qesitmNm").val("");
|
|
$("#qesitmAt").val("N");
|
|
}
|
|
});
|
|
//추가입력 항목 라디오 'click' 이벤트
|
|
$(document).on('click', '.answRadioC', function () {
|
|
const radio = $(this);
|
|
//추가입력 항목 내용 요소 get
|
|
const answ = radio.closest(".custom-radio-container").find('[name="answCnArr[]"]');
|
|
//추가입력 항목 내용 요소 get
|
|
const qesitmInnb = radio.closest(".custom-radio-container").find('[name="qesitmInnbArr[]"]');
|
|
//라디오 클릭으로 인한 제어 요소 get
|
|
const contrlTarget = radio.closest(".custom-radio-container").find('.answRadio');
|
|
//항목 고유번호 내용 요소 get
|
|
const itmInnb = radio.closest(".custom-radio-container").find('[name="itmInnbArr[]"]');
|
|
//라디오 클릭 시 disabled 비활성
|
|
if (radio.is(":checked")) {
|
|
//답변 내용 초기화
|
|
answ.val("");
|
|
const radioVal = $(radio).attr('itm-cn');
|
|
answ.val(radioVal);
|
|
//항목 내용 set
|
|
qesitmInnb.val("");
|
|
const qesitmInnbVal = $(radio).attr('qesitm-innb');
|
|
qesitmInnb.val(qesitmInnbVal);
|
|
//항목고유번호 내용 set
|
|
itmInnb.val("");
|
|
const itmInnbVal = $(radio).val();
|
|
itmInnb.val(itmInnbVal);
|
|
//라디오 주위 input값 disable false처리
|
|
contrlTarget.each(function () {
|
|
contrlTarget.prop("disabled", false);
|
|
radio.closest(".custom-radio-container").find(".answRadioAt").val("Y");
|
|
});
|
|
} else {
|
|
contrlTarget.each(function () {
|
|
contrlTarget.prop("disabled", true);
|
|
radio.closest(".custom-radio-container").find(".answRadioAt").val("N");
|
|
});
|
|
}
|
|
});
|
|
//추가입력 항목 셀렉트 'change'이벤트
|
|
$(document).on('change', '.answSelectC', function () {
|
|
const select = $(this);
|
|
const answ = select.closest("td").find('[name="answCnArr[]"]');
|
|
const qesitmInnb = select.closest("td").find('[name="qesitmInnbArr[]"]');
|
|
const contrlTarget = select.closest("td").find('.answSelect');
|
|
const option = $('option:selected', this);
|
|
if (select.val() != "") {
|
|
//답변 내용 초기화
|
|
answ.val("");
|
|
const selectVal = $(option).attr('itm-cn');
|
|
answ.val(selectVal);
|
|
//항목 내용 set
|
|
qesitmInnb.val("");
|
|
const qesitmInnbVal = $(option).attr('qesitm-innb');
|
|
qesitmInnb.val(qesitmInnbVal);
|
|
//셀렉트 주위 input값 disable false처리
|
|
contrlTarget.each(function () {
|
|
contrlTarget.prop("disabled", false);
|
|
select.closest("td").find(".answSelectAt").val("Y");
|
|
});
|
|
} else {
|
|
contrlTarget.each(function () {
|
|
contrlTarget.prop("disabled", true);
|
|
select.closest("td").find(".answSelectAt").val("N");
|
|
});
|
|
}
|
|
});
|
|
//추가입력 항목 체크박스 'click'이벤트
|
|
$(document).on('click', '.answChkC', function () {
|
|
const check = $(this);
|
|
const contrlTarget = check.closest("div").find('.answChk');
|
|
var isChecked = $(this).is(":checked");
|
|
//클릭한 체크박스 주위 input값 disable false처리
|
|
contrlTarget.each(function () {
|
|
if (isChecked) {
|
|
$(this).prop("disabled", false);
|
|
} else {
|
|
$(this).prop("disabled", true);
|
|
}
|
|
});
|
|
// 체크된 체크박스가 하나라도 있는지 확인
|
|
let anyChecked = $('.answChkC:checked').length > 0;
|
|
|
|
contrlTarget.each(function () {
|
|
if (anyChecked) {
|
|
check.closest("td").find(".answChkAt").val("Y");
|
|
} else {
|
|
check.closest("td").find(".answChkAt").val("N");
|
|
}
|
|
});
|
|
});
|
|
//추가입력 항목 텍스트 'input'이벤트
|
|
$(document).on('input', '.answTxtC', function () {
|
|
const txt = $(this);
|
|
const contrlTarget = txt.closest(".input-grow-container").find('.answTxt');
|
|
const contrlAt = txt.closest(".input-grow-container").find('.answTxtAt');
|
|
//클릭한 체크박스 주위 input값 disable false처리
|
|
if (txt.val() != "") {
|
|
contrlTarget.each(function () {
|
|
contrlTarget.prop("disabled", false);
|
|
contrlAt.val("Y");
|
|
});
|
|
} else {
|
|
contrlTarget.each(function () {
|
|
contrlTarget.prop("disabled", true);
|
|
contrlAt.val("N");
|
|
});
|
|
}
|
|
});
|
|
//파일 업로드
|
|
$(document).on("change", "#fileUpload", function () {
|
|
addFiles(event, 0);
|
|
});
|
|
//등록 버튼 이벤트
|
|
$(document).on("click", "#regBtn", function () {
|
|
fn_regist_bbsctt();
|
|
});
|
|
//등록 완료 모달 > 확인 버튼 이벤트 (새로고침)
|
|
$(document).on("click","#alertBtn",function(){
|
|
$(".close").each(function (){
|
|
$(this).click();
|
|
});
|
|
});
|
|
}
|
|
</script>
|
|
<button id = "pop" onclick="fn_pop_regist()">pop</button>
|
|
<%--상품q&a등록팝업--%>
|
|
<div id = "modalDv"></div>
|
|
|
|
</html>
|