short.js 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  1. // 获取表格数据
  2. function getShortList(page){
  3. page = page || 1;
  4. var pageSize = 10, data = {
  5. "name" : $("#shortName").val(),
  6. "saleStatus":$("#saleStatus").val(),
  7. "pageNo" : page,
  8. "pageSize" : pageSize
  9. }, html = "";
  10. $("#shortPage, #shortList,#shortCount").empty();
  11. ajax("ajax_resource_short_list.do", data, function(res){
  12. if (res.code == 1 && res.list.length > 0){
  13. $.each(res.list, function(index, item){
  14. html += '<tr>'+
  15. '<td><input type="checkbox" class="checkbox {click:itemCheck}" name="chk" value="'+item.id+'" /><label></label></td>'+
  16. '<td class="edit"><a href="to_resource_by_short_info.do?id='+item.id+'" target="_blank">'+item.name.toNull()+'</a></td>'+
  17. '<td>'+item.showTime.toNull()+'</td>'+
  18. '<td>'+item.registeredUser.toString().decode("0","-",item.registeredUser)+'</td>'+
  19. '<td>'+item.downloads.toString().decode("0","-",item.downloads)+'</td>'+
  20. '<td>'+item.dailyActivity.toString().decode("0","-",item.dailyActivity)+'</td>'+
  21. '<td>'+item.monthlyActivity.toString().decode("0","-",item.monthlyActivity)+'</td>'+
  22. '<td>'+item.mediaLabel.toString().decode("","-",item.mediaLabel)+'</td>'+
  23. '<td>'+item.advertisementForm.toString().decode("","-",item.advertisementForm)+'</td>'+
  24. '<td>'+item.systemPlatform.toString().decode("","-",item.systemPlatform)+'</td>'+
  25. '<td>'+item.displayMode.toString().decode("","-",item.displayMode)+'</td>'+
  26. '<td>'+item.cpx.toString().decode("","-",item.cpx)+'</td>'+
  27. '<td>'+item.price+'</td>'+
  28. '<td>'+item.saleStatus.toString().decode("0","在售", "1","已售","")+'</td>'+
  29. '<td>'+item.customer.toString().decode("","-",item.customer)+'</td>'+
  30. '<td>'+item.remarks.toString().decode("","-",item.remarks)+'</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:delRecord('+item.id+');">删除</a>' : '' ) +
  34. '</td>'+
  35. '</tr>';
  36. });
  37. $("#shortList").html(html);
  38. $.checkbox();
  39. $("#shortCount").text(res.count);
  40. $("#curShortPage").val(page);
  41. var newpage = new createPage(res.count, page, pageSize, 3);
  42. $("#shortPage").html(newpage.pageHtml);
  43. } else {
  44. $("#shortCount").text(0);
  45. $("#curShortPage").val(page);
  46. var newpage = new createPage(0, page, pageSize, 3);
  47. $("#shortPage").html(newpage.pageHtml);
  48. $("#shortList").info("暂无数据");
  49. }
  50. });
  51. }
  52. pageGo = function(page){
  53. resetCheckAll();
  54. getShortList(page);
  55. }
  56. // 删除单个
  57. function delRecord(id){
  58. confirm("确定删除该条记录吗?", function(){
  59. ajax("delete_resource_short.do", {"id" : id}, function(res){
  60. if (res.code == 1){
  61. alert("删除成功", 1, function(){
  62. window.location.reload();
  63. });
  64. } else {
  65. alert(res.msg);
  66. }
  67. });
  68. });
  69. }
  70. // 导入表格数据
  71. function importShortExcel(obj){
  72. $("#shortFileForm").submit();
  73. }
  74. // 导入结果
  75. function excelCallback(code, msg) {
  76. if (code == 1) {
  77. // 导入成功
  78. alert("导入成功。", 1, function(){
  79. location.reload();
  80. });
  81. } else {
  82. // 导入失败
  83. alert(msg, 0, function(){
  84. location.reload();
  85. });
  86. }
  87. }
  88. // 保存短视频资源信息
  89. function saveShort(){
  90. // 得到数据
  91. var data = $('#dataForm').serializeJSON();
  92. data.id = $.getParam("id");
  93. // 数据是否完整
  94. if (data['name'].isEmpty()){
  95. top.alert("请输入资源名称", 0, function(){
  96. $("input[name='name']").focus();
  97. });
  98. return;
  99. }
  100. if (data['showTime'].isEmpty()){
  101. top.alert("请输入时间", 0, function(){
  102. $("input[name='showTime']").focus();
  103. });
  104. return;
  105. }
  106. if (!isNaN(data['registeredUser'])){
  107. if (parseInt(data['registeredUser']) < 0 || parseInt(data['registeredUser']) > 99999.999){
  108. top.alert("数据范围错误!注册用户应为 0~99999.999");
  109. return;
  110. }
  111. }else if(isNaN(data['registeredUser'])){
  112. top.alert("注册用户请输入数字");
  113. return;
  114. }
  115. if (!isNaN(data['downloads'])){
  116. if (parseInt(data['downloads']) < 0 || parseInt(data['downloads']) > 99999.999){
  117. top.alert("数据范围错误!下载量应为 0~99999.999");
  118. return;
  119. }
  120. }else if(isNaN(data['downloads'])){
  121. top.alert("下载量请输入数字");
  122. return;
  123. }
  124. if (!isNaN(data['dailyActivity'])){
  125. if (parseInt(data['dailyActivity']) < 0 || parseInt(data['dailyActivity']) > 99999.999){
  126. top.alert("数据范围错误!日活应为 0~99999.999");
  127. return;
  128. }
  129. }else if(isNaN(data['dailyActivity'])){
  130. top.alert("日活请输入数字");
  131. return;
  132. }
  133. if (!isNaN(data['monthlyActivity'])){
  134. if (parseInt(data['monthlyActivity']) < 0 || parseInt(data['monthlyActivity']) > 99999.999){
  135. top.alert("数据范围错误!月活应为 0~99999.999");
  136. return;
  137. }
  138. }else if(isNaN(data['monthlyActivity'])){
  139. top.alert("月活请输入数字");
  140. return;
  141. }
  142. if (data['price'].isEmpty()){
  143. top.alert("请输入刊例价格", 0, function(){
  144. $("input[name='price']").focus();
  145. });
  146. return;
  147. }
  148. if(isNaN(data['price'])){
  149. top.alert("刊例价铬请输入数字");
  150. return;
  151. }
  152. if (!isNaN(data['price'])){
  153. if (parseInt(data['price']) < 0 || parseInt(data['price']) > 99999999.99){
  154. top.alert("数据范围错误!刊例价格应为 0~99999999.99");
  155. return;
  156. }
  157. }
  158. if(!document.getElementById("saleStatus1").checked&&
  159. !document.getElementById("saleStatus2").checked){
  160. top.alert("请选择售卖状态")
  161. return;
  162. }
  163. // 提交数据
  164. top.ajax("save_resource_short_info.do", data, function(res){
  165. if (res.code == 1){
  166. top.alert("保存成功", 1, function(){
  167. if(res.curPage==1){
  168. top.getShortList(1);
  169. }else {
  170. top.getShortList($.getParam("curPage"));
  171. }
  172. top.$.closeWindow();
  173. });
  174. } else {
  175. top.alert(res.msg);
  176. }
  177. });
  178. }
  179. // 弹窗
  180. function platformModfiy(act, title, id){
  181. title = title || "";
  182. id = id || "";
  183. $.openWindow(act.decode("add","新增","edit","修改","")+title, "ad_resources_short_info.do?id="+id+"&curPage="+$("#curShortPage").val(), 500, 470, true, null, true);
  184. }
  185. //确认覆盖
  186. function confirmCallback(repeat, msg) {
  187. if (repeat == 1){
  188. confirm(msg, function(){
  189. top.$("#isSure").val("sure");
  190. top.$("#shortFileForm").submit();
  191. });
  192. }
  193. }
  194. //删除多个
  195. function delShortBatch(){
  196. var arr = document.getElementsByName("chk");
  197. var ids = "";
  198. for (i=0; i<arr.length; i++){
  199. if (arr[i].checked){
  200. ids += ("," + arr[i].value);
  201. }
  202. }
  203. if (ids.isEmpty()){
  204. alert("请至少选择一条记录");
  205. return false;
  206. }
  207. confirm("确定删除这些记录吗?", function(){
  208. ajax("del_batch_resource_by_short.do", {"ids" : ids.substring(1,ids.length)}, function(res){
  209. if (res.code == 1){
  210. alert("删除成功。", 1, function(){
  211. top.getShortList(1);
  212. });
  213. } else {
  214. alert(res.msg);
  215. }
  216. });
  217. });
  218. }