diff --git a/apps/sn/app/oper/floodPre/page.tsx b/apps/sn/app/oper/floodPre/page.tsx index 8fa3e9ae7..98b14cd62 100644 --- a/apps/sn/app/oper/floodPre/page.tsx +++ b/apps/sn/app/oper/floodPre/page.tsx @@ -9,7 +9,7 @@ import { searchData } from '@/components/lib/common/apiHelpers' import { tableHeadlist } from '..' import { handleDownload } from '@/components/lib/utils/fileDownload' import { formatDate } from '@/components/lib/utils/date' -import { postData } from '@/components/lib/api' +import { deleteData, getData, postData } from '@/components/lib/api' const Page = () => { const [fromDate, setFromDate] = useState(new Date()) @@ -21,25 +21,49 @@ const Page = () => { const [fileNm, setFileNm] = useState('') const [atflId, setAtflId] = useState('') const [atflCd, setAtflCd] = useState('') + const [sbmrgPrevntBizSn, setSbmrgPrevntBizSn] = useState('') const [tableData, setTableData] = useState([{}]) + const [curPage, setCurPage] = useState(1) + const fetchData = async () => { + const data = await searchData('v1/sbmrgPrevnt', { + fromRegDt: formatDate(fromDate), + fromMngYr: manageYear, + toMngYr: mngQu, + toRegDt: formatDate(toDate), + atflNm: pjNm, + rgtrNm: usr, + page: curPage - 1, + size: '10' + }) + setTableData(data) + } useEffect(() => { - const fetchData = async () => { - const data = await searchData('v1/sbmrgPrevnt', { - fromRegDt: formatDate(new Date()), - toRegDt: formatDate(new Date()), - page: '0', - size: '10' - }) - setTableData(data) - } + setCurPage(1) fetchData() }, []) const isChckFile = () => { if (fileNm === '' || fileNm === undefined) { alert('파일을 선택해주세요') + return false } handleDownload(`/attach-service/api/v1/download/${atflId}`, fileNm) } + const isDeleteFile = async () => { + if (fileNm === '' || fileNm === undefined) { + alert('삭제할 파일을 선택해주세요') + return false + } + const data = await getData(`/attach-service/api/v1/atfl/attachments/${atflId}`) + if (data) { + const delData = await deleteData(`v1/sbmrgPrevnt/${sbmrgPrevntBizSn}`) + if (delData) { + alert('삭제되었습니다.') + fetchData() + } else { + alert('삭제에 실패했습니다.') + } + } + } const registFile = async (fileNm: string, year: string, quater: string, cd: string, id: string) => { const data = await postData('v1/sbmrgPrevnt', { atflNm: fileNm, @@ -98,7 +122,7 @@ const Page = () => { - + @@ -106,15 +130,13 @@ const Page = () => {

사업정보 등록현황

- +
- { if (index != null) { const fileName = tableData[index]?.fileNm ?? ""; setFileNm(fileName) } }} onPageChange={function (page: number): void { - throw new Error('Function not implemented.') - }}> + { if (index != null) { const fileName = tableData[index]?.fileNm ?? ""; setFileNm(fileName); setSbmrgPrevntBizSn(tableData[index]?.sbmrgPrevntBizSn) } }} onPageChange={async (page:number)=>{setCurPage(page); await fetchData()}}>
- {await registFile(file, year,quater, cd,id) }} /> + { await registFile(file, year, quater, cd, id) }} /> ) diff --git a/apps/sn/app/oper/index.ts b/apps/sn/app/oper/index.ts index 66e8da828..f4ebe7eeb 100644 --- a/apps/sn/app/oper/index.ts +++ b/apps/sn/app/oper/index.ts @@ -1,5 +1,5 @@ export const tableHeadlist = [ - { id: 'no', title: 'NO' }, + { id: 'sbmrgPrevntBizSn', title: '일련번호' }, { id: 'fileNm', title: '파일명' }, { id: 'mngYr', title: '년도' }, { id: 'mngQu', title: '분기' }, diff --git a/apps/sn/app/oper/oldPp/page.tsx b/apps/sn/app/oper/oldPp/page.tsx index 26a20d21e..b9f68bc1a 100644 --- a/apps/sn/app/oper/oldPp/page.tsx +++ b/apps/sn/app/oper/oldPp/page.tsx @@ -9,7 +9,7 @@ import { tableHeadlist } from '..' import { handleDownload } from '@/components/lib/utils/fileDownload' import { searchData } from '@/components/lib/common/apiHelpers' import { formatDate } from '@/components/lib/utils/date' -import { postData } from '@/components/lib/api' +import { deleteData, getData, postData } from '@/components/lib/api' const Page = () => { const [fromDate, setFromDate] = useState(new Date()); const [toDate, setToDate] = useState(new Date()); @@ -20,36 +20,63 @@ const Page = () => { const [fileNm, setFileNm] = useState('') const [atflId, setAtflId] = useState('') const [atflCd, setAtflCd] = useState('') + const [sbmrgPrevntBizSn, setSbmrgPrevntBizSn] = useState('') const [tableData, setTableData] = useState([{}]) - useEffect(() => { - const fetchData = async () => { - const data = await searchData('v1/dcrpPpl', { - fromRegDt: formatDate(new Date()), - toRegDt: formatDate(new Date()), - page: '0', - size: '10' - }) - setTableData(data) - } - fetchData() - }, []) + const [curPage, setCurPage] = useState(1) + // 데이터 조회 + const fetchData = async () => { + const data = await searchData('v1/dcrpPpl', { + fromRegDt: formatDate(fromDate), + fromMngYr: manageYear, + toMngYr: mngQu, + toRegDt: formatDate(toDate), + atflNm: pjNm, + rgtrNm: usr, + page: curPage - 1, + size: '10' + }) + setTableData(data) + } + useEffect(() => { + setCurPage(1) + fetchData() + }, []) + // 파일 다운로드 const isChckFile = () => { if (fileNm === '' || fileNm === undefined) { alert('파일을 선택해주세요') return false } - handleDownload(`/sn/attach-service/api/v1/download/${atflId}}`, fileNm) + handleDownload(`/attach-service/api/v1/download/${atflId}}`, fileNm) return true } - const registFile = async (fileNm:string, year: string, quater: string,cd: string, id: string) => { - const data = await postData('v1/dcrpPpl', { - atflNm: fileNm, - mngYr: year, - mngQu: quater, - atflCd: cd, - atflId: id - }) - if (data.ok) { setAtflId(data.atflId); setAtflCd(data.atflCd) } + // 파일 삭제 + const isDeleteFile = async () => { + if (fileNm === '' || fileNm === undefined) { + alert('삭제할 파일을 선택해주세요') + return false + } + const data = await getData(`/attach-service/api/v1/atfl/attachments/${atflId}`) + if (data) { + const delData = await deleteData(`v1/sbmrgPrevnt/${sbmrgPrevntBizSn}`) + if (delData) { + alert('삭제되었습니다.') + fetchData() + } else { + alert('삭제에 실패했습니다.') + } + } + } + // 파일 등록 + const registFile = async (fileNm: string, year: string, quater: string, cd: string, id: string) => { + const data = await postData('v1/dcrpPpl', { + atflNm: fileNm, + mngYr: year, + mngQu: quater, + atflCd: cd, + atflId: id + }) + if (data.ok) { setAtflId(data.atflId); setAtflCd(data.atflCd) } } return ( @@ -99,7 +126,7 @@ const Page = () => { - + @@ -107,15 +134,13 @@ const Page = () => {

사업정보 등록현황

- +
- { if (index != null) { const fileName = tableData[index]?.fileNm ?? ""; setFileNm(fileName) } }} onPageChange={function (page: number): void { - throw new Error('Function not implemented.') - }}> + { if (index != null) { const fileName = tableData[index]?.fileNm ?? ""; setFileNm(fileName); setSbmrgPrevntBizSn(tableData[index]?.sbmrgPrevntBizSn) } }} onPageChange={async (page:number)=>{setCurPage(page); await fetchData()}}>
- {await registFile(file, year,quater, cd,id)}} /> + { await registFile(file, year, quater, cd, id) }} />
)