|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370 |
- //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 = '<option value="0" style="font-size: 12px;">选择省</option>';
- 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 = '<option value="">请选择</option>';
- for (var i = 0, m = confirm_org_list.length; i < m; i++) {
- var tempHTML = '<option value="0">请选择</option>';
- 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 = '<option value="0" selected=selected>请选择</option>';
- for (var i = 0, m = supplier_list.length; i < m; i++) {
- var tempHTML = '<option value="0">请选择</option>';
- 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 = '<option value="">请选择</option>';
- for (var i = 0, m = purchase_people_list.length; i < m; i++) {
- var tempHTML = '<option value="0">请选择</option>';
- 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 = '<option value="0" style="font-size: 12px;">选择市</option>';
- 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 = '<div class="content_xiala" style="padding: 5px" data-id="' + tempDict['hotel_id'] + '" data-address="' + tempDict['hotel_address'] + '"onclick="changeHotel(this)">' + tempDict['hotel_name'] + '</div>';
- 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 = '<div class="content_xiala" style="padding: 5px" data-id="' + tempDict['hotel_id'] + '" data-address="' + tempDict['hotel_address'] + '"onclick="changeHotel(this)">' + tempDict['hotel_name'] + '</div>';
- 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 = '<label tab="0" class="lbl-check" ><input type="checkbox" checked="checked" onclick="checked=defaultChecked" data-id="' + tempDict['room_id'] + '"/><span style="margin-left:2px;margin-right: 20px;color:darkgray">' + tempDict['room_name'] + '</span></label>';
- } else {
- tempHTML = '<label class="lbl-check" ><input type="checkbox" onclick="selectRoom(this)" data-id="' + tempDict['room_id'] + '"/><span style="margin-left:2px;margin-right: 20px;">' + tempDict['room_name'] + '</span></label>';
- }
-
- if ((i + 1) % 6 == 0) {
- tempHTML += '</br>';
- }
- 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 = '<span class="span_principal" style="cursor: pointer;" data-res-id="' + res_id + ',' + '">' + res_name + ' <img alt="点击删除" onclick="delTicket(this)" style="width: 12px;height: 12px;margin-bottom: 2px;" src="images/close.png">';
- var oldstr = $('#principal').html();
- //判断该票种是否已经添加
- if (oldstr.indexOf(cstr) == -1) {
- $('#principal').html(oldstr + cstr);
- } else {
- ZZAlertInfo('该负责人已被添加!');
- }
- }
- }
- //删除添加的缓存运营负责人
- function delTicket(obj) {
- $(obj).parent().remove();
- }
|