주소록 등록 function ajax 배치로 진행중
This commit is contained in:
parent
30914b0d69
commit
307ce85acf
@ -329,10 +329,11 @@ function SetAddrMassSave(){
|
||||
// $('.loading_layer').addClass('active');
|
||||
|
||||
// setTimeout(setSenderList_advc, 1000);
|
||||
$('.loading_layer').addClass('active');
|
||||
setSenderList_advc();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
function setSenderList_advc(){
|
||||
|
||||
// tab에 해당하는 타블레이터 가져오기
|
||||
@ -362,33 +363,10 @@ function setSenderList_advc(){
|
||||
|
||||
if (data.status == 'OK') {
|
||||
alert(data.message);
|
||||
// alert("저장에 성공했습니다.\n저장 : " + returnData.resultCnt + "건"
|
||||
// +", 중복 : " + returnData.dupliCnt + "건"
|
||||
// +", 휴대폰번호 오류 : " + returnData.errPhoneCnt + "건");
|
||||
|
||||
// 중복번호 Hide
|
||||
// $("#btnAddrMassDupli").hide();
|
||||
// $("#btnAddrMassSaveDupli").hide();
|
||||
|
||||
// 중복건이 있을경우
|
||||
|
||||
// if (returnData.dupliCnt > 0) {
|
||||
//alert(returnData.addrMassDupliList.length);
|
||||
|
||||
// 중복번호(해당 그룹) Show
|
||||
// $("#btnAddrMassSaveDupli").show();
|
||||
|
||||
// addrMassDupliSaveList = returnData.addrMassDupliList;
|
||||
//$("#btnAddrMassSaveDupli").trigger("click");
|
||||
// }
|
||||
|
||||
// 데이터 비우기
|
||||
SetClear($objTabul);
|
||||
|
||||
var selectMassVal = $("#addrGrpIdInfo option:selected").val();
|
||||
|
||||
// 주소록그룹 콤보박스 유지
|
||||
// setTimeout(setSelectMassSetting, 500, selectMassVal);
|
||||
}
|
||||
else {
|
||||
alert("오류 알림 : :: "+data.message);
|
||||
@ -407,184 +385,78 @@ function setSenderList_advc(){
|
||||
$('.loading_layer').removeClass('active');
|
||||
}
|
||||
});
|
||||
}
|
||||
/*
|
||||
function setSenderList() {
|
||||
var selectedData = tableR.getRows();
|
||||
for (var i=gArrRestartIndex; i < selectedData.length; i++) {
|
||||
var name = tableR.getRows()[i].getData().name;
|
||||
var phone = removeDash(tableR.getRows()[i].getData().phone);
|
||||
var info1 = tableR.getRows()[i].getData().info1;
|
||||
var info2 = tableR.getRows()[i].getData().info2;
|
||||
var info3 = tableR.getRows()[i].getData().info3;
|
||||
var info4 = tableR.getRows()[i].getData().info4;
|
||||
var memo = tableR.getRows()[i].getData().memo;
|
||||
|
||||
gPhoneList[i] = phone;
|
||||
// name
|
||||
if (name == "" || name == null || name == undefined) {
|
||||
gNameList[i] = "";
|
||||
}
|
||||
else {
|
||||
if(!addrEmojiCheck(name)){//이모지 체크 해주기
|
||||
return false;
|
||||
}
|
||||
|
||||
gNameList[i] = name.replace(/,/g,"§");
|
||||
}
|
||||
|
||||
// info1
|
||||
if (info1 == "" || info1 == null || info1 == undefined) {
|
||||
gInfo1List[i] = "";
|
||||
}
|
||||
else {
|
||||
if(!addrEmojiCheck(info1)){//이모지 체크 해주기
|
||||
return false;
|
||||
}
|
||||
|
||||
gInfo1List[i] = info1.replace(/,/g,"§");
|
||||
}
|
||||
// info2
|
||||
if (info2 == "" || info2 == null || info2 == undefined) {
|
||||
gInfo2List[i] = "";
|
||||
}
|
||||
else {
|
||||
if(!addrEmojiCheck(info2)){//이모지 체크 해주기
|
||||
return false;
|
||||
}
|
||||
|
||||
gInfo2List[i] = info2.replace(/,/g,"§");
|
||||
}
|
||||
// info3
|
||||
if (info3 == "" || info3 == null || info3 == undefined) {
|
||||
gInfo3List[i] = "";
|
||||
}
|
||||
else {
|
||||
if(!addrEmojiCheck(info3)){//이모지 체크 해주기
|
||||
return false;
|
||||
}
|
||||
gInfo3List[i] = info3.replace(/,/g,"§");
|
||||
}
|
||||
// info4
|
||||
if (info4 == "" || info4 == null || info4 == undefined) {
|
||||
gInfo4List[i] = "";
|
||||
}
|
||||
else {
|
||||
if(!addrEmojiCheck(info4)){//이모지 체크 해주기
|
||||
return false;
|
||||
}
|
||||
gInfo4List[i] = info4.replace(/,/g,"§");
|
||||
}
|
||||
// memo
|
||||
if (memo == "" || memo == null || memo == undefined) {
|
||||
gMemoList[i] = "";
|
||||
}
|
||||
else {
|
||||
if(!addrEmojiCheck(memo)){//이모지 체크 해주기
|
||||
return false;
|
||||
}
|
||||
gMemoList[i] = memo.replace(/,/g,"§");
|
||||
}
|
||||
|
||||
//브라우저 대기 메세지 안나오게 하기위한 처리
|
||||
var reStartArray = [10000, 20000, 30000, 40000, 50000, 60000, 70000, 80000, 90000, 100000, 110000, 120000, 130000, 140000, 150000, 160000, 170000, 180000, 190000, 200000];
|
||||
|
||||
if (reStartArray.includes(i, 0)) {
|
||||
gArrRestartIndex = i+1;
|
||||
|
||||
if (selectedData.length > gArrRestartIndex) {
|
||||
setTimeout(setSenderList, 500);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (gPhoneList.length == selectedData.length) {
|
||||
//console.log(new Date());
|
||||
//console.log("gPhoneList.length : " + gPhoneList.length);
|
||||
//console.log("selectedData.length : " + selectedData.length);
|
||||
|
||||
SetAddrMassSave_Step2();
|
||||
}
|
||||
}
|
||||
*/
|
||||
//저장
|
||||
/* function SetAddrMassSave_Step2(){
|
||||
var form = document.addrMassForm;
|
||||
form.phoneList.value = gPhoneList;
|
||||
form.nameList.value = gNameList;
|
||||
form.info1List.value = gInfo1List;
|
||||
form.info2List.value = gInfo2List;
|
||||
form.info3List.value = gInfo3List;
|
||||
form.info4List.value = gInfo4List;
|
||||
form.memoList.value = gMemoList;
|
||||
form.addrGrpId.value = $("#addrGrpIdInfo").val();
|
||||
|
||||
var data = new FormData(form);
|
||||
|
||||
url = "/web/mjon/addr/addrMassInsertByTempAjax.do";
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: url,
|
||||
data: data,
|
||||
dataType:'json',
|
||||
async: true,
|
||||
processData: false,
|
||||
contentType: false,
|
||||
cache: false,
|
||||
success: function (returnData) {
|
||||
//로딩창 hide
|
||||
$('.loading_layer').removeClass('active');
|
||||
|
||||
if (returnData.isSuccess) {
|
||||
alert("저장에 성공했습니다.\n저장 : " + returnData.resultCnt + "건, 중복 : " + returnData.dupliCnt + "건, 휴대폰번호 오류 : " + returnData.errPhoneCnt + "건");
|
||||
|
||||
|
||||
|
||||
function setSenderList_advc(){
|
||||
var $objTabul = fn_utils_getTabulator();
|
||||
var dataToSend = $objTabul.getData();
|
||||
var addrGrpIdInfo = $("#addrGrpIdInfo").val();
|
||||
var addrGrpNmInfo = $("#addrGrpNm").val();
|
||||
|
||||
// 중복번호 Hide
|
||||
$("#btnAddrMassDupli").hide();
|
||||
$("#btnAddrMassSaveDupli").hide();
|
||||
|
||||
// 중복건이 있을경우
|
||||
if (returnData.dupliCnt > 0) {
|
||||
//alert(returnData.addrMassDupliList.length);
|
||||
var batchSize = 20000; // 배치 크기
|
||||
var totalBatches = Math.ceil(dataToSend.length / batchSize); // 총 배치 수
|
||||
var currentBatch = 0; // 현재 배치 인덱스
|
||||
|
||||
// 중복번호(해당 그룹) Show
|
||||
$("#btnAddrMassSaveDupli").show();
|
||||
|
||||
addrMassDupliSaveList = returnData.addrMassDupliList;
|
||||
//$("#btnAddrMassSaveDupli").trigger("click");
|
||||
}
|
||||
|
||||
// 데이터 비우기
|
||||
SetClear();
|
||||
|
||||
var selectMassVal = $("#addrGrpIdInfo option:selected").val();
|
||||
|
||||
// 주소록그룹 콤보박스 유지
|
||||
setTimeout(setSelectMassSetting, 500, selectMassVal);
|
||||
}
|
||||
else {
|
||||
alert("오류 알림 : " + returnData.msg);
|
||||
}
|
||||
},
|
||||
error: function (e) {
|
||||
//로딩창 hide
|
||||
$('.loading_layer').removeClass('active');
|
||||
|
||||
alert("저장에 실패하였습니다.");
|
||||
alert("ERROR : " + JSON.stringify(e));
|
||||
},
|
||||
beforeSend : function(xmlHttpRequest) {
|
||||
//로딩창 show
|
||||
$('.loading_layer').addClass('active');
|
||||
},
|
||||
complete : function(xhr, textStatus) {
|
||||
//로딩창 hide
|
||||
$('.loading_layer').removeClass('active');
|
||||
}
|
||||
});
|
||||
} */
|
||||
fn_loadAddActive();
|
||||
|
||||
|
||||
function sendBatch() {
|
||||
if (currentBatch < totalBatches) {
|
||||
var start = currentBatch * batchSize;
|
||||
var end = Math.min(start + batchSize, dataToSend.length);
|
||||
var batchData = dataToSend.slice(start, end);
|
||||
|
||||
var updateData = batchData.map(row => {
|
||||
row.addrGrpId = addrGrpIdInfo;
|
||||
row.addrGrpNm = addrGrpNmInfo;
|
||||
return row;
|
||||
});
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/web/mjon/addr/addrMassInsertByTempAjax_advc.do",
|
||||
data: JSON.stringify(updateData),
|
||||
dataType: 'json',
|
||||
contentType: 'application/json',
|
||||
async: true,
|
||||
success: function (data) {
|
||||
console.log('Batch ' + (currentBatch + 1) + ' success: ', data);
|
||||
if (data.status == 'OK') {
|
||||
if (currentBatch === totalBatches - 1) {
|
||||
alert("모든 데이터가 성공적으로 저장되었습니다.");
|
||||
// 데이터 비우기
|
||||
SetClear($objTabul);
|
||||
} else {
|
||||
currentBatch++;
|
||||
sendBatch(); // 다음 배치 전송
|
||||
}
|
||||
} else {
|
||||
alert("오류 알림 : " + data.message);
|
||||
}
|
||||
},
|
||||
error: function (e) {
|
||||
alert("배치 전송에 실패하였습니다.");
|
||||
console.error("ERROR: ", JSON.stringify(e));
|
||||
},
|
||||
beforeSend: function(xmlHttpRequest) {
|
||||
},
|
||||
complete: function(xhr, textStatus) {
|
||||
console.log('end : ', end);
|
||||
$('#lodingTxt').text(end);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
// 첫 번째 배치 전송 시작
|
||||
sendBatch();
|
||||
$('.loading_layer').removeClass('active');
|
||||
}
|
||||
|
||||
|
||||
|
||||
//주소록그룹 콤보박스 유지
|
||||
function setSelectMassSetting(selectMassVal) {
|
||||
$("#addrGrpIdInfo").val(selectMassVal).prop("selected", true);
|
||||
@ -612,7 +484,6 @@ function SetClear($objTabul) {
|
||||
// AddrListAjax.jsp에서 호출
|
||||
$(document).on('click', '#btnAddrMassRegCall', function() {
|
||||
getAddrGroupList();
|
||||
console.log('??');
|
||||
});
|
||||
|
||||
|
||||
@ -765,7 +636,9 @@ function fn_tabToggle(tabNum){
|
||||
<div class="loading_layer">
|
||||
<div class="loading_container">
|
||||
<div class="bar"></div>
|
||||
<div class="text">Loading</div>
|
||||
<div class="text" id="lodingTxt">
|
||||
Loading
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@ -80,7 +80,7 @@ $(document).ready(function(){
|
||||
$("#excelFile").on("change", function(event) {
|
||||
var fileInfo = event.target.files;
|
||||
if(fileInfo.length > 0){
|
||||
fn_loadAddActive();
|
||||
// fn_loadAddActive();
|
||||
excelFileChange(fileInfo[0]);
|
||||
}
|
||||
});
|
||||
@ -342,7 +342,7 @@ $(document).on("dragover",".upload_area",function(e){
|
||||
e.preventDefault();
|
||||
});
|
||||
$(document).on("drop",".upload_area",function(e){
|
||||
fn_loadAddActive();
|
||||
// fn_loadAddActive();
|
||||
e.preventDefault();
|
||||
var files = e.originalEvent.dataTransfer.files;
|
||||
excelFileChange(files[0]);
|
||||
@ -353,8 +353,8 @@ $(document).on('dragenter', function (e){
|
||||
e.preventDefault();
|
||||
});
|
||||
$(document).on('dragover', function (e){
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
//objDragAndDrop.css('border', '2px dotted #0B85A1');
|
||||
});
|
||||
$(document).on('drop', function (e){
|
||||
@ -365,22 +365,25 @@ $(document).on('drop', function (e){
|
||||
|
||||
function excelFileChange(file) {
|
||||
if (file) {
|
||||
fn_loadAddActive();
|
||||
var reader = new FileReader();
|
||||
var extension = file.name.split('.').pop().toLowerCase();
|
||||
|
||||
reader.onload = function(e) {
|
||||
if (extension === 'xlsx') {
|
||||
var data = new Uint8Array(e.target.result);
|
||||
var workbook = XLSX.read(data, {type: 'array'});
|
||||
var firstSheet = workbook.Sheets[workbook.SheetNames[0]];
|
||||
var jsonData = XLSX.utils.sheet_to_json(firstSheet, {header: 1});
|
||||
processExcelData(jsonData);
|
||||
} else if (extension === 'txt') {
|
||||
var textData = e.target.result;
|
||||
processTextData(textData);
|
||||
} else {
|
||||
alert('지원되지 않는 파일 형식입니다.');
|
||||
}
|
||||
setTimeout(() => { // 파일 읽기 완료 후 실행되도록 함
|
||||
if (extension === 'xlsx') {
|
||||
var data = new Uint8Array(e.target.result);
|
||||
var workbook = XLSX.read(data, {type: 'array'});
|
||||
var firstSheet = workbook.Sheets[workbook.SheetNames[0]];
|
||||
var jsonData = XLSX.utils.sheet_to_json(firstSheet, {header: 1});
|
||||
processExcelData(jsonData);
|
||||
} else if (extension === 'txt') {
|
||||
var textData = e.target.result;
|
||||
processTextData(textData);
|
||||
} else {
|
||||
alert('지원되지 않는 파일 형식입니다.');
|
||||
}
|
||||
fn_loadRemoveActive();
|
||||
}, 0); // 지연 없이 즉시 실행되도록 0ms 지연을 설정
|
||||
};
|
||||
|
||||
if (extension === 'xlsx') {
|
||||
@ -398,19 +401,22 @@ function excelFileChange(file) {
|
||||
function processExcelData(data) {
|
||||
var keys = ['A', 'B', 'C', 'D', 'E', 'F', 'G'];
|
||||
var tableData = [];
|
||||
var totalRows = data.length - 2; // 전체 데이터 수 (1, 2행 제외)
|
||||
|
||||
|
||||
// 3번째 행부터 입력
|
||||
// 1, 2행은 예시와 타이틀이라 입력안함
|
||||
data.slice(2).forEach(row => {
|
||||
data.slice(2).forEach((row, index) => {
|
||||
var rowData = {};
|
||||
keys.forEach((key, index) => {
|
||||
rowData[key] = row[index] ? row[index].trim() : ""; // 각 컬럼에 대해 기본값을 설정
|
||||
keys.forEach((key, idx) => { // index 변수명 변경 (내부와 외부에서 사용되므로 충돌 방지)
|
||||
rowData[key] = row[idx] ? row[idx].trim() : ""; // 각 컬럼에 대해 기본값을 설정
|
||||
});
|
||||
tableData.push(rowData);
|
||||
|
||||
});
|
||||
|
||||
updateTable(tableData);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 텍스트 데이터 처리 함수
|
||||
function processTextData(text) {
|
||||
@ -436,13 +442,13 @@ function updateTable(tableData) {
|
||||
{formatter: "rowSelection", titleFormatter: "rowSelection", clipboard: false, hozAlign: "center", headerHozAlign: "center", headerSort: false, cellClick: function(e, cell) {
|
||||
cell.getRow().toggleSelect();
|
||||
}},
|
||||
{title: "A", hozAlign: "center", headerHozAlign: "center", field: "A", editor: "input", width: 125, validator: ["maxLength:100", "string"]},
|
||||
{title: "B", hozAlign: "center", headerHozAlign: "center", field: "B", editor: "input", width: 125, validator: ["maxLength:100", "string"]},
|
||||
{title: "C", hozAlign: "center", headerHozAlign: "center", field: "C", editor: "input", width: 125, validator: ["maxLength:100", "string"]},
|
||||
{title: "D", hozAlign: "center", headerHozAlign: "center", field: "D", editor: "input", width: 125, validator: ["maxLength:100", "string"]},
|
||||
{title: "E", hozAlign: "center", headerHozAlign: "center", field: "E", editor: "input", width: 125, validator: ["maxLength:100", "string"]},
|
||||
{title: "F", hozAlign: "center", headerHozAlign: "center", field: "F", editor: "input", width: 125, validator: ["maxLength:100", "string"]},
|
||||
{title: "G", hozAlign: "center", headerHozAlign: "center", field: "G", editor: "input", width: 125, validator: ["maxLength:100", "string"]}
|
||||
{title: "A", field: "A", hozAlign: "center", headerHozAlign: "center", width: 125, validator: ["maxLength:100", "string"]},
|
||||
{title: "B", field: "B", hozAlign: "center", headerHozAlign: "center", width: 125, validator: ["maxLength:100", "string"]},
|
||||
{title: "C", field: "C", hozAlign: "center", headerHozAlign: "center", width: 125, validator: ["maxLength:100", "string"]},
|
||||
{title: "D", field: "D", hozAlign: "center", headerHozAlign: "center", width: 125, validator: ["maxLength:100", "string"]},
|
||||
{title: "E", field: "E", hozAlign: "center", headerHozAlign: "center", width: 125, validator: ["maxLength:100", "string"]},
|
||||
{title: "F", field: "F", hozAlign: "center", headerHozAlign: "center", width: 125, validator: ["maxLength:100", "string"]},
|
||||
{title: "G", field: "G", hozAlign: "center", headerHozAlign: "center", width: 125, validator: ["maxLength:100", "string"]}
|
||||
]);
|
||||
|
||||
$tableExcel.setData(tableData).then(() => {
|
||||
|
||||
@ -37,13 +37,13 @@ $(document).ready(function(){
|
||||
cell.getRow().toggleSelect();
|
||||
}
|
||||
},
|
||||
{title:"A", hozAlign:"center", headerHozAlign: "center", field:"A", editor:"input", width:125, validator:["maxLength:100", "string"]},
|
||||
{title:"B", hozAlign:"center", headerHozAlign: "center", field:"B", editor:"input", width:125, validator:["maxLength:100", "string"]},
|
||||
{title:"C", hozAlign:"center", headerHozAlign: "center", field:"C", editor:"input", width:125, validator:["maxLength:100", "string"]},
|
||||
{title:"D", hozAlign:"center", headerHozAlign: "center", field:"D", editor:"input", width:125, validator:["maxLength:100", "string"]},
|
||||
{title:"E", hozAlign:"center", headerHozAlign: "center", field:"E", editor:"input", width:125, validator:["maxLength:100", "string"]},
|
||||
{title:"F", hozAlign:"center", headerHozAlign: "center", field:"F", editor:"input", width:125, validator:["maxLength:100", "string"]},
|
||||
{title:"G", hozAlign:"center", headerHozAlign: "center", field:"G", editor:"input", width:125, validator:["maxLength:100", "string"]}
|
||||
{title:"A", field:"A", hozAlign:"center", headerHozAlign: "center", width:125, validator:["maxLength:100", "string"]},
|
||||
{title:"B", field:"B", hozAlign:"center", headerHozAlign: "center", width:125, validator:["maxLength:100", "string"]},
|
||||
{title:"C", field:"C", hozAlign:"center", headerHozAlign: "center", width:125, validator:["maxLength:100", "string"]},
|
||||
{title:"D", field:"D", hozAlign:"center", headerHozAlign: "center", width:125, validator:["maxLength:100", "string"]},
|
||||
{title:"E", field:"E", hozAlign:"center", headerHozAlign: "center", width:125, validator:["maxLength:100", "string"]},
|
||||
{title:"F", field:"F", hozAlign:"center", headerHozAlign: "center", width:125, validator:["maxLength:100", "string"]},
|
||||
{title:"G", field:"G", hozAlign:"center", headerHozAlign: "center", width:125, validator:["maxLength:100", "string"]}
|
||||
],
|
||||
validationFailed:function(cell, value, parameters){ // 유효성 체크 함수
|
||||
var valid = cell.isValid();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user