portal html css js resource

cmp-updateinfo.js 11KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356
  1. $(document).ready(function() {
  2. $(".onlogin .headnavbtn li").eq(0).addClass("navcurrent");
  3. var id = $.cookie('orgId');
  4. if(id == "" || id == null || id == "null"){
  5. location.href = "cmp-settled-log.html";
  6. }
  7. var fileId = null;
  8. var cacheImageKey = null;
  9. /*企业信息*/
  10. function companyInformation() {
  11. $.ajax({
  12. url: "/ajax/org/" + id,
  13. type: "GET",
  14. timeout: 10000,
  15. dataType: "json",
  16. beforeSend: function() {},
  17. success: function(data, textState) {
  18. if(data.success) {
  19. console.log(data);
  20. var $data = data.data;
  21. $(".h1Font").text($data.name);
  22. if($data.hasOrgLogo) {
  23. $("#oimg").attr("src", "/images/org/" + $data.id + ".jpg");
  24. }
  25. if($data.orgUrl) {
  26. $("#inteAddress").val($data.orgUrl);
  27. } else {
  28. $("#inteAddress").val("");
  29. }
  30. if($data.forShort) {
  31. $("#businessAbbreviation").val($data.forShort);
  32. } else {
  33. $("#businessAbbreviation").val("");
  34. }
  35. if($data.foundTime) {
  36. var oTime = timeGeshi($data.foundTime);
  37. $("#createTime").val(oTime);
  38. } else {
  39. $("#createTime").val("");
  40. }
  41. if($data.province) {
  42. $("#oprovince").text($data.province);
  43. } else {
  44. $("#oprovince").text("请选择企业总部所在省或直辖市");
  45. }
  46. if($data.city) {
  47. $("#ocity").text($data.city);
  48. } else {
  49. $("#ocity").text("请选择企业总部所在城市");
  50. }
  51. if($data.descp) {
  52. $("textarea").val($data.descp);
  53. }
  54. if($data.orgSize) {
  55. $("#qualificationList").val($data.orgSize)
  56. }
  57. if($data.orgType) {
  58. $("#orgType").val($data.orgType)
  59. }
  60. if($data.industry) {
  61. indu($data.industry, '#industryList')
  62. }
  63. if($data.subject) {
  64. indu($data.subject, '#subjectList')
  65. }
  66. if($data.qualification) {
  67. indu($data.qualification, '.editUlistC ')
  68. }
  69. //省份城市颜色
  70. if($("#oprovince").text()=="请选择企业总部所在省或直辖市"){
  71. $("#oprovince").removeClass("mr_select");
  72. }else{
  73. $("#oprovince").addClass("mr_select");
  74. }
  75. if($("#ocity").text()=="请选择企业总部所在城市"){
  76. $("#ocity").removeClass("mr_select");
  77. }else{
  78. $("#ocity").addClass("mr_select");
  79. }
  80. }
  81. },
  82. error: function(XMLHttpRequest, textStats, errorThrown) {
  83. $.MsgBox.Alert('提示', '服务器请求失败')
  84. }
  85. })
  86. }
  87. companyInformation()
  88. /*时间格式*/
  89. function timeGeshi(otm) {
  90. var otme = otm.substring(0, 4) + "-" + otm.substring(4, 6) + "-" + otm.substring(6, 8);
  91. return otme;
  92. }
  93. /*企业简介限制在500字内*/
  94. function limitFont(e) {
  95. var pastedText;
  96. if (window.clipboardData  &&  window.clipboardData.getData)  {  // IE
  97.             
  98. pastedText  = $("textarea").val() +  window.clipboardData.getData('Text');          
  99. else  {            
  100. pastedText  = $("textarea").val() +  e.originalEvent.clipboardData.getData('Text'); //e.clipboardData.getData('text/plain');
  101.           
  102. }
  103. $("textarea").val(pastedText.substring(0, 500));
  104. }
  105. $("textarea").bind({
  106. paste: function(e) {
  107. limitFont(e);
  108. setTimeout(function() {
  109. $(".limitNum").text($("textarea").val().length);
  110. }, 1);
  111. e.preventDefault();
  112. },
  113. cut: function(e) {
  114. setTimeout(function() {
  115. $(".limitNum").text($("textarea").val().length);
  116. }, 1);
  117. },
  118. keyup: function(e) {
  119. if($("textarea").val().length > 500) {
  120. $("textarea").val($("textarea").val().substring(0,500));
  121. e.preventDefault();
  122. }
  123. setTimeout(function() {
  124. $(".limitNum").text($("textarea").val().length);
  125. }, 1);
  126. }
  127. });
  128. /*应用行业及领域及企业资质*/
  129. function indu(oString, oSelector) {
  130. var arr = oString.split(",");
  131. var oArr = new Array();
  132. var i;
  133. for(i in arr) {
  134. oArr.push('<li>' + arr[i] + '<div class="closeThis"></div></li>');
  135. }
  136. $(oSelector).html(oArr.join(""));
  137. }
  138. /*删除*/
  139. $("body").on("click", ".closeThis", function() {
  140. $(this).parent().remove();
  141. })
  142. /*添加*/
  143. $("button:contains('添加')").click(function() {
  144. var oValue = $(this).siblings("input").val().trim();
  145. var oJudge = $(this).parent().siblings().find("ul.ulspace li");
  146. if(!oValue) {
  147. $.MsgBox.Alert('提示', '请先填写内容');
  148. return;
  149. }
  150. if(oValue.length > 10) {
  151. $.MsgBox.Alert('提示', '添加内容不能超过10个字');
  152. return;
  153. }
  154. for(var i = 0; i < oJudge.length; i++) {
  155. if(oValue == oJudge[i].innerText) {
  156. $.MsgBox.Alert('提示', '添加内容不能重复');
  157. return;
  158. }
  159. }
  160. $(this).parent().siblings().find("ul.ulspace").append('<li>' + oValue + '<div class="closeThis"></div></li>');
  161. $(this).siblings("input").val("");
  162. })
  163. /*保存*/
  164. $("button:contains('保存')").click(function() {
  165. var oBusinessAbbreviation = $("#businessAbbreviation").val().trim();
  166. if(!oBusinessAbbreviation) {
  167. $.MsgBox.Alert('提示', '企业简称不能为空');
  168. return;
  169. }
  170. if(oBusinessAbbreviation.length > 10) {
  171. $.MsgBox.Alert('提示', '企业简称不能超过10个字');
  172. return;
  173. }
  174. /*
  175. var oTextArea = $("textarea").val().trim();
  176. var oBusinessType = $("#orgType").find("option").length;
  177. var oBusinessDimensions = $("#qualificationList").find("li.cmpBg.listactive").length;
  178. var oIndustryNumber = $("#industryList").find("li").length;
  179. var oSubjectNumber = $("#subjectList").find("li").length;
  180. var oEditUlistCNumber = $(".editUlistC ").find("li").length;
  181. if(!oTextArea) {
  182. $.MsgBox.Alert('提示', '企业简介不能为空');
  183. return;
  184. }
  185. if(oBusinessType == 0) {
  186. $.MsgBox.Alert('提示', '请选择企业类型');
  187. return;
  188. }
  189. if(oIndustryNumber == 0) {
  190. $.MsgBox.Alert('提示', '企业所属行业必填一项');
  191. return;
  192. }
  193. if(oSubjectNumber == 0) {
  194. $.MsgBox.Alert('提示', '企业所属领域必填一项');
  195. return;
  196. }
  197. if(oBusinessDimensions == 0) {
  198. $.MsgBox.Alert('提示', '请选择企业规模');
  199. return;
  200. }
  201. if(oEditUlistCNumber == 0) {
  202. $.MsgBox.Alert('提示', '企业资质必填一项');
  203. return;
  204. }*/
  205. var $info = {};
  206. $info.id = id;
  207. if(cacheImageKey != null) {
  208. $info.fn = cacheImageKey;
  209. }
  210. $info.forShort = $("#businessAbbreviation").val();
  211. if($("#orgType").find("option:selected").text()!="请选择最符合的一项") {
  212. $info.orgType =$("#orgType").find("option:selected").text()
  213. }
  214. if($("#qualificationList").find("option:selected").text()!="请选择员工数量范围") {
  215. $info.orgSize = $("#qualificationList").find("option:selected").text();
  216. }
  217. if($("#inteAddress").val().trim()) {
  218. if($("#inteAddress").val().trim().length>20) {
  219. $.MsgBox.Alert('提示', '企业官网 20个字之内!');
  220. return;
  221. }
  222. $info.orgUrl = $("#inteAddress").val();
  223. }
  224. if($("#oprovince").text() != "请选择企业总部所在省或直辖市") {
  225. $info.province = $("#oprovince").text();
  226. }
  227. if($("#ocity").text() != "请选择企业总部所在城市") {
  228. $info.city = $("#ocity").text();
  229. }
  230. if($("#createTime").val()) {
  231. $info.foundTime = st6($("#createTime").val());
  232. }
  233. if($("#cmpAddress").val().trim()) {
  234. if($("#cmpAddress").val().trim().length>20) {
  235. $.MsgBox.Alert('提示', '企业地址 20个字之内!');
  236. return;
  237. }
  238. }
  239. $info.descp = $("textarea").val();
  240. $info.industry = oString("#industryList");
  241. $info.subject = oString("#subjectList");
  242. $info.qualification = oString(".editUlistC");
  243. $.ajax({
  244. url: "/ajax/org/update",
  245. type: "POST",
  246. data: $info,
  247. timeout: 10000,
  248. dataType: "json",
  249. beforeSend: function() {},
  250. success: function(data, textState) {
  251. if(data.success) {
  252. $.MsgBox.Alert('提示', '修改成功');
  253. $("#mb_msgicon").css("background", 'url("images/sign_icon_chenggong_nor.png") 0% 0% / contain');
  254. setTimeout(function(){
  255. location.reload(false)
  256. },500);
  257. }
  258. },
  259. error: function(XMLHttpRequest, textStats, errorThrown) {
  260. $.MsgBox.Alert('提示', '服务器请求失败')
  261. }
  262. })
  263. })
  264. /*应用行业,学术领域,企业纸质生成字符串*/
  265. function oString(sele) {
  266. var len = $(sele).find("li");
  267. var arry = new Array();
  268. for(var i = 0; i < len.length; i++) {
  269. arry.push(len[i].innerText);
  270. }
  271. return arry.join(",");
  272. }
  273. /*时间转换成6位传给后台*/
  274. function st6(osr) {
  275. var tim = osr.substring(0, 4) + osr.substring(5, 7) + osr.substring(8, 10);
  276. return tim;
  277. }
  278. /*企业图片上传*/
  279. var uploader = WebUploader.create({
  280. auto: true,
  281. fileNumLimit: 1,
  282. swf: '../js/webuploader/Uploader.swf',
  283. server: '../ajax/cachedFileUpload',
  284. fileSingleSizeLimit: 5 * 1024 * 1024,
  285. pick: {
  286. id: "#filePicker",
  287. multiple: false
  288. },
  289. accept: {
  290. title: 'Images',
  291. extensions: 'jpg,jpeg,png',
  292. mimeTypes: 'image/gif,image/jpg,image/jpeg,image/bmp,image/png'
  293. }
  294. });
  295. // 当有文件添加进来的时候
  296. uploader.on('fileQueued', function(file) {
  297. fileId = file.id;
  298. var $li = $('<div id="' + file.id + '" class="file-item thumbnail">' + '<img>' + '</div>')
  299. $img = $li.find('img');
  300. var $list = $('#fileList');
  301. /*//判断上传文件格式
  302. var fileNameAll = file.name;
  303. var AllImgExt = ".jpg|.jpeg|.png|";
  304. var extName = fileNameAll.substring(fileNameAll.lastIndexOf(".")).toLowerCase(); //(把路径中的所有字母全部转换为小写)
  305. if(AllImgExt.indexOf(extName + "|") == -1) {
  306. var ErrMsg = "该文件类型不允许上传。请上传 " + AllImgExt + " 类型的文件,当前文件类型为" + extName;
  307. $.MsgBox.Alert('提示', ErrMsg);
  308. return false;
  309. }*/
  310. });
  311. uploader.onError = function( code ) {
  312. $.MsgBox.Alert('提示', '请上传jpg、jpeg、png格式的图片,大小不超过5M')
  313. };
  314. uploader.on('uploadSuccess', function(file, data) {
  315. uploader.removeFile(fileId);
  316. cacheImageKey = data.data[0].cacheKey;
  317. $("#oimg").attr("src", "/images/tmp/" + cacheImageKey);
  318. });
  319. /*取消*/
  320. $("#Ocancel").click(function() {
  321. location.href="cmp-workspaces.html"
  322. })
  323. /*选择省份*/
  324. $(document).on("click", "#Province li a", function() {
  325. var aVal = $(this).text();
  326. $(this).parent().parent().parent().find('.mr_show').text(aVal);
  327. $(this).parent().parent().parent().find('input[name=cho_Province]').val(aVal);
  328. if($("#oprovince").text()=="请选择企业总部所在省或直辖市"){
  329. $("#oprovince").removeClass("mr_select");
  330. $("#ocity").removeClass("mr_select");
  331. }else{
  332. $("#oprovince").addClass("mr_select");
  333. $("#ocity").removeClass("mr_select");
  334. }
  335. });
  336. /*选择城市填充js */
  337. $(document).on("click", "#City li a", function() {
  338. var aVal = $(this).text();
  339. $(this).parent().parent().parent().find('.mr_show').text(aVal);
  340. $(this).parent().parent().parent().find('input[name=cho_City]').val(aVal);
  341. if($("#ocity").text()=="请选择企业总部所在城市"){
  342. $("#ocity").removeClass("mr_select");
  343. }else{
  344. $("#ocity").addClass("mr_select");
  345. }
  346. });
  347. })