From ef03ab961c593215dcc396b751622adbf941f3d6 Mon Sep 17 00:00:00 2001 From: JIeunhuh Date: Fri, 23 May 2025 15:35:00 +0900 Subject: [PATCH 1/2] =?UTF-8?q?=ED=8C=8C=EC=9D=BC=20=EC=82=AD=EC=A0=9C=20?= =?UTF-8?q?=EB=B0=8F=20=ED=85=8C=EC=9D=B4=EB=B8=94=20=ED=8E=98=EC=9D=B4?= =?UTF-8?q?=EC=A7=95=20=EC=B2=98=EB=A6=AC=20=EA=B5=AC=ED=98=84=20(?= =?UTF-8?q?=ED=85=8C=EC=8A=A4=ED=8A=B8=20=ED=95=84=EC=9A=94)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/sn/app/oper/floodPre/page.tsx | 54 +++++++++++++------ apps/sn/app/oper/index.ts | 2 +- apps/sn/app/oper/oldPp/page.tsx | 83 +++++++++++++++++++----------- 3 files changed, 93 insertions(+), 46 deletions(-) diff --git a/apps/sn/app/oper/floodPre/page.tsx b/apps/sn/app/oper/floodPre/page.tsx index 8fa3e9ae7..4bf0ca878 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-1); 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..236e3ea28 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-1); await fetchData()}}>
- {await registFile(file, year,quater, cd,id)}} /> + { await registFile(file, year, quater, cd, id) }} />
) From 66837f5a8a246520b3550f1a48958271fb61548b Mon Sep 17 00:00:00 2001 From: JIeunhuh Date: Fri, 23 May 2025 15:49:28 +0900 Subject: [PATCH 2/2] =?UTF-8?q?=ED=8E=98=EC=9D=B4=EC=A7=95=20=EA=B4=80?= =?UTF-8?q?=EB=A0=A8=20=EC=BD=94=EB=93=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/sn/app/oper/floodPre/page.tsx | 2 +- apps/sn/app/oper/oldPp/page.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/sn/app/oper/floodPre/page.tsx b/apps/sn/app/oper/floodPre/page.tsx index 4bf0ca878..98b14cd62 100644 --- a/apps/sn/app/oper/floodPre/page.tsx +++ b/apps/sn/app/oper/floodPre/page.tsx @@ -133,7 +133,7 @@ const Page = () => { - { if (index != null) { const fileName = tableData[index]?.fileNm ?? ""; setFileNm(fileName); setSbmrgPrevntBizSn(tableData[index]?.sbmrgPrevntBizSn) } }} onPageChange={async (page:number)=>{setCurPage(page-1); await fetchData()}}> + { 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) }} /> diff --git a/apps/sn/app/oper/oldPp/page.tsx b/apps/sn/app/oper/oldPp/page.tsx index 236e3ea28..b9f68bc1a 100644 --- a/apps/sn/app/oper/oldPp/page.tsx +++ b/apps/sn/app/oper/oldPp/page.tsx @@ -137,7 +137,7 @@ const Page = () => { - { if (index != null) { const fileName = tableData[index]?.fileNm ?? ""; setFileNm(fileName); setSbmrgPrevntBizSn(tableData[index]?.sbmrgPrevntBizSn) } }} onPageChange={async (page:number)=>{setCurPage(page-1); await fetchData()}}> + { 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) }} />