pptnew.js 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. /**
  2. * Created by Administrator on 2018/1/3 0003.
  3. */
  4. function getparam(e) {
  5. e = e.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
  6. var t = "[\\?&]" + e + "=([^&#]*)", n = new RegExp(t), a = n.exec(window.location.search);
  7. return null == a ? "" : decodeURIComponent(a[1].replace(/\+/g, " "))
  8. }
  9. $(document).ready(function(){
  10. loadPage();
  11. $(".titleInput").val(" "+getparam("title"));
  12. $("#iUserLoginForm").submit(function () {
  13. $("#iUserLoginForm").ajaxSubmit({
  14. success: function (data) {
  15. if(data.status == "SUCCESS"){
  16. var htmlStr='';
  17. htmlStr='<div class="pptimgcontentDiv">'+
  18. '<img src="'+data.record.imgurl+'"/>';
  19. if(data.record.filepath == null || data.record.filepath== "javascript:void(0)"){
  20. htmlStr+= '<input type="text" value="" class="input_text" id="'+data.record.id+'" name="filepath">';
  21. }else{
  22. htmlStr+= '<input type="text" value="'+data.record.filepath+'" class="input_text" id="'+data.record.id+'" name="filepath">';
  23. }
  24. htmlStr+= '<button class="btn-self" onclick="toDelete(\''+data.record.id+'\',this)">删除</button>'+
  25. '</div>';
  26. $(".imgContent").prepend(htmlStr);
  27. $("#sc").prepend(","+data.record.id);
  28. if($(".pptimgcontentDiv").size()>=3){
  29. $(".pptimgcontentDivPlus").remove();
  30. }
  31. $("#iUserLogin").dialog("close");
  32. $("#img1").val("");
  33. }
  34. }
  35. });
  36. return false;
  37. });
  38. $("#iUserLogin").dialog({
  39. modal: true,
  40. autoOpen:false,
  41. closeable:false,
  42. bgiframe:true,
  43. height:300,
  44. width:500,
  45. closeOnEscape:false,
  46. draggable:false,
  47. resizable:false,
  48. title:"上传图片",
  49. open:function (event, ui) {
  50. $(".ui-dialog-titlebar-close").hide();
  51. },
  52. buttons:{
  53. "保存":function () {
  54. if($("#img1").val()==""){
  55. alert("上传图片不能为空!");
  56. return false;
  57. }
  58. document.getElementById("iUserLoginForm").action=" "+baseConfig.URL.addImgList + "";
  59. $("#iUserLoginForm").submit();
  60. },
  61. "关闭":function () {
  62. $(this).dialog("close");
  63. }
  64. }
  65. })
  66. });
  67. function loadPage(obj) {
  68. $.ajax({
  69. url: " "+baseConfig.URL.pptimgList + "",
  70. type: "POST",
  71. async: false,
  72. cache: false,
  73. data: {name:getparam("name")},
  74. success:function (data) {
  75. if(data.status=="SUCCESS"){
  76. $(".imgContent").html('');
  77. $("#sc").html('');
  78. $("#sc").html('');
  79. $.each(data.list,function (name,value){
  80. var htmlStr='';
  81. htmlStr='<div class="pptimgcontentDiv">'+
  82. '<img src="'+value.imgurl+'"/>';
  83. if(value.filepath == null || value.filepath == "javascript:void(0)"){
  84. htmlStr+= '<input type="text" value="" class="input_text" id="'+value.id+'" name="filepath">';
  85. }else{
  86. htmlStr+= '<input type="text" value="'+value.filepath+'" class="input_text" id="'+value.id+'" name="filepath">';
  87. }
  88. htmlStr+= '<button class="btn-self" onclick="toDelete(\''+value.id+'\',this)">删除</button>'+
  89. '</div>';
  90. $(".imgContent").append(htmlStr);
  91. $("#sc").prepend(","+value.id);
  92. });
  93. if (data.list.length<3){
  94. $(".imgContent").append('<div class="pptimgcontentDivPlus" onclick="showFileuploadDiv()">+</div>');
  95. }
  96. }
  97. }
  98. });
  99. }
  100. function toDelete(id,btn) {
  101. $.ajax({
  102. url: " "+baseConfig.URL.deleteList + "",
  103. type: "POST",
  104. async: false,
  105. cache: false,
  106. data: {id:id},
  107. success:function (data) {
  108. if(data.status=="SUCCESS"){
  109. if($(".pptimgcontentDivPlus")[0] == undefined ){
  110. $(".imgContent").append('<div class="pptimgcontentDivPlus" onclick="showFileuploadDiv()">+</div>');
  111. }
  112. $(btn).parent("div").remove();
  113. }
  114. }
  115. });
  116. }
  117. function toHrefPage() {
  118. if($(".titleInput").val()==""){
  119. alert("标题不能为空!");
  120. return;
  121. }
  122. var filePath="";
  123. var ids = $("#sc").text();
  124. var arr = ids.split(",");
  125. for(var i=0;i<arr.length;i++){
  126. if($("#"+arr[i]).val() ==""){
  127. if(i==0){
  128. filePath+="undefined";
  129. }else{
  130. filePath+=",undefined";
  131. }
  132. }else{
  133. if(i==0){
  134. filePath+=$("#"+arr[i]).val();
  135. }else{
  136. filePath+=","+$("#"+arr[i]).val();
  137. }
  138. }
  139. }
  140. location.href = baseConfig.URL.hrefPage + "?ids=" + ids+ "&title=" + $(".titleInput").val()+"&filePath="+filePath;
  141. }
  142. function showFileuploadDiv() {
  143. $("#name").val(getparam("name"));
  144. $("#iUserLogin").dialog("open");
  145. }