설문관리 작업완료.
parent
bfef1ce1a8
commit
57d669cbdc
|
|
@ -5,6 +5,7 @@ import Col from "react-bootstrap/Col";
|
|||
import Form from "react-bootstrap/Form";
|
||||
import Table from "react-bootstrap/Table";
|
||||
import * as EgovNet from "api/egovFetch";
|
||||
import CODE from "../../../../constants/code";
|
||||
|
||||
function QuestionModal({svySeq}){
|
||||
|
||||
|
|
@ -44,12 +45,54 @@ function QuestionModal({svySeq}){
|
|||
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){
|
||||
|
||||
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(() => {
|
||||
|
|
@ -60,16 +103,20 @@ function QuestionModal({svySeq}){
|
|||
const tempQt = [...qtList];
|
||||
tempQt.forEach(function (qt, index){
|
||||
if(qt.qtSeq === null){
|
||||
if(qt.tempSeq === selectedQt.tempSeq){
|
||||
qt = selectedQt;
|
||||
if(qt.tempSeq === selectedQt?.tempSeq){
|
||||
tempQt[index] = selectedQt;
|
||||
}
|
||||
}else if(qt.qtSeq === selectedQt.qtSeq){
|
||||
qt = selectedQt;
|
||||
}else if(qt.qtSeq === selectedQt?.qtSeq){
|
||||
tempQt[index] = selectedQt;
|
||||
}
|
||||
})
|
||||
setQtList(tempQt);
|
||||
}, [selectedQt]);
|
||||
|
||||
useEffect(() => {
|
||||
|
||||
}, [qtList]);
|
||||
|
||||
return (
|
||||
<>
|
||||
<Modal.Header closeButton>
|
||||
|
|
@ -79,17 +126,29 @@ function QuestionModal({svySeq}){
|
|||
<Row>
|
||||
<Col xs={5}>
|
||||
<Table>
|
||||
<colgroup>
|
||||
<col/>
|
||||
<col className={"w_100"}/>
|
||||
</colgroup>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>질문</th>
|
||||
<th>삭제</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{qtList.map(qt=>{
|
||||
{qtList.map((qt, index)=>{
|
||||
return (
|
||||
<tr>
|
||||
<tr onClick={()=>setSelectedQt({...qt})}>
|
||||
<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>
|
||||
</tr>
|
||||
);
|
||||
|
|
@ -97,7 +156,7 @@ function QuestionModal({svySeq}){
|
|||
</tbody>
|
||||
<tfoot>
|
||||
<tr>
|
||||
<td>
|
||||
<td colSpan={2}>
|
||||
<button className={"btn btn_blue_h31"} onClick={addQt}>추가</button>
|
||||
</td>
|
||||
</tr>
|
||||
|
|
@ -110,10 +169,38 @@ function QuestionModal({svySeq}){
|
|||
질문유형
|
||||
</Form.Label>
|
||||
<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={2} checked={selectedQt?.qtType === 2} onClick={()=>{setSelectedQt({...selectedQt, qtType:2})}}/>
|
||||
<Form.Check inline label="직접입력" name="qtType" type={'radio'} value={3} checked={selectedQt?.qtType === 3} onClick={()=>{setSelectedQt({...selectedQt, qtType:3})}}/>
|
||||
<Form.Check inline label="이용자만족도" name="qtType" type={'radio'} value={4} checked={selectedQt?.qtType === 4} onClick={()=>{setSelectedQt({...selectedQt, qtType:4})}}/>
|
||||
<Form.Check inline label="체크박스" name="qtType" type={'radio'} value={1}
|
||||
checked={selectedQt?.qtType === 1} defaultChecked={selectedQt?.qtType === 1}
|
||||
onClick={(e)=>{
|
||||
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>
|
||||
</Form.Group>
|
||||
<Form.Group as={Row} className={`mb-3 ${selectedQt?.qtType!==1?'d-none':''}`}>
|
||||
|
|
@ -121,19 +208,32 @@ function QuestionModal({svySeq}){
|
|||
최대 선택 개수
|
||||
</Form.Label>
|
||||
<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>
|
||||
<Form.Label column sm={'auto'}>
|
||||
기타 여부
|
||||
</Form.Label>
|
||||
<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>
|
||||
</Form.Group>
|
||||
<Table>
|
||||
<Table className={`mb-3 ${selectedQt?.qtType===3?'d-none':''}`}>
|
||||
<colgroup>
|
||||
<col/>
|
||||
<col className={"w_100"}/>
|
||||
</colgroup>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>보기</th>
|
||||
<th>삭제</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
|
@ -148,13 +248,16 @@ function QuestionModal({svySeq}){
|
|||
setSelectedQt(qt);
|
||||
}}/>
|
||||
</td>
|
||||
<td>
|
||||
<button className={"btn btn_red_h31"} onClick={()=>removeItem(index)}>삭제</button>
|
||||
</td>
|
||||
</tr>
|
||||
);
|
||||
})}
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<tr>
|
||||
<td>
|
||||
<td colSpan={2}>
|
||||
<button className={"btn btn_blue_h31"} onClick={addItem}>추가</button>
|
||||
</td>
|
||||
</tr>
|
||||
|
|
@ -164,7 +267,7 @@ function QuestionModal({svySeq}){
|
|||
</Row>
|
||||
</Modal.Body>
|
||||
<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>
|
||||
</>
|
||||
);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package com.dbnt.kcscbackend.admin.contents.survey;
|
||||
|
||||
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.auth.entity.LoginVO;
|
||||
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.validation.Valid;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@RestController
|
||||
|
|
@ -75,7 +77,7 @@ public class AdminSurveyController {
|
|||
}
|
||||
|
||||
@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();
|
||||
Map<String, Object> resultMap = new HashMap<>();
|
||||
|
|
@ -83,4 +85,15 @@ public class AdminSurveyController {
|
|||
resultVO.setResult(resultMap);
|
||||
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> {
|
||||
List<TnSurveyQtItem> findByQtSeqInOrderByQtItemSeq(List<Integer> qtSeqList);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,4 +7,6 @@ import java.util.List;
|
|||
|
||||
public interface TnSurveyQtRepository extends JpaRepository<TnSurveyQt, Integer> {
|
||||
List<TnSurveyQt> findBySvySeqOrderByQtSeq(Integer svySeq);
|
||||
|
||||
void deleteBySvySeq(Integer svySeq);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -77,4 +77,20 @@ public class AdminSurveyService {
|
|||
public void deleteSurvey(Integer 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