//查询
function getList(page){
page = page || 1;
var pageSize = 10, data = $("#programForm").serializeJSON(), html = "";
data['pageSize'] = pageSize;
data['pageNo'] = page;
data['firstType'] = $("#keywords1").val();
data['secondType'] = $("#keywords2").val();
$("#list").empty();
$("#count").text(0);
ajax("get_program_list.do",data,function(res){
if(res.code == 1 && res.data.length > 0){
$.each(res.data, function(index, item){
html += '
'+
' | ' +
''+item.programName.toNull()+' | '+
''+item.type.toString().decode("1","综艺", "2","栏目", "3","电视剧","4", "电影","") +' | '+
''+item.firstType.toNull() +' | '+
''+item.secondType.toNull() +' | '+
''+ (item.type == 1 || item.type == 2 ? item.showCycle.toString().decode("1","周播", "2","季播","") : "")+' | '+
''+ (item.type == 1 || item.type == 2 ? item.showCycle.toString().decode("1",item.showYear != '' ? item.showYear + "年":item.showYear.toNull(),"2",item.showYear != '' ?"第" + item.showYear +"季" :item.showYear.toNull(),""):"") +' | '+
''+ item.type.toString().decode("1",item.showPhase!=''? "第" +item.showPhase +"期" : item.showPhase.toNull(),"2",item.showPhase != '' ? "第" + item.showPhase + "期" : item.showPhase.toNull(),"3",item.episode != '' ? "第" + item.episode + "集" : item.episode.toNull(),"") +' | '+
''+(item.showTime ? new Date(item.showTime.time).Format("yyyy-MM-dd"):"")+' | '+
''+(item.startTime ? new Date(item.startTime.time).Format("hh:mm"):"")+' | '+
''+(item.endTime ? new Date(item.endTime.time).Format("hh:mm"):"")+ ' | '+
''+
' 查看 '+
(data_update_flag == 1 ? ' 编辑' : '') +
' | ' +
' '+
(update_flag == 1 ? '编辑 ' : '')+
(delete_flag == 1 ? '删除' : '') +
' | ' +
'
';
});
$("#list").html(html);
$("#count").text(res.total);
var newpage = new createPage(res.total, page, pageSize, 3);
$("#page").html(newpage.pageHtml);
$(".table").hoverTable(true);
$.checkbox();
}else{
$("#list").info("暂无信息。");
}
});
}
pageGo = function(page){
resetCheckAll();
getList(page);
}
// 删除
function delProgram(id){
id = id == undefined ? getChkId().join(",") : id;
confirm("您确定需要删除该节目记录吗?",function(){
top.ajax("del_program.do",{"id":id},function(res){
if(res.code == 1){
alert("节目记录删除成功。", 1, function(){
getList(1);
});
}else{
alert(res.msg);
}
});
});
}
// 获取选中的id
function getChkId(){
var ids = '';
$("input[name='item']:checked").each(function(){
if(ids != ''){
ids = ids + ',' + $(this).val();
}else{
ids = $(this).val();
}
});
return ids;
}
// 批量删除
function delBatch(){
var checkedId = getChkId();
if (checkedId.isEmpty()){
alert("请至少选择一条记录");
return false;
}
confirm("确定删除这些记录吗?", function(){
ajax("del_batch_program.do", {"checkedId":checkedId}, function(res){
if (res.code == 1){
alert("删除成功。", 1, function(){
getList(1);
});
} else {
alert(res.msg);
}
});
});
}
// 新增或修改弹窗
function programModfiy(act, title, id){
title = title || "";
id = id || "";
$.openWindow(act.decode("add","新增","edit","修改","")+title, "program_info.do?id="+id, 800, 400, true);
}
function changeToVariety(obj){
var val = $(obj).val();
switch(parseInt(val)){
case 3:
$(".variety,.cycle-year,.cycle-month").addClass("contentTxt");
$("input[name='showCycle']:eq(0),input[name='showCycle']:eq(1)").prop("checked",false);
$(".tv").removeClass("contentTxt");
break;
case 4:
$(".variety,.cycle-year,.cycle-month,.tv,.variety-date").addClass("contentTxt");
$("input[name='showCycle']:eq(0),input[name='showCycle']:eq(1)").prop("checked",false);
break;
default:
$(".variety,.cycle-year,.variety-date").removeClass("contentTxt");
$(".tv,.cycle-month").addClass("contentTxt");
$(".cycle-year").find("input").attr("name","showYear");
$(".cycle-month").find("input").removeAttr("name");
$("input[name='showCycle']:eq(0)").prop("checked",true);
break;
}
$(".text").input();
getOneCategory($(obj).val());
$.radio();
}
// 周播和季播切换
function changeTobo(obj){
var val = $(obj).val();
if(val == 1){
$(".cycle-year").removeClass("contentTxt");
$(".cycle-month").addClass("contentTxt");
$(".cycle-year").find("input").attr("name","showYear");
$(".cycle-month").find("input").removeAttr("name");
$(".cycle-month").find("input").val("");
}else{
$(".cycle-month").removeClass("contentTxt");
$(".cycle-year").addClass("contentTxt");
$(".cycle-month").find("input").attr("name","showYear");
$(".cycle-year").find("input").removeAttr("name");
$(".cycle-year").find("input").val("");
}
$(".text").input();
}
//// 获取一级分类(类型为单选框)
//function getOneCategory(typeName){
// var html = '