//Author:fuhc //Date:20160909 //添加酒店产品 var provinceHTML = ''; //省HTML var cityHTML = ''; //市HTML // 选中的房型参数 var room_type_str = ''; window.onload = function () { provinceHTML = $('#province').html(); cityHTML = $('#city').html(); var apiurl = base_api + "?type=hotel_AddHotelProduct&op=provinceCity &area_id="; ZZLog(apiurl); $.getJSON(apiurl, function (res_data) { ZZLog(res_data); if (res_data['code'] != "0") { alert(res_data['info']); } else { //地区 var area_list = res_data['area_list']; var areaHTML = ''; for (var i = 0, m = area_list.length; i < m; i++) { var tempDict = area_list[i]; var tempHTML = provinceHTML; tempHTML = tempHTML.replace('选择省', tempDict['area_name']); tempHTML = tempHTML.replace('0', tempDict['area_id']); areaHTML += tempHTML; } if (areaHTML) { $('#province').html(areaHTML); $('#province').selectedIndex = 0; } } }) setSupplierConfirmHTML(); } //加载供应商和发单主体 function setSupplierConfirmHTML() { var urlapi = base_api; var param = { type: "hotel_AddHotelProduct", op: "supplier-confirm" } ZZLog(urlapi + JSON.stringify(param)); $.ajax({ url: urlapi, data: param, type: "post", dataType: "json", success: function (res_data) { ZZLog(res_data); if (res_data['code'] != "0") { alert(res_data['info']); } else { var confirm_org_list = res_data['confirm_org_list']; var HTML1 = ''; for (var i = 0, m = confirm_org_list.length; i < m; i++) { var tempHTML = ''; var tempDict = confirm_org_list[i]; tempHTML = tempHTML.replace('value="0"', 'value=' + tempDict['org_id']); tempHTML = tempHTML.replace('请选择', tempDict['org_name']); HTML1 += tempHTML; } if (HTML1) { $('#fadan').html(HTML1); } var supplier_list = res_data['supplier_list']; var HTML2 = ''; for (var i = 0, m = supplier_list.length; i < m; i++) { var tempHTML = ''; var tempDict = supplier_list[i]; tempHTML = tempHTML.replace('value="0"', 'value=' + tempDict['supplier_id']); tempHTML = tempHTML.replace('请选择', tempDict['supplier_name']); HTML2 += tempHTML; } if (HTML2) { $('#supplier').html(HTML2); $('.select_line').comboSelect(); } } } }); } $(document).ready(function () { $('#supplier').bind('change', function () { var urlapi = base_api + "?type=hotel_AddHotelProduct&op=selpurchase&supplier_id=" + $(this).val(); ZZLog(urlapi); $.getJSON(urlapi, function (res_data) { ZZLog(res_data); var purchase_people_list = res_data['purchase_people_list']; var HTML = ''; for (var i = 0, m = purchase_people_list.length; i < m; i++) { var tempHTML = ''; var tempDict = purchase_people_list[i]; tempHTML = tempHTML.replace('value="0"', 'value=' + tempDict['purchaser_id']); tempHTML = tempHTML.replace('请选择', tempDict['purchaser_name']); HTML += tempHTML; } if (HTML) { $('#procurement').html(HTML); } if (res_data['purchase_people_list'][0]['purchaser_id']) { $('#procurement').val(res_data['purchase_people_list'][0]['purchaser_id']); } }) }) //选择省的事件 $('#province').bind('change', function () { var area_id = $(this).val(); if (area_id == "0" || area_id == "") { $('#city').html(cityHTML); return; } var url = base_api + "?type=hotel_AddHotelProduct&op=provinceCity&area_id=" + area_id; ZZLog(url); $.getJSON(url, function (res_data) { ZZLog(res_data); if (res_data['code'] != "0") { alert(res_data['info']); } else { //地区 var area_list = res_data['area_list']; var areaHTML = ''; for (var i = 0, m = area_list.length; i < m; i++) { var tempDict = area_list[i]; var tempHTML = cityHTML; tempHTML = tempHTML.replace('选择市', tempDict['area_name']); tempHTML = tempHTML.replace('0', tempDict['area_id']); areaHTML += tempHTML; } if (areaHTML) { $('#city').html(areaHTML); $('#city').selectedIndex = 0; } } }) }) //酒店检索keyword $('#hotel_name').bind({ click: function () { var key_word = $(this).val().trim(); var province = $('#province').val(); var city = $('#city').val(); var area_id = city != 0 ? city : province; var apiurl = base_api + "?type=hotel_AddHotelProduct&op=fuzzy&key_word=" + key_word + "&area_id=" + area_id; ZZLog(apiurl); $.getJSON(apiurl, function (res_data) { ZZLog(res_data); // if(res_data['code']!="0"){ // alert(res_data['info']); // }else{ var hotel_list = res_data['hotel_list']; var HTML = ''; for (var i = 0, m = hotel_list.length; i < m; i++) { var tempDict = hotel_list[i]; var tempHTML = '
' + tempDict['hotel_name'] + '
'; HTML += tempHTML; } if (HTML) { $('.xiala').html(HTML); $('.xiala').show(); } else { $('.xiala').html(''); $('.xiala').hide(); } // } }) }, input: function () { var key_word = $(this).val().trim(); var province = $('#province').val(); var city = $('#city').val(); var area_id = city != 0 ? city : province; var apiurl = base_api + "?type=hotel_AddHotelProduct&op=fuzzy&key_word=" + key_word + "&area_id=" + area_id; ZZLog(apiurl); $.getJSON(apiurl, function (res_data) { ZZLog(res_data); // if(res_data['code']!="0"){ // alert(res_data['info']); // }else{ var hotel_list = res_data['hotel_list']; var HTML = ''; for (var i = 0, m = hotel_list.length; i < m; i++) { var tempDict = hotel_list[i]; var tempHTML = '
' + tempDict['hotel_name'] + '
'; HTML += tempHTML; } if (HTML) { $('.xiala').html(HTML); $('.xiala').show(); } else { $('.xiala').html(''); $('.xiala').hide(); } // } }) } }) $('#hotel_name').bind('input', function () { }) // 点击保存 $('#nextBtn').bind('click', function () { var hotel_id = $('#hotel_name').attr('hotel_id'); if (hotel_id == "" || hotel_id == undefined) { alert('请选择酒店'); return; } var province = $('#province').val(); var city = $('#city').val(); var area_id = city != 0 ? city : province; var earliest_checkin_time = $('#earliest_heckin_time').val(); var fadan = $('#fadan').val(); var supplier_id = $('#supplier').val(); var procurement = $('#procurement').val(); var status = $('.status_value').val(); if (supplier_id == "") { alert('请选择供应商'); return; } if (procurement == "") { alert('请选择采购人'); return; } if (fadan == "") { alert('请选择发单主体'); return; } if (status == "-1") { alert('请选择状态'); return; } var _span_principal = ''; $('.span_principal').each(function (index, principal_obj) { var principal_list = $(principal_obj).attr('data-res-id'); _span_principal += principal_list; }) _span_principal = _span_principal.substr(0, _span_principal.length - 1); if (_span_principal == "") { alert('请选择运营负责人'); return; } $('input[type="checkbox"]').each(function (index, domEle) { if (this.checked && room_type_str == "") { room_type_str = $(this).attr('data-id'); } else if (this.checked && room_type_str != "") { room_type_str += "," + $(this).attr('data-id'); } }) // 获取参数 var parm = { type: "hotel_AddHotelProduct", op: "add", hotel_id: hotel_id, area_id: area_id, room_type_sale: room_type_str, earliest_checkin_time: earliest_checkin_time, confirm_from: fadan, procurement: procurement, supplier_id: supplier_id, principal: _span_principal, //运营负责人 status: status }; var urlapi = base_api; ZZLog(urlapi + JSON.stringify(parm)); $.post(urlapi, parm, function (res_data) { res_data = JSON.parse(res_data); ZZLog(res_data); if (res_data['code'] != "0") { alert(res_data['info']); } else { // 跳转 var listURL = "up_down_control.html"; listURL = encodeURI(listURL); window.location.href = listURL; } }) }) }) // 选择酒店 function changeHotel(domEle) { $('.xiala').html(''); $('.xiala').hide(); var hotel_address = $(domEle).attr('data-address'); var hotel_id = $(domEle).attr('data-id'); $('#hotel_name').val($(domEle).html()); $('#hotel_name').attr('hotel_id', hotel_id); $('#hotel_address').text('地址:' + hotel_address); var apiurl = base_api + "?type=hotel_AddHotelProduct&op=room&hotel_id=" + hotel_id; ZZLog(apiurl); $.getJSON(apiurl, function (res_data) { ZZLog(res_data); if (res_data['code'] != "0") { alert(res_data['info']); } else { var room_list = res_data['room_list']; var HTML = ''; for (var i = 0, m = room_list.length; i < m; i++) { var tempDict = room_list[i]; var tempHTML = ''; if (tempDict['checked'] == "1") { tempHTML = ''; } else { tempHTML = ''; } if ((i + 1) % 6 == 0) { tempHTML += '
'; } HTML += tempHTML; } if (HTML) { $('#room').html(HTML); } else { $('#room').html('-'); } } }) } // 选择房型 function selectRoom(domEle) { if (domEle.checked) { $(domEle).parent().children().eq(1).css('color', 'darkgray'); } else { $(domEle).parent().children().eq(1).css('color', 'black'); } } //选择运营负责人 function choosefuzeren(obj) { res_id = $(obj).val().trim(); if (res_id != -1) { res_name = $(obj).find('option:selected').text(); var cstr = '' + res_name + ' 点击删除'; var oldstr = $('#principal').html(); //判断该票种是否已经添加 if (oldstr.indexOf(cstr) == -1) { $('#principal').html(oldstr + cstr); } else { ZZAlertInfo('该负责人已被添加!'); } } } //删除添加的缓存运营负责人 function delTicket(obj) { $(obj).parent().remove(); }