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.
 
 
 
 

305 lines
9.6 KiB

  1. // 总计
  2. var tr_finalStr='';
  3. var http_data_length=0;
  4. function reload_Info(httpData){
  5. var chartLeftSpan=$('#chartLeftSpan');
  6. var chartLeftSpanStr=chartLeftSpan.html();
  7. chartLeftSpanStr=chartLeftSpanStr.replace('[订单号]',httpData['orderID']);
  8. chartLeftSpanStr=chartLeftSpanStr.replace('[是否入住]',httpData['ifstay']);
  9. chartLeftSpanStr=chartLeftSpanStr.replace('[分销商(上海驴妈妈)]',httpData['orderCome']);
  10. chartLeftSpanStr=chartLeftSpanStr.replace('[酒店]',httpData['saleStyle']);
  11. chartLeftSpan.html(chartLeftSpanStr);
  12. var orderCount=$('#orderCount');
  13. var orderCountStr=orderCount.html();
  14. orderCountStr=orderCountStr.replace('[a]',httpData['orderCount']);
  15. orderCountStr=orderCountStr.replace('[b]',httpData['messageCount']);
  16. orderCountStr=orderCountStr.replace('[c]',httpData['orderAttachment']);
  17. orderCount.html(orderCountStr);
  18. //提交订单
  19. var commitOrder=$('#commitOrder');
  20. var commitOrderStr=commitOrder.html();
  21. commitOrderStr=commitOrderStr.replace('[2016.03.02]',httpData['commitDay']);
  22. commitOrderStr=commitOrderStr.replace('[20:30]',httpData['commitTime']);
  23. commitOrder.html(commitOrderStr);
  24. var startarea=$('#startarea');
  25. var startareaStr=startarea.html();
  26. startareaStr=startareaStr.replace('[产品]',httpData['product']);
  27. startareaStr=startareaStr.replace('[房型]',httpData['bedStyle']);
  28. startarea.html(startareaStr);
  29. var startTime =$('#starttime');
  30. var startTimeStr=startTime.html();
  31. startTimeStr=startTimeStr.replace('[销售渠道]',httpData['bookSale']);
  32. startTimeStr=startTimeStr.replace('[产品公司]',httpData['company']);
  33. startTime.html(startTimeStr);
  34. var totalTime =$('#totalTime');
  35. var totalTimeStr=totalTime.html();
  36. totalTimeStr=totalTimeStr.replace('[入住]',httpData['comeDay']);
  37. totalTimeStr=totalTimeStr.replace('[离店]',httpData['goDay']);
  38. totalTimeStr=totalTimeStr.replace('[t]',httpData['totalTime']);
  39. totalTimeStr=totalTimeStr.replace('[h]',httpData['totalhour']);
  40. totalTime.html(totalTimeStr);
  41. //前
  42. var bookInfo=httpData['bookInfo'];
  43. var front=$("#front");
  44. var tttHTML=$('#tr_one').prop('outerHTML');
  45. var newHTML=''
  46. for(var i=0;i<bookInfo.length;i++){
  47. var tempDict=bookInfo[i];
  48. var tempHTML=tttHTML;
  49. tempHTML=tempHTML.replace('[入住日期]',tempDict['startTime']);
  50. tempHTML=tempHTML.replace('[库存]',tempDict['stock']);
  51. tempHTML=tempHTML.replace('[N间]',tempDict['bedCount']);
  52. tempHTML=tempHTML.replace('[m元]',tempDict['buyPrice']);
  53. tempHTML=tempHTML.replace('[n元]',tempDict['endPrice']);
  54. tempHTML=tempHTML.replace('[零售价]',tempDict['salePrice']);
  55. tempHTML=tempHTML.replace('[采购价金额]',tempDict['buy']);
  56. tempHTML=tempHTML.replace('[结算价金额]',tempDict['end']);
  57. tempHTML=tempHTML.replace('[销售利润]',tempDict['profit']);
  58. newHTML+=tempHTML;
  59. }
  60. var total = $('#tr_total').prop('outerHTML');
  61. total = total.replace('[总采购价金额]',httpData['bookTotalBuy']);
  62. total = total.replace('[总结算价金额]',httpData['bookTotalEnd']);
  63. total = total.replace('[总销售利润]',httpData['bookTotalProfit']);
  64. newHTML+=total;
  65. front.html(newHTML);
  66. // 后
  67. var bookInfoChange=httpData['bookInfochange'];
  68. var after=$("#after");
  69. http_data_length=bookInfoChange.length;
  70. var tttHTML=$('#tr_two').prop('outerHTML');
  71. var newHTML2=''
  72. for(var i=0;i<bookInfoChange.length;i++){
  73. var tempDict=bookInfoChange[i];
  74. var tempHTML=tttHTML;
  75. tempHTML=tempHTML.replace('tr_one','tr_one_'+i);
  76. tempHTML=tempHTML.replace('select_room','select_room_'+i);
  77. tempHTML=tempHTML.replace('[cai_blur]',i);
  78. tempHTML=tempHTML.replace('[jie_blur]',i);
  79. tempHTML=tempHTML.replace('[index]',i);
  80. tempHTML=tempHTML.replace('[cai1]',i);
  81. tempHTML=tempHTML.replace('[jie1]',i);
  82. tempHTML=tempHTML.replace('[cai2]',i);
  83. tempHTML=tempHTML.replace('[jie2]',i);
  84. tempHTML=tempHTML.replace('[lirun]',i);
  85. tempHTML=tempHTML.replace('[入住日期]',tempDict['startTimechange']);
  86. tempHTML=tempHTML.replace('[库存]',tempDict['stockchange']);
  87. tempHTML=tempHTML.replace('[零售价]',tempDict['salePricechange']);
  88. tempHTML=tempHTML.replace('[采购价金额]',tempDict['buychange']);
  89. tempHTML=tempHTML.replace('[结算价金额]',tempDict['endchange']);
  90. tempHTML=tempHTML.replace('[销售利润]',tempDict['profitchange']);
  91. newHTML2+=tempHTML;
  92. }
  93. //
  94. // var totalchange = $('#totalchange').prop('outerHTML');
  95. // totalchange = totalchange.replace('[总采购价金额]',httpData['bookTotalBuy']);
  96. // totalchangeotal = totalchange.replace('[总结算价金额]',httpData['bookTotalEnd']);
  97. // totalchange = totalchange.replace('[总销售利润]',httpData['bookTotalProfit']);
  98. // newHTML2+=totalchange;
  99. for (var i=0;i<bookInfoChange.length;i++) {
  100. var tempDict=bookInfoChange[i];
  101. update_show(i,1,tempDict['buychange'],tempDict['endchange'])
  102. // alert(tempDict['cai_price_balance']);
  103. }
  104. // newHTML2+=tr_finalStr;
  105. tr_finalStr=$('#totalchange').prop('outerHTML');
  106. after.html(newHTML2);
  107. //加载之后第一次计算
  108. var all_cai=0;
  109. var all_jie=0;
  110. var all_profits=0;//利润
  111. for (var i=0;i<bookInfoChange.length;i++) {
  112. var tempDict=bookInfoChange[i];
  113. update_show(i,1,tempDict['buychange'],tempDict['endchange']);
  114. all_cai+=parseInt(tempDict['buychange']);
  115. all_jie+=parseInt(tempDict['endchange']);
  116. all_profits+=all_jie-all_cai;
  117. }
  118. //计算完了再加载 总计的HTML
  119. var all_HTML=$('#after').html();
  120. var tempHTML=tr_finalStr;
  121. tempHTML=tempHTML.replace('[总采购价金额]',all_cai);
  122. tempHTML=tempHTML.replace('[总结算价金额]',all_jie);
  123. tempHTML=tempHTML.replace('[总销售利润]',all_profits);
  124. all_HTML+=tempHTML;
  125. $('#after').html(all_HTML);
  126. }
  127. window.onload=function (){
  128. get_virtual_user_list('./json/changeOrderJson.html');
  129. }
  130. /*======================网络请求的Ajax的代码=======================*/
  131. // 创建一个Ajax对象
  132. if (window.ActiveXObject){
  133. var myreq = new ActiveXObject("Microsoft.XMLHTTP");
  134. }else{
  135. var myreq = new XMLHttpRequest();
  136. }
  137. // 请求方法,传入URL
  138. function get_virtual_user_list(myURL)
  139. {
  140. myreq.open("get",myURL,true);
  141. // 接收的数据交给哪个函数处理
  142. myreq.onreadystatechange = show_user_list;
  143. myreq.send();
  144. }
  145. function show_user_list()
  146. {
  147. if (myreq.readyState == 4)
  148. {
  149. // newstr 就是接收到的数据
  150. var newstr = myreq.responseText;
  151. var httpData=JSON.parse(newstr);
  152. reload_Info(httpData);
  153. }
  154. }
  155. //选择房间数
  156. function select_room(index,count){
  157. //拿到采购价和结算价
  158. var cai_price=$('#cai_price_'+index).val();
  159. var jie_price=$('#jie_price_'+index).val();
  160. //计算
  161. update_show(index,count,cai_price,jie_price);
  162. //总计
  163. all_total_show()
  164. }
  165. //采购价value发生改变
  166. function cai_change(index,value){
  167. //拿到房间数
  168. var rooms=$('#select_room_'+index).find("option:selected").val();
  169. //拿到结算价
  170. var jie_price=$('#jie_price_'+index).val();
  171. //计算
  172. update_show(index,rooms,value,jie_price);
  173. //总计
  174. all_total_show();
  175. }
  176. //结算价value发生改变
  177. function jie_change(index,value){
  178. if (value.trim().length<=0) {
  179. value=0;
  180. }
  181. //拿到房间数
  182. var rooms=$('#select_room_'+index).find("option:selected").val();
  183. //拿到采购价
  184. var cai_price=$('#cai_price_'+index).val();
  185. //计算
  186. update_show(index,rooms,cai_price,value);
  187. //总计
  188. all_total_show();
  189. }
  190. //计算和显示
  191. function update_show(index,room_count,cai_price,jie_price){
  192. //计算
  193. var all_cai=cai_price*room_count;
  194. var all_jie=jie_price*room_count;
  195. //改变页面
  196. //利润
  197. var profits=all_jie-all_cai;
  198. //改变页面的效果
  199. $('#cai_price_balance_'+index).html(all_cai);
  200. $('#jie_price_balance_'+index).html(all_jie);
  201. $('#profits_'+index).html(profits);
  202. }
  203. //总计
  204. function all_total_show(){
  205. var all_cai=0;
  206. var all_jie=0;
  207. var all_profits=0;//利润
  208. for (var i=0;i<http_data_length;i++) {
  209. var cai=$('#cai_price_balance_'+i).html();
  210. var jie=$('#jie_price_balance_'+i).html();
  211. var profits=$('#profits_'+i).html();
  212. all_cai+=parseInt(cai);
  213. all_jie+=parseInt(jie);
  214. all_profits=all_jie-all_cai;
  215. }
  216. var all_HTML=$('#totalchange').html();
  217. var tempHTML=tr_finalStr;
  218. var profits=all_jie-all_cai;
  219. tempHTML=tempHTML.replace('[总采购价金额]',all_cai);
  220. tempHTML=tempHTML.replace('[总结算价金额]',all_jie);
  221. tempHTML=tempHTML.replace('[总销售利润]',all_profits);
  222. all_HTML+=tempHTML;
  223. $('#totalchange').html(all_HTML);
  224. }
  225. //居中显示
  226. var tempDiv=null;
  227. function center_show(show_div){
  228. tempDiv=show_div;
  229. //显示蒙板
  230. show_div.css('display','block');
  231. show_div.css('z-index',10);
  232. show_div.css('background-color','white');
  233. show_div.css('position','fixed');
  234. var w=show_div.css('width');
  235. var h=show_div.css('height');
  236. w=w.substr(0,w.length-2);
  237. h=h.substr(0,h.length-2);
  238. // var s_left=(window.screen.availWidth-w)/2 +"px";
  239. // var s_top=(window.screen.availHeight-h)/2 +'px';
  240. var s_left=(window.innerWidth-w)/2+'px';
  241. var s_top=(window.innerHeight-h)/2+'px';
  242. show_div.css('left',s_left);
  243. show_div.css('top',s_top);
  244. $('.mask').css('display','block');
  245. }
  246. //点击蒙板
  247. function hide_all(){
  248. $('.mask').css('display','none');
  249. tempDiv.css('display','none');
  250. }
  251. //点击了三个固定的
  252. function click_show_div(objName){
  253. var obj=$(objName);
  254. if (obj.css('display')=='none') {
  255. center_show(obj);
  256. }else{
  257. obj.css('display','none');
  258. }
  259. }
  260. //点击了第二级
  261. function click_two_show_div(father_name,self_name){
  262. var father=$(father_name);
  263. var self=$(self_name);
  264. father.css('display','none');
  265. center_show(self);
  266. }
  267. //点击了关闭
  268. function click_cancel(father_name,self_name){
  269. if (father_name) {
  270. var father=$(father_name);
  271. center_show(father);
  272. }else{
  273. $('.mask').css('display','none');
  274. }
  275. $(self_name).css('display','none');
  276. }