//取权限缓存
var user_type = getStorage("user_type");
//一个页面的线路条数
var pagesize = 10;
//当前页数
var currpage = 1;
//根据线路编号和名称检索
var line_code = $("#line_text").val();
//运营公司
var supply_id = "-1";
//产品线
var product_line = "-1";
//线路状态
var line_status = "-1";
//线路类型
var line_type = "255";
//线路类型为 256 时 增加判断 705
var tailor_type = 0;
//总页数
var totalpage = "";
var sing_listHTML = '';
var com_listHTML = '';
$(document).ready(function () {
if (user_type == "0") {
$("#line1").show();
$("#line2").show();
$("#line3").show();
$("#line4").show();
line_type = "255";
} else if (user_type == "1") {
$("#line1").show();
$("#line2").hide();
$("#line3").hide();
$("#line4").hide();
line_type = "255";
} else if (user_type == "2") {
$("#line1").hide();
$("#line2").show();
$("#line3").hide();
$("#line2").removeClass("com_line btn-primary");
$("#line2").addClass("sole_line");
line_type = "256";
} else if (user_type == "3") {
$("#line1").hide();
$("#line2").hide();
$("#line3").show();
$("#line3").removeClass("com_line btn-primary");
$("#line3").addClass("sole_line");
$("#sample-table-1").hide();
$("#sample-table-2").show();
line_type = "316";
} else if (user_type == "4") {
$("#line1").show();
$("#line2").show();
$("#line3").hide();
line_type = "255";
} else if (user_type == "5") {
$("#line1").show();
$("#line2").hide();
$("#line3").show();
line_type = "255";
} else if (user_type == "6") {
$("#line1").hide();
$("#line2").show();
$("#line3").show();
line_type = "256";
$("#line2").removeClass("com_line btn-primary");
$("#line2").addClass("sole_line");
}
$("#line3").hide();
sing_listHTML = $('#sing_list').html();
com_listHTML = $('#com_list').html();
line_list_baseinfo();
selectOnePage(1);
});
//头部切换
function cut_car_type(index) {
$(".top").children().addClass("com_line btn-primary");
$(index).addClass("sole_line");
$(index).removeClass("com_line btn-primary");
$("#line_text").val("");
$("#yunying_company").val("-1");
$("#state").val("-1");
$("#product_type").val("-1");
line_type = $(index).attr("line_type");
if (line_type == 705) {
line_type = 256;
tailor_type = 705;
} else {
line_type = line_type;
tailor_type = 0;
}
if (line_type == "316") {
$("#product_line").show();
$("#sample-table-2").show();
$("#sample-table-1").hide();
} else {
$("#product_line").hide();
$("#sample-table-1").show();
$("#sample-table-2").hide();
}
supply_id = $("#yunying_company").val();
line_code = $("#line_text").val();
line_status = $("#state").val();
selectOnePage(1);
}
//加载配置信息
function line_list_baseinfo() {
$.ajax({
url: base_api + 'lineManager/index.php',//请求地址
data: {tp: "singleLine_getLineListBase"},
type: "post", //请求方式
dataType: "json",
success: function (data) {
console.log(data);
if (data.code == 0) {
get_baseinfo(data.supply_list, data.product_list);
} else {
ZZAlertInfo(data.info);
}
}
});
}
//替换线路加载配置信息
function get_baseinfo(data1, data2) {
var temp1 = '';
var temp2 = '';
for (var i = 0, j = data1.length; i < j; i++) {
temp1 += '';
}
for (var i = 0, j = data2.length; i < j; i++) {
temp2 += '';
}
$("#yunying_company").html(temp1);
$("#product_type").html(temp2);
}
//加载线路列表
function selectOnePage(page) {
if (line_type != "316") {
$('.yunying_company').hide();
$('#yunying_company').hide();
} else {
$('.yunying_company').show();
$('#yunying_company').show();
}
supply_id = $("#yunying_company").val();
line_code = $("#line_text").val();
line_status = $("#state").val();
product_line = $("#product_type").val();
if (line_type == "316") {
$.ajax({
url: base_api + 'lineManager/index.php', //请求地址
data: {
tp: "groupLine_getLineList",
page_size: pagesize,
current_page: page,
line_code: line_code,
supply_id: supply_id,
line_status: line_status,
product_type: product_line,
line_type: line_type
},
type: "post", //请求方式
dataType: "json",
async: false,
success: function (data) {
if (data.code == 0) {
console.log(data);
totalpage = data.page.total_page;
comReloadData(data.line_list);
if (totalpage == 0) {
$('.pageDiv').hide();
} else {
createPage(currpage, totalpage);
$('.pageDiv').show();
}
} else {
ZZAlertInfo(data.info);
}
}
});
} else {
$.ajax({
url: base_api + 'lineManager/index.php', //请求地址
data: {
tp: "singleLine_getLineList",
page_size: pagesize,
current_page: page,
line_code: line_code,
supply_id: supply_id,
line_status: line_status,
line_type: line_type,
tailor_type: tailor_type,
},
type: "post", //请求方式
dataType: "json",
async: false,
success: function (data) {
if (data.code == 0) {
console.log(data);
totalpage = data.page.total_page;
singReloadData(data.line_list);
if (totalpage == 0) {
$('.pageDiv').hide();
} else {
createPage(currpage, totalpage);
$('.pageDiv').show();
}
} else {
ZZAlertInfo(data.info);
}
}
});
}
}
//替换加载列表
function get_linelist(data) {
var temp = '';
for (var i = 0, j = data.length; i < j; i++) {
temp += '';
}
$("#yunying_company").html(temp);
}
//加载单一线路列表数据
function singReloadData(data) {
var list = data;
var newHTML = '';
for (var i = 0; i < list.length; i++) {
var tempHTML = sing_listHTML;
tempHTML = tempHTML.replace('[sing线路编号]', list[i].line_code);
tempHTML = tempHTML.replace('[sing线路名称]', list[i].line_name);
// tempHTML=tempHTML.replace('[类目]',list[i].line_sub_type);
tempHTML = tempHTML.replace('[sing票种数量]', list[i].cnt);
tempHTML = tempHTML.replace('[sing运营公司]', list[i].org_name);
tempHTML = tempHTML.replace('[sing状态]', list[i].disabled_status);
tempHTML = tempHTML.replace('[sing_userid_style]', 'userid_style' + list[i].line_id);
tempHTML = tempHTML.replace('[singOneCheckName]', list[i].line_id);
var str = '票种管理修改';
tempHTML = tempHTML.replace('[sing操作]', str);
newHTML += tempHTML;
}
$('#sing_list').html(newHTML);
$('#sing_list').show();
}
//加载组合线路列表数据
function comReloadData(data) {
var list = data;
var newHTML = '';
for (var i = 0; i < list.length; i++) {
var tempHTML = com_listHTML;
tempHTML = tempHTML.replace('[com线路编号]', list[i].line_code);
tempHTML = tempHTML.replace('[com线路名称]', list[i].line_name);
tempHTML = tempHTML.replace('[com产品线]', list[i].product_type_name);
tempHTML = tempHTML.replace('[com票种数量]', list[i].cnt);
tempHTML = tempHTML.replace('[com运营公司]', list[i].org_name);
tempHTML = tempHTML.replace('[com状态]', list[i].disabled_status);
tempHTML = tempHTML.replace('[com_userid_style]', 'userid_style' + list[i].line_id);
tempHTML = tempHTML.replace('[comOneCheckName]', list[i].line_id);
var str = '票种管理修改';
tempHTML = tempHTML.replace('[com操作]', str);
newHTML += tempHTML;
}
$('#com_list').html(newHTML);
}
//创建分页控件
function createPage(currpage, totalpage) {
$(".pageDiv").createPage({
pageCount: totalpage,//总页数
current: currpage,//当前页
turndown: 'true',//是否显示跳转框,显示为true,不现实为false,一定记得加上引号...
backFn: function (p) {
if (line_type == "316") {
$.ajax({
url: base_api + 'lineManager/index.php', //请求地址
data: {
tp: "groupLine_getLineList",
page_size: pagesize,
current_page: p,
line_code: line_code,
supply_id: supply_id,
line_status: line_status,
product_type: product_line,
line_type: line_type,
},
type: "post", //请求方式
dataType: "json",
async: false,
success: function (data) {
if (data.code == 0) {
console.log(data);
totalpage = data.page.total_page;
comReloadData(data.line_list);
} else {
ZZAlertInfo(data.info);
}
}
});
} else {
$.ajax({
url: base_api + 'lineManager/index.php', //请求地址
data: {
tp: "singleLine_getLineList",
page_size: pagesize,
current_page: p,
line_code: line_code,
supply_id: supply_id,
line_status: line_status,
line_type: line_type,
tailor_type: tailor_type,
},
type: "post",
dataType: "json",
async: false,
success: function (data) {
if (data.code == "0") {
console.log(data);
totalpage = data.page.total_page;
singReloadData(data.line_list);
} else {
ZZAlertInfo(data.info);
}
}
});
}
}
});
}
//查询
function searchInfo() {
selectOnePage(1);
}
//复选框判断
function select_checked(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;
}
}
//得到url上的参数
function getPar(par) {
var local_url = document.location.href;
local_url = decodeURI(local_url);
var get = local_url.indexOf(par + "=");
if (get == -1) {
return false;
}
var get_par = local_url.slice(par.length + get + 1);
var nextPar = get_par.indexOf("&");
if (nextPar != -1) {
get_par = get_par.slice(0, nextPar);
}
return get_par;
}
//停用选中项
function stopSelect() {
var ary = new Array();
$('.ace_check').each(function (index, item) {
if (this.checked && index != 0 && isNaN($(this).attr('name')) == false) {
ary.push($(this).attr('name'));
}
});
if (ary.length <= 0) {
ZZAlertInfo('请勾选!!!');
return;
}
var pro_str = ary.join(',');
var data = {
tp: "singleLine_lineStop",
line_id: pro_str
}
$.ajax({
url: base_api + 'lineManager/index.php', //请求地址
type: "post", //请求方式
data: data,
async: false,
dataType: "json",
success: function (data) {
console.log(data);
if (data.code == 0) {
$('.ace_check').each(function (index, item) {
if (this.checked && index != 0) {
var stopid = $(this).attr('name');
$('#userid_style' + stopid).text('停用');
}
});
ZZAlertInfo('停用成功!');
}
}
});
}
//启用选中项
function startSelect() {
var ary = new Array();
$('.ace_check').each(function (index, item) {
if (this.checked && index != 0 && isNaN($(this).attr('name')) == false) {
ary.push($(this).attr('name'));
}
});
if (ary.length <= 0) {
ZZAlertInfo('请勾选!!!');
return;
}
var pro_str = ary.join(',');
var data = {
tp: "singleLine_lineStart",
line_id: pro_str
}
$.ajax({
url: base_api + 'lineManager/index.php', //请求地址
type: "post", //请求方式
data: data,
dataType: "json",
success: function (data) {
console.log(data);
if (data.code == 0) {
$('.ace_check').each(function (index, item) {
if (this.checked && index != 0) {
var stopid = $(this).attr('name');
$('#userid_style' + stopid).text('启用');
}
});
ZZAlertInfo('启用成功!');
}
}
});
}
function addline() {
if (line_type == "316") {
window.location.href = "combination_line.html";
} else {
window.location.href = "singline_baseinfo.html";
}
}