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.

hotel_order_detail_level.js 42 KiB

3 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317
  1. //date:2017-04-12
  2. let cache_res_data = {};
  3. let order_id = '';
  4. let mao_location = '';
  5. let temp_all_html = '';
  6. let save_info = '保存';
  7. let save_update_info = '保存并生成修改单';
  8. let temp_docking_type = '';
  9. let temp_order_status = '';
  10. $(document).ready(function() {
  11. order_id = getPar('order_id');
  12. mao_location = getPar('location');
  13. if(mao_location.indexOf('#') != -1) {
  14. let index = mao_location.indexOf('#');
  15. mao_location = mao_location.substring(0, index);
  16. }
  17. if('' == order_id) {
  18. ZZAlertInfo('缺少订单号!');
  19. return;
  20. }
  21. loading();
  22. httpLoadInfo()
  23. })
  24. //加载基本信息
  25. function httpLoadInfo() {
  26. let data = {
  27. "type": "order_HotelOrderDetailLevel",
  28. "order_id": order_id
  29. }
  30. $.ajax({
  31. type: "post",
  32. url: base_api,
  33. async: true,
  34. data: data,
  35. dataType: "json",
  36. success: (res_data) => {
  37. ZZLog(res_data);
  38. if(res_data['code'] != "0") {
  39. ZZAlertInfo(res_data['info']);
  40. } else {
  41. cache_res_data[order_id] = res_data;
  42. loadHtml(res_data);
  43. loadUpLog(res_data);
  44. httpLoadLog();
  45. closeLoading();
  46. //锚点定位
  47. // location.href = "#"+mao_location;
  48. if(mao_location != "") window.location.hash = '#' + mao_location;
  49. }
  50. },
  51. error: () => {
  52. ZZAlertInfo(infoApiError);
  53. }
  54. });
  55. }
  56. //根据初始数据刷新页面
  57. function loadHtml(res_data) {
  58. // order_info
  59. //:如果是直连订单 不能更改销售价
  60. let order_info = res_data['order_info'];
  61. let order_id = order_info['order_id'];
  62. let order_status_name = order_info['order_status_name']
  63. let org_id = order_info['org_id'];
  64. let org_name = order_info['org_name'];
  65. let org_num = order_info['org_num'];
  66. $('#top-order-id').html('订单编号:' + order_id);
  67. $('#top-order-status').html(order_status_name);
  68. $('#top-order-channel').html('订单渠道:' + org_name);
  69. $('#top-order-channel-order-id').html(org_num);
  70. let docking_type = order_info['docking_type'];
  71. temp_docking_type = docking_type;
  72. let docking_type_desc = order_info['docking_type_desc'];
  73. if('557' == docking_type) {
  74. // $('#ludan').html(docking_type_desc);
  75. $('#ludan').html('录');
  76. $('#ludan').removeClass('hide_f')
  77. }
  78. if('556' == docking_type) {
  79. // $('#zhilian').html(docking_type_desc);
  80. $('#zhilian').html('直');
  81. $('#zhilian').removeClass('hide_f')
  82. }
  83. let cha = order_info['seconds'];
  84. if(cha >= 0) { //后30分钟内
  85. timeJian();
  86. function timeJian() {
  87. cha--;
  88. if(cha < 0) cha = 0;
  89. let m = parseInt(cha / 60);
  90. let s = cha % 60;
  91. if(0 == m && s == 0) {
  92. $('#top-order-status-main').children().eq(2).html(`${order_status_name} <span style="color:red;">(超时)</span>`);
  93. return;
  94. }
  95. m = m < 10 ? `0${m}` : m;
  96. s = s < 10 ? `0${s}` : s;
  97. $('#top-order-status-main').children().eq(1).html('|');
  98. $('#top-order-status-main').children().eq(2).html(`${order_status_name} <span style="color:red;">(${m}:${s})</span>`);
  99. setTimeout(timeJian, 1000);
  100. }
  101. }
  102. //订单状态
  103. let order_status = res_data['order_status'];
  104. if(order_status.hasOwnProperty('198')) $('.198').addClass('active'); //待安排
  105. if(order_status.hasOwnProperty('314')) $('.314').addClass('active'); //已安排
  106. if(order_status.hasOwnProperty('147')) $('.147').addClass('active'); //已入住
  107. if('147' == order_info['order_status']) $('.147').addClass('active'); //已入住
  108. temp_order_status = order_info['order_status'];
  109. //三个单 下载 0:确认单 1:修改单 2:取消单
  110. if('0' == order_info['order_level']) {
  111. $('#top-btn-ok-d').removeClass('hide_f')
  112. $('#top-btn-update-d').addClass('hide_f')
  113. $('#top-btn-cancele-d').addClass('hide_f')
  114. };
  115. if('1' == order_info['order_level']) {
  116. $('#top-btn-update-d').removeClass('hide_f')
  117. $('#top-btn-ok-d').addClass('hide_f')
  118. $('#top-btn-cancele-d').addClass('hide_f')
  119. };
  120. if('2' == order_info['order_level']) {
  121. $('#top-btn-cancel-d').removeClass('hide_f')
  122. $('#top-btn-ok-d').addClass('hide_f')
  123. $('#top-btn-update-d').addClass('hide_f')
  124. };
  125. //1.入住需求
  126. let hotel_id = order_info['hotel_id'];
  127. let hotel_name = order_info['hotel_name'];
  128. let room_type = order_info['room_type'];
  129. let base_room_type = order_info['base_room_type'];
  130. let room_name = order_info['room_name'];
  131. $('#rz-hotel-name').attr('data-hotel-id', hotel_id);
  132. $('#rz-hotel-name').html(hotel_name);
  133. $('#rz-hotel-room').attr('data-room-type', room_type);
  134. $('#rz-hotel-room').attr('data-base-room-type', base_room_type);
  135. $('#rz-hotel-room').html(room_name);
  136. //1.1渠道订单号
  137. $('#order_channel_order_id_txt').html(org_num);
  138. $('#order_channel_order_id').val(org_num);
  139. $('#order_channel_txt').html(org_name);
  140. let org_list = res_data['org_list'];
  141. let channel_html = '';
  142. org_list.forEach((v, i) => {
  143. channel_html += `<option value="${v.org_id}">${v.org_name}</option>`;
  144. })
  145. $('#order_channel').html(channel_html);
  146. $('#order_channel').val(org_id);
  147. //1.2入住日期
  148. let start_date = order_info['start_date'];
  149. let end_date = order_info['end_date'];
  150. $('#start_date').children().eq(0).val(start_date);
  151. $('#end_date').children().eq(0).val(end_date);
  152. let s_s = start_date.replace(/\-/g, '');
  153. let e_s = end_date.replace(/\-/g, '');
  154. let days = e_s - s_s - 0;
  155. $('#datediff').html(`共${days}晚`);
  156. $('#start_date_txt').html(start_date);
  157. $('#end_date_txt').html(end_date);
  158. //1.3表格
  159. let one_day = order_info['one_day'];
  160. let one_html = '';
  161. let all_commission = order_info['all_commission'];
  162. let all_price = order_info['all_price'];
  163. let all_profit = order_info['all_profit'];
  164. let all_html = `<tr style="font-weight:bold">
  165. <td>小计</td>
  166. <td></td>
  167. <td></td>
  168. <td></td>
  169. <td class="all_price" data-value="${all_price}">${all_price}元</td>
  170. <td class="all_commission" data-value="${all_price}">${all_commission}元</td>
  171. <td class="all_profit" data-value="${all_price}">${all_profit}元</td>
  172. </tr>`;
  173. temp_all_html = all_html;
  174. one_day.forEach((v, i) => {
  175. let cstr1 = '';
  176. for(let j = 1; j <= 20; j++) {
  177. cstr1 += `<option value="${j}">${j}</option>`;
  178. }
  179. one_html += `<tr class="tr_line" height="45">
  180. <td>${v.start_date}</td>
  181. <td>
  182. <span class="update1_s">${v.count}</span>
  183. <select class="form-control hide_f update1_h room_count" style="width: 40px;padding:0px">
  184. ${cstr1}
  185. </select>
  186. </td>
  187. <td>
  188. <span class="update2_s">${v.order_price}</span>
  189. <input data-price="${v.order_price}" type="text" class="form-control hide_f update2_h sale_single_price" style="width: 80px;" value="${v.order_price}"/>
  190. </td>
  191. <td>
  192. <span class="update3_s">${v.base_price}</span>
  193. <input data-price="${v.base_price}" type="text" class="form-control hide_f update3_h cai_base_price" style="width: 80px;" value="${v.base_price}"/>
  194. </td>
  195. <td class="tr_all_price">${toDecimal2(v.order_price*v.count)}</td>
  196. <td class="tr_all_commission" data-commission="${toDecimal2(v.commission)}">${toDecimal2(v.commission)}</td>
  197. <td class="tr_profit_value">${toDecimal2(v.profit_value)}</td>
  198. </tr>`;
  199. });
  200. one_html += all_html;
  201. $('#rz-table').html(one_html);
  202. $('.room_count').on('change', function() {
  203. $parent = $(this).closest('.tr_line');
  204. changeCount($parent);
  205. })
  206. $('.sale_single_price').on('input', function() {
  207. $parent = $(this).closest('.tr_line');
  208. tr_change($parent);
  209. })
  210. $('.cai_base_price').on('input', function() {
  211. $parent = $(this).closest('.tr_line');
  212. tr_change($parent);
  213. })
  214. $('.sale_single_price').on('blur', function() {
  215. let val = $(this).val();
  216. val = val.trim() == "" ? "0" : val.trim();
  217. $(this).val(val);
  218. })
  219. $('.cai_base_price').on('blur', function() {
  220. let val = $(this).val();
  221. val = val.trim() == "" ? "0" : val.trim();
  222. $(this).val(val);
  223. })
  224. //1.5三个按钮
  225. //如果是直连 则不能够修改销售价 556:直连 557:录单
  226. if('556' == docking_type) {
  227. $('#btn-rz-update-xsj').hide();
  228. $('#btn-rz-update-xsj').remove();
  229. $('#btn-rz-update-xsj').css('opacity', '0');
  230. //1.5.1
  231. let status_arr1 = ['313'];
  232. let status_arr2 = ["198", "382"];
  233. let status_arr3 = ['313', '198', '382'];
  234. if($.inArray(temp_order_status, status_arr3) == -1) {
  235. $('#btn-rz-update-xq').hide();
  236. $('#btn-rz-update-xq').remove();
  237. $('#btn-rz-update-xq').css('opacity', '0');
  238. $('#btn-rz-update-cgj').hide();
  239. $('#btn-rz-update-cgj').remove();
  240. $('#btn-rz-update-cgj').css('opacity', '0');
  241. $('#btn-rz-update-cancel').hide();
  242. $('#btn-rz-update-cancel').remove();
  243. $('#btn-rz-update-cancel').css('opacity', '0');
  244. //客人信息
  245. $('#btn-customer-update').closest('.myBody').children().eq(2).css('opacity', '0');
  246. $('#btn-customer-update').closest('.myBody').children().eq(2).hide();
  247. //订单备注
  248. $('.order-remark').css('opacity', '0');
  249. $('.order-remark').hide();
  250. $('.btn-comment').attr("disabled", "disabled");
  251. $('.btn-comment').hide();
  252. }
  253. }
  254. if("557" == docking_type) {
  255. //1.5.2
  256. let status_arr1 = ['313'];
  257. let status_arr2 = ["198", "382"];
  258. let status_arr3 = ['313', '198', '382'];
  259. if($.inArray(temp_order_status, status_arr3) == -1) {
  260. //三个按钮
  261. $('#btn-rz-update-xq').hide();
  262. $('#btn-rz-update-xq').remove();
  263. $('#btn-rz-update-xq').css('opacity', '0');
  264. $('#btn-rz-update-xsj').hide();
  265. $('#btn-rz-update-xsj').remove();
  266. $('#btn-rz-update-xsj').css('opacity', '0');
  267. $('#btn-rz-update-cgj').hide();
  268. $('#btn-rz-update-cgj').remove();
  269. $('#btn-rz-update-cgj').css('opacity', '0');
  270. $('#btn-rz-update-cancel').hide();
  271. $('#btn-rz-update-cancel').remove();
  272. $('#btn-rz-update-cancel').css('opacity', '0');
  273. //客人信息
  274. $('#btn-customer-update').closest('.myBody').children().eq(2).css('opacity', '0');
  275. $('#btn-customer-update').closest('.myBody').children().eq(2).hide();
  276. //订单备注
  277. $('.order-remark').css('opacity', '0');
  278. $('.order-remark').hide();
  279. $('.btn-comment').attr("disabled", "disabled");
  280. $('.btn-comment').hide();
  281. }
  282. }
  283. //2.0客人信息
  284. let customer_name = order_info['customer_name'];
  285. let customer_mobile = order_info['customer_mobile'];
  286. $('#customer_name_txt').html(customer_name);
  287. $('#customer_name').val(customer_name);
  288. $('#customer_phone_txt').html(customer_mobile ? customer_mobile : "-");
  289. $('#customer_phone').val(customer_mobile);
  290. //3.0订单备注
  291. let order_comment = res_data['order_comment'];
  292. let comment_html = '';
  293. order_comment.forEach((v, i) => {
  294. comment_html += ` <tr>
  295. <td data-type="${v.comment_type}">${v.comment_type_desc}</td>
  296. <td>${v.comment_txt}</td>
  297. <td>${v.user_true_name?v.user_true_name:"-"}</td>
  298. <td>${v.create_time}</td>
  299. <td>
  300. <button type="button" data-comment-id="${v.comment_id}" class="btn btn-link btn-comment" style="padding-left: 0;">删除</button>
  301. </td>
  302. </tr>`;
  303. })
  304. $('#remark-table').html(comment_html);
  305. //删除备注
  306. $('.btn-comment').on('click', function() {
  307. let $this = $(this);
  308. ZZConfirm("您真的要删除该条备注吗?", function() {
  309. let comment_id = $this.attr('data-comment-id');
  310. let data = {
  311. type: "order_ModifyHTOrderLevel",
  312. op: "commentDel",
  313. order_id,
  314. comment_id
  315. }
  316. $.ajax({
  317. type: "post",
  318. url: base_api,
  319. async: true,
  320. data: data,
  321. dataType: "json",
  322. success: (res_data) => {
  323. ZZLog(res_data);
  324. if(res_data['code'] != "0") {
  325. ZZAlertInfo(res_data['info']);
  326. } else {
  327. httpLoadInfo();
  328. }
  329. },
  330. error: () => {
  331. ZZAlertInfo(infoApiError);
  332. }
  333. });
  334. })
  335. })
  336. }
  337. function changeCount($parent) {
  338. // 房间数量
  339. var room_count = $parent.find('.room_count');
  340. // 结算单价
  341. var room_price = $parent.find('.sale_single_price');
  342. // 佣金规则
  343. var dict = getJsonHtml($parent.attr('data-json'));
  344. var dict_maiduan = getJsonHtml($parent.attr('data-json-maiduan'));
  345. var dict_baoliu = getJsonHtml($parent.attr('data-json-baoliu'));
  346. var dict_xianxun = getJsonHtml($parent.attr('data-json-xianxun'));
  347. var commision_price = 0;
  348. if(dict['commision_flag'] == '1') { //有佣金规则
  349. if(dict['back_commision_method'] == '309') { //308 按销售金额309 按结算金额
  350. commision_price = dict['back_value']
  351. } else if(dict['back_commision_method'] == '308') {
  352. commision_price = room_count * room_price * parseFloat(dict['back_percent']) / 100;
  353. }
  354. } else { //无佣金规则
  355. commision_price = 0;
  356. }
  357. //end 佣金规则
  358. //结算总价
  359. var jiesuan_price = room_count * room_price;
  360. //end 结算总价
  361. //库存类型与成本
  362. var maiduan_count = dict_maiduan['remaining_count'] == undefined ? 0 : dict_maiduan['remaining_count'];
  363. var baoliu_count = dict_baoliu['remaining_count'] == undefined ? 0 : dict_baoliu['remaining_count'];
  364. var xianxun_count = dict_xianxun['remaining_count'] == undefined ? 0 : dict_xianxun['remaining_count'];
  365. var maiduan_price = dict_maiduan['cost_price'] == undefined ? 0 : dict_maiduan['cost_price'];
  366. var baoliu_price = dict_baoliu['cost_price'] == undefined ? 0 : dict_baoliu['cost_price'];
  367. var xianxun_price = dict_xianxun['cost_price'] == undefined ? 0 : dict_xianxun['cost_price'];
  368. //end 库存类型与成本
  369. //销售利润
  370. var profit = 0;
  371. if(parseInt(room_count) <= parseInt(maiduan_count)) { //所选房间数小于等于买断数
  372. profit = jiesuan_price - commision_price - maiduan_price * room_count
  373. } else if(parseInt(room_count) > parseInt(maiduan_count) && parseInt(room_count) <= (parseInt(maiduan_count) + parseInt(baoliu_count))) { //所选房间数大于买断数,小于等于保留数+买断数
  374. profit = jiesuan_price - commision_price - maiduan_price * maiduan_count - baoliu_price * (room_count - maiduan_count)
  375. } else if(parseInt(room_count) > (parseInt(maiduan_count) + parseInt(baoliu_count)) && parseInt(room_count) <= (parseInt(maiduan_count) + parseInt(baoliu_count) + parseInt(xianxun_count))) {
  376. profit = jiesuan_price - commision_price - maiduan_price * maiduan_count - baoliu_price * baoliu_count - xianxun_price * (room_count - maiduan_count - baoliu_count)
  377. }
  378. //end 销售利润
  379. //佣金显示
  380. var commision_price1 = parseFloat(commision_price).toFixed(2);
  381. if(dict['commision_flag'] == 1) {
  382. $parent.find('.tr_all_commission').text(commision_price1);
  383. } else {
  384. $parent.find('.tr_all_commission').text('-');
  385. }
  386. //结算总价显示
  387. var jiesuan_price1 = parseFloat(jiesuan_price).toFixed(2);
  388. if(jiesuan_price1) {
  389. $parent.find('.tr_all_price').text(jiesuan_price1);
  390. }
  391. //销售利润显示
  392. var profit1 = parseFloat(profit).toFixed(2);
  393. if(profit1) {
  394. $parent.find('.tr_profit_value').text(profit1);
  395. }
  396. total_price_jisuan();
  397. }
  398. function tr_change($parent) {
  399. let room_count = $parent.find('.room_count').val();
  400. let sale_single_price = $parent.find('.sale_single_price').val();
  401. let cai_base_price = $parent.find('.cai_base_price').val();
  402. let commission = $parent.find('.tr_all_commission').attr('data-commission');
  403. let tr_all_1 = sale_single_price * room_count;
  404. tr_all_1 = tr_all_1.toFixed(2);
  405. let tr_all_2 = commission * room_count;
  406. tr_all_2 = tr_all_2.toFixed(2);
  407. let tr_all_3 = tr_all_1 - cai_base_price * room_count;
  408. tr_all_3 = tr_all_3.toFixed(2);
  409. if(isNaN(tr_all_1)) tr_all_1 = 0;
  410. if(isNaN(tr_all_2)) tr_all_2 = 0;
  411. if(isNaN(tr_all_3)) tr_all_3 = 0;
  412. // if(0==tr_all_1) tr_all_1 = '-';
  413. // if(0==tr_all_2) tr_all_2 = '-';
  414. // if(0==tr_all_3) tr_all_3 = '-';
  415. $parent.find('.tr_all_price').text(tr_all_1);
  416. $parent.find('.tr_all_commission').text(tr_all_2);
  417. $parent.find('.tr_profit_value').text(tr_all_3);
  418. total_price_jisuan();
  419. }
  420. function total_price_jisuan() {
  421. let all_1 = 0,
  422. all_2 = 0,
  423. all_3 = 0;
  424. $('.tr_all_price').each(function(index, dom) {
  425. let tr_all_1 = $(this).text();
  426. all_1 += tr_all_1 - 0;
  427. })
  428. $('.tr_all_commission').each(function(index, dom) {
  429. let tr_all_2 = $(this).text();
  430. all_2 += tr_all_2 - 0;
  431. })
  432. $('.tr_profit_value').each(function(index, dom) {
  433. let tr_all_3 = $(this).text();
  434. all_3 += tr_all_3 - 0;
  435. })
  436. if(isNaN(all_1)) all_1 = 0;
  437. if(isNaN(all_2)) all_2 = 0;
  438. if(isNaN(all_3)) all_3 = 0;
  439. $('.all_price').text(all_1.toFixed(2) + '元');
  440. $('.all_price').attr('data-value', all_1.toFixed(2));
  441. $('.all_commission').text(all_2.toFixed(2) + '元');
  442. $('.all_commission').attr('data-value', all_2.toFixed(2));
  443. $('.all_profit').text(all_3.toFixed(2) + '元');
  444. $('.all_profit').attr('data-value', all_2.toFixed(2));
  445. }
  446. function loadUpLog(res_data) {
  447. let log_update_user = res_data['log_update_user'];
  448. let log_html = ' <option value="0">全部</option>';
  449. log_update_user.forEach((v, i) => {
  450. log_html += `<option value="${v.id}">${v.true_name}</option>`;
  451. })
  452. $('#update-user').html(log_html);
  453. $('#update-user').comboSelect();
  454. }
  455. $('#log-search').on('click', function() {
  456. httpLoadLog();
  457. })
  458. //请求操作日志
  459. function httpLoadLog() {
  460. let log_user = $('#update-user').val();
  461. let log_start_date = $('#log-start-date').val();
  462. let log_end_date = $('#log-end-date').val();
  463. let data = {
  464. order_id,
  465. type: "log_LogLogInformation",
  466. name: "getHotelDetail",
  467. operator: log_user,
  468. startDate: log_start_date,
  469. endDate: log_end_date
  470. }
  471. ZZLog(JSON.stringify(data));
  472. $.ajax({
  473. type: "post",
  474. url: base_api,
  475. async: true,
  476. data: data,
  477. dataType: 'json',
  478. success: (res_data) => {
  479. ZZLog(res_data);
  480. if(res_data['code'] != "0") {
  481. ZZAlertInfo(res_data['info']);
  482. } else {
  483. let log_list = res_data['result'];
  484. let log_html = '';
  485. let _room_name = '';
  486. log_list = log_list.reverse();
  487. log_list.forEach((v, i) => {
  488. log_html += `<tr height="40px">
  489. <td>${v.true_name}</td>
  490. <td>${v.create_time}</td>
  491. <td>${v.log_desc.replace(/\;/g,'<br/>')}</td>
  492. </tr>`;
  493. })
  494. $('#log-table').html(log_html);
  495. }
  496. },
  497. error: () => {
  498. ZZAlertInfo(infoApiError);
  499. }
  500. });
  501. }
  502. //确认单
  503. $('#top-btn-ok-d').on('click', function() {
  504. window.location.href = base_api + "?type=order_HotelOrderDetailLevel&op=export&order_id=" + order_id;
  505. })
  506. //修改单
  507. $('#top-btn-update-d').on('click', function() {
  508. window.location.href = base_api + "?type=order_HotelOrderDetailLevel&op=export&order_id=" + order_id;
  509. })
  510. //取消单
  511. $('#top-btn-cancel-d').on('click', function() {
  512. window.location.href = base_api + "?type=order_HotelOrderDetailLevel&op=export&order_id=" + order_id;
  513. })
  514. //入住时间
  515. $('#start_date').on('changeDate', function(e) {
  516. changeStartEndDate();
  517. })
  518. //离店时间
  519. $('#end_date').on('changeDate', function(e) {
  520. changeStartEndDate();
  521. })
  522. function changeStartEndDate() {
  523. let start_date = $('#start_date').children().eq(0).val();
  524. let end_date = $('#end_date').children().eq(0).val();
  525. let s_s = start_date.replace(/\-/g, '');
  526. let e_s = end_date.replace(/\-/g, '');
  527. let days = e_s - s_s - 0;
  528. $('#datediff').html(`共${days}晚`);
  529. let hotel_id = $('#rz-hotel-name').attr('data-hotel-id');
  530. let room_type = $('#rz-hotel-room').attr('data-room-type');
  531. let base_room_type = $('#rz-hotel-room').attr('data-base-room-type');
  532. let org_id = $('#order_channel').val();
  533. let data = {
  534. "type": "order_ModifyHTOrderLevel",
  535. "op": "stockGetList",
  536. start_date,
  537. end_date,
  538. hotel_id,
  539. room_type,
  540. org_id,
  541. "parent_room_type": base_room_type
  542. }
  543. ZZLog(JSON.stringify(data));
  544. $.ajax({
  545. type: "post",
  546. url: base_api,
  547. async: true,
  548. data: data,
  549. dataType: "json",
  550. success: (res_data) => {
  551. ZZLog(res_data);
  552. if(res_data['code'] != "0") {
  553. ZZAlertInfo(res_data['info']);
  554. } else {
  555. loadStockHtml(res_data);
  556. }
  557. },
  558. error: () => {
  559. ZZAlertInfo(infoApiError);
  560. }
  561. });
  562. }
  563. //加载库存相差
  564. function loadStockHtml(res_data) {
  565. let price_info_list = res_data['price_info_list'];
  566. let stock_list = res_data['stock_list'];
  567. let sumHTML = '';
  568. price_info_list.forEach((v, i) => {
  569. let HTML = `<tr class="tr_line" height="45" data-json=[data-json] data-json-maiduan=[data-json-maiduan] data-json-baoliu=[data-json-baoliu] data-json-xianxun=[data-json-xianxun]>
  570. <td>[入住日期]</td>
  571. <td>
  572. <span class="update1_h hide_f room_count_txt">[间数1]</span>
  573. <select class="form-control update1_s room_count" style="width: 40px;padding:0px">
  574. [间数2]
  575. </select>
  576. </td>
  577. <td>
  578. <span class="update2_s sale_single_price_txt">[销售单价]</span>
  579. <input data-price="[销售单价]" type="text" class="form-control hide_f update2_h sale_single_price" style="width: 80px;" value="[销售单价]">
  580. </td>
  581. <td>
  582. <span class="update3_s cai_base_price_txt">[采购成本价]</span>
  583. <input data-price="[采购成本价]" type="text" class="form-control hide_f update3_h cai_base_price" style="width: 80px;" value="[采购成本价]">
  584. </td>
  585. <td class="tr_all_price">[销售总价]</td>
  586. <td class="tr_all_commission" data-commission=[渠道佣金]>[渠道佣金]</td>
  587. <td class="tr_profit_value">[利润]</td>
  588. </tr>`;
  589. HTML = HTML.replace('[入住日期]', v['run_date']);
  590. //得到替换数量,逻辑:先判断超售oversell_flag,1为可以超售,如果可以超售则取data['order_list'][1]中的该天所有库存,超了不能下单。
  591. let count = 0;
  592. if(1 == v['oversell_flag'] && -1 != v['remaining_count']) {
  593. stock_list.forEach((v2, i2) => {
  594. if(v['run_date'] == v2['run_date']) {
  595. count += parseInt(v2['remaining_count']);
  596. if("228" == v2['stock_type']) { //买断
  597. HTML = HTML.replace('[data-json-maiduan]', JSON.stringify(v2));
  598. } else if("229" == v2['stock_type']) { //现询
  599. HTML = HTML.replace('[data-json-xianxun]', JSON.stringify(v2));
  600. } else if("230" == v2["stock_type"]) { //保留
  601. HTML = HTML.replace('[data-json-baoliu]', JSON.stringify(v2));
  602. } else {
  603. ZZAlertInfo('没有该库存类型');
  604. }
  605. }
  606. })
  607. } else {
  608. stock_list.forEach((v2, i2) => {
  609. if(v['run_date'] == v2['run_date']) {
  610. if("228" == v2['stock_type']) { //买断
  611. count += parseInt(v2['remaining_count']);
  612. HTML = HTML.replace('[data-json-maiduan]', JSON.stringify(v2));
  613. } else if("229" == v2['stock_type']) { //现询
  614. HTML = HTML.replace('[data-json-xianxun]', JSON.stringify(v2));
  615. } else if("230" == v2["stock_type"]) { //保留
  616. count += parseInt(v2['remaining_count']);
  617. HTML = HTML.replace('[data-json-baoliu]', JSON.stringify(v2));
  618. } else {
  619. ZZAlertInfo('没有该库存类型');
  620. }
  621. }
  622. })
  623. count = parseInt(v['remaining_count'] == -1 ? 0 : v['remaining_count']);
  624. }
  625. let optionHTML = '';
  626. for(let m = 0; m <= count; m++) {
  627. if(m > 20) break;
  628. let temp = `<option value="${m}">${m}</option>`;
  629. optionHTML += temp;
  630. }
  631. HTML = HTML.replace('[间数2]', optionHTML);
  632. HTML = HTML.replace(/\[销售单价]/g, v['price']);
  633. HTML = HTML.replace(/\[采购成本价]/g, v['price']);
  634. //佣金规则
  635. let ling = 0;
  636. let ling1 = ling.toFixed(2);
  637. if(0 == v['commission_flag']) { //为0不返佣 为1返佣
  638. HTML = HTML.replace(/\[渠道佣金]/g, '-');
  639. } else {
  640. HTML = HTML.replace(/\[渠道佣金]/g, ling1);
  641. }
  642. HTML = HTML.replace('[销售总价]', ling1);
  643. HTML = HTML.replace('[利润]', ling1);
  644. //将非超卖库存存入data-json
  645. HTML = HTML.replace('[data-json]', JSON.stringify(v));
  646. sumHTML += HTML;
  647. })
  648. sumHTML += temp_all_html;
  649. $('#rz-table').html(sumHTML);
  650. $('.room_count').on('change', function() {
  651. $parent = $(this).closest('.tr_line');
  652. tr_change($parent);
  653. })
  654. let hotel_child_order_detail = {};
  655. if(cache_res_data.hasOwnProperty(order_id)) {
  656. hotel_child_order_detail = cache_res_data[order_id]['hotel_child_order_detail'];
  657. $('#rz-table .tr_line').each(function(index, dom) {
  658. for(let n = 0; n < hotel_child_order_detail.length; n++) {
  659. if(hotel_child_order_detail[n]['run_date'] == $(dom).find('td:first').text()) {
  660. let dict = hotel_child_order_detail[n];
  661. $(dom).find('.room_count').val(dict['total']); //间数
  662. $(dom).find('.sale_single_price_txt').text(dict['order_price']); //销售单价
  663. $(dom).find('.sale_single_price').attr('data-price', dict['order_price']);
  664. $(dom).find('.sale_single_price').attr('value', dict['order_price']);
  665. $(dom).find('.cai_base_price_txt').text(dict['base_price']); //采购成本价
  666. $(dom).find('.cai_base_price').attr('data-price', dict['base_price']);
  667. $(dom).find('.cai_base_price').attr('value', dict['base_price']);
  668. $(dom).find('.tr_all_price').html(dict['all_price']); //销售总价
  669. $(dom).find('.tr_profit_value').text(dict['benefit']); //利润
  670. //根据不同类型,选择不同库存
  671. let json_type = '';
  672. if("228" == dict['stock_type']) json_type = "data-json-maiduan";
  673. if("229" == dict['stock_type']) json_type = "data-json-xianxun";
  674. if("230" == dict['stock_type']) json_type = "data-json-baoliu";
  675. let tr_json_data = $(dom).attr(json_type);
  676. if(tr_json_data != '' && tr_json_data.indexOf('[data-json') == -1) {
  677. let tmp_data = JSON.parse(tr_json_data);
  678. tmp_data['remaining_count'] = parseInt(tmp_data['remaining_count']) + parseInt(dict['total']);
  679. var json_str = JSON.stringify(tmp_data);
  680. $(dom).attr(json_type, json_str);
  681. }
  682. let count = parseInt($(dom).find('.room_count option:last').html());
  683. let new_count = count + parseInt(dict['total']);
  684. for(var i = count + 1; i <= new_count && i < 20; i++) {
  685. $(dom).find('.room_count option:last').after('<option value="' + i + '">' + i + '</option>');
  686. }
  687. $(dom).find('.room_count').val(dict['total']).change();
  688. }
  689. }
  690. })
  691. }
  692. //刷新总计
  693. total_price_jisuan();
  694. }
  695. $('#btn-rz-update-xq').on('click', function() {
  696. //1:修改入住需求 2:保存并生成修改单 3:保存
  697. let btn_status = $(this).attr('data-btn-status') ? $(this).attr('data-btn-status') : "1";
  698. if('1' == btn_status) {
  699. ZZLog('修改入住需求');
  700. $('#btn-rz-cancel').attr('data-main-status', '1');
  701. $('#btn-rz-cancel').removeClass('hide_f');
  702. $('#btn-rz-update-xsj').addClass('hide_f');
  703. $('#btn-rz-update-cgj').addClass('hide_f');
  704. //切换编辑状态
  705. $('.update1_h').removeClass('hide_f');
  706. $('.update1_s').addClass('hide_f');
  707. changeStartEndDate();
  708. click_three_btn($(this));
  709. }
  710. if('2' == btn_status || "3" == btn_status) {
  711. ZZLog('保存入住需求');
  712. commit($(this));
  713. }
  714. })
  715. function commit($this) {
  716. //提交的参数
  717. let hotel_id = '';
  718. let room_type = '';
  719. if(cache_res_data.hasOwnProperty(order_id)) {
  720. hotel_id = cache_res_data[order_id]['order_info']['hotel_id'];
  721. room_type = cache_res_data[order_id]['order_info']['room_type'];
  722. }
  723. if('' == hotel_id || '' == room_type) {
  724. ZZAlertInfo('缺少参数,逻辑出错');
  725. return;
  726. }
  727. //获取联系人,联系方式,备注
  728. var contacts = $('#customer_name').val().replace(/\,/g, ' ').trim();
  729. var phone = $('#customer_phone').val();
  730. var more = '',
  731. total = 0;
  732. //拒单标识0为不能拒单,1为可以拒单
  733. var if_cancel = 0;
  734. let cus_list = `{${contacts},${phone},${more}}`;
  735. //最晚到店时间
  736. let checkin_time = "23:59";
  737. let org_num = $('#order_channel_order_id').val();
  738. let org_id = $('#order_channel').val();
  739. //房型列表
  740. let room_list = '';
  741. let room_count = 0;
  742. let dan_yongj = 0;
  743. let all_yongj = $('.all_commission').attr('data-value');
  744. let all_profit = $('.all_profit').attr('data-value');
  745. let temp_arr = [];
  746. $('.tr_line').each(function(index, dom) {
  747. let start_date = $(this).children().eq(0).text();
  748. let all_count = $(this).find('.room_count').val();
  749. room_count += parseInt(all_count) - 0;
  750. if(all_count == 0) {
  751. temp_arr.push('1');
  752. // ZZAlertInfo('请选择库存');
  753. // return;
  754. }
  755. let dan_jiesuan = $(this).find('.sale_single_price').val();
  756. dan_yongj = 0;
  757. if("-" == $(this).find('.tr_all_commission').text()) dan_yongj = 0;
  758. if("-" != $(this).find('.tr_all_commission').text()) dan_yongj = parseFloat($(this).find('.tr_all_commission').text()) / parseInt(all_count);
  759. //获得买断,保留,现询的价格与库存
  760. let dict_maiduan = getJsonHtml($(this).attr('data-json-maiduan'));
  761. let dict_baoliu = getJsonHtml($(this).attr('data-json-baoliu'));
  762. let dict_xianxun = getJsonHtml($(this).attr('data-json-xianxun'));
  763. //库存类型与成本
  764. var maiduan_count = dict_maiduan == 0 ? 0 : dict_maiduan['remaining_count'];
  765. var baoliu_count = dict_baoliu == 0 ? 0 : dict_baoliu['remaining_count'];
  766. var xianxun_count = dict_xianxun == 0 ? 0 : dict_xianxun['remaining_count'];
  767. var maiduan_price = dict_maiduan == 0 ? 0 : dict_maiduan['cost_price'];
  768. var baoliu_price = dict_baoliu == 0 ? 0 : dict_baoliu['cost_price'];
  769. var xianxun_price = dict_xianxun == 0 ? 0 : dict_xianxun['cost_price'];
  770. if(maiduan_price == 0 && baoliu_price == 0 && xianxun_price == 0) {
  771. temp_arr.push('2');
  772. // ZZAlertInfo('存在成本价为零,请至对应房型列表确认');
  773. // return;
  774. }
  775. //判断库存
  776. var maiduan_field = '';
  777. var baoliu_field = '';
  778. var xianxun_field = '';
  779. var sum_field = '';
  780. if(parseInt(all_count) <= parseInt(maiduan_count)) { //小于等于买断库存228
  781. sum_field = '228' + ',' + all_count + ',' + maiduan_price
  782. } else if(parseInt(all_count) > parseInt(maiduan_count) && parseInt(all_count) <= (parseInt(maiduan_count) + parseInt(baoliu_count))) {
  783. maiduan_field = '228' + ',' + maiduan_count + ',' + maiduan_price;
  784. baoliu_field = '230' + ',' + (all_count - maiduan_count) + ',' + baoliu_price;
  785. sum_field = maiduan_field + '|' + baoliu_field
  786. } else if(parseInt(all_count) > (parseInt(maiduan_count) + parseInt(baoliu_count)) && parseInt(all_count) <= (parseInt(maiduan_count) + parseInt(baoliu_count) + parseInt(xianxun_count))) {
  787. if_cancel = 1;
  788. maiduan_field = '228' + ',' + maiduan_count + ',' + maiduan_price;
  789. baoliu_field = '230' + ',' + baoliu_count + ',' + baoliu_price;
  790. xianxun_field = '229' + ',' + (all_count - baoliu_count - maiduan_count) + ',' + xianxun_price;
  791. sum_field = maiduan_field + '|' + baoliu_field + '|' + xianxun_field
  792. } else {
  793. // alert('出错了,不可能!!');
  794. temp_arr.push('3');
  795. // return;
  796. }
  797. room_list += '{\'\'' + start_date + '\'\',' + all_count + ',' + dan_jiesuan + ',' + dan_yongj + '}';
  798. total += all_count;
  799. })
  800. if($.inArray('1', temp_arr) >= 0) {
  801. ZZAlertInfo('请选择库存');
  802. return;
  803. } else if($.inArray('2', temp_arr) >= 0) {
  804. ZZAlertInfo('存在成本价为零,请至对应房型列表确认');
  805. return;
  806. } else if($.inArray('3', temp_arr) >= 0) {
  807. ZZAlertInfo('出错了,不可能!!');
  808. return;
  809. } else {}
  810. let start_date = $('#start_date').children().eq(0).val();
  811. let end_date = $('#end_date').children().eq(0).val();
  812. let data = {
  813. // type: "order_ModifyHTOrder",
  814. // op: "modify_order",
  815. type: "order_ModifyHTOrderLevel",
  816. op: "orderUpdateCheckIn",
  817. hotel_id: hotel_id,
  818. room_type: room_type,
  819. org_id: org_id,
  820. org_num: org_num,
  821. room_list: room_list,
  822. room_count: room_count,
  823. cus_list: cus_list,
  824. contact: contacts,
  825. mobile: phone,
  826. start_date: start_date,
  827. end_date: end_date,
  828. // memo: more,
  829. // total: total,//这两个参数 php没有接收
  830. checkin_time: checkin_time,
  831. if_cancel: if_cancel,
  832. order_id: order_id,
  833. total_commission: all_yongj,
  834. benefit: all_profit
  835. }
  836. ZZLog(JSON.stringify(data));
  837. $.ajax({
  838. type: "post",
  839. url: base_api,
  840. async: true,
  841. data: data,
  842. dataType: "json",
  843. success: (res_data) => {
  844. ZZLog(res_data);
  845. if(res_data['code'] != "0") {
  846. ZZAlertInfo(res_data['info']);
  847. } else {
  848. //在这里写保存的操作
  849. $('#btn-rz-cancel').addClass('hide_f');
  850. $('#btn-rz-update-xsj').removeClass('hide_f');
  851. $('#btn-rz-update-cgj').removeClass('hide_f');
  852. //浏览状态
  853. $('.update1_h').addClass('hide_f');
  854. $('.update1_s').removeClass('hide_f');
  855. $(this).attr('data-btn-status', '1');
  856. $(this).html('修改入住需求');
  857. httpLoadInfo();
  858. }
  859. },
  860. error: () => {
  861. ZZAlertInfo(infoApiError);
  862. }
  863. });
  864. }
  865. //修改销售价
  866. $('#btn-rz-update-xsj').on('click', function() {
  867. //1:修改销售价 2:保存销售价
  868. let btn_status = $(this).attr('data-btn-status') ? $(this).attr('data-btn-status') : "1";
  869. if('1' == btn_status) {
  870. ZZLog('修改销售价');
  871. $('#btn-rz-cancel').attr('data-main-status', '2');
  872. $('#btn-rz-cancel').removeClass('hide_f');
  873. $('#btn-rz-update-xq').addClass('hide_f');
  874. $('#btn-rz-update-cgj').addClass('hide_f');
  875. $(this).attr('data-btn-status', '2');
  876. $(this).html(save_info);
  877. //切换编辑状态
  878. $('.update2_h').removeClass('hide_f');
  879. $('.update2_s').addClass('hide_f');
  880. }
  881. if('2' == btn_status) {
  882. ZZLog('保存销售价');
  883. //在这里写保存的操作
  884. $('#btn-rz-cancel').addClass('hide_f');
  885. $('#btn-rz-update-xq').removeClass('hide_f');
  886. $('#btn-rz-update-cgj').removeClass('hide_f');
  887. $(this).attr('data-btn-status', '1');
  888. $(this).html('修改销售价');
  889. //浏览状态
  890. $('.update2_h').addClass('hide_f');
  891. $('.update2_s').removeClass('hide_f');
  892. let room_list = [];
  893. $('.tr_line').each(function(index, dom) {
  894. let run_date = $(this).children().eq(0).text();
  895. let old = $(this).find('.sale_single_price').attr('data-price');
  896. let sale_single_price = $(this).find('.sale_single_price').val();
  897. if(old != sale_single_price) {
  898. let obj = {
  899. run_date,
  900. "order_price": sale_single_price
  901. };
  902. room_list.push(obj);
  903. }
  904. })
  905. let data = {
  906. type: "order_ModifyHTOrderLevel",
  907. op: "orderUpdateXSJ",
  908. order_id,
  909. room_list: JSON.stringify(room_list)
  910. }
  911. $.ajax({
  912. type: "post",
  913. url: base_api,
  914. async: true,
  915. data: data,
  916. dataType: "json",
  917. success: (res_data) => {
  918. ZZLog(res_data);
  919. if(res_data['code'] != "0") {
  920. ZZAlertInfo(res_data['info']);
  921. } else {
  922. httpLoadInfo();
  923. }
  924. },
  925. error: () => {
  926. ZZAlertInfo(infoApiError);
  927. }
  928. });
  929. }
  930. })
  931. //修改采购价
  932. $('#btn-rz-update-cgj').on('click', function() {
  933. //1:修改采购价 2:保存并生成修改单 3:保存采购价
  934. let btn_status = $(this).attr('data-btn-status') ? $(this).attr('data-btn-status') : "1";
  935. if('1' == btn_status) {
  936. ZZLog('修改采购价');
  937. $('#btn-rz-cancel').attr('data-main-status', '3');
  938. $('#btn-rz-cancel').removeClass('hide_f');
  939. $('#btn-rz-update-xq').addClass('hide_f');
  940. $('#btn-rz-update-xsj').addClass('hide_f');
  941. //切换编辑状态
  942. $('.update3_h').removeClass('hide_f');
  943. $('.update3_s').addClass('hide_f');
  944. click_three_btn($(this));
  945. }
  946. if('2' == btn_status || "3" == btn_status) {
  947. ZZLog('保存采购价');
  948. //在这里写保存的操作
  949. $('#btn-rz-cancel').addClass('hide_f');
  950. $('#btn-rz-update-xq').removeClass('hide_f');
  951. $('#btn-rz-update-xsj').removeClass('hide_f');
  952. $(this).attr('data-btn-status', '1');
  953. $(this).html('修改采购价');
  954. //浏览状态
  955. $('.update3_h').addClass('hide_f');
  956. $('.update3_s').removeClass('hide_f');
  957. let cus_list = [];
  958. $('.tr_line').each(function(index, dom) {
  959. let run_date = $(this).children().eq(0).text();
  960. let old = $(this).find('.cai_base_price').attr('data-price');
  961. let base_price = $(this).find('.cai_base_price').val();
  962. if(old != base_price) {
  963. let obj = {
  964. run_date,
  965. "base_price": base_price
  966. };
  967. cus_list.push(obj);
  968. }
  969. })
  970. let data = {
  971. type: "order_ModifyHTOrderLevel",
  972. op: "orderUpdateCGJ",
  973. order_id,
  974. cus_list: JSON.stringify(cus_list)
  975. }
  976. $.ajax({
  977. type: "post",
  978. url: base_api,
  979. async: true,
  980. data: data,
  981. dataType: "json",
  982. success: (res_data) => {
  983. ZZLog(res_data);
  984. if(res_data['code'] != "0") {
  985. ZZAlertInfo(res_data['info']);
  986. } else {
  987. httpLoadInfo();
  988. }
  989. },
  990. error: () => {
  991. ZZAlertInfo(infoApiError);
  992. }
  993. });
  994. }
  995. })
  996. //入住需求取消
  997. $('#btn-rz-cancel').on('click', function() {
  998. //data-main-status 1:修改入住需求 2:修改销售价 3:修改采购价
  999. var btn_main_status = $(this).attr('data-main-status') ? $(this).attr('data-main-status') : "1";
  1000. if('1' == btn_main_status) {
  1001. //修改入住需求
  1002. ZZLog('入住需求取消-修改入住需求');
  1003. $('#btn-rz-update-xq').html('修改入住需求');
  1004. $('#btn-rz-update-xq').attr('data-btn-status', '1');
  1005. }
  1006. if('2' == btn_main_status) {
  1007. //修改销售价
  1008. ZZLog('入住需求取消-修改销售价');
  1009. $('#btn-rz-update-xsj').html('修改销售价');
  1010. $('#btn-rz-update-xsj').attr('data-btn-status', '1');
  1011. }
  1012. if('3' == btn_main_status) {
  1013. //修改采购价
  1014. ZZLog('入住需求取消-修改采购价');
  1015. $('#btn-rz-update-cgj').html('修改采购价');
  1016. $('#btn-rz-update-cgj').attr('data-btn-status', '1');
  1017. }
  1018. $(this).addClass('hide_f');
  1019. $('#btn-rz-update-xq').removeClass('hide_f');
  1020. $('#btn-rz-update-xsj').removeClass('hide_f');
  1021. $('#btn-rz-update-cgj').removeClass('hide_f');
  1022. $('.update1_s').removeClass('hide_f');
  1023. $('.update1_h').addClass('hide_f');
  1024. $('.update2_s').removeClass('hide_f');
  1025. $('.update2_h').addClass('hide_f');
  1026. $('.update3_s').removeClass('hide_f');
  1027. $('.update3_h').addClass('hide_f');
  1028. if(cache_res_data.hasOwnProperty(order_id)) {
  1029. loadHtml(cache_res_data[order_id]);
  1030. }
  1031. })
  1032. //客人修改
  1033. $('#btn-customer-update').on('click', function() {
  1034. //1:客人信息修改 2:保存并生成修改单 3:保存
  1035. ZZLog('客人信息修改');
  1036. let btn_status = $(this).attr('data-btn-status') ? $(this).attr('data-btn-status') : "1";
  1037. if('1' == btn_status) {
  1038. $('#btn-customer-cancel').removeClass('hide_f');
  1039. click_customer_update1($(this));
  1040. $('.update4_h').removeClass('hide_f');
  1041. $('.update4_s').addClass('hide_f');
  1042. }
  1043. if('2' == btn_status || '3' == btn_status) {
  1044. customer_cancel_css();
  1045. let customer_name = $('#customer_name').val().trim();
  1046. let customer_mobile = $('#customer_phone').val().trim();
  1047. let old_customer_name = $('#customer_name_txt').text();
  1048. let old_customer_mobile = $('#customer_phone_txt').text();
  1049. if(old_customer_name == customer_name && old_customer_mobile == customer_mobile) {
  1050. return;
  1051. }
  1052. let data = {
  1053. type: "order_ModifyHTOrderLevel",
  1054. op: "customerUpdate",
  1055. order_id,
  1056. customer_name,
  1057. customer_mobile
  1058. }
  1059. $.ajax({
  1060. type: "post",
  1061. url: base_api,
  1062. async: true,
  1063. data: data,
  1064. dataType: 'json',
  1065. success: (res_data) => {
  1066. ZZLog(res_data);
  1067. if(res_data['code'] != "0") {
  1068. ZZAlertInfo(res_data['info']);
  1069. } else {
  1070. httpLoadInfo();
  1071. httpLoadLog(); //重新加载log
  1072. }
  1073. },
  1074. error: () => {
  1075. ZZAlertInfo(infoApiError);
  1076. }
  1077. });
  1078. }
  1079. })
  1080. function click_customer_update1($this) {
  1081. let btn_status = '';
  1082. let btn_info = '';
  1083. let status_arr1 = ["313"];
  1084. let status_arr2 = ["198", "382"];
  1085. if($.inArray(temp_order_status, status_arr1) >= 0) {
  1086. btn_status = '3';
  1087. btn_info = save_info;
  1088. }
  1089. if($.inArray(temp_order_status, status_arr2) >= 0) {
  1090. btn_status = '2';
  1091. btn_info = save_update_info;
  1092. }
  1093. // //1.录单
  1094. // if("557" == temp_docking_type) {
  1095. // }
  1096. // //2.直连
  1097. // if("556" == temp_docking_type) {
  1098. // }
  1099. $this.attr('data-btn-status', btn_status);
  1100. $this.html(btn_info);
  1101. }
  1102. //客人取消
  1103. $('#btn-customer-cancel').on('click', function() {
  1104. ZZLog('客人信息取消');
  1105. customer_cancel_css();
  1106. })
  1107. $('.comment-type').on('click', function() {
  1108. $('.comment-type0').removeClass('comment_selected');
  1109. $('.comment-type1').removeClass('comment_selected');
  1110. $(this).addClass('comment_selected');
  1111. if($(this).hasClass('comment-type0')) {
  1112. //内部备注
  1113. $(this).removeClass('btn-default');
  1114. $(this).addClass('btn-primary');
  1115. $('#btn-order-remark-save-update-d').html('保存');
  1116. $('.comment-type1').removeClass('btn-primary');
  1117. $('.comment-type1').addClass('btn-default');
  1118. }
  1119. if($(this).hasClass('comment-type1')) {
  1120. //公共备注
  1121. $(this).removeClass('btn-default');
  1122. $(this).addClass('btn-primary');
  1123. let btn_info = '';
  1124. let status_arr1 = ['313'];
  1125. let status_arr2 = ["198", "382"];
  1126. if($.inArray(temp_order_status, status_arr1) >= 0) btn_info = save_info;
  1127. if($.inArray(temp_order_status, status_arr2) >= 0) btn_info = save_update_info;
  1128. $('#btn-order-remark-save-update-d').html(btn_info);
  1129. // $('#btn-order-remark-save-update-d').html('保存并生成修改单');
  1130. $('.comment-type0').removeClass('btn-primary');
  1131. $('.comment-type0').addClass('btn-default');
  1132. }
  1133. })
  1134. //备注保存并生成修改单
  1135. $('#btn-order-remark-save-update-d').on('click', function() {
  1136. ZZLog('备注保存并生成修改单');
  1137. let comment_type = $('.comment_selected').attr('data-value');
  1138. let comment_txt = $('#comment-txt').val();
  1139. let data = {
  1140. type: "order_ModifyHTOrderLevel",
  1141. op: "commentAdd",
  1142. order_id,
  1143. comment_type,
  1144. comment_txt
  1145. }
  1146. $.ajax({
  1147. type: "post",
  1148. url: base_api,
  1149. async: true,
  1150. data: data,
  1151. dataType: "json",
  1152. success: (res_data) => {
  1153. ZZLog(res_data);
  1154. if(res_data['code'] != "0") {
  1155. ZZAlertInfo(res_data['info']);
  1156. } else {
  1157. $('#comment-txt').val('');
  1158. $('#comment-type').val('0');
  1159. httpLoadInfo();
  1160. }
  1161. },
  1162. error: () => {
  1163. ZZAlertInfo(infoApiError);
  1164. }
  1165. });
  1166. })
  1167. //客人取消
  1168. function customer_cancel_css() {
  1169. $('#btn-customer-cancel').addClass('hide_f');
  1170. $('#btn-customer-update').attr('data-btn-status', '1');
  1171. $('#btn-customer-update').html('修改');
  1172. $('.update4_h').addClass('hide_f');
  1173. $('.update4_s').removeClass('hide_f');
  1174. }
  1175. //时间戳转换函数
  1176. function getLocalTime(nS) {
  1177. return new Date(parseInt(nS) * 1000).toLocaleString().replace(/:\d{1,2}$/, ' ');
  1178. }
  1179. //取出html存入的json
  1180. function getJsonHtml(data) {
  1181. if(data && data.indexOf('[') == -1) {
  1182. var data_info = JSON.parse(data);
  1183. return data_info;
  1184. } else {
  1185. return 0
  1186. }
  1187. }
  1188. //制保留2位小数,如:2,会在2后面补上00.即2.00
  1189. function toDecimal2(x) {
  1190. var f = parseFloat(x);
  1191. if(isNaN(f)) {
  1192. return false;
  1193. }
  1194. var f = Math.round(x * 100) / 100;
  1195. var s = f.toString();
  1196. var rs = s.indexOf('.');
  1197. if(rs < 0) {
  1198. rs = s.length;
  1199. s += '.';
  1200. }
  1201. while(s.length <= rs + 2) {
  1202. s += '0';
  1203. }
  1204. return s;
  1205. }
  1206. function click_three_btn($this) {
  1207. let btn_status = '';
  1208. let btn_info = '';
  1209. let status_arr1 = ['313'];
  1210. let status_arr2 = ["198", "382"];
  1211. if($.inArray(temp_order_status, status_arr1) >= 0) {
  1212. btn_status = '3';
  1213. btn_info = save_info;
  1214. }
  1215. if($.inArray(temp_order_status, status_arr2) >= 0) {
  1216. btn_status = '2';
  1217. btn_info = save_update_info;
  1218. }
  1219. $this.attr('data-btn-status', btn_status);
  1220. $this.html(btn_info);
  1221. }