$(window).load(function(){ // 타이틀변경 $(document).attr("title",'한국소비자원 참가격'+' 지역별 가격동향'); if(($("#keyword").val()).length > 0){ var remake = ($("#keyword").val()).split(","); var remakename = ($("#keywordname").val()).split(","); //alert(remake.length); var cnt = (remake.length)-1; for(var i = 0 ; i <= cnt ; i++){ fn_addRow(remake[i],remakename[i]); } } var term = $("#termflag").val(); var lflag = $("#lflag").val(); //입력기간 if(term == 0){ $("#mon1").css("display",""); $("#bon1").css("display","none"); $("#year1").css("display","none"); $("#half1").css("display","none"); }else if(term == 1){ $("#mon1").css("display","none"); $("#bon1").css("display",""); $("#year1").css("display","none"); $("#half1").css("display","none"); }else if(term == 2){ $("#mon1").css("display","none"); $("#bon1").css("display","none"); $("#year1").css("display",""); $("#half1").css("display","none"); }else if(term == 3){ $("#mon1").css("display","none"); $("#bon1").css("display","none"); $("#year1").css("display","none"); $("#half1").css("display",""); } // 조건별 그리드 if(term == '0' && lflag == '0' ){ $("#exceldn").css("display",""); $("#op1").css("display",""); $("#op2").css("display","none"); }else if(term == '1' && lflag == '0' ){ $("#exceldn").css("display",""); $("#op1").css("display",""); $("#op2").css("display","none"); }else if(term == '2' && lflag == '0' ){ $("#exceldn").css("display",""); $("#op1").css("display",""); $("#op2").css("display","none"); }else if(term == '3' && lflag == '0' ){ $("#exceldn").css("display",""); $("#op1").css("display",""); $("#op2").css("display","none"); }else if(lflag != '0'){ $("#exceldn").css("display",""); $("#op1").css("display","none"); $("#op2").css("display",""); } // 지역코드 설정 fn_getCodeStat("", "020000000", "larea", $("#lflag").val(),""); // 업태코드 설정 fn_getCodeStat("BU", "", "upteabox", $("#upteaflag").val()); // 상품 대분류코드 fn_getCodeStatI("selectD","1","",$("#dflag").val(),""); // 상품 중분류코드 if($("#dflag").val() != ""){ fn_getCodeStatI("selectJ","2",$("#dflag").val(),$("#jflag").val(),""); }else{ $("#selectD").trigger('change'); } // 상품 소분류코드 if($("#jflag").val() != ""){ fn_getCodeStatI("selectS","3",$("#jflag").val(),$("#sflag").val()); }else{ $("#selectJ").trigger('change'); } // 상품 코드 if($("#sflag").val() != ""){ fn_getCodeTGood($("#sflag").val(), "selectP", ""); } var searchManu = $("#searchManu").val(); if(searchManu == '1'){ $("[name=search1]").hide(); $("#menu1").attr('class','on'); $("#menu2").attr('class',''); }else if (searchManu == '2'){ $("[name=search1]").show(); $("#menu1").attr('class',''); $("#menu2").attr('class','on'); } 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); }); //개월 조정을 위한 부분 var startbun = Number($("#startNum").val()); var endbun = Number($("#endNum").val()); var countbun = Number($("#countNum").val()); //alert(startbun); //alert(countbun); if(endbun > 6){ for(i = startbun ; i <= countbun ; i++){ $("[name="+i+"]").css("display",""); } if(countbun == endbun){ $("[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<= countbun ;i++){ $("[name="+i+"]").css("display",""); } $("[name=prevGo]").hide(); $("[name=nextGo]").hide(); $("[name=pre_btn]").hide(); $("[name=next_btn]").hide(); } }); $(document).ready(function(){ //페이지 UNIT 갯수 수정 $("#pageUnit").change(function() { $("#searchOrExcel").val("search"); var termflag = $("#termflag").val(); var lflag = $("#lflag").val(); var url = ""; if(termflag == '0' && lflag == '0'){ url = "/tprice/portal/pricetrend/dailynecessitypricetrend/getAreaTrendMList.do"; }else if(termflag == '0' && lflag != '0'){ url = "/tprice/portal/pricetrend/dailynecessitypricetrend/getAreaTrendOneMList.do"; }else if(termflag == '1' && lflag == '0'){ url = "/tprice/portal/pricetrend/dailynecessitypricetrend/getAreaTrendBList.do"; }else if(termflag == '1' && lflag != '0'){ url = "/tprice/portal/pricetrend/dailynecessitypricetrend/getAreaTrendOneBList.do"; }else if(termflag == '2' && lflag == '0'){ url = "/tprice/portal/pricetrend/dailynecessitypricetrend/getAreaTrendYList.do"; }else if(termflag == '2' && lflag != '0'){ url = "/tprice/portal/pricetrend/dailynecessitypricetrend/getAreaTrendOneYList.do"; }else if(termflag == '3' && lflag == '0'){ url = "/tprice/portal/pricetrend/dailynecessitypricetrend/getAreaTrendHList.do"; }else if(termflag == '3' && lflag != '0'){ url = "/tprice/portal/pricetrend/dailynecessitypricetrend/getAreaTrendOneHList.do"; } // 프로그래스바 시작 fn_progressPop(); $("#listForm") .attr("action", url) .attr("onSubmit", "return true") .submit(); }); $("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 >5){ $("#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"); }); $("#menu1").click(function(){ $("#searchManu").val("1"); $("#menu1").attr('class','on'); $("#menu2").attr('class',''); $("#ul_searchGood li").remove(); $("[name=search1]").hide(); $('#menu1 a').attr('title', $('#menu1 a').text() + ' 선택됨'); $('#menu2 a').attr('title', $('#menu2 a').text()); }); $("#menu2").click(function(){ $("#searchManu").val("2"); $("#menu1").attr('class',''); $("#menu2").attr('class','on'); $("[name=search1]").show(); $('#menu1 a').attr('title', $('#menu1 a').text()); $('#menu2 a').attr('title', $('#menu2 a').text() + ' 선택됨'); }); // 중분류값 $("#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,""); } }); // 상품값 $("#selectS").change(function(){ $('#selectP').find("option").each(function(){ $(this).remove(); }); var goodSmlclsCode = $(this).val(); fn_getCodeTGood(goodSmlclsCode, "selectP",""); }); // 조회조건 변경시 날짜 박스 컨트롤 $("[name=term]").change(function(){ // var sear = $("#sear option:selected").val(); // $("#Searchflag").val(sear); var term = $("#term option:selected").val(); $("#termflag").val(term); if(term == 0){ $("#mon1").css("display",""); $("#bon1").css("display","none"); $("#year1").css("display","none"); $("#half1").css("display","none"); $("#mon1").find('option:first').attr('selected', 'selected'); }else if(term == 1){ $("#mon1").css("display","none"); $("#bon1").css("display",""); $("#year1").css("display","none"); $("#half1").css("display","none"); $("#bon1").find('option:first').attr('selected', 'selected'); }else if(term == 2){ $("#mon1").css("display","none"); $("#bon1").css("display","none"); $("#year1").css("display",""); $("#half1").css("display","none"); $("#year1").find('option:first').attr('selected', 'selected'); }else if(term == 3){ $("#mon1").css("display","none"); $("#bon1").css("display","none"); $("#year1").css("display","none"); $("#half1").css("display",""); $("#half1").find('option:first').attr('selected', 'selected'); } }); //조회 $("#search_btn").click(function(){ $("#searchOrExcel").val("search"); // 페이지 번호 초기화 $("[name=pageNo]").val("1"); $("#startNum").val("1"); $("#countNum").val("6"); $("#endNum").val("16"); // 검색조건 유지값 셋팅 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 lflag = $("#larea option:selected").val(); $("#lflag").val(lflag); var upteaflag = $("#upteabox option:selected").val(); $("#upteaflag").val(upteaflag); var upteaname = $("#upteabox option:selected").text(); $("#upteaname").val(upteaname); var viewflag = $("#viewflag").val(); if(viewflag != '0' && viewflag != '1' && viewflag != '3'){ $("#viewflag").val("3"); } //조회상품 LIST 작성 var keyword = new Array(); var keywordname = new Array(); $("#ul_searchGood li").each(function(i){ keyword.push($(this).children("#val").val()); //alert(keyword); keywordname.push($(this).children("#text").val()); }); $("#keyword").val(keyword); $("#keywordname").val(keywordname); var url =""; if(termflag == '0' && lflag == '0'){ url = "/tprice/portal/pricetrend/dailynecessitypricetrend/getAreaTrendMList.do"; }else if(termflag == '0' && lflag != '0'){ url = "/tprice/portal/pricetrend/dailynecessitypricetrend/getAreaTrendOneMList.do"; }else if(termflag == '1' && lflag == '0'){ url = "/tprice/portal/pricetrend/dailynecessitypricetrend/getAreaTrendBList.do"; }else if(termflag == '1' && lflag != '0'){ url = "/tprice/portal/pricetrend/dailynecessitypricetrend/getAreaTrendOneBList.do"; }else if(termflag == '2' && lflag == '0'){ url = "/tprice/portal/pricetrend/dailynecessitypricetrend/getAreaTrendYList.do"; }else if(termflag == '2' && lflag != '0'){ url = "/tprice/portal/pricetrend/dailynecessitypricetrend/getAreaTrendOneYList.do"; }else if(termflag == '3' && lflag == '0'){ url = "/tprice/portal/pricetrend/dailynecessitypricetrend/getAreaTrendHList.do"; }else if(termflag == '3' && lflag != '0'){ url = "/tprice/portal/pricetrend/dailynecessitypricetrend/getAreaTrendOneHList.do"; } // 프로시그바 시작 fn_progressPop(); //월 조회 if( termflag == '0' && lflag =='0'){ var mon1 = $("#mon1 option:selected").val(); $("#monthS").val(mon1); var mons = mon1.substring(0,4)+mon1.substring(5,7); $("#one").val(mons); $("#listForm") .attr("action", url) .attr("onSubmit", "return true") .submit(); } //지역+월 조회 if( termflag == '0' && lflag !='0'){ var mon1 = $("#mon1 option:selected").val(); $("#monthS").val(mon1); var mons = mon1.substring(0,4)+mon1.substring(5,7); $("#one").val(mons); $("#listForm") .attr("action", url) .attr("onSubmit", "return true") .submit(); } //분기 조회 else if (termflag == '1' && lflag =='0'){ var bon1 = $("#bon1 option:selected").val(); $("#monthS").val(bon1); $("#one").val(bon1); $("#listForm") .attr("action", url) .attr("onSubmit", "return true") .submit(); } //분기+지역 조회 else if (termflag == '1' && lflag !='0'){ var bon1 = $("#bon1 option:selected").val(); $("#monthS").val(bon1); $("#one").val(bon1); $("#listForm") .attr("action", url) .attr("onSubmit", "return true") .submit(); } // 년 셋팅 else if (termflag == '2' && lflag =='0'){ var year1 = $("#year1 option:selected").val(); $("#monthS").val(year1); $("#one").val(year1); $("#listForm" ) .attr("action", url) .attr("onSubmit", "return true") .submit(); } // 년+지역 셋팅 else if (termflag == '2' && lflag !='0'){ var year1 = $("#year1 option:selected").val(); $("#monthS").val(year1); $("#one").val(year1); $("#listForm") .attr("action", url) .attr("onSubmit", "return true") .submit(); } // 반기 셋팅 else if (termflag == '3' && lflag =='0'){ var half1 = $("#half1 option:selected").val(); $("#monthS").val(half1); $("#one").val(half1); var halfyy = Number(half1.substring(0,4)); var halfbb = Number(half1.substring(5,6)); if(halfbb == 1){ var name = halfyy+"-상반기"; $("#monthE").val(name); }else if(halfbb == 2){ var name = halfyy+"-하반기"; $("#monthE").val(name); } $("#listForm") .attr("action", url) .attr("onSubmit", "return true") .submit(); } //반기+지역 else if (termflag == '3' && lflag !='0'){ var half1 = $("#half1 option:selected").val(); $("#monthS").val(half1); $("#one").val(half1); var halfyy = Number(half1.substring(0,4)); var halfbb = Number(half1.substring(5,6)); if(halfbb == 1){ var name = halfyy+"-상반기"; $("#monthE").val(name); }else if(halfbb == 2){ var name = halfyy+"-하반기"; $("#monthE").val(name); } $("#listForm") .attr("action", url) .attr("onSubmit", "return true") .submit(); } }); // 지역선택 $("#larea").change(function(){ $("#larea option:selected").each(function(i){ var lflag = $(this).val(); var lname = $(this).text(); $("#lflag").val(lflag); $("#lname").val(lname); }); }); // 상품 추가 버튼 $("#img_addCom").click(function(){ $("#selectP option:selected").each(function(i){ var hasEntpId = false; var selVal = $(this).val(); var selText = $(this).text(); if(selVal != "0"){ // 추가된 판매업체중에 같은 판매업체가 있는지 확인 $("#ul_searchGood li").each(function(k){ if($("[id=val]").eq(k).val() == selVal){ alert("이미 등록된 상품 입니다."); hasEntpId = true; } }); if( !hasEntpId ){ fn_addRow(selVal, selText); } }else{ alert("상품을 선택해 주세요!"); } }); }); // 상품 삭제버튼 클릭 $("table").delegate(".img_delCom", "click", function(){ fn_delRow( $(".img_delCom").index(this) ); }); $("#btn_excelDownload").click(function(){ // 조회, 엑셀다운 구분자 $("#searchOrExcel").val("excel"); var termflag = $("#termflag").val(); var lflag = $("#lflag").val(); var url =""; if(termflag == '0' && lflag == '0'){ url = "/tprice/portal/pricetrend/dailynecessitypricetrend/getAreaTrendMList.do"; }else if(termflag == '0' && lflag != '0'){ url = "/tprice/portal/pricetrend/dailynecessitypricetrend/getAreaTrendOneMList.do"; }else if(termflag == '1' && lflag == '0'){ url = "/tprice/portal/pricetrend/dailynecessitypricetrend/getAreaTrendBList.do"; }else if(termflag == '1' && lflag != '0'){ url = "/tprice/portal/pricetrend/dailynecessitypricetrend/getAreaTrendOneBList.do"; }else if(termflag == '2' && lflag == '0'){ url = "/tprice/portal/pricetrend/dailynecessitypricetrend/getAreaTrendYList.do"; }else if(termflag == '2' && lflag != '0'){ url = "/tprice/portal/pricetrend/dailynecessitypricetrend/getAreaTrendOneYList.do"; }else if(termflag == '3' && lflag == '0'){ url = "/tprice/portal/pricetrend/dailynecessitypricetrend/getAreaTrendHList.do"; }else if(termflag == '3' && lflag != '0'){ url = "/tprice/portal/pricetrend/dailynecessitypricetrend/getAreaTrendOneHList.do"; } $("#listForm") .attr("action", url) .attr("onSubmit", "return true") .submit(); }); }); //상품 추가 function fn_addRow(selVal, selText){ var appendHtml = ""; appendHtml = "