other.js 6.7 KB

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