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.
 
 
 
 

2269 lines
86 KiB

  1. //Author:fuhc
  2. //Date:20160919
  3. //
  4. var baseHTML = '';
  5. var childHTML = '';
  6. var firstDate = '';
  7. var d1 = "";
  8. var d2 = "";
  9. var d3 = "";
  10. var d4 = "";
  11. var d5 = "";
  12. var d6 = "";
  13. var d7 = "";
  14. var w1 = "";
  15. var w2 = "";
  16. var w3 = "";
  17. var w4 = "";
  18. var w5 = "";
  19. var w6 = "";
  20. var w7 = "";
  21. var channel_id = '';
  22. // 房型售卖状态
  23. var room_sale_status = "-1";
  24. //基础房型关键字
  25. var base_room_type = '';
  26. var hotel_id = '';
  27. var hotel_name = '';
  28. var page_size = '10';
  29. var start_date = getPar('start_date');
  30. var qudao_least = 0;
  31. var date_flag = 0;
  32. var number = null;
  33. var check_limit = new Array(); // {"1":"98", "2":"99", "3":"100", "4":"101", "5":"102", "6":"103"};
  34. check_limit[1] = 98;
  35. check_limit[2] = 99;
  36. check_limit[3] = 100;
  37. check_limit[4] = 101;
  38. check_limit[5] = 102;
  39. check_limit[6] = 103;
  40. check_limit[7] = 104;
  41. check_limit[8] = 105;
  42. check_limit[9] = 106;
  43. var limit_name = new Array();
  44. limit_name[1] = '单人入住';
  45. limit_name[2] = '双人入住';
  46. limit_name[3] = '三人入住';
  47. limit_name[4] = '四人入住';
  48. limit_name[5] = '五人入住';
  49. limit_name[6] = '六人入住';
  50. limit_name[7] = '七人入住';
  51. limit_name[8] = '八人入住';
  52. limit_name[9] = '九人入住';
  53. $(document).ready(function () {
  54. $('#Wdate2').val(getDateTime(0));
  55. $('#Wdate3').val(getDateByDay(7, getDateTime(0)));
  56. baseHTML = $('#table-data tbody tr:first').prop('outerHTML');
  57. childHTML = $('#table-data tbody tr:nth-child(2)').prop('outerHTML');
  58. hotel_name = getPar('hotel_name');
  59. hotel_id = getPar('hotel_id');
  60. channel_id = getPar('channel_id');
  61. initChannelList();
  62. $("#current_date").val(getDateTime(0));
  63. if (hotel_name !== "") {
  64. $('#hotel_name').text(hotel_name);
  65. }
  66. // 设置tb_top_td
  67. setTbTopTd();
  68. // http
  69. current = localStorage.getItem('current') === null ? 1 : localStorage.getItem('current');
  70. getDataFromHttp();
  71. // playPermission();
  72. });
  73. $(document).ready(function () {
  74. //日期插件
  75. $(".form_date").datetimepicker({
  76. format: 'yyyy-mm-dd',
  77. autoclose: true,
  78. minView: 2,
  79. pickerPosition: "bottom-left"
  80. });
  81. $("#channel_list").on('change', function () {
  82. channel_id = $("#channel_list").val();
  83. d1 = $("#current_date").val();
  84. setTbTopTd();
  85. current = 1;
  86. getDataFromHttp();
  87. })
  88. $(".form_date_change").on('change', function () {
  89. d1 = $("#current_date").val();
  90. setTbTopTd();
  91. current = 1;
  92. getDataFromHttp();
  93. })
  94. // 今天
  95. $('#today').bind('click', function () {
  96. d1 = getDateTime(0);
  97. setTbTopTd();
  98. current = 1;
  99. getDataFromHttp();
  100. });
  101. // 前7天
  102. $('#before7').bind('click', function () {
  103. d1 = getDateByDay(-7, d1);
  104. setTbTopTd();
  105. current = 1;
  106. getDataFromHttp();
  107. });
  108. // 后7天
  109. $('#after7').bind('click', function () {
  110. d1 = getDateByDay(7, d1);
  111. setTbTopTd();
  112. current = 1;
  113. getDataFromHttp();
  114. });
  115. // 售卖状态
  116. $('#sale_status').bind('change', function () {
  117. room_sale_status = $(this).val();
  118. });
  119. // 售卖状态
  120. $('#base_room_type').bind('change', function () {
  121. base_room_type = $(this).val();
  122. });
  123. //点击搜索
  124. $('#search').bind('click', function () {
  125. d1 = $('.Wdate').val();
  126. // 设置tb_top_td
  127. setTbTopTd();
  128. if (d1 !== "") {
  129. // http
  130. current = 1;
  131. getDataFromHttp();
  132. }
  133. });
  134. // 新增房型
  135. $('#newAddRoom').bind('click', function () {
  136. var listURL = "add_room_type.html?hotel_id=" + hotel_id + "&hotel_name=" + hotel_name;
  137. listURL = encodeURI(listURL);
  138. $.cookie("path_url", cookie_path + "zz-jd/" + listURL, {domain: domain_path});
  139. window.open(system_path);
  140. //window.open(listURL);
  141. });
  142. // 点击保存
  143. $('.save_base').bind('click', function () {
  144. var urlapi = base_api;
  145. var param = {
  146. type: "room_base_SetBaseRoom",
  147. op: "AddBaseRoom",
  148. hotel_id: _hotel_id,
  149. room_info: cstr
  150. };
  151. ZZLog(urlapi + JSON.stringify(param));
  152. $(".save_base").html('保存中');
  153. loading();
  154. // $('.save_child').css('background-color', 'darkgray !important'); //不知道什么原因,不起作用
  155. $('.save_base').attr('style', 'cursor: pointer;background: darkgray!important;color: white;margin-left:26px;padding: 10px 20px;')
  156. $.post(urlapi, param, function (res_data) {
  157. res_data = JSON.parse(res_data);
  158. ZZLog(res_data);
  159. if (res_data['code'] !== "0") {
  160. alert(res_data['info']);
  161. } else {
  162. clickMask();
  163. getDataFromHttp();
  164. }
  165. $(".save_base").html('保存');
  166. $('.save_base').attr('style', 'cursor: pointer;background: #428bca!important;color: white;margin-left:26px;padding: 10px 20px;');
  167. closeLoading();
  168. })
  169. })
  170. $('.save_child').bind('click', function () {
  171. var childIndex = $temp_cday.attr('childIndex');
  172. var _td_date = $('.tb_title').children().eq(childIndex).attr('f_date');
  173. var _child_maiduan_price = $("#child_maiduan_price").val();
  174. var _child_baoliu_price = $("#child_baoliu_price").val();
  175. var _child_xianxun_price = $("#child_xianxun_price").val();
  176. var _parent_room_type = $temp_cday.parent().attr('data-parent-room-type');
  177. var _room_type = $temp_cday.parent().attr('data-room-type');
  178. var _hotel_id = hotel_id;
  179. var _run_status = $('input[name="status"]:checked').val();
  180. if (_run_status === '') {
  181. ZZAlertInfo('请选择房态', function () {
  182. return;
  183. })
  184. }
  185. if (_child_maiduan_price === '' && _child_baoliu_price === '' && _child_xianxun_price === '') {
  186. ZZAlertInfo('请填写必要的采购价!', function () {
  187. return;
  188. })
  189. }
  190. if (isNaN(_child_maiduan_price) || isNaN(_child_baoliu_price) || isNaN(_child_xianxun_price)) {
  191. ZZAlertInfo('数据格式不正确');
  192. return;
  193. }
  194. var urlapi = base_api;
  195. var param = {
  196. type: "room_child_UpdateChildRoom",
  197. op: "update",
  198. run_status: _run_status,
  199. price_buyout: _child_maiduan_price,
  200. price_reserve: _child_baoliu_price,
  201. price_inquiry: _child_xianxun_price,
  202. run_date: _td_date,
  203. parent_room_type: _parent_room_type,
  204. room_type: _room_type,
  205. hotel_id: _hotel_id
  206. }
  207. ZZLog(urlapi + JSON.stringify(param));
  208. $(".save_child").html('保存中');
  209. loading();
  210. // $('.save_child').css('background-color', 'darkgray !important'); //不知道什么原因,不起作用
  211. $('.save_child').attr('style', 'cursor: pointer;background: darkgray!important;color: white;margin-left:26px;padding: 10px 20px;')
  212. $.post(urlapi, param, function (res_data) {
  213. res_data = JSON.parse(res_data);
  214. ZZLog(res_data);
  215. if (res_data['code'] !== "0") {
  216. alert(res_data['info']);
  217. } else {
  218. clickMask();
  219. getDataFromHttp();
  220. }
  221. $(".save_child").html('保存');
  222. $('.save_child').attr('style', 'cursor: pointer;background: #428bca!important;color: white;margin-left:26px;padding: 10px 20px;');
  223. closeLoading();
  224. })
  225. // 房态
  226. })
  227. // 取消修改的弹框
  228. $('.cancel_base').bind('click', function () {
  229. clickMask();
  230. })
  231. $('.cancel_child').bind('click', function () {
  232. clickMask();
  233. })
  234. // 点击蒙板
  235. $('#mask').bind('click', function () {
  236. clickMask();
  237. })
  238. })
  239. // 新增子房型
  240. var cstr0 = '';
  241. var cstr1 = '';
  242. var cstr2 = '[无早]';
  243. var cstr3 = '';
  244. function addChild(selfOBJ) {
  245. $selfOBJ = $(selfOBJ);
  246. var room_type = $selfOBJ.parent().parent().attr('data-room-type');
  247. var room_name = $selfOBJ.parent().parent().children().eq(1).text().trim();
  248. $("#div_maiduan_price").val('');
  249. $("#div_baoliu_price").val('');
  250. $("#div_xianxun_price").val('');
  251. ZZLog(room_name + '' + room_type);
  252. cstr0 = room_name;
  253. $('#div_room_name').text(room_name);
  254. $('#div_child_room_name').val(cstr0 + cstr1 + cstr2);
  255. $('#mask').css('background', 'black');
  256. $('#mask').css('opacity', '0.5');
  257. showCenterView('.main_style');
  258. }
  259. // 修改基础房型
  260. function updateBaseRoomInfo(selfOBJ) {
  261. localStorage.setItem('start_date', d1);
  262. localStorage.setItem('current', current);
  263. var room_type = $(selfOBJ).closest('tr').attr('data-room-type');
  264. var room_name = $(selfOBJ).attr('data-room-name');
  265. var start_date = $("#Wdate").val();
  266. var listURL = "modify_price_inventory.html?hotel_id=" + hotel_id + "&hotel_name=" + hotel_name + "&start_date=" + start_date + "&room_name=" + room_name + "&room_type=" + room_type;
  267. listURL = encodeURI(listURL);
  268. window.location.href = listURL;
  269. }
  270. // 选择入住人数
  271. function changePeople(selfOBJ) {
  272. var $selfOBJ = $(selfOBJ);
  273. var count = $selfOBJ.val();
  274. if (count < 100) {
  275. cstr1 = "(" + count + "人入住)";
  276. } else {
  277. cstr1 = '';
  278. }
  279. $('#div_child_room_name').val(cstr0 + cstr1 + cstr2);
  280. }
  281. //选择最晚预订日期
  282. function changeLastestBook(selfOBJ) {
  283. var $selfOBJ = $(selfOBJ);
  284. var fast = parseInt($selfOBJ.val());
  285. switch (fast) {
  286. case 0:
  287. fast = "";
  288. break;
  289. case 1:
  290. fast = "提前一天";
  291. break;
  292. case 2:
  293. fast = "提前二天";
  294. break;
  295. case 3:
  296. fast = "提前三天";
  297. break;
  298. case 4:
  299. fast = "提前四天";
  300. break;
  301. case 5:
  302. fast = "提前五天";
  303. break;
  304. case 6:
  305. fast = "提前六天";
  306. break;
  307. case 7:
  308. fast = "提前七天";
  309. break;
  310. case -1:
  311. fast = "——";
  312. break;
  313. }
  314. if (fast !== "") {
  315. cstr3 = "[" + fast + "]";
  316. } else {
  317. cstr3 = "";
  318. }
  319. $('#div_child_room_name').val(cstr3 + cstr0 + cstr1 + cstr2);
  320. }
  321. // 选择早餐
  322. function changeBreakfast(selfOBJ) {
  323. var $selfOBJ = $(selfOBJ);
  324. var fast = parseInt($selfOBJ.val());
  325. switch (fast) {
  326. case 0:
  327. fast = "无早";
  328. break;
  329. case 1:
  330. fast = "单早";
  331. break;
  332. case 2:
  333. fast = "双早";
  334. break;
  335. case 3:
  336. fast = "三早";
  337. break;
  338. case 4:
  339. fast = "四早";
  340. break;
  341. case 5:
  342. fast = "五早";
  343. break;
  344. case 6:
  345. fast = "六早";
  346. break;
  347. case 7:
  348. fast = "七早";
  349. break;
  350. case 8:
  351. fast = "八早";
  352. break;
  353. case 9:
  354. fast = "九早";
  355. break;
  356. case 10 :
  357. fast = "十早";
  358. break;
  359. }
  360. cstr2 = "[" + fast + "]";
  361. $('#div_child_room_name').val(cstr0 + cstr1 + cstr2);
  362. }
  363. // 将目标节点居中显示
  364. var $tempShowView = null;
  365. function showCenterView(classOrIdName) {
  366. $('#mask').css('display', 'block');
  367. $('#mask').css('z-index', '15');
  368. $showView = $(classOrIdName);
  369. $tempShowView = $showView;
  370. $showView.css('display', 'block');
  371. $showView.css('position', 'absolute');
  372. // $showView.css('top', $(window).height() / 2.2);
  373. $showView.css('top', $(window).height() / 3.2);
  374. $showView.css('left', '50%');
  375. $showView.css('z-index', '20');
  376. $showView.css('background', 'white');
  377. var w = $showView.css('width');
  378. var h = $showView.css('height');
  379. w = w.substr(0, w.length - 2);
  380. h = h.substr(0, h.length - 2);
  381. $showView.css('margin-top', '-' + h / 2 + 'px');
  382. $showView.css('margin-left', '-' + w / 2 + 'px');
  383. }
  384. // 点击蒙板
  385. function clickMask() {
  386. $('#up_base_room').css('display', 'none');
  387. $('#up_parent_room').css('display', 'none');
  388. $('.main_style').css('display', 'none');
  389. $('.modify_child_room').css('display', 'none');
  390. $('#mask').css('display', 'none');
  391. }
  392. // 复选框事件
  393. var child_true_count = 0;
  394. function select_checked(index, selfOBJ) {
  395. $selfOBJ = $(selfOBJ);
  396. //index=0最上面的全选 index=1表示的是下面所有的
  397. var top_check = $('.ace_check')[0];
  398. var checkList = $('.ace_check');
  399. var checkCount = checkList.length - 1;
  400. var base_count = $('.baseace').length;
  401. for (var i = 1, m = checkList.length; i < m; i++) {
  402. if (index === '0') {
  403. checkList[i].checked = top_check.checked;
  404. } else if (index === '1') {
  405. // 当前的base为选中
  406. var room_type = $selfOBJ.closest('.base').attr('data-room-type');
  407. var t = $(checkList[i]).parent().parent().parent().attr('class');
  408. if (t === "child" + room_type) {
  409. checkList[i].checked = selfOBJ.checked;
  410. }
  411. } else {
  412. // if(selfOBJ===checkList[i] && selfOBJ.checked){
  413. // child_true_count+=1;
  414. // }
  415. // var t=$selfOBJ.parent().parent().parent().attr('class');
  416. // var parent_room_type=t.replace('child','');
  417. // var child_count=$('.child'+parent_room_type).length;
  418. // var ttt=$('.child'+parent_room_type);
  419. //
  420. // var room_type=$(checkList[i]).parent().parent().parent().attr('data-room-type');
  421. // ZZLog(child_count+"<><><>"+child_true_count);
  422. // if(room_type===parent_room_type && child_true_count===child_count){
  423. // checkList[i].checked=selfOBJ.checked;
  424. // }
  425. }
  426. }
  427. if (!$selfOBJ.hasClass('child_room')) {
  428. $("#room_list").find('[data-p-room-type=' + $selfOBJ.closest('tr').attr('data-room-type') + ']').find('input[type=checkbox]').prop('checked', $selfOBJ.prop('checked'))
  429. }
  430. }
  431. // 浮动复选框事件
  432. function alterCheck(obj) {
  433. $obj = obj;
  434. $('.ace_check')[0].checked = $obj.checked;
  435. select_checked('0', $('.ace_check')[0]);
  436. }
  437. function getDataFromHttp() {
  438. // var urlapi = base_api + "?type=room_RoomList&hotel_id=" + hotel_id + "&start_date=" + d1 + "&sale_status=" + room_sale_status + "&current=" + current + "&page_size=" + page_size + "&base_room_type=" + base_room_type;
  439. var urlapi = base_api + "?type=room_RoomList&op=get_channel_room_info&channel_id=" + channel_id + "&hotel_id=" + hotel_id + "&start_date=" + d1 + "&sale_status=" + room_sale_status + "&current=" + current
  440. + "&page_size=" + page_size;
  441. ZZLog(urlapi);
  442. $.ajaxSetup({
  443. async: false
  444. });
  445. $.getJSON(urlapi, function (res_data) {
  446. console.log(res_data);
  447. ZZLog(res_data);
  448. if (res_data['code'] !== "0") {
  449. alert(res_data['info']);
  450. } else {
  451. var HTML = '';
  452. var room_list = res_data['room_list'];
  453. for (var i = 0, m = room_list.length; i < m; i++) {
  454. var tempDict = room_list[i];
  455. var tempHTML = '';
  456. if (tempDict['parent_room_type'] === "0") {
  457. tempHTML = baseHTML;
  458. HTML += setBaseHTML(tempHTML, tempDict);
  459. } else {
  460. tempHTML = childHTML;
  461. HTML += setChildHTML(tempHTML, tempDict);
  462. }
  463. }
  464. if (HTML) {
  465. $('#room_list').html(HTML).css('display', 'table-row-group');
  466. $('#table').show();
  467. if (res_data['total'] < 1) {
  468. $('.pageDiv').hide();
  469. } else {
  470. $(".pageDiv").createPage({
  471. pageCount: res_data['total_page'],//总页数
  472. current: current,//当前页
  473. turndown: 'true',//是否显示跳转框,显示为true,不现实为false,一定记得加上引号...
  474. backFn: function (p) {
  475. current = p;
  476. getDataFromHttp();
  477. }
  478. });
  479. $('.pageDiv').show();
  480. }
  481. // 添加好innerHTML再添加事件
  482. baseAddEvent();
  483. bdayAddEvent();
  484. cdayAddEvent();
  485. onOffLineAddEvent();
  486. saleRule();
  487. $('.bday').each(function (index, domEle) { // 给子房型添加按钮
  488. if ($(this).attr('data-value') === "") {
  489. $(this).css('background', '');
  490. $(this).css('text-align', 'center');
  491. $(this).css('vertical-align', 'middle');
  492. $(this).html('暂无');
  493. }
  494. })
  495. $('.cday').each(function (index, domEle) { // 基础房型设置信息
  496. if ($(this).attr('data-value') === "||") {
  497. $(this).html('暂无');
  498. $(this).css('text-align', 'center');
  499. $(this).css('vertical-align', 'middle');
  500. $(this).css('background', '');
  501. }
  502. })
  503. } else {
  504. $('#room_list').html(HTML);
  505. $('#table').show();
  506. }
  507. }
  508. $("#table-data").removeClass('hidden');
  509. $("#table-thead").removeClass('hidden');
  510. }).error(function (msg) {
  511. $("#table-data").addClass('hidden');
  512. $("#table-thead").addClass('hidden');
  513. ZZAlertInfo('系统错误,请联系管理员!');
  514. });
  515. $.ajaxSetup({
  516. async: true
  517. });
  518. $("#all_check_box").prop('checked', false);
  519. }
  520. // 给.base添加事件
  521. function baseAddEvent() {
  522. $('.base_room').each(function (index, domEle) {
  523. $(this).children().eq(1).bind('click', function () {
  524. var siblings = $(this).parent().siblings();
  525. var parent_type = $(this).parent().attr('data-room-type');
  526. if ($(this).find('img').attr('src') == 'images/down_arrow.png') {
  527. $(this).find('img').attr('src', 'images/up_arrow.png');
  528. siblings.each(function (item, value) {
  529. if ($(this).attr('data-p-room-type') == parent_type) {
  530. $(this).addClass('hidden');
  531. }
  532. });
  533. } else if ($(this).find('img').attr('src') == 'images/up_arrow.png') {
  534. $(this).find('img').attr('src', 'images/down_arrow.png');
  535. siblings.each(function (item, value) {
  536. if ($(this).attr('data-p-room-type') == parent_type) {
  537. $(this).removeClass('hidden');
  538. }
  539. });
  540. }
  541. });
  542. })
  543. }
  544. // 给.bday添加事件
  545. var $temp_bday = null;
  546. function bdayAddEvent() {
  547. $('.bday').bind('click', function (e) {
  548. number = $(this).attr('childindex'); //当前点击的是第几天
  549. if ($temp_bday !== null) {
  550. $temp_bday.css('background', '');
  551. $temp_bday.css('color', '');
  552. }
  553. if ($temp_cday !== null) {
  554. $temp_cday.css('background', '');
  555. $temp_cday.css('color', '');
  556. }
  557. setParentData(this);
  558. showCenterView('#up_parent_room');
  559. $('#mask')
  560. .css('display', 'block')
  561. .css('background', 'white')
  562. .css('opacity', '0');
  563. var mouseTop = $(this).offset().top;
  564. var td_height = parseInt($(this).css('height').replace('px', ''));
  565. $(this).css('background', '#4191ff');
  566. $(this).css('color', '#fff');
  567. $('#up_parent_room')
  568. .css('top', mouseTop + td_height + 'px')
  569. .css('display', 'block')
  570. .attr('')
  571. $temp_bday = $(this);
  572. })
  573. }
  574. // 给.cday添加事件
  575. var $temp_cday = null;
  576. function cdayAddEvent() {
  577. $('.cday').bind('click', function () {
  578. url = base_api;
  579. number = $(this).attr('childindex')-1; //当前点击的是第几天
  580. now_date = $('#f_date'+number).attr('f_date');
  581. room_type = $(this).attr('data-room-type');
  582. parent_room_type = $(this).attr('data-parent-room-type');
  583. distrib_id = $("#channel_list").val();
  584. var param = {
  585. type: "room_distribRoomService",
  586. op: "getRunDistribRoomNowInfo",
  587. hotel_id: hotel_id,
  588. room_type: room_type,
  589. parent_room_type: parent_room_type,
  590. now_date: now_date,
  591. distrib_id: distrib_id
  592. };
  593. $.ajax({
  594. url: url,
  595. type: 'post',
  596. data: param,
  597. success: function (res_data) {
  598. res_data = JSON.parse(res_data);
  599. if(res_data != null) {
  600. var gift = res_data['gift'] == ''?'无':res_data['gift'][0]['GIFT_NAME'];
  601. var res = res_data['rowset'][0];
  602. var latest_confirm_time = formatterTime(res['LATEST_COMFIRM_TIME']);
  603. var latest_book_time = formatterTime(res['LASTEST_BOOK_TIME']);
  604. var latest_cancel_time = formatterTime(res['LASTEST_CANCEL_DAY']);
  605. if(res['AUTO_CLOSE'] == 1){
  606. auto_close = '是';
  607. }else if(res['AUTO_CLOSE'] == 0){
  608. auto_close = '否';
  609. }else{
  610. auto_close = '不变';
  611. }
  612. $('#latest_confirm_time').html(latest_confirm_time);
  613. $('#latest_book_time').html(latest_book_time);
  614. $('#latest_cancel_time').html(latest_cancel_time);
  615. $('#auto_close_info').html(auto_close);
  616. $('#gift_info').html(gift);
  617. }
  618. }
  619. });
  620. if ($temp_cday !== null) {
  621. $temp_cday.css('background', '');
  622. $temp_cday.css('color', '');
  623. }
  624. if ($temp_bday !== null) {
  625. $temp_bday.css('background', '');
  626. $temp_bday.css('color', '');
  627. }
  628. if ($(this).attr('data-parent-room-type') !== '') {
  629. setData(this);
  630. showCenterView('#up_base_room');
  631. $('#mask')
  632. .css('display', 'block')
  633. .css('background', 'white')
  634. .css('opacity', '0');
  635. var mouseTop = $(this).offset().top;
  636. var td_height = parseInt($(this).css('height').replace('px', ''));
  637. $(this).css('background', '#4191ff');
  638. $(this).css('color', '#fff');
  639. $('#up_base_room')
  640. .css('top', mouseTop + td_height + 'px')
  641. .css('display', 'block')
  642. .attr('')
  643. }
  644. $temp_cday = $(this);
  645. })
  646. }
  647. function formatterTime(obj){
  648. var res = '';
  649. if(obj == 0){
  650. res = '不变';
  651. }else if(obj == -1){
  652. res = '不设置';
  653. }else if(obj == null){
  654. res = '无';
  655. }else{
  656. res = obj.replace(',','天前');
  657. }
  658. return res;
  659. }
  660. function setData(obj) {
  661. $("#parent_room_type").val($(obj).attr('data-parent-room-type'));
  662. $("#room_type").val($(obj).attr('data-room-type'));
  663. $("#run_status").val($(obj).attr('data-status'));
  664. $("#remain_count").val($(obj).attr('data-count'));
  665. $("input[name='overSale'][value='" + $(obj).attr('data-over-sell') + "']").prop("checked", true);
  666. if ($(obj).attr('data-count') === '177') {
  667. $("#sell_type").val('分销价:');
  668. } else {
  669. $("#sell_type").val('零售价:');
  670. }
  671. $("#max_stock").val($(obj).attr('data-max-count'));
  672. $("#sell_value").val($(obj).attr('data-value'));
  673. }
  674. function setParentData(obj) {
  675. $("#b_parent_room_type").val($(obj).closest('tr').attr('data-room-type'));
  676. // ::todo 渠道保底
  677. var stock = $(obj).attr('data-value').split('/');
  678. $("#count_buyout").val(stock[0]);
  679. $("#count_keep").val(stock[1]);
  680. $("#count_ask").val(stock[2]);
  681. }
  682. //销售规则
  683. function saleRule() {
  684. $('.child_sale_rule').bind('click', function () {
  685. localStorage.setItem('start_date', d1);
  686. localStorage.setItem('current', current);
  687. var _hotel_id = hotel_id;
  688. var _parent_room_type = $(this).closest('tr').attr('data-parent-room-type');
  689. var _room_type = $(this).closest('tr').attr('data-room-type');
  690. var _room_type_str = $(this).closest('tr').children().eq(1).text();
  691. var _start_date = $("#Wdate").val();
  692. var listURL = "sell_rule_main.html?hotel_id=" + _hotel_id + "&room_type_id=" + _room_type + "&room_type_name=" + _room_type_str + "&parent_room_type=" + _parent_room_type + "&start_date=" + _start_date;
  693. listURL = encodeURI(listURL);
  694. window.location.href = listURL;
  695. })
  696. }
  697. // 设置表格头部的td
  698. function setTbTopTd() {
  699. // 设置标题的日期和星期
  700. var today = getDateTime(0);
  701. if (d1 === "") {
  702. /*if (localStorage.getItem("start_date") !== null) {
  703. d1 = localStorage.getItem("start_date")
  704. } else {
  705. d1 = today;
  706. }*/
  707. d1 = today;
  708. }
  709. if (date_flag === 0) {
  710. var start_date = getPar('start_date');
  711. if (start_date !== '')
  712. d1 = getDateTime(0, new Date(start_date));
  713. date_flag = 1;
  714. }
  715. $('#current_date').val(d1);
  716. d2 = after(d1);
  717. d3 = after(d2);
  718. d4 = after(d3);
  719. d5 = after(d4);
  720. d6 = after(d5);
  721. d7 = after(d6);
  722. w1 = getWeekDay(d1);
  723. w2 = getWeekDay(d2);
  724. w3 = getWeekDay(d3);
  725. w4 = getWeekDay(d4);
  726. w5 = getWeekDay(d5);
  727. w6 = getWeekDay(d6);
  728. w7 = getWeekDay(d7);
  729. $('#f_date1').attr('f_date', d1);
  730. $('#f_date2').attr('f_date', d2);
  731. $('#f_date3').attr('f_date', d3);
  732. $('#f_date4').attr('f_date', d4);
  733. $('#f_date5').attr('f_date', d5);
  734. $('#f_date6').attr('f_date', d6);
  735. $('#f_date7').attr('f_date', d7);
  736. var td1 = d1.substring(5);
  737. var td2 = d2.substring(5);
  738. var td3 = d3.substring(5);
  739. var td4 = d4.substring(5);
  740. var td5 = d5.substring(5);
  741. var td6 = d6.substring(5);
  742. var td7 = d7.substring(5);
  743. $('#f_date1').html(td1 + " " + w1);
  744. $('#f_date2').html(td2 + " " + w2);
  745. $('#f_date3').html(td3 + " " + w3);
  746. $('#f_date4').html(td4 + " " + w4);
  747. $('#f_date5').html(td5 + " " + w5);
  748. $('#f_date6').html(td6 + " " + w6);
  749. $('#f_date7').html(td7 + " " + w7);
  750. // 将日期为今天的星期设置为今天
  751. $('th[f_date=' + getDateTime(0) + ']').html(getDateTime(0).substring(5) + ' 今天');
  752. }
  753. function setBaseHTML(tempHTML, tempDict) {
  754. //对接的渠道,有前台按钮
  755. if (tempDict['web_url'] !== undefined && tempDict['channel_data_id'] !== '0') {
  756. $("#website a").attr('href', tempDict['web_url']);
  757. $("#website").removeClass('hidden');
  758. } else {
  759. $("#website").addClass('hidden');
  760. }
  761. var HTML = '';
  762. for (var i = 1; i <= 7; i++) {
  763. var cstr = 'cstr' + i;
  764. var date = 'date' + i;
  765. var s = 's' + i;
  766. window[cstr] = '';
  767. window[date] = tempDict['date' + i]
  768. window[s] = (window['date' + i]['buyout_count'] === '' ? '0' : window['date' + i]['buyout_count']) + '/' + (window['date' + i]['reserve_count'] === '' ? '0' : window['date' + i]['reserve_count']) + '/' + (window['date' + i]['inquiry_count'] === '' ? '0' : window['date' + i]['inquiry_count']);
  769. }
  770. tempHTML = tempHTML.replace('[房型名称]', tempDict['room_name']);
  771. tempHTML = tempHTML.replace('[table_switch]', '<img src="images/down_arrow.png">');
  772. tempHTML = tempHTML.replace('[update-room-name]', tempDict['room_name']);
  773. tempHTML = tempHTML.replace('[tr-room-type]', tempDict['room_type']);
  774. tempHTML = tempHTML.replace('[room-type]', tempDict['room_type']);
  775. tempHTML = tempHTML.replace('[total-count1]', date1['remain_count']);
  776. tempHTML = tempHTML.replace('[total-count2]', date2['remain_count']);
  777. tempHTML = tempHTML.replace('[total-count3]', date3['remain_count']);
  778. tempHTML = tempHTML.replace('[total-count4]', date4['remain_count']);
  779. tempHTML = tempHTML.replace('[total-count5]', date5['remain_count']);
  780. tempHTML = tempHTML.replace('[total-count6]', date6['remain_count']);
  781. tempHTML = tempHTML.replace('[total-count7]', date7['remain_count']);
  782. for (var i = 1; i <= 7; i++) {
  783. if (window['date' + i]['inventory_type'] !== "") {
  784. window['cstr' + i] =
  785. //'<img data-inventory-type=' + date1["inventory_type"] + ' style="float: right;margin-top: -8px;margin-right: -9px;" src="images/' + date1["inventory_type"] + '.png"/>'
  786. '<span>已售' + (window['date' + i]['saled_count'] === '' ? '0' : window['date' + i]['saled_count']) + '</span></br>'
  787. + '<span> </span></br>'
  788. + '<span>剩余' + window['s' + i] + '</span>';
  789. //+ '<span>采购:' + date1["base_price"] + '</span>';
  790. tempHTML = tempHTML.replace('[value' + i + ']', (window['date' + i]['buyout_count'] === '' ? '0' : window['date' + i]['buyout_count']) + '/' + (window['date' + i]['reserve_count'] === '' ? '0' : window['date' + i]['reserve_count']) + '/' + (window['date' + i]['inquiry_count'] === '' ? '0' : window['date' + i]['inquiry_count']));
  791. } else {
  792. tempHTML = tempHTML.replace('[value' + i + ']', "");
  793. }
  794. tempHTML = tempHTML.replace('[day' + i + ']', window['cstr' + i]);
  795. }
  796. rp_id = tempDict['rp_id'];
  797. channel_base_room_id = tempDict['channel_base_room_id'];
  798. if (channel_id == 675) // 当前渠道为阿里
  799. {
  800. // $('#rp').css('display', 'block');
  801. // $('.rp').css('display', 'block');
  802. tempHTML = tempHTML.replace('[close]', '关');
  803. if (channel_base_room_id == 0) {
  804. tempHTML = tempHTML.replace('[image]', '<img class=\"image_class\" src="images/OffSwitch.png" style=\"height: 14px;width: 53*16/36px;\" onclick=\"baseImageClick(this, 1)\" isopen="0">');
  805. } else {
  806. tempHTML = tempHTML.replace('[image]', '<img class=\"image_class\" src="images/OnSwitch.png" style=\"height: 14px;width: 53*16/36px;\" onclick=\"baseImageClick(this, 1)\" isopen="1">');
  807. }
  808. tempHTML = tempHTML.replace('[open]', '开');
  809. } else {
  810. tempHTML = tempHTML.replace('[close]', '');
  811. tempHTML = tempHTML.replace('[image]', '');
  812. tempHTML = tempHTML.replace('[open]', '');
  813. }
  814. HTML += tempHTML;
  815. return HTML;
  816. }
  817. function setChildHTML(tempHTML, tempDict) {
  818. tempHTML = tempHTML.replace('[room_type_id]', tempDict['room_type']);
  819. tempHTML = tempHTML.replace('[p_room_type_id]', tempDict['parent_room_type']);
  820. tempHTML = tempHTML.replace('[data-hotel-id]', tempDict['hotel_id']);
  821. tempHTML = tempHTML.replace('[data-hotel-room-id]', tempDict['opera_hotel_room_id']);
  822. var auth_status = '';
  823. for (i = 1; i <= 7; i++) {
  824. tmpData = tempDict['date' + i];
  825. if (tmpData['price'] === '') { //没有价格就说明没有设置房态
  826. // tempHTML.replace('[left]', tmpData['remain_count']);
  827. tempHTML = tempHTML.replace('[p_room_type' + i + ']', '');
  828. day_str = '<div class="none" >暂无</div>';
  829. channel_room_id = tempDict['channel_data_id'];
  830. channel_base_room_id = tempDict['channel_base_room_id'];
  831. rp_id = tempDict['rp_id'];
  832. } else {
  833. if(tmpData['gift_id'] === null || tmpData['gift_id'] === '0'){
  834. var day_str = '<div style="text-align: left" ><span>已售 ' + (tmpData['saled_count'] === '' ? '0' : tmpData['saled_count']) + '</span></br>'
  835. + '<div><span style="display: inline-block;">剩余 ' + tmpData['remaining_count'] + '</span><span class="label label-warning overRight">' + (tmpData['oversell_flag'] === '1' ? '超卖' : '') + '</span></div>'
  836. + '<span>' + (tempDict['sale_type'] === '177' ? '分销价 ' : '零售价') + tmpData['price'] + '</span></div>';
  837. }else{
  838. var day_str = '<div style="text-align: left" ><span>已售 ' + (tmpData['saled_count'] === '' ? '0' : tmpData['saled_count']) + '</span><span class="label label-danger gift-icon">礼</span></br>'
  839. + '<div><span style="display: inline-block;">剩余 ' + tmpData['remaining_count'] + '</span><span class="label label-warning overRight">' + (tmpData['oversell_flag'] === '1' ? '超卖' : '') + '</span></div>'
  840. + '<span>' + (tempDict['sale_type'] === '177' ? '分销价 ' : '零售价') + tmpData['price'] + '</span></div>';
  841. }
  842. var tmp_full = '';
  843. if (tmpData['run_full'] === '329') {
  844. tmp_full = '<div class="over-full" ></div>';
  845. }
  846. if (tmpData['run_status'] === '329') {
  847. tmp_full = '<div class="over-closing" ></div>';
  848. }
  849. day_str += tmp_full;
  850. tempHTML = tempHTML.replace('[p_room_type' + i + ']', tempDict['parent_room_type']);
  851. tempHTML = tempHTML.replace('[room_type' + i + ']', tempDict['room_type']);
  852. tempHTML = tempHTML.replace('[total_count' + i + ']', tmpData['remaining_count']);
  853. tempHTML = tempHTML.replace('[over_sell' + i + ']', tmpData['oversell_flag']);
  854. tempHTML = tempHTML.replace('[value' + i + ']', tmpData['price']);
  855. tempHTML = tempHTML.replace('[run_status' + i + ']', tmpData['run_status']);
  856. tempHTML = tempHTML.replace('[run_full' + i + ']', tmpData['run_full']);
  857. }
  858. if (auth_status === '') {
  859. auth_status = tempDict['NEW_AUTHORITY_STATUS'];
  860. if (auth_status === "0") {
  861. tempHTML = tempHTML.replace('isopen="1"', 'isopen="0"');
  862. tempHTML = tempHTML.replace('images/OnSwitch.png', 'images/OffSwitch.png');
  863. } else if (auth_status === "1") {
  864. tempHTML = tempHTML.replace('isopen="0"', 'isopen="1"');
  865. tempHTML = tempHTML.replace('images/OffSwitch.png"', 'images/OnSwitch.png"');
  866. } else { //当没有取到的时候,默认是没有授权
  867. tempHTML = tempHTML.replace('isopen="1"', 'isopen="0"');
  868. tempHTML = tempHTML.replace('images/OnSwitch.png', 'images/OffSwitch.png');
  869. }
  870. }
  871. channel_room_id = tempDict['channel_data_id']; // 渠道子房型id
  872. channel_base_room_id = tempDict['channel_base_room_id']; // 渠道基础房型id
  873. rp_id = tempDict['rp_id']; // 房型价格计划
  874. if (channel_id != 675) // 当渠道是携程
  875. {
  876. tempHTML = tempHTML.replace('[close1]', '关');
  877. if (channel_room_id == 0) {
  878. tempHTML = tempHTML.replace('[image1]', '<img class=\"image_class\" src="images/OffSwitch.png" style=\"height: 14px;width: 53*16/36px;\" onclick=\"mapping_onclick(this)\" isopen="0">');
  879. } else {
  880. tempHTML = tempHTML.replace('[image1]', '<img class=\"image_class\" src="images/OnSwitch.png" style=\"height: 14px;width: 53*16/36px;\" onclick=\"mapping_onclick(this)\" isopen="1">');
  881. }
  882. tempHTML = tempHTML.replace('[open1]', '开');
  883. tempHTML = tempHTML.replace('[close2]', '-');
  884. tempHTML = tempHTML.replace('[image2]', '-');
  885. tempHTML = tempHTML.replace('[open2]', '-');
  886. tempHTML = tempHTML.replace('[房型名称]', tempDict['room_name'] + (tempDict['mapping_id'] !== '0' ? '<br /><br /><span class="label label-success">' + tempDict['mapping_id'] + '</span>' : ''));
  887. } else if (channel_id == 675) {
  888. // $('.rp_image').css('display', 'block');
  889. tempHTML = tempHTML.replace('[close1]', '');
  890. tempHTML = tempHTML.replace('[image1]', '');
  891. tempHTML = tempHTML.replace('[open1]', '');
  892. tempHTML = tempHTML.replace('[close2]', '关');
  893. if (rp_id == 0 || rp_id == null) {
  894. tempHTML = tempHTML.replace('[image2]', '<img class=\"image_class\" src="images/OffSwitch.png" style=\"height: 14px;width: 53*16/36px;\" onclick=\"baseImageClick(this, 2)\" isopen="0">');
  895. } else {
  896. tempHTML = tempHTML.replace('[image2]', '<img class=\"image_class\" src="images/OnSwitch.png" style=\"height: 14px;width: 53*16/36px;\" onclick=\"baseImageClick(this, 2)\" isopen="1">');
  897. }
  898. tempHTML = tempHTML.replace('[open2]', '开');
  899. tempHTML = tempHTML.replace('[房型名称]', tempDict['room_name'] + (!(rp_id == 0 || rp_id == null) ? '<br /><br /><span class="label label-success">' + rp_id + '</span>' : ''));
  900. }
  901. tempHTML = tempHTML.replace('[cday' + i + ']', day_str);
  902. }
  903. return tempHTML;
  904. }
  905. // 点击按钮发送请求(阿里直连使用)
  906. function baseImageClick(obj, type) {
  907. loading();
  908. var start = new Date().getTime();
  909. var $par_tr = $(obj).closest('tr');
  910. var _hotel_id = hotel_id; // 酒店ID
  911. var is_open = $(obj).attr('isopen'); // 判断开关状态
  912. // 1. 基础房型直连, 2. rp开关
  913. if (type == 1) {
  914. var parent_room_type = $par_tr.attr('data-room-type'); // 基础房型id
  915. var utype = 'room_base_SetBaseRoom';
  916. var op = 'push_room';
  917. } else if (type == 2) {
  918. var parent_room_type = $par_tr.attr('data-p-room-type'); // 基础房型id
  919. var utype = 'room_base_SetBaseRoom';
  920. var op = 'push_rp';
  921. var room_type = $par_tr.attr('data-room-type-id');
  922. }
  923. if ($(obj).attr('isopen') == "0") {
  924. apiurl = base_api + "?type=" + utype + "&op=" + op + "&hotel_id=" + _hotel_id + "&parent_room_type=" + parent_room_type + "&room_type=" + room_type + "&is_open=" + is_open;
  925. ZZLog(apiurl);
  926. $.getJSON(apiurl, function (res_data) {
  927. if (res_data['code'] != 200) {
  928. ZZAlertInfo(res_data['msg']);
  929. } else {
  930. $('#today').trigger('click');
  931. }
  932. }).error(function (msg) {
  933. })
  934. } else {
  935. apiurl = base_api + "?type=" + utype + "&op=" + op + "&hotel_id=" + _hotel_id + "&parent_room_type=" + parent_room_type + "&room_type=" + room_type + "&is_open=" + is_open;
  936. ZZLog(apiurl);
  937. //alert('345');
  938. $.getJSON(apiurl, function (res_data) {
  939. if (res_data['code'] != 200) {
  940. ZZAlertInfo(res_data['msg']);
  941. } else {
  942. $('#today').trigger('click');
  943. }
  944. })
  945. }
  946. var end = new Date().getTime();
  947. if (end - start > 1500) {
  948. closeLoading();
  949. } else {
  950. setTimeout(closeLoading, 1500 - (end - start));
  951. }
  952. }
  953. function getRoomID() {
  954. localStorage.setItem('start_date', d1);
  955. localStorage.setItem('current', current);
  956. var arrids = [];
  957. $('.childace').each(function (index, domEle) {
  958. if (domEle.checked) {
  959. arrids.push($(this).attr('room-type'));
  960. }
  961. });
  962. var ids = arrids.join(",");
  963. if (ids === '') {
  964. alert('请勾选子房型');
  965. return
  966. }
  967. var start_date = $('#Wdate').val();
  968. window.location.href = "batch_modify_hotel_price.html?hotel_id=" + hotel_id + "&ids=" + ids + "&start_date=" + start_date + "&hotel_name=" + hotel_name;
  969. }
  970. function getRoomStatus() {
  971. var arrids = [];
  972. $('.childace').each(function (index, domEle) {
  973. if (domEle.checked) {
  974. arrids.push($(this).attr('room-type'));
  975. }
  976. });
  977. var ids = arrids.join(",");
  978. if (ids === '') {
  979. alert('请勾选子房型');
  980. return
  981. }
  982. var start_date = $('#Wdate').val();
  983. window.location.href = "batch_modify_hotel_status.html?hotel_id=" + hotel_id + "&ids=" + ids + "&start_date=" + start_date + "&hotel_name=" + hotel_name;
  984. }
  985. //修改子房型
  986. var $tempModify = null;
  987. var param = [];
  988. var child_room_type = '';
  989. var parent_room_type1 = '';
  990. var parent_room_name = '';
  991. // 修改选择入住人数
  992. function mdchangePeople(selfOBJ) {
  993. var $selfOBJ = $(selfOBJ);
  994. var count = $selfOBJ.val();
  995. if (count < 100) {
  996. cstr1 = "(" + count + "人入住)";
  997. } else {
  998. cstr1 = '';
  999. }
  1000. var tstr = cstr3 + parent_room_name + cstr1 + cstr2;
  1001. $('.data-child-room-name').val(tstr.trim());
  1002. }
  1003. //选择最晚预订时间
  1004. function mdChangeLastestBook(selfOBJ) {
  1005. var $selfOBJ = $(selfOBJ);
  1006. var fast = parseInt($selfOBJ.val());
  1007. switch (fast) {
  1008. case 0:
  1009. fast = "";
  1010. break;
  1011. case 1:
  1012. fast = "提前一天";
  1013. break;
  1014. case 2:
  1015. fast = "提前二天";
  1016. break;
  1017. case 3:
  1018. fast = "提前三天";
  1019. break;
  1020. case 4:
  1021. fast = "提前四天";
  1022. break;
  1023. case 5:
  1024. fast = "提前五天";
  1025. break;
  1026. case 6:
  1027. fast = "提前六天";
  1028. break;
  1029. case 7:
  1030. fast = "提前七天";
  1031. break;
  1032. case -1:
  1033. fast = "——";
  1034. break;
  1035. }
  1036. if (fast !== "") {
  1037. cstr3 = "[" + fast + "]";
  1038. } else {
  1039. cstr3 = "";
  1040. }
  1041. var tstr = cstr3 + parent_room_name + cstr1 + cstr2;
  1042. $('.data-child-room-name').val(tstr.trim());
  1043. }
  1044. // 选择早餐
  1045. function mdchangeBreakfast(selfOBJ) {
  1046. var $selfOBJ = $(selfOBJ);
  1047. var fast = parseInt($selfOBJ.val());
  1048. switch (fast) {
  1049. case 0:
  1050. fast = "无早";
  1051. break;
  1052. case 1:
  1053. fast = "单早";
  1054. break;
  1055. case 2:
  1056. fast = "双早";
  1057. break;
  1058. case 3:
  1059. fast = "三早";
  1060. break;
  1061. case 4:
  1062. fast = "四早";
  1063. break;
  1064. case 5:
  1065. fast = "五早";
  1066. break;
  1067. case 6:
  1068. fast = "六早";
  1069. break;
  1070. case 7:
  1071. fast = "七早";
  1072. break;
  1073. case 8:
  1074. fast = "八早";
  1075. break;
  1076. case 9:
  1077. fast = "九早";
  1078. break;
  1079. case 10 :
  1080. fast = "十早";
  1081. break;
  1082. }
  1083. cstr2 = "[" + fast + "]";
  1084. var tstr = cstr3 + parent_room_name + cstr1 + cstr2;
  1085. $('.data-child-room-name').val(tstr.trim());
  1086. }
  1087. //选择现询变999
  1088. function xianxun999() {
  1089. if ($('#base_stock_type').val() === 229) {
  1090. $('#base_count').val(999)
  1091. }
  1092. }
  1093. //查询
  1094. function search() {
  1095. base_room_type = $('#base_room_type').val();
  1096. room_sale_status = $('#sale_status').val();
  1097. d1 = $('.Wdate').val();
  1098. // 设置tb_top_td
  1099. setTbTopTd();
  1100. if (d1 !== "") {
  1101. // http
  1102. current = 1;
  1103. getDataFromHttp();
  1104. }
  1105. }
  1106. /*
  1107. 渠道商所有房型房态
  1108. */
  1109. function channelRoom(obj) {
  1110. var listURL = "sell_rule_main.html?hotel_id=" + _hotel_id + "&room_type_id=" + _room_type + "&room_type_name=" + _room_type_str + "&parent_room_type=" + _parent_room_type + "&start_date=" + _start_date;
  1111. listURL = encodeURI(listURL);
  1112. window.location.href = listURL;
  1113. }
  1114. function showDialog() {
  1115. $('#updateAll').unbind('click');
  1116. $('#updateAll').bind('click', function () {
  1117. input_time = $('#input_time').val();
  1118. $('#start_date_update').val(input_time);
  1119. $('#end_date_update').val(getDateByDay(6, input_time));
  1120. if (check_distrib_id.length === 0) { //没有选中的情况,弹出提示框
  1121. alert('请选中需要批量修改的渠道商!');
  1122. return;
  1123. }
  1124. //$('#one').css('display','block');
  1125. $('#mask').css('background', 'white');
  1126. $('#mask').css('opacity', '0.5');
  1127. $("#authorized_stock_num_many").val('');
  1128. $("#distribution_price_many").val('');
  1129. $("#retail_price_many").val('');
  1130. showCenterView('#up_base_room');
  1131. });
  1132. }
  1133. function saveChildUpdate() {
  1134. //alert(new Date(d1).getDay()); //当前页面上第一天是星期几
  1135. //当前点击的是第number个日期,可以获取到具体的日期
  1136. //alert(number);
  1137. var _td_date = $('.tb_title').children().eq(number).attr('f_date'); //当前点击的日期
  1138. //alert(_td_date);return;
  1139. var startDate = _td_date;
  1140. var endDate = _td_date;
  1141. var allCheckString = "2345671"; //para_week_day,存储过程中的参数
  1142. var authorizedStock = $('#run_status').val();
  1143. var authorizedStockNum = $('#remain_count').val();
  1144. var distributionPrice = $('#sell_value').val() === '' ? 0 : $('#sell_value').val();
  1145. var overSaleOne = $("input[name='overSale']:checked").val();
  1146. if (startDate === "" || endDate === "" || allCheckString === "" || authorizedStock === "" || authorizedStockNum === "") {
  1147. alert('您还有未输入的选项!');
  1148. return;
  1149. }
  1150. if (distributionPrice === "" && retailPrice === "") {
  1151. alert('您还有未输入的选项!');
  1152. // alert('startDate:'+startDate);
  1153. // alert('endDate:'+endDate);
  1154. // alert('allCheckString:'+allCheckString);
  1155. // alert('authorizedStock:'+authorizedStock);
  1156. // alert('authorizedStockNum:'+authorizedStockNum);
  1157. // alert('distributionPrice:'+distributionPrice);
  1158. // alert('retailPrice:'+retailPrice);
  1159. return;
  1160. }
  1161. parent_room_type = $("#parent_room_type").val();
  1162. room_type_id = $("#room_type").val();
  1163. distrib_id_checkd = channel_id;
  1164. var urlapi = base_api;
  1165. var param = {
  1166. type: "hotel_SaleRuleInfo",
  1167. op: "updateAuthorizeInfo",
  1168. para_user_id: 1,
  1169. para_hotel_id: hotel_id,
  1170. para_base_room_type: parent_room_type,
  1171. para_room_type: room_type_id,
  1172. para_distrib_list: distrib_id_checkd,
  1173. para_start_date: startDate,
  1174. para_end_date: endDate,
  1175. para_week_day: allCheckString,
  1176. para_stock_type: authorizedStock,
  1177. para_stock_num: authorizedStockNum,
  1178. para_prod_price: distributionPrice,
  1179. para_cus_price: distributionPrice,
  1180. para_over_sale: overSaleOne,
  1181. disable_validate: 'off'
  1182. };
  1183. // alert(urlapi + JSON.stringify(param));
  1184. ZZLog(urlapi + JSON.stringify(param));
  1185. $("#one_save").html('保存中');
  1186. $('#one_save').css('background', 'darkgray');
  1187. loading();
  1188. $.ajax({
  1189. url: urlapi,
  1190. data: param,
  1191. type: "post",
  1192. dataType: "json",
  1193. success: function (res_data) {
  1194. closeLoading();
  1195. ZZLog(res_data);
  1196. if (res_data['code'] !== "0") {
  1197. ZZAlertInfo(res_data['info']);
  1198. } else {
  1199. //alert(res_data);
  1200. getDataFromHttp();
  1201. ZZAlertInfo('修改成功' + res_data['info']);
  1202. }
  1203. $("#one_save").html('保存');
  1204. $('#one_save').css('background', '#428bca');
  1205. },
  1206. error: function (msg) {
  1207. $("#one_save").html('保存');
  1208. $('#one_save').css('background', '#428bca');
  1209. closeLoading();
  1210. }
  1211. })
  1212. $('#one').css('display', 'none');
  1213. clickMask();
  1214. }
  1215. function saveUpdate() {
  1216. var childIndex = $temp_bday.attr('childIndex');
  1217. var _td_date = $('.tb_title').children().eq(childIndex).attr('f_date');
  1218. $('#base_price').val('-1');
  1219. var _room_type = $temp_bday.parent().attr('data-room-type');
  1220. var _hotel_id = hotel_id;
  1221. var maiduan_count = $('#count_buyout').val();
  1222. var baoliu_count = $('#count_keep').val();
  1223. var xianxun_count = $('#count_ask').val();
  1224. var maiduan_cstr = "{" + _room_type + ",\"" + _td_date + "\",\"" + _td_date + "\"," + '2345671' + "," + '228' + "," + maiduan_count + "}";
  1225. var xianxun_cstr = "{" + _room_type + ",\"" + _td_date + "\",\"" + _td_date + "\"," + '2345671' + "," + '229' + "," + xianxun_count + "}";
  1226. var baoliu_cstr = "{" + _room_type + ",\"" + _td_date + "\",\"" + _td_date + "\"," + '2345671' + "," + '230' + "," + baoliu_count + "}";
  1227. baoliu_cstr = baoliu_count === '' ? '' : baoliu_cstr;
  1228. maiduan_cstr = maiduan_count === '' ? '' : maiduan_cstr;
  1229. xianxun_cstr = xianxun_count === '' ? '' : xianxun_cstr;
  1230. var cstr = baoliu_cstr + maiduan_cstr + xianxun_cstr;
  1231. if (maiduan_count < 0 || baoliu_count < 0 || xianxun_count < 0) {
  1232. ZZAlertInfo('库存数量请填写大于等于0的整数!', function () {
  1233. })
  1234. return;
  1235. }
  1236. if (cstr === '') {
  1237. ZZAlertInfo('请完整填写库存数量,没有则填写0,至少一个不为空!', function () {
  1238. })
  1239. return;
  1240. }
  1241. if (parseInt(maiduan_count) + parseInt(baoliu_count) < qudao_least) {
  1242. ZZAlertInfo('买断加保留数量不能小于渠道保底房间数!', function () {
  1243. })
  1244. return;
  1245. }
  1246. var urlapi = base_api;
  1247. var param = {
  1248. type: "room_base_SetBaseRoom",
  1249. op: "AddBaseRoom",
  1250. hotel_id: _hotel_id,
  1251. room_info: cstr
  1252. };
  1253. ZZLog(urlapi + JSON.stringify(param));
  1254. $("#parent_save").html('保存中');
  1255. loading();
  1256. // $('.save_child').css('background-color', 'darkgray !important'); //不知道什么原因,不起作用
  1257. $('#parent_save').attr('disabled', true);
  1258. $.post(urlapi, param, function (res_data) {
  1259. res_data = JSON.parse(res_data);
  1260. ZZLog(res_data);
  1261. if (res_data['code'] != "0") {
  1262. alert(res_data['info']);
  1263. } else {
  1264. clickMask();
  1265. getDataFromHttp();
  1266. }
  1267. $("#parent_save").html('保存');
  1268. $('#parent_save').attr('disabled', false);
  1269. closeLoading();
  1270. })
  1271. $('#one').css('display', 'none');
  1272. clickMask();
  1273. }
  1274. // 授权开关, 进行渠道授权
  1275. function image_onclick(obj) {
  1276. loading();
  1277. var start = new Date().getTime();
  1278. var $par_tr = $(obj).closest('tr');
  1279. var distrib_id = $("#channel_list").val();
  1280. var parent_room_type = $par_tr.attr('data-p-room-type');
  1281. var room_type_id = $par_tr.attr('data-room-type-id');
  1282. if ($(obj).attr('isopen') == "0") { //变成打开授权状态
  1283. //alert("distrib_id:"+distrib_id+" hotel_id:"+hotel_id+" parent_room_type"+parent_room_type+" room_type_id"+room_type_id);
  1284. var apiurl = base_api + "?type=hotel_SaleRuleInfo&authorize_status=" + 1 + "&hotel_id=" + hotel_id + "&parent_room_type=" + parent_room_type + "&room_type=" + room_type_id + "&op=updateAuthorizeStatus&distrib_id_string=" + distrib_id;
  1285. ZZLog(apiurl);
  1286. //alert('123');
  1287. $.getJSON(apiurl, function (res_data) {
  1288. //alert("awefawfawefwaf");
  1289. //console.log("数据:"+res_data);
  1290. if (res_data['code'] != 0) {
  1291. ZZAlertInfo(res_data['info']);
  1292. } else {
  1293. $(obj).attr('isopen', "1");
  1294. $(obj).attr('src', "images/OnSwitch.png");
  1295. }
  1296. }).error(function (msg) {
  1297. })
  1298. } else {
  1299. $(obj).attr('isopen', "0");
  1300. $(obj).attr('src', "images/OffSwitch.png");
  1301. var apiurl = base_api + "?type=hotel_SaleRuleInfo&authorize_status=" + 0 + "&hotel_id=" + hotel_id + "&parent_room_type=" + parent_room_type + "&room_type=" + room_type_id + "&op=updateAuthorizeStatus&distrib_id_string=" + distrib_id;
  1302. ZZLog(apiurl);
  1303. //alert('345');
  1304. $.getJSON(apiurl, function (res_data) {
  1305. //alert("awefawfawefwaf");
  1306. ZZLog("数据:" + res_data);
  1307. })
  1308. }
  1309. var end = new Date().getTime();
  1310. if (end - start > 1500) {
  1311. closeLoading();
  1312. } else {
  1313. setTimeout(closeLoading, 1500 - (end - start));
  1314. }
  1315. }
  1316. // 直连开关提示,渠道为非飞猪提示直连操作
  1317. function mapping_onclick(obj) {
  1318. var distrib_id = $("#channel_list").val();
  1319. if (distrib_id == 669) {
  1320. ZZAlertInfo('携程渠道访问以下链接进行设置:\nhttp://cs1.zhizhuchuxing.com/hotel/set/index');
  1321. return false;
  1322. }
  1323. if (distrib_id != 675) {
  1324. ZZAlertInfo('不支持直连操作');
  1325. return false;
  1326. }
  1327. // return false;
  1328. /*loading();
  1329. var start = new Date().getTime();
  1330. var $par_tr = $(obj).closest('tr');
  1331. var parent_room_type = $par_tr.attr('data-p-room-type');
  1332. var room_type_id = $par_tr.attr('data-room-type-id');
  1333. var _hotel_id = hotel_id;
  1334. if ($(obj).attr('isopen') == "0") { //阿里直连房型
  1335. var apiurl = 'http://cs1.wzzcx.com/hotel/ali/room-update?parent_room_type=' + parent_room_type + "&room_type=" + room_type_id + "&hotel_id=" + _hotel_id;
  1336. ZZLog(apiurl);
  1337. //alert('123');
  1338. $.getJSON(apiurl, function (res_data) {
  1339. if (res_data['code'] != 200) {
  1340. ZZAlertInfo(res_data['msg']);
  1341. } else {
  1342. $(obj).attr('isopen', "1");
  1343. $(obj).attr('src', "images/OnSwitch.png");
  1344. }
  1345. }).error(function (msg) {
  1346. })
  1347. } else { // 阿里房型断开直连
  1348. $(obj).attr('isopen', "0");
  1349. $(obj).attr('src', "images/OffSwitch.png");
  1350. var apiurl = 'http://cs1.wzzcx.com/hotel/ali/room-update?parent_room_type=' + parent_room_type + "&room_type=" + room_type_id + "&hotel_id=" + _hotel_id;
  1351. ZZLog(apiurl);
  1352. //alert('345');
  1353. $.getJSON(apiurl, function (res_data) {
  1354. //alert("awefawfawefwaf");
  1355. ZZLog("数据:" + res_data);
  1356. })
  1357. }
  1358. var end = new Date().getTime();
  1359. if (end - start > 1500) {
  1360. closeLoading();
  1361. } else {
  1362. setTimeout(closeLoading, 1500 - (end - start));
  1363. }*/
  1364. }
  1365. function onOffLineAddEvent() {
  1366. $('.child_on_off_line').bind('click', function () {
  1367. //1 shangxian
  1368. //0 xiaxian
  1369. var info = '';
  1370. var is_onsale = $(this).attr('data-value');
  1371. var room_type = $(this).closest('tr').attr('data-room-type');
  1372. var parent_room_type = $(this).closest('tr').attr('data-parent-room-type');
  1373. if (room_type === undefined) {
  1374. alert('缺少room_type参数');
  1375. return;
  1376. }
  1377. info = is_onsale === '0' ? "确定上线?" : "确定下线?";
  1378. ZZConfirm(info, function () {
  1379. var urlapi = base_api;
  1380. var param = {};
  1381. if (is_onsale == 1) {
  1382. param = {
  1383. type: "room_child_OffLineChildRoom",
  1384. hotel_id: hotel_id,
  1385. room_type: room_type,
  1386. parent_room_type: parent_room_type
  1387. }
  1388. } else {
  1389. param = {
  1390. type: "room_child_OnLineChildRoom",
  1391. hotel_id: hotel_id,
  1392. room_type: room_type,
  1393. parent_room_type: parent_room_type
  1394. }
  1395. }
  1396. ZZLog(urlapi + JSON.stringify(param));
  1397. loading();
  1398. $.ajax({
  1399. url: urlapi,
  1400. type: "post",
  1401. data: param,
  1402. success: function (res_data) {
  1403. ZZLog(res_data);
  1404. // 刷新数据
  1405. getDataFromHttp();
  1406. closeLoading();
  1407. }
  1408. });
  1409. })
  1410. });
  1411. }
  1412. function open_new(obj, action) {
  1413. var room = '';
  1414. var tr;
  1415. var arr = $('input.child_room:checked');
  1416. if (arr.length <= 0) {
  1417. ZZAlertInfo('请选择子房型!');
  1418. return true;
  1419. }
  1420. $.each(arr, function (k, e) {
  1421. tr = $(e).closest('tr');
  1422. if (room !== '') {
  1423. room += ',';
  1424. }
  1425. room += $(tr).attr('data-p-room-type') + ':' + $(tr).attr('data-room-type-id') + ':-';
  1426. });
  1427. var go_path = "zz-jd/distrib_change_price.html?action=" + action + "&hotel_name=" + hotel_name + "&hotel_id=" + hotel_id + "&start_date=" + d1 + "&room=" + room + "&channel_id=" + channel_id + "&channel_name=" + $("#channel_list>option:selected").html();
  1428. $.cookie('user_path', "2", {path: "/", domain: domain_path});
  1429. $.cookie("path_url", cookie_path + go_path, {domain: domain_path, path: "/"});
  1430. window.open(system_path);
  1431. }
  1432. /**
  1433. *获取渠道房型信息
  1434. *
  1435. */
  1436. function getChannelRoomInfo(obj) {
  1437. var url = base_api;
  1438. var _hotel_id = $(obj).attr('data-hotel-id');
  1439. var _opera_hotel_room_id = $(obj).attr('data-hotel-room-id');
  1440. var _distrib_id = $("#channel_list").val();
  1441. var param = {
  1442. type: "room_distribRoomService",
  1443. op: "getDistribRoomInfo",
  1444. hotel_id: _hotel_id,
  1445. opera_hotel_room_id: _opera_hotel_room_id,
  1446. distrib_id: _distrib_id
  1447. };
  1448. var channel_name = '';
  1449. if ($.inArray(parseInt(_distrib_id), [669, 1667, 1668, 1669, 1670]) != -1) {
  1450. $("#breakfast option[value='2']").remove();
  1451. $('#breakfast').append('<option value="2">不定</option>');
  1452. channel_name = '<select class="form-control" id="distrib_room_name" name="roomNameRemark">\n' +
  1453. ' <option value="-1">无</option>\n' +
  1454. ' <option value="572">限时特惠</option>\n' +
  1455. ' <option value="48042">限时促销</option>\n' +
  1456. ' <option value="639904">今日特价</option>\n' +
  1457. ' <option value="687096">特价大促销</option>\n' +
  1458. ' <option value="611402">特惠专享</option>\n' +
  1459. ' <option value="455904">特惠</option>\n' +
  1460. ' <option value="498104">升级特惠</option>\n' +
  1461. '</select>';
  1462. $('.switch').removeClass('hide_div');
  1463. } else {
  1464. $("#breakfast option[value='2']").remove();
  1465. $('.switch').addClass('hide_div');
  1466. channel_name = '<input class="form-control" id="distrib_room_name" type="text" placeholder="请输入渠到名称"/>';
  1467. }
  1468. $('#channel_mapping_name').html(channel_name);
  1469. $.ajax({
  1470. url: url,
  1471. type: 'post',
  1472. data: param,
  1473. success: function (res_data) {
  1474. res_data = JSON.parse(res_data);
  1475. var bed_arr = new Array();
  1476. bed_arr[1] = '大床';
  1477. bed_arr[2] = '双床';
  1478. bed_arr[3] = '多床';
  1479. var channel_bed_id = new Array();
  1480. channel_bed_id[1] = 108;
  1481. channel_bed_id[2] = 109;
  1482. channel_bed_id[3] = 107;
  1483. if (res_data['code'] == '0') {
  1484. $('#opera_hotel_room_id').val(_opera_hotel_room_id);
  1485. var data = res_data['rowset'][0];
  1486. $('#distribe_name').val(data['SUPPLIER_NAME']);
  1487. $('#opera_room_name').val(data['ROOM_NAME'] + data['INNER_IDENTIFY']);
  1488. $('#distrib_room_name').val(data['DISTRIB_ROOM_NAME']);
  1489. if (data['AUTHORITY_STATUS'] == 1) {
  1490. $("#authority_status").attr('src', "images/OnSwitch.png");
  1491. $('#authority_status').attr('isopen', '1');
  1492. } else {
  1493. $("#authority_status").attr('src', "images/OffSwitch.png");
  1494. $('#authority_status').attr('isopen', '0');
  1495. }
  1496. // 床型展示
  1497. var bed_option = '<option value="0">不限</option>';
  1498. var bed = [];
  1499. if (data['BED_TYPE'] == 0) {
  1500. bed = data['BASE_BED_TYPE'].split(',');
  1501. } else {
  1502. bed = data['BED_TYPE'].split(',');
  1503. }
  1504. $(bed).each(function (i, n) {
  1505. bed_option += '<option value="' + channel_bed_id[n] + '">' + bed_arr[n] + '</option>';
  1506. });
  1507. $('.bed_tye').empty();
  1508. $('.bed_tye').append(bed_option);
  1509. var check_limit = new Array(); // {"1":"98", "2":"99", "3":"100", "4":"101", "5":"102", "6":"103"};
  1510. check_limit[1] = 98;
  1511. check_limit[2] = 99;
  1512. check_limit[3] = 100;
  1513. check_limit[4] = 101;
  1514. check_limit[5] = 102;
  1515. check_limit[6] = 103;
  1516. check_limit[7] = 104;
  1517. check_limit[8] = 105;
  1518. check_limit[9] = 106;
  1519. var limit_name = new Array();
  1520. limit_name[1] = '单人入住';
  1521. limit_name[2] = '双人入住';
  1522. limit_name[3] = '三人入住';
  1523. limit_name[4] = '四人入住';
  1524. limit_name[5] = '五人入住';
  1525. limit_name[6] = '六人入住';
  1526. limit_name[7] = '七人入住';
  1527. limit_name[8] = '八人入住';
  1528. limit_name[9] = '九人入住';
  1529. // check_limit[999] = 106;
  1530. // check_limit[] = 98;
  1531. // 入住人数 如果是0则不限人数,最多9人,-1 表示入住人数不限制,继承父级房型
  1532. var limit_option = '<option value="-1">不限</option>';
  1533. if (data['OCCUPANCY_LIMIT'] > 6) {
  1534. data['OCCUPANCY_LIMIT'] = 9;
  1535. for (var i = 1; i <= 9; i++) {
  1536. limit_option += '<option value="' + check_limit[i] + '">' + limit_name[i] + '</option>';
  1537. }
  1538. } else {
  1539. for (var i = 1; i <= data['OCCUPANCY_LIMIT']; i++) {
  1540. limit_option += '<option value="' + check_limit[i] + '">' + limit_name[i] + '</option>';
  1541. }
  1542. }
  1543. $('.check_in_num').empty();
  1544. $('.check_in_num').append(limit_option);
  1545. $('.check_in_num').val(check_limit[data['OCCUPANCY_LIMIT']]);
  1546. // 入住人数end
  1547. // 餐食数begin
  1548. var breakfast_select = '';
  1549. if (data['level'] == 3) {
  1550. breakfast_select = '<span>&emsp;餐食数&emsp;</span><select class="form-control breakfast-num" id="breakfast-num">' +
  1551. '<option value="128">无早</option>\n' +
  1552. '<option value="126">单早</option>\n' +
  1553. '<option value="127">双早</option>\n' +
  1554. '<option value="125">三早</option>\n' +
  1555. '<option value="117">四早</option>\n' +
  1556. '<option value="118">五早</option>\n' +
  1557. '<option value="119">六早</option>\n' +
  1558. '<option value="120">七早</option>\n' +
  1559. '<option value="121">七早</option>\n' +
  1560. '<option value="122">八早</option>\n' +
  1561. '<option value="123">九早</option>\n' +
  1562. '<option value="124">十早</option></select>';
  1563. $('#breakfast').val(2);
  1564. $('.breakfast-hide').html(breakfast_select);
  1565. $('.breakfast-num').val(data['ID']);
  1566. } else {
  1567. $('.breakfast-hide').html(breakfast_select);
  1568. if (data['ID'] != '' && data['ID'] != null && data['ID'] != 0) {
  1569. $('#breakfast').val(data['ID']);
  1570. } else {
  1571. $('#breakfast').val(-1);
  1572. }
  1573. }
  1574. closeLoading();
  1575. }
  1576. }
  1577. })
  1578. }
  1579. function setChannelRoomInfo(obj) {
  1580. var url = base_api;
  1581. var _hotel_id = $(obj).attr('data-hotel-id');
  1582. var _opera_hotel_room_id = $(obj).attr('data-hotel-room-id');
  1583. var _distrib_id = $("#channel_list").val();
  1584. var param = {
  1585. type: "room_distribRoomService",
  1586. op: "setDistribRoomInfo",
  1587. hotel_id: _hotel_id,
  1588. opera_hotel_room_id: _opera_hotel_room_id,
  1589. distrib_id: _distrib_id
  1590. };
  1591. $.ajax({
  1592. url: url,
  1593. type: 'post',
  1594. data: param,
  1595. success: function (res_data) {
  1596. res_data = JSON.parse(res_data);
  1597. if (res_data['code'] == '0') {
  1598. $('#opera_hotel_room_id').val(_opera_hotel_room_id);
  1599. var data = res_data['rowset'][0];
  1600. var gift = res_data['rowset']['gift'];
  1601. $('#distribe_name').val(data['SUPPLIER_NAME']);
  1602. $('#opera_room_name').val(data['ROOM_NAME'] + data['INNER_IDENTIFY']);
  1603. $('#distrib_room_name').val(data['DISTRIB_ROOM_NAME']);
  1604. if (data['AUTHORITY_STATUS'] == 1) {
  1605. $("#authority_status").attr('src', "images/OnSwitch.png");
  1606. $('#authority_status').attr('isopen', '1');
  1607. } else {
  1608. $("#authority_status").attr('src', "images/OffSwitch.png");
  1609. $('#authority_status').attr('isopen', '0');
  1610. }
  1611. if (data['LATEST_COMFIRM_TIME'] != null) {
  1612. if (data['LATEST_COMFIRM_TIME'] == "-1") {
  1613. $('#div_confirm').css('display', 'none');
  1614. } else {
  1615. $('#not_set_latest_comfirm').prop("checked", false);
  1616. $('#set_latest_comfirm').prop("checked", "checked");
  1617. var latest_comfirm_time = data['LATEST_COMFIRM_TIME'].split(",");
  1618. $("#quick_confirm_day").val(latest_comfirm_time[0]);
  1619. $("#quick_confirm_time").val(latest_comfirm_time[1]);
  1620. $('#div_confirm').css('display', 'block');
  1621. }
  1622. } else {
  1623. $('#not_set_latest_comfirm').prop("checked", "checked");
  1624. $('#set_latest_comfirm').prop("checked", false);
  1625. $('#div_confirm').css('display', 'none');
  1626. }
  1627. $("#gift_select").html('<option value="0">无</option>');
  1628. for (var i = 0; i < gift.length; i++) {
  1629. $("#gift_select").append("<option value='" + gift[i]['ID'] + "' data-content='" + gift[i]['GIFT_CONTENT'] + "'>" + gift[i]['GIFT_NAME'] + "</option>");
  1630. $('.select_screen').comboSelect();
  1631. }
  1632. $('#gift_date_begin').val(getDateTime(0));
  1633. $('#gift_date_end').val(getDateTime(0));
  1634. closeLoading();
  1635. }
  1636. }
  1637. })
  1638. }
  1639. /**
  1640. * 礼盒选中项变更时,礼盒内容隐藏
  1641. */
  1642. $('#gift_select').change(function () {
  1643. $("#gift_content").css('display', 'none');
  1644. });
  1645. /**
  1646. * 查看礼盒内容
  1647. */
  1648. function gift_detail() {
  1649. if ($("#gift_content").css('display') == "block") {
  1650. $("#gift_content").css('display', 'none');
  1651. } else {
  1652. var gift_cotent = $("#gift_select").find("option:selected").attr("data-content");
  1653. if (gift_cotent == undefined) {
  1654. $("#gift_content").html('礼盒内容:无');
  1655. } else {
  1656. $("#gift_content").html('礼盒内容:' + gift_cotent);
  1657. }
  1658. $("#gift_content").css('display', 'block');
  1659. }
  1660. }
  1661. /**
  1662. * 切换授权开关按钮
  1663. * @param obj
  1664. */
  1665. function authorityStatusMenu(obj) {
  1666. if ($(obj).attr('isopen') == 0) {
  1667. $(obj).attr('isopen', "1");
  1668. $(obj).attr('src', "images/OnSwitch.png");
  1669. } else {
  1670. $(obj).attr('isopen', "0");
  1671. $(obj).attr('src', "images/OffSwitch.png");
  1672. }
  1673. }
  1674. function isSetLastestConfirm() {
  1675. var check_val = $('input:radio[name="inlineRadioOptions"]:checked').val();
  1676. if (check_val == -1) {
  1677. $('#div_confirm').css('display', 'none');
  1678. } else {
  1679. $('#div_confirm').css('display', 'block');
  1680. }
  1681. }
  1682. /**
  1683. * 保存房型信息
  1684. */
  1685. function updateDistribRoomInfo() {
  1686. loading();
  1687. var _distrib_id = $("#channel_list").val();
  1688. var _opera_hotel_room_id = $("#opera_hotel_room_id").val();
  1689. var _distrib_room_name = $("#distrib_room_name").val();
  1690. var _authority_status = $("#authority_status").attr('isopen');
  1691. var _purcharse_channel = $('#purcharse_channel').val(); // 采购渠道
  1692. var _bed_type = $('.bed_tye').val(); // 床型
  1693. var _check_in_num = $('.check_in_num').val(); // 入住人数限制
  1694. var _breakfast = -1;
  1695. if ($('#breakfast').val() == 2) {
  1696. _breakfast = $('#breakfast-num').val();
  1697. } else {
  1698. _breakfast = $('#breakfast').val();
  1699. }
  1700. var param = {
  1701. type: "room_distribRoomService",
  1702. op: "setDistribRoomInfo",
  1703. opera_hotel_room_id: _opera_hotel_room_id,
  1704. distrib_id: _distrib_id,
  1705. distrib_room_name: _distrib_room_name,
  1706. authority_status: _authority_status,
  1707. breakfast_num: _breakfast,
  1708. purcharse_channel: _purcharse_channel,
  1709. bed_type: _bed_type,
  1710. check_in_num: _check_in_num
  1711. };
  1712. if ($.inArray(parseInt(_distrib_id), [669, 1667, 1668, 1669, 1670]) != -1) {
  1713. var _room_discounts_type = $('#room-discounts').val(); // 优惠类型
  1714. var _room_discounts_value = $('#option-discounts').val(); // 优惠值
  1715. var _members = $('.members').val(); // 会员类型
  1716. var _show_channel = $("input[name='optionsRadios']:checked").val(); // 展示渠道
  1717. var _fit_people_type = 0;
  1718. var _fit_people_value = '';
  1719. if ($('.fit-people').val() == 11) { // 适应人群及类型获取,不限值为所有
  1720. _fit_people_type = 11;
  1721. _fit_people_value = '1,2,3,4,5,6,7,8,10';
  1722. } else { // 限定,取限定范围的值
  1723. _fit_people_type = $('.fit-people-tye').val();
  1724. $('.in-checkbox:checked').each(function (i, n) {
  1725. _fit_people_value += $(this).val() + ',';
  1726. });
  1727. _fit_people_value = _fit_people_value.substring(0, _fit_people_value.length - 1);
  1728. }
  1729. param.room_discount_type = _room_discounts_type;
  1730. param.room_discounts_value = _room_discounts_value;
  1731. param.members = _members;
  1732. param.show_channel = _show_channel;
  1733. param.fit_people_type = _fit_people_type;
  1734. param.fit_people_value = _fit_people_value;
  1735. }
  1736. $.ajax({
  1737. url: base_api,
  1738. type: 'post',
  1739. data: param,
  1740. success: function (res_data) {
  1741. res_data = JSON.parse(res_data);
  1742. if (res_data['code'] == '0') {
  1743. $("#cancel").trigger("click");
  1744. closeLoading();
  1745. alert('修改成功!');
  1746. return true;
  1747. } else {
  1748. closeLoading();
  1749. alert('修改失败!');
  1750. return false;
  1751. }
  1752. },
  1753. error: function (e) {
  1754. closeLoading();
  1755. alert('修改失败!');
  1756. return false;
  1757. }
  1758. })
  1759. }
  1760. /**
  1761. * @author guhh
  1762. * 获取渠道房型信息
  1763. */
  1764. function getDistribRoomInfo(obj) {
  1765. var url = base_api;
  1766. var _hotel_id = $(obj).prev().attr('data-hotel-id');
  1767. var _opera_hotel_room_id = $(obj).prev().attr('data-hotel-room-id');
  1768. var _distrib_id = $("#channel_list").val();
  1769. var param = {
  1770. type: "room_distribRoomService",
  1771. op: "getDistribRunRoomInfo",
  1772. hotel_id: _hotel_id,
  1773. opera_hotel_room_id: _opera_hotel_room_id,
  1774. distrib_id: _distrib_id
  1775. };
  1776. $.ajax({
  1777. url: url,
  1778. type: 'post',
  1779. data: param,
  1780. success: function (res_data) {
  1781. res_data = JSON.parse(res_data);
  1782. console.log(res_data);
  1783. if(res_data != null){
  1784. if (res_data['code'] == '0') {
  1785. $('#opera_hotel_room_id').val(_opera_hotel_room_id);
  1786. var data = res_data['rowset'][0];
  1787. var gift = res_data['rowset']['gift'];
  1788. $('#distribe_name').val(data['SUPPLIER_NAME']);
  1789. $('#opera_room_name').val(data['ROOM_NAME'] + data['INNER_IDENTIFY']);
  1790. $('#distrib_room_name').val(data['DISTRIB_ROOM_NAME']);
  1791. $('#distrib_hotel_id').val(_hotel_id);
  1792. $('#distrib_hotel_room_id').val(_opera_hotel_room_id);
  1793. $('#distrib_base_room_type').val(data['PARENT_ROOM_TYPE']);
  1794. $('#distrib_room_type').val(data['ROOM_TYPE']);
  1795. if (data['AUTHORITY_STATUS'] == 1) {
  1796. $("#authority_status").attr('src', "images/OnSwitch.png");
  1797. $('#authority_status').attr('isopen', '1');
  1798. } else {
  1799. $("#authority_status").attr('src', "images/OffSwitch.png");
  1800. $('#authority_status').attr('isopen', '0');
  1801. }
  1802. $("#gift_select").html('<option value="0" data-content="0">不设置</option>');
  1803. for (var i = 0; i < gift.length; i++) {
  1804. $("#gift_select").append("<option value='" + gift[i]['ID'] + "' data-content='" + gift[i]['GIFT_CONTENT'] +"'>" + gift[i]['GIFT_NAME'] + "</option>");
  1805. $('.select_screen').comboSelect();
  1806. }
  1807. $('#gift_date_begin').val(getDateTime(0));
  1808. $('#gift_date_end').val(getDateByDay(7, getDateTime(0)));
  1809. closeLoading();
  1810. }
  1811. }
  1812. }
  1813. })
  1814. }
  1815. function getTimeRange(data, select, day, time, content) {
  1816. if (data != null) {
  1817. if (data == "-1") {
  1818. $(select).val('-1');
  1819. $(content).css('display', 'none');
  1820. } else if (data == "0") {
  1821. $(select).val('0');
  1822. $(content).css('display', 'none');
  1823. } else {
  1824. $(select).val('2');
  1825. var latest_comfirm_time = data.split(",");
  1826. $(day).val(latest_comfirm_time[0]);
  1827. $(time).val(latest_comfirm_time[1]);
  1828. $(content).css('display', 'block');
  1829. }
  1830. } else {
  1831. $(content).css('display', 'none');
  1832. $(select).val('0');
  1833. }
  1834. }
  1835. /**
  1836. * 修改渠道房型信息
  1837. */
  1838. function updateDistribRoomTime() {
  1839. var _distrib_id = $("#channel_list").val(); //渠道ID
  1840. var _opera_hotel_room_id = $("#opera_hotel_room_id").val(); //渠道名称
  1841. var _authority_status = $("#authority_status").attr('isopen'); //渠道授权开关
  1842. var _is_set_confirm_time=$('.latest_confirm').val();
  1843. var _is_set_schedule_time=$('.latest_schedule').val();
  1844. var _is_set_cancel_time=$('.latest_cancel').val();
  1845. var _quick_confirm_day = $('#quick_confirm_day').val(); //最晚立即确认时间-天数
  1846. var _quick_confirm_time = $('#quick_confirm_time').val(); //最晚立即确认时间-时分秒
  1847. var _quick_schedule_day = $('#quick_schedule_day').val(); //最晚预定时间-天数
  1848. var _quick_schedule_time = $('#quick_schedule_time').val(); //最晚预定时间-时分秒
  1849. var _quick_cancel_day = $('#quick_cancel_day').val(); //最晚取消时间-天数
  1850. var _quick_cancel_time = $('#quick_cancel_time').val(); //最晚取消时间-时分秒
  1851. var _gift_select = $('#gift_select').val(); //礼盒ID
  1852. var _begin_date = $("#gift_date_begin").val(); //开始时间
  1853. var _end_date = $("#gift_date_end").val(); //结束时间
  1854. var _auto_close = $("#auto_close").val(); //库房自动关闭
  1855. var _distrib_hotel_id = $("#distrib_hotel_id").val(); //酒店ID
  1856. var _distrib_hotel_room_id = $("#distrib_hotel_room_id").val();
  1857. var _distrib_base_room_type=$('#distrib_base_room_type').val(); //酒店基础房型ID
  1858. var _distrib_room_type=$('#distrib_room_type').val(); //酒店字房型ID
  1859. var r = /^\d+$/;
  1860. if(_is_set_confirm_time == '2'){
  1861. if (!r.test(_quick_confirm_day)) {
  1862. alert("请输入正整数");
  1863. return false;
  1864. }
  1865. }
  1866. if(_is_set_schedule_time == '2'){
  1867. if (!r.test(_quick_schedule_day)) {
  1868. alert("请输入正整数");
  1869. return false;
  1870. }
  1871. }
  1872. if(_is_set_cancel_time == '2'){
  1873. if (!r.test(_quick_cancel_day)) {
  1874. alert("请输入正整数");
  1875. return false;
  1876. }
  1877. }
  1878. obj = document.getElementsByName("channel_week");
  1879. check_val = [];
  1880. for (k in obj) {
  1881. if (obj[k].checked)
  1882. check_val.push(obj[k].value);
  1883. }
  1884. var param = {
  1885. type: "room_distribRoomService",
  1886. op: "updateDistribRoomInfo",
  1887. opera_hotel_room_id: _opera_hotel_room_id,
  1888. distrib_id: _distrib_id,
  1889. auto_close:_auto_close,
  1890. authority_status: _authority_status,
  1891. quick_confirm_day: _quick_confirm_day,
  1892. quick_confirm_time: _quick_confirm_time,
  1893. quick_schedule_day: _quick_schedule_day,
  1894. quick_schedule_time: _quick_schedule_time,
  1895. quick_cancel_day: _quick_cancel_day,
  1896. quick_cancel_time: _quick_cancel_time,
  1897. gift_select: _gift_select,
  1898. begin_date: _begin_date,
  1899. end_date: _end_date,
  1900. weekstr: check_val,
  1901. is_set_confirm_time:_is_set_confirm_time,
  1902. is_set_schedule_time:_is_set_schedule_time,
  1903. is_set_cancel_time:_is_set_cancel_time,
  1904. distrib_hotel_id:_distrib_hotel_id,
  1905. distrib_hotel_room_id:_distrib_hotel_room_id,
  1906. distrib_base_room_type:_distrib_base_room_type,
  1907. distrib_room_type:_distrib_room_type
  1908. };
  1909. $.ajax({
  1910. url: base_api,
  1911. type: 'post',
  1912. data: param,
  1913. success: function (res_data) {
  1914. res_data = JSON.parse(res_data);
  1915. console.log(res_data);
  1916. if (res_data['code'] == '0') {
  1917. $("#cancel1").trigger("click");
  1918. closeLoading();
  1919. alert('修改成功!');
  1920. location.reload();
  1921. return true;
  1922. } else {
  1923. closeLoading();
  1924. alert('修改失败!');
  1925. return false;
  1926. }
  1927. },
  1928. error: function (e) {
  1929. closeLoading();
  1930. alert('修改失败!');
  1931. return false;
  1932. }
  1933. })
  1934. }
  1935. // 改变适应人群下拉选择框显示或隐藏
  1936. function changeLimit(e) {
  1937. var people_value = $(e).val();
  1938. if (people_value == 1) {
  1939. $('.fit-district').removeClass('hide_div');
  1940. } else {
  1941. $('.fit-district').addClass('hide_div');
  1942. $('.other-condition').addClass('hide_div');
  1943. }
  1944. }
  1945. // 按照适应人群动态生成复选框
  1946. function changeDistict(e) {
  1947. var district_value = $(e).val();
  1948. if (district_value == 899272 || district_value == 899274 || district_value == 899322) {
  1949. html = '';
  1950. } else {
  1951. $('.other-condition').removeClass('hide_div');
  1952. if (district_value == 2) { // 内宾
  1953. html = '<input type="checkbox" value="1" class="in-checkbox" checked disabled>持中国身份证的居民';
  1954. } else if (district_value == 3) { // 外宾
  1955. html = '<input type="checkbox" value="4" class="in-checkbox" checked>持中国护照的侨胞<br/>\n' +
  1956. '<input type="checkbox" value="5" class="in-checkbox" checked>持外国人工作许可证/居留许可证的外籍人士<br/>\n' +
  1957. '<input type="checkbox" value="6" class="in-checkbox" checked>持非中国护照的外籍人士';
  1958. } else if (district_value == 1) { // 中宾
  1959. html = '<input type="checkbox" value="1" class="in-checkbox" checked disabled>持中国身份证的居民<br/>\n' +
  1960. '<input type="checkbox" value="2" class="in-checkbox" checked disabled>持中国回乡证/中国护照的香港人士\n<br/>\n' +
  1961. '<input type="checkbox" value="3" class="in-checkbox" checked disabled>持台胞证/护照的台湾人士\n<br/>\n' +
  1962. '<input type="checkbox" value="4" class="in-checkbox" checked disabled>持中国护照的侨胞\n<br/>\n' +
  1963. '<input type="checkbox" value="5" class="in-checkbox" checked disabled>持外国人工作许可证/居留许可证的外籍人士\n<br/>\n' +
  1964. '<input type="checkbox" value="10" class="in-checkbox" checked disabled>持回乡证/中国护照的澳门人士\n<br/>\n';
  1965. } else if (district_value == 2532721) { //此价格只适用于台湾客人
  1966. html = '<input type="checkbox" value="3" checked disabled class="in-checkbox" >持台胞证/护照的台湾人士<br/>\n';
  1967. } else if (district_value == 1332673) { // 内宾台湾及外籍人士
  1968. html = '<input type="checkbox" value="1" checked disabled class="in-checkbox" >持中国身份证的居民<br/>\n' +
  1969. '<input type="checkbox" value="3" checked disabled class="in-checkbox" >持台胞证/护照的台湾人士\n<br/>\n' +
  1970. '<input type="checkbox" value="4" checked disabled class="in-checkbox" >持中国护照的侨胞\n<br/>\n' +
  1971. '<input type="checkbox" value="5" checked disabled class="in-checkbox" >持外国人工作许可证/居留许可证的外籍人士\n<br/>\n' +
  1972. '<input type="checkbox" value="6" checked disabled class="in-checkbox" >持非中国护照的外籍人士\n<br/>\n';
  1973. } else if (district_value == 1332678) { //内宾港澳及外籍人士
  1974. html = '<input type="checkbox" value="1" checked disabled class="in-checkbox" >持中国身份证的居民<br/>\n' +
  1975. '<input type="checkbox" value="2" checked disabled class="in-checkbox" >持中国回乡证/中国护照的香港人士\n<br/>\n' +
  1976. '<input type="checkbox" value="4" checked disabled class="in-checkbox" >持中国护照的侨胞\n<br/>\n' +
  1977. '<input type="checkbox" value="5" checked disabled class="in-checkbox" >持外国人工作许可证/居留许可证的外籍人士\n<br/>\n' +
  1978. '<input type="checkbox" value="6" checked disabled class="in-checkbox" >持非中国护照的外籍人士\n<br/>\n' +
  1979. '<input type="checkbox" value="10" checked disabled class="in-checkbox" >持回乡证/中国护照的澳门人士\n<br/>\n';
  1980. }
  1981. }
  1982. $('.other-condition').html(html);
  1983. }
  1984. // 优惠选择的隐藏和显示,动态加载优惠信息
  1985. function roomDiscounts(e) {
  1986. var value = $(e).val();
  1987. if (value == -1 || value == 95) {
  1988. $('.discount-select').addClass('hide_div');
  1989. } else {
  1990. $('.discount-select').removeClass('hide_div');
  1991. var option = '';
  1992. if (value == 10) {
  1993. option += '<option value="113">2间起订</option>\n' +
  1994. '<option value="1175">3间起订</option>\n' +
  1995. '<option value="2334">5间起订</option>\n' +
  1996. '<option value="8335">8间起订</option>\n' +
  1997. '<option value="12964">10间起订</option>\n' +
  1998. '<option value="15930">4间起订</option>\n' +
  1999. '<option value="17502">7间起订</option>\n' +
  2000. '<option value="49619">6间起订</option>\n' +
  2001. '<option value="379123">9间起订</option>';
  2002. } else if (value == 20) {
  2003. option = '<option value="97">提前1天预订</option>\n' +
  2004. '<option value="562">提前2天预订</option>\n' +
  2005. '<option value="26">提前3天预订</option>\n' +
  2006. '<option value="479">提前4天预订</option>\n' +
  2007. '<option value="98">提前5天预订</option>\n' +
  2008. '<option value="434">提前6天预订</option>\n' +
  2009. '<option value="35">提前7天预订</option>\n' +
  2010. '<option value="979">提前8天预订</option>\n' +
  2011. '<option value="2298">提前9天预订</option>\n' +
  2012. '<option value="799">提前10天预订</option>\n' +
  2013. '<option value="510662">提前11天预订</option>\n' +
  2014. '<option value="7105">提前12天预订</option>\n' +
  2015. '<option value="22266">提前13天预订</option>\n' +
  2016. '<option value="57">提前14天预订</option>\n' +
  2017. '<option value="409">提前15天预订</option>\n' +
  2018. '<option value="411931">提前16天预订</option>\n' +
  2019. '<option value="379632">提前17天预订</option>\n' +
  2020. '<option value="378788">提前18天预订</option>\n' +
  2021. '<option value="513609">提前19天预订</option>\n' +
  2022. '<option value="2914">提前20天预订</option>\n' +
  2023. '<option value="114">提前21天预订</option>\n' +
  2024. '<option value="13089">提前22天预订</option>\n' +
  2025. '<option value="795169">提前23天预订</option>\n' +
  2026. '<option value="13735">提前24天预订</option>\n' +
  2027. '<option value="14138">提前25天预订</option>\n' +
  2028. '<option value="17745">提前28天预订</option>\n' +
  2029. '<option value="795294">提前29天预订</option>\n' +
  2030. '<option value="274">提前30天预订</option>\n' +
  2031. '<option value="134">提前45天预订</option>\n' +
  2032. '<option value="106">提前60天预订</option>';
  2033. } else if (value == 51) {
  2034. option = '<option value="96">住1送1</option>\n' +
  2035. '<option value="69">住2送1</option>\n' +
  2036. '<option value="108">住3送1</option>\n' +
  2037. '<option value="1335966">住3送2</option>\n' +
  2038. '<option value="812">住4送1</option>\n' +
  2039. '<option value="795382">住4送2</option>\n' +
  2040. '<option value="1335983">住4送3</option>\n' +
  2041. '<option value="522">住5送1</option>\n' +
  2042. '<option value="795383">住5送2</option>\n' +
  2043. '<option value="1335984">住5送3</option>\n' +
  2044. '<option value="8932">住6送1</option>\n' +
  2045. '<option value="795384">住6送2</option>\n' +
  2046. '<option value="795385">住6送3</option>\n' +
  2047. '<option value="3797">住7送1</option>\n' +
  2048. '<option value="1335968">住7送2</option>\n' +
  2049. '<option value="1335986">住7送3</option>\n' +
  2050. '<option value="630396">住8送1</option>\n' +
  2051. '<option value="1335971">住8送2</option>\n' +
  2052. '<option value="1335987">住8送3</option>\n' +
  2053. '<option value="3798">住9送1</option>\n' +
  2054. '<option value="1335981">住9送2</option>\n' +
  2055. '<option value="1335989">住9送3</option>\n' +
  2056. '<option value="1335982">住10送2</option>\n' +
  2057. '<option value="1335990">住10送3</option>';
  2058. } else if (value == 76) {
  2059. option =
  2060. '<option value="34">连住2晚及以上</option>\n' +
  2061. '<option value="42">连住3晚及以上</option>\n' +
  2062. '<option value="140">连住4晚及以上</option>\n' +
  2063. '<option value="441">连住5晚及以上</option>\n' +
  2064. '<option value="12875">连住6晚及以上</option>\n' +
  2065. '<option value="279">连住7晚及以上</option>\n' +
  2066. '<option value="32">连住8晚及以上</option>\n' +
  2067. '<option value="630395">连住9晚及以上</option>\n' +
  2068. '<option value="8939">连住10晚及以上</option>';
  2069. } else if (value == 86) {
  2070. option = '<option value="90">住2晚或2晚的倍数</option>\n' +
  2071. '<option value="89">住3晚或3晚的倍数</option>\n' +
  2072. '<option value="91">住4晚或4晚的倍数</option>\n' +
  2073. '<option value="92">住5晚或5晚的倍数</option>\n' +
  2074. '<option value="87">住6晚或6晚的倍数</option>\n' +
  2075. '<option value="93">住7晚或7晚的倍数</option>\n' +
  2076. '<option value="88">住8晚或8晚的倍数</option>\n' +
  2077. '<option value="94">住9晚或9晚的倍数</option>';
  2078. }
  2079. $('.option-discounts').empty();
  2080. $('.option-discounts').append(option);
  2081. }
  2082. }
  2083. // 餐食数动态调整
  2084. function mealChange(e) {
  2085. value = $(e).val();
  2086. var meal_select = '';
  2087. if (value == 2) {
  2088. meal_select = '<span>&emsp;餐食数&emsp;</span><select class="form-control">' +
  2089. '<option value="128">无早</option>\n' +
  2090. '<option value="126">单早</option>\n' +
  2091. '<option value="127">双早</option>\n' +
  2092. '<option value="125">三早</option>\n' +
  2093. '<option value="117">四早</option>\n' +
  2094. '<option value="118">五早</option>\n' +
  2095. '<option value="119">六早</option>\n' +
  2096. '<option value="120">七早</option>\n' +
  2097. '<option value="121">七早</option>\n' +
  2098. '<option value="122">八早</option>\n' +
  2099. '<option value="123">九早</option>\n' +
  2100. '<option value="124">十早</option></select>';
  2101. }
  2102. $('.breakfast-hide').html(meal_select);
  2103. }