173 lines
3.8 KiB
JavaScript
173 lines
3.8 KiB
JavaScript
let files = [];
|
|
|
|
$(document).on('click', '#addPartInfo', function (){
|
|
$.ajax({
|
|
url: '/target/partInfoEditModal',
|
|
type: 'GET',
|
|
dataType:"html",
|
|
success: function(html){
|
|
$("#partInfoEditModalEditModalContent").empty().append(html);
|
|
$("#partInfoEditModal").modal('show');
|
|
$("#rentPrice").hide();
|
|
$("#utilityPrice").hide();
|
|
setUploadDiv();
|
|
},
|
|
error:function(){
|
|
|
|
}
|
|
});
|
|
})
|
|
|
|
$(document).on('change', '#rentType', function (){
|
|
if($("#rentType").val() == 'Y'){
|
|
$("#rentPrice").show();
|
|
}else{
|
|
$("#rentPrice").hide();
|
|
$("#rentPrice").val('');
|
|
}
|
|
});
|
|
|
|
$(document).on('change', '#utilityType', function (){
|
|
if($("#utilityType").val() == 'Y'){
|
|
$("#utilityPrice").show();
|
|
}else{
|
|
$("#utilityPrice").hide();
|
|
$("#utilityPrice").val('');
|
|
}
|
|
});
|
|
|
|
$(document).on('change', '#mgtOrgan', function (){
|
|
const ogCd = $(this).val();
|
|
if(ogCd != ''){
|
|
$.ajax({
|
|
url: '/target/partInfoSelecBox',
|
|
data: {
|
|
ogCd,
|
|
},
|
|
type: 'GET',
|
|
dataType:"html",
|
|
success: function(html){
|
|
$("#piUserSeq").empty().append(html);
|
|
$("#piUserSeq").prop('disabled',false);
|
|
},
|
|
error:function(){
|
|
}
|
|
});
|
|
}else{
|
|
$("#piUserSeq").prop('disabled',true);
|
|
$("#piUserSeq").val('');
|
|
}
|
|
});
|
|
|
|
$(document).on('click', '#savePartInfo', function (){
|
|
if($("#rentType").val() == 'Y'){
|
|
if($("#rentPrice").val() == ''){
|
|
alert("임차료를 입력해주세요.");
|
|
$('#rentPrice').focus();
|
|
return false;
|
|
}
|
|
}
|
|
if($("#utilityType").val() == 'Y'){
|
|
if($("#utilityPrice").val() == ''){
|
|
alert("공공요금을 입력해주세요.");
|
|
$('#utilityPrice').focus();
|
|
return false;
|
|
}
|
|
}
|
|
if(confirm("저장하시겠습니까?")){
|
|
contentFade("in");
|
|
const formData = new FormData($("#partInfoSave")[0]);
|
|
for(const file of files) {
|
|
if(!file.isDelete)
|
|
formData.append('uploadFiles', file, file.name);
|
|
}
|
|
$.ajax({
|
|
type : 'POST',
|
|
data : formData,
|
|
url : "/target/savePartInfo",
|
|
processData: false,
|
|
contentType: false,
|
|
success : function(result) {
|
|
alert("저장되었습니다.");
|
|
contentFade("out");
|
|
location.reload();
|
|
},
|
|
error : function(xhr, status) {
|
|
alert("저장에 실패하였습니다.")
|
|
contentFade("out");
|
|
}
|
|
})
|
|
}
|
|
})
|
|
|
|
$(document).on('click', '.partInfoTr', function (){
|
|
const piSeq = (Number($(this).find(".piSeq").val()));
|
|
const versionNo = (Number($(this).find(".verNo").val()));
|
|
const url = '/target/updatePartInfoPage';
|
|
showModal(piSeq,versionNo,url);
|
|
})
|
|
|
|
function showModal(piSeq,versionNo,url){
|
|
$.ajax({
|
|
url: url,
|
|
data: {
|
|
piSeq: piSeq,
|
|
versionNo: versionNo
|
|
},
|
|
type: 'GET',
|
|
dataType:"html",
|
|
success: function(html){
|
|
$("#partInfoEditModalEditModalContent").empty().append(html);
|
|
$("#partInfoEditModal").modal('show');
|
|
if($("#mRentType").val() != 'Y'){
|
|
$("#mRentPrice").hide();
|
|
}
|
|
if($("#mUtilityType").val() != 'Y'){
|
|
$("#mUtilityPrice").hide();
|
|
}
|
|
setUploadDiv();
|
|
},
|
|
error:function(){
|
|
|
|
}
|
|
});
|
|
}
|
|
|
|
$(function(){
|
|
$("#startDate").datepicker({
|
|
format: "yyyy-mm-dd",
|
|
language: "ko"
|
|
});
|
|
})
|
|
|
|
$(document).on('click', '#goExcel', function (){
|
|
if(confirm("엑셀로 다운로드 하시겠습니까?")){
|
|
$('input[name=excel]').val('Y');
|
|
$('#searchFm').submit();
|
|
$('input[name=excel]').val('');
|
|
}else{
|
|
false;
|
|
}
|
|
})
|
|
|
|
$(document).on('change', '#mRentType', function (){
|
|
if($("#mRentType").val() == 'Y'){
|
|
$("#mRentPrice").show();
|
|
}else{
|
|
$("#mRentPrice").hide();
|
|
$("#mRentPrice").val('');
|
|
}
|
|
});
|
|
|
|
$(document).on('change', '#mUtilityType', function (){
|
|
if($("#mUtilityType").val() == 'Y'){
|
|
$("#mUtilityPrice").show();
|
|
}else{
|
|
$("#mUtilityPrice").hide();
|
|
$("#mUtilityPrice").val('');
|
|
}
|
|
});
|
|
|
|
|
|
|