|
- //补单
- var first_load=1;
- var line_id = 450894;
- var run_date = getDateTime(0);
- var urlstr = base_api + 'orderManager/index.php';
- var listHTML = ''
- var newstr = base_api + 'index.php';
- var order_id = '';
- var old_data = [];
-
-
- var last_supplier_id='';
- window.onload = function () {
- $('#Wdate2').val(run_date);
- listHTML = $('#list').html();
- //修改订单时,先通过order_id获取run_date和line_id
- console.log(first_load);
- //###针对补单载入线路列表并默认选中第一个线路###//
- $.ajax({
- url: newstr,
- data: {
- tp: 'order_groupOrder_getGroupLine',
- },
- type: "post",
- dataType: "json",
- async: false,
- success: function (data) {
- if (data.code == "0") {
- line_id = data.list[1]['line_id'];
-
-
-
- $('#hotel').val(data.list[0]['tavern_stay']);
- $('#substitute_add').val(data.list[0]['add_line_price']);
- var sel_text = data.list[0]['terrace'];
- $(".if_online").find('option[text='+sel_text+']').attr("selected",true);
- replaceLineInfo(data);
- loadCar();
- } else {
- ZZAlertInfo(data.info);
- }
- },
- error: function (e) {
- ZZLog(e);
- }
- });
- //###//
-
- reloadData();//根据line_id,run_date载入渠道票种信息
- //载入时如果是修改订单,则重置订单值
- if (order_id != '') {
- initEditData();
- }
- //这里给上车站点的空间生成input加一个onblur事件
- $('.start_sta input').blur(function () {
- reset_sta()
- });
- }
- //combo-select(bug)插件如果输入项没有对应值,则将显示值设置为厦门未知酒店
- function reset_sta() {
- if ($("#start_area").val() == '11964') {
- var name = $("#start_area").find("option[value='11964']").text();
- $('.start_sta input:eq(0)').val(name);
- }
- }
- //选择日期
- function selectDate() {
- run_date = $('#Wdate2').val();
- first_load=first_load-1;
- console.log(first_load);
- loadCar();
- // reloadData();
- }
- //刷新车次日期
- function refreshDate() {
- $('#theday').text(run_date);
- $('#nextday').text(after(run_date));
- }
- //根据line_id,run_date得到车次信息(包括一日游,两个车;双日游三个车)
- function loadCar() {
- refreshDate();
- var data = {
- tp: 'order_groupOrder_getDayCar',
- run_date: run_date,
- line_id: line_id
- };
- ZZLog(data);
- $.ajax({
- url: newstr,
- data: data,
- type: "post",
- dataType: "json",
- async: false,
- success: function (data) {
- if (data.code == "0") {
- console.log(data);
- replaceCar(data.list);
- } else {
- ZZAlertInfo(data.info);
- run_date = $('#Wdate2').val();
- }
- },
- error: function (e) {
- ZZLog(e);
- }
- });
- }
- //替换车次信息选项
- function replaceCar(data) {
- var bus11=data.bus11;
- var bus12=data.bus12;
- var bus22=data.bus22;
- //console.log(bus22);
- //处理run_id
- if(bus22.length!=0){
- $('#bus2').show();
- $('#bus22_run_id').val(bus22[0]['run_id']);
- $('#bus22_run_date').val(bus22[0]['run_date']);
- }else{
- $('#bus2').hide();
- $('#bus22_run_id').val(0);
- $('#bus22_run_date').val(0);
- }
- if(bus11.length!=0){
- $('#bus11_run_id').val(bus11[0]['run_id']);
- $('#bus11_run_date').val(bus11[0]['run_date']);
- }else{
- $('#bus11_run_id').val(0);
- $('#bus11_run_date').val(0);
- }
- if(bus12.length!=0){
- $('#bus12_run_id').val(bus12[0]['run_id']);
- $('#bus12_run_date').val(bus12[0]['run_date']);
- }else{
- $('#bus12_run_id').val(0);
- $('#bus12_run_date').val(0);
- }
- //处理有数据的列表信息
- //当日接驳
- var temp11 = '<option value="0">若无接驳段请勿选择</option>';
- for(var i = 0, j = bus11.length; i < j; i++) {
- temp11 += '<option value="' + bus11[i].run_bus_id + '">' +bus11[i].run_bus_id+' | '+ bus11[i].send_bus_no +' | 司机:'+bus11[i].send_driver_name+' | 导游:'+bus11[i].send_tour_guide_name+ '</option>';
- }
- //当日直通
- var temp12 = '<option value="0">请选择</option>';
- for(var i = 0, j = bus12.length; i < j; i++) {
- temp12 += '<option value="' + bus12[i].run_bus_id + '">' +bus12[i].run_bus_id+' | '+ bus12[i].send_bus_no +' | 司机:'+bus12[i].send_driver_name+' | 导游:'+bus12[i].send_tour_guide_name+ '</option>';
- }
- //次日直通
- var temp22 = '<option value="0">请选择</option>';
- for(var i = 0, j = bus22.length; i < j; i++) {
- temp22 += '<option value="' + bus22[i].run_bus_id + '">' +bus22[i].run_bus_id+' | '+ bus22[i].send_bus_no +' | 司机:'+bus22[i].send_driver_name+' | 导游:'+bus22[i].send_tour_guide_name+ '</option>';
- }
- //alert(temp11);
- $("#bus11").html(temp11);
- $("#bus12").html(temp12);
- $("#bus22").html(temp22);
- }
- //页面加载数据
- function reloadData() {
- var data = {
- tp: 'groupOrder_getProductBase',
- run_date: run_date,
- line_id: line_id
- };
- ZZLog(data);
-
- $.ajax({
- url: urlstr,
- data: data,
- type: "post",
- dataType: "json",
- async: false,
- success: function (data) {
- if (data.code == "0") {
- console.log(data);
- replaceData(data);
- } else {
- ZZAlertInfo(data.info,function(){
- console.log(first_load);
- if(first_load<0){
- run_date = getDateTime(0);
- window.location.reload();
- }
-
- });
- //run_date = $('#Wdate2').val();
-
- }
- /*if (order_id != ''){
- initEditData();
- }*/
-
-
- },
- error: function (e) {
- ZZLog(e);
- }
- });
- }
-
- //数据展示
- function replaceData(data) {
- //修改线路列表
- //changeLine();
-
- $('#line_code').html(data.line_name);
- var startHTML = '';
- var start_station = data.start_station;
- for (var i = 0; i < start_station.length; i++) {
- var tempHTML1 = '<option seq_id="[seq_id]" start_time="[start_time]" value="0">请选择</option>';
- tempHTML1 = tempHTML1.replace('请选择', start_station[i].res_name);
- tempHTML1 = tempHTML1.replace('0', start_station[i].res_id);
- tempHTML1 = tempHTML1.replace('[seq_id]', start_station[i].seq_id);
- tempHTML1 = tempHTML1.replace('[start_time]', start_station[i].start_time);
- startHTML += tempHTML1;
- }
- $('#start_area').html(startHTML);
- //如果始发站点 有 名为‘厦门未知酒店’的站点,则默认选中
- $('#start_area').comboSelect();
- $("#start_area").find("option[value='11964']").attr("selected", true);
-
- var channelHTML = '';
- var channel_list = data.channel_list;
- for (var j = 0; j < channel_list.length; j++) {
- var tempHTML = '<option saleman="[saleman]" value="0">请选择</option>';
- tempHTML = tempHTML.replace('请选择', channel_list[j].supplier_name);
- tempHTML = tempHTML.replace('0', channel_list[j].supplier_id);
- tempHTML = tempHTML.replace('[saleman]', channel_list[j].sales_man);
- $('#salesman').html(channel_list[0].sales_man);
- channelHTML += tempHTML;
- }
- $('#channel_list').html(channelHTML);
- $('.select_line').comboSelect();
-
- var value = $('#channel_list').val();
- changeChannelSelected(value);
-
- }
-
-
- //替换线路的相关信息
- function replaceLineInfo(data) {
- var productHTML = '';
- var product_list = data.list;
- console.log(data.list);
-
- for (var i = 0; i < product_list.length; i++) {
- var tempHTML1 = '<option value="0">请选择</option>';
- tempHTML1 = tempHTML1.replace('请选择', product_list[i].line_name);
- tempHTML1 = tempHTML1.replace('0', product_list[i].line_id);
- productHTML += tempHTML1;
- }
- $('#line_info').html(productHTML);
- $('.select_line').comboSelect();
-
- // $("#line_info option[value='"+line_id+"']").attr("select","selected");
- $("#line_info").find("option[value='" + line_id + "']").attr("selected", true);
- }
-
-
-
-
- //切换渠道
- function changeChannelSelected(value) {
- var saleman = $("#channel_list").find("option:selected").attr('saleman');
-
- console.log(saleman);
- $('#salesman').val(saleman);
-
- var data = {
- tp: 'groupOrder_getTicketType',
- line_id: line_id,
- channel_id: value
- };
- ZZLog(data);
- $.ajax({
- url: urlstr,
- data: data,
- type: "post",
- dataType: "json",
- async: false,
- success: function (data) {
- if (data.code == "0") {
- console.log(data);
- showTicketInfo(data);
- } else {
- ZZAlertInfo(data.info);
- }
- },
- error: function (e) {
- ZZLog(e);
- }
- });
- }
-
- //展示票种信息
- function showTicketInfo(data) {
- var list = data.list;
- var newHTML = '';
- var sin_price_arr=new Array();
- var count_arr=new Array();
- for (var i = 0; i < list.length; i++) {
- var tempHTML = listHTML;
- sin_price_arr[i]=$('.sin_price').eq(i).val();
- count_arr[i]=$('.count').eq(i).val();
- tempHTML = tempHTML.replace('[座位等级]', list[i].seat_type_name);
- tempHTML = tempHTML.replace('[人群]', list[i].human_type_name);
- tempHTML = tempHTML.replace('[价格]', list[i].price);
- tempHTML = tempHTML.replace('[ticket_id]', list[i].ticket_id);
- // 数量
- var stock = 1000;
- var maxCount = stock > 55 ? 55 : stock;
- maxCount = maxCount > 0 ? maxCount : 0;
- var newHTML1 = '';
- for (var j = 0; j <= maxCount; j++) {
- var str = '<option value="[0]">[-]</option> ';
- str = str.replace('[0]', j);
- str = str.replace('[-]', j);
- newHTML1 += str;
- }
- tempHTML = tempHTML.replace('<option value="[0]">[-]</option>', newHTML1);
- tempHTML = tempHTML.replace('[总额]', '0');
- newHTML += tempHTML;
- }
- $('#list').html(newHTML);
- $('#list').show();
- for(var i =0;i<sin_price_arr.length;i++){
- $('.sin_price').eq(i).val(sin_price_arr[i]);
- $('.count').eq(i).val(count_arr[i]);
- if($('.sin_price').eq(i).val()==''){
- $('.sin_price').eq(i).val(0);
- }
- if( $('.count').eq(i).val()==''){
- $('.count').eq(i).val(0);
- }
- }
- for(var i =0;i<sin_price_arr.length;i++){
- changeTotalPrice($('.count').eq(i));
- }
- }
-
- //切换票种数量,更改价格
- function changeTotalPrice(obj) {
- // var single_price = $(obj).parent().parent().find('.price').val();
- // var total_price = parseInt($(obj).val()) * parseInt(single_price);
- // $(obj).parent().parent().find('.total_price').html(total_price);
- var single_price = $(obj).parent().parent().find('.price').val();
- var count= $(obj).parent().parent().find('.count').val();
- var total_price = parseInt(single_price)*count;
- $(obj).parent().parent().find('.total_price').html(total_price);
- }
-
- //保存按钮
- function basicInfoSave() {
- //出发日期
- var start_date = $('#Wdate2').val();
- var start_area = $('#start_area').val();
- if (!start_date || !start_area) {
- ZZAlertInfo('出发日期填写不完整!');
- return;
- }
- //订单渠道
- var order_channel = $('#channel_list').val();
- var channel_id = $('#channel_id').val();
- if (!order_channel) {
- ZZAlertInfo('订单渠道填写不完整!');
- return;
- }
- //数量
- var count_str = '';
- var rec_str = '';
- var count_num = 0;
- $('.list_info').each(function (index, dom) {
- var ticket_id = $(this).attr('id');
- var price = $(this).children().find('.price').val();
- var sin_price = $(this).children().find('.sin_price').val();
- if (!sin_price) {
- sin_price = 0
- }
- var count = $(this).children().find('.count').val();
- count_num += parseInt(count);
- if (count > 0) {
- var str = '{' + ticket_id + ',' + price + ',' + count + '}';
- count_str += str;
- var str2 = ticket_id + ',' + sin_price;
- rec_str += str2 + '|';
- } else {
- return;
- }
- })
- if (count_str == '') {
- ZZAlertInfo('请完善订单信息,并选择数量!');
- return;
- }
-
- //联系人
- var link_man = $('#name').val().trim();
- var link_tel = $('#tel').val().trim();
- var remarks = $('#remarks').val();
-
- //如果联系人或者备注中有半角逗号,替换为全角
- link_man = link_man.replace(/,/g, ",");
- remarks = remarks.replace(/,/g, ",");
- if (!link_man && !link_tel) {
- ZZAlertInfo('联系人信息输入不完整!');
- return;
- }
- if (link_tel != '' ) {
- return;
- }
- var link_info = '{' + link_man + ',' + link_tel + ',' + remarks + '}';
- //业务员
- var salesman = $('#salesman').val();
- //代收
- /*var substitute = $('#substitute').val();
- // substitute = substitute== " " ? '0' : substitute;
- if (substitute == '') {
- var substitute_all = $('#substitute_all').val();
- if (substitute_all == '') {
- substitute = '0';
- }else{
- substitute = substitute_all;
- }
- }else {
- substitute = substitute * count_num;
- }*/
- var if_sin = 0;//如果为0表示代收单价没有填写,如果非0,则表示代收总价
- var terrace = $('#if_online').text();
- var tavern_stay = $('#hotel').val();
- var add_line_price = $('#substitute_add').val();
-
- var if_sin = 0;//如果为0表示代收单价没有填写,如果非0,则表示代收总价
- $('.sin_price').each(function () {
- var tmp = $(this).val();
- if (tmp) {
- var snum = $(this).parent().parent().find('.count').val();
- if_sin += parseInt(tmp) * parseInt(snum);
- }
- })
- //总价计算规则改变--2017-01-20 娄梦宁
- var receive_value = $('#total_collection').val();
- // var receive_value = 0;
- // var substitute_all = $('#substitute_all').val();
- // //得到总价(如果没写任何单价[或者代收单价累计计算值为0]),则取代收总价栏的数值,否则取代收单价计算得到代收总价)
- // if (!if_sin) {
- // receive_value = substitute_all ? parseInt(substitute_all) : 0;
- // } else {
- // receive_value = if_sin;
- // }
-
- //####得到车次信息(3个)
- var bus11_run_id=$('#bus11_run_id').val();
- var bus12_run_id=$('#bus12_run_id').val();
- var bus22_run_id=$('#bus22_run_id').val();
- var car11={run_id:bus11_run_id,run_bus_id:$('#bus11').val(),run_date:$('#bus11_run_date').val()};
- var car12={run_id:bus12_run_id,run_bus_id:$('#bus12').val(),run_date:$('#bus12_run_date').val()};
- var car22={run_id:bus22_run_id,run_bus_id:$('#bus22').val(),run_date:$('#bus22_run_date').val()};
- var car_info=[car11,car12,car22];
- /* console.log(car_info);
- return;*/
- //####车次信息结束
- //站点信息 order_groupOrder_groupProductList
- var seq_id = $("#start_area").find("option:selected").attr('seq_id');
- var start_time = $("#start_area").find("option:selected").attr('start_time');
- var tp = order_id != '' ? 'order_groupOrder_updateGroupOrder' : 'order_groupOrder_addExtraOrder';
- var data = {
- tp: tp,
- line_id: line_id,
- car_info:car_info, //车次信息
- count_num:count_num,
- org_id: order_channel,
- order_id: order_id,
- order_no: channel_id,
- salesman: salesman,
- start_date: start_date,
- start_station: start_area,
- prod_list: count_str,
- rec_list: rec_str, //代收单价列表
- customer_info: link_info,
- receive_value: receive_value,
- seq_id: seq_id,
- start_time: start_time,
- terrace : terrace,
- tavern_stay : tavern_stay,
- add_line_price : add_line_price
- };
- ZZLog(data);
- $.ajax({
- url: newstr,
- data: data,
- type: "post",
- dataType: "json",
- async: false,
- success: function (data) {
- if (data.code == "0") {
- ZZLog(data);
- ZZAlertInfo(data.info,function(){
- if (order_id == '')
- //window.location.href = "select_product.html";
- window.location.reload();
- else {
- window.location.href = "order_list.html";
- }
- });
- /*setTimeout(function () {
- if (order_id == '')
- //window.location.href = "select_product.html";
- window.location.reload();
- else {
- window.location.href = "order_list.html";
- }
- }, 3000)*/
- } else {
- ZZAlertInfo(data.info);
- }
- },
- error: function (e) {
- ZZLog(e);
- }
- });
-
-
- }
-
-
- //切换线路
- function changeLineInfo(obj) {
- var ttt = $(obj).val();
- line_id = ttt;
- first_load=first_load-1;
- loadCar();
- var data = {
- tp: 'groupOrder_getProductBase',
- run_date: run_date,
- line_id: line_id
- };
- ZZLog(data);
-
- $.ajax({
- url: urlstr,
- data: data,
- type: "post",
- dataType: "json",
- async: false,
- success: function (data) {
- if (data.code == "0") {
- console.log(data);
- replace1Data(data);
- } else {
- ZZAlertInfo(data.info, function () {
- console.log(first_load);
- window.location.reload();
- });
-
- }
- },
- error: function (e) {
- ZZLog(e);
- }
- });
- }
-
- //修改线路数据展示
- function replace1Data(data) {
- //修改线路列表
- var value=$('#channel_list').val();
- for(var item in data.channel_list){
- if(data.channel_list[item].supplier_id==$('#channel_list').val()){
- var new_supplier_id=data.channel_list[item].supplier_id;
- break;
- }
- }
- if(typeof new_supplier_id === 'undefined'){
- ZZConfirm('此线路无当前渠道信息,是否确认修改?', function (ok) {
- //修改线路列表
- // changeLine();
- $('#line_code').html(data.line_name);
- var startHTML = '';
- var start_station = data.start_station;
- for (var i = 0; i < start_station.length; i++) {
- var tempHTML1 = '<option seq_id="[seq_id]" start_time="[start_time]" value="0">请选择</option>';
- tempHTML1 = tempHTML1.replace('请选择', start_station[i].res_name);
- tempHTML1 = tempHTML1.replace('0', start_station[i].res_id);
- tempHTML1 = tempHTML1.replace('[seq_id]', start_station[i].seq_id);
- tempHTML1 = tempHTML1.replace('[start_time]', start_station[i].start_time);
- startHTML += tempHTML1;
- }
- $('#start_area').html(startHTML);
- //如果始发站点 有 名为‘厦门未知酒店’的站点,则默认选中
- $('#start_area').comboSelect();
- $("#start_area").find("option[value='11964']").attr("selected", true);
- var new_supplier_id = data.channel_list[0].supplier_id;
- supplier_id=new_supplier_id;
- var channelHTML = '';
- var channel_list = data.channel_list;
- for (var j = 0; j < channel_list.length; j++) {
- var tempHTML = '<option saleman="[saleman]" value="0">请选择</option>';
- tempHTML = tempHTML.replace('请选择', channel_list[j].supplier_name);
- tempHTML = tempHTML.replace('0', channel_list[j].supplier_id);
- tempHTML = tempHTML.replace('[saleman]', channel_list[j].sales_man);
- $('#salesman').html(channel_list[0].sales_man);
- channelHTML += tempHTML;
- }
- $('#channel_list').html(channelHTML);
- $('.select_line').comboSelect();
- value = $('#channel_list').val();
- last_supplier_id = value;
- }, function (cancel) {
- value = last_supplier_id;
- }, function (close) {
- })
- }
- changeChannelSelected(value);
-
- }
-
-
-
-
- //如果是修改订单,对表单赋值
- function initEditData() {
- $("#Wdate2").val(old_data['PROD_START_STATION_DATE']);
- $("#start_area").val(old_data['PROD_START_STATION_RES_ID']).comboSelect();
- $("#channel_list").val(old_data['SUPPLIER_ID']).comboSelect();
- //没有触发 changeChannelSelected函数
- changeChannelSelected(old_data['SUPPLIER_ID']);
- var count_num = 0;
- $.each(old_data['ticket_info'], function (k, item) {
- $("#" + item['ticket_id'] + " .count").val(item['num']);
- $("#" + item['ticket_id'] + " .sin_price").val(item['sin_price']);
- var total_amount = item['num'] * $("#" + item['ticket_id'] + " .count").parent().prev('td').find('.price').val();
- $("#" + item['ticket_id'] + " .count").parent().next('.total_price').html(total_amount);
- count_num += parseInt(item['num']);
- });
- $("#channel_id").val(old_data['OUTSIDE_ORDER_NO']);
-
- $("#substitute_all").val(old_data['RECEIVE_VALUE']);
- /*if(count_num > 0)
- $("#substitute").val(parseInt(old_data['RECEIVE_VALUE']) / count_num);*/
- $("#name").val(old_data['customer_name']);
- $("#tel").val(old_data['customer_mobile']);
- $("#salesman").val(old_data['sales_man']);
- $("#remarks").val(old_data['customer_memo']);
-
- }
- //手机号验证取消,后台判断,当手机号,日期,线路一致时返回提示错误信息---娄梦宁2017-01-20
- //当手机输入框手机号码输完即时判断
- // $("#tel").bind('input propertychange', function () {
- //
- // var tel = $('#tel').val().trim();
- // if (tel.length == 11) {
- // $.ajax({
- // url: base_api + 'index.php', //请求地址
- // data: {
- // tp: "order_groupOrder_getPurchaseHistory",
- // tel: tel
- // },
- // type: "post",
- // dataType: "json",
- // success: function (data) {
- // console.log(data);
- // if (data.code == "0") {
- // $('#attention').text('提示:该电话号码今日已有下单记录!');
- // $('#attention').show();
- // return;
- // } else {
- // // $('#attention').text('提示:该电话号码今日已有下单记录!');
- // $('#attention').hide();
- // }
- //
- // }
- // });
- //
- // } else {
- // $('#attention').hide();
- // }
- // })
-
-
- //代收总价计算
- function total_collection(){
- var total_collection_price=0;
- var count=$('.sin_price').length;
- for(i=0;i<count;i++ ){
- if(isNaN(Number($('.sin_price').eq(i).val()))){
- total_collection_price+=0;
- }else{
- total_collection_price+=Number($('.sin_price').eq(i).val());
- }
- }
- if(isNaN(Number($('#substitute_add').val()))){
- total_collection_price+=0;
- }else{
- total_collection_price+=Number($('#substitute_add').val());
- }
- $('#total_collection').val(total_collection_price);
- }
|