diff --git a/egovframe-template-simple-react-contribution/src/pages/admin/contents/PopUp/PopupWriter.jsx b/egovframe-template-simple-react-contribution/src/pages/admin/contents/PopUp/PopupEditor.jsx
similarity index 99%
rename from egovframe-template-simple-react-contribution/src/pages/admin/contents/PopUp/PopupWriter.jsx
rename to egovframe-template-simple-react-contribution/src/pages/admin/contents/PopUp/PopupEditor.jsx
index 2eba0af..026a33f 100644
--- a/egovframe-template-simple-react-contribution/src/pages/admin/contents/PopUp/PopupWriter.jsx
+++ b/egovframe-template-simple-react-contribution/src/pages/admin/contents/PopUp/PopupEditor.jsx
@@ -28,7 +28,7 @@ const StyledDiv = styled.div`
`;
-function PopupWriter(props) {
+function PopupEditor(props) {
const navigate = useNavigate();
const location = useLocation();
@@ -373,4 +373,4 @@ function PopupWriter(props) {
}
-export default PopupWriter;
\ No newline at end of file
+export default PopupEditor;
\ No newline at end of file
diff --git a/egovframe-template-simple-react-contribution/src/pages/admin/contents/StandardResearch.jsx b/egovframe-template-simple-react-contribution/src/pages/admin/contents/StandardResearch.jsx
index b5f3522..fb24312 100644
--- a/egovframe-template-simple-react-contribution/src/pages/admin/contents/StandardResearch.jsx
+++ b/egovframe-template-simple-react-contribution/src/pages/admin/contents/StandardResearch.jsx
@@ -1,13 +1,85 @@
-import React from 'react';
-import { Link } from 'react-router-dom';
+import React, { useState, useEffect } from 'react';
+import { Link, useLocation, useNavigate } from 'react-router-dom';
+import Switch from '@mui/material/Switch';
+import * as EgovNet from 'api/egovFetch';
import URL from 'constants/url';
+import CODE from 'constants/code';
import { default as EgovLeftNav } from 'components/leftmenu/EgovLeftNavAdmin';
+import EgovPagingPaginationInfo from 'components/EgovPagingPaginationInfo';
+import styled from "styled-components";
+
+const StyledDiv = styled.div`
+ .board_btn_area {
+ margin: 12px 0px;
+ }
+`;
+
+const label = { inputProps: { 'aria-label': '사용여부' } };
+
function StandardResearch(props) {
+ const location = useLocation();
+ const navigate = useNavigate();
+
+ const [list, setList] = useState([]);
+ const [searchCondition, setSearchCondition] = useState(location.state?.searchCondition || { pageIndex: 1, searchCnd: '0', searchWrd: '' });
+ const [paginationInfo, setPaginationInfo] = useState({});
+
+ useEffect(function () {
+ getList(searchCondition);
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ }, []);
+
+ const requestOptions = {
+ method: "GET",
+ headers: {
+ 'Content-type': 'application/json'
+ }
+ }
+
+ const getList = (searchCondition) => {
+
+ EgovNet.requestFetch(`/contents/standard-research/list?page=${searchCondition.pageIndex-1}&size=10&sort=rsSeq,desc`,
+ requestOptions,
+ function (resp) {
+ console.log('%o', resp);
+ setList(resp.result.list);
+ setPaginationInfo({...resp.result.paginationInfo});
+ }
+ );
+
+ }
+
+
+ const onChangeActivationSwitch = (e, popupId) => {
+ const checked = e.target.checked;
+ const requestURL = `/contents/api/popup-manage/activation-switch/${popupId}?checked=${checked}`;
+
+ const requestOptions = {
+ method: "PUT",
+ headers: {
+ 'Content-type': 'application/json',
+ }
+ }
+
+ EgovNet.requestFetch(requestURL,
+ requestOptions,
+ (resp) => {
+ console.log("====>>> Schdule delete= ", resp);
+ if (Number(resp.resultCode) === Number(CODE.RCV_SUCCESS)) {
+ navigate(URL.ADMIN__CONTENTS__POP_UP ,{ replace: true });
+ } else {
+ navigate({pathname: URL.ERROR}, {state: {msg : resp.resultMessage}});
+ }
+
+ }
+ );
+ }
+
const Location = React.memo(function Location() {
return (
@@ -35,11 +107,51 @@ function StandardResearch(props) {
{/* */}
-
-
건설기준연구 관리
-
+
+
+
건설기준연구 관리
+
+ {/* */}
+
+ {/* */}
+
+ {/* */}
+
+
+ 번호
+ 연구명
+ 연구기간
+ 연구책임자
+
+
+ {/* */}
+ {list.length === 0 &&
+
검색된 결과가 없습니다.
+ }
+ {list.map((it)=>(
+
+
{it.id}
+
{it.title}
+
{it.researchStartDate} ~ {it.researchEndDate}
+
{it.director}
+
+ ))}
+
+
+ {/* */}
- 여기에 구현해주세요.
+
+ {/* */}
+ {
+ getList({ ...searchCondition, pageIndex: passedPage })
+ }} />
+ {/* */}
+
+
{/* */}
diff --git a/egovframe-template-simple-react-contribution/src/pages/admin/contents/StandardResearch/StandardResearchEditor.jsx b/egovframe-template-simple-react-contribution/src/pages/admin/contents/StandardResearch/StandardResearchEditor.jsx
new file mode 100644
index 0000000..5e1c30b
--- /dev/null
+++ b/egovframe-template-simple-react-contribution/src/pages/admin/contents/StandardResearch/StandardResearchEditor.jsx
@@ -0,0 +1,376 @@
+import React, { useState, useEffect } from 'react';
+import { Link, useLocation, useNavigate } from 'react-router-dom';
+import DatePicker from "react-datepicker";
+
+import EgovAttachFile from 'components/EgovAttachFile';
+import RichTextEditor from "../../../../components/editor/RichTextEditor";
+import AlertDialogSlide from "../../../../components/alert/AlertDialogSlide";
+import CODE from 'constants/code';
+
+
+import * as EgovNet from 'api/egovFetch';
+import URL from 'constants/url';
+
+import { default as EgovLeftNav } from 'components/leftmenu/EgovLeftNavAdmin';
+
+import styled from "styled-components";
+
+const StyledDiv = styled.div`
+
+ .board_view2 {
+ margin-bottom: 30px;
+ }
+
+ .board_btn_area {
+
+ margin-top: 70px;
+ }
+
+`;
+
+function StandardResearchEditor(props) {
+
+ const navigate = useNavigate();
+ const location = useLocation();
+
+ const [modeInfo, setModeInfo] = useState({ mode: props.mode });
+ const [text, setText] = useState("");
+ const [textOriginal, setTextOriginal] = useState("");
+ const [popupDetail, setPopupDetail] = useState({ startDate: new Date(), endDate: new Date() });
+
+ const [schdulBgndeHH, setSchdulBgndeHH] = useState();
+ const [schdulBgndeMM, setSchdulBgndeMM] = useState();
+ const [schdulEnddeHH, setSchdulEnddeHH] = useState();
+ const [schdulEnddeMM, setSchdulEnddeMM] = useState();
+ const [boardAttachFiles, setBoardAttachFiles] = useState();
+
+ const [confirm, setConfirm] = React.useState();
+
+
+
+ useEffect(function () {
+ initMode();
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ }, []);
+
+ const formValidator = (formData) => {
+ if (formData.get('title') === null || formData.get('title') === "") {
+ alert("제목은 필수 값입니다.");
+ return false;
+ }
+
+ if (formData.get('schdulBgnde') > formData.get('schdulEndde')) {
+ alert("종료일시는 시작일시보다 앞 설 수 없습니다.");
+ return false;
+ }
+ if (formData.get('contents') === null || formData.get('contents') === "") {
+ alert("내용은 필수 값입니다.");
+ return false;
+ }
+ return true;
+ }
+
+ const initMode = () => {
+
+ // props.mode 값이 없으면 에러가 발생한다.
+ switch (props.mode) {
+ case CODE.MODE_CREATE:
+ setModeInfo({
+ ...modeInfo,
+ modeTitle: "등록",
+ method : "POST",
+ editURL: '/contents/api/popup-manage'
+ });
+ break;
+ case CODE.MODE_MODIFY:
+ setModeInfo({
+ ...modeInfo,
+ modeTitle: "수정",
+ method : "PUT",
+ editURL: '/contents/api/popup-manage'
+ });
+ break;
+ default:
+ navigate({pathname: URL.ERROR}, {state: {msg : ""}});
+ }
+ retrieveDetail();
+ }
+
+ const retrieveDetail = () => {
+
+ if (modeInfo.mode === CODE.MODE_CREATE) {// 조회/등록이면 조회 안함
+ return;
+ }
+
+ const retrieveDetailURL = `/contents/api/popup-manage/${location.state?.popupId}`;
+ const requestOptions = {
+ method: "GET",
+ headers: {
+ 'Content-type': 'application/json'
+ }
+ }
+ EgovNet.requestFetch(retrieveDetailURL,
+ requestOptions,
+ function (resp) {
+ let rawDetail = resp.result;
+ //기본값 설정
+ setPopupDetail({
+ ...popupDetail,
+ ...rawDetail,
+ startDate: convertDate(rawDetail.schdulBgnde),
+ endDate: convertDate(rawDetail.schdulEndde),
+ });
+ setText(rawDetail.contents);
+ setTextOriginal(rawDetail.contents);
+ }
+ );
+ }
+
+
+
+ const createPopup = () => {
+ const formData = new FormData();
+
+ for (let key in popupDetail) {
+ if ( key === 'startDate' ) {
+ formData.append(key, getDateFourteenDigit( popupDetail[key] ));
+ } else if( key === 'endDate' ) {
+ formData.append(key, getDateFourteenDigit( popupDetail[key] ));
+ } else {
+ formData.append(key, popupDetail[key]);
+ }
+ }
+
+ //게시글 내용
+ formData.delete("contents");
+ formData.append("contents", text);
+
+ if (formValidator(formData)) {
+ const requestOptions = {
+ method: modeInfo.method,
+ body: formData
+ }
+
+ const requestTask = (callbackParams) => {
+ EgovNet.requestFetch(callbackParams.requestUrl,
+ requestOptions,
+ (resp) => {
+ if (Number(resp.resultCode) === Number(CODE.RCV_SUCCESS)) {
+ if (modeInfo.mode === CODE.MODE_MODIFY) {
+ alert("게시글이 수정 되었습니다.");
+ }
+ navigate({ pathname: URL.ADMIN__CONTENTS__POP_UP });
+ } else {
+ navigate({pathname: URL.ERROR}, {state: {msg : resp.resultMessage}});
+ }
+ }
+ );
+ };
+
+
+ if (modeInfo.mode === CODE.MODE_CREATE) {
+ setConfirm({...confirm, open: true, body: "추가하시겠습니까?", yesCallback: requestTask, yesCallbackParams: {requestUrl:modeInfo.editURL}});
+ } else if (modeInfo.mode === CODE.MODE_MODIFY) {
+ setConfirm({...confirm, open: true, body: "수정하시겠습니까?", yesCallback: requestTask, yesCallbackParams: {requestUrl:`${modeInfo.editURL}/${location.state?.popupId}`}});
+ }
+
+ }
+
+ }
+
+ const onClickDelete = (popupId) => {
+ const deleteBoardURL = `/contents/api/popup-manage/${popupId}`;
+
+ const requestOptions = {
+ method: "DELETE",
+ headers: {
+ 'Content-type': 'application/json',
+ }
+ }
+
+ const requestTask = () => {
+ EgovNet.requestFetch(deleteBoardURL,
+ requestOptions,
+ (resp) => {
+ if (Number(resp.resultCode) === Number(CODE.RCV_SUCCESS)) {
+ alert("삭제 되었습니다.");
+ navigate(URL.ADMIN__CONTENTS__POP_UP ,{ replace: true });
+ } else {
+ navigate({pathname: URL.ERROR}, {state: {msg : resp.resultMessage}});
+ }
+ }
+ );
+ };
+
+ setConfirm({...confirm, open: true, body: "삭제하시겠습니까?", yesCallback: requestTask});
+ }
+
+ const onClickList = (e) => {
+
+ const requestTask = () => {
+ navigate(URL.ADMIN__CONTENTS__POP_UP ,{ replace: true });
+ };
+ if( text !== textOriginal ) {
+ setConfirm({...confirm, open: true, body: "작업 내용을 취소하시겠습니까?", yesCallback: requestTask});
+ } else {
+ requestTask();
+ }
+
+ }
+
+
+ const convertDate = (str) => {
+ let year = str.substring(0, 4);
+ let month = str.substring(4, 6);
+ let date = str.substring(6, 8);
+ let hour = str.substring(8, 10);
+ let minute = str.substring(10, 12);
+ return new Date(year, month - 1, date, hour, minute)
+ }
+ const getDateFourteenDigit = (date) => {
+ return `${getYYYYMMDD(date).toString()}${makeTwoDigit(date.getHours())}${makeTwoDigit(date.getMinutes())}${makeTwoDigit(date.getSeconds())}`;
+ }
+ const getYYYYMMDD = (date) => {
+ return date.getFullYear().toString() + makeTwoDigit(Number(date.getMonth() + 1)) + makeTwoDigit(date.getDate());
+ }
+ const makeTwoDigit = (number) => {
+ return number < 10 ? "0" + number : number.toString();
+ }
+
+
+ const Location = React.memo(function Location() {
+ return (
+
+
+ Home
+ 사이트 관리
+ 컨텐츠 관리
+ 팝업 관리
+
+
+ )
+ });
+
+ return (
+
+
+ {/* */}
+
+ {/* */}
+
+
+ {/* */}
+
+ {/* */}
+
+
+ {/* */}
+
+
+
팝업 추가
+
+ {/* */}
+
+
+ 제목 필수
+
+ setPopupDetail({ ...popupDetail, title: e.target.value })}
+ />
+
+
+
+ 기간필수
+
+
+ {
+ console.log("setStartDate : ", date);
+ setPopupDetail({ ...popupDetail, schdulBgnde: getDateFourteenDigit(date), schdulBgndeYYYMMDD: getYYYYMMDD(date), schdulBgndeHH: date.getHours(), schdulBgndeMM: date.getMinutes(), startDate: date });
+ setSchdulBgndeHH(date.getHours());
+ setSchdulBgndeMM(date.getMinutes());
+ }} />
+
+
+ ~
+
+
+ {
+ console.log("setEndDate: ", date);
+ setPopupDetail({ ...popupDetail, schdulEndde: getDateFourteenDigit(date), schdulEnddeYYYMMDD: getYYYYMMDD(date), schdulEnddeHH: date.getHours(), schdulEnddeMM: date.getMinutes(), endDate: date });
+ setSchdulEnddeHH(date.getHours());
+ setSchdulEnddeMM(date.getMinutes());
+ }
+ } />
+
+
+
+
+
+
{
+ console.log("====>>> Changed attachfile file = ", attachfile);
+ const arrayConcat = { ...popupDetail}; // 기존 단일 파일 업로드에서 다중파일 객체 추가로 변환(아래 for문으로)
+ for ( let i = 0; i < attachfile.length; i++) {
+ arrayConcat[`file_${i}`] = attachfile[i];
+ }
+ setPopupDetail(arrayConcat);
+ }}
+ fnDeleteFile={(deletedFile) => {
+ console.log("====>>> Delete deletedFile = ", deletedFile);
+ setBoardAttachFiles(deletedFile);
+ }}
+ boardFiles={boardAttachFiles}
+ mode={props.mode} />
+
+ {/* */}
+
+ {/* */}
+
+ {/* */}
+
+ {/* */}
+
+
+ createPopup()}
+ > 저장
+ {modeInfo.mode === CODE.MODE_MODIFY &&
+ {
+ onClickDelete(location.state?.popupId);
+ }}>삭제
+ }
+
+
+ 목록
+
+
+ {/* */}
+
+
+
+ {/* */}
+
+
+
+
+ );
+}
+
+
+export default StandardResearchEditor;
\ No newline at end of file
diff --git a/egovframe-template-simple-react-contribution/src/routes/index.jsx b/egovframe-template-simple-react-contribution/src/routes/index.jsx
index 27837f7..a821863 100644
--- a/egovframe-template-simple-react-contribution/src/routes/index.jsx
+++ b/egovframe-template-simple-react-contribution/src/routes/index.jsx
@@ -91,7 +91,7 @@ import AdminStandardsInfoDisclosure from 'pages/admin/standards/InfoDisclosure';
// 관리자 - 컨텐츠 관리
import AdminContentsSurvey from 'pages/admin/contents/Survey'; // 관리자 - 컨텐츠 관리/설문 관리
import AdminContentsPopUp from 'pages/admin/contents/PopUp'; // 관리자 - 컨텐츠 관리/팝업 관리
-import AdminContentsPopUpWriter from 'pages/admin/contents/PopUp/PopupWriter'; // 관리자 - 컨텐츠 관리/팝업 관리/팝업 추가 또는 수정
+import AdminContentsPopUpWriter from 'pages/admin/contents/PopUp/PopupEditor'; // 관리자 - 컨텐츠 관리/팝업 관리/팝업 추가 또는 수정
import AdminContentsStandardResearch from 'pages/admin/contents/StandardResearch'; // 관리자 - 컨텐츠 관리/건설기준연구 관리
import AdminContentsTextMessages from 'pages/admin/contents/TextMessages'; // 관리자 - 컨텐츠 관리/문자 발송