policynewsnoticeaddnews.js 7.6 KB

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