468 lines
15 KiB
JavaScript
468 lines
15 KiB
JavaScript
$(document).ready(function () {
|
|
|
|
|
|
/* Company 등록/수정 팝업*/
|
|
$('.company-reg').on("click",function(){
|
|
let com_no = $(this).data('idx');
|
|
popCompany(com_no);
|
|
})
|
|
|
|
|
|
/* Company 수정*/
|
|
$('#btn-register').on("click",function(){
|
|
var formData = $("#dailyTaskInput").serialize();
|
|
|
|
if(!$("#com_name").val()){
|
|
alert('업체명을 입력해 주세요.');
|
|
$("#com_name").focus();
|
|
return;
|
|
}
|
|
|
|
$.ajax({
|
|
cache : false,
|
|
url : "/html/process.html", // 요기에
|
|
type : 'POST',
|
|
data : formData,
|
|
success : function(data) {
|
|
if(data=='Success' || data == 'Auth'){
|
|
top.opener.location.reload();
|
|
self.close();
|
|
}
|
|
else alert(data);
|
|
}, // success
|
|
|
|
error : function(xhr, status) {
|
|
alert(xhr + " : " + status);
|
|
}
|
|
}); // $.ajax */
|
|
})
|
|
|
|
|
|
/* Company 삭제*/
|
|
$('.company-del').on("click",function(){
|
|
let com_no = $(this).data('idx')
|
|
let refpage = '/html/company/company_add.html';
|
|
|
|
if(!com_no){
|
|
alert('회원정보가 아닙니다.');
|
|
return;
|
|
}
|
|
|
|
if(!confirm('해당 업체를 삭제 하시겠습니까?')) return;
|
|
|
|
$.ajax({
|
|
cache : false,
|
|
url : "/html/process.html",
|
|
type : 'POST',
|
|
data : {com_no:com_no,mod:'del',refpage:refpage },
|
|
success : function(data) {
|
|
if(data=='Success') location.reload();
|
|
else alert(data);
|
|
}, // success
|
|
|
|
error : function(xhr, status) {
|
|
alert(xhr + " : " + status);
|
|
}
|
|
}); // $.ajax */
|
|
})
|
|
|
|
// 리스트내 세부정보 토글
|
|
$(".company-list").on("click",function(){
|
|
let comDetail = $(this).parent().parent().parent().next();
|
|
let status = comDetail.hasClass('hidden');
|
|
|
|
if(status){
|
|
comDetail.removeClass('hidden');
|
|
}else{
|
|
comDetail.addClass('hidden');
|
|
}
|
|
|
|
});
|
|
|
|
|
|
// 업체 임직원 신규등록 모달
|
|
$(".company-member-add").on("click",function(){
|
|
let com_no = $(this).data('idx')
|
|
$('#com_no').val('');
|
|
if(com_no){
|
|
$('#com_no').val(com_no);
|
|
}else{
|
|
$('#company-tr').removeClass('hidden');
|
|
}
|
|
document.getElementById('myModal-company-user').style.display = 'block';
|
|
});
|
|
|
|
// 업체 임직원 수정 화면
|
|
var titleORG='';
|
|
$(document).on("click",'.view-company-user-modal',function(e){
|
|
|
|
let refpage = "/html/company/customer_list.html";
|
|
let idx = $(this).data('idx');
|
|
|
|
$.ajax({
|
|
cache : false,
|
|
url : "/html/process.html",
|
|
type : 'POST',
|
|
dataType: 'json',
|
|
data : {sidx:idx,mod:'view',refpage:refpage },
|
|
success : function(data) {
|
|
|
|
//console.log(data);
|
|
|
|
if(data.response=='Success') {
|
|
|
|
|
|
$('#company-tr').removeClass('hidden');
|
|
document.getElementById('myModal-company-user').style.display = 'block';
|
|
|
|
let CU = data.data;
|
|
|
|
$('#CU_NAME').val(CU.CU_NAME);
|
|
$('#COMPANY').val(CU.COM_NO);
|
|
$('#CU_ROLE').val(CU.CU_ROLE);
|
|
$('#CU_HP').val(CU.CU_HP);
|
|
$('#CU_EMAIL').val(CU.CU_EMAIL);
|
|
$('#CU_JUMIN').val(CU.CU_JUMIN);
|
|
$('#CU_ADDR').val(CU.CU_ADDR);
|
|
$('#CU_MEMO').val(CU.CU_MEMO);
|
|
|
|
if(idx) $('#modal-btn').text('수정');
|
|
$('#cu_no').val(idx);
|
|
}
|
|
else alert(data);
|
|
}, // success
|
|
|
|
error : function(xhr, status) {
|
|
alert(xhr + " : " + status);
|
|
}
|
|
}); // $.ajax */
|
|
|
|
})
|
|
|
|
|
|
// 업체 임직원 정보 등록
|
|
$(".submit-com-user").on("click",function(){
|
|
|
|
var formData = $("#frm-company-user-add").serialize();
|
|
let setName = $("#CU_NAME").val();
|
|
|
|
if(!setName){
|
|
alert('이름을 입력해 주세요.');
|
|
return;
|
|
}
|
|
|
|
$.ajax({
|
|
cache : false,
|
|
url : "/html/process.html",
|
|
type : 'POST',
|
|
data : formData,
|
|
dataType: 'json',
|
|
success : function(data) {
|
|
//console.log(data);
|
|
|
|
if(data.response == 'Success') {
|
|
|
|
let val = data.data;
|
|
let html = '';
|
|
|
|
if(val.refpage == "/html/company/company_list.html") {
|
|
|
|
html += '<tr>';
|
|
html += ' <td class="company-user-td"> </td>';
|
|
html += ' <td class="company-user-td">' + val.CU_ROLE + ' ' + val.CU_NAME + '</td>';
|
|
html += ' <td class="company-user-td">' + val.CU_HP + '</td>';
|
|
html += ' <td class="company-user-td">' + val.CU_EMAIL + '</td>';
|
|
html += ' <td class="company-user-td">' + val.CU_JUMIN + '</td>';
|
|
html += ' <td class="company-user-td">' + val.CU_ADDR + '</td>';
|
|
html += ' <td class="company-user-td">' + val.CU_MEMO + '</td>';
|
|
html += ' <td class="company-user-td">';
|
|
html += ' <button class="btn btn-tiny btn-nomal company-member-del" data-idx="">X</button>';
|
|
html += ' </td>';
|
|
html += '</tr>';
|
|
|
|
$("#ComUserTable_" + val.com_no).append(html);
|
|
}
|
|
else if (val.refpage == "/html/company/company_detail.html"){
|
|
|
|
html += '<tr>';
|
|
html += ' <td>' + val.CU_ROLE + ' ' + val.CU_NAME + '</td>';
|
|
html += ' <td>' + val.CU_HP + '</td>';
|
|
html += ' <td>' + val.CU_EMAIL + '</td>';
|
|
html += ' <td>' + val.CU_JUMIN + '</td>';
|
|
html += ' <td>' + val.CU_ADDR + '</td>';
|
|
html += ' <td>';
|
|
html += ' <button class="btn btn-tiny btn-nomal company-member-del" data-idx="'+ val.com_no +'|'+ val.cu_no + '">X</button>';
|
|
html += ' </td>';
|
|
html += '</tr>';
|
|
|
|
$("#appendix-user").append(html);
|
|
}
|
|
else if (val.refpage == "/html/company/customer_list.html"){
|
|
location.reload();
|
|
}
|
|
|
|
} else alert(data);
|
|
}, // success
|
|
|
|
error: function (xhr, status) {
|
|
alert(xhr + " : " + status);
|
|
}
|
|
}); // $.ajax */
|
|
|
|
// 모달 닫기
|
|
closeModal();
|
|
})
|
|
|
|
// 업체 임직원 정보 삭제
|
|
$(document).on("click", ".company-member-del", function () {
|
|
|
|
let data = $(this).data('idx').split('|');
|
|
//console.log(data);
|
|
let com_no = data[0];
|
|
let cu_no = data[1];
|
|
let type = data[2];
|
|
let target = $(this).parent().parent();
|
|
|
|
if(!confirm('해당 임직원을 삭제 하시겠습니까?\n관련 파일이 있으면 파일도 함께 삭제 됩니다.')) return;
|
|
|
|
$.ajax({
|
|
cache: false,
|
|
url: "/html/process.html",
|
|
type : 'POST',
|
|
data : {com_no:com_no,cu_no:cu_no,mod:'del',refpage:'/html/company/company_list.html' },
|
|
success : function(data) {
|
|
if(data=='Success') {
|
|
if (type == 'customer'){
|
|
location.reload();
|
|
}else {
|
|
target.remove();
|
|
}
|
|
}
|
|
else alert(data);
|
|
}, // success
|
|
|
|
error : function(xhr, status) {
|
|
alert(xhr + " : " + status);
|
|
}
|
|
}); // $.ajax */
|
|
|
|
})
|
|
|
|
$(".btn-company-search").on("click", function () {
|
|
|
|
let com_no = $('#keyword').val();
|
|
if(com_no) location.href='?com_no='+com_no;
|
|
})
|
|
|
|
|
|
/*** 업체관리 상세[S] ***/
|
|
// 업체관리 상세 탭 활성
|
|
$("[class*='appendix-']").on("click", function(){
|
|
|
|
// 클릭된 요소의 모든 클래스를 배열로 가져와 "appendix-"로 시작하는 클래스를 찾음
|
|
let classList = $(this).attr('class').split(/\s+/);
|
|
let appendixClass = classList.find(function(className) {
|
|
return className.startsWith('appendix-');
|
|
});
|
|
|
|
$("[id^='appendix-']").addClass("hidden");
|
|
$("#"+appendixClass).removeClass("hidden");
|
|
})
|
|
|
|
|
|
// 파일관리 - 첨부파일 모달 오픈
|
|
$(".company-file-add").on("click",function(){
|
|
let com_no = $(this).data('idx');
|
|
$('input[name="com_no"]').val('');
|
|
if(com_no){
|
|
$('input[name="com_no"]').val(com_no);
|
|
}
|
|
|
|
// 테이블 초기화
|
|
fno = 0;
|
|
$('#fileTable tbody tr').remove();
|
|
|
|
$(".file-add").trigger('click');
|
|
$("#myModal-company-file").show();
|
|
$(".file-add").show();
|
|
$(".text-file-title").text("등록");
|
|
});
|
|
|
|
// 파일등록 - 항목추가
|
|
var fno = 0;
|
|
$(".file-add").on("click",function(){
|
|
|
|
fno++;
|
|
|
|
let addHtml = '';
|
|
addHtml +='<tr class="add-tr">';
|
|
addHtml +=' <td>';
|
|
addHtml +=' <select class="form-control" name="fileType['+fno+']" style="padding:5px">';
|
|
addHtml +=' <option value="00">일반</option>';
|
|
addHtml +=' <option value="01">컨설팅</option>';
|
|
addHtml +=' <option value="02">보험</option>';
|
|
addHtml +=' <option value="03">인증서</option>';
|
|
addHtml +=' <option value="04">기타</option>';
|
|
addHtml +=' </select>';
|
|
addHtml +=' </td>';
|
|
addHtml +=' <td>';
|
|
addHtml +=' <input class="form-control btn-xs" type="text" name="fileName['+fno+']" list="file_list" placeholder="파일명" autocomplete="off"/>';
|
|
addHtml +=' </td>';
|
|
addHtml +=' <td>';
|
|
addHtml +=' <input class="btn-xs" type="file" name="upload['+fno+']" style="width:100%">';
|
|
addHtml +=' </td>';
|
|
addHtml +='</tr>';
|
|
$('#fileTable').append(addHtml);
|
|
});
|
|
|
|
// 파일등록 - 업로드
|
|
$(".submit-com-file").on("click",function(){
|
|
|
|
// 로딩바
|
|
$('#status').fadeIn();
|
|
$('#preloader').delay(100).fadeIn();
|
|
|
|
var formData = new FormData($('#frm-company-file-add')[0]); // FormData 객체 생성
|
|
$.ajax({
|
|
cache : false,
|
|
url : "/html/process.html",
|
|
type : 'POST',
|
|
data : formData,
|
|
contentType: false,
|
|
processData: false,
|
|
dataType: 'json',
|
|
success : function(data) {
|
|
|
|
//console.log(data);
|
|
|
|
|
|
if(data.response == 'Success') {
|
|
|
|
$("#fileTable > tbody").empty(); // 파일입력폼 초기화
|
|
|
|
let fileData = data.data;
|
|
$.each(fileData, function(index, value) {
|
|
|
|
let FD = fileData[index];
|
|
let fileHtml = '';
|
|
|
|
if(index < 1){
|
|
$("#ComFileTable_"+FD.T_ID).empty(); // 파일리스트 초기화
|
|
}
|
|
|
|
fileHtml += '<div class="appendix">';
|
|
fileHtml += ' <a href="/html/download.html?file='+FD.R_NAME+'" target="_blank">'+FD.F_NAME+'</a> ';
|
|
fileHtml += ' <i class="fas fa-edit file-modify" aria-hidden="true" data-idx="'+FD.F_NO+'"></i>';
|
|
fileHtml += ' <i class="fa fa-minus-square file-delete" aria-hidden="true" data-idx="'+FD.F_NO+'"></i>';
|
|
fileHtml += '</div>';
|
|
|
|
$("#ComFileTable_"+FD.T_ID).append(fileHtml);
|
|
});
|
|
|
|
} else alert(data.response);
|
|
|
|
}, // success
|
|
|
|
error: function (xhr, status) {
|
|
alert(xhr + " : " + status);
|
|
}
|
|
}); // $.ajax */
|
|
|
|
|
|
$('#status').fadeOut();
|
|
$('#preloader').delay(100).fadeOut();
|
|
|
|
// 모달 닫기
|
|
closeModal();
|
|
})
|
|
/*** 업체관리 상세[E] ***/
|
|
|
|
//카드에 내용 보기
|
|
$(".btn-detail").on("click", function () {
|
|
let target = $(this).data('area');
|
|
$("#"+target).toggleClass('hidden');
|
|
})
|
|
|
|
// 업체명 검색
|
|
$('#com-search').on('input', function() {
|
|
var searchText = $(this).val().toLowerCase(); // 입력된 텍스트를 소문자로 변환
|
|
|
|
$('.com-title').each(function() {
|
|
var comTitleText = $(this).data('comtitle').toLowerCase(); // data-comtitle 값을 소문자로 변환
|
|
|
|
if (comTitleText.includes(searchText)) {
|
|
$(this).removeClass('hidden'); // 텍스트가 포함되면 hidden 클래스 제거
|
|
} else {
|
|
$(this).addClass('hidden'); // 텍스트가 포함되지 않으면 hidden 클래스 추가
|
|
}
|
|
});
|
|
});
|
|
|
|
// 업체 파일 검색
|
|
$('#com-file-search').on('input', function() {
|
|
let searchText = $(this).val().toLowerCase(); // 입력된 텍스트를 소문자로 변환
|
|
|
|
|
|
$('.com-title').addClass('hidden');
|
|
$('.com-file-title').each(function() {
|
|
let comFileTitleText = $(this).data('name').toLowerCase(); // data-comtitle 값을 소문자로 변환
|
|
|
|
if (comFileTitleText.includes(searchText)) {
|
|
$(this).removeClass('hidden'); // 텍스트가 포함되면 hidden 클래스 제거
|
|
$(this).parent().parent().removeClass('hidden');
|
|
} else {
|
|
$(this).addClass('hidden'); // 텍스트가 포함되지 않으면 hidden 클래스 추가
|
|
}
|
|
});
|
|
});
|
|
|
|
|
|
|
|
// 파일관리 - 파일 수정 화면
|
|
$(document).on("click",'.file-modify',function(e){
|
|
|
|
let refpage = "/html/company/customer_list.html";
|
|
let file_no = $(this).data('idx')
|
|
$('#file_no').val(file_no);
|
|
|
|
// 테이블 초기화
|
|
fno = 0;
|
|
$('#fileTable tbody tr').remove();
|
|
|
|
$(".file-add").trigger('click');
|
|
$("#myModal-company-file").show();
|
|
|
|
$(".file-add").hide();
|
|
$(".text-file-title").text("수정");
|
|
|
|
|
|
$.ajax({
|
|
cache : false,
|
|
url : "/html/process.html",
|
|
type : 'POST',
|
|
dataType: 'json',
|
|
data : {sidx:file_no,mod:'file-view',refpage:refpage },
|
|
success : function(data) {
|
|
|
|
//console.log(data);
|
|
|
|
if(data.response=='Success') {
|
|
|
|
let SF = data.data;
|
|
//console.log(SF);
|
|
|
|
$('input[name="fileType['+fno+']"]').val(SF.T_ID_TYPE);
|
|
$('input[name="fileName['+fno+']"]').val(SF.F_NAME);
|
|
|
|
}
|
|
else alert(data);
|
|
}, // success
|
|
|
|
error : function(xhr, status) {
|
|
alert(xhr + " : " + status);
|
|
}
|
|
}); // $.ajax */
|
|
|
|
})
|
|
|
|
}); |