123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223 |
- // 获取表格数据
- function getAppList(page){
- page = page || 1;
- var pageSize = 10, data = {
- "name" : $("#appName").val(),
- "showTime" : $("#appShowTime").val(),
- "pageNo" : page,
- "pageSize" : pageSize
- }, html = "";
-
- $("#appPage, #appList,#appCount").empty();
- ajax("ajax_resource_app_list.do", data, function(res){
- if (res.code == 1 && res.list.length > 0){
- $.each(res.list, function(index, item){
- html += '<tr>'+
- '<td><input type="checkbox" class="checkbox {click:itemCheck}" name="chk" value="'+item.id+'" /><label></label></td>'+
- '<td class="edit"><a href="to_resource_by_app_info.do?id='+item.id+'" target="_blank">'+item.name.toNull()+'</a></td>'+
- '<td>'+item.showTime.toNull()+'</td>'+
- '<td>'+item.registeredUser.toString().decode("0","-",item.registeredUser)+'</td>'+
- '<td>'+item.downloads.toString().decode("0","-",item.downloads)+'</td>'+
- '<td>'+item.dailyActivity.toString().decode("0","-",item.dailyActivity)+'</td>'+
- '<td>'+item.monthlyActivity.toString().decode("0","-",item.monthlyActivity)+'</td>'+
- '<td>'+item.mediaLabel.toString().decode("","-",item.mediaLabel)+'</td>'+
- '<td>'+item.advertisementForm.toString().decode("","-",item.advertisementForm)+'</td>'+
- '<td>'+item.systemPlatform.toString().decode("","-",item.systemPlatform)+'</td>'+
- '<td>'+item.displayMode.toString().decode("","-",item.displayMode)+'</td>'+
- '<td>'+item.cpx.toString().decode("","-",item.cpx)+'</td>'+
- '<td>'+item.price+'</td>'+
- '<td>'+item.saleStatus.toString().decode("0","在售", "1","已售","")+'</td>'+
- '<td>'+item.customer.toString().decode("","-",item.customer)+'</td>'+
- '<td>'+item.remarks.toString().decode("","-",item.remarks)+'</td>'+
- '<td class="edit">'+
- (update_flag == 1 ? '<a href="javascript:platformModfiy(\'edit\',\'App资源信息\','+item.id+');">编辑</a> ' : '') +
- (delete_flag == 1 ? '<a href="javascript:delRecord('+item.id+');">删除</a>' : '' ) +
- '</td>'+
- '</tr>';
- });
- $("#appList").html(html);
- $.checkbox();
- $("#appCount").text(res.count);
- $("#curAppPage").val(page);
- var newpage = new createPage(res.count, page, pageSize, 3);
- $("#appPage").html(newpage.pageHtml);
- } else {
- $("#appList").info("暂无数据");
- }
- });
- }
- pageGo = function(page){
- resetCheckAll();
- getAppList(page);
- }
- // 删除单个
- function delRecord(id){
- confirm("确定删除该条记录吗?", function(){
- ajax("delete_resource_app.do", {"id" : id}, function(res){
- if (res.code == 1){
- alert("删除成功。", 1, function(){
- window.location.reload();
- });
- } else {
- alert(res.msg);
- }
- });
- });
- }
- // 导入表格数据
- function importAppExcel(obj){
- $("#appFileForm").submit();
- }
- // 导入结果
- function excelCallback(code, msg) {
- if (code == 1) {
- // 导入成功
- alert("导入成功。", 1, function(){
- location.reload();
- });
- } else {
- // 导入失败
- alert(msg, 0, function(){
- location.reload();
- });
- }
- }
- // 保存App资源信息
- function saveApp(){
- // 得到数据
- var data = $('#dataForm').serializeJSON();
- data.id = $.getParam("id");
- // 数据是否完整
- if (data['name'].isEmpty()){
- top.alert("请输入资源名称", 0, function(){
- $("input[name='name']").focus();
- });
- return;
- }
- if (data['showTime'].isEmpty()){
- top.alert("请输入时间", 0, function(){
- $("input[name='showTime']").focus();
- });
- return;
- }
- if (!isNaN(data['registeredUser'])){
- if (parseInt(data['registeredUser']) < 0 || parseInt(data['registeredUser']) > 99999.999){
- top.alert("数据范围错误!注册用户应为 0~99999.999");
- return;
- }
- }else if(isNaN(data['registeredUser'])){
- top.alert("注册用户请输入数字");
- return;
- }
- if (!isNaN(data['downloads'])){
- if (parseInt(data['downloads']) < 0 || parseInt(data['downloads']) > 99999.999){
- top.alert("数据范围错误!下载量应为 0~99999.999");
- return;
- }
- }else if(isNaN(data['downloads'])){
- top.alert("下载量请输入数字");
- return;
- }
- if (!isNaN(data['dailyActivity'])){
- if (parseInt(data['dailyActivity']) < 0 || parseInt(data['dailyActivity']) > 99999.999){
- top.alert("数据范围错误!日活应为 0~99999.999");
- return;
- }
- }else if(isNaN(data['dailyActivity'])){
- top.alert("日活请输入数字");
- return;
- }
- if (!isNaN(data['monthlyActivity'])){
- if (parseInt(data['monthlyActivity']) < 0 || parseInt(data['monthlyActivity']) > 99999.999){
- top.alert("数据范围错误!月活应为 0~99999.999");
- return;
- }
- }else if(isNaN(data['monthlyActivity'])){
- top.alert("月活请输入数字");
- return;
- }
- if (data['price'].isEmpty()){
- top.alert("请输入刊例价格", 0, function(){
- $("input[name='price']").focus();
- });
- return;
- }
- if(isNaN(data['price'])){
- top.alert("刊例价铬请输入数字");
- return;
- }
- if (!isNaN(data['price'])){
- if (parseInt(data['price']) < 0 || parseInt(data['price']) > 99999999.99){
- top.alert("数据范围错误!刊例价格应为 0~99999999.99");
- return;
- }
- }
- if(!document.getElementById("saleStatus1").checked&&
- !document.getElementById("saleStatus2").checked){
- top.alert("请选择售卖状态")
- return;
- }
-
- // 提交数据
- top.ajax("save_resource_app_info.do", data, function(res){
- if (res.code == 1){
- top.alert("保存成功。", 1, function(){
- if(res.curPage==1){
- top.getAppList(1);
- }else {
- top.getAppList($.getParam("curPage"));
- }
- top.$.closeWindow();
- });
- } else {
- top.alert(res.msg);
- }
- });
- }
- // 弹窗
- function platformModfiy(act, title, id){
- title = title || "";
- id = id || "";
- $.openWindow(act.decode("add","新增","edit","修改","")+title, "ad_resources_app_info.do?id="+id+"&curPage="+$("#curAppPage").val(), 500, 470, true, null, true);
- }
- //确认覆盖
- function confirmCallback(repeat, msg) {
- if (repeat == 1){
- confirm(msg, function(){
- top.$("#isSure").val("sure");
- top.$("#appFileForm").submit();
- });
- }
- }
- //删除多个
- function delAppBatch(){
- var arr = document.getElementsByName("chk");
- var ids = "";
- for (i=0; i<arr.length; i++){
- if (arr[i].checked){
- ids += ("," + arr[i].value);
- }
- }
- if (ids.isEmpty()){
- alert("请至少选择一条记录");
- return false;
- }
- confirm("确定删除这些记录吗?", function(){
- ajax("del_batch_resource_by_app.do", {"ids" : ids.substring(1,ids.length)}, function(res){
- if (res.code == 1){
- alert("删除成功。", 1, function(){
- top.getAppList(1);
- });
- } else {
- alert(res.msg);
- }
- });
- });
- }
|