noticeaddnews.js 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. /**
  2. * Created by 14381 on 2017/12/04.
  3. */
  4. var editor;
  5. $(document).ready(function() {
  6. editor=UE.getEditor('content', {
  7. toolbars: [
  8. ['bold', 'italic', 'underline', 'fontborder', 'strikethrough', 'superscript', 'subscript',
  9. 'removeformat', 'formatmatch', 'autotypeset', 'blockquote', 'pasteplain', '|', 'forecolor',
  10. 'backcolor', 'insertorderedlist', 'insertunorderedlist','simpleupload',
  11. 'selectall', 'cleardoc',
  12. 'justifyleft', 'justifyright','justifycenter', 'justifyjustify',
  13. 'fontfamily', 'fontsize', 'paragraph']
  14. ]
  15. });
  16. $("#qa_form").submit(function () {
  17. var flad = checkForm();
  18. if(!flad){
  19. return false;
  20. }
  21. $("#changeTJ").attr("style","display: none");
  22. $("#addIJ").attr("style", "display: none");
  23. $("#projectBtn").attr("style", "margin: 20px;background: #f2a734;font-size: 14px;width: 110px");
  24. $("#qa_form").ajaxSubmit({
  25. success: function (data) {
  26. if(data.status == "SUCCESS"){
  27. Showbo.Msg.alert("操作成功");
  28. setTimeout('myrefresh()',1000); //指定1秒刷新一次
  29. } else if(data.status == "ERROR"){
  30. Showbo.Msg.alert("操作失败");
  31. var thisURL = document.URL
  32. var version = thisURL.substring(thisURL.indexOf('=') + 1);
  33. if (version == thisURL) {
  34. $("#changeTJ").attr("style", "display: none");
  35. $("#addIJ").attr("style", "margin: 20px;background: #f2a734;font-size: 14px;width: 110px");
  36. } else {
  37. $("#changeTJ").attr("style", "margin: 20px;background: #f2a734;font-size: 14px;width: 110px");
  38. $("#addIJ").attr("style", "display: none");
  39. }
  40. $("#projectBtn").attr("style", "display: none");
  41. } else if(data.status == "BEYOND"){
  42. Showbo.Msg.alert(data.desc);
  43. }
  44. },
  45. });
  46. return false;
  47. });
  48. typeSelectList($("#atype").val(),"atype",-1);
  49. getmanu();
  50. });
  51. function myrefresh(){
  52. window.location.href ="/iflytek/activitynews.html"
  53. }
  54. function getmanu() {
  55. var thisURL = document.URL
  56. var version = thisURL.substring(thisURL.indexOf('=') + 1);
  57. if (version == thisURL) {
  58. $("#changeTJ").attr("style", "margin: 20px;background: #f2a734;font-size: 14px;width: 110px;display: none");
  59. $("#addIJ").attr("style", "margin: 20px;background: #f2a734;font-size: 14px;width: 110px");
  60. } else {
  61. $("#changeTJ").attr("style", "margin: 20px;background: #f2a734;font-size: 14px;width: 110px");
  62. $("#addIJ").attr("style", "margin: 20px;background: #f2a734;font-size: 14px;width: 110px;display: none");
  63. }
  64. $("#changeid").val(version);
  65. $.ajax({
  66. url: " " + baseConfig.URL.findByid + "",
  67. type: "POST",
  68. async: false,
  69. cache: false,
  70. data: {id: version},
  71. success: function (data) {
  72. if (data.status == "SUCCESS") {
  73. $("#title").val(data.rec.title);
  74. $("#atype").val(data.rec.atype);
  75. $("#creattime").val(data.rec.creattime);
  76. $("#content").html(data.rec.content);
  77. typeSelectList("01","atype",data.rec.atype);
  78. var getfileurl = data.rec.fileurl;
  79. var imgurl = data.rec.imgurl;
  80. if (imgurl != null && imgurl != "") {
  81. var indeximg = imgurl.lastIndexOf("/");
  82. var fileimgname = imgurl.substr(indeximg + 1);
  83. $("#firstimg").val(fileimgname);
  84. }
  85. if (getfileurl != null && getfileurl != "") {
  86. var index = getfileurl.lastIndexOf("/");
  87. var filename = getfileurl.substr(index + 1);
  88. $("#other0").val(filename);
  89. }
  90. }
  91. }
  92. });
  93. }
  94. function addnoticenews() {
  95. document.getElementById("qa_form").action=" "+baseConfig.URL.addnews + "";
  96. $("#qa_form").submit();
  97. }
  98. function changenoticenews() {
  99. document.getElementById("qa_form").action=" "+baseConfig.URL.updatenews + "";
  100. $("#qa_form").submit();
  101. }
  102. function checkForm(){
  103. var content= editor.getContentTxt();
  104. if (content == "" || content==null) {
  105. Showbo.Msg.alert("请填写内容!");
  106. return false;
  107. }
  108. if ($.trim($('#title').val()) == "" ||$('#title').val()==null) {
  109. Showbo.Msg.alert("请填写标题!");
  110. return false;
  111. }
  112. if ($.trim($('#atype').val()) == "" ||$('#atype').val()==null) {
  113. Showbo.Msg.alert("请选择分类!");
  114. return false;
  115. }
  116. return true;
  117. }
  118. var count = 0;
  119. var num = 0;
  120. function PreviewImage(imgFile) {
  121. var length = $("#sc").children("div").length;
  122. if(length >=6){
  123. $("#csgo1").html("附件只可以上传5张");
  124. $("#csgo0").attr("style", "display:block");
  125. return false;
  126. }
  127. //定义路径var path;
  128. var name= $(imgFile).val().split("\\").pop();
  129. document.getElementById("other"+count+"").style.display="none";
  130. //添加显示图片的HTML元素
  131. count += 1;
  132. $(".img-cont"+num).append("<input id='img"+count+"' width='220' height='110' value='"+name+"' " +
  133. " style='width:300px;border:none;' /><button onclick='del("+num+")' " +
  134. "style='background: #fff;color: #1d4795;height: 20px;padding: 0 20px;margin-left: 40px;'>删除</button>");
  135. num += 1;
  136. $("#sc").append(" <div class='img-cont"+num+" img_up ad-btn'><input style='color: #fff;border:none;' " +
  137. "type='file' name='other"+count+"' id='other"+count+"' class='upload-input' onchange='PreviewImage(this)'/>" +"</div>");
  138. }
  139. function del(cl) {
  140. $(".img-cont"+cl).remove();
  141. }
  142. function checkFileExt(filename)
  143. {
  144. var flag = false; //状态
  145. var arr = ["jpg","png","jpeg","bmp"];
  146. //取出上传文件的扩展名
  147. var index = filename.lastIndexOf(".");
  148. var ext = filename.substr(index+1);
  149. //循环比较
  150. for(var i=0;i<arr.length;i++)
  151. {
  152. if(ext == arr[i])
  153. {
  154. flag = true; //一旦找到合适的,立即退出循环
  155. break;
  156. }
  157. }
  158. //条件判断
  159. if(!flag){
  160. Showbo.Msg.alert("请上传正确的图片格式(jpg jpeg png bmp)!");
  161. return false;
  162. }
  163. }
  164. function onChangeSelect(){
  165. typeSelectList($("#atype").val(),"atype",-1);
  166. }
  167. function typeSelectList(fcode,objid,objval){//
  168. $.ajax({
  169. url: baseConfig.URL.selectType + "",
  170. type: "POST",
  171. data:{fcode:fcode},
  172. cache: false,
  173. success:function (res) {
  174. var options = "";
  175. $.each(res.selectList, function (i, value) {
  176. options += "<option value=\"" + value.code + "\">" +value.name + "</option>";
  177. });
  178. $("#"+objid).html(options);
  179. if(objval!=-1){
  180. $("#"+objid).val(objval);
  181. }
  182. delete options;
  183. },
  184. complete:function (XHR, TS) {
  185. // $('.ui-dialog-buttonpane').find('button:contains("保存添加信息")').removeAttr("disabled");
  186. },
  187. error:function (XMLHttpRequest, textStatus, errorThrown) {
  188. alert(textStatus);
  189. }
  190. });
  191. }