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.
 
 
 
 

229 lines
6.6 KiB

  1. /**
  2. * Created by luocj on 2016/10/29.
  3. */
  4. var data_tr = $('.data-tr').prop('outerHTML');
  5. var current = '1';
  6. var page_size = '15';
  7. var hotel_name = '';
  8. window.onload = function () {
  9. addNewHotel();
  10. getHotelList();
  11. checkBox();
  12. };
  13. function addNewHotel() {
  14. $('#add_new_hotel').bind('click', function () {
  15. window.location.href = 'add_new_hotel.html';
  16. })
  17. }
  18. function checkBox() {
  19. $('.check_box_main').bind('click', function () {
  20. if ($('.check_box_main').is(':checked')) {
  21. $("input[name='check_box_child']").prop("checked", true);
  22. } else {
  23. $("input[name='check_box_child']").removeAttr("checked", true);
  24. }
  25. //取值
  26. $('.check_box').each(function () {
  27. var status = $(this).is(':checked')
  28. })
  29. });
  30. $('.check_box').bind('click', function () {
  31. if ($("input[name='check_box_child']").not("input:checked").size() <= 0) {
  32. $('.check_box_main').prop("checked", true);
  33. } else {
  34. $('.check_box_main').prop("checked", false);
  35. }
  36. })
  37. }
  38. function getHotelList() {
  39. hotel_name = $('#hotel_name').val();
  40. var param = {
  41. op: '1',
  42. type: 'hotel_HotelList',
  43. hotel_name: hotel_name,
  44. current: current,
  45. page_size: page_size
  46. };
  47. $.ajax({
  48. url: base_api,
  49. data: param,
  50. type: "post",
  51. dataType: "json",
  52. success: function (res_data) {
  53. ZZLog(res_data);
  54. if (res_data['code'] != "0") {
  55. alert(res_data['info']);
  56. }
  57. setDataBody(res_data);
  58. if (res_data['total_count'] < 1) {
  59. $('.pageDiv').hide();
  60. } else {
  61. $(".pageDiv").createPage({
  62. pageCount: res_data['total_page'],//总页数
  63. current: current,//当前页
  64. turndown: 'true',//是否显示跳转框,显示为true,不现实为false,一定记得加上引号...
  65. backFn: function (p) {
  66. current = p;
  67. havePageData();
  68. }
  69. });
  70. $('.pageDiv').show();
  71. }
  72. },
  73. error: function (error) {
  74. alert('system ajax http error');
  75. ZZLog(error);
  76. }
  77. })
  78. }
  79. function setDataBody(res_data) {
  80. var sumHTML = '';
  81. for (var i = 0; i < res_data['hotel_list'].length; i++) {
  82. var dict = res_data['hotel_list'][i];
  83. var HTML = data_tr;
  84. HTML = HTML.replace('<tr class="data-tr">', '<tr class="data-tr" data-hotel-id="' + dict['hotel_id'] + '">')
  85. HTML = HTML.replace('[酒店名称]', dict['hotel_name']);
  86. if (null != dict['type_name']) {
  87. HTML = HTML.replace('[星级]', dict['type_name']);
  88. } else {
  89. HTML = HTML.replace('[星级]', '暂无');
  90. }
  91. if (null != dict['area_name']) {
  92. HTML = HTML.replace('[城市]', dict['parent_area_name'] + dict['area_name']);
  93. } else {
  94. HTML = HTML.replace('[城市]', '暂无');
  95. }
  96. if (null != dict['hotel_address']) {
  97. HTML = HTML.replace('[地址]', dict['hotel_address']);
  98. } else {
  99. HTML = HTML.replace('[地址]', '暂无');
  100. }
  101. // if (1 == dict['hotel_status']) {
  102. // HTML = HTML.replace('[状态]', '在售');
  103. // } else {
  104. // HTML = HTML.replace('[状态]', '停售');
  105. // }
  106. HTML = HTML.replace('[操作]', '<a style="cursor: pointer;color: #428bca" onclick="to_modifty(this)" >修改</a>');
  107. sumHTML += HTML;
  108. }
  109. $('#data-tbody').html(sumHTML);
  110. $('#data-tbody').show()
  111. }
  112. function change_hotel_status_ts(obj) {
  113. var data_hotel_id = $(obj).closest('tr').attr('data-hotel-id');
  114. var param = {
  115. op: '2',
  116. type: 'hotel_HotelList',
  117. id: data_hotel_id
  118. }
  119. $.ajax({
  120. data: param,
  121. url: base_api,
  122. dataType: 'json',
  123. type: 'post',
  124. success: function (res_data) {
  125. ZZLog(res_data);
  126. if (res_data['code'] != "0") {
  127. alert(res_data['info']);
  128. }
  129. getHotelList()
  130. },
  131. error: function (error) {
  132. alert('system ajax http error');
  133. ZZLog(error);
  134. }
  135. })
  136. }
  137. function change_hotel_status_zs(obj) {
  138. var data_hotel_id = $(obj).closest('tr').attr('data-hotel-id');
  139. var param = {
  140. op: '3',
  141. type: 'hotel_HotelList',
  142. id: data_hotel_id
  143. }
  144. $.ajax({
  145. data: param,
  146. url: base_api,
  147. dataType: 'json',
  148. type: 'post',
  149. success: function (res_data) {
  150. ZZLog(res_data);
  151. if (res_data['code'] != "0") {
  152. alert(res_data['info']);
  153. }
  154. getHotelList()
  155. },
  156. error: function (error) {
  157. alert('system ajax http error');
  158. ZZLog(error);
  159. }
  160. })
  161. }
  162. //批量将在售改为停售
  163. function batch_change_status(value) {
  164. var check_value = [];
  165. $('input[name="check_box_child"]:checked').each(function () {
  166. check_value.push($(this).closest('tr').attr('data-hotel-id'));
  167. });
  168. var check_hotel_id = check_value.join(",");
  169. var param = {
  170. op: value,
  171. type: 'hotel_HotelList',
  172. id: check_hotel_id
  173. }
  174. $.ajax({
  175. type: 'post',
  176. dataType: 'json',
  177. data: param,
  178. url: base_api,
  179. success: function (res_data) {
  180. ZZLog(res_data);
  181. if (res_data['code'] != "0") {
  182. alert(res_data['info'])
  183. }
  184. ;
  185. getHotelList();
  186. },
  187. error: function (error) {
  188. alert('system ajax http error');
  189. ZZLog(error);
  190. }
  191. })
  192. }
  193. //管理跳至修改酒店
  194. function to_modifty(obj) {
  195. var hotel_id = $(obj).closest('tr').attr('data-hotel-id');
  196. var hotel_name = $(obj).closest('tr').children().eq(1).text();
  197. window.location.href = 'modify_hotel_info.html?hotel_id=' + hotel_id + '&hotel_name=' + hotel_name;
  198. }
  199. function havePageData() {
  200. var param = {
  201. op: '1',
  202. type: 'hotel_HotelList',
  203. hotel_name: hotel_name,
  204. current: current,
  205. page_size: page_size
  206. };
  207. $.ajax({
  208. data: param,
  209. dataType: 'json',
  210. type: 'post',
  211. url: base_api,
  212. success: function (res_data) {
  213. ZZLog(res_data);
  214. if (res_data['code'] != "0") {
  215. alert(res_data['info'])
  216. }
  217. setDataBody(res_data);
  218. },
  219. error: function (error) {
  220. alert('system ajax http error');
  221. ZZLog(error);
  222. }
  223. })
  224. }