123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450 |
- // 获取表格数据
- function getList(page){
- page = page || 1;
-
- var pageSize = 10, data = {
- "brand" : $("#brand").val(),
- "model" : $("#model").val(),
- "programName" : $("#programName").val(),
- "type" : $("#type option:selected").val(),
- "form" : $("#form option:selected").val(),
- "priceMin" : $("#priceMin").val(),
- "priceMax" : $("#priceMax").val(),
- "tvMode" : $("#tvMode option:selected").val(),
- "showMode" : $("#showMode option:selected").val(),
- "frequencyMin" : $("#frequencyMin").val(),
- "frequencyMax" : $("#frequencyMax").val(),
- "lengthMin" : $("#lengthMin").val(),
- "lengthMax" : $("#lengthMax").val(),
- "pageNo" : page,
- "pageSize" : pageSize
- }, html = "";
-
- $("#page, #list").empty();
- ajax("ajax_brand_placement.do", data, function(res){
- if (res.code == 1 && res.list.length > 0){
- $.each(res.list, function(index, item){
- html += '<tr>'+
- '<td><input type="checkbox" class="checkbox {click:itemCheck}" name="chk" value="'+item.id+'" /><label></label></td>'+
- '<td>'+item.brand.toNull()+'</td>'+
- '<td>'+item.model.toNull()+'</td>'+
- '<td>'+item.program_name.toNull()+'</td>'+
- '<td>'+(item.type ? item.type.toString().decode(1,"综艺",2,"栏目",3,"电视剧",4,"电影","") : "")+'</td>'+
- // '<td>'+item.type.toString().decode("1",item.show_year!=''?item.show_year+"年":item.show_year.toNull(), "2",item.show_year!=''?"第"+item.show_year +"季":item.show_year.toNull(), "/") +'</td>'+
- '<td>'+ (item.type == 1 || item.type == 2 ? item.showCycle.toString().decode("1",item.show_year != '' ? item.show_year + "年":item.show_year.toNull(),"2",item.show_year != '' ?"第" + item.show_year +"季" :item.show_year.toNull(),""):"") +'</td>'+
- '<td>'+item.type.toString().decode("1",item.show_phase!=''?"第"+item.show_phase+"期":item.show_phase.toNull(), "2",item.show_phase!=''?"第"+item.show_phase+"期":item.show_phase.toNull(), "3",item.episode!=''?"第"+item.episode+"集":item.episode.toNull(), "/") +'</td>'+
- '<td>'+item.show_time.toNull()+'</td>'+
- '<td>'+(item.type ? (item.type<=2?retForm(item.form):"/") : "/")+'</td>'+
- '<td class="edit">'+
- '<a href="javascript:placementModfiyOnList(\'\',\'广告属性/植入方式\','+item.id+');">'+item.mode.replace(/\,/img, "、").toNull()+'</a><br />'+
- '</td>'+
- '<td>'+(item.frequency != -1 ? item.frequency : "")+'</td>'+// 频次
- '<td>'+(item.length != -1 ? item.length : "")+'</td>'+// 时长
- '<td>'+item.price+'</td>'+// 预估价格
- '<td class="edit">'+
- (update_flag == 1 ? '<a href="brand_placement_info.do?id='+item.id+'" target="_blank" >编辑</a> ' : '')+
- (delete_flag == 1 ? '<a href="javascript:delRecord('+item.id+');">删除</a>' : '')+
- '</td>'+
- '</tr>';
- });
- $("#list").html(html);
- $.checkbox();
- // $(".table").hoverTable(true);
- $("#count").text(res.count);
- var newpage = new createPage(res.count,page,pageSize,3);
- $("#page").html(newpage.pageHtml);
- } else {
- $("#list").info("暂无数据。");
- }
- });
-
- }
- pageGo = function(page){
- resetCheckAll();
- getList(page);
- }
- // 广告形式
- function retForm(form){
- return form == undefined ? "" : form.replace(/1/,"冠名").replace(/2/,"特约").replace(/3/,"互动支持").replace(/4/,"合作伙伴").replace(/5/,"指定产品").replace(/6/,"指定用车").replace(/7/,"其他").replace(/8/,"创意中插").replace(/\,/g,"、");
- }
- // 删除单个品牌植入
- function delRecord(id){
- confirm("您确定需要删除该条记录吗?", function(){
- ajax("del_brand_placement.do", {"id" : id}, function(res){
- if (res.code == 1){
- alert("删除成功", 1, function(){
- window.location.href = "brand_placement.do";
- });
- } else {
- alert(res.msg);
- }
- });
- });
- }
- // 删除多个品牌植入
- function delRecordBatch(){
- var arr = document.getElementsByName("chk");
- var ids = "";
- for (i=0; i<arr.length; i++){
- if (arr[i].checked){
- ids += ("," + arr[i].value);
- }
- }
- if (ids.isEmpty()){
- alert("请至少选择一条记录");
- return false;
- }
- confirm("确定删除这些记录吗?", function(){
- ajax("batch_del_for_placement.do", {"ids" : ids.substring(1,ids.length)}, function(res){
- if (res.code == 1){
- alert("删除成功。", 1, function(){
- window.location.href = "brand_placement.do";
- });
- } else {
- alert(res.msg);
- }
- });
- });
- }
- // 删除单个植入方式(从表格中移除)
- function delMode(){
-
- }
- // 保存详情信息
- function save(){
- /* 得到并验证基本信息数据 */
- var data = $('#dataForm').serializeJSON();
- data.id = $.getParam("id");
- data.programName = $("#programName option:selected").val();
- data.showYear = $("#showYear option:selected").val();
- data.showPhase = $("#showPhase option:selected").val();
- // 广告形式
- var arr = document.getElementsByName("form");
- var form = "";var formCount = 0;
- for (i=0; i<arr.length; i++){
- if (arr[i].checked){
- form += ("," + arr[i].value);
- formCount += 1;
- }
- }
- if (formCount < 1){
- top.alert("请选择广告形式");
- return false;
- }
- data.form = form.substring(1,form.length);
- if (data['type'].isEmpty()){
- alert("请选择节目类型。");
- return false;
- }
- if (data['brand'].isEmpty()){
- alert("请选择品牌。");
- return false;
- }
- if (data['model'].isEmpty()){
- alert("请选择产品型号。");
- return false;
- }
- if (data['programName'].isEmpty()){
- alert("请选择节目。");
- return false;
- }
- if (data['type'] == 1 || data['type'] == 2){
- if (data['showYear'].isEmpty()){
- alert("请选择年份/季。");
- return false;
- }
- if (data['showPhase'].isEmpty()){
- alert("请选择期数。");
- return false;
- }
- if (data['form'].isEmpty()){
- alert("请选择广告形式。");
- return false;
- }
- }
- if (data['type'] == 3){
- if (data['episode'].isEmpty()){
- alert("请选择集数。");
- return false;
- }
- data['form'] = "";
- }
- if (data['type'] == 4){
- data['form'] = "";
- }
- /* 得到子关联信息(具体植入方式) */
- data.sonJsonStr = [];
- $(".table>tbody>tr").each(function(){
- var obj = {};
- obj.mode = $(this).attr("data-mode");;// 广告植入方式
- obj.imgUrls = $(this).attr("data-img");// 植入截图
- obj.frequency = $(this).attr("data-frequency");// 频次
- obj.length = $(this).attr("data-length");// 时长
- obj.slogan = $(this).attr("data-slogan");// 广告语
- if(obj.mode.isEmpty()){
- return false;
- }else{
- data.sonJsonStr.push(obj);
- }
- });
- // 数组转json字符串
- data.sonJsonStr = ObjectArrayToJsonString(data.sonJsonStr);
- ajax("save_brand_placement.do", data, function(res){
- if (res.code == 1){
- alert("保存成功。", 1, function(){
- window.location.href = "brand_placement.do";
- });
- } else {
- alert(res.msg);
- }
- });
- }
- // “品牌”下拉值变动:获取产品型号
- function onchangeByBrand(model){
- var html = "", brand = $("select[name='brand']>option:selected").val();
- if(brand.isEmpty()){
- return false;
- }
- ajax({url:"ajax_model_by_brand.do",data:{"q":brand},callBack:function(res){
- if(res.list.length > 0){
- $.each(res.list,function(index, item){
- html+='<option value="'+item.model+'" '+(item.model == model ? " selected":"")+'>'+item.model+'</option>';
- });
- $("select[name='model']").html(html);
- $(".select").uiSelect();
- }
- },load:false});
- }
- // “节目名称”下拉值变动:获取“年份/季” or “集数”
- function onchangeByProgramName(showYear,episode){
- var html = "", programName = $("select[name='programName']>option:selected").val();
- var typeParame = 2, type = $("input[name='type']:checked").val();
- if(programName.isEmpty()){
- return false;
- }
- // 该参数默认为2,如果节目类型是电视剧,则为4
- if(type == 3){
- typeParame = 4;
- }
- ajax({url:"ajax_program_info.do",data:{"type":typeParame,"programName":programName},callBack:function(res){
- if(res.list.length > 0){
- if (type == 1 || type == 2){
- // 综艺or栏目(修改年份下拉)
- $.each(res.list, function(index, item){
- html += '<option value="'+item.showYear+'" '+(item.showYear == showYear ? " selected":"")+'>'+item.showYear+'</option>';
- });
- $("select[name='showYear']").html(html);
- } else if (type == 3){
- // 电视剧(修改集数下拉)
- $.each(res.list, function(index, item){
- html += '<option value="'+item.episode+'" '+(item.episode == episode ? " selected":"")+'>'+item.episode+'</option>';
- });
- $("select[name='episode']").html(html);
- } else {
- $.each(res.list, function(){
- html += '<option value=""></option>';
- });
- }
- }else{
- $("#showYear").html('<option value="">年份/季</option>');// 年份
- $("#showPhase").html('<option value="">期数</option>');// 期数
- $("#episode").html('<option value="">请选择集数</option>');// 集数
- }
- $(".select").uiSelect();
- },load:false});
- }
- // “节目年份”下拉值变动:获取期数
- function onchangeByShowYear(showPhase){
- var html = "", programName = $("select[name='programName']>option:selected").val();
- var showYear = $("select[name='showYear']>option:selected").val();
- if(programName.isEmpty() || showYear.isEmpty()){
- return false;
- }
- ajax({url:"ajax_program_info.do",data:{"type":3,"programName":programName,"showYear":showYear},callBack:function(res){
- if(res.list.length > 0){
- $.each(res.list,function(index, item){
- html+='<option value="'+item.showPhase+'" '+(item.showPhase == showPhase ? " selected":"")+'>'+item.showPhase+'</option>';
- });
- $("select[name='showPhase']").html(html);
- }else{
- $("#showPhase").html('<option value="">期数</option>');// 期数
- }
- $(".select").uiSelect();
- },load:false});
- }
- // to 列表页子弹窗
- function placementModfiyOnList(act, title, id){
- title = title || "";
- id = id || "";
- $.openWindow(act.decode("add","新增","edit","修改","")+title, "brand_placement_box.do?id="+id, 500, 470, true);
- }
- // to 详情页子弹窗
- function placementModfiy(act, title, id, index){
- // title = title || "广告属性";
- title = "广告属性";
- id = id || "";
- index = index == undefined ? -1 : index;
- var type = $("input[name='type']:checked").val(), modeType = 1;
- // modeType 植入方式的所属类型(1综艺、栏目,2电视剧、电影)
- if (type == 3 || type == 4){
- modeType = 2;
- title = "植入方式";
- }
- $.openWindow(act.decode("add","新增","edit","修改","")+title, "brand_placement_info_box.do?act="+act+"&id="+id+"&modeType="+modeType+'&index='+index, 540, 460, true);
- }
- // 将 box 页面中的数据提交到 info 页面
- function saveInfoBox(){
- var data = $('#saveInfoFrm').serializeJSON(), imgs = [], table = top.$(".table>tbody>tr"), html = "", index = $.getParam("index");
- $("#imgShow .img").each(function(){
- imgs.push($(this).prop("href"));
- });
- data['modeName'] = $("input[name='mode']:checked").next("label").text();
- data['img'] = imgs.join(";");
- data['id'] = $.getParam("id");
- data['act'] = $.getParam("act");
- data['modeType'] = $.getParam("modeType");
- data['slogan'] = data['slogan'] || "";
- html = '<tr data-id="'+data.id+'" data-mode="'+data.mode+'" data-img="'+data.img+'" data-slogan="'+data.slogan+'" data-frequency="'+data.frequency+'" data-length="'+data.length+'">\n\
- <td>'+data.modeName+'</td>\n\
- <td class="nop">'+(imgs.length > 0 ? '<img src="'+imgs[0]+'" width="98" height="58" valign="middle" />':'')+'</td>\n\
- '+(data.modeType == 1 ? "<td>"+data.slogan+"</td>":"")+'\n\
- <td>'+data.frequency+'</td>\n\
- <td>'+data.length+'</td>\n\
- <td class="edit">\n\
- <a href="javascript:placementModfiy(\'edit\',\'植入方式\',\''+data.id+'\','+(data['act'] == "edit" ? $.getParam("index") : table.length)+');">编辑</a> \n\
- <a class="del">删除</a>\n\
- </td>\n\
- </tr>';
- if(data['act'] == "edit"){
- table.eq(index).replaceWith(html);
- }else{
- top.$(".table>tbody").append(html);
- }
- top.$.closeWindow();
- }
- function delImg(obj){
- $(obj).closest("li").remove();
- }
- function setDefaultData(){
- var index = $.getParam("index"), table = top.$(".table>tbody>tr").eq(index), html = "", data = {};
- if(index != -1){
- data.id = table.data("id");
- data.mode = table.data("mode");
- data.img = table.data("img");
- data.slogan = table.data("slogan");
- data.frequency = table.data("frequency");
- data.length = table.data("length");
- $("input[name='mode']").each(function(){
- if($(this).val() == data.mode){
- $(this).prop("checked",true);
- }
- });
- $.radio();
- if(!data.img.isEmpty()){
- data.img = data.img.split(";");
- $.each(data.img,function(i,item){
- html+='<li><a href="javascript:void(0);" class="del" onclick="delImg(this);"></a><a href="'+item+'" class="img" style="background-image:url('+item+');"></a></li>';
- });
- $("#imgShow").html(html);
- }
- $("input[name='slogan']").val(data.slogan);
- $("input[name='frequency']").val(data.frequency);
- $("input[name='length']").val(data.length);
- $(".lInput").hide();
- }
- }
- // 切换节目类型
- function brandType(obj){
- var val = $(obj).val(), th = $(".table>thead>tr>th"), td = $(".table>tbody>tr");
-
- // 1.修改"节目名称"下拉项
- $("#programName").empty();
- ajax("ajax_programname_list.do", {"type" : val}, function(res){
- $("#programName").append('<option value="">请选择节目</option>');
- if (res.code == 1 && res.list.length > 0){
- $.each(res.list, function(index, item){
- $("#programName").append('<option value="'+item.programName+'">'+item.programName+'</option>');
- });
- }
- $("#episode").html('<option value="">请选择集数</option>');// 集数
- $("#showYear").html('<option value="">年份/季</option>');// 年份
- $("#showPhase").html('<option value="">期数</option>');// 期数
- $(".select").uiSelect();
- },false);
-
- // 2.其他
- switch(parseInt(val)){
- case 3:
- $(".column").addClass("contentTxt");// "广告形式"的显示/隐藏
- $(".tv").removeClass("contentTxt");
- th.eq(0).text("植入方式");// 表格表头文字(广告属性/植入方式)
- th.eq(1).text("植入截图");// 表格表头文字(广告创意/植入截图)
- // 表格->"广告语"的显示/隐藏
- th.eq(2).hide();
- td.each(function(){
- $(this).find("td").eq(2).hide();
- }).eq(2).show();
- break;
- case 4:
- $(".column, .tv").addClass("contentTxt");
- th.eq(0).text("植入方式");
- th.eq(1).text("植入截图");
- th.eq(2).hide();
- td.each(function(){
- $(this).find("td").eq(2).hide();
- }).eq(2).show();
- break;
- default:
- $(".tv").addClass("contentTxt");
- $(".column").removeClass("contentTxt");
- th.eq(0).text("广告属性");
- th.eq(1).text("广告创意");
- th.eq(2).show();
- td.each(function(){
- $(this).find("td").eq(2).show();
- }).eq(2).show();
- break;
- }
- }
- //导入表格数据
- function importExcel(obj){
- $("#fileForm").submit();
- }
- // 导入视频
- function updVideo(){
- $("#updVideo").submit();
- }
- // 导入结果
- function excelCallback(code, msg) {
- if (code == 1) {
- // 导入成功
- alert("导入成功。", 1, function(){
- window.location.href = "brand_placement.do";
- });
- } else {
- // 导入失败
- alert(msg, 0, function(){
- location.reload();
- });
- }
- }
|