|
-
- // 总计
- var tr_finalStr='';
- var http_data_length=0;
-
- function reload_Info(httpData){
-
- var chartLeftSpan=$('#chartLeftSpan');
- var chartLeftSpanStr=chartLeftSpan.html();
- chartLeftSpanStr=chartLeftSpanStr.replace('[订单号]',httpData['orderID']);
- chartLeftSpanStr=chartLeftSpanStr.replace('[是否入住]',httpData['ifstay']);
- chartLeftSpanStr=chartLeftSpanStr.replace('[分销商(上海驴妈妈)]',httpData['orderCome']);
- chartLeftSpanStr=chartLeftSpanStr.replace('[酒店]',httpData['saleStyle']);
- chartLeftSpan.html(chartLeftSpanStr);
-
- var orderCount=$('#orderCount');
- var orderCountStr=orderCount.html();
- orderCountStr=orderCountStr.replace('[a]',httpData['orderCount']);
- orderCountStr=orderCountStr.replace('[b]',httpData['messageCount']);
- orderCountStr=orderCountStr.replace('[c]',httpData['orderAttachment']);
- orderCount.html(orderCountStr);
- //提交订单
- var commitOrder=$('#commitOrder');
- var commitOrderStr=commitOrder.html();
- commitOrderStr=commitOrderStr.replace('[2016.03.02]',httpData['commitDay']);
- commitOrderStr=commitOrderStr.replace('[20:30]',httpData['commitTime']);
- commitOrder.html(commitOrderStr);
-
-
-
- var startarea=$('#startarea');
- var startareaStr=startarea.html();
- startareaStr=startareaStr.replace('[产品]',httpData['product']);
- startareaStr=startareaStr.replace('[房型]',httpData['bedStyle']);
- startarea.html(startareaStr);
-
- var startTime =$('#starttime');
- var startTimeStr=startTime.html();
- startTimeStr=startTimeStr.replace('[销售渠道]',httpData['bookSale']);
- startTimeStr=startTimeStr.replace('[产品公司]',httpData['company']);
- startTime.html(startTimeStr);
-
- var totalTime =$('#totalTime');
- var totalTimeStr=totalTime.html();
- totalTimeStr=totalTimeStr.replace('[入住]',httpData['comeDay']);
- totalTimeStr=totalTimeStr.replace('[离店]',httpData['goDay']);
- totalTimeStr=totalTimeStr.replace('[t]',httpData['totalTime']);
- totalTimeStr=totalTimeStr.replace('[h]',httpData['totalhour']);
- totalTime.html(totalTimeStr);
-
- //前
- var bookInfo=httpData['bookInfo'];
- var front=$("#front");
- var tttHTML=$('#tr_one').prop('outerHTML');
- var newHTML=''
- for(var i=0;i<bookInfo.length;i++){
- var tempDict=bookInfo[i];
- var tempHTML=tttHTML;
- tempHTML=tempHTML.replace('[入住日期]',tempDict['startTime']);
- tempHTML=tempHTML.replace('[库存]',tempDict['stock']);
- tempHTML=tempHTML.replace('[N间]',tempDict['bedCount']);
- tempHTML=tempHTML.replace('[m元]',tempDict['buyPrice']);
- tempHTML=tempHTML.replace('[n元]',tempDict['endPrice']);
- tempHTML=tempHTML.replace('[零售价]',tempDict['salePrice']);
- tempHTML=tempHTML.replace('[采购价金额]',tempDict['buy']);
- tempHTML=tempHTML.replace('[结算价金额]',tempDict['end']);
- tempHTML=tempHTML.replace('[销售利润]',tempDict['profit']);
- newHTML+=tempHTML;
- }
- var total = $('#tr_total').prop('outerHTML');
- total = total.replace('[总采购价金额]',httpData['bookTotalBuy']);
- total = total.replace('[总结算价金额]',httpData['bookTotalEnd']);
- total = total.replace('[总销售利润]',httpData['bookTotalProfit']);
- newHTML+=total;
- front.html(newHTML);
-
- // 后
- var bookInfoChange=httpData['bookInfochange'];
- var after=$("#after");
- http_data_length=bookInfoChange.length;
- var tttHTML=$('#tr_two').prop('outerHTML');
- var newHTML2=''
- for(var i=0;i<bookInfoChange.length;i++){
- var tempDict=bookInfoChange[i];
- var tempHTML=tttHTML;
- tempHTML=tempHTML.replace('tr_one','tr_one_'+i);
- tempHTML=tempHTML.replace('select_room','select_room_'+i);
- tempHTML=tempHTML.replace('[cai_blur]',i);
- tempHTML=tempHTML.replace('[jie_blur]',i);
- tempHTML=tempHTML.replace('[index]',i);
- tempHTML=tempHTML.replace('[cai1]',i);
- tempHTML=tempHTML.replace('[jie1]',i);
- tempHTML=tempHTML.replace('[cai2]',i);
- tempHTML=tempHTML.replace('[jie2]',i);
- tempHTML=tempHTML.replace('[lirun]',i);
-
-
- tempHTML=tempHTML.replace('[入住日期]',tempDict['startTimechange']);
- tempHTML=tempHTML.replace('[库存]',tempDict['stockchange']);
- tempHTML=tempHTML.replace('[零售价]',tempDict['salePricechange']);
- tempHTML=tempHTML.replace('[采购价金额]',tempDict['buychange']);
- tempHTML=tempHTML.replace('[结算价金额]',tempDict['endchange']);
- tempHTML=tempHTML.replace('[销售利润]',tempDict['profitchange']);
- newHTML2+=tempHTML;
- }
-
- //
- // var totalchange = $('#totalchange').prop('outerHTML');
- // totalchange = totalchange.replace('[总采购价金额]',httpData['bookTotalBuy']);
- // totalchangeotal = totalchange.replace('[总结算价金额]',httpData['bookTotalEnd']);
- // totalchange = totalchange.replace('[总销售利润]',httpData['bookTotalProfit']);
- // newHTML2+=totalchange;
- for (var i=0;i<bookInfoChange.length;i++) {
- var tempDict=bookInfoChange[i];
- update_show(i,1,tempDict['buychange'],tempDict['endchange'])
- // alert(tempDict['cai_price_balance']);
- }
- // newHTML2+=tr_finalStr;
- tr_finalStr=$('#totalchange').prop('outerHTML');
- after.html(newHTML2);
-
-
-
- //加载之后第一次计算
- var all_cai=0;
- var all_jie=0;
- var all_profits=0;//利润
- for (var i=0;i<bookInfoChange.length;i++) {
- var tempDict=bookInfoChange[i];
- update_show(i,1,tempDict['buychange'],tempDict['endchange']);
- all_cai+=parseInt(tempDict['buychange']);
- all_jie+=parseInt(tempDict['endchange']);
- all_profits+=all_jie-all_cai;
- }
- //计算完了再加载 总计的HTML
- var all_HTML=$('#after').html();
-
- var tempHTML=tr_finalStr;
- tempHTML=tempHTML.replace('[总采购价金额]',all_cai);
- tempHTML=tempHTML.replace('[总结算价金额]',all_jie);
- tempHTML=tempHTML.replace('[总销售利润]',all_profits);
- all_HTML+=tempHTML;
-
- $('#after').html(all_HTML);
- }
- window.onload=function (){
- get_virtual_user_list('./json/changeOrderJson.html');
- }
-
- /*======================网络请求的Ajax的代码=======================*/
-
- // 创建一个Ajax对象
- if (window.ActiveXObject){
- var myreq = new ActiveXObject("Microsoft.XMLHTTP");
- }else{
- var myreq = new XMLHttpRequest();
- }
- // 请求方法,传入URL
- function get_virtual_user_list(myURL)
- {
- myreq.open("get",myURL,true);
-
- // 接收的数据交给哪个函数处理
- myreq.onreadystatechange = show_user_list;
- myreq.send();
- }
- function show_user_list()
- {
-
- if (myreq.readyState == 4)
- {
- // newstr 就是接收到的数据
- var newstr = myreq.responseText;
- var httpData=JSON.parse(newstr);
- reload_Info(httpData);
- }
- }
-
- //选择房间数
- function select_room(index,count){
- //拿到采购价和结算价
- var cai_price=$('#cai_price_'+index).val();
- var jie_price=$('#jie_price_'+index).val();
- //计算
- update_show(index,count,cai_price,jie_price);
- //总计
- all_total_show()
- }
- //采购价value发生改变
- function cai_change(index,value){
- //拿到房间数
- var rooms=$('#select_room_'+index).find("option:selected").val();
- //拿到结算价
- var jie_price=$('#jie_price_'+index).val();
- //计算
- update_show(index,rooms,value,jie_price);
- //总计
- all_total_show();
- }
- //结算价value发生改变
- function jie_change(index,value){
- if (value.trim().length<=0) {
- value=0;
- }
- //拿到房间数
- var rooms=$('#select_room_'+index).find("option:selected").val();
- //拿到采购价
- var cai_price=$('#cai_price_'+index).val();
- //计算
- update_show(index,rooms,cai_price,value);
- //总计
- all_total_show();
- }
- //计算和显示
- function update_show(index,room_count,cai_price,jie_price){
- //计算
- var all_cai=cai_price*room_count;
- var all_jie=jie_price*room_count;
- //改变页面
- //利润
- var profits=all_jie-all_cai;
- //改变页面的效果
- $('#cai_price_balance_'+index).html(all_cai);
- $('#jie_price_balance_'+index).html(all_jie);
- $('#profits_'+index).html(profits);
- }
- //总计
- function all_total_show(){
- var all_cai=0;
- var all_jie=0;
- var all_profits=0;//利润
- for (var i=0;i<http_data_length;i++) {
- var cai=$('#cai_price_balance_'+i).html();
- var jie=$('#jie_price_balance_'+i).html();
- var profits=$('#profits_'+i).html();
- all_cai+=parseInt(cai);
- all_jie+=parseInt(jie);
- all_profits=all_jie-all_cai;
- }
- var all_HTML=$('#totalchange').html();
- var tempHTML=tr_finalStr;
- var profits=all_jie-all_cai;
- tempHTML=tempHTML.replace('[总采购价金额]',all_cai);
- tempHTML=tempHTML.replace('[总结算价金额]',all_jie);
- tempHTML=tempHTML.replace('[总销售利润]',all_profits);
- all_HTML+=tempHTML;
- $('#totalchange').html(all_HTML);
- }
-
- //居中显示
- var tempDiv=null;
- function center_show(show_div){
- tempDiv=show_div;
- //显示蒙板
- show_div.css('display','block');
- show_div.css('z-index',10);
- show_div.css('background-color','white');
- show_div.css('position','fixed');
-
- var w=show_div.css('width');
- var h=show_div.css('height');
- w=w.substr(0,w.length-2);
- h=h.substr(0,h.length-2);
-
- // var s_left=(window.screen.availWidth-w)/2 +"px";
- // var s_top=(window.screen.availHeight-h)/2 +'px';
- var s_left=(window.innerWidth-w)/2+'px';
- var s_top=(window.innerHeight-h)/2+'px';
- show_div.css('left',s_left);
- show_div.css('top',s_top);
- $('.mask').css('display','block');
-
- }
- //点击蒙板
- function hide_all(){
- $('.mask').css('display','none');
- tempDiv.css('display','none');
- }
-
- //点击了三个固定的
- function click_show_div(objName){
- var obj=$(objName);
- if (obj.css('display')=='none') {
- center_show(obj);
- }else{
- obj.css('display','none');
- }
- }
- //点击了第二级
- function click_two_show_div(father_name,self_name){
- var father=$(father_name);
- var self=$(self_name);
- father.css('display','none');
- center_show(self);
- }
- //点击了关闭
- function click_cancel(father_name,self_name){
- if (father_name) {
- var father=$(father_name);
- center_show(father);
- }else{
- $('.mask').css('display','none');
- }
- $(self_name).css('display','none');
- }
|