advertise.js 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. // 获取表格数据-电视硬广
  2. function getList(page){
  3. page = page || 1;
  4. var pageSize = 10, data = {
  5. "name" : $("#name").val(),
  6. "type" : $("#type option:selected").val(),
  7. "showTime" : $("#showTime").val(),
  8. "saleStatus" : $("#saleStatus option:selected").val(),
  9. "pageNo" : page,
  10. "pageSize" : pageSize
  11. }, html = "";
  12. $("#page, #list, #count").empty();
  13. ajax("ajax_resource_list_by_advertise.do", data, function(res){
  14. if (res.code == 1 && res.list.length > 0){
  15. $.each(res.list, function(index, item){
  16. var length = item.theaterAttribute.toNull().length;
  17. html += '<tr>'+
  18. '<td><input type="checkbox" class="checkbox {click:itemCheck}" name="chk" value="'+item.id+'" /><label></label></td>'+
  19. '<td>'+item.name.toNull()+'</td>'+
  20. '<td>'+item.showTime.toNull()+'</td>'+
  21. '<td>'+item.type.toString().decode("1","央视", "2","卫视","3","省级地面","4","其它","") +'</td>'+
  22. ((length>25)?'<td title="'+item.theaterAttribute+'">'+item.theaterAttribute.substring(0,22)+'……</td>':'<td>'+item.theaterAttribute.toNull()+'</td>')+
  23. '<td>'+(item.ratings ? item.ratings+'%' : '')+'</td>'+
  24. '<td>'+(item.share ? item.share+'%' : '')+'</td>'+
  25. '<td>'+item.versions+'</td>'+
  26. '<td>'+item.price+'</td>'+
  27. '<td>'+(item.discount ? item.discount+'%' : '')+'</td>'+
  28. '<td>'+item.saleStatus.toString().decode("0","在售", "1","已售","")+'</td>'+
  29. '<td>'+item.customer.toNull()+'</td>'+
  30. '<td>'+item.remarks.toNull()+'</td>'+
  31. '<td class="edit">'+
  32. (update_flag == 1 ? '<a href="javascript:platformModfiy(\'edit\',\'电视硬广\','+item.id+');">编辑</a>&nbsp;&nbsp;' : '') +
  33. (delete_flag == 1 ? '<a href="javascript:delAdvertise('+item.id+');">删除</a>' : '' ) +
  34. '</td>'+
  35. '</tr>';
  36. });
  37. $("#list").html(html);
  38. $("#count").text(res.count);
  39. var newpage = new createPage(res.count, page, pageSize, 3);
  40. $("#page").html(newpage.pageHtml);
  41. $(".table").hoverTable(true);
  42. $.checkbox();
  43. } else {
  44. $("#list").info("暂无数据。");
  45. }
  46. });
  47. }
  48. pageGo = function(page){
  49. resetCheckAll();
  50. getList(page);
  51. }
  52. // 删除单个
  53. function delAdvertise(id){
  54. confirm("确定删除该条记录吗?", function(){
  55. ajax("del_resource_by_advertise.do", {"id" : id}, function(res){
  56. if (res.code == 1){
  57. alert("删除成功。", 1, function(){
  58. window.location.reload();
  59. });
  60. } else {
  61. alert(res.msg);
  62. }
  63. });
  64. });
  65. }
  66. //删除多个
  67. function delRecordBatch(){
  68. var arr = document.getElementsByName("chk");
  69. var ids = "";
  70. for (i=0; i<arr.length; i++){
  71. if (arr[i].checked){
  72. ids += ("," + arr[i].value);
  73. }
  74. }
  75. if (ids.isEmpty()){
  76. alert("请至少选择一条记录");
  77. return false;
  78. }
  79. confirm("确定删除这些记录吗?", function(){
  80. ajax("del_batch_resource_by_advertise.do", {"ids" : ids.substring(1,ids.length)}, function(res){
  81. if (res.code == 1){
  82. alert("删除成功。", 1, function(){
  83. window.location.href = "to_advertise_list.do";
  84. });
  85. } else {
  86. alert(res.msg);
  87. }
  88. });
  89. });
  90. }
  91. // 导入表格数据
  92. function importExcel(obj){
  93. $("#fileForm").submit();
  94. }
  95. // “importExcel”的执行结果
  96. function excelCallback(code, msg) {
  97. if (code == 1) {
  98. // 导入成功
  99. alert("导入成功。", 1, function(){
  100. window.location.href = "to_advertise_list.do";
  101. });
  102. } else {
  103. // 导入失败
  104. alert(msg, 0, function(){
  105. location.reload();
  106. });
  107. }
  108. }
  109. // to详情弹窗
  110. function platformModfiy(act, title, id){
  111. title = title || "";
  112. id = id || "";
  113. $.openWindow(act.decode("add","新增","edit","修改","")+title, "to_resource_by_advertise.do?id="+id, 500, 470, true, null, true);
  114. }
  115. // 保存信息
  116. function saveAdvertise(){
  117. // 得到数据
  118. var data = $('#infoForm').serializeJSON();
  119. data.id = $.getParam("id");
  120. // 数据是否完整
  121. if (data['name'].isEmpty()){
  122. top.alert("请输入媒体名称", 0, function(){
  123. $("input[name='name']").focus();
  124. });
  125. return false;
  126. }
  127. if (data['showTime'].isEmpty()){
  128. top.alert("请输入时间", 0, function(){
  129. $("input[name='showTime']").focus();
  130. });
  131. return false;
  132. }
  133. if (data['type'].isEmpty()){
  134. top.alert("请选择频道类型");
  135. return false;
  136. }
  137. if (data['theaterAttribute'].isEmpty()){
  138. top.alert("请输入时段", 0, function(){
  139. $("input[name='theaterAttribute']").focus();
  140. });
  141. return false;
  142. }
  143. if (data['ratings'].isEmpty()){
  144. top.alert("请输入收视率", 0, function(){
  145. $("input[name='ratings']").focus();
  146. });
  147. return false;
  148. }
  149. if (data['share'].isEmpty()){
  150. top.alert("请输入收视份额", 0, function(){
  151. $("input[name='share']").focus();
  152. });
  153. return false;
  154. }
  155. if (data['versions'].isEmpty()){
  156. top.alert("请输入版本", 0, function(){
  157. $("input[name='versions']").focus();
  158. });
  159. return false;
  160. }
  161. if (data['price'].isEmpty()){
  162. top.alert("请输入刊例价格", 0, function(){
  163. $("input[name='price']").focus();
  164. });
  165. return false;
  166. }
  167. if (data['discount'].isEmpty()){
  168. top.alert("请输入折扣", 0, function(){
  169. $("input[name='discount']").focus();
  170. });
  171. return false;
  172. }
  173. data.saleStatus = $('input:radio[name="saleStatus"]:checked').val() || -1;
  174. if (data['saleStatus'] == -1){
  175. top.alert("请选择售卖状态");
  176. return false;
  177. }
  178. if (!data['customer'].isEmpty() && data['customer'].length > 20){
  179. top.alert("“已售客户”长度不可超过20");
  180. return false;
  181. }
  182. if (!data['remarks'].isEmpty() && data['remarks'].length > 20){
  183. top.alert("“备注”长度不可超过20");
  184. return false;
  185. }
  186. // 提交数据
  187. top.ajax("save_resource_by_advertise.do", data, function(res){
  188. if (res.code == 1){
  189. top.alert("保存成功。", 1, function(){
  190. top.getList(1);
  191. top.$.closeWindow();
  192. });
  193. } else {
  194. top.alert(res.msg);
  195. }
  196. });
  197. }
  198. //确认覆盖
  199. function confirmCallback(repeat, msg) {
  200. if (repeat == 1){
  201. confirm(msg, function(){
  202. top.$("#isSure").val("sure");
  203. top.$("#fileForm").submit();
  204. });
  205. }
  206. }