/*
* 작성자 : 전종원
* 작성일 : 2014-09-03
* 설명 : 생필품 할인정보
*/
var assistGoodName = new Array(); //품목
var assistGoodName2 = new Array(); //상품
$(document).ready(function(){
// 타이틀변경
$(document).attr("title",'한국소비자원 참가격'+' 생필품할인정보');
//$("#btn_excelDownload").focus();
$.ajax({
type:"POST",
url:"/tprice/portal/saleinfo/saleinfo/getAssistWords.do",
dayaType:"json",
success:function(data) {
goodName = data.goodNames;
$.each(goodName, function(key) {
assistGoodName.push(goodName[key].goodName);
});
}, failure:function(data) {
}
});
$.ajax({
type:"POST",
url:"/tprice/portal/saleinfo/saleinfo/getAssistWords2.do",
dayaType:"json",
success:function(data) {
goodName = data.goodNames;
$.each(goodName, function(key) {
assistGoodName2.push(goodName[key].goodName);
});
}, failure:function(data) {
}
});
// 조사연도 설정
$("#inspectYear option").each(function(){
$(this).remove();
});
$.ajax({
type:"POST",
url: "/tprice/common/code/getInspectYear.do",
data: "",
dataType:"json",
success:function(data){
var codeData = data.json;
$.each(codeData, function(i){
if(codeData[i].CODE == $("#hid_inspectYear").val()){
$("#inspectYear").append("");
}
else{
$("#inspectYear").append("");
}
});
// 조사월 조회 호출
fn_getInspectMonth($("#inspectYear").val(), fn_getInspectDay);
},
failure:function(data){}
});
// 조사연도 변경
$("#inspectYear").change(function(){
// 조사월 조회 호출
fn_getInspectMonth($(this).val(), fn_getInspectDay);
});
// 조사월 변경
$("#inspectMonth").change(function(){
// 조사일 조회 호출
fn_getInspectDay($("#inspectYear").val(), $(this).val());
});
// 지역
fn_getCode("AR", "020000000", "searchCondition02", $("#hid_searchCondition02").val(), "");
// 지역상세
// fn_getCode("", $("#hid_searchCondition02").val(), "searchCondition02_1", $("#hid_searchCondition02_1").val());
// 지역 변경
// $("#searchCondition02").change(function(){
// fn_getCode("", $(this).val(), "searchCondition02_1", $("#hid_searchCondition02_1").val());
// });
// 업태
if ($("#hid_searchCondition02").val() == "") {
fn_getCode("BU", "", "searchCondition03", $("#hid_searchCondition03").val());
} else {
var searchCondition02 = $("#hid_searchCondition02").val();
$("#searchCondition03").find("option").each(function(){
$(this).remove();
});
$("#searchCondition03").append("");
$.ajax({
type:"POST",
url: "/tprice/portal/saleinfo/saleinfo/getEntpTypeList.do",
data: "entpAreaCode=" + searchCondition02,
dataType:"json",
success:function(data){
var codeData = data.json;
$.each(codeData, function(i){
if(codeData[i].CODE == $("#hid_searchCondition03").val()){
$("#searchCondition03").append("");
}
else{
$("#searchCondition03").append("");
}
});
},
failure:function(data){}
});
}
// 지역 변경시 업태
$("#searchCondition02").change(function(){
var searchCondition02 = $("#searchCondition02 option:selected").val();
if (searchCondition02 == undefined) {
searchCondition02 = $("#hid_searchCondition02").val();
}
if (searchCondition02 == "") {
fn_getCode("BU", "", "searchCondition03", "");
} else {
$("#searchCondition03").find("option").each(function(){
$(this).remove();
});
$("#searchCondition03").append("");
$.ajax({
type:"POST",
url: "/tprice/portal/saleinfo/saleinfo/getEntpTypeList.do",
data: "entpAreaCode=" + searchCondition02,
dataType:"json",
success:function(data){
var codeData = data.json;
$.each(codeData, function(i){
$("#searchCondition03").append("");
});
},
failure:function(data){}
});
}
});
//품목&상품 변경시
$("#searchCondition06").change(function(){
if("0" == $(this).val()){
$("#searchKeyword").show();
$("#searchKeyword2").hide();
$("#searchKeyword2").val("");
}else{
$("#searchKeyword").hide();
$("#searchKeyword2").show();
$("#searchKeyword").val("");
}
});
$("#searchCondition06").trigger("change");
// 검색버튼
$("#search_btn").click(function(){
$("#searchOrExcel").val("search");
$("#searchForm")
.attr("action", "/tprice/portal/saleinfo/saleinfo/saleinfoList.do")
.submit();
});
// 탭 매뉴
$("#tab_menu ul li").click(function(){
$("#tab_menu ul li a").removeAttr("title");
var targetId = $(this).attr("id");
$("#tab_menu").find("li").each(function(){
if ($(this).find("img").size() > 0) {
$(this).find("img").attr("src").replace("_on.", "_off.");
$("#"+targetId).find("img").attr("src").replace("_off.", "_on.");
} else {
$(this).removeClass("on");
$("#"+targetId).addClass("on");
$("#"+targetId+" a").attr("title","선택됨");
}
});
if(targetId == 'tab_all'){
$("[name=onoff]").show();
}else{
$("[name=onoff]").hide();
$("#"+targetId+"_"+$(this).index()).show();
}
// 웹접근성 조치 by 황인환 2018-04-26
$('#hContentTitle').text($(this).find('a').text() + ' 생필품 할인정보 목록');
});
// 엑셀변환 버튼
$("#btn_excelDownload").click(function(){
$("#searchOrExcel").val("excel");
$("#searchForm")
.attr("action", "/tprice/portal/saleinfo/saleinfo/saleinfoList.do")
.submit();
});
// 엑셀 전체지역 버튼
$("#btn_excelAllAreaDownload").click(function(){
$("#searchOrExcel").val("excelAll");
$("#searchForm")
.attr("action", "/tprice/portal/saleinfo/saleinfo/saleinfoList.do")
.submit();
});
$(".saleDetailBtn").click(function(){
var res1 = $(this).siblings("input[name=hid_inspectSeq_re]").val();
var res2 = $(this).siblings("input[name=hid_goodId_re]").val();
var res3 = $(this).siblings("input[name=hid_entpAreaCode_re]").val();
var res4 = $(this).siblings("input[name=hid_entpBrandCode_re]").val();
var res5 = "" + $("#hid_inspectYear").val() + $("#hid_inspectMonth").val() + $("#hid_inspectDay").val();
var res6 = $(this).attr('id');
var url = "/tprice/portal/saleinfo/saleinfo/saleInfoDetailPop.do";
fn_bpopup(url + "?inspectSeq="+res1
+ "&goodId="+res2
+ "&entpAreaCode="+res3
+ "&entpBrandCode="+res4
+ "&inspectDate="+res5
+ "&focusObjId="+res6
,850,600,'할인정보조회');
// $("#btn_excelDownload").focus();
});
});
//자동완성
$(function() {
$("#searchKeyword").autocomplete({
source: assistGoodName,
minLength:0
});
$("#searchKeyword").dblclick(function(){
$("#searchKeyword").autocomplete("search","");
});
$("#searchKeyword2").autocomplete({
source: assistGoodName2,
minLength:0
});
$("#searchKeyword2").dblclick(function(){
$("#searchKeyword2").autocomplete("search","");
});
});
//지역에서 '전체' 항목 삭제
function fn_delAreaCode(){
$("#searchCondition02 option").each(function(){
if($(this).val() == ""){
$(this).remove();
}
});
}
//조사월 조회
function fn_getInspectMonth(inspectYear, callbackFn){
$("#inspectMonth option").each(function(){
$(this).remove();
});
$.ajax({
type:"POST",
url: "/tprice/common/code/getInspectMonth.do",
data: "inspectYear="+inspectYear,
dataType:"json",
success:function(data){
var codeData = data.json;
$.each(codeData, function(i){
if(codeData[i].CODE == $("#hid_inspectMonth").val()){
$("#inspectMonth").append("");
}
else{
$("#inspectMonth").append("");
}
});
if( typeof callbackFn === "function" ) {
// 조사일 조회 호출
callbackFn(inspectYear, $("#inspectMonth").val());
}
},
failure:function(data){}
});
}
// 조사일 조회
function fn_getInspectDay(inspectYear, inspectMonth){
$("#inspectDay option").each(function(){
$(this).remove();
});
$.ajax({
type:"POST",
url: "/tprice/common/code/getInspectDay.do",
data: "inspectYear="+inspectYear + "&inspectMonth="+inspectMonth,
dataType:"json",
success:function(data){
var codeData = data.json;
$.each(codeData, function(i){
if(codeData[i].CODE == $("#hid_inspectDay").val()){
$("#inspectDay").append("");
}
else{
$("#inspectDay").append("");
}
});
},
failure:function(data){}
});
}