설문관리 작업완료.
parent
bfef1ce1a8
commit
57d669cbdc
|
|
@ -5,6 +5,7 @@ import Col from "react-bootstrap/Col";
|
||||||
import Form from "react-bootstrap/Form";
|
import Form from "react-bootstrap/Form";
|
||||||
import Table from "react-bootstrap/Table";
|
import Table from "react-bootstrap/Table";
|
||||||
import * as EgovNet from "api/egovFetch";
|
import * as EgovNet from "api/egovFetch";
|
||||||
|
import CODE from "../../../../constants/code";
|
||||||
|
|
||||||
function QuestionModal({svySeq}){
|
function QuestionModal({svySeq}){
|
||||||
|
|
||||||
|
|
@ -44,12 +45,54 @@ function QuestionModal({svySeq}){
|
||||||
setTempSeq(tempSeq+1);
|
setTempSeq(tempSeq+1);
|
||||||
}
|
}
|
||||||
|
|
||||||
function addItem(){
|
function qtOptionChange(target, value){
|
||||||
|
const temp = {...selectedQt}
|
||||||
|
temp[target] = value;
|
||||||
|
setSelectedQt(temp);
|
||||||
|
}
|
||||||
|
|
||||||
|
function addItem(){
|
||||||
|
const temp = {...selectedQt}
|
||||||
|
temp.itemList.push({
|
||||||
|
qtItemSeq: null,
|
||||||
|
qtSeq:null,
|
||||||
|
itemNm: null,
|
||||||
|
questionYn:null
|
||||||
|
})
|
||||||
|
setSelectedQt(temp);
|
||||||
|
}
|
||||||
|
|
||||||
|
function removeQt(index){
|
||||||
|
const temp = [...qtList]
|
||||||
|
temp.splice(index, 1);
|
||||||
|
setQtList(temp);
|
||||||
|
setSelectedQt(null)
|
||||||
|
}
|
||||||
|
|
||||||
|
function removeItem(index){
|
||||||
|
const temp = {...selectedQt}
|
||||||
|
temp.itemList.splice(index, 1)
|
||||||
|
setSelectedQt(temp)
|
||||||
}
|
}
|
||||||
|
|
||||||
function editSurveyQt(e){
|
function editSurveyQt(e){
|
||||||
|
EgovNet.requestFetch(
|
||||||
|
'/admin/survey/info-qt',
|
||||||
|
{
|
||||||
|
method: "PUT",
|
||||||
|
headers: {
|
||||||
|
'Content-type': 'application/json'
|
||||||
|
},
|
||||||
|
body: JSON.stringify(qtList)
|
||||||
|
},
|
||||||
|
(resp) => {
|
||||||
|
if (Number(resp.resultCode) === Number(CODE.RCV_SUCCESS)) {
|
||||||
|
alert("저장되었습니다.")
|
||||||
|
}else{
|
||||||
|
alert(resp.resultMessage)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|
@ -60,16 +103,20 @@ function QuestionModal({svySeq}){
|
||||||
const tempQt = [...qtList];
|
const tempQt = [...qtList];
|
||||||
tempQt.forEach(function (qt, index){
|
tempQt.forEach(function (qt, index){
|
||||||
if(qt.qtSeq === null){
|
if(qt.qtSeq === null){
|
||||||
if(qt.tempSeq === selectedQt.tempSeq){
|
if(qt.tempSeq === selectedQt?.tempSeq){
|
||||||
qt = selectedQt;
|
tempQt[index] = selectedQt;
|
||||||
}
|
}
|
||||||
}else if(qt.qtSeq === selectedQt.qtSeq){
|
}else if(qt.qtSeq === selectedQt?.qtSeq){
|
||||||
qt = selectedQt;
|
tempQt[index] = selectedQt;
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
setQtList(tempQt);
|
setQtList(tempQt);
|
||||||
}, [selectedQt]);
|
}, [selectedQt]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
|
||||||
|
}, [qtList]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Modal.Header closeButton>
|
<Modal.Header closeButton>
|
||||||
|
|
@ -79,17 +126,29 @@ function QuestionModal({svySeq}){
|
||||||
<Row>
|
<Row>
|
||||||
<Col xs={5}>
|
<Col xs={5}>
|
||||||
<Table>
|
<Table>
|
||||||
|
<colgroup>
|
||||||
|
<col/>
|
||||||
|
<col className={"w_100"}/>
|
||||||
|
</colgroup>
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>질문</th>
|
<th>질문</th>
|
||||||
|
<th>삭제</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{qtList.map(qt=>{
|
{qtList.map((qt, index)=>{
|
||||||
return (
|
return (
|
||||||
<tr>
|
<tr onClick={()=>setSelectedQt({...qt})}>
|
||||||
<td>
|
<td>
|
||||||
<Form.Control type={"text"} defaultValue={qt.qtTitle} onClick={()=>{setSelectedQt(qt)}}/>
|
<Form.Control type={"text"} defaultValue={qt.qtTitle} value={qt.qtTitle}
|
||||||
|
onChange={(e)=>{
|
||||||
|
qt.qtTitle = e.target.value
|
||||||
|
setSelectedQt({...qt})
|
||||||
|
}} />
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<button className={"btn btn_red_h31"} onClick={()=>removeQt(index)}>삭제</button>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
);
|
);
|
||||||
|
|
@ -97,7 +156,7 @@ function QuestionModal({svySeq}){
|
||||||
</tbody>
|
</tbody>
|
||||||
<tfoot>
|
<tfoot>
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td colSpan={2}>
|
||||||
<button className={"btn btn_blue_h31"} onClick={addQt}>추가</button>
|
<button className={"btn btn_blue_h31"} onClick={addQt}>추가</button>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
@ -110,10 +169,38 @@ function QuestionModal({svySeq}){
|
||||||
질문유형
|
질문유형
|
||||||
</Form.Label>
|
</Form.Label>
|
||||||
<Col sm={9} key={`inline-radio`} className={'my-auto'}>
|
<Col sm={9} key={`inline-radio`} className={'my-auto'}>
|
||||||
<Form.Check inline label="체크박스" name="qtType" type={'radio'} value={1} checked={selectedQt?.qtType === 1} onClick={()=>{setSelectedQt({...selectedQt, qtType:1})}}/>
|
<Form.Check inline label="체크박스" name="qtType" type={'radio'} value={1}
|
||||||
<Form.Check inline label="라디오버튼" name="qtType" type={'radio'} value={2} checked={selectedQt?.qtType === 2} onClick={()=>{setSelectedQt({...selectedQt, qtType:2})}}/>
|
checked={selectedQt?.qtType === 1} defaultChecked={selectedQt?.qtType === 1}
|
||||||
<Form.Check inline label="직접입력" name="qtType" type={'radio'} value={3} checked={selectedQt?.qtType === 3} onClick={()=>{setSelectedQt({...selectedQt, qtType:3})}}/>
|
onClick={(e)=>{
|
||||||
<Form.Check inline label="이용자만족도" name="qtType" type={'radio'} value={4} checked={selectedQt?.qtType === 4} onClick={()=>{setSelectedQt({...selectedQt, qtType:4})}}/>
|
qtOptionChange("qtType", Number(e.target.value));
|
||||||
|
}}/>
|
||||||
|
<Form.Check inline label="라디오버튼" name="qtType" type={'radio'} value={2}
|
||||||
|
checked={selectedQt?.qtType === 2} defaultChecked={selectedQt?.qtType === 2}
|
||||||
|
onClick={(e)=>{
|
||||||
|
qtOptionChange("qtType", Number(e.target.value));
|
||||||
|
}}/>
|
||||||
|
<Form.Check inline label="직접입력" name="qtType" type={'radio'} value={3}
|
||||||
|
checked={selectedQt?.qtType === 3} defaultChecked={selectedQt?.qtType === 3}
|
||||||
|
onClick={(e)=>{
|
||||||
|
qtOptionChange("qtType", Number(e.target.value));
|
||||||
|
}}/>
|
||||||
|
<Form.Check inline label="이용자만족도" name="qtType" type={'radio'} value={4}
|
||||||
|
checked={selectedQt?.qtType === 4} defaultChecked={selectedQt?.qtType === 4}
|
||||||
|
onClick={(e)=>{
|
||||||
|
qtOptionChange("qtType", Number(e.target.value));
|
||||||
|
}}/>
|
||||||
|
</Col>
|
||||||
|
</Form.Group>
|
||||||
|
<Form.Group as={Row}>
|
||||||
|
<Form.Label column sm={3}>
|
||||||
|
설명
|
||||||
|
</Form.Label>
|
||||||
|
<Col sm={9}>
|
||||||
|
<Form.Control as={"textarea"} rows={3} name="qtDesc"
|
||||||
|
defaultValue={selectedQt?.qtDesc?selectedQt?.qtDesc:''} value={selectedQt?.qtDesc?selectedQt?.qtDesc:''}
|
||||||
|
onChange={(e)=>{
|
||||||
|
qtOptionChange("qtDesc", e.target.value);
|
||||||
|
}}/>
|
||||||
</Col>
|
</Col>
|
||||||
</Form.Group>
|
</Form.Group>
|
||||||
<Form.Group as={Row} className={`mb-3 ${selectedQt?.qtType!==1?'d-none':''}`}>
|
<Form.Group as={Row} className={`mb-3 ${selectedQt?.qtType!==1?'d-none':''}`}>
|
||||||
|
|
@ -121,19 +208,32 @@ function QuestionModal({svySeq}){
|
||||||
최대 선택 개수
|
최대 선택 개수
|
||||||
</Form.Label>
|
</Form.Label>
|
||||||
<Col sm={3}>
|
<Col sm={3}>
|
||||||
<Form.Control type="text" name="maxNo" defaultValue={selectedQt?.maxNo} onChange={(e)=>{setSelectedQt({...selectedQt, maxNo:e.target.value})}}/>
|
<Form.Control type="text" name="maxNo"
|
||||||
|
defaultValue={selectedQt?.maxNo} value={selectedQt?.maxNo}
|
||||||
|
onChange={(e)=>{
|
||||||
|
qtOptionChange("maxNo", e.target.value);
|
||||||
|
}}/>
|
||||||
</Col>
|
</Col>
|
||||||
<Form.Label column sm={'auto'}>
|
<Form.Label column sm={'auto'}>
|
||||||
기타 여부
|
기타 여부
|
||||||
</Form.Label>
|
</Form.Label>
|
||||||
<Col sm={3} className={'my-auto'}>
|
<Col sm={3} className={'my-auto'}>
|
||||||
<Form.Check type="checkbox" name="etcYn" checked={selectedQt?.etcYn==='Y'} onClick={(e)=>{setSelectedQt({...selectedQt, etcYn:e.target.checked?'Y':'N'})}}/>
|
<Form.Check type="checkbox" name="etcYn"
|
||||||
|
defaultChecked={selectedQt?.etcYn==='Y'} checked={selectedQt?.etcYn==='Y'}
|
||||||
|
onClick={(e)=>{
|
||||||
|
qtOptionChange("etcYn", e.target.checked?'Y':'N');
|
||||||
|
}}/>
|
||||||
</Col>
|
</Col>
|
||||||
</Form.Group>
|
</Form.Group>
|
||||||
<Table>
|
<Table className={`mb-3 ${selectedQt?.qtType===3?'d-none':''}`}>
|
||||||
|
<colgroup>
|
||||||
|
<col/>
|
||||||
|
<col className={"w_100"}/>
|
||||||
|
</colgroup>
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>보기</th>
|
<th>보기</th>
|
||||||
|
<th>삭제</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
|
|
@ -148,13 +248,16 @@ function QuestionModal({svySeq}){
|
||||||
setSelectedQt(qt);
|
setSelectedQt(qt);
|
||||||
}}/>
|
}}/>
|
||||||
</td>
|
</td>
|
||||||
|
<td>
|
||||||
|
<button className={"btn btn_red_h31"} onClick={()=>removeItem(index)}>삭제</button>
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
</tbody>
|
</tbody>
|
||||||
<tfoot>
|
<tfoot>
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td colSpan={2}>
|
||||||
<button className={"btn btn_blue_h31"} onClick={addItem}>추가</button>
|
<button className={"btn btn_blue_h31"} onClick={addItem}>추가</button>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
@ -164,7 +267,7 @@ function QuestionModal({svySeq}){
|
||||||
</Row>
|
</Row>
|
||||||
</Modal.Body>
|
</Modal.Body>
|
||||||
<Modal.Footer>
|
<Modal.Footer>
|
||||||
<button type="button" className={"btn btn_blue_h31 px-3"}>저장</button>
|
<button type="button" className={"btn btn_blue_h31 px-3"} onClick={editSurveyQt}>저장</button>
|
||||||
</Modal.Footer>
|
</Modal.Footer>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package com.dbnt.kcscbackend.admin.contents.survey;
|
package com.dbnt.kcscbackend.admin.contents.survey;
|
||||||
|
|
||||||
import com.dbnt.kcscbackend.admin.contents.survey.entity.TnSurvey;
|
import com.dbnt.kcscbackend.admin.contents.survey.entity.TnSurvey;
|
||||||
|
import com.dbnt.kcscbackend.admin.contents.survey.entity.TnSurveyQt;
|
||||||
import com.dbnt.kcscbackend.admin.contents.survey.service.AdminSurveyService;
|
import com.dbnt.kcscbackend.admin.contents.survey.service.AdminSurveyService;
|
||||||
import com.dbnt.kcscbackend.auth.entity.LoginVO;
|
import com.dbnt.kcscbackend.auth.entity.LoginVO;
|
||||||
import com.dbnt.kcscbackend.config.common.ResponseCode;
|
import com.dbnt.kcscbackend.config.common.ResponseCode;
|
||||||
|
|
@ -18,6 +19,7 @@ import org.springframework.web.bind.annotation.RestController;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
|
|
@ -75,7 +77,7 @@ public class AdminSurveyController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(method = RequestMethod.GET, value = "/info-qt")
|
@RequestMapping(method = RequestMethod.GET, value = "/info-qt")
|
||||||
public ResultVO surveyEditQt(TnSurvey survey) throws Exception{
|
public ResultVO surveyQt(TnSurvey survey) throws Exception{
|
||||||
|
|
||||||
ResultVO resultVO = new ResultVO();
|
ResultVO resultVO = new ResultVO();
|
||||||
Map<String, Object> resultMap = new HashMap<>();
|
Map<String, Object> resultMap = new HashMap<>();
|
||||||
|
|
@ -83,4 +85,15 @@ public class AdminSurveyController {
|
||||||
resultVO.setResult(resultMap);
|
resultVO.setResult(resultMap);
|
||||||
return resultVO;
|
return resultVO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@RequestMapping(method = RequestMethod.PUT, value = "/info-qt")
|
||||||
|
public ResultVO surveyQtEdit(@RequestBody List<TnSurveyQt> qtList, @AuthenticationPrincipal LoginVO user) throws Exception{
|
||||||
|
ResultVO resultVO = new ResultVO();
|
||||||
|
|
||||||
|
adminSurveyService.insertSurveyQt(qtList, user.getId());
|
||||||
|
resultVO.setResultCode(ResponseCode.SUCCESS.getCode());
|
||||||
|
resultVO.setResultMessage("저장 되었습니다.");
|
||||||
|
|
||||||
|
return resultVO;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,4 +7,5 @@ import java.util.List;
|
||||||
|
|
||||||
public interface TnSurveyQtItemRepository extends JpaRepository<TnSurveyQtItem, Integer> {
|
public interface TnSurveyQtItemRepository extends JpaRepository<TnSurveyQtItem, Integer> {
|
||||||
List<TnSurveyQtItem> findByQtSeqInOrderByQtItemSeq(List<Integer> qtSeqList);
|
List<TnSurveyQtItem> findByQtSeqInOrderByQtItemSeq(List<Integer> qtSeqList);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,4 +7,6 @@ import java.util.List;
|
||||||
|
|
||||||
public interface TnSurveyQtRepository extends JpaRepository<TnSurveyQt, Integer> {
|
public interface TnSurveyQtRepository extends JpaRepository<TnSurveyQt, Integer> {
|
||||||
List<TnSurveyQt> findBySvySeqOrderByQtSeq(Integer svySeq);
|
List<TnSurveyQt> findBySvySeqOrderByQtSeq(Integer svySeq);
|
||||||
|
|
||||||
|
void deleteBySvySeq(Integer svySeq);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -77,4 +77,20 @@ public class AdminSurveyService {
|
||||||
public void deleteSurvey(Integer svySeq) {
|
public void deleteSurvey(Integer svySeq) {
|
||||||
surveyRepository.deleteById(svySeq);
|
surveyRepository.deleteById(svySeq);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
public void insertSurveyQt(List<TnSurveyQt> qtList, String id) {
|
||||||
|
qtRepository.deleteBySvySeq(qtList.get(0).getSvySeq());
|
||||||
|
for(TnSurveyQt qt: qtList){
|
||||||
|
qt.setQtSeq(null);
|
||||||
|
}
|
||||||
|
qtRepository.saveAll(qtList);
|
||||||
|
for(TnSurveyQt qt: qtList){
|
||||||
|
for(TnSurveyQtItem item: qt.getItemList()){
|
||||||
|
item.setQtSeq(qt.getQtSeq());
|
||||||
|
}
|
||||||
|
itemRepository.saveAll(qt.getItemList());
|
||||||
|
}
|
||||||
|
System.out.println();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue