banner.js 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. $(document).ready(function(){
  2. var ctx = $("#ctx").val();//获取服务器地址
  3. /*************************** 创意列表页 ***************************/
  4. $("#all-btn-upload").click(function(){
  5. if($("#advertiserId").val() == "" || $("#advertiserId").val() == -1){
  6. $(this).attr("href","javascript:void(0);");
  7. bootbox.alert("请选择广告主!");
  8. $(this).attr("title","请选择广告主");
  9. return false;
  10. }else{
  11. $('#all-input-file').click();
  12. }
  13. });
  14. $('ul#advertiser_son_ul li').live("click",function(){
  15. $("#myform").attr("action",ctx+"/advertiser/main/ad/banner-template/list");
  16. refreshData();
  17. });
  18. //获取创意尺寸
  19. if($("#size").val() == 0 || $("#size").val() == ""){
  20. $("#selectBar_size a:first").addClass("selectBar_change");
  21. }
  22. $("#selectBar_size a").each(function(){
  23. var value = $(this).attr("value");
  24. if($("#size").val() == value){
  25. $(this).addClass("selectBar_change").siblings('.selectBar_change').removeClass('selectBar_change');
  26. }
  27. });
  28. $("#selectBar_size a").click(function(){
  29. $("#size").val($(this).attr("value"));
  30. if($(this).attr("value") != ""){
  31. var _size = $(this).attr("value").split(':',2);
  32. $("#rwidth").val(_size[0]);
  33. $("#rheight").val(_size[1]);
  34. }else{
  35. $("#rwidth").val("");
  36. $("#rheight").val("");
  37. }
  38. refreshData();
  39. });
  40. //创意类型
  41. if($("#type").val() == 0 || $("#type").val() == ""){
  42. $("#selectBar_type a:first").addClass("selectBar_change");
  43. }
  44. $("#selectBar_type a").each(function(){
  45. var value = $(this).attr("value");
  46. if($("#type").val() == value){
  47. $(this).addClass("selectBar_change").siblings('.selectBar_change').removeClass('selectBar_change');
  48. }
  49. });
  50. $("#selectBar_type a").click(function(){
  51. $("#type").val($(this).attr("value"));
  52. refreshData();
  53. });
  54. //状态全部、开启、停用
  55. if($("#status").val() == -1 || $("#status").val() == ""){
  56. $("#selectBar_status a:first").addClass("selectBar_change");
  57. }
  58. $("#selectBar_status a").each(function(){
  59. var value = $(this).attr("value");
  60. if($("#status").val() == value){
  61. $(this).addClass("selectBar_change").siblings('.selectBar_change').removeClass('selectBar_change');
  62. }
  63. });
  64. $("#selectBar_status a").click(function(){
  65. $("#status").val($(this).attr("value"));
  66. refreshData();
  67. });
  68. //开启,暂停
  69. $("#btn-enable,#btn-disable,#btn-delete").click(function(){
  70. if($(this).attr("id") == "btn-enable"){
  71. url = ctx+"/advertiser/main/ad/banner-template/enable";
  72. }else if($(this).attr("id") == "btn-disable"){
  73. url = ctx+"/advertiser/main/ad/banner-template/disable";
  74. }else if($(this).attr("id") == "btn-delete"){
  75. url = ctx+"/advertiser/main/ad/banner-template/delete";
  76. }
  77. singleOper($(this),url);
  78. });
  79. //批量开启,批量暂停
  80. $("#all-btn-enable,#all-btn-disable,#all-btn-delete").click(function(){
  81. if($(this).attr("id") == "all-btn-enable"){
  82. url = ctx+"/advertiser/main/ad/banner-template/enable";
  83. }else if($(this).attr("id") == "all-btn-disable"){
  84. url = ctx+"/advertiser/main/ad/banner-template/disable";
  85. }else if($(this).attr("id") == "all-btn-delete"){
  86. url = ctx+"/advertiser/main/ad/banner-template/delete";
  87. }
  88. batchOpear($(this),url);
  89. });
  90. if($("#all-btn-upload").html()){
  91. $("#all-input-file").fileupload({
  92. autoUpload: true,
  93. url:ctx+"/advertiser/main/ad/banner-template/upload",//文件上传地址,当然也可以直接写在input的data-url属性内
  94. formData:{advertiserId:$("#advertiserId").val()},
  95. //如果需要额外添加参数可以在这里添加
  96. done:function(e,data){
  97. //done方法就是上传完毕的回调函数,其他回调函数可以自行查看api
  98. //注意result 要和jquery的ajax的data参数区分,这个对象包含了整个请求信息
  99. //返回的数据在result.result中,假设我们服务器返回了一个json对象
  100. bootbox.alert(data.result,function(ensure) {
  101. refreshData();
  102. });
  103. }
  104. });
  105. }
  106. $('#btn-edit').live("click",function(){
  107. $(this).parent("div#listButtons").children('input').click();
  108. });
  109. $('#btn-editName').live("click",function(){
  110. $("table .input-text-change").each(function(){
  111. $(this).removeClass("input-text-change");
  112. $(this).attr('disabled',true);
  113. });
  114. $(this).parents("tr").find(".input-text-edit").addClass("input-text-change");
  115. $(this).parents("tr").find(".input-text-edit").removeAttr('disabled');
  116. });
  117. $('.input-text-edit').blur(function(){
  118. $(this).removeClass("input-text-change");
  119. $(this).attr('disabled',true);
  120. $.post(ctx+"/advertiser/main/ad/banner-template/alterName",{id:$(this).attr("valueId"),name:$(this).val()},function(data){
  121. refreshData();
  122. });
  123. });
  124. $("#listButtons input[type='file']").each(function(){
  125. var bannerTemplateId = $(this).attr("valueId");
  126. $(this).fileupload({
  127. autoUpload: true,
  128. url: ctx+'/advertiser/main/ad/banner-template/replace',
  129. formData:{bannerTemplateId:bannerTemplateId},
  130. done:function(e,data){
  131. bootbox.alert(data.result,function(ensure) {
  132. refreshData();
  133. });
  134. }
  135. });
  136. });
  137. $(document).bind('click',function(evt){
  138. if (evt.target.className.indexOf("input-text-change") == -1 && evt.target.id != "btn-editName") {
  139. $(".input-text-edit").removeClass("input-text-change");
  140. $(".input-text-edit").attr('disabled',true);
  141. }
  142. });
  143. /*************************** 创建,编辑广告主 ***************************/
  144. //初始校验表单
  145. if($("#validateForm").html()){
  146. $("#validateForm").autovalidate();
  147. }
  148. $(".btn-save").click(function(){
  149. if (!$("#validateForm").validate()) {
  150. return false;
  151. }
  152. var falg = validateMoney();
  153. if(falg == false){
  154. return false;
  155. }
  156. $("#validateForm").submit();
  157. return false;
  158. });
  159. $(".btn-cancel").click(function(){
  160. window.location.href = ctx+"/advertiser/main/ad/order/list?advertiserId="+$("#advertiserId").val();
  161. });
  162. });
  163. function exportExcel_list(){
  164. var searchValue = $("#searchValue").val();
  165. if(searchValue == "请输入关键字"){
  166. searchValue = "";
  167. }
  168. var param = "?advertiserId="+$("#advertiserId").val()+"&status="+$("#status").val()+"&searchValue="+searchValue;
  169. $("#exportExcel").attr("href",$("#ctx").val()+"/advertiser/main/ad/order/exportDataReportExcel"+param);
  170. return false;
  171. }