You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

371 lines
14 KiB

  1. //Author:fuhc
  2. //Date:20160909
  3. //添加酒店产品
  4. var provinceHTML = ''; //省HTML
  5. var cityHTML = ''; //市HTML
  6. // 选中的房型参数
  7. var room_type_str = '';
  8. window.onload = function () {
  9. provinceHTML = $('#province').html();
  10. cityHTML = $('#city').html();
  11. var apiurl = base_api + "?type=hotel_AddHotelProduct&op=provinceCity &area_id=";
  12. ZZLog(apiurl);
  13. $.getJSON(apiurl, function (res_data) {
  14. ZZLog(res_data);
  15. if (res_data['code'] != "0") {
  16. alert(res_data['info']);
  17. } else {
  18. //地区
  19. var area_list = res_data['area_list'];
  20. var areaHTML = '<option value="0" style="font-size: 12px;">选择省</option>';
  21. for (var i = 0, m = area_list.length; i < m; i++) {
  22. var tempDict = area_list[i];
  23. var tempHTML = provinceHTML;
  24. tempHTML = tempHTML.replace('选择省', tempDict['area_name']);
  25. tempHTML = tempHTML.replace('0', tempDict['area_id']);
  26. areaHTML += tempHTML;
  27. }
  28. if (areaHTML) {
  29. $('#province').html(areaHTML);
  30. $('#province').selectedIndex = 0;
  31. }
  32. }
  33. })
  34. setSupplierConfirmHTML();
  35. }
  36. //加载供应商和发单主体
  37. function setSupplierConfirmHTML() {
  38. var urlapi = base_api;
  39. var param = {
  40. type: "hotel_AddHotelProduct",
  41. op: "supplier-confirm"
  42. }
  43. ZZLog(urlapi + JSON.stringify(param));
  44. $.ajax({
  45. url: urlapi,
  46. data: param,
  47. type: "post",
  48. dataType: "json",
  49. success: function (res_data) {
  50. ZZLog(res_data);
  51. if (res_data['code'] != "0") {
  52. alert(res_data['info']);
  53. } else {
  54. var confirm_org_list = res_data['confirm_org_list'];
  55. var HTML1 = '<option value="">请选择</option>';
  56. for (var i = 0, m = confirm_org_list.length; i < m; i++) {
  57. var tempHTML = '<option value="0">请选择</option>';
  58. var tempDict = confirm_org_list[i];
  59. tempHTML = tempHTML.replace('value="0"', 'value=' + tempDict['org_id']);
  60. tempHTML = tempHTML.replace('请选择', tempDict['org_name']);
  61. HTML1 += tempHTML;
  62. }
  63. if (HTML1) {
  64. $('#fadan').html(HTML1);
  65. }
  66. var supplier_list = res_data['supplier_list'];
  67. var HTML2 = '<option value="0" selected=selected>请选择</option>';
  68. for (var i = 0, m = supplier_list.length; i < m; i++) {
  69. var tempHTML = '<option value="0">请选择</option>';
  70. var tempDict = supplier_list[i];
  71. tempHTML = tempHTML.replace('value="0"', 'value=' + tempDict['supplier_id']);
  72. tempHTML = tempHTML.replace('请选择', tempDict['supplier_name']);
  73. HTML2 += tempHTML;
  74. }
  75. if (HTML2) {
  76. $('#supplier').html(HTML2);
  77. $('.select_line').comboSelect();
  78. }
  79. }
  80. }
  81. });
  82. }
  83. $(document).ready(function () {
  84. $('#supplier').bind('change', function () {
  85. var urlapi = base_api + "?type=hotel_AddHotelProduct&op=selpurchase&supplier_id=" + $(this).val();
  86. ZZLog(urlapi);
  87. $.getJSON(urlapi, function (res_data) {
  88. ZZLog(res_data);
  89. var purchase_people_list = res_data['purchase_people_list'];
  90. var HTML = '<option value="">请选择</option>';
  91. for (var i = 0, m = purchase_people_list.length; i < m; i++) {
  92. var tempHTML = '<option value="0">请选择</option>';
  93. var tempDict = purchase_people_list[i];
  94. tempHTML = tempHTML.replace('value="0"', 'value=' + tempDict['purchaser_id']);
  95. tempHTML = tempHTML.replace('请选择', tempDict['purchaser_name']);
  96. HTML += tempHTML;
  97. }
  98. if (HTML) {
  99. $('#procurement').html(HTML);
  100. }
  101. if (res_data['purchase_people_list'][0]['purchaser_id']) {
  102. $('#procurement').val(res_data['purchase_people_list'][0]['purchaser_id']);
  103. }
  104. })
  105. })
  106. //选择省的事件
  107. $('#province').bind('change', function () {
  108. var area_id = $(this).val();
  109. if (area_id == "0" || area_id == "") {
  110. $('#city').html(cityHTML);
  111. return;
  112. }
  113. var url = base_api + "?type=hotel_AddHotelProduct&op=provinceCity&area_id=" + area_id;
  114. ZZLog(url);
  115. $.getJSON(url, function (res_data) {
  116. ZZLog(res_data);
  117. if (res_data['code'] != "0") {
  118. alert(res_data['info']);
  119. } else {
  120. //地区
  121. var area_list = res_data['area_list'];
  122. var areaHTML = '<option value="0" style="font-size: 12px;">选择市</option>';
  123. for (var i = 0, m = area_list.length; i < m; i++) {
  124. var tempDict = area_list[i];
  125. var tempHTML = cityHTML;
  126. tempHTML = tempHTML.replace('选择市', tempDict['area_name']);
  127. tempHTML = tempHTML.replace('0', tempDict['area_id']);
  128. areaHTML += tempHTML;
  129. }
  130. if (areaHTML) {
  131. $('#city').html(areaHTML);
  132. $('#city').selectedIndex = 0;
  133. }
  134. }
  135. })
  136. })
  137. //酒店检索keyword
  138. $('#hotel_name').bind({
  139. click: function () {
  140. var key_word = $(this).val().trim();
  141. var province = $('#province').val();
  142. var city = $('#city').val();
  143. var area_id = city != 0 ? city : province;
  144. var apiurl = base_api + "?type=hotel_AddHotelProduct&op=fuzzy&key_word=" + key_word + "&area_id=" + area_id;
  145. ZZLog(apiurl);
  146. $.getJSON(apiurl, function (res_data) {
  147. ZZLog(res_data);
  148. // if(res_data['code']!="0"){
  149. // alert(res_data['info']);
  150. // }else{
  151. var hotel_list = res_data['hotel_list'];
  152. var HTML = '';
  153. for (var i = 0, m = hotel_list.length; i < m; i++) {
  154. var tempDict = hotel_list[i];
  155. 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>';
  156. HTML += tempHTML;
  157. }
  158. if (HTML) {
  159. $('.xiala').html(HTML);
  160. $('.xiala').show();
  161. } else {
  162. $('.xiala').html('');
  163. $('.xiala').hide();
  164. }
  165. // }
  166. })
  167. },
  168. input: function () {
  169. var key_word = $(this).val().trim();
  170. var province = $('#province').val();
  171. var city = $('#city').val();
  172. var area_id = city != 0 ? city : province;
  173. var apiurl = base_api + "?type=hotel_AddHotelProduct&op=fuzzy&key_word=" + key_word + "&area_id=" + area_id;
  174. ZZLog(apiurl);
  175. $.getJSON(apiurl, function (res_data) {
  176. ZZLog(res_data);
  177. // if(res_data['code']!="0"){
  178. // alert(res_data['info']);
  179. // }else{
  180. var hotel_list = res_data['hotel_list'];
  181. var HTML = '';
  182. for (var i = 0, m = hotel_list.length; i < m; i++) {
  183. var tempDict = hotel_list[i];
  184. 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>';
  185. HTML += tempHTML;
  186. }
  187. if (HTML) {
  188. $('.xiala').html(HTML);
  189. $('.xiala').show();
  190. } else {
  191. $('.xiala').html('');
  192. $('.xiala').hide();
  193. }
  194. // }
  195. })
  196. }
  197. })
  198. $('#hotel_name').bind('input', function () {
  199. })
  200. // 点击保存
  201. $('#nextBtn').bind('click', function () {
  202. var hotel_id = $('#hotel_name').attr('hotel_id');
  203. if (hotel_id == "" || hotel_id == undefined) {
  204. alert('请选择酒店');
  205. return;
  206. }
  207. var province = $('#province').val();
  208. var city = $('#city').val();
  209. var area_id = city != 0 ? city : province;
  210. var earliest_checkin_time = $('#earliest_heckin_time').val();
  211. var fadan = $('#fadan').val();
  212. var supplier_id = $('#supplier').val();
  213. var procurement = $('#procurement').val();
  214. var status = $('.status_value').val();
  215. if (supplier_id == "") {
  216. alert('请选择供应商');
  217. return;
  218. }
  219. if (procurement == "") {
  220. alert('请选择采购人');
  221. return;
  222. }
  223. if (fadan == "") {
  224. alert('请选择发单主体');
  225. return;
  226. }
  227. if (status == "-1") {
  228. alert('请选择状态');
  229. return;
  230. }
  231. var _span_principal = '';
  232. $('.span_principal').each(function (index, principal_obj) {
  233. var principal_list = $(principal_obj).attr('data-res-id');
  234. _span_principal += principal_list;
  235. })
  236. _span_principal = _span_principal.substr(0, _span_principal.length - 1);
  237. if (_span_principal == "") {
  238. alert('请选择运营负责人');
  239. return;
  240. }
  241. $('input[type="checkbox"]').each(function (index, domEle) {
  242. if (this.checked && room_type_str == "") {
  243. room_type_str = $(this).attr('data-id');
  244. } else if (this.checked && room_type_str != "") {
  245. room_type_str += "," + $(this).attr('data-id');
  246. }
  247. })
  248. // 获取参数
  249. var parm = {
  250. type: "hotel_AddHotelProduct",
  251. op: "add",
  252. hotel_id: hotel_id,
  253. area_id: area_id,
  254. room_type_sale: room_type_str,
  255. earliest_checkin_time: earliest_checkin_time,
  256. confirm_from: fadan,
  257. procurement: procurement,
  258. supplier_id: supplier_id,
  259. principal: _span_principal, //运营负责人
  260. status: status
  261. };
  262. var urlapi = base_api;
  263. ZZLog(urlapi + JSON.stringify(parm));
  264. $.post(urlapi, parm, function (res_data) {
  265. res_data = JSON.parse(res_data);
  266. ZZLog(res_data);
  267. if (res_data['code'] != "0") {
  268. alert(res_data['info']);
  269. } else {
  270. // 跳转
  271. var listURL = "up_down_control.html";
  272. listURL = encodeURI(listURL);
  273. window.location.href = listURL;
  274. }
  275. })
  276. })
  277. })
  278. // 选择酒店
  279. function changeHotel(domEle) {
  280. $('.xiala').html('');
  281. $('.xiala').hide();
  282. var hotel_address = $(domEle).attr('data-address');
  283. var hotel_id = $(domEle).attr('data-id');
  284. $('#hotel_name').val($(domEle).html());
  285. $('#hotel_name').attr('hotel_id', hotel_id);
  286. $('#hotel_address').text('地址:' + hotel_address);
  287. var apiurl = base_api + "?type=hotel_AddHotelProduct&op=room&hotel_id=" + hotel_id;
  288. ZZLog(apiurl);
  289. $.getJSON(apiurl, function (res_data) {
  290. ZZLog(res_data);
  291. if (res_data['code'] != "0") {
  292. alert(res_data['info']);
  293. } else {
  294. var room_list = res_data['room_list'];
  295. var HTML = '';
  296. for (var i = 0, m = room_list.length; i < m; i++) {
  297. var tempDict = room_list[i];
  298. var tempHTML = '';
  299. if (tempDict['checked'] == "1") {
  300. 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>';
  301. } else {
  302. 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>';
  303. }
  304. if ((i + 1) % 6 == 0) {
  305. tempHTML += '</br>';
  306. }
  307. HTML += tempHTML;
  308. }
  309. if (HTML) {
  310. $('#room').html(HTML);
  311. } else {
  312. $('#room').html('-');
  313. }
  314. }
  315. })
  316. }
  317. // 选择房型
  318. function selectRoom(domEle) {
  319. if (domEle.checked) {
  320. $(domEle).parent().children().eq(1).css('color', 'darkgray');
  321. } else {
  322. $(domEle).parent().children().eq(1).css('color', 'black');
  323. }
  324. }
  325. //选择运营负责人
  326. function choosefuzeren(obj) {
  327. res_id = $(obj).val().trim();
  328. if (res_id != -1) {
  329. res_name = $(obj).find('option:selected').text();
  330. 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">';
  331. var oldstr = $('#principal').html();
  332. //判断该票种是否已经添加
  333. if (oldstr.indexOf(cstr) == -1) {
  334. $('#principal').html(oldstr + cstr);
  335. } else {
  336. ZZAlertInfo('该负责人已被添加!');
  337. }
  338. }
  339. }
  340. //删除添加的缓存运营负责人
  341. function delTicket(obj) {
  342. $(obj).parent().remove();
  343. }