portal html css js resource

cmp-updateinfo.js 13KB

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