program_schedule.js 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. function getList(page){
  2. page = page || 1;
  3. var type = $("#type option:selected").val();
  4. var pageSize = 10, data = {
  5. "platformName" : $("#platformName").val(),
  6. "type" : ( type == "" ? "" : type),
  7. "pageNo" : page,
  8. "pageSize" : pageSize
  9. }, html = "";
  10. $("#page, #list,#count").empty();
  11. ajax("ajax_program_schedule_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>'+item.platformName+'</td>'+
  17. '<td>'+(item.updDate ? new Date(item.updDate.time).Format("yyyy年MM月dd日"):"")+'</td>'+
  18. '<td>'+ (item.type == 1 ? "剧编及备播" :item.type == 2 ? "剧排进程" : item.type == 3 ? "节目编排" : "-") + '</td>'+
  19. '<td class="nop">'+(item.imgUrl ? '<img id="'+item.imgUrl+'" src="'+item.imgUrl.toNull()+'" onclick="showimg(\''+item.imgUrl+'\')" width="98" height="58" valign="middle" onerror="this.src=\'static/img/noimg.jpg\';" />':'&nbsp;')+'</td>'+
  20. '<td>'+(item.crtTime ? new Date(item.crtTime.time).Format("yyyy年MM月dd日 hh:mm"):"")+'</td>'+
  21. '<td>'+item.sortNum.toString().decode("","-",item.sortNum)+'</td>'+
  22. '<td><a href="'+item.associatedFile+'" style="color: #65AAFF" target="_blank">'+item.associatedFileName+'</a></td>'+
  23. '<td>'+item.crtUname.toString().decode("","-",item.crtUname)+'</td>'+
  24. '<td class="edit">'+
  25. (update_flag == 1 ? '<a href="javascript:platformModfiy(\'edit\',\'节目编排信息\','+item.id+');">编辑</a>&nbsp;&nbsp;' : '<br />') +
  26. (delete_flag == 1 ? '<a href="javascript:delRecord('+item.id+');">删除</a>' : '<br />' ) +
  27. '</td>'+
  28. '</tr>';
  29. });
  30. $("#list").html(html);
  31. $.checkbox();
  32. $("#count").text(res.count);
  33. $("#curPage").val(page);
  34. var newpage = new createPage(res.count, page, pageSize, 3);
  35. $("#page").html(newpage.pageHtml);
  36. } else {
  37. $("#list").info("暂无数据。");
  38. }
  39. });
  40. }
  41. pageGo = getList;
  42. // 删除单个
  43. function delRecord(id){
  44. confirm("确定删除该条记录吗?", function(){
  45. ajax("delete_program_schedule.do", {"id" : id}, function(res){
  46. if (res.code == 1){
  47. alert("删除成功。", 1, function(){
  48. window.location.href = "program_schedule_list.do";
  49. });
  50. } else {
  51. alert(res.msg);
  52. }
  53. });
  54. });
  55. }
  56. // 删除多个
  57. function delRecordBatch(){
  58. var arr = document.getElementsByName("chk");
  59. var ids = "";
  60. for (i=0; i<arr.length; i++){
  61. if (arr[i].checked){
  62. ids += ("," + arr[i].value);
  63. }
  64. }
  65. if (ids.isEmpty()){
  66. alert("请至少选择一条记录");
  67. return false;
  68. }
  69. confirm("确定删除这些记录吗?", function(){
  70. ajax("batch_del_for_program_schedule.do", {"ids" : ids.substring(1,ids.length)}, function(res){
  71. if (res.code == 1){
  72. alert("删除成功。", 1, function(){
  73. top.getList(1);
  74. });
  75. } else {
  76. alert(res.msg);
  77. }
  78. });
  79. });
  80. }
  81. // 导入表格数据
  82. function importExcel(obj){
  83. $("#fileForm").submit();
  84. }
  85. // 导入结果
  86. function excelCallback(code, msg) {
  87. if (code == 1) {
  88. // 导入成功
  89. alert("导入成功。", 1, function(){
  90. location.reload();
  91. });
  92. } else {
  93. // 导入失败
  94. alert(msg);
  95. }
  96. }
  97. function fileCallback(code,msg,name,url){
  98. if (code == 1) {
  99. // 上传成功
  100. top.alert("上传成功。", 1, function(){
  101. window.top.minWindow.$("#fileName").text(name);
  102. window.top.minWindow.$("#associatedFileName").val(name);
  103. window.top.minWindow.$("#associatedFile").val(url);
  104. });
  105. } else {
  106. // 上传失败
  107. top.alert(msg);
  108. }
  109. }
  110. // 保存资源信息
  111. function save(){
  112. // 得到数据
  113. var data = $('#dataForm').serializeJSON();
  114. data.id = $.getParam("id");
  115. data.type = $("select[name='type']>option:selected").val();
  116. data.imgUrl = $("#imgUrl")[0].src;
  117. data.associatedFile = $("#associatedFile").val();
  118. data.associatedFileName = $("#associatedFileName").val();
  119. console.log(data);
  120. // 数据是否完整
  121. if (data['type'].isEmpty()){
  122. top.alert("请选择类型", 0, function(){
  123. $("input[name='type']").focus();
  124. });
  125. return false;
  126. }
  127. if (data['imgUrl'].isEmpty() || data['imgUrl'].indexOf("ylcm_sys") > 1){
  128. top.alert("请上传编排图");
  129. return false;
  130. }
  131. if (data['platformName'].isEmpty()){
  132. top.alert("请填写资源名称", 0, function(){
  133. $("input[name='platformName']").focus();
  134. });
  135. return false;
  136. }
  137. if (data['updDate'].isEmpty()){
  138. top.alert("请选择更新时间", 0, function(){
  139. $("input[name='updDate']").focus();
  140. });
  141. return false;
  142. }
  143. if (data['sortNum'].isEmpty()){
  144. top.alert("请填写排序号", 0, function(){
  145. $("input[name='sortNum']").focus();
  146. });
  147. return false;
  148. }
  149. if(isNaN(data['sortNum'])){
  150. top.alert("排序号请输入数字");
  151. return false;
  152. }
  153. // 提交数据
  154. top.ajax("save_program_schedule_info.do", data, function(res){
  155. if (res.code == 1){
  156. top.alert("保存成功。", 1, function(){
  157. top.getList($("#curPage").val());
  158. top.$.closeWindow();
  159. });
  160. } else {
  161. top.alert(res.msg);
  162. }
  163. });
  164. }
  165. // 弹窗
  166. function platformModfiy(act, title, id){
  167. title = title || "";
  168. id = id || "";
  169. $.openWindow(act.decode("add","新增","edit","修改","")+title, "program_schedule_info.do?id="+id, 500, 470, true);
  170. }
  171. function showimg(imgurl){
  172. var url = document.getElementById(imgurl).src;
  173. if(url!='' && url!='http://localhost:8080/ylcm_sys/static/img/noimg.jpg' && url != "http://121.41.17.212:8080/ylcm_sys/static/img/noimg.jpg"){
  174. var newwin=window.open();
  175. var w = document.documentElement.scrollWidth || document.body.scrollWidth ;
  176. var h = document.documentElement.scrollHeight || document.body.scrollHeight ;
  177. newwin.document.write("<img src="+url+" width='"+w+"' height='"+h+"' />");
  178. // var html = '<img src='+url+' width="480px" height="380px" />';
  179. // $.openWindow(" ",html,500,380,false);
  180. }
  181. }
  182. //确认覆盖
  183. function confirmCallback(repeat, msg) {
  184. if (repeat == 1){
  185. confirm(msg, function(){
  186. top.$("#isSure").val("sure");
  187. top.$("#fileForm").submit();
  188. });
  189. }
  190. }