play.js 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295
  1. // 获取表格数据-电视硬广
  2. function getList(page){
  3. page = page || 1;
  4. var pageSize = 10, data = {
  5. "name" : $("#name").val(),
  6. "channel" : $("#channel").val(),
  7. "showTime" : $("#showTime").val(),
  8. "showInterval" : $("#showInterval").val(),
  9. "customer" : $("#customer").val(),
  10. "form" : $("#form").val(),
  11. "sellStatus" : $("#sellStatus option:selected").val(),
  12. "pageNo" : page,
  13. "pageSize" : pageSize
  14. }, html = "";
  15. $("#page, #list, #count").empty();
  16. ajax("ajax_resource_list_by_play.do", data, function(res){
  17. if (res.code == 1 && res.list.length > 0){
  18. $.each(res.list, function(index, item){
  19. html += '<tr>'+
  20. '<td><input type="checkbox" class="checkbox {click:itemCheck}" name="chk" value="'+item.id+'" /><label></label></td>'+
  21. '<td>'+item.channel.toNull()+'</td>'+
  22. '<td class="edit"><a href="to_resource_by_play_info.do?id='+item.id+'" target="_blank">'+item.name.toNull()+'</a></td>'+
  23. '<td>'+item.type.toString().decode("1","电视剧", "2","综艺","3","栏目","4","其他","") +'</td>'+
  24. '<td>'+item.form.toNull()+'</td>'+
  25. '<td>'+item.showTime.toNull()+'</td>'+
  26. '<td>'+(item.category ? item.category.toNull() : "")+'</td>'+
  27. '<td>'+item.sellMode.toNull()+'</td>'+
  28. '<td>'+(item.price ? item.price : "")+'</td>'+
  29. '<td>'+(item.discount ? item.discount+'%' : '')+'</td>'+
  30. '<td>'+item.showInterval+'</td>'+
  31. '<td>'+item.sellStatus.toString().decode("0","在售", "1","已售","")+'</td>'+
  32. '<td>'+(item.customer ? item.customer : "")+'</td>'+
  33. '<td>'+(item.remarks ? 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><br / >' : '' ) +
  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. $("#list").html(html);
  42. $("#count").text(res.count);
  43. var newpage = new createPage(res.count, page, pageSize, 3);
  44. $("#page").html(newpage.pageHtml);
  45. $(".table").hoverTable(true);
  46. $.checkbox();
  47. } else {
  48. $("#list").info("暂无数据。");
  49. }
  50. });
  51. }
  52. pageGo = function(page){
  53. resetCheckAll();
  54. getList(page);
  55. }
  56. //广告形式
  57. function retForm(form){
  58. return form == undefined ? "" : form.replace(/1/,"节目冠名").replace(/2/,"特约播映").replace(/3/,"互动支持").replace(/4/,"合作伙伴").replace(/5/,"指定产品").replace(/6/,"指定用车").replace(/7/,"其他").replace(/\,/g,"、");
  59. }
  60. // 删除单个
  61. function delRecord(id){
  62. confirm("确定删除该条记录吗?", function(){
  63. ajax("del_resource_by_play.do", {"id" : id}, function(res){
  64. if (res.code == 1){
  65. alert("删除成功。", 1, function(){
  66. window.location.reload();
  67. });
  68. } else {
  69. alert(res.msg);
  70. }
  71. });
  72. });
  73. }
  74. //删除多个
  75. function delRecordBatch(){
  76. var arr = document.getElementsByName("chk");
  77. var ids = "";
  78. for (i=0; i<arr.length; i++){
  79. if (arr[i].checked){
  80. ids += ("," + arr[i].value);
  81. }
  82. }
  83. if (ids.isEmpty()){
  84. alert("请至少选择一条记录");
  85. return false;
  86. }
  87. confirm("确定删除这些记录吗?", function(){
  88. ajax("del_batch_resource_by_play.do", {"ids" : ids.substring(1,ids.length)}, function(res){
  89. if (res.code == 1){
  90. alert("删除成功。", 1, function(){
  91. window.location.href = "to_play_list.do";
  92. });
  93. } else {
  94. alert(res.msg);
  95. }
  96. });
  97. });
  98. }
  99. // 导入表格数据
  100. function importExcel(obj){
  101. $("#excelfileForm").submit();
  102. }
  103. // “importExcel”的执行结果
  104. function excelCallback(code, msg) {
  105. if (code == 1) {
  106. // 导入成功
  107. alert("导入成功。", 1, function(){
  108. window.location.href = "to_play_list.do";
  109. });
  110. } else {
  111. // 导入失败
  112. alert(msg, 0, function(){
  113. location.reload();
  114. });
  115. }
  116. }
  117. // to详情弹窗
  118. function platformModfiy(act, title, id){
  119. title = title || "";
  120. id = id || "";
  121. $.openWindow(act.decode("add","新增","edit","修改","")+title, "to_resource_by_play.do?id="+id, 500, 470, true, null, true);
  122. }
  123. // to资源评分
  124. function platformModfiyFormScore(resourceName){
  125. console.log("..."+resourceName);
  126. resourceName = resourceName || "";
  127. ajax("edit_permit_form_playscore.do", {"resourceName":resourceName}, function(res){
  128. if (res.code == 1){
  129. var uri = "to_resource_by_play_score.do?resourceName="+resourceName;
  130. uri = encodeURI(encodeURI(uri));
  131. $.openWindow("资源评价",uri , 500, 470, true, null, true);
  132. } else {
  133. alert(res.msg);
  134. }
  135. });
  136. }
  137. // 保存基本信息
  138. function saveInfo(){
  139. // 得到数据
  140. var data = $('#infoForm').serializeJSON();
  141. data.id = $.getParam("id");
  142. // 数据是否完整
  143. if (data['channel'].isEmpty()){
  144. top.alert("请输入播出频道", 0, function(){
  145. $("input[name='channel']").focus();
  146. });
  147. return false;
  148. }
  149. if (data['name'].isEmpty()){
  150. top.alert("请输入资源名称", 0, function(){
  151. $("input[name='name']").focus();
  152. });
  153. return false;
  154. }
  155. if (data['type'].isEmpty()){
  156. top.alert("请选择频道类型");
  157. return false;
  158. }
  159. if (data['form'].isEmpty()){
  160. top.alert("请选择广告形式");
  161. return false;
  162. }
  163. if (data['showTime'].isEmpty()){
  164. top.alert("请输入时间", 0, function(){
  165. $("input[name='showTime']").focus();
  166. });
  167. return false;
  168. }
  169. if (data['category'].isEmpty()){
  170. top.alert("请输入节目体裁", 0, function(){
  171. $("input[name='category']").focus();
  172. });
  173. return false;
  174. }
  175. if (data['sellMode'].isEmpty()){
  176. top.alert("请输入售卖状态", 0, function(){
  177. $("input[name='sellMode']").focus();
  178. });
  179. return false;
  180. }
  181. if (data['price'].isEmpty()){
  182. top.alert("请输入刊例价格", 0, function(){
  183. $("input[name='price']").focus();
  184. });
  185. return false;
  186. }
  187. if (data['discount'].isEmpty()){
  188. top.alert("请输入折扣", 0, function(){
  189. $("input[name='discount']").focus();
  190. });
  191. return false;
  192. }
  193. if (data['showInterval'].isEmpty()){
  194. top.alert("请输入客户类别", 0, function(){
  195. $("input[name='showInterval']").focus();
  196. });
  197. return false;
  198. }
  199. data.sellStatus = $('input:radio[name="sellStatus"]:checked').val() || -1;
  200. if (data['sellStatus'] == -1){
  201. top.alert("请选择售卖状态");
  202. return false;
  203. }
  204. if (!data['customer'].isEmpty() && data['customer'].length > 20){
  205. top.alert("“已售客户”长度不可超过20");
  206. return false;
  207. }
  208. if (!data['remarks'].isEmpty() && data['remarks'].length > 20){
  209. top.alert("“备注”长度不可超过20");
  210. return false;
  211. }
  212. // 提交数据
  213. top.ajax("save_resource_by_play.do", data, function(res){
  214. if (res.code == 1){
  215. top.alert("保存成功。", 1, function(){
  216. top.getList(1);
  217. top.$.closeWindow();
  218. });
  219. } else {
  220. top.alert(res.msg);
  221. }
  222. });
  223. }
  224. // 数据验证(验证通过返回 true)
  225. function dataVerificationFormScore(value2, text2, maxScore2){
  226. if (value2 == null || value2 === ""){
  227. top.alert("请给"+ text2 +"打分。");
  228. return false;
  229. }
  230. if (isNaN(value2)){
  231. top.alert("数据类型错误!"+ text2 +"的评分只能是数字,且为 0~"+ maxScore2);
  232. return false;
  233. }
  234. if (0 > parseInt(value2) || parseInt(value2) > maxScore2){
  235. top.alert("数据范围错误!"+ text2 +"的评分应为 0~"+ maxScore2);
  236. return false;
  237. }
  238. return true;
  239. }
  240. // 保存资源评价
  241. function saveScore(id,resourceName){
  242. // 得到数据
  243. var data = $('#scoreForm').serializeJSON();
  244. data.id = id || "";
  245. data.resourceName = resourceName || "";
  246. // 数据验证
  247. if (!dataVerificationFormScore(data['mIp'], "IP", 12)){
  248. return false;
  249. }
  250. if (!dataVerificationFormScore(data['mTheme'], "题材", 5)){return false;}
  251. if (!dataVerificationFormScore(data['mEpisode'], "集数", 3)){return false;}
  252. if (!dataVerificationFormScore(data['mSchedule'], "档期", 4)){return false;}
  253. if (!dataVerificationFormScore(data['mPlatform'], "平台", 15)){return false;}
  254. if (!dataVerificationFormScore(data['mFlow'], "预估流量", 10)){return false;}
  255. if (!dataVerificationFormScore(data['pActor'], "演员", 15)){return false;}
  256. if (!dataVerificationFormScore(data['pDirector'], "导演", 8)){return false;}
  257. if (!dataVerificationFormScore(data['pScriptwritter'], "编剧", 7)){return false;}
  258. if (!dataVerificationFormScore(data['pProduced'], "出品公司", 5)){return false;}
  259. if (!dataVerificationFormScore(data['pIssue'], "发行公司", 10)){return false;}
  260. if (!dataVerificationFormScore(data['sSimilar'], "同期竞剧", 3)){return false;}
  261. if (!dataVerificationFormScore(data['sDissem'], "前期宣发", 3)){return false;}
  262. // 提交数据
  263. top.ajax("save_resource_by_play_score.do", data, function(res){
  264. if (res.code == 1){
  265. top.alert("保存成功。", 1, function(){
  266. top.getList(1);
  267. top.$.closeWindow();
  268. });
  269. } else {
  270. top.alert(res.msg);
  271. }
  272. });
  273. }
  274. //确认覆盖
  275. function confirmCallback(repeat, msg) {
  276. if (repeat == 1){
  277. confirm(msg, function(){
  278. top.$("#isSure").val("sure");
  279. top.$("#excelfileForm").submit();
  280. });
  281. }
  282. }