kcscDev/egovframe-template-simple-r.../src/pages/admin/contents/survey/QuestionModal.jsx

141 lines
4.0 KiB
React
Raw Normal View History

2024-03-06 09:12:30 +00:00
import React, {useEffect, useState} from "react";
import Modal from "react-bootstrap/Modal";
import Row from "react-bootstrap/Row";
import Col from "react-bootstrap/Col";
2024-03-06 10:37:09 +00:00
import Form from "react-bootstrap/Form";
import Table from "react-bootstrap/Table";
2024-03-06 09:12:30 +00:00
import * as EgovNet from "api/egovFetch";
function QuestionModal({svySeq}){
const [qtTag, setQtTag] = useState([]);
const [itemTag, setItemTag] = useState([]);
function getSurveyQt(){
EgovNet.requestFetch(
'/admin/survey/edit-qt?svySeq='+svySeq,
{
method: "GET"
},
(resp) => {
const temp = [];
resp.result.qtList.forEach(function (qt, index){
temp.push(
2024-03-06 10:37:09 +00:00
<tr>
<td className={"clickable"} onClick={()=>selectQt(qt.itemList)}>
<Form.Control type={"text"} defaultValue={qt.qtTitle}/>
</td>
</tr>
2024-03-06 09:12:30 +00:00
)
})
setQtTag(temp);
},
function (resp) {
console.log("err response : ", resp);
}
);
}
function selectQt(itemList){
const temp = [];
itemList.forEach(function (item, index){
temp.push(
2024-03-06 10:37:09 +00:00
<tr>
<td>
<Form.Control type={"text"} defaultValue={item.itemNm}/>
</td>
</tr>
2024-03-06 09:12:30 +00:00
)
})
setItemTag(temp);
}
2024-03-06 10:37:09 +00:00
function addQt(){
const temp = [...qtTag]
temp.push(
<tr>
<td>
<Form.Control type={"text"}/>
</td>
</tr>
)
setQtTag(temp)
}
function addItem(){
const temp = [...itemTag]
temp.push(
<tr>
<td>
<Form.Control type={"text"}/>
</td>
</tr>
)
setItemTag(temp)
}
2024-03-06 09:12:30 +00:00
function editSurveyQt(e){
}
useEffect(() => {
getSurveyQt()
}, []);
return (
<>
<Modal.Header closeButton>
<Modal.Title>질문관리</Modal.Title>
</Modal.Header>
<Modal.Body>
<Row>
<Col xs={6}>
2024-03-06 10:37:09 +00:00
<Table>
<thead>
<tr>
<th>질문</th>
</tr>
</thead>
<tbody>
{qtTag}
</tbody>
<tfoot>
<tr>
<td>
<button className={"btn btn_blue_h31"} onClick={addQt}>추가</button>
</td>
</tr>
</tfoot>
</Table>
2024-03-06 09:12:30 +00:00
</Col>
<Col xs={6}>
2024-03-06 10:37:09 +00:00
<Table>
<thead>
<tr>
<th>보기</th>
</tr>
</thead>
<tbody>
{itemTag}
</tbody>
<tfoot>
<tr>
<td>
<button className={"btn btn_blue_h31"} onClick={addItem}>추가</button>
</td>
</tr>
</tfoot>
</Table>
2024-03-06 09:12:30 +00:00
</Col>
</Row>
</Modal.Body>
<Modal.Footer>
<button type="button" className={"btn btn_blue_h31 px-3"}>저장</button>
</Modal.Footer>
</>
);
}
export default QuestionModal;