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.

hotelSendConfirmList.js 19 KiB

3 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518
  1. /**
  2. * Created by luocj on 2016/9/24.
  3. */
  4. var tr_order_str = $('#tr_order').prop('outerHTML');//获取tr中所有的字符串
  5. var order_status = $("#search_status").val();
  6. var start_date = '';
  7. var end_date = '';
  8. var province = '0';
  9. var city = '0';
  10. var hotel_name = $("#hotel_name").val();
  11. var org_id = '';
  12. var more_search = '';
  13. var date_type = '';
  14. var yesterday = '';
  15. var today = '';
  16. var thisweekstartdate = '';
  17. var thisweekenddate = '';
  18. var thismonthstartdate = '';
  19. var thismonthenddate = '';
  20. var user_id = 1;
  21. var current = '1';
  22. var page_size = '30';
  23. var memodiv = $('.memo1').prop('outerHTML');
  24. var firstLoad = true;
  25. window.onload = function () {
  26. start_date = "";
  27. end_date = "";
  28. getHotelList();
  29. /*
  30. provinceHTML = $('#province').html();
  31. cityHTML = $('#city').html();
  32. var apiurl = base_api + "?type=hotel_AddHotelProduct&op=provinceCity&area_id=";
  33. ZZLog(apiurl);
  34. $.getJSON(apiurl, function (res_data) {
  35. ZZLog(res_data);
  36. if (res_data['code'] != "0") {
  37. ZZAlertInfo(res_data['info']);
  38. } else {
  39. //地区
  40. var area_list = res_data['area_list'];
  41. var areaHTML = '<option value="0" style="font-size:12px;">选择省</option>';
  42. for (var i = 0, m = area_list.length; i < m; i++) {
  43. var tempDict = area_list[i];
  44. var tempHTML = provinceHTML;
  45. tempHTML = tempHTML.replace('选择省', tempDict['area_name']);
  46. tempHTML = tempHTML.replace('0', tempDict['area_id']);
  47. areaHTML += tempHTML;
  48. }
  49. $('#province').html(areaHTML);
  50. $('#province')[0].selectedIndex = 0;
  51. }
  52. })
  53. */
  54. };
  55. //获取订单列表
  56. function getHotelList() {
  57. order_status = $("#search_status").val();
  58. if( order_status == 313 ) {
  59. $("#send_button").show();
  60. $("#confirm_button").hide();
  61. $("#send_button2").show();
  62. $("#confirm_button2").hide();
  63. } else {
  64. $("#send_button").hide();
  65. $("#confirm_button").show();
  66. $("#send_button2").hide();
  67. $("#confirm_button2").show();
  68. }
  69. province = '0';
  70. city = '0';
  71. hotel_name = $("#hotel_name").val();
  72. var com_url = base_api + "?type=order_HotelOrderList&op=sendconfirm_list&province=" + province + "&city=" + city + "&hotel_name=" + hotel_name + "&order_status=" + order_status + "&current=" + current + "&page_size=" + page_size;
  73. ZZLog(com_url);
  74. if(!firstLoad)
  75. loading();
  76. firstLoad = false;
  77. $.getJSON(com_url, function (data) {
  78. closeLoading();
  79. ZZLog(data);
  80. setDataBody(data);
  81. if (data['total_count'] < 0) {
  82. $('.pageDiv').hide();
  83. } else {
  84. $(".pageDiv").createPage({
  85. pageCount: data['total_page'],//总页数
  86. current: current,//当前页
  87. turndown: 'true',//是否显示跳转框,显示为true,不现实为false,一定记得加上引号...
  88. backFn: function (p) {
  89. current = p;
  90. havePageData();
  91. }
  92. });
  93. $('.pageDiv').show();
  94. }
  95. }).error(function (msg) {
  96. closeLoading();
  97. });
  98. }
  99. //替换订单主体
  100. function setDataBody(data) {
  101. var order_list = data['order_list'];
  102. var comHTML = '';
  103. for (var i = 0; i < order_list.length; i++) {
  104. var dict = order_list[i];
  105. var HTML = tr_order_str;
  106. var order_id = dict['order_id'];
  107. var order_status_name = dict['order_status_name'];
  108. var org_name = dict['org_name'];
  109. var status_txt = '';
  110. //var order_info = filterRepeatStr(dict['order_description']);
  111. HTML = HTML.replace('[订单编号]', dict['order_id'] === null ? '-' : dict['order_id']);
  112. HTML = HTML.replace('[order_id_c]', dict['order_id'] === null ? '-' : dict['order_id']);
  113. HTML = HTML.replace('[order_id]', dict['order_id'] === null ? '-' : dict['order_id']);
  114. HTML = HTML.replace('[order_status]', dict['order_status_name'] === null ? '-' : dict['order_status_name']);
  115. HTML = HTML.replace('[org_name]', dict['org_name'] === null ? '-' : dict['org_name']);
  116. HTML = HTML.replace('[org_id]', dict['org_id'] === null ? '-' : dict['org_id']);
  117. HTML = HTML.replace('[room_type]', dict['room_type'] === null ? '-' : dict['room_type']);
  118. HTML = HTML.replace('[hotel_id]', dict['hotel_id'] === null ? '-' : dict['hotel_id']);
  119. HTML = HTML.replace('[预订时间]', dict['create_time'] === null ? '-' : dict['create_time']);
  120. HTML = HTML.replace('[供应商]', dict['prod_supply_org_name'] === null ? '-' : dict['prod_supply_org_name']);
  121. HTML = HTML.replace('[预订产品]', dict['hotel_name'] + '&nbsp;' + dict['zifangxing'] + '<br/><span class="short-text" title="' + dict['order_description'] + '">' + dict['order_description'] + '</span>');
  122. HTML = HTML.replace('[客人信息]', dict['customer_name'] + '<br />' + dict['customer_mobile']);
  123. HTML = HTML.replace('[订单渠道]', dict['org_name'] === null ? '-' : dict['org_name'] + '<br/>');
  124. HTML = HTML.replace('[订单金额]', '¥' + dict['order_price']);
  125. HTML = HTML.replace('[支付方式]', dict['order_pay_type'] === null ? '-' : dict['order_pay_type']);
  126. //取消状态的订单要显示
  127. if ((dict['order_status'] == 148 || dict['order_status'] == 383) && dict['cancel_reason']) {
  128. status_txt = '<a href="javascritp:;" onclick="ZZAlertInfo(\'' + dict['cancel_reason'] + '\')">' + dict['order_status_name'] + '</a>';
  129. } else {
  130. status_txt = dict['order_status_name'];
  131. }
  132. HTML = HTML.replace('[状态]', status_txt);
  133. var order_id = dict['order_id'];
  134. var order_status = dict['order_status'];
  135. var hotel_id = dict['hotel_id'];
  136. var parent_room_type = dict['parent_room_type'];
  137. var room_type = dict['room_type'];
  138. var org_name = dict['org_name'];
  139. var org_id = dict['org_id'];
  140. /*
  141. var modify = ' <a onclick="modify_order(' + order_id + ',' + org_id + ',' + hotel_id + ',' + parent_room_type + ',' + room_type + ',\'' + org_name + '\')" style="cursor: pointer">修改</a>&nbsp;';
  142. var cancel = ' <a onclick="cancel_order(' + order_id + ',148)" style="cursor: pointer">取消</a> &nbsp;';
  143. var confirm = ' <a onclick="make_sure(' + order_id + ')" style="cursor: pointer">确认</a>&nbsp;';
  144. var send = ' <a style="cursor: pointer" onclick="billing(' + order_id + ')">发送确认单</a>&nbsp;';
  145. var sp_deal = ' <a style="cursor: pointer" onclick="showMB(' + order_id + ',' + order_status + ',\'' + order_status_name + '\')">异常订单处理</a>&nbsp;';
  146. if (dict['order_status'] == 145) {
  147. var cstr145 = modify + cancel;
  148. HTML = HTML.replace('[操作]', cstr145);
  149. } else if (dict['order_status'] == 313) {
  150. var cstr313 = modify + cancel + send;
  151. HTML = HTML.replace('[操作]', cstr313)
  152. } else if (dict['order_status'] == 198) {
  153. var cstr198 = confirm + sp_deal;
  154. HTML = HTML.replace('[操作]', cstr198)
  155. } else if (dict['order_status'] == 314) {
  156. HTML = HTML.replace('[操作]', sp_deal)
  157. } else if (dict['order_status'] == 382) { //已安排的订单 异常操作处理了,
  158. cancel = '<a onclick="cancel_order(' + order_id + ',' + order_status + ',383)" style="cursor: pointer"> 取消&nbsp; </a>';
  159. var cstr313 = modify + cancel + send;
  160. HTML = HTML.replace('[操作]', cstr313)
  161. } else if (dict['order_status'] == 383) {
  162. HTML = HTML.replace('[操作]', '-')
  163. HTML = HTML.replace('[font-color]', 'color: gray');
  164. }
  165. */
  166. // else if (dict['order_status'] == 314 && dict['order_pay_type'] == '现金支付') {
  167. // HTML = HTML.replace('[操作]', sp_deal)
  168. // } else if (dict['order_status'] == 314 && dict['order_pay_type'] == '微信支付') {
  169. // var cstr314wx = modify;
  170. // HTML = HTML.replace('[操作]', cstr314wx)
  171. // }
  172. /*
  173. else if (dict['order_status'] == 147) {
  174. var cstr147 = modify + cancel;
  175. HTML = HTML.replace('[操作]', cstr147)
  176. } else if (dict['order_status'] == 148 || dict['order_status'] == 383) {
  177. HTML = HTML.replace('[操作]', '—');
  178. HTML = HTML.replace('[font-color]', 'color: #cccccc');
  179. }
  180. */
  181. //公共备注
  182. if (dict['memo_flag'] != '') {
  183. HTML = HTML.replace('[公共备注]', '<a style="cursor: pointer" onclick="remarks(\'' + dict["memo_flag"] + '\')">有</a>')
  184. } else {
  185. HTML = HTML.replace('[公共备注]', '无')
  186. }
  187. comHTML += HTML;
  188. }
  189. $('#order_list').html(comHTML);
  190. $('#order_list').show();
  191. }
  192. function havePageData() {
  193. order_status = $("#search_status").val();
  194. if( order_status == 313 ) {
  195. $("#send_button").show();
  196. $("#confirm_button").hide();
  197. $("#send_button2").show();
  198. $("#confirm_button2").hide();
  199. } else {
  200. $("#send_button").hide();
  201. $("#confirm_button").show();
  202. $("#send_button2").hide();
  203. $("#confirm_button2").show();
  204. }
  205. province = '0';
  206. city = '0';
  207. hotel_name = $("#hotel_name").val();
  208. var com_url = base_api + "?type=order_HotelOrderList&op=sendconfirm_list&province=" + province + "&city=" + city + "&hotel_name=" + hotel_name + "&order_status=" + order_status + "&current=" + current + "&page_size=" + page_size;
  209. ZZLog(com_url);
  210. $.getJSON(com_url, function (data) {
  211. ZZLog(data);
  212. if (data['code'] != "0") {
  213. ZZAlertInfo(data['info']);
  214. } else {
  215. setDataBody(data);
  216. }
  217. })
  218. }
  219. // 复选框事件
  220. function select_checked(index) {
  221. //index=0最上面的全选 index=1表示的是下面所有的
  222. var cur_check = $('.ace')[0];
  223. var checkList = $('.ace');
  224. var checkCount = checkList.length - 1;
  225. var true_count = 0;
  226. for (var i = 1; i < checkList.length; i++) {
  227. if (index == '0') {
  228. checkList[i].checked = cur_check.checked;
  229. } else {
  230. if (checkList[i].checked == false) {
  231. cur_check.checked = false
  232. } else {
  233. true_count = true_count + 1;
  234. }
  235. }
  236. }
  237. //判断下面是否选中完
  238. if (checkCount == true_count) {
  239. cur_check.checked = true;
  240. }
  241. }
  242. $(document).ready(function () {
  243. //点击查询
  244. $('#search').bind('click', function () {
  245. getHotelList();
  246. });
  247. //昨日日期
  248. $('#yesterday').bind('click', function () {
  249. $("#start_date").val(getDateTime(10));
  250. $("#end_date").val(getDateTime(10));
  251. getHotelList();
  252. });
  253. //今日日期
  254. $('#today').bind('click', function () {
  255. $("#start_date").val(getDateTime(0));
  256. $("#end_date").val(getDateTime(0));
  257. getHotelList();
  258. });
  259. //本周日期
  260. $('#thisweek').bind('click', function () {
  261. $("#start_date").val(after(getDateTime(12)));
  262. $("#end_date").val(after(getDateTime(13)));
  263. getHotelList();
  264. });
  265. //本月日期
  266. $('#thismonth').bind('click', function () {
  267. $("#start_date").val(getDateTime(14));
  268. $("#end_date").val(getDateTime(15));
  269. getHotelList();
  270. });
  271. //选择省的事件
  272. $('#province').bind('change', function () {
  273. var area_id = $(this).val();
  274. if (area_id == "0" || area_id == "") {
  275. $('#city').html(cityHTML);
  276. return;
  277. }
  278. var url = base_api + "?type=hotel_AddHotelProduct&op=provinceCity&area_id=" + area_id;
  279. ZZLog(url);
  280. $.getJSON(url, function (res_data) {
  281. ZZLog(res_data);
  282. if (res_data['code'] != "0") {
  283. ZZAlertInfo(res_data['info']);
  284. } else {
  285. //地区
  286. var area_list = res_data['area_list'];
  287. var areaHTML = '<option value="0" style="font-size: 12px;">选择市</option>';
  288. for (var i = 0, m = area_list.length; i < m; i++) {
  289. var tempDict = area_list[i];
  290. var tempHTML = cityHTML;
  291. tempHTML = tempHTML.replace('选择市', tempDict['area_name']);
  292. tempHTML = tempHTML.replace('0', tempDict['area_id']);
  293. areaHTML += tempHTML;
  294. }
  295. if (areaHTML) {
  296. $('#city').html(areaHTML);
  297. $('#city')[0].selectedIndex = 0;
  298. }
  299. }
  300. })
  301. });
  302. }
  303. );
  304. //订单状态筛选
  305. var tempobj = null;
  306. function submit(param, obj) {
  307. if (tempobj) {
  308. $(tempobj).css("cssText", "font-size: 12px;width: 50px; padding: 3px;display: inline-block;margin-left: 5px;");
  309. }
  310. if (obj) {
  311. $(obj).css("cssText", "font-size: 12px;width: 50px; padding: 3px;display: inline-block;margin-left: 5px;background:dimgrey!important");
  312. }
  313. tempobj = obj;
  314. var url = getSelectInfo(param);
  315. getHotelList();
  316. }
  317. function getSelectInfo(status) {
  318. order_status = status;
  319. getHotelList();
  320. }
  321. //end 订单状态筛选
  322. //批量确认
  323. function get_seleted_order_list() {
  324. var checkList = $('.ace');
  325. var checkCount = checkList.length - 1;
  326. var true_count = 0;
  327. var order_list = "";
  328. for (var i = 1; i < checkList.length; i++) {
  329. if (checkList[i].checked == true ) {
  330. if( true_count == 0 ) {
  331. order_list = checkList[i].value;
  332. } else {
  333. order_list = order_list + "," + checkList[i].value;
  334. }
  335. true_count ++;
  336. }
  337. }
  338. if( true_count <= 0 ) {
  339. return false;
  340. } else {
  341. return order_list;
  342. }
  343. }
  344. function make_sure_all() {
  345. order_list = get_seleted_order_list();
  346. if( order_list == false ) {
  347. ZZAlertInfo('请选择要确认的订单');return;
  348. }
  349. var make_sure_num = ZZInput("请输入确认号", function (make_sure_num) {
  350. var make_sure_order_id = order_list;
  351. if (make_sure_num) { //点击的是确定
  352. make_sure_order_update(make_sure_order_id, make_sure_num);
  353. } else if (make_sure_num == "") { //没有输入内窝 点击了取消
  354. ZZAlertInfo('请正确输入确认单号');
  355. } else { //点击了取消
  356. }
  357. });
  358. function make_sure_order_update(make_sure_order_id, make_sure_num) {
  359. var url = base_api;
  360. var param = {
  361. type: "order_HotelOrderList",
  362. op: "make_sure_all",
  363. make_sure_order_id: make_sure_order_id,
  364. make_sure_num: make_sure_num
  365. }
  366. loading();
  367. $.ajax({
  368. url: url,
  369. type: "post",
  370. dataType: "json",
  371. data: param,
  372. success: function (res_data) {
  373. ZZLog(res_data);
  374. ZZAlertInfo(res_data['info']);
  375. getHotelList();
  376. closeLoading();
  377. },
  378. error: function (res_data) {
  379. closeLoading();
  380. }
  381. })
  382. }
  383. }
  384. //发单
  385. function billing_all() {
  386. order_list = get_seleted_order_list();
  387. if( order_list == false ) {
  388. ZZAlertInfo('请选择要发单的订单');return;
  389. }
  390. ZZConfirm("确定发送确认单吗?", function () {
  391. var url = base_api;
  392. var param = {
  393. type: "order_HotelOrderList",
  394. op: "billing_all",
  395. user_id: user_id,
  396. order_id: order_list
  397. };
  398. loading();
  399. $.ajax({
  400. url: url,
  401. type: "post",
  402. dataType: "json",
  403. data: param,
  404. success: function (res_data) {
  405. ZZLog(res_data);
  406. ZZAlertInfo(res_data['info'])
  407. getHotelList();
  408. closeLoading();
  409. },
  410. error: function (res_data) {
  411. closeLoading();
  412. }
  413. })
  414. });
  415. }
  416. //删掉重复显示的房型
  417. function filterRepeatStr(str) {
  418. var array = str.split("|");
  419. var data = '<br/>';
  420. var dict = array[0];//得到第一条数据
  421. var str2 = dict.split(",");
  422. var str3 = str2[0];//得到重复房型
  423. for (var i = 0; i < array.length; i++) {
  424. var dict1 = array[i];
  425. if (i == 0) {
  426. data += dict1;
  427. } else {
  428. dict1 = dict1.replace(str3 + ",", "|");
  429. data += dict1;
  430. }
  431. }
  432. return data;
  433. }
  434. //点击备注
  435. function remarks(memo) {
  436. $('#beizhu').show();
  437. $('#mask').show();
  438. var row_arr = memo.split('|');
  439. var sumHTML = '';
  440. if (row_arr) {
  441. for (var i = 0; i < row_arr.length; i++) {
  442. var dict = row_arr[i];
  443. var HTML = memodiv;
  444. var temp = dict.split(',');
  445. var main = temp[2];
  446. var time = temp[1];
  447. var user = temp[0];
  448. HTML = HTML.replace('[备注main]', main);
  449. HTML = HTML.replace('[备注time]', time);
  450. HTML = HTML.replace('[备注user]', user);
  451. sumHTML += HTML
  452. }
  453. $('#beizhumain').html(sumHTML);
  454. $('.memo1:odd').css('background', 'lightgray');
  455. }
  456. }
  457. // 点击蒙板
  458. function showMB(order_id, order_status, order_status_name) {
  459. $('#exception_handling').show();
  460. $('#mask').show();
  461. //提交异常状态处理状态
  462. var order_id = order_id;
  463. var order_status = order_status;
  464. var order_status_name = order_status_name;
  465. $('#make_sure').unbind('click');
  466. $('#make_sure').on('click', function () {
  467. var text_reason = $('#text_reason').val();
  468. var url = base_api;
  469. var param = {
  470. type: 'order_HotelOrderList',
  471. op: 'handle_order',
  472. user_id: 1,
  473. order_id: order_id,
  474. text_reason: text_reason,
  475. order_status: order_status,
  476. order_status_name: order_status_name
  477. }
  478. $.ajax({
  479. url: url,
  480. type: "post",
  481. dataType: "json",
  482. data: param,
  483. success: function (res_data) {
  484. ZZLog(res_data);
  485. if (res_data['code'] != "0") {
  486. ZZAlertInfo(res_data['info']);
  487. } else {
  488. ZZLog('code=0');
  489. hideMB();
  490. getHotelList();
  491. }
  492. }, error: function (error) {
  493. ZZLog(error);
  494. }
  495. })
  496. })
  497. }
  498. function hideMB() {
  499. $('#exception_handling').hide();
  500. $('#mask').hide();
  501. $("#text_reason").val('');
  502. $("#beizhu").hide();
  503. }