//author:zhaojian
//date:20161030
//组合线路的调度
var dispatch_status = ''; //调度状态
var current_page = 1; //当前页
var page_size = 6; //每页个数
var start_area = ''; //出发地
var end_area = ''; //目的地
var start_date = ''; //开始时间
var end_date = ''; //结束时间
var bus_type = '0'; //0单一全部 255直通 256穿梭 316组合
var line_group = '0'; //线路组合
var line = ''; //线路
var sort_id = 0; // 排序
var trHTML = ''; //待替换的HTML
var sale_people_count = '0'; //列表中的已售人数
var run_bus_id = ''; //run_bus中的唯一id
var product_type = "" //产品线
var t_time = "08:00";
$(document).ready(function () {
$('#tbodySingle').show();
trHTML = $('#tbodySingle').html();
$('#tbodySingle').html('');
start_date = $('#start_date').val().trim();
$('#tbodyGroup').show();
$('#tbodyGroup').html('');
start_date = $('#start_date').val().trim();
$('#start_date').val(getDateTime(0));
$('#end_date').val(getDateTime(11));
base_info();
//加载公司
loadCompany();
});
//今天
function today() {
$('#start_date').val(getDateTime(0));
$('#end_date').val(getDateTime(0));
start_date = getDateTime(0);
end_date = getDateTime(0);
httpFirstData();
}
//明天
function tomorrow() {
$('#start_date').val(getDateTime(11));
$('#end_date').val(getDateTime(11));
start_date = getDateTime(11);
end_date = getDateTime(11);
httpFirstData();
}
//查询
function searchBtnDidClicked() {
httpFirstData();
//头部产品线列表
product_line();
}
//车辆事件
function addCarEvent() {
$('.td_car_input').bind('input', function () {
ZZLog('carEvent click');
})
$('.td_car_input').bind('click', function () {
var jsonstr = $(this).closest('tr').attr('data-param');
var datajson = getJsonHtml(jsonstr);
var _saled_count = datajson['order_cnt'];
var _bus_id = datajson['id'];
var _run_id = $(this).closest('tr').find('.run_id').val();
var tbody = $(this).closest('tbody').attr('id');
var _run_id2;
if (tbody == 'tbodyGroup')
_run_id2 = $("#tbodySingle .run_id:first").val();
else
_run_id2 = 0;
//检索车俩时需要已售人数
sale_people_count = _saled_count;
//派遣时需要的run_bus_id
run_bus_id = _bus_id;
var _obj = $('.right_list_top[dataStr="vehicle"]');
carDriverGuide(_obj); //车辆-司机-导游切换
loadVehicleList(_run_id, _run_id2); //加载车辆
})
}
//司机事件
function addDriveEvent() {
$('.td_driver_input').bind('input', function () {
ZZLog('driverEvent');
})
$('.td_driver_input').bind('click', function () {
ZZLog('driverEvent click');
var jsonstr = $(this).closest('tr').attr('data-param');
var datajson = getJsonHtml(jsonstr);
var _saled_count = datajson['order_cnt'];
var _bus_id = datajson['id'];
var _run_id = $(this).closest('tr').find('.run_id').val();
var tbody = $(this).closest('tbody').attr('id');
var _run_id2;
if (tbody == 'tbodyGroup')
_run_id2 = $("#tbodySingle .run_id:first").val();
else
_run_id2 = 0;
//检索车俩时需要已售人数
sale_people_count = _saled_count;
//派遣时需要的run_bus_id
run_bus_id = _bus_id;
var _obj = $('.right_list_top[dataStr="driver"]');
carDriverGuide(_obj); //车辆-司机-导游切换
loadDriverList(_run_id, _run_id2); //加载车辆
})
}
//导游事件
function addGuideEvent() {
$('.td_guide_input').bind('input', function () {
ZZLog('guideEvent');
})
$('.td_guide_input').bind('click', function () {
ZZLog('guideEvent click');
var jsonstr = $(this).closest('tr').attr('data-param');
var datajson = getJsonHtml(jsonstr);
var _saled_count = datajson['order_cnt'];
var _bus_id = datajson['id'];
var _run_id = $(this).closest('tr').find('.run_id').val();
var tbody = $(this).closest('tbody').attr('id');
var _run_id2;
if (tbody == 'tbodyGroup')
_run_id2 = $("#tbodySingle .run_id:first").val();
else
_run_id2 = 0;
//检索车俩时需要已售人数
sale_people_count = _saled_count;
//派遣时需要的run_bus_id
run_bus_id = _bus_id;
var _obj = $('.right_list_top[dataStr="guide"]');
carDriverGuide(_obj); //车辆-司机-导游切换
loadGuideList(_run_id, _run_id2); //加载车辆
})
}
////可用,弹出调用取消;
//function can_need(index){
// //解决冒泡
// solveBubbing();
//
// $(index).children().eq(3).hide();
// $(index).children().eq(4).show();
//}
/**改变车辆-司机-导游*/
//改变车牌号
function changeVehicle(obj) {
loadVehicleList();
}
//改变车辆公司
function changeVehicleCompany(obj) {
loadVehicleList();
}
//改变司机姓名手机
function changeDriver(obj) {
loadDriverList();
}
//改变司机公司
function changeDriverCompany(obj) {
loadDriverList();
}
//改变导游姓名手机
function changeGuide(obj) {
loadGuideList();
}
//改变导游公司
function changeGuideCompany(obj) {
loadGuideList();
}
//加载公司
function loadCompany() {
var param = {
tp: "singleDispatch_getCompanyList"
}
ZZLog(base_api + "carDispatchManager/index.php" + JSON.stringify(param));
$.ajax({
type: "post",
url: base_api + "carDispatchManager/index.php",
data: param,
dataType: 'json',
success: function (res_data) {
ZZLog(res_data);
if (res_data['code'] != "0") {
ZZAlertInfo(res_data['info']);
} else {
//公司
var comHTML = '';
var company_list = res_data['company_list'];
for (var i = 0, m = company_list.length; i < m; i++) {
var dict = company_list[i];
var tempHTML = ''
comHTML += tempHTML;
}
$('select[name="company"]').html(comHTML);
}
},
error: function (e) {
ZZLog(e);
ZZAlertInfo('php 500');
}
});
}
function base_info() {
var param = {
tp: "carDispatch_groupDispatch_getBaseInfo"
}
ZZLog(base_api + "carDispatchManager/index.php" + JSON.stringify(param));
//请求车次列表数据
$.ajax({
type: "post",
url: base_api + "index.php",
data: param,
dataType: "json",
success: function (data) {
console.log(data);
if (data['code'] != "0") {
ZZAlertInfo(data['info']);
} else {
var base_info_html = '';
for (var i = 0, j = data.base_info.length; i < j; i++) {
base_info_html += '';
}
$("#product_type").html(base_info_html);
//头部产品线列表
product_line();
//第一次加载数据
httpFirstData();
}
},
error: function (e) {
ZZLog(e);
ZZAlertInfo('php 500');
}
});
}
//头部产品线列表
function product_line() {
start_date = $('#start_date').val().trim();
product_type = $("#product_type").val();
var param = {
tp: "carDispatch_groupDispatch_getOrderList",
start_date: start_date,
product_type: product_type
}
ZZLog(base_api + "index.php" + JSON.stringify(param));
//请求车次列表数据
$.ajax({
type: "post",
url: base_api + "index.php",
data: param,
dataType: "json",
success: function (data) {
console.log(data);
if (data['code'] != "0") {
ZZAlertInfo(data['info']);
} else {
productHTML(data);
}
},
error: function (e) {
ZZLog(e);
ZZAlertInfo('php 500');
}
});
};
//替换产品线html
function productHTML(data) {
var product_name_temp = '
总计 | ';
var product_no_temp = '' + data.total_num + ' | ';
var pro_no = "";
for (var i = 0, j = data.list.length; i < j; i++) {
pro_no = data.list[i].num;
if (data.list[i].num == "0") {
pro_no = "";
} else {
pro_no = data.list[i].num;
}
product_name_temp += '' + data.list[i].line_code + ' | '
product_no_temp += '' + pro_no + ' | '
}
$("#product_line_name").html(product_name_temp);
$("#product_line_no").html(product_no_temp);
//修改分车
$(".amend_line").click(function () {
var line_id = $(this).attr("line_id");
var product_type = $('#product_type').val();
var param = {
tp: "carDispatch_groupDispatch_getOrderDetail",
start_date: start_date,
product_id: product_type,
line_id: line_id
}
ZZLog(base_api + "index.php" + JSON.stringify(param));
//请求车次列表数据
$.ajax({
type: "post",
url: base_api + "index.php",
data: param,
dataType: "json",
success: function (data) {
console.log(data);
if (data['code'] != "0") {
ZZAlertInfo(data['info']);
} else {
re_amend_html(data);
}
},
error: function (e) {
ZZLog(e);
ZZAlertInfo('php 500');
}
});
});
}
//替换修改车次列表
function re_amend_html(data, tbody) {
var amend_list_temp = "";
var amend_car_temp = '';
for (var i = 0, j = data.list_order.length; i < j; i++) {
amend_list_temp += ''
+ ' | '
+ '' + data.list_order[i].num + ' | ';
if (data.list_order[i].day == 2)
amend_list_temp += '' + data.list_order[i].line_codes + ' 第二日' + ' | ';
else
amend_list_temp += '' + data.list_order[i].line_codes + ' | ';
amend_list_temp += '' + data.list_order[i].start_station + ' | '
+ '' + data.list_order[i].trans_name + ' | '
+ '' + data.list_order[i].tel + ' | '
+ '' + data.list_order[i].run_bus_id + ' | '
+ '
'
}
for (var i = 0, j = data.list_bus.length; i < j; i++) {
amend_car_temp += ''
}
$("#amend_list").html(amend_list_temp);
$("#amend_car_list").html(amend_car_temp);
if (tbody == 'tbodySingle')
$(".amend_car_bottom").show();
else
$(".amend_car_bottom").show();
$(".alert-block").show();
}
//第一次加载
function httpFirstData() {
var tpSingle, tpGroup;
current_page = 1;
tpSingle = 'carDispatch_groupDispatch_getSingleResult';
tpGroup = 'carDispatch_groupDispatch_getDispatchResult';
httpLoadData(tpSingle, 'tbodySingle');
httpLoadData(tpGroup, 'tbodyGroup');
}
function httpLoadData(tp, tbody) {
start_date = $('#start_date').val().trim();
product_type = $('#product_type').val();
var param = {
tp: tp,
run_date: start_date,
product_id: product_type,
current_page: current_page,
page_size: page_size
}
ZZLog(base_api + "index.php" + JSON.stringify(param));
//请求车次列表数据
$.ajax({
type: "post",
url: base_api + "index.php",
data: param,
dataType: "json",
success: function (res_data) {
ZZLog(res_data);
//加载车辆
loadVehicleList();
//加载司机
loadDriverList();
//加载导游
loadGuideList();
if (res_data['code'] != "0") {
ZZAlertInfo(res_data['info']);
} else {
setTrHTML(res_data, tbody);
initPageDiv(res_data, tbody, tp);
}
$("#travel-1").height('auto');
$("#travel-2").height('auto');
if ($("#travel-1").height() >= 230)
$("#travel-1").height($('#travel-1').height() + 60);
if ($("#travel-2").height() >= 230)
$("#travel-2").height($('#travel-2').height() + 60)
$(".right ul").height($('.left').height() - 101);
},
error: function (e) {
ZZLog(e);
ZZAlertInfo('php 500');
}
});
}
function initPageDiv(res_data, tbody, tp) {
var pageCount = res_data['page']['total_page'];
if (2 <= 0) {
$('#' + tbody + ' .pageDiv').hide();
} else {
$('#' + tbody).closest('table').next().createPage({
pageCount: pageCount, //总页数
current: current_page, //当前页
turndown: 'true', //是否显示跳转框,显示为true,不现实为false,一定记得加上引号...
backFn: function (p) {
current_page = p;
httpLoadData(tp, tbody);
}
});
$('#' + tbody).closest('table').next().show();
}
}
//设置表格HTML
function setTrHTML(res_data, tbody) {
var run_list = res_data['data'];
var HTML = '';
for (var i = 0, m = run_list.length; i < m; i++) {
var dict = run_list[i];
var tempHTML = trHTML;
tempHTML = tempHTML.replace('[data-param]', setJsonHtml(dict));
tempHTML = tempHTML.replace('[name]', dict['run_bus_order_id']);
tempHTML = tempHTML.replace('[序号]', dict['run_bus_order_id']);
tempHTML = tempHTML.replace('[出发日期]', dict['run_date']);
tempHTML = tempHTML.replace('[人数]', dict['order_cnt']);
tempHTML = tempHTML.replace('[组成]', dict['line_code']);
tempHTML = tempHTML.replace('[座位数]', dict['seat_count']);
tempHTML = tempHTML.replace('[余位]', dict['remain_cnt']);
tempHTML = tempHTML.replace('[bus_num]', dict['run_bus_order_id']);
tempHTML = tempHTML.replace('[run_id]', dict['run_id']);
var carcstr = '';
if ("" == dict['send_bus_res_name'].trim()) {
carcstr = '';
} else {
// carcstr = '' + dict['send_bus_res_name'] + '';
carcstr = '';
}
carcstr += '';
tempHTML = tempHTML.replace('[车辆]', carcstr);
var drivercstr = '';
if ("" == dict['send_driver_name'].trim()) {
drivercstr = '';
} else {
// drivercstr = '' + dict['send_bus_driver_res_name'] + '';
drivercstr = '';
}
tempHTML = tempHTML.replace('[司机]', drivercstr);
var guidecstr = '';
if ("" == dict['send_tour_guide_name'].trim()) {
guidecstr = '';
} else {
// guidecstr = '' + dict['send_tour_guide_name'] + '';
guidecstr = '';
}
tempHTML = tempHTML.replace('[导游]', guidecstr);
HTML += tempHTML;
}
$('#' + tbody).html(HTML);
//给车辆 司机 导游绑定事件
addCarEvent();
addDriveEvent();
addGuideEvent();
//修改分车
$('#' + tbody).find(".amend_line2").click(function () {
//$("#amend_button").removeAttr("onclick");
$("#amend_button").attr("onclick","amend_save();");
var tp = '';
var product_type = $('#product_type').val();
if (tbody == 'tbodySingle')
tp = 'carDispatch_getGroupInfo_getTransmsg';
else
tp = 'carDispatch_getGroupInfo_getRunmsg';
var bus_num = $(this).attr("bus_num"),
run_id = $(this).attr("run_id");
var param = {
tp: tp,
run_date: start_date,
product_id: product_type,
run_id: run_id,
bus_num: bus_num
}
ZZLog(base_api + "index.php" + JSON.stringify(param));
//请求车次列表数据
$.ajax({
type: "post",
url: base_api + "index.php",
data: param,
dataType: "json",
success: function (data) {
console.log(data);
if (data['code'] != "0") {
ZZAlertInfo(data['info']);
} else {
re_amend_html(data, tbody);
}
},
error: function (e) {
ZZLog(e);
ZZAlertInfo('php 500');
}
});
});
}
//取消,调用取消;
function dispatchCancel(index) {
//解决冒泡
solveBubbing();
$(index).parent().prev().show();
$(index).parent().hide();
}
//复选框判断
function selectChecked(index) {
//index=0最上面的全选 index=1表示的是下面所有的
var cur_check = $('.ace_check')[0];
var checkList = $('.ace_check');
var checkCount = checkList.length - 1;
var true_count = 0;
for (var i = 1; i < checkList.length; i++) {
if (index == '0') {
checkList[i].checked = cur_check.checked;
} else {
if (checkList[i].checked == false) {
cur_check.checked = false
} else {
true_count = true_count + 1;
}
}
}
//判断下面是否选中完
if (checkCount == true_count) {
cur_check.checked = true;
}
}
//车辆-司机-导游切换
function carDriverGuide(obj) {
$('.right_list_top').each(function (index, domEle) {
$(this).addClass('right_com_line btn-primary');
$(this).removeClass('right_sole_line');
var typestr = $(this).attr('dataStr');
$('#' + typestr).hide();
});
$(obj).addClass('right_sole_line');
$(obj).removeClass('right_com_line btn-primary');
$('#' + $(obj).attr('dataStr')).show();
}
//加载车辆
function loadVehicleList(run_id, run_id2) {
var _keyword = $('input[type="text"][name="vehicle"]').val().trim();
var _company = $('#vehicleCompany').val();
if (typeof run_id == null)
run_id = '';
if (typeof run_id2 == null)
run_id2 = '';
var param = {
tp: 'carDispatch_groupDispatch_getVehicleList',
keyword: _keyword,
company: _company,
salecount: sale_people_count,
run_date: start_date,
run_time: t_time,
run_id1: run_id,
run_id2: run_id2
}
ZZLog(base_api + "index.php" + JSON.stringify(param));
//请求车辆列表
$.ajax({
type: "post",
url: base_api + 'index.php',
data: param,
dataType: "json",
success: function (res_data) {
ZZLog(res_data);
if (res_data['code'] != '0') {
ZZAlertInfo(res_data['info']);
} else {
//车辆
//设置车辆的HTML
setVehicleHTML(res_data);
// 给li绑定事件
setLiBindEvent()
}
},
error: function (e) {
ZZLog(e);
}
});
}
//给li绑定事件
function setLiBindEvent() {
var $temp = null;
$('.statusOK').bind('click', function () {
$(this).parent().find(".status_div_show1").show();
$(this).parent().find(".status_div_hide").hide();
$(this).children().eq(3).hide();
$(this).children().eq(4).show();
})
}
//加载司机
function loadDriverList(run_id, run_id2) {
var _keyword = $('input[type="text"][name="driver"]').val().trim();
var _company = $('#driverCompany').val();
if (typeof run_id == null)
run_id = '';
if (typeof run_id2 == null)
run_id2 = '';
var param = {
tp: 'carDispatch_groupDispatch_getDriverList',
keyword: _keyword,
company: _company,
run_date: start_date,
run_time: t_time,
run_id1: run_id,
run_id2: run_id2
}
ZZLog(base_api + "index.php" + JSON.stringify(param));
//请求车辆列表
$.ajax({
type: "post",
url: base_api + 'index.php',
data: param,
dataType: "json",
success: function (res_data) {
ZZLog(res_data);
if (res_data['code'] != '0') {
ZZAlertInfo(res_data['info']);
} else {
//司机
//设置司机的HTML
setDriverHTML(res_data);
// 给li绑定事件
setLiBindEvent()
}
},
error: function (e) {
ZZLog(e);
}
});
}
//加载导游
function loadGuideList(run_id, run_id2) {
var _keyword = $('input[type="text"][name="guide"]').val().trim();
var _company = $('#guideCompany').val();
if (typeof run_id == null)
run_id = '';
if (typeof run_id2 == null)
run_id2 = '';
var param = {
tp: 'carDispatch_groupDispatch_getGuideList',
keyword: _keyword,
company: _company,
run_date: start_date,
run_time: t_time,
run_id1: run_id,
run_id2: run_id2
}
ZZLog(base_api + "index.php" + JSON.stringify(param));
//请求车辆列表
$.ajax({
type: "post",
url: base_api + 'index.php',
data: param,
dataType: "json",
success: function (res_data) {
ZZLog(res_data);
if (res_data['code'] != '0') {
ZZAlertInfo(res_data['info']);
} else {
//导游
//设置导游的HTML
setGuideHTML(res_data);
// 给li绑定事件
setLiBindEvent()
}
},
error: function (e) {
ZZLog(e);
}
});
}
//设置车辆-司机-导游的HTML
//设置车辆的HTML
function setVehicleHTML(res_data) {
var carHTML = '';
var vehicle_list = res_data['vehicle_list'];
for (var i = 0, m = vehicle_list.length; i < m; i++) {
var dict = vehicle_list[i];
var cstr1 = '';
var cstr2 = '';
if (dict['bus_status'] == '336') {
cstr1 = '可用';
cstr2 = 'statusOK';
} else {
cstr1 = '被用';
cstr2 = 'statusNO';
}
var tempHTML = '' +
'' + dict['vihicle_number'] + '' +
'| ' + dict['vihicle_seat'] + '' +
'| ' + dict['company_name'] + '' +
'' +
cstr1 +
' ' +
'' +
'调用' +
'取消' +
'' +
'';
carHTML += tempHTML;
}
$('#vehicle_list').html(carHTML);
}
//设置司机的HTML
function setDriverHTML(res_data) {
var driverHTML = '';
var driver_list = res_data['driver_list'];
for (var i = 0, m = driver_list.length; i < m; i++) {
var dict = driver_list[i];
var cstr1 = '';
var cstr2 = '';
// if (dict['driver_status'] == '0') {
cstr1 = '可用';
cstr2 = 'statusOK';
// } else {
// cstr1 = '被用';
// cstr2 = 'statusNO';
// }
var tempHTML = '' +
'' + dict['driver_name'] + '' +
'| ' + dict['driver_phone'] + '' +
'| ' + dict['company_name'] + '' +
'' +
cstr1 +
' ' +
'' +
'调用' +
'取消' +
'' +
'';
driverHTML += tempHTML;
}
$('#driver_list').html(driverHTML);
}
//设置导游的HTML
function setGuideHTML(res_data) {
var guideHTML = '';
var guide_list = res_data['guide_list'];
for (var i = 0, m = guide_list.length; i < m; i++) {
var dict = guide_list[i];
var cstr1 = '';
var cstr2 = '';
// if (dict['guide_status'] == '0') {
cstr1 = '可用';
cstr2 = 'statusOK';
// } else {
// cstr1 = '被用';
// cstr2 = 'statusNO';
// }
var tempHTML = '' +
'' + dict['guide_name'] + '' +
'| ' + dict['guide_phone'] + '' +
'| ' + dict['company_name'] + '' +
'' +
cstr1 +
' ' +
'' +
'调用' +
'取消' +
'' +
'';
guideHTML += tempHTML;
}
$('#guide_list').html(guideHTML);
}
/*派遣*/
//重置
function resetDispatch(obj) {
var _idstr = '';
var _idarr = [];
$('.ace_check').each(function (index, domEle) {
if (domEle.checked && index != 0) {
var jsonstr = $(this).closest('tr').attr('data-param');
var datajson = getJsonHtml(jsonstr);
if (typeof datajson != 'undefined' && datajson['id'] != "") {
_idarr.push(datajson['id']);
}
}
})
if (_idarr.length <= 0) {
ZZAlertInfo('请选择');
return;
}
_idstr = _idarr.join(',');
var param = {
tp: 'singleDispatch_resetDispatch',
idstr: _idstr
}
ZZLog(base_api + 'carDispatchManager/index.php' + JSON.stringify(param));
$.ajax({
type: "post",
url: base_api + 'carDispatchManager/index.php',
data: param,
dataType: "json",
success: function (res_data) {
ZZLog(res_data);
if (res_data['code'] != "0") {
ZZAlertInfo(res_data['info'], function () {
$('.ace_check').each(function (index, domEle) {
domEle.checked = false;
})
});
} else {
httpFirstData();
}
}, error: function (e) {
ZZLog(e);
}
});
}
//调用车辆
function dispatchVehicle(obj) {
//解决冒泡
solveBubbing();
var $li = $(obj).closest('li');
var json_str = $li.attr('data-param');
var li_json = getJsonHtml(json_str);
if ("" == run_bus_id.trim()) {
ZZAlertInfo('未选择需派遣线路车辆');
return;
}
var _bus_id = run_bus_id;
var _res_id = li_json['res_id'];
var param = {
tp: 'singleDispatch_vehicleDispatch',
bus_id: _bus_id,
res_id: _res_id
}
ZZLog(base_api + 'carDispatchManager/index.php' + JSON.stringify(param));
loading();
$.ajax({
type: "post",
url: base_api + 'carDispatchManager/index.php',
data: param,
dataType: 'json',
success: function (res_data) {
ZZLog(res_data);
if (res_data['code'] != '0') {
ZZAlertInfo(res_data['info']);
} else {
run_bus_id = ''; //置空run_bus_id
httpFirstData();
}
closeLoading();
}, error: function (e) {
ZZLog(e);
closeLoading();
}
});
dispatchCancel(obj);
}
//派遣司机
function dispatchDriver(obj) {
//解决冒泡
solveBubbing();
var $li = $(obj).closest('li');
var json_str = $li.attr('data-param');
var li_json = getJsonHtml(json_str);
if ("" == run_bus_id.trim()) {
ZZAlertInfo('未选择需派遣线路司机');
return;
}
var _bus_id = run_bus_id;
var _res_id = li_json['res_id'];
var param = {
tp: 'singleDispatch_DriverDispatch',
bus_id: _bus_id,
res_id: _res_id
}
ZZLog(base_api + 'carDispatchManager/index.php' + JSON.stringify(param));
$.ajax({
type: "post",
url: base_api + 'carDispatchManager/index.php',
data: param,
dataType: 'json',
success: function (res_data) {
ZZLog(res_data);
if (res_data['code'] != '0') {
ZZAlertInfo(res_data['info']);
} else {
run_bus_id = ''; //置空run_bus_id
httpFirstData(); //重新加载数据
}
}, error: function (e) {
ZZLog(e);
}
});
dispatchCancel(obj);
}
//派遣导游
function dispatchGuide(obj) {
//解决冒泡
solveBubbing();
var $li = $(obj).closest('li');
var json_str = $li.attr('data-param');
var li_json = getJsonHtml(json_str);
if ("" == run_bus_id.trim()) {
ZZAlertInfo('未选择需派遣线路导游');
return;
}
var _bus_id = run_bus_id;
var _res_id = li_json['res_id'];
var param = {
tp: 'singleDispatch_GuideDispatch',
bus_id: _bus_id,
res_id: _res_id
}
ZZLog(base_api + 'carDispatchManager/index.php' + JSON.stringify(param));
$.ajax({
type: "post",
url: base_api + 'carDispatchManager/index.php',
data: param,
dataType: 'json',
success: function (res_data) {
ZZLog(res_data);
if (res_data['code'] != '0') {
ZZAlertInfo(res_data['info']);
} else {
run_bus_id = ''; //置空run_bus_id
httpFirstData(); //重新加载数据
}
}, error: function (e) {
ZZLog(e);
}
});
dispatchCancel(obj);
}
//取消修改
function cancel_amend() {
solveBubbing();
$(".alert-block").hide();
}
//加车
function add_car() {
start_date = $('#start_date').val().trim();
var param = {
tp: 'carDispatch_groupDispatch_addBus',
run_date: start_date
}
ZZLog(base_api + 'index.php' + JSON.stringify(param));
$.ajax({
type: "post",
url: base_api + 'index.php',
data: param,
dataType: 'json',
success: function (res_data) {
ZZLog(res_data);
if (res_data['code'] != '0') {
ZZAlertInfo(res_data['info']);
} else {
ZZAlertInfo("加车成功", function () {
httpFirstData();
});
}
}, error: function (e) {
ZZLog(e);
}
});
}
//减车
function cut_car() {
var _car_str = '';
var _car_arr = [];
start_date = $('#start_date').val().trim();
$('.ace_check').each(function (index, domEle) {
if (domEle.checked && index != 0) {
var car_id = $(this).attr('name');
_car_arr.push(car_id);
}
})
if (_car_arr.length <= 0) {
ZZAlertInfo('请选择');
return;
}
_car_str = _car_arr.join(',');
var param = {
tp: 'carDispatch_groupDispatch_delBus',
bus_order_id: _car_str,
run_date: start_date
}
ZZLog(base_api + 'index.php' + JSON.stringify(param));
$.ajax({
type: "post",
url: base_api + 'index.php',
data: param,
dataType: 'json',
success: function (res_data) {
ZZLog(res_data);
if (res_data['code'] != '0') {
ZZAlertInfo(res_data['info']);
} else {
ZZAlertInfo("减车成功!", function () {
httpFirstData();
});
}
}, error: function (e) {
ZZLog(e);
}
});
}
//车次复选框判断
function selectChecked(index) {
//index=0最上面的全选 index=1表示的是下面所有的
var cur_check = $('.ace_check')[0];
var checkList = $('.ace_check');
var checkCount = checkList.length - 1;
var true_count = 0;
for (var i = 1; i < checkList.length; i++) {
if (index == '0') {
checkList[i].checked = cur_check.checked;
} else {
if (checkList[i].checked == false) {
cur_check.checked = false
} else {
true_count = true_count + 1;
}
}
}
//判断下面是否选中完
if (checkCount == true_count) {
cur_check.checked = true;
}
}
//修改车次复选框判断
function selectChecked2(index) {
//index=0最上面的全选 index=1表示的是下面所有的
var cur_check = $('.ace_check2')[0];
var checkList = $('.ace_check2');
var checkCount = checkList.length - 1;
var true_count = 0;
for (var i = 1; i < checkList.length; i++) {
if (index == '0') {
checkList[i].checked = cur_check.checked;
} else {
if (checkList[i].checked == false) {
cur_check.checked = false
} else {
true_count = true_count + 1;
}
}
var man_no_arr = 0;
$('.ace_check2').each(function (index, item) {
if (this.checked && index != 0) {
var man_no_one = Math.floor($(this).attr('man_no'));
man_no_arr += man_no_one;
}
});
$("#select_no").text(man_no_arr);
}
//判断下面是否选中完
if (checkCount == true_count) {
cur_check.checked = true;
}
}
function selectBarInfo(index) {
window.location.href = "single_dispatch.html?bus_type=" + index;
}
function amend_save() {
$("#amend_button").removeAttr("onclick");
var ary = [];//主订单号集合
var bus_arr = [];//要修改的车次号集合
var alter_arr=[];//每个订单要修改的人数详情
var man_no_arr = 0;
$('.ace_check2').each(function (index, item) {
if (this.checked && index != 0) {
ary.push($(this).attr('name'));
bus_arr.push($(this).attr('sin_bus_id'));
alter_arr.push($(this).attr('man_no'));
var man_no_one = Math.floor($(this).attr('man_no'));
man_no_arr += man_no_one;
}
});
if (ary.length <= 0) {
ZZAlertInfo('请勾选!!!');
$("#amend_button").attr("onclick","amend_save();");
return;
}
var pro_str = ary.join(',');
//ZZAlertInfo(pro_str);
var bus_str = bus_arr.join(',');
var alter_str = alter_arr.join(',');
//ZZAlertInfo(bus_str);return;
var bus_and_run_arr = $("#amend_car_list").val().split(",");
var bus_num = bus_and_run_arr[0];
var run_id = bus_and_run_arr[1];
var param = {
tp: 'carDispatch_getGroupInfo_uptRunId',
orderid: pro_str,
bus_ori_str:bus_str,
alter_str:alter_str,
run_id: run_id,
p_num: man_no_arr,
bus_num: bus_num
}
ZZLog(base_api + 'index.php' + JSON.stringify(param));
$.ajax({
type: "post",
url: base_api + 'index.php',
data: param,
dataType: 'json',
success: function (res_data) {
ZZLog(res_data);
if (res_data['code'] != '0') {
ZZAlertInfo(res_data['info']);
} else {
ZZAlertInfo("修改成功");
$(".alert-block").hide();
httpFirstData();
}
$("#amend_button").attr("onclick","amend_save();");
}, error: function (e) {
ZZLog(e);
$("#amend_button").attr("onclick","amend_save();");
}
});
}
//自动分车
function auto_bus() {
if ($("#tbodySingle").html().trim() != '' || $("#tbodyGroup").html().trim() != '') {
ZZConfirm(
'自动分车将重置当前分车与派车结果
确定要自动分车吗?', function () {
auto_bus_dispatch();
}
)
} else {
auto_bus_dispatch();
}
}
function auto_bus_dispatch() {
start_date = $('#start_date').val().trim();
product_type = $('#product_type').val();
var param = {
tp: 'carDispatch_groupDispatch_dispatch',
run_date: start_date,
product_id: product_type
}
ZZLog(base_api + 'index.php' + JSON.stringify(param));
loading();
$.ajax({
type: "post",
url: base_api + 'index.php',
data: param,
dataType: 'json',
success: function (res_data) {
ZZLog(res_data);
if (res_data['code'] != '0') {
ZZAlertInfo(res_data['info']);
} else {
searchBtnDidClicked();
}
closeLoading();
}, error: function (e) {
ZZLog(e);
closeLoading();
}
});
}