$(window).load(function(){ // 타이틀변경 $(document).attr("title",'한국소비자원 참가격'+' 제조업체별 가격동향'); $("form").attr("onsubmit", "return false;"); if(($("#keyword").val()).length > 0){ var remake = ($("#keyword").val()).split(","); var remakename = ($("#keywordname").val()).split(","); var cnt = (remake.length)-1; for(var i = 0 ; i <= cnt ; i++){ fn_addRow(remake[i],remakename[i]); } } var sear = $("#Searchflag").val(); var term = $("#termflag").val(); //입력기간 if(term == 0){ $("#mon1").css("display",""); $("#mon2").css("display",""); $("#bon1").css("display","none"); $("#bon2").css("display","none"); $("#year1").css("display","none"); $("#year2").css("display","none"); $("#half1").css("display","none"); $("#half2").css("display","none"); }else if(term == 1){ $("#mon1").css("display","none"); $("#mon2").css("display","none"); $("#bon1").css("display",""); $("#bon2").css("display",""); $("#year1").css("display","none"); $("#year2").css("display","none"); $("#half1").css("display","none"); $("#half2").css("display","none"); }else if(term == 2){ $("#mon1").css("display","none"); $("#mon2").css("display","none"); $("#bon1").css("display","none"); $("#bon2").css("display","none"); $("#year1").css("display",""); $("#year2").css("display",""); $("#half1").css("display","none"); $("#half2").css("display","none"); }else if( term == 3){ $("#mon1").css("display","none"); $("#mon2").css("display","none"); $("#bon1").css("display","none"); $("#bon2").css("display","none"); $("#year1").css("display","none"); $("#year2").css("display","none"); $("#half1").css("display",""); $("#half2").css("display",""); } // 조건별 그리드 if(sear == '1' && term == '0' ){ $("#exceldn").css("display",""); $("#op1").css("display",""); $("#op4").css("display","none"); }else if(sear == '1' && term == '1'){ $("#exceldn").css("display",""); $("#op1").css("display",""); $("#op4").css("display","none"); }else if(sear == '1' && term == '2'){ $("#exceldn").css("display",""); $("#op1").css("display",""); $("#op4").css("display","none"); }else if(sear == '1' && term == '3'){ $("#exceldn").css("display",""); $("#op1").css("display",""); $("#op4").css("display","none"); }else if(sear == '0' && term == '0'){ $("#exceldn").css("display",""); $("#op1").css("display","none"); $("#op4").css("display",""); }else if(sear == '0' && term == '1'){ $("#exceldn").css("display",""); $("#op1").css("display","none"); $("#op4").css("display",""); }else if(sear == '0' && term == '2'){ $("#exceldn").css("display",""); $("#op1").css("display","none"); $("#op4").css("display",""); }else if(sear == '0' && term == '3'){ $("#exceldn").css("display",""); $("#op1").css("display","none"); $("#op4").css("display",""); } //개월 조정을 위한 부분 if(($("#categories").val()).length > 0){ var startbun = Number($("#startNum").val()); var endbun = Number($("#endNum").val()); var countbun = Number($("#countNum").val()); //alert(startbun); //alert(endbun); if(endbun > 5){ for(i = startbun ; i <= countbun ; i++){ $("[name="+i+"]").css("display",""); } if(endbun == countbun){ $("[name=prevGo]").show(); $("[name=nextGo]").hide(); $("[name=pre_btn]").show(); $("[name=next_btn]").hide(); }else if(startbun == 1){ $("[name=prevGo]").hide(); $("[name=nextGo]").show(); $("[name=pre_btn]").hide(); $("[name=next_btn]").show(); }else{ $("[name=prevGo]").show(); $("[name=nextGo]").show(); $("[name=pre_btn]").show(); $("[name=next_btn]").show(); } }else{ for(i=startbun ; i<= endbun ;i++){ $("[name="+i+"]").css("display",""); $("[name=prevGo]").hide(); $("[name=nextGo]").hide(); $("[name=pre_btn]").hide(); $("[name=next_btn]").hide(); } } } // 상품 대분류코드 fn_getCodeStatI("selectD","1","",$("#dflag").val()); // 상품 중분류코드 if($("#dflag").val() != ""){ fn_getCodeStatI("selectJ","2",$("#dflag").val(),$("#jflag").val()); } // 상품 소분류코드 if($("#jflag").val() != ""){ fn_getCodeStatI("selectS","3",$("#jflag").val(),$("#sflag").val()); } var viewflag = $("#viewflag").val(); if(viewflag == '3'){ $("#all").attr('class','btn_sort on'); $("#sall").attr('class','btn_sort'); $("#base").attr('class','btn_sort'); var title = $(document).attr("title") + " - 전체가격"; $(document).attr("title", title); }else if(viewflag == '1'){ $("#all").attr('class','btn_sort'); $("#sall").attr('class','btn_sort on'); $("#base").attr('class','btn_sort'); var title = $(document).attr("title") + " - 단위가격"; $(document).attr("title", title); }else if(viewflag == '0'){ $("#all").attr('class','btn_sort'); $("#sall").attr('class','btn_sort'); $("#base").attr('class','btn_sort on'); var title = $(document).attr("title") + " - 판매가격"; $(document).attr("title", title); } // 버튼 선택됨 표시 $('#exceldn a.btn_sort').each(function(){ var title = $(this).attr('title'); if($(this).hasClass('on')) { title += ' 선택됨'; } $(this).attr('title',title); }); $(function() { var aa = new Array(); var classCode = "PE"; $.ajax({ type:"POST", url: "/tprice/portal/pricetrend/dailynecessitypricetrend/selectEntp.do", data: "classCode="+classCode , dataType:"json", success:function(data){ var tr = data.json; $.each(tr, function(key){ aa.push(tr[key].codeName); } ); $( "#nflag" ).val(aa); }, failure:function(data){ } }); $( "#productEntpName" ).autocomplete({ source: aa }); }); }); $(document).ready(function(){ //페이지 UNIT 갯수 수정 $("#pageUnit").change(function() { $("#searchOrExcel").val("search"); var termflag = $("#termflag").val(); var Searchflag = $("#Searchflag").val(); var url = ""; if(Searchflag == '1' && termflag == '0'){ url = "/tprice/portal/pricetrend/dailynecessitypricetrend/getManufacTrendMList.do"; }else if(Searchflag == '0' && termflag == '0'){ url = "/tprice/portal/pricetrend/dailynecessitypricetrend/getManufacTrendMtomList.do"; }else if(Searchflag == '1' && termflag == '1'){ url = "/tprice/portal/pricetrend/dailynecessitypricetrend/getManufacTrendBList.do"; }else if(Searchflag == '0' && termflag == '1'){ url = "/tprice/portal/pricetrend/dailynecessitypricetrend/getManufacTrendBtobList.do"; }else if(Searchflag == '1' && termflag == '2'){ url = "/tprice/portal/pricetrend/dailynecessitypricetrend/getManufacTrendYList.do"; }else if(Searchflag == '0' && termflag == '2'){ url = "/tprice/portal/pricetrend/dailynecessitypricetrend/getManufacTrendYtoyList.do"; }else if(Searchflag == '1' && termflag == '3'){ url = "/tprice/portal/pricetrend/dailynecessitypricetrend/getManufacTrendHList.do"; }else if(Searchflag == '0' && termflag == '3'){ url = "/tprice/portal/pricetrend/dailynecessitypricetrend/getManufacTrendHtohList.do"; } // 프로그래스바 시작 fn_progressPop(); $("#listForm") .attr("action", url) .attr("onSubmit", "return true") .submit(); }); $("#productEntpName").keydown(function(e){ if(e.keyCode==13) { $("#img_addCom").trigger("click"); } }); $("input[type=checkbox]").click(function() { var intLength = $("input[type=checkbox]:checked").length; if(intLength > 5) { alert("차트보기 상품은 5개 까지 가능합니다."); $(this).attr("checked", false); return; } }); $("[name=prevGo]").click(function(){ var startbun = $("#startNum").val();//시작 var endbun = $("#endNum").val();//끝 var countbun = $("#countNum").val();//디스플레이 번호 var end = Number(endbun); var count = Number(countbun) - 1; var start = Number(startbun) - 1; if(count >4){ $("#countNum").val(count); $("#startNum").val(start); $("[name="+countbun+"]").css("display","none"); $("[name="+start+"]").css("display",""); } if(start == '1'){ $("[name=prevGo]").hide(); $("[name=pre_btn]").hide(); }else{ $("[name=prevGo]").show(); $("[name=pre_btn]").show(); } if(count == end){ $("[name=nextGo]").hide(); $("[name=next_btn]").hide(); }else { $("[name=nextGo]").show(); $("[name=next_btn]").show(); } }); $("[name=nextGo]").click(function(){ var startbun = $("#startNum").val(); var endbun = $("#endNum").val(); var countbun = $("#countNum").val(); var end = Number(endbun); var count = Number(countbun) + 1; var start = Number(startbun) + 1; //alert(startbun +"/"+ endbun +"/"+ countbun ); if( end >= count){ $("#countNum").val(count); $("#startNum").val(start); $("[name="+count+"]").css("display",""); $("[name="+startbun+"]").css("display","none"); } if(count == end){ $("[name=nextGo]").hide(); $("[name=next_btn]").hide(); }else{ $("[name=nextGo]").show(); $("[name=next_btn]").show(); } if(start > 1){ $("[name=prevGo]").show(); $("[name=pre_btn]").show(); }else{ $("[name=prevGo]").hide(); $("[name=pre_btn]").hide(); } }); $("#all").click(function(){ $("#viewflag").val("3"); $("#all").css('color','blue'); $("#search_btn").trigger("click"); }); $("#base").click(function(){ $("#viewflag").val("0"); $("#base").css('color','blue'); $("#search_btn").trigger("click"); }); $("#sall").click(function(){ $("#viewflag").val("1"); $("#sall").css('color','blue'); $("#search_btn").trigger("click"); }); // 중분류값 $("#selectD").change(function(){ $('#selectJ, #selectS, #selectP').find("option").each(function(){ $(this).remove(); }); $('#selectJ').append(""); $('#selectS').append(""); $('#selectP').append(""); var highCode = $(this).val(); if(highCode != '0'){ fn_getCodeStatI("selectJ","2",highCode,""); } }); // 소분류값 $("#selectJ").change(function(){ $('#selectS, #selectP').find("option").each(function(){ $(this).remove(); }); $('#selectS').append(""); $('#selectP').append(""); var highCode = $(this).val(); if(highCode != '0'){ fn_getCodeStatI("selectS","3",highCode,""); } }); // 조회조건 변경시 날짜 박스 컨트롤 $("[name=sear],[name=term]").change(function(){ var term = $("#term option:selected").val(); $("#termflag").val(term); if(term == 0){ $("#mon1").css("display",""); $("#mon2").css("display",""); $("#bon1").css("display","none"); $("#bon2").css("display","none"); $("#year1").css("display","none"); $("#year2").css("display","none"); $("#half1").css("display","none"); $("#half2").css("display","none"); $("#mon1").find('option:first').attr('selected', 'selected'); $("#mon2").find('option:first').attr('selected', 'selected'); }else if(term == 1){ $("#mon1").css("display","none"); $("#mon2").css("display","none"); $("#bon1").css("display",""); $("#bon2").css("display",""); $("#year1").css("display","none"); $("#year2").css("display","none"); $("#half1").css("display","none"); $("#half2").css("display","none"); $("#bon1").find('option:first').attr('selected', 'selected'); $("#bon2").find('option:first').attr('selected', 'selected'); }else if(term == 2){ $("#mon1").css("display","none"); $("#mon2").css("display","none"); $("#bon1").css("display","none"); $("#bon2").css("display","none"); $("#year1").css("display",""); $("#year2").css("display",""); $("#half1").css("display","none"); $("#half2").css("display","none"); $("#year1").find('option:first').attr('selected', 'selected'); $("#year2").find('option:first').attr('selected', 'selected'); }else if(term == 3){ $("#mon1").css("display","none"); $("#mon2").css("display","none"); $("#bon1").css("display","none"); $("#bon2").css("display","none"); $("#year1").css("display","none"); $("#year2").css("display","none"); $("#half1").css("display",""); $("#half2").css("display",""); $("#half1").find('option:first').attr('selected', 'selected'); $("#half2").find('option:first').attr('selected', 'selected'); } }); // $("#op1 thead tr th").click(function() { // $("#searchOrExcel").val("search"); // var orderColumn = $(this).attr("headers"); // var className = $(this).children("span").attr("class"); // var order = "DESC"; // if (className.indexOf("down") != -1) { // order = "ASC"; // } else { // order = "DESC"; // } // $("#orderColumn").val(orderColumn); // $("#order").val(order); // var termflag = $("#term option:selected").val(); // $("#termflag").val(termflag); // var Searchflag = $("#sear option:selected").val(); // $("#Searchflag").val(Searchflag); // var url =""; // if(Searchflag == '1' && termflag == '0'){ // url = "/tprice/portal/pricetrend/dailynecessitypricetrend/getManufacTrendMList.do"; // }else if(Searchflag == '0' && termflag == '0'){ // url = "/tprice/portal/pricetrend/dailynecessitypricetrend/getManufacTrendMtomList.do"; // }else if(Searchflag == '1' && termflag == '1'){ // url = "/tprice/portal/pricetrend/dailynecessitypricetrend/getManufacTrendBList.do"; // }else if(Searchflag == '0' && termflag == '1'){ // url = "/tprice/portal/pricetrend/dailynecessitypricetrend/getManufacTrendBtobList.do"; // }else if(Searchflag == '1' && termflag == '2'){ // url = "/tprice/portal/pricetrend/dailynecessitypricetrend/getManufacTrendYList.do"; // }else if(Searchflag == '0' && termflag == '2'){ // url = "/tprice/portal/pricetrend/dailynecessitypricetrend/getManufacTrendYtoyList.do"; // }else if(Searchflag == '1' && termflag == '3'){ // url = "/tprice/portal/pricetrend/dailynecessitypricetrend/getManufacTrendHList.do"; // }else if(Searchflag == '0' && termflag == '3'){ // url = "/tprice/portal/pricetrend/dailynecessitypricetrend/getManufacTrendHtohList.do"; // } // // $("#listForm") // .attr("action", url) // .attr("onSubmit", "return true") // .submit(); // }); // // $("#op4 thead tr th").click(function() { // $("#searchOrExcel").val("search"); // var orderColumn = $(this).attr("headers"); // var className = $(this).children("span").attr("class"); // var order = "DESC"; // if (className.indexOf("down") != -1) { // order = "ASC"; // } else { // order = "DESC"; // } // $("#orderColumn").val(orderColumn); // $("#order").val(order); // var termflag = $("#term option:selected").val(); // $("#termflag").val(termflag); // var Searchflag = $("#sear option:selected").val(); // $("#Searchflag").val(Searchflag); // var url =""; // if(Searchflag == '1' && termflag == '0'){ // url = "/tprice/portal/pricetrend/dailynecessitypricetrend/getManufacTrendMList.do"; // }else if(Searchflag == '0' && termflag == '0'){ // url = "/tprice/portal/pricetrend/dailynecessitypricetrend/getManufacTrendMtomList.do"; // }else if(Searchflag == '1' && termflag == '1'){ // url = "/tprice/portal/pricetrend/dailynecessitypricetrend/getManufacTrendBList.do"; // }else if(Searchflag == '0' && termflag == '1'){ // url = "/tprice/portal/pricetrend/dailynecessitypricetrend/getManufacTrendBtobList.do"; // }else if(Searchflag == '1' && termflag == '2'){ // url = "/tprice/portal/pricetrend/dailynecessitypricetrend/getManufacTrendYList.do"; // }else if(Searchflag == '0' && termflag == '2'){ // url = "/tprice/portal/pricetrend/dailynecessitypricetrend/getManufacTrendYtoyList.do"; // }else if(Searchflag == '1' && termflag == '3'){ // url = "/tprice/portal/pricetrend/dailynecessitypricetrend/getManufacTrendHList.do"; // }else if(Searchflag == '0' && termflag == '3'){ // url = "/tprice/portal/pricetrend/dailynecessitypricetrend/getManufacTrendHtohList.do"; // } // $("#listForm") // .attr("action", url) // .attr("onSubmit", "return true") // .submit(); // }); //조회 $("#search_btn").click(function(){ $("#searchOrExcel").val("search"); // 페이지 번호 초기화 $("[name=pageNo]").val("1"); $("#startNum").val("1"); $("#countNum").val("5"); // 검색조건 유지값 셋팅 var sflag = $("#selectS option:selected").val(); $("#sflag").val(sflag); var jflag = $("#selectJ option:selected").val(); $("#jflag").val(jflag); var dflag = $("#selectD option:selected").val(); $("#dflag").val(dflag); var termflag = $("#term option:selected").val(); $("#termflag").val(termflag); var termflag = $("#term option:selected").val(); $("#termflag").val(termflag); var Searchflag = $("#sear option:selected").val(); $("#Searchflag").val(Searchflag); var viewflag = $("#viewflag").val(); if(viewflag != '0' && viewflag != '1' && viewflag != '3'){ $("#viewflag").val("3"); } //조회업체 LIST 작성 var keyword = new Array(); var keywordname = new Array(); $("#ul_searchEntp li").each(function(i){ keyword.push($(this).children("#val").val()); keywordname.push($(this).children("#text").val()); }); $("#keyword").val(keyword); $("#keywordname").val(keywordname); if(termflag =='1'){ $("#datename").val("분기"); }else if(termflag =='3'){ $("#datename").val("반기"); }else if(termflag =='2'){ $("#datename").val("년"); }else{ $("#datename").val("월"); } var url =""; if(Searchflag == '1' && termflag == '0'){ url = "/tprice/portal/pricetrend/dailynecessitypricetrend/getManufacTrendMList.do"; }else if(Searchflag == '0' && termflag == '0'){ url = "/tprice/portal/pricetrend/dailynecessitypricetrend/getManufacTrendMtomList.do"; }else if(Searchflag == '1' && termflag == '1'){ url = "/tprice/portal/pricetrend/dailynecessitypricetrend/getManufacTrendBList.do"; }else if(Searchflag == '0' && termflag == '1'){ url = "/tprice/portal/pricetrend/dailynecessitypricetrend/getManufacTrendBtobList.do"; }else if(Searchflag == '1' && termflag == '2'){ url = "/tprice/portal/pricetrend/dailynecessitypricetrend/getManufacTrendYList.do"; }else if(Searchflag == '0' && termflag == '2'){ url = "/tprice/portal/pricetrend/dailynecessitypricetrend/getManufacTrendYtoyList.do"; }else if(Searchflag == '1' && termflag == '3'){ url = "/tprice/portal/pricetrend/dailynecessitypricetrend/getManufacTrendHList.do"; }else if(Searchflag == '0' && termflag == '3'){ url = "/tprice/portal/pricetrend/dailynecessitypricetrend/getManufacTrendHtohList.do"; } // 프로시그바 시작 fn_progressPop(); //월 기간셋팅 if(Searchflag == '1' && termflag == '0'){ var mon1 = $("#mon1 option:selected").val(); $("#monthS").val(mon1); var mon2 = $("#mon2 option:selected").val(); $("#monthE").val(mon2); var one1 = Number(mon1.substring(0,4)); var one2 = Number(mon1.substring(5,7)); $("#one").val(mon1); var gap = one1*12+one2; var two = $("#mon2 option:selected").val(); var two1 = Number(two.substring(0,4)); var two2 = Number(two.substring(5,7)); var Cnt = (two1*12+two2)-(one1*12+one2); $("#Cnt").val(Cnt); if(Cnt > 11){ alert("조회가능한 기간은 최대 12개월 입니다."); fn_progressPopClose(); }else if(Cnt < 0){ alert("선택하신 조회 종료월이 시작월의 이전 시점입니다."); fn_progressPopClose(); }else if(Cnt == 0){ alert("선택하신 입력월이 동일합니다. "); fn_progressPopClose(); } else { var arrid = new Array(); // var arryearval = new Array(); // var arrmonval = new Array(); // for(var i=1; i <=Cnt ; i++ ){ var searstart1 = Math.floor(((gap+i)/12)); var searstart2 = (gap+i)%12; var start =""; if(searstart2 == 1){ start = "-01"; }else if(searstart2 == 2){ start = "-02"; }else if(searstart2 == 3){ start = "-03"; }else if(searstart2 == 4){ start = "-04"; }else if(searstart2 == 5){ start = "-05"; }else if(searstart2 == 6){ start = "-06"; }else if(searstart2 == 7){ start = "-07"; }else if(searstart2 == 8){ start = "-08"; }else if(searstart2 == 9){ start = "-09"; }else if(searstart2 == 10){ start = "-10"; }else if(searstart2 == 11){ start = "-11"; }else if(searstart2 == 0){ start = "-12"; searstart1 = searstart1-1; } var startyearmon = String(searstart1)+start; // var yearval = String(searstart1); // var monval = start.substring(1,2); arrid.push(startyearmon); // arryearval.push(yearval); // arrmonval.push(monval); //alert(arrid); } $("#twelve").val(arrid[10]); $("#eleven").val(arrid[9]); $("#ten").val(arrid[8]); $("#nine").val(arrid[7]); $("#eight").val(arrid[6]); $("#seven").val(arrid[5]); $("#six").val(arrid[4]); $("#five").val(arrid[3]); $("#four").val(arrid[2]); $("#three").val(arrid[1]); $("#two").val(arrid[0]); var categories = new Array(); categories.push(mon1); for(var j =0 ; j <= Cnt-1 ; j++){ categories.push(arrid[j]); } $("#categories").val(categories); var endNum = categories.length; $("#endNum").val(endNum); $("#listForm") .attr("action", url) .attr("onSubmit", "return true") .submit(); } } //월 비교셋팅 else if (Searchflag == '0' && termflag == '0'){ var mon1 = $("#mon1 option:selected").val(); $("#monthS").val(mon1); var mon2 = $("#mon2 option:selected").val(); $("#monthE").val(mon2); if(mon1 != mon2){ $("#one").val($("#mon1 option:selected").val()); $("#two").val($("#mon2 option:selected").val()); var categories = new Array(); categories.push(mon1); categories.push(mon2); $("#categories").val(categories); var endNum = categories.length; $("#endNum").val(endNum); $("#listForm") .attr("action", url) .attr("onSubmit", "return true") .submit(); }else{ alert("선택 월이 동일합니다."); fn_progressPopClose(); } } //분기 기간셋팅 else if (Searchflag == '1' && termflag == '1'){ var bon1 = $("#bon1 option:selected").val(); $("#monthS").val(bon1); var bon2 = $("#bon2 option:selected").val(); $("#monthE").val(bon2); var one = $("#bon1 option:selected").val(); $("#one").val(one); var last = $("#bon2 option:selected").val(); var one1 = Number(one.substring(0,4)); var one2 = Number(one.substring(5,6)); var last1 = Number(last.substring(0,4)); var last2 = Number(last.substring(5,6)); // var oneb = String(one1)+String(one2); var gap = one1*4+one2; var Cnt = (last1*4+last2)-(one1*4+one2); $("#Cnt").val(Cnt); if(Cnt > 7){ alert("조회가능한 분기는 최대 8분기 입니다."); fn_progressPopClose(); }else if(Cnt < 0){ alert("선택하신 조회 분기가 시작분기 이전 시점입니다."); fn_progressPopClose(); }else if(Cnt == 0){ alert("선택하신 분기가 동일합니다. "); fn_progressPopClose(); }else { var arrid = new Array(); for(var i=1; i <=Cnt ; i++ ){ var searstart1 = Math.floor(((gap+i)/4)); var searstart2 = (gap+i)%4; var start =""; if(searstart2 == 1){ start = "-1"; }else if(searstart2 == 2){ start = "-2"; }else if(searstart2 == 3){ start = "-3"; }else if(searstart2 == 0){ start = "-4"; searstart1 = searstart1-1; } var startyearmon = String(searstart1)+start; arrid.push(startyearmon); } $("#eight").val(arrid[6]); $("#seven").val(arrid[5]); $("#six").val(arrid[4]); $("#five").val(arrid[3]); $("#four").val(arrid[2]); $("#three").val(arrid[1]); $("#two").val(arrid[0]); var categories = new Array(); categories.push(bon1); for(var j =0 ; j <= Cnt-1 ; j++){ categories.push(arrid[j]); } $("#categories").val(categories); var endNum = categories.length; $("#endNum").val(endNum); $("#listForm") .attr("action", url) .attr("onSubmit", "return true") .submit(); } } //분기 비교셋팅 else if (Searchflag == '0' && termflag == '1'){ var bon1 = $("#bon1 option:selected").val(); $("#monthS").val(bon1); var bon2 = $("#bon2 option:selected").val(); $("#monthE").val(bon2); $("#one").val(bon1); $("#two").val(bon2); if(bon1 != bon2){ var categories = new Array(); categories.push(bon1); categories.push(bon2); $("#categories").val(categories); var endNum = categories.length; $("#endNum").val(endNum); $("#listForm") .attr("action", url) .attr("onSubmit", "return true") .submit(); }else{ alert("선택한 분기가 동일합니다."); fn_progressPopClose(); } } // 년 비교 셋팅 else if (Searchflag == '0' && termflag == '2'){ var year1 = $("#year1 option:selected").val(); $("#monthS").val(year1); var year2 = $("#year2 option:selected").val(); $("#monthE").val(year2); if(year1 != year2){ var one = $("#year1 option:selected").val(); $("#one").val(one); var two = $("#year2 option:selected").val(); $("#two").val(two); var categories = new Array(); categories.push(one); categories.push(two); $("#categories").val(categories); var endNum = categories.length; $("#endNum").val(endNum); $("#listForm") .attr("action", url) .attr("onSubmit", "return true") .submit(); }else{ alert("선택한 년도가 동일합니다."); fn_progressPopClose(); } } // 년 기간 셋팅 else if (Searchflag == '1' && termflag == '2'){ var year1 = $("#year1 option:selected").val(); $("#monthS").val(year1); var year2 = $("#year2 option:selected").val(); $("#monthE").val(year2); $("#one").val(year1); var one1 = Number(year1); var one2 = Number(year2); var Cnt = one2-one1; $("#Cnt").val(Cnt); if(Cnt > 3){ alert("조회가능한 년도는 최대 4년도 입니다."); fn_progressPopClose(); }else if(Cnt < 0){ alert("선택하신 조회 년도가 시작년도 이전 시점입니다."); fn_progressPopClose(); }else if(Cnt == 0){ alert("선택하신 년도가 동일합니다. "); fn_progressPopClose(); } else { var arrmon = new Array(); var categories = new Array(); categories.push(year1); for(var i=1 ; i <= Cnt ; i++){ arrmon.push(one1+i); categories.push(one1+i); } $("#four").val(arrmon[2]); $("#three").val(arrmon[1]); $("#two").val(arrmon[0]); $("#categories").val(categories); var endNum = categories.length; $("#endNum").val(endNum); $("#listForm") .attr("action", url) .attr("onSubmit", "return true") .submit(); } } //반기 기간셋팅 else if (Searchflag == '1' && termflag == '3'){ var half1 = $("#half1 option:selected").val(); $("#monthS").val(half1); var half2 = $("#half2 option:selected").val(); $("#monthE").val(half2); var one = $("#half1 option:selected").val(); $("#one").val(one); var last = $("#half2 option:selected").val(); var one1 = Number(one.substring(0,4)); var one2 = Number(one.substring(5,6)); var last1 = Number(last.substring(0,4)); var last2 = Number(last.substring(5,6)); // var oneb = String(one1)+String(one2); var gap = one1*2+one2; var Cnt = (last1*2+last2)-(one1*2+one2); $("#Cnt").val(Cnt); if(Cnt > 7){ alert("조회가능한 (상/하)반기는 최대 8(상/하)반기 입니다."); fn_progressPopClose(); }else if(Cnt < 0){ alert("선택하신 조회 (상/하)반기가 시작(상/하)반기 이전 시점입니다."); fn_progressPopClose(); }else if(Cnt == 0){ alert("선택하신 (상/하)반기가 동일합니다. "); fn_progressPopClose(); } else { var arrid = new Array(); for(var i=1; i <=Cnt ; i++ ){ var searstart1 = Math.floor(((gap+i)/2)); var searstart2 = (gap+i)%2; var start =""; if(searstart2 == 1){ start = "-1"; }else if(searstart2 == 0){ start = "-2"; searstart1 = searstart1-1; } var startyearmon = String(searstart1)+start; arrid.push(startyearmon); } $("#eight").val(arrid[6]); $("#seven").val(arrid[5]); $("#six").val(arrid[4]); $("#five").val(arrid[3]); $("#four").val(arrid[2]); $("#three").val(arrid[1]); $("#two").val(arrid[0]); var categories = new Array(); categories.push(half1); for(var j =0 ; j <= Cnt-1 ; j++){ categories.push(arrid[j]); } $("#categories").val(categories); var endNum = categories.length; $("#endNum").val(endNum); $("#listForm") .attr("action", url) .attr("onSubmit", "return true") .submit(); } } //반기 비교셋팅 else if (Searchflag == '0' && termflag == '3'){ var half1 = $("#half1 option:selected").val(); $("#monthS").val(half1); var half2 = $("#half2 option:selected").val(); $("#monthE").val(half2); if(half1 == half2){ alert("선택한 (상/하)반기가 동일합니다."); fn_progressPopClose(); }else{ $("#one").val(half1); $("#two").val(half2); var categories = new Array(); categories.push(half1); categories.push(half2); $("#categories").val(categories); var endNum = categories.length; $("#endNum").val(endNum); $("#listForm") .attr("action", url) .attr("onSubmit", "return true") .submit(); } } }); //엑셀버튼 $("#btn_excelDownload").click(function(){ // 조회, 엑셀다운 구분자 $("#searchOrExcel").val("excel"); var termflag = $("#term option:selected").val(); $("#termflag").val(termflag); var Searchflag = $("#sear option:selected").val(); $("#Searchflag").val(Searchflag); var url =""; if(Searchflag == '1' && termflag == '0'){ url = "/tprice/portal/pricetrend/dailynecessitypricetrend/getManufacTrendMList.do"; }else if(Searchflag == '0' && termflag == '0'){ url = "/tprice/portal/pricetrend/dailynecessitypricetrend/getManufacTrendMtomList.do"; }else if(Searchflag == '1' && termflag == '1'){ url = "/tprice/portal/pricetrend/dailynecessitypricetrend/getManufacTrendBList.do"; }else if(Searchflag == '0' && termflag == '1'){ url = "/tprice/portal/pricetrend/dailynecessitypricetrend/getManufacTrendBtobList.do"; }else if(Searchflag == '1' && termflag == '2'){ url = "/tprice/portal/pricetrend/dailynecessitypricetrend/getManufacTrendYList.do"; }else if(Searchflag == '0' && termflag == '2'){ url = "/tprice/portal/pricetrend/dailynecessitypricetrend/getManufacTrendYtoyList.do"; }else if(Searchflag == '1' && termflag == '3'){ url = "/tprice/portal/pricetrend/dailynecessitypricetrend/getManufacTrendHList.do"; }else if(Searchflag == '0' && termflag == '3'){ url = "/tprice/portal/pricetrend/dailynecessitypricetrend/getManufacTrendHtohList.do"; } $("#listForm") .attr("action", url) .attr("onSubmit", "return true") .submit(); }); // 선택업체 추가버튼 $("#img_addCom").click(function(){ var selVal = $("#productEntpName").val(); var selText = $("#productEntpName").val(); var chekval = $("#productEntpName").val(); var ckeList1 = $("#nflag").val(); //var checklen = selVal.length ; var ckeList= ckeList1.split(','); var j = 0; for(var i = 0 ;i<=ckeList.length ;i++){ if(chekval==ckeList[i]){ j++; } } var hasEntpId = false; if(j==0){ alert("입력하신 제조업체명이 없습니다. 확인해 주세요!"); hasEntpId = true; } if(selVal != "0"){ // 추가된 판매업체중에 같은 판매업체가 있는지 확인 $("#ul_searchEntp li").each(function(k){ if($("[id=val]").eq(k).val() == selVal){ alert("이미 등록된 상품 입니다."); hasEntpId = true; } }); if( !hasEntpId ){ fn_addRow(selVal, selText); } } }); // 삭제버튼 클릭 $("table").delegate("[name=img_delCom]", "click", function(){ fn_delRow( $("[name=img_delCom]").index(this) ); }); }); //제조업체 TABLE 추가 function fn_addRow(selVal, selText){ var appendHtml = ""; appendHtml = "