FAISP/src/main/resources/static/js/igActivities/fpiMgt/affair/statistics.js

170 lines
4.3 KiB
JavaScript
Raw Normal View History

2022-10-25 02:36:32 +00:00
$(function(){
$("#dateSelectorDiv").datepicker({
format: "yyyy-mm-dd",
language: "ko"
});
})
$(document).on('click', '#downExcel', function (){
exportExcel();
})
function exportExcel(){
// step 1. workbook 생성
var wb = XLSX.utils.book_new();
// step 2. 시트 만들기
var newWorksheet = excelHandler.getWorksheet();
// step 3. workbook에 새로만든 워크시트에 이름을 주고 붙인다.
XLSX.utils.book_append_sheet(wb, newWorksheet, excelHandler.getSheetName());
// step 4. 엑셀 파일 만들기
var wbout = XLSX.write(wb, {bookType:'xlsx', type: 'binary'});
// step 5. 엑셀 파일 내보내기
saveAs(new Blob([s2ab(wbout)],{type:"application/octet-stream"}), excelHandler.getExcelFileName());
}
var excelHandler = {
getExcelFileName : function(){
return '견문통계'+'_'+getToday()+'.xlsx'; //파일명
},
getSheetName : function(){
return 'Table Test Sheet'; //시트명
},
getExcelData : function(){
return document.getElementById('tableData'); //TABLE id
},
getWorksheet : function(){
return XLSX.utils.table_to_sheet(this.getExcelData());
}
}
function s2ab(s) {
var buf = new ArrayBuffer(s.length); //convert s to arrayBuffer
var view = new Uint8Array(buf); //create uint8array as viewer
for (var i=0; i<s.length; i++) view[i] = s.charCodeAt(i) & 0xFF; //convert to octet
return buf;
}
function getToday(){
var date = new Date();
var year = date.getFullYear();
var month = ("0" + (1 + date.getMonth())).slice(-2);
var day = ("0" + date.getDate()).slice(-2);
return year + "-" + month + "-" + day;
2022-10-25 02:36:32 +00:00
}
$(document).on('click', '#fieldSearch', function (){
goFieldStatistics();
})
$(document).on('click', '#fieldTab', function (){
goFieldStatistics();
})
function goFieldStatistics(){
searchFade("in");
const formData = new FormData($("#searchFm")[0]);
$.ajax({
url: '/affair/fieldStatistics',
data: formData,
type: 'POST',
dataType:"html",
contentType: false,
processData: false,
success: function(html){
$("#statisticsBody").empty().append(html)
$("#statisticsBody").show();
$(".statisticsMenu").hide();
searchFade("out");
},
error:function(){
searchFade("out");
}
});
}
$(document).on('click', '#ratingSearch', function (){
goRatingStatistics();
})
$(document).on('click', '#ratingTab', function (){
goRatingStatistics();
})
function goRatingStatistics(){
searchFade("in");
const formData = new FormData($("#searchFm")[0]);
$.ajax({
url: '/affair/ratingStatistics',
data: formData,
type: 'POST',
dataType:"html",
contentType: false,
processData: false,
success: function(html){
$("#statisticsBody").empty().append(html)
$("#statisticsBody").show();
$(".statisticsMenu").hide();
searchFade("out");
},
error:function(){
searchFade("out");
}
});
}
$(document).on('click', '#showMenu', function (){
$(".statisticsMenu").show();
})
$(document).ready(function() {
$("#organAll").click(function() {
if($("#organAll").is(":checked")){
$("input[name=organList]").prop("checked", true);
} else{
$("input[name=organList]").prop("checked", false);
}
});
$("#ratingAll").click(function() {
if($("#ratingAll").is(":checked")){
$("input[name=rating]").prop("checked", true);
} else{
$("input[name=rating]").prop("checked", false);
}
});
$("#category1All").click(function() {
if($("#category1All").is(":checked")){
$("input[name=category1]").prop("checked", true);
} else{
$("input[name=category1]").prop("checked", false);
}
});
$("#category2All").click(function() {
if($("#category2All").is(":checked")){
$("input[name=category2]").prop("checked", true);
} else{
$("input[name=category2]").prop("checked", false);
}
});
$("#category3All").click(function() {
if($("#category3All").is(":checked")){
$("input[name=category3]").prop("checked", true);
} else{
$("input[name=category3]").prop("checked", false);
}
});
$("#category4All").click(function() {
if($("#category4All").is(":checked")){
$("input[name=category4]").prop("checked", true);
} else{
$("input[name=category4]").prop("checked", false);
}
});
});