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.
 
 
 
 

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