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.

up_down_control.js 13 KiB

3 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352
  1. //Author:fuhc
  2. //Date:20160909
  3. //酒店产品列表
  4. //
  5. // //param
  6. // var area_id = '';
  7. // var hotel_name = '';
  8. // var hotel_status = '1';
  9. // var page_size = 10; //每页条数
  10. // var current = 1;
  11. //
  12. //
  13. // window.onload = function () {
  14. //
  15. // current = 1;
  16. // havePageData();
  17. // chooseProvince();
  18. // chooseCity();
  19. // }
  20. // function havePageData() {
  21. // var url = base_api + "?type=hotel_HotelProductList&area_id=" + area_id + "&hotel_name=" + hotel_name + "&hotel_status=" + hotel_status + "&current=" + current + "&page_size=" + page_size;
  22. // ZZLog(url);
  23. // $.getJSON(url, function (res_data) {
  24. // ZZLog(res_data);
  25. // if (res_data['code'] != "0") {
  26. // alert(res_data['info']);
  27. // } else {
  28. // var hotel_list = res_data['hotel_list'];
  29. // setHotelList(hotel_list);
  30. // if (res_data['total'] <= 0) {
  31. // $('.pageDiv').hide();
  32. // } else {
  33. //
  34. // $(".pageDiv").createPage({
  35. // pageCount: res_data['total_page'],//总页数
  36. // current: current,//当前页
  37. // turndown: 'true',//是否显示跳转框,显示为true,不现实为false,一定记得加上引号...
  38. // backFn: function (p) {
  39. // current = p;
  40. // havePageData();
  41. // }
  42. // });
  43. // $('.pageDiv').show();
  44. // }
  45. // }
  46. // })
  47. // }
  48. // function setHotelList(hotel_list) {
  49. // //酒店列表
  50. // var HTHTML = '';
  51. // for (var i = 0, m = hotel_list.length; i < m; i++) {
  52. // var tempDict = hotel_list[i];
  53. // var tempHTML = hotelHTML;
  54. // tempHTML = tempHTML.replace(/\[hotel-id]/g, tempDict['hotel_id']);
  55. // tempHTML = tempHTML.replace('[酒店名称]', tempDict['hotel_name']);
  56. // tempHTML = tempHTML.replace('[城市]', tempDict['area_name'] != "" ? tempDict['area_name'] : "-");
  57. // tempHTML = tempHTML.replace('[供应商]', tempDict['supplier_name'] != "" ? tempDict['supplier_name'] : "-");
  58. // tempHTML = tempHTML.replace('[采购负责人]', tempDict['cai_people'] != "" ? tempDict['cai_people'] : "-");
  59. // tempHTML = tempHTML.replace('[售卖状态]', tempDict['hotel_status_str']);
  60. // var cstr = '<a href="room_info.html?hotel_id=' + tempDict['hotel_id'] + '&hotel_name=' + tempDict['hotel_name'] + '">房型</a>'
  61. // + '<a style="margin-left:10px;" href="modify_hotel_product.html?hotel_id=' + tempDict['hotel_id'] + '">修改</a>';
  62. // tempHTML = tempHTML.replace('[操作]', cstr);
  63. // HTHTML += tempHTML;
  64. // }
  65. // if (HTHTML) {
  66. // $('#hotel_list').html(HTHTML);
  67. // linkToUpdate();
  68. // } else {
  69. // $('#hotel_list').html("");
  70. // }
  71. // }
  72. // function linkToUpdate() {
  73. // //跳到修改酒店产品页面
  74. // $('.update_hotel_product').bind('click', function () {
  75. // var hotel_id = $(this).closest('tr').attr('hotel-id');
  76. // var hotel_name = $(this).closest('tr').children().eq(1).text();
  77. // var listURL = "update_hotel_product.html?hotel_id=" + hotel_id + "&hotel_name=" + hotel_name;
  78. // listURL = encodeURI(listURL);
  79. // window.location.href = listURL;
  80. // })
  81. // }
  82. // $(document).ready(function () {
  83. // $('#search').bind('click', function () {
  84. // //获取条件信息
  85. // var province = $('#province').val();
  86. // var city = $('#city').val();
  87. // var hotel_name = $('#hotel_name').val();
  88. // var hotel_status = $('#hotel_status').val();
  89. // var area_id = city != 0 ? city : province;
  90. // if (hotel_status == "") {
  91. // alert('请选择售卖状态!');
  92. // return;
  93. // }
  94. // var url = base_api + "?type=hotel_HotelProductList&area_id=" + area_id + "&hotel_name=" + hotel_name + "&hotel_status=" + hotel_status + "&current=1&page_size=" + page_size;
  95. // ZZLog(url);
  96. // $.getJSON(url, function (res_data) {
  97. // ZZLog(res_data);
  98. // if (res_data['code'] != "0") {
  99. // alert(res_data['info']);
  100. // } else {
  101. // var hotel_list = res_data['hotel_list'];
  102. // setHotelList(hotel_list);
  103. // }
  104. // });
  105. // })
  106. // // 添加酒店跳转链接
  107. // $('#add').bind('click', function () {
  108. // var listURL = "add_hotel_product.html";
  109. // listURL = encodeURI(listURL);
  110. // window.open(listURL);
  111. // })
  112. //
  113. //
  114. // });
  115. var provinceHTML = ''; //省HTML
  116. var cityHTML = ''; //市HTML
  117. var hotelHTML = ''; //酒店列表HTML
  118. var area_id = '';
  119. var hotel_name = '';
  120. var hotel_status = '';
  121. var current = '1';
  122. var page_size = '15';
  123. window.onload = function () {
  124. provinceHTML = $('#province').html();
  125. cityHTML = $('#city').html();
  126. hotelHTML = $('#hotel_list').html();
  127. chooseProvince();
  128. chooseCity();
  129. current = '1';
  130. getHotelList();
  131. addNewHP();
  132. search();
  133. checkBox();
  134. }
  135. //选择省
  136. function chooseProvince() {
  137. provinceHTML = $('#province').html();
  138. cityHTML = $('#city').html();
  139. var apiurl = base_api + "?type=hotel_AddHotelProduct&op=provinceCity &area_id=";
  140. ZZLog(apiurl);
  141. $.getJSON(apiurl, function (res_data) {
  142. ZZLog(res_data);
  143. if (res_data['code'] != "0") {
  144. alert(res_data['info']);
  145. } else {
  146. //地区
  147. var area_list = res_data['area_list'];
  148. var areaHTML = '<option value="0" style="font-size:12px;">选择省</option>';
  149. for (var i = 0, m = area_list.length; i < m; i++) {
  150. var tempDict = area_list[i];
  151. var tempHTML = provinceHTML;
  152. tempHTML = tempHTML.replace('选择省', tempDict['area_name']);
  153. tempHTML = tempHTML.replace('0', tempDict['area_id']);
  154. areaHTML += tempHTML;
  155. }
  156. if (areaHTML) {
  157. $('#province').html(areaHTML);
  158. $('#province')[0].selectedIndex = 0;
  159. }
  160. }
  161. })
  162. }
  163. //选择市
  164. function chooseCity() {
  165. $('#province').bind('change', function () {
  166. var area_id = $(this).val();
  167. if (area_id == "0" || area_id == "") {
  168. $('#city').html(cityHTML);
  169. return;
  170. }
  171. var url = base_api + "?type=hotel_AddHotelProduct&op=provinceCity&area_id=" + area_id;
  172. ZZLog(url);
  173. $.getJSON(url, function (res_data) {
  174. ZZLog(res_data);
  175. if (res_data['code'] != "0") {
  176. alert(res_data['info']);
  177. } else {
  178. //地区
  179. var area_list = res_data['area_list'];
  180. var areaHTML = '<option value="0" style="font-size: 12px;">选择市</option>';
  181. for (var i = 0, m = area_list.length; i < m; i++) {
  182. var tempDict = area_list[i];
  183. var tempHTML = cityHTML;
  184. tempHTML = tempHTML.replace('选择市', tempDict['area_name']);
  185. tempHTML = tempHTML.replace('0', tempDict['area_id']);
  186. areaHTML += tempHTML;
  187. }
  188. if (areaHTML) {
  189. $('#city').html(areaHTML);
  190. $('#city')[0].selectedIndex = 0;
  191. }
  192. }
  193. })
  194. });
  195. }
  196. //得酒店信息
  197. function getHotelList() {
  198. var url = base_api + "?type=hotel_HotelProductList&area_id=" + area_id + "&hotel_name=" + hotel_name + "&hotel_status=" + hotel_status + "&current=" + current + "&page_size=" + page_size;
  199. ZZLog(url);
  200. $.getJSON(url, function (res_data) {
  201. ZZLog(res_data);
  202. if (res_data['code'] != "0") {
  203. alert(res_data['info']);
  204. } else {
  205. //酒店列表
  206. var HTHTML = '';
  207. for (var i = 0; i < res_data['hotel_list'].length; i++) {
  208. var tempDict = res_data['hotel_list'][i];
  209. var tempHTML = hotelHTML;
  210. tempHTML = tempHTML.replace(/\[hotel-id]/g, tempDict['hotel_id']);
  211. tempHTML = tempHTML.replace('[酒店名称]', tempDict['hotel_name']);
  212. tempHTML = tempHTML.replace('[城市]', tempDict['area_name'] != "" ? tempDict['parent_area_name']+tempDict['area_name'] : "-");
  213. tempHTML = tempHTML.replace('[供应商]', tempDict['supplier_name'] !== null ? tempDict['supplier_name'] : "-");
  214. tempHTML = tempHTML.replace('[采购负责人]', tempDict['purchaser_name'] !== null ? tempDict['purchaser_name'] : "-");
  215. tempHTML = tempHTML.replace('[售卖状态]', tempDict['hotel_status'] == "0" ? '停售' : '在售');
  216. //需求修改上下架不需要房型
  217. //'<a href="room_info.html?hotel_id=' + tempDict['hotel_id'] + '&hotel_name=' + tempDict['hotel_name'] + '">房型</a>'
  218. var cstr = '<a onclick="open_new_path(this)" go_path="zz-jd/modify_hotel_product.html?hotel_id=' + tempDict['hotel_id'] + '">修改</a>';
  219. tempHTML = tempHTML.replace('[操作]', cstr);
  220. HTHTML += tempHTML;
  221. }
  222. $('#hotel_list').html(HTHTML);
  223. $('#hotel_list').show();
  224. if (res_data['total'] <= 0) {
  225. $('.pageDiv').hide();
  226. } else {
  227. $(".pageDiv").createPage({
  228. pageCount: res_data['total_page'],//总页数
  229. current: current,//当前页
  230. turndown: 'true',//是否显示跳转框,显示为true,不现实为false,一定记得加上引号...
  231. backFn: function (p) {
  232. current = p;
  233. getHotelList();
  234. }
  235. });
  236. $('.pageDiv').show();
  237. }
  238. }
  239. }).error(function(jqXHR, textStatus, errorThrown) {
  240. console.log("error " + textStatus);
  241. console.log("incoming Text " + jqXHR.responseText);
  242. })
  243. }
  244. function search() {
  245. $('#search').bind('click', function () {
  246. //获取条件信息
  247. var province = $('#province').val();
  248. var city = $('#city').val();
  249. hotel_name = $('#hotel_name').val();
  250. hotel_status = $('#hotel_status').val();
  251. area_id = city != 0 ? city : province;
  252. if (hotel_status == "") {
  253. alert('请选择售卖状态!');
  254. return;
  255. }
  256. if (area_id == '0') {
  257. area_id = '';
  258. }
  259. current = 1;
  260. getHotelList()
  261. });
  262. }
  263. function addNewHP() {
  264. // 添加酒店跳转链接
  265. $('#add').bind('click', function () {
  266. var listURL = "add_hotel_product.html";
  267. listURL = encodeURI(listURL);
  268. // window.open(listURL);
  269. $.cookie("path_url",cookie_path+"zz-jd/"+listURL,{domain:domain_path,path:"/"});
  270. window.open(system_path);
  271. })
  272. }
  273. function linkToUpdate() {
  274. //跳到修改酒店产品页面
  275. $('.update_hotel_product').bind('click', function () {
  276. var hotel_id = $(this).closest('tr').attr('hotel-id');
  277. var hotel_name = $(this).closest('tr').children().eq(1).text();
  278. var listURL = "update_hotel_product.html?hotel_id=" + hotel_id + "&hotel_name=" + hotel_name;
  279. listURL = encodeURI(listURL);
  280. window.location.href = listURL;
  281. })
  282. }
  283. //批量将在售改为停售
  284. function batch_change_status(value) {
  285. var check_value = [];
  286. $('input[name="check_box_child"]:checked').each(function () {
  287. check_value.push($(this).closest('tr').attr('hotel-id'));
  288. });
  289. var check_hotel_id = check_value.join(",");
  290. var param = {
  291. op: value,
  292. type: 'hotel_HotelList',
  293. id: check_hotel_id
  294. }
  295. $.ajax({
  296. type: 'post',
  297. dataType: 'json',
  298. data: param,
  299. url: base_api,
  300. success: function (res_data) {
  301. ZZLog(res_data);
  302. if (res_data['code'] != "0") {
  303. alert(res_data['info'])
  304. }
  305. ;
  306. getHotelList();
  307. },
  308. error: function (error) {
  309. alert('system ajax http error');
  310. ZZLog(error);
  311. }
  312. })
  313. }
  314. function checkBox() {
  315. $('.check_box_main').bind('click', function () {
  316. if ($('.check_box_main').is(':checked')) {
  317. $("input[name='check_box_child']").prop("checked", true);
  318. } else {
  319. $("input[name='check_box_child']").removeAttr("checked", true);
  320. }
  321. //取值
  322. $('.check_box').each(function () {
  323. var status = $(this).is(':checked')
  324. })
  325. });
  326. $('.check_box').bind('click', function () {
  327. if ($("input[name='check_box_child']").not("input:checked").size() <= 0) {
  328. $('.check_box_main').prop("checked", true);
  329. } else {
  330. $('.check_box_main').prop("checked", false);
  331. }
  332. })
  333. }