companyAdd.js 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. /**
  2. * Created by Administrator on 2018/1/4 0004.
  3. */
  4. var editor;
  5. var flag=true;
  6. $(document).ready(function() {
  7. editor=UE.getEditor('content', {
  8. toolbars: [
  9. ['bold', 'italic', 'underline', 'fontborder', 'strikethrough', 'superscript', 'subscript',
  10. 'removeformat', 'formatmatch', 'autotypeset', 'blockquote', 'pasteplain', '|', 'forecolor',
  11. 'backcolor', 'insertorderedlist', 'insertunorderedlist','simpleupload', 'selectall', 'cleardoc',
  12. 'justifyleft', 'justifyright','justifycenter', 'justifyjustify',
  13. 'fontfamily', 'fontsize', 'paragraph']
  14. // [//工具条
  15. // 'fullscreen', 'source', 'undo', 'redo', 'bold', 'italic',
  16. // 'underline','fontborder', 'backcolor', 'fontsize', 'fontfamily',
  17. // 'justifyleft', 'justifyright','justifycenter', 'justifyjustify',
  18. // 'strikethrough','superscript', 'subscript', 'removeformat',
  19. // 'formatmatch','autotypeset', 'blockquote', 'pasteplain', '|',
  20. // 'forecolor', 'backcolor','insertorderedlist', 'insertunorderedlist',
  21. // 'selectall', 'cleardoc', 'link', 'unlink','emotion', 'help'
  22. // ]
  23. ]
  24. });
  25. var id =getQueryString("id");
  26. if(id != "add"){
  27. flag=false;
  28. findone(id);
  29. }
  30. $("#qa_form").submit(function () {
  31. var flad = checkForm();
  32. if(!flad){
  33. return false;
  34. }
  35. $("#addBtn").attr("style","display: none");
  36. $("#projectBtn").attr("style", "margin: 20px;background: #f2a734;font-size: 14px;width: 110px");
  37. $("#qa_form").ajaxSubmit({
  38. success: function (data) {
  39. if(data.status == "SUCCESS"){
  40. Showbo.Msg.alert("操作成功");
  41. setTimeout('myrefresh()',1000); //指定1秒刷新一次
  42. window.location.href ="/iflytek/company.html";
  43. } else if(data.status == "ERROR"){
  44. Showbo.Msg.alert("操作失败");
  45. $("#projectBtn").attr("style","display: none");
  46. $("#addBtn").attr("style", "margin: 20px;background: #f2a734;font-size: 14px;width: 110px");
  47. }
  48. },
  49. });
  50. return false;
  51. });
  52. typeSelectList($("#btype").val(),"btype",-1);
  53. });
  54. function findone(id) {
  55. $.ajax({
  56. url: baseConfig.URL.companyById + "",
  57. type: "POST",
  58. data: {id:id},
  59. cache: false,
  60. success: function (data) {
  61. if(data.status == "SUCCESS"){
  62. var rec = data.rec;
  63. $("#id").val(rec.id);
  64. $("#title").val(rec.title);
  65. $("#btype").val(rec.btype);
  66. $("#synopsis").val(rec.synopsis);
  67. $("#id").val(rec.id);
  68. typeSelectList(rec.btype.substring(0,2),"btype",rec.btype.substring(0,4));
  69. typeSelectList(rec.btype.substring(0,4),"type",rec.btype);
  70. // console.log(rec.btype);
  71. $("input[name='shownews'][value='"+rec.shownews+"']").attr("checked",true);
  72. editor.ready(function(){
  73. editor.setContent(rec.content);
  74. });
  75. }
  76. }
  77. });
  78. }
  79. function myrefresh(){
  80. window.location.href ="/iflytek/company.html";
  81. }
  82. function addData() {
  83. if(flag){
  84. document.getElementById("qa_form").action=" "+baseConfig.URL.companyAdd + "";
  85. }else{
  86. document.getElementById("qa_form").action=" "+baseConfig.URL.companyUpd + "";
  87. }
  88. $("#qa_form").submit();
  89. }
  90. function checkForm(){
  91. var content= editor.getContentTxt();
  92. if (content == "" || content==null) {
  93. Showbo.Msg.alert("请填写公司详细内容!");
  94. return false;
  95. }
  96. if ($.trim($('#title').val()) == "" ||$('#title').val()==null) {
  97. Showbo.Msg.alert("请填写公告名称!");
  98. return false;
  99. }
  100. if ($.trim($('#synopsis').val()) == "" ||$('#synopsis').val()==null) {
  101. Showbo.Msg.alert("请填写公司简介!");
  102. return false;
  103. }
  104. return true;
  105. }
  106. //获取url参数
  107. function getQueryString(name) {
  108. var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
  109. var r = window.location.search.substr(1).match(reg);
  110. if (r != null) return unescape(r[2]); return null;
  111. }
  112. function checkFileExt(filename)
  113. {
  114. var flag = false; //状态
  115. var arr = ["jpg","png","jpeg","bmp"];
  116. //取出上传文件的扩展名
  117. var index = filename.lastIndexOf(".");
  118. var ext = filename.substr(index+1);
  119. //循环比较
  120. for(var i=0;i<arr.length;i++)
  121. {
  122. if(ext == arr[i])
  123. {
  124. flag = true; //一旦找到合适的,立即退出循环
  125. break;
  126. }
  127. }
  128. //条件判断
  129. if(!flag){
  130. Showbo.Msg.alert("请上传正确的图片格式(jpg jpeg png bmp)!");
  131. return false;
  132. }
  133. }
  134. function onChangeSelect(){
  135. typeSelectList($("#btype").val(),"type",-1);
  136. }
  137. function typeSelectList(fcode,objid,objval){
  138. $.ajax({
  139. url: baseConfig.URL.companyselectType + "",
  140. type: "get",
  141. data:{fcode:fcode},
  142. cache: false,
  143. success:function (res) {
  144. console.log(res);
  145. var options = "";
  146. $.each(res.selectList, function (i, value) {
  147. options += "<option value=\"" + value.code + "\">" +value.name + "</option>";
  148. });
  149. $("#"+objid).html(options);
  150. if(objval!=-1){
  151. $("#"+objid).val(objval);
  152. }
  153. delete options;
  154. },
  155. complete:function (XHR, TS) {
  156. // $('.ui-dialog-buttonpane').find('button:contains("保存添加信息")').removeAttr("disabled");
  157. },
  158. error:function (XMLHttpRequest, textStatus, errorThrown) {
  159. alert(textStatus);
  160. }
  161. });
  162. }