diff --git a/egovframe-template-simple-react-contribution/src/components/file/AttachFile.jsx b/egovframe-template-simple-react-contribution/src/components/file/AttachFile.jsx index 94e1e21..d9f4915 100644 --- a/egovframe-template-simple-react-contribution/src/components/file/AttachFile.jsx +++ b/egovframe-template-simple-react-contribution/src/components/file/AttachFile.jsx @@ -1,9 +1,11 @@ import React, { useState, useEffect } from 'react'; +import Button from '@mui/material/Button'; import AttachFileIcon from '@mui/icons-material/AttachFile'; import IconButton from '@mui/material/IconButton'; import DeleteIcon from '@mui/icons-material/Delete'; import styled from "styled-components"; import FileDragDrop from "./FileDragDrop"; +import * as File from "utils/file"; const StyledDiv = styled.div` label { @@ -14,7 +16,7 @@ const StyledDiv = styled.div` border-radius: 6px; & > div { height: 100%; - line-height: 37px; + line-height: auto; padding: 20px; color: #999999; } @@ -31,7 +33,6 @@ function AttachFile(props) { useEffect(function () { const labelEle = document.querySelectorAll("label[for='preDataFile']")[0]; - console.log(labelEle); // NodeList(3) [li, li, li] // event const onClickLabel = (e) => { @@ -43,15 +44,16 @@ function AttachFile(props) { e.preventDefault(); return false; } else { + if( oldTagName === 'path' || oldTagName === 'svg' || oldTagName === 'button' ) { oldTagName = undefined; - e.preventDefault(); + e.preventDefault(); return false; - } + } } } @@ -129,14 +131,12 @@ function AttachFile(props) { } Object.keys(files).forEach(function(key, index) { - //console.log(key, props.files[key]); if( typeof files[key].name === 'undefined' ) { return; } files[key].index=nNewIndex++; items.push( files[key] ); }); - console.log('%o\n%o', files, items); setFileItem(items); props.setFiles(items); }; @@ -144,6 +144,7 @@ function AttachFile(props) { const onClickDeleteItem = (e, targetEle) => { + const dataIndex = Number(targetEle.getAttribute('data-index')); let items = []; @@ -157,7 +158,39 @@ function AttachFile(props) { setFileItem(items); props.setFiles(items); - } + }; + + const onClickFile = (e, item) => { + e = e || window.event; + const target = e.target || e.srcElement; + const dataSeq = target.getAttribute('data-seq'); + if( dataSeq ) { + // server로 부터 download 요청 + const fileSeq = Number(dataSeq); + File.download(fileSeq); + } else { + //현재 첨부된 file 다운로드 + const file = item; + let fr = new FileReader(); + fr.readAsDataURL(file); + + var blob = new Blob([file], { type: "application/pdf" }); + + var objectURL = window.URL.createObjectURL(blob); + + if (navigator.appVersion.toString().indexOf('.NET') > 0) { + window.navigator.msSaveOrOpenBlob(blob, item.name); + } else { + var link = document.createElement('a'); + link.href = objectURL; + link.download = item.name; + document.body.appendChild(link); + link.click(); + link.remove(); + } + } + + }; return ( @@ -179,11 +212,11 @@ function AttachFile(props) { fileItem.map((item) => ( { e = e || window.event; const target = e.target || e.srcElement; - - console.log('%o', target); + const tagName = String(target.tagName).toLowerCase(); // target 보정 @@ -199,11 +232,20 @@ function AttachFile(props) { > - {item.name}
+ +
)) : - 파일을 마우스로 끌어놓으세요. + 여기를 누르시거나 파일을 마우스로 끌어놓으세요. } diff --git a/egovframe-template-simple-react-contribution/src/pages/admin/committee/Schedules.jsx b/egovframe-template-simple-react-contribution/src/pages/admin/committee/Schedules.jsx index 1d07793..01a4b16 100644 --- a/egovframe-template-simple-react-contribution/src/pages/admin/committee/Schedules.jsx +++ b/egovframe-template-simple-react-contribution/src/pages/admin/committee/Schedules.jsx @@ -3,6 +3,8 @@ import React, { useState, useEffect, useCallback } from 'react'; import { Link, useLocation } from 'react-router-dom'; import styled from "styled-components"; +import CircularProgress from '@mui/material/CircularProgress'; +import Box from '@mui/material/Box'; import * as EgovNet from 'api/egovFetch'; @@ -62,7 +64,7 @@ function Schedules(props) { const [searchCondition, setSearchCondition] = useState(location.state?.searchCondition || { schdulSe: '', year: TODAY.getFullYear(), month: TODAY.getMonth(), date: TODAY.getDate() }); const [calendarTag, setCalendarTag] = useState([]); - const [scheduleList, setScheduleList] = useState([]); + const [scheduleList, setScheduleList] = useState(); const innerConsole = (...args) => { console.log(...args); @@ -189,7 +191,7 @@ function Schedules(props) { if (day !== 0) {//당월 일별 구현 let sDate = day.toString().length === 1 ? "0" + day.toString() : day.toString(); let iUseDate = Number(mutsUseYearMonth + sDate); - if (scheduleList.length > 0) {//일정 있는 경우 + if (scheduleList && scheduleList.length > 0) {//일정 있는 경우 return ( 금 토 - - - {true && calendarTag} - + + { + typeof scheduleList === 'undefined' + ? + + + + + + + + + + : + + {calendarTag} + + }
diff --git a/egovframe-template-simple-react-contribution/src/pages/admin/contents/PopUp.jsx b/egovframe-template-simple-react-contribution/src/pages/admin/contents/PopUp.jsx index 4dcc0fb..b85476f 100644 --- a/egovframe-template-simple-react-contribution/src/pages/admin/contents/PopUp.jsx +++ b/egovframe-template-simple-react-contribution/src/pages/admin/contents/PopUp.jsx @@ -1,6 +1,7 @@ import React, { useState, useEffect } from 'react'; import { Link, useLocation, useNavigate } from 'react-router-dom'; import Switch from '@mui/material/Switch'; +import LinearProgress from '@mui/material/LinearProgress'; import * as EgovNet from 'api/egovFetch'; import URL from 'constants/url'; @@ -54,7 +55,7 @@ function PopUp(props) { const location = useLocation(); const navigate = useNavigate(); - const [listPopup, setListPopup] = useState([]); + const [listPopup, setListPopup] = useState(); const [searchCondition, setSearchCondition] = useState(location.state?.searchCondition || { pageIndex: 1, searchCnd: '0', searchWrd: '' }); const [paginationInfo, setPaginationInfo] = useState({}); @@ -152,10 +153,13 @@ function PopUp(props) {
{/* */} - {listPopup.length === 0 && + {typeof listPopup === 'undefined' && +

+ } + {listPopup && listPopup.length === 0 &&

검색된 결과가 없습니다.

} - {listPopup.map((it)=>( + {listPopup && listPopup.map((it)=>(
{it.number}
{it.popupTitle}
diff --git a/egovframe-template-simple-react-contribution/src/pages/admin/contents/PopUp/PopupEditor.jsx b/egovframe-template-simple-react-contribution/src/pages/admin/contents/PopUp/PopupEditor.jsx index efb1d77..953f5a9 100644 --- a/egovframe-template-simple-react-contribution/src/pages/admin/contents/PopUp/PopupEditor.jsx +++ b/egovframe-template-simple-react-contribution/src/pages/admin/contents/PopUp/PopupEditor.jsx @@ -1,6 +1,7 @@ import React, { useState, useEffect } from 'react'; import { Link, useLocation, useNavigate } from 'react-router-dom'; import DatePicker from "react-datepicker"; +import LinearProgress from '@mui/material/LinearProgress'; import AttachFile from "../../../../components/file/AttachFile"; import RichTextEditor from "../../../../components/editor/RichTextEditor"; import AlertDialogSlide from "../../../../components/alert/AlertDialogSlide"; @@ -164,15 +165,17 @@ function PopupEditor(props) { formData.append("contents", text); //첨부파일 - //formData.append("files", files); - for(let i=0; i { const deleteBoardURL = `/contents/api/popup-manage/${popupId}`; @@ -235,6 +238,27 @@ function PopupEditor(props) { setConfirm({...confirm, open: true, body: "삭제하시겠습니까?", yesCallback: requestTask}); } + + // 첨부된 file을 삭제하는 요청 + const deleteFile = (fileSeq) => { + const deleteFileURL = `/contents/api/popup-manage/file/${fileSeq}`; + + const requestOptions = { + method: "DELETE", + headers: { + 'Content-type': 'application/json', + } + } + + EgovNet.requestFetch(deleteFileURL, + requestOptions, + (resp) => { + } + ); + } + + + const onClickList = (e) => { const requestTask = () => { @@ -315,6 +339,7 @@ function PopupEditor(props) {
필수
+ {modeInfo.mode === CODE.MODE_MODIFY && typeof popupDetail.title === 'undefined' && } setPopupDetail({ ...popupDetail, title: e.target.value })} @@ -364,7 +389,7 @@ function PopupEditor(props) {
첨부파일
- +
@@ -372,7 +397,13 @@ function PopupEditor(props) { {/* */} {/* */} - + {modeInfo.mode === CODE.MODE_MODIFY && typeof text === 'undefined' + ? + + : + + } + {/* */} {/* */} 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 69a13ca..df5d913 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,6 +1,6 @@ import React, { useState, useEffect } from 'react'; import { Link, useLocation, useNavigate } from 'react-router-dom'; -import Switch from '@mui/material/Switch'; +import LinearProgress from '@mui/material/LinearProgress'; import * as EgovNet from 'api/egovFetch'; import URL from 'constants/url'; @@ -67,7 +67,7 @@ function StandardResearch(props) { const location = useLocation(); const navigate = useNavigate(); - const [list, setList] = useState([]); + const [list, setList] = useState(); const [searchCondition, setSearchCondition] = useState(location.state?.searchCondition || { pageIndex: 1, searchCnd: '0', searchWrd: '' }); const [paginationInfo, setPaginationInfo] = useState({}); @@ -167,10 +167,13 @@ function StandardResearch(props) {
{/* */} - {list.length === 0 && + {typeof list === 'undefined' && +

+ } + {list && list.length === 0 &&

검색된 결과가 없습니다.

} - {list.map((it)=>( + {list && list.map((it)=>(
{it.number}
{it.title}
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 index 3cee0f3..fe8e435 100644 --- 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 @@ -1,6 +1,7 @@ import React, { useState, useEffect } from 'react'; import { Link, useLocation, useNavigate } from 'react-router-dom'; import DatePicker from "react-datepicker"; +import LinearProgress from '@mui/material/LinearProgress'; import EgovAttachFile from 'components/EgovAttachFile'; import RichTextEditor from "../../../../components/editor/RichTextEditor"; @@ -45,12 +46,12 @@ function StandardResearchEditor(props) { const location = useLocation(); const [modeInfo, setModeInfo] = useState({ mode: props.mode }); - const [purpose, setPurpose] = useState(""); - const [purposeOriginal, setPurposeOriginal] = useState(""); + const [purpose, setPurpose] = useState(); + const [purposeOriginal, setPurposeOriginal] = useState(); const [content, setContent] = useState(""); - const [contentOriginal, setContentOriginal] = useState(""); + const [contentOriginal, setContentOriginal] = useState(); const [effectContent, setEffectContent] = useState(""); - const [effectContentOriginal, setEffectContentOriginal] = useState(""); + const [effectContentOriginal, setEffectContentOriginal] = useState(); @@ -319,6 +320,7 @@ function StandardResearchEditor(props) {
필수
+ {modeInfo.mode === CODE.MODE_MODIFY && typeof standardResearchDetail.title === 'undefined' && } setStandardResearchDetail({ ...standardResearchDetail, title: e.target.value })} @@ -358,6 +360,7 @@ function StandardResearchEditor(props) {
필수
+ {modeInfo.mode === CODE.MODE_MODIFY && typeof standardResearchDetail.director === 'undefined' && } setStandardResearchDetail({ ...standardResearchDetail, director: e.target.value })} @@ -369,13 +372,34 @@ function StandardResearchEditor(props) { {/* */} - + { + modeInfo.mode === CODE.MODE_MODIFY && typeof purpose === 'undefined' + ? + + : + + } + - + { + modeInfo.mode === CODE.MODE_MODIFY && typeof content === 'undefined' + ? + + : + + } + - + { + modeInfo.mode === CODE.MODE_MODIFY && typeof effectContent === 'undefined' + ? + + : + + } + {/* */} {/* */}