long.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337
  1. // 获取表格数据
  2. function getLongList(page){
  3. page = page || 1;
  4. var pageSize = 10, data = {
  5. "name" : $("#longName").val(),
  6. "networkTv":$("#networkTv").val(),
  7. "sellStatus":$("#sellStatus").val(),
  8. "showTime":$("#showTime").val(),
  9. "showInterval" : $("#showInterval").val(),
  10. "customer" : $("#customer").val(),
  11. "pageNo" : page,
  12. "pageSize" : pageSize
  13. }, html = "";
  14. $("#longPage, #longList,#longCount").empty();
  15. ajax("ajax_resource_long_list.do", data, function(res){
  16. if (res.code == 1 && res.list.length > 0){
  17. $.each(res.list, function(index, item){
  18. html += '<tr>'+
  19. '<td><input type="checkbox" class="checkbox {click:itemCheck}" name="chk" value="'+item.id+'" /><label></label></td>'+
  20. '<td>'+item.networkTv.toNull()+'</td>'+
  21. '<td class="edit"><a href="to_resource_by_long_info.do?id='+item.id+'" target="_blank">'+item.name.toString().decode("","-",item.name)+'</a></td>'+
  22. '<td>'+item.type.toString().decode("1","电视剧","2","综艺","3","栏目","4","其他","-")+'</td>'+
  23. '<td>'+retIp(item.ip)+'</td>'+
  24. '<td>'+retForm(item.form)+'</td>'+
  25. '<td>'+item.showTime.toString().decode("","-",item.showTime)+'</td>'+
  26. '<td>'+item.category.toString().decode("","-",item.category)+'</td>'+
  27. '<td>'+item.sellMode.toString().decode("","-",item.sellMode)+'</td>'+
  28. '<td>'+item.price.toString().decode("","-",item.price)+'</td>'+
  29. '<td>'+item.discount.toString().decode("0","-",item.discount+"%")+'</td>'+
  30. '<td>'+item.showInterval.toString().decode("","-",item.showInterval)+'</td>'+
  31. '<td>'+item.sellStatus.toString().decode("0","在售", "1","已售","")+'</td>'+
  32. '<td>'+item.customer.toString().decode("","-",item.customer)+'</td>'+
  33. '<td>'+item.remarks.toString().decode("","-",item.remarks)+'</td>'+
  34. '<td class="edit">'+
  35. (update_flag == 1 ? '<a href="javascript:platformModfiy(\'edit\',\'长视频资源信息\','+item.id+');">编辑</a>&nbsp;&nbsp;' : '') +
  36. (delete_flag == 1 ? '<a href="javascript:delRecord('+item.id+');">删除</a>' : '' ) +
  37. (score_flag == 1&& 1 == item.type? '<a href="javascript:platformModfiyFormScore(\''+item.name+'\');">'+item.scoreId.toString().decode("0","评价", "已评")+'</a>': '') +
  38. '</td>'+
  39. '</tr>';
  40. });
  41. $("#longList").html(html);
  42. $.checkbox();
  43. $("#longCount").text(res.count);
  44. $("#curLongPage").val(page);
  45. var newpage = new createPage(res.count, page, pageSize, 3);
  46. $("#longPage").html(newpage.pageHtml);
  47. } else {
  48. $("#longList").info("暂无数据。");
  49. }
  50. });
  51. }
  52. pageGo = function(page){
  53. resetCheckAll();
  54. getLongList(page);
  55. }
  56. //ip
  57. function retIp(ip){
  58. return ip == undefined ? "-" : ip.toString().replace(/1/,"版权").replace(/2/,"自制").replace(/3/,"合作").replace(/0/,"-");
  59. }
  60. //广告形式
  61. function retForm(form){
  62. return form == undefined ? "-" : form.toString().replace(/1/,"节目冠名").replace(/2/,"特约播映").replace(/3/,"互动支持").replace(/4/,"合作伙伴").replace(/5/,"指定产品").replace(/6/,"指定用车").replace(/7/,"中插").replace(/8/,"创可贴").replace(/9/,"贴片").replace(/10/,"其他").replace(/\,/g,"、").replace(/''/,"-");
  63. }
  64. // 删除单个
  65. function delRecord(id){
  66. confirm("确定删除该条记录吗?", function(){
  67. ajax("delete_resource_long.do", {"id" : id}, function(res){
  68. if (res.code == 1){
  69. alert("删除成功。", 1, function(){
  70. window.location.reload();
  71. });
  72. } else {
  73. alert(res.msg);
  74. }
  75. });
  76. });
  77. }
  78. // 导入表格数据
  79. function importLongExcel(obj){
  80. $("#longFileForm").submit();
  81. }
  82. // 导入结果
  83. function excelCallback(code, msg) {
  84. if (code == 1) {
  85. // 导入成功
  86. alert("导入成功。", 1, function(){
  87. location.reload();
  88. });
  89. } else {
  90. // 导入失败
  91. alert(msg, 0, function(){
  92. location.reload();
  93. });
  94. }
  95. }
  96. // 保存长视频资源信息
  97. function saveLong(){
  98. // 得到数据
  99. var data = $('#infoForm').serializeJSON();
  100. console.log(data);
  101. data.id = $.getParam("id");
  102. // 数据是否完整
  103. if (data['networkTv'].isEmpty()){
  104. top.alert("请输入播出频道", 0, function(){
  105. $("input[name='networkTv']").focus();
  106. });
  107. return;
  108. }
  109. if (data['name'].isEmpty()){
  110. top.alert("请输入资源名称", 0, function(){
  111. $("input[name='name']").focus();
  112. });
  113. return;
  114. }
  115. if(!document.getElementById("type1").checked&&
  116. !document.getElementById("type2").checked&&
  117. !document.getElementById("type3").checked&&
  118. !document.getElementById("type4").checked){
  119. top.alert("请选择资源类型")
  120. return;
  121. }
  122. if(!document.getElementById("ip1").checked&&
  123. !document.getElementById("ip2").checked&&
  124. !document.getElementById("ip3").checked){
  125. top.alert("请选择IP归属")
  126. return;
  127. }
  128. if(!document.getElementById("form1").checked&&
  129. !document.getElementById("form2").checked&&
  130. !document.getElementById("form3").checked&&
  131. !document.getElementById("form4").checked&&
  132. !document.getElementById("form5").checked&&
  133. !document.getElementById("form6").checked&&
  134. !document.getElementById("form7").checked&&
  135. !document.getElementById("form8").checked&&
  136. !document.getElementById("form9").checked&&
  137. !document.getElementById("form10").checked){
  138. top.alert("请选择广告形式")
  139. return;
  140. }
  141. if (data['showTime'].isEmpty()){
  142. top.alert("请输入时间", 0, function(){
  143. $("input[name='showTime']").focus();
  144. });
  145. return;
  146. }
  147. if (data['sellMode'].isEmpty()){
  148. top.alert("请输入售卖方式", 0, function(){
  149. $("input[name='sellMode']").focus();
  150. });
  151. return;
  152. }
  153. if (data['price'].isEmpty()){
  154. top.alert("请输入刊例价格", 0, function(){
  155. $("input[name='price']").focus();
  156. });
  157. return;
  158. }
  159. if(isNaN(data['price'])){
  160. top.alert("刊例价铬请输入数字");
  161. return;
  162. }
  163. if (!isNaN(data['price'])){
  164. if (parseInt(data['price']) < 0 || parseInt(data['price']) > 99999999.99){
  165. top.alert("数据范围错误!刊例价格应为 0~99999999.99");
  166. return;
  167. }
  168. }
  169. if(!document.getElementById("sellStatus1").checked&&
  170. !document.getElementById("sellStatus2").checked){
  171. top.alert("请选择售卖状态")
  172. return;
  173. }
  174. if(!data['discount'].isEmpty()){
  175. if(isNaN(data['discount'])){
  176. top.alert("折扣请输入数字");
  177. return;
  178. }
  179. }
  180. // 提交数据
  181. top.ajax("save_resource_long_info.do", data, function(res){
  182. if (res.code == 1){
  183. top.alert("保存成功", 1, function(){
  184. if(res.curPage==1){
  185. top.getLongList(1);
  186. }else {
  187. top.getLongList($.getParam("curPage"));
  188. }
  189. top.$.closeWindow();
  190. });
  191. } else {
  192. top.alert(res.msg);
  193. }
  194. });
  195. }
  196. // 弹窗
  197. function platformModfiy(act, title, id){
  198. title = title || "";
  199. id = id || "";
  200. $.openWindow(act.decode("add","新增","edit","修改","")+title, "ad_resources_long_info.do?id="+id+"&curPage="+$("#curLongPage").val(), 500, 470, true, null, true);
  201. }
  202. //数据验证
  203. function dataVerificationFormScore(value, text, maxScore){
  204. if (value == null || value === ""){
  205. top.alert("请给"+ text +"打分。");
  206. return false;
  207. }
  208. console.log(text+":"+value);
  209. if (isNaN(value)){
  210. top.alert("数据类型错误!"+ text +"的评分只能是数字,且为 0~"+ maxScore);
  211. return false;
  212. }
  213. if (0 > parseInt(value) || parseInt(value) > maxScore){
  214. top.alert("数据范围错误!"+ text +"的评分应为 0~"+ maxScore);
  215. return false;
  216. }
  217. return true;
  218. }
  219. //保存资源评价
  220. function saveScore(id,resourceName){
  221. // 得到数据
  222. var data = $('#scoreForm').serializeJSON();
  223. data.id = id || "";
  224. data.resourceName = resourceName;
  225. // 数据验证
  226. if(!dataVerificationFormScore(data['mIp'], 'IP', 12)){
  227. return;
  228. }
  229. if(!dataVerificationFormScore(data['mTheme'], '题材', 5)){
  230. return;
  231. }
  232. if(!dataVerificationFormScore(data['mEpisode'], '集数', 3)){
  233. return;
  234. }
  235. if(!dataVerificationFormScore(data['mSchedule'], '档期', 4)){
  236. return;
  237. }
  238. if(!dataVerificationFormScore(data['mPlatform'], '平台', 15)){
  239. return;
  240. }
  241. if(!dataVerificationFormScore(data['mFlow'], '预估流量', 10)){
  242. return;
  243. }
  244. if(!dataVerificationFormScore(data['pActor'], '演员', 15)){
  245. return;
  246. }
  247. if(!dataVerificationFormScore(data['pDirector'], '导演', 8)){
  248. return;
  249. }
  250. if(!dataVerificationFormScore(data['pScriptwritter'], '编剧', 7)){
  251. return;
  252. }
  253. if(!dataVerificationFormScore(data['pProduced'], '出品公司', 5)){
  254. return;
  255. }
  256. if(!dataVerificationFormScore(data['pIssue'], '发行公司', 10)){
  257. return;
  258. }
  259. if(!dataVerificationFormScore(data['sSimilar'], '同期竞剧', 3)){
  260. return;
  261. }
  262. if(!dataVerificationFormScore(data['sDissem'], '前期宣发', 3)){
  263. return;
  264. }
  265. // 提交数据
  266. top.ajax("save_resource_by_long_score.do", data, function(res){
  267. if (res.code == 1){
  268. top.alert("保存成功。", 1, function(){
  269. top.getLongList(1);
  270. top.$.closeWindow();
  271. });
  272. } else {
  273. top.alert(res.msg);
  274. }
  275. });
  276. }
  277. //to资源评分
  278. function platformModfiyFormScore(resourceName){
  279. resourceName = resourceName || "";
  280. console.log(resourceName);
  281. ajax("edit_permit_form_longscore.do", {"resourceName":resourceName}, function(res){
  282. if (res.code == 1){
  283. var uri = "to_resource_by_long_score.do?resourceName="+resourceName;
  284. uri = encodeURI(encodeURI(uri));
  285. $.openWindow("资源评价", uri, 500, 470, true, null, true);
  286. } else {
  287. alert(res.msg);
  288. }
  289. });
  290. }
  291. //确认覆盖
  292. function confirmCallback(repeat, msg) {
  293. if (repeat == 1){
  294. confirm(msg, function(){
  295. top.$("#isSure").val("sure");
  296. top.$("#longFileForm").submit();
  297. });
  298. }
  299. }
  300. //删除多个
  301. function delLongBatch(){
  302. var arr = document.getElementsByName("chk");
  303. var ids = "";
  304. for (i=0; i<arr.length; i++){
  305. if (arr[i].checked){
  306. ids += ("," + arr[i].value);
  307. }
  308. }
  309. if (ids.isEmpty()){
  310. alert("请至少选择一条记录");
  311. return false;
  312. }
  313. confirm("确定删除这些记录吗?", function(){
  314. ajax("del_batch_resource_by_long.do", {"ids" : ids.substring(1,ids.length)}, function(res){
  315. if (res.code == 1){
  316. alert("删除成功。", 1, function(){
  317. top.getLongList(1);
  318. });
  319. } else {
  320. alert(res.msg);
  321. }
  322. });
  323. });
  324. }