portal html css js resource

cmp-updateinfo.js 12KB

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