app.js 6.9 KB

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