발주기관 > 통계 : 알림내역 CSV다운로드

main
유지인 2026-02-09 11:29:25 +09:00
parent 45846a70ec
commit 023afd63b7
1 changed files with 85 additions and 19 deletions

View File

@ -112,6 +112,7 @@ function getStatusInfo(statusCode) {
/** /**
* API 호출 결과를 받아 화면에 이력 목록을 표시하는 콜백 함수 * API 호출 결과를 받아 화면에 이력 목록을 표시하는 콜백 함수
*/ */
var historyData;
function displayHistoryList(response) { function displayHistoryList(response) {
// ▼▼▼ [수정] 대상 ID를 'notification-list-full'로 변경 // ▼▼▼ [수정] 대상 ID를 'notification-list-full'로 변경
var notificationList = document.getElementById('notification-list-full'); var notificationList = document.getElementById('notification-list-full');
@ -120,7 +121,7 @@ function displayHistoryList(response) {
if (response && response.resultCode === 200 && response.datas) { if (response && response.resultCode === 200 && response.datas) {
var datas = response.datas; var datas = response.datas;
var contentHtml = ''; var contentHtml = '';
historyData = response.datas; // 전역 변수에 셋팅(엑셀다운로드시 필요)
for (var i = 0; i < datas.length; i++) { for (var i = 0; i < datas.length; i++) {
var item = datas[i]; var item = datas[i];
@ -169,10 +170,74 @@ function displayHistoryList(response) {
console.error("Error fetching history list:", response.resultMessage); console.error("Error fetching history list:", response.resultMessage);
} }
} }
/**
* 알림내역 CSV 다운로드
*/
function clickExcelListDown() {
console.log(historyData);
if (!historyData || historyData.length === 0) {
alert("다운로드할 데이터가 없습니다.");
return;
}
const headers = [
"프로젝트명",
"이전상태",
"변경상태",
"변경일시"
];
const STATE_MAP = {
"0": "미입력",
"1": "입력 중",
"2": "검수 준비 대기중",
"3": "검수중",
"4": "수정 요청",
"6": "검수 완료",
"6": "등록 완료"
};
const rows = historyData.map(function (item) {
return [
item.constName,
STATE_MAP[item.preProjectStateCode] || item.preProjectStateCode,
STATE_MAP[item.projectStateCode] || item.projectStateCode,
item.modDt
];
});
let csvContent = "";
csvContent += headers.join(",") + "\n";
rows.forEach(function (row) {
csvContent += row
.map(function (value) {
return '"' + String(value).replace(/"/g, '""') + '"';
})
.join(",") + "\n";
});
const blob = new Blob(
["\uFEFF" + csvContent],
{ type: "text/csv;charset=utf-8;" }
);
const link = document.createElement("a");
const url = URL.createObjectURL(blob);
link.href = url;
link.download = "상태변경이력.csv";
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
URL.revokeObjectURL(url);
}
</script> </script>
<section class="drilling-page-container"> <section class="drilling-page-container">
<div class="page-content-wrapper drilling inquiry"> <div class="page-content-wrapper drilling inquiry">
<div class="page-sidebar-wrapper"> <div class="page-sidebar-wrapper">
<div class="page-sidebar"> <div class="page-sidebar">
<div class="treeview-project-name"> <div class="treeview-project-name">
<p class="project-title">알림</p> <p class="project-title">알림</p>
@ -181,31 +246,32 @@ function displayHistoryList(response) {
</div> </div>
</div> </div>
</div> </div>
<div class="page-content"> <div class="page-content">
<div class="page-content-inner"> <div class="page-content-inner">
<div class="category-wrapper"> <div class="category-wrapper">
<ul class="page-category"> <ul class="page-category">
<li class="category-item"></li> <li class="category-item"></li>
<li class="category-item">알림 내역</li> <li class="category-item">알림 내역</li>
</ul> </ul>
<a href="#" class="btn btn-help">도움말</a> <a href="#" class="btn btn-help">도움말</a>
</div> </div>
<h1 class="page-title-1depth">알림 내역</h1> <h1 class="page-title-1depth">알림 내역</h1>
<div class="content-wrapper"> <div class="content-wrapper">
<main class="w-full"> <main class="w-full">
<div class="bg-white p-6 rounded-lg shadow-md"> <div class="bg-white p-6 rounded-lg shadow-md">
<div class="border-b pb-4 mb-4"> <div class="border-b pb-4 mb-4 display-flex" style="justify-content: space-between;">
<h3 class="font-semibold text-gray-800 text-4xl">건설현장 프로젝트 상태 변경 이력</h3> <h3 class="font-semibold text-gray-800 text-4xl">건설현장 프로젝트 상태 변경 이력</h3>
</div> <button class="btn-green btn-list-excel-download marB0 marR0" type="button" id="excel-download-btn" onclick="javascript:clickExcelListDown();">CSV 다운로드</button>
<div id="notification-list-full" class="space-y-6"> </div>
<div class="p-4 text-center text-gray-500">알림 목록을 불러오는 중입니다...</div> <div id="notification-list-full" class="space-y-6">
</div> <div class="p-4 text-center text-gray-500">알림 목록을 불러오는 중입니다...</div>
</div> </div>
</main> </div>
</main>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</section> </section>
<div id="calenderDiv" class="trViewOff" style="position:absolute;"></div> <div id="calenderDiv" class="trViewOff" style="position:absolute;"></div>