123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192 |
- $(document).ready(function(){
- var ctx = $("#ctx").val();//获取服务器地址
-
- /*************************** 创意列表页 ***************************/
-
- $("#all-btn-upload").click(function(){
- if($("#advertiserId").val() == "" || $("#advertiserId").val() == -1){
- $(this).attr("href","javascript:void(0);");
- bootbox.alert("请选择广告主!");
- $(this).attr("title","请选择广告主");
- return false;
- }else{
- $('#all-input-file').click();
- }
- });
- $('ul#advertiser_son_ul li').live("click",function(){
- $("#myform").attr("action",ctx+"/advertiser/main/ad/banner-template/list");
- refreshData();
- });
-
- //获取创意尺寸
- if($("#size").val() == 0 || $("#size").val() == ""){
- $("#selectBar_size a:first").addClass("selectBar_change");
- }
- $("#selectBar_size a").each(function(){
- var value = $(this).attr("value");
- if($("#size").val() == value){
- $(this).addClass("selectBar_change").siblings('.selectBar_change').removeClass('selectBar_change');
- }
- });
- $("#selectBar_size a").click(function(){
- $("#size").val($(this).attr("value"));
- if($(this).attr("value") != ""){
- var _size = $(this).attr("value").split(':',2);
- $("#rwidth").val(_size[0]);
- $("#rheight").val(_size[1]);
- }else{
- $("#rwidth").val("");
- $("#rheight").val("");
- }
- refreshData();
- });
-
- //创意类型
- if($("#type").val() == 0 || $("#type").val() == ""){
- $("#selectBar_type a:first").addClass("selectBar_change");
- }
- $("#selectBar_type a").each(function(){
- var value = $(this).attr("value");
- if($("#type").val() == value){
- $(this).addClass("selectBar_change").siblings('.selectBar_change').removeClass('selectBar_change');
- }
- });
- $("#selectBar_type a").click(function(){
- $("#type").val($(this).attr("value"));
- refreshData();
- });
-
- //状态全部、开启、停用
- if($("#status").val() == -1 || $("#status").val() == ""){
- $("#selectBar_status a:first").addClass("selectBar_change");
- }
- $("#selectBar_status a").each(function(){
- var value = $(this).attr("value");
- if($("#status").val() == value){
- $(this).addClass("selectBar_change").siblings('.selectBar_change').removeClass('selectBar_change');
- }
- });
- $("#selectBar_status a").click(function(){
- $("#status").val($(this).attr("value"));
- refreshData();
- });
-
- //开启,暂停
- $("#btn-enable,#btn-disable,#btn-delete").click(function(){
- if($(this).attr("id") == "btn-enable"){
- url = ctx+"/advertiser/main/ad/banner-template/enable";
- }else if($(this).attr("id") == "btn-disable"){
- url = ctx+"/advertiser/main/ad/banner-template/disable";
- }else if($(this).attr("id") == "btn-delete"){
- url = ctx+"/advertiser/main/ad/banner-template/delete";
- }
- singleOper($(this),url);
- });
-
- //批量开启,批量暂停
- $("#all-btn-enable,#all-btn-disable,#all-btn-delete").click(function(){
- if($(this).attr("id") == "all-btn-enable"){
- url = ctx+"/advertiser/main/ad/banner-template/enable";
- }else if($(this).attr("id") == "all-btn-disable"){
- url = ctx+"/advertiser/main/ad/banner-template/disable";
- }else if($(this).attr("id") == "all-btn-delete"){
- url = ctx+"/advertiser/main/ad/banner-template/delete";
- }
- batchOpear($(this),url);
- });
-
- if($("#all-btn-upload").html()){
- $("#all-input-file").fileupload({
- autoUpload: true,
- url:ctx+"/advertiser/main/ad/banner-template/upload",//文件上传地址,当然也可以直接写在input的data-url属性内
- formData:{advertiserId:$("#advertiserId").val()},
- //如果需要额外添加参数可以在这里添加
- done:function(e,data){
- //done方法就是上传完毕的回调函数,其他回调函数可以自行查看api
- //注意result 要和jquery的ajax的data参数区分,这个对象包含了整个请求信息
- //返回的数据在result.result中,假设我们服务器返回了一个json对象
- bootbox.alert(data.result,function(ensure) {
- refreshData();
- });
- }
- });
- }
-
- $('#btn-edit').live("click",function(){
- $(this).parent("div#listButtons").children('input').click();
- });
-
- $('#btn-editName').live("click",function(){
- $("table .input-text-change").each(function(){
- $(this).removeClass("input-text-change");
- $(this).attr('disabled',true);
- });
- $(this).parents("tr").find(".input-text-edit").addClass("input-text-change");
- $(this).parents("tr").find(".input-text-edit").removeAttr('disabled');
- });
-
- $('.input-text-edit').blur(function(){
- $(this).removeClass("input-text-change");
- $(this).attr('disabled',true);
- $.post(ctx+"/advertiser/main/ad/banner-template/alterName",{id:$(this).attr("valueId"),name:$(this).val()},function(data){
- refreshData();
- });
- });
-
- $("#listButtons input[type='file']").each(function(){
- var bannerTemplateId = $(this).attr("valueId");
- $(this).fileupload({
- autoUpload: true,
- url: ctx+'/advertiser/main/ad/banner-template/replace',
- formData:{bannerTemplateId:bannerTemplateId},
- done:function(e,data){
- bootbox.alert(data.result,function(ensure) {
- refreshData();
- });
- }
- });
- });
-
- $(document).bind('click',function(evt){
- if (evt.target.className.indexOf("input-text-change") == -1 && evt.target.id != "btn-editName") {
- $(".input-text-edit").removeClass("input-text-change");
- $(".input-text-edit").attr('disabled',true);
- }
- });
-
- /*************************** 创建,编辑广告主 ***************************/
-
- //初始校验表单
- if($("#validateForm").html()){
- $("#validateForm").autovalidate();
- }
-
- $(".btn-save").click(function(){
- if (!$("#validateForm").validate()) {
- return false;
- }
- var falg = validateMoney();
- if(falg == false){
- return false;
- }
- $("#validateForm").submit();
- return false;
- });
-
- $(".btn-cancel").click(function(){
- window.location.href = ctx+"/advertiser/main/ad/order/list?advertiserId="+$("#advertiserId").val();
- });
-
- });
-
- function exportExcel_list(){
- var searchValue = $("#searchValue").val();
- if(searchValue == "请输入关键字"){
- searchValue = "";
- }
- var param = "?advertiserId="+$("#advertiserId").val()+"&status="+$("#status").val()+"&searchValue="+searchValue;
- $("#exportExcel").attr("href",$("#ctx").val()+"/advertiser/main/ad/order/exportDataReportExcel"+param);
- return false;
- }
|