portal html css js resource

cmp-updateinfo.js 15KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506
  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. if($data.fieldOfSupplier) {
  70. indu($data.fieldOfSupplier, '#subjectListOut')
  71. }
  72. if($data.fieldOfCustomer) {
  73. indu($data.fieldOfCustomer, '#subjectListIn')
  74. }
  75. if($data.addr) {
  76. $("#cmpAddress").val($data.addr);
  77. }
  78. if($data.contactNum) {
  79. $("#phone").val($data.contactNum);
  80. }
  81. if($data.email) {
  82. $("#mail").val($data.email);
  83. }
  84. //省份城市颜色
  85. if($("#oprovince").text() == "请选择企业总部所在省或直辖市") {
  86. $("#oprovince").removeClass("mr_select");
  87. } else {
  88. $("#oprovince").addClass("mr_select");
  89. }
  90. if($("#ocity").text() == "请选择企业总部所在城市") {
  91. $("#ocity").removeClass("mr_select");
  92. } else {
  93. $("#ocity").addClass("mr_select");
  94. }
  95. }
  96. },
  97. error: function(XMLHttpRequest, textStats, errorThrown) {
  98. $.MsgBox.Alert('提示', '服务器请求失败')
  99. }
  100. })
  101. }
  102. companyInformation()
  103. /*时间格式*/
  104. function timeGeshi(otm) {
  105. var otme = otm.substring(0, 4) + "-" + otm.substring(4, 6) + "-" + otm.substring(6, 8);
  106. return otme;
  107. }
  108. /*企业简介限制在500字内*/
  109. function limitFont(e) {
  110. var pastedText;
  111. if (window.clipboardData  &&  window.clipboardData.getData)  {  // IE
  112.             
  113. pastedText  = $("textarea").val() +  window.clipboardData.getData('Text');          
  114. else  {            
  115. pastedText  = $("textarea").val() +  e.originalEvent.clipboardData.getData('Text'); //e.clipboardData.getData('text/plain');
  116.           
  117. }
  118. $("textarea").val(pastedText.substring(0, 500));
  119. }
  120. $("textarea").bind({
  121. paste: function(e) {
  122. limitFont(e);
  123. setTimeout(function() {
  124. $(".limitNum").text($("textarea").val().length);
  125. }, 1);
  126. e.preventDefault();
  127. },
  128. cut: function(e) {
  129. setTimeout(function() {
  130. $(".limitNum").text($("textarea").val().length);
  131. }, 1);
  132. },
  133. keyup: function(e) {
  134. if($("textarea").val().length > 500) {
  135. $("textarea").val($("textarea").val().substring(0, 500));
  136. e.preventDefault();
  137. }
  138. setTimeout(function() {
  139. $(".limitNum").text($("textarea").val().length);
  140. }, 1);
  141. }
  142. });
  143. $(".oinput").bind({
  144. paste: function(e) {
  145. var pastedText;
  146. if (window.clipboardData  &&  window.clipboardData.getData)  {  // IE
  147.             
  148. pastedText  = $(this).val() +  window.clipboardData.getData('Text');          
  149. else  {            
  150. pastedText  = $(this).val() +  e.originalEvent.clipboardData.getData('Text'); //e.clipboardData.getData('text/plain');
  151.           
  152. }
  153. $(this).val(pastedText.substring(0, 10));
  154. var $this = $(this);
  155. setTimeout(function() {
  156. if($this.val().trim()) {
  157. $this.siblings("button").show();
  158. } else {
  159. $this.siblings("button").hide();
  160. }
  161. }, 1);
  162. e.preventDefault();
  163. },
  164. cut: function(e) {
  165. var $this = $(this);
  166. setTimeout(function() {
  167. if($this.val().trim()) {
  168. $this.siblings("button").show();
  169. } else {
  170. $this.siblings("button").hide();
  171. }
  172. }, 1);
  173. },
  174. blur:function(){
  175. var $this=$(this);
  176. setTimeout(function(){
  177. $this.siblings(".keydrop").hide();
  178. },500)
  179. },
  180. focus:function(){
  181. $(this).siblings(".keydrop").show();
  182. },
  183. keyup: function(e) {
  184. if($(this).val().trim()) {
  185. $(this).siblings("button").show();
  186. var lNum = $.trim($(this).val()).length;
  187. if(lNum > 10) {
  188. $(this).val($(this).val().substr(0, 10));
  189. } else if(0 < lNum && lNum < 10) {
  190. var $this = $(this)
  191. $("#addKeyword").show();
  192. $.ajax({
  193. "url": "/ajax/dataDict/qaHotKey",
  194. "type": "GET",
  195. "success": function(data) {
  196. console.log(data);
  197. if(data.success) {
  198. if(data.data.length == 0) {
  199. $this.siblings(".keydrop").addClass("displayNone");
  200. $this.siblings(".keydrop").find("ul").html("");
  201. } else {
  202. $this.siblings(".keydrop").removeClass("displayNone");
  203. var oSr = "";
  204. for(var i = 0; i < data.data.length; i++) {
  205. oSr += '<li>' + data.data[i].caption + '<div class="closeThis"></div></li>';
  206. }
  207. $this.siblings(".keydrop").find("ul").html(oSr);
  208. }
  209. } else {
  210. $this.siblings(".keydrop").addClass("displayNone");
  211. $this.siblings(".keydrop").find("ul").html("");
  212. }
  213. },
  214. "data": {
  215. "key": $(this).val()
  216. },
  217. dataType: "json",
  218. 'error': function() {
  219. $.MsgBox.Alert('提示', '服务器连接超时!');
  220. }
  221. });
  222. }
  223. } else {
  224. $(this).siblings("button").hide();
  225. $(this).siblings(".keydrop").addClass("displayNone");
  226. $(this).siblings(".keydrop").find("ul").html("");
  227. }
  228. }
  229. })
  230. $(".keydrop").on("click","li",function(){
  231. var oValue = $(this).text();
  232. var oJudge = $(this).parents(".col-w-12").siblings().find("ul.ulspace li");
  233. for(var i = 0; i < oJudge.length; i++) {
  234. if(oValue == oJudge[i].innerText) {
  235. $.MsgBox.Alert('提示', '添加内容不能重复');
  236. return;
  237. }
  238. }
  239. $(this).parents(".col-w-12").siblings().find("ul.ulspace").append('<li>' + oValue + '<div class="closeThis"></div></li>');
  240. $(this).parents(".keydrop").siblings("input").val("");
  241. if(oJudge.length == 4) {
  242. $(this).parents(".keydrop").siblings("input").val("");
  243. $(this).parents(".col-w-12").hide();
  244. }
  245. $(this).parent("ul").html("")
  246. })
  247. /*应用行业及领域及企业资质*/
  248. function indu(oString, oSelector) {
  249. var arr = oString.split(",");
  250. var oArr = new Array();
  251. var i;
  252. for(i in arr) {
  253. oArr.push('<li>' + arr[i] + '<div class="closeThis"></div></li>');
  254. }
  255. $(oSelector).html(oArr.join(""));
  256. }
  257. /*删除*/
  258. $("body").on("click", ".closeThis", function() {
  259. if($(this).parent().length < 5) {
  260. $(this).parents(".keyResult").siblings("div").show();
  261. }
  262. $(this).parent().remove();
  263. })
  264. /*添加*/
  265. $("button:contains('添加')").click(function() {
  266. var oValue = $(this).siblings("input").val().trim();
  267. var oJudge = $(this).parent().siblings().find("ul.ulspace li");
  268. if(!oValue) {
  269. $.MsgBox.Alert('提示', '请先填写内容');
  270. return;
  271. }
  272. if(oValue.length > 10) {
  273. $.MsgBox.Alert('提示', '添加内容不能超过10个字');
  274. return;
  275. }
  276. for(var i = 0; i < oJudge.length; i++) {
  277. if(oValue == oJudge[i].innerText) {
  278. $.MsgBox.Alert('提示', '添加内容不能重复');
  279. return;
  280. }
  281. }
  282. $(this).parent().siblings().find("ul.ulspace").append('<li>' + oValue + '<div class="closeThis"></div></li>');
  283. $(this).siblings("input").val("");
  284. if(oJudge.length == 4) {
  285. $(this).val("").parents(".col-w-12").hide();
  286. }
  287. $(this).siblings(".keydrop").find("ul").html("");
  288. })
  289. /*保存*/
  290. $("button:contains('保存')").click(function() {
  291. var oBusinessAbbreviation = $("#businessAbbreviation").val().trim();
  292. if(!oBusinessAbbreviation) {
  293. $.MsgBox.Alert('提示', '企业简称不能为空');
  294. return;
  295. }
  296. if(oBusinessAbbreviation.length > 10) {
  297. $.MsgBox.Alert('提示', '企业简称不能超过10个字');
  298. return;
  299. }
  300. /*
  301. var oTextArea = $("textarea").val().trim();
  302. var oBusinessType = $("#orgType").find("option").length;
  303. var oBusinessDimensions = $("#qualificationList").find("li.cmpBg.listactive").length;
  304. var oIndustryNumber = $("#industryList").find("li").length;
  305. var oSubjectNumber = $("#subjectList").find("li").length;
  306. var oEditUlistCNumber = $(".editUlistC ").find("li").length;
  307. if(!oTextArea) {
  308. $.MsgBox.Alert('提示', '企业简介不能为空');
  309. return;
  310. }
  311. if(oBusinessType == 0) {
  312. $.MsgBox.Alert('提示', '请选择企业类型');
  313. return;
  314. }
  315. if(oIndustryNumber == 0) {
  316. $.MsgBox.Alert('提示', '企业所属行业必填一项');
  317. return;
  318. }
  319. if(oSubjectNumber == 0) {
  320. $.MsgBox.Alert('提示', '企业所属领域必填一项');
  321. return;
  322. }
  323. if(oBusinessDimensions == 0) {
  324. $.MsgBox.Alert('提示', '请选择企业规模');
  325. return;
  326. }
  327. if(oEditUlistCNumber == 0) {
  328. $.MsgBox.Alert('提示', '企业资质必填一项');
  329. return;
  330. }*/
  331. var $info = {};
  332. $info.id = id;
  333. if(cacheImageKey != null) {
  334. $info.fn = cacheImageKey;
  335. }
  336. $info.forShort = $("#businessAbbreviation").val();
  337. if($("#orgType").find("option:selected").text() != "请选择最符合的一项") {
  338. $info.orgType = $("#orgType").find("option:selected").text()
  339. }
  340. if($("#qualificationList").find("option:selected").text() != "请选择员工数量范围") {
  341. $info.orgSize = $("#qualificationList").find("option:selected").text();
  342. }
  343. if($("#inteAddress").val().trim()) {
  344. if($("#inteAddress").val().trim().length > 20) {
  345. $.MsgBox.Alert('提示', '企业官网 20个字之内!');
  346. return;
  347. }
  348. $info.orgUrl = $("#inteAddress").val();
  349. }
  350. if($("#oprovince").text() != "请选择企业总部所在省或直辖市") {
  351. $info.province = $("#oprovince").text();
  352. }
  353. if($("#ocity").text() != "请选择企业总部所在城市") {
  354. $info.city = $("#ocity").text();
  355. }
  356. if($("#createTime").val()) {
  357. $info.foundTime = st6($("#createTime").val());
  358. }
  359. if($("#cmpAddress").val().trim()) {
  360. if($("#cmpAddress").val().trim().length > 20) {
  361. $.MsgBox.Alert('提示', '企业地址 20个字之内!');
  362. return;
  363. } else {
  364. $info.addr = $("#cmpAddress").val();
  365. }
  366. }
  367. if($("#phone").val().trim()) {
  368. if($("#phone").val().trim().length > 50) {
  369. $.MsgBox.Alert('提示', '办公电话50个字之内!');
  370. return;
  371. } else {
  372. $info.contactNum = $("#cmpAddress").val();
  373. }
  374. }
  375. if($("#mail").val().trim()) {
  376. if($("#mail").val().trim().indexOf("@")) {
  377. $info.email = $("#mail").val();
  378. } else {
  379. $.MsgBox.Alert('提示', '邮箱格式不正确');
  380. return;
  381. }
  382. }
  383. $info.descp = $("textarea").val();
  384. $info.industry = oString("#industryList");
  385. $info.subject = oString("#subjectList");
  386. $info.qualification = oString(".editUlistC");
  387. $info.fieldOfCustomer=oString(subjectListIn);
  388. $info.fieldOfSupplier==oString(subjectListOut);
  389. $.ajax({
  390. url: "/ajax/org/update",
  391. type: "POST",
  392. data: $info,
  393. timeout: 10000,
  394. dataType: "json",
  395. beforeSend: function() {},
  396. success: function(data, textState) {
  397. if(data.success) {
  398. $.MsgBox.Alert('提示', '修改成功');
  399. $("#mb_msgicon").css("background", 'url("images/sign_icon_chenggong_nor.png") 0% 0% / contain');
  400. setTimeout(function() {
  401. location.reload(false)
  402. }, 500);
  403. }
  404. },
  405. error: function(XMLHttpRequest, textStats, errorThrown) {
  406. $.MsgBox.Alert('提示', '服务器请求失败')
  407. }
  408. })
  409. })
  410. /*应用行业,学术领域,企业纸质生成字符串*/
  411. function oString(sele) {
  412. var len = $(sele).find("li");
  413. var arry = new Array();
  414. for(var i = 0; i < len.length; i++) {
  415. arry.push(len[i].innerText);
  416. }
  417. return arry.join(",");
  418. }
  419. /*时间转换成6位传给后台*/
  420. function st6(osr) {
  421. var tim = osr.substring(0, 4) + osr.substring(5, 7) + osr.substring(8, 10);
  422. return tim;
  423. }
  424. /*企业图片上传*/
  425. var uploader = WebUploader.create({
  426. auto: true,
  427. fileNumLimit: 1,
  428. swf: '../js/webuploader/Uploader.swf',
  429. server: '../ajax/cachedFileUpload',
  430. fileSingleSizeLimit: 5 * 1024 * 1024,
  431. pick: {
  432. id: "#filePicker",
  433. multiple: false
  434. },
  435. accept: {
  436. title: 'Images',
  437. extensions: 'jpg,jpeg,png',
  438. mimeTypes: 'image/gif,image/jpg,image/jpeg,image/bmp,image/png'
  439. }
  440. });
  441. // 当有文件添加进来的时候
  442. uploader.on('fileQueued', function(file) {
  443. fileId = file.id;
  444. var $li = $('<div id="' + file.id + '" class="file-item thumbnail">' + '<img>' + '</div>')
  445. $img = $li.find('img');
  446. var $list = $('#fileList');
  447. /*//判断上传文件格式
  448. var fileNameAll = file.name;
  449. var AllImgExt = ".jpg|.jpeg|.png|";
  450. var extName = fileNameAll.substring(fileNameAll.lastIndexOf(".")).toLowerCase(); //(把路径中的所有字母全部转换为小写)
  451. if(AllImgExt.indexOf(extName + "|") == -1) {
  452. var ErrMsg = "该文件类型不允许上传。请上传 " + AllImgExt + " 类型的文件,当前文件类型为" + extName;
  453. $.MsgBox.Alert('提示', ErrMsg);
  454. return false;
  455. }*/
  456. });
  457. uploader.onError = function(code) {
  458. $.MsgBox.Alert('提示', '请上传jpg、jpeg、png格式的图片,大小不超过5M')
  459. };
  460. uploader.on('uploadSuccess', function(file, data) {
  461. uploader.removeFile(fileId);
  462. cacheImageKey = data.data[0].cacheKey;
  463. $("#oimg").attr("src", "/images/tmp/" + cacheImageKey);
  464. });
  465. /*取消*/
  466. $("#Ocancel").click(function() {
  467. location.href = "cmp-workspaces.html"
  468. })
  469. /*选择省份*/
  470. $(document).on("click", "#Province li a", function() {
  471. var aVal = $(this).text();
  472. $(this).parent().parent().parent().find('.mr_show').text(aVal);
  473. $(this).parent().parent().parent().find('input[name=cho_Province]').val(aVal);
  474. if($("#oprovince").text() == "请选择企业总部所在省或直辖市") {
  475. $("#oprovince").removeClass("mr_select");
  476. $("#ocity").removeClass("mr_select");
  477. } else {
  478. $("#oprovince").addClass("mr_select");
  479. $("#ocity").removeClass("mr_select");
  480. }
  481. });
  482. /*选择城市填充js */
  483. $(document).on("click", "#City li a", function() {
  484. var aVal = $(this).text();
  485. $(this).parent().parent().parent().find('.mr_show').text(aVal);
  486. $(this).parent().parent().parent().find('input[name=cho_City]').val(aVal);
  487. if($("#ocity").text() == "请选择企业总部所在城市") {
  488. $("#ocity").removeClass("mr_select");
  489. } else {
  490. $("#ocity").addClass("mr_select");
  491. }
  492. });
  493. })