portal html css js resource

cmp-updateinfo.js 11KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377
  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. /*应用行业及领域及企业资质*/
  144. function indu(oString, oSelector) {
  145. var arr = oString.split(",");
  146. var oArr = new Array();
  147. var i;
  148. for(i in arr) {
  149. oArr.push('<li>' + arr[i] + '<div class="closeThis"></div></li>');
  150. }
  151. $(oSelector).html(oArr.join(""));
  152. }
  153. hotKey(".oinput");
  154. /*删除*/
  155. $("body").on("click", ".closeThis", function() {
  156. if($(this).parent().length < 5) {
  157. $(this).parents(".keyResult").siblings("div").show();
  158. }
  159. $(this).parent().remove();
  160. })
  161. /*保存*/
  162. $("button:contains('保存')").click(function() {
  163. var oBusinessAbbreviation = $("#businessAbbreviation").val().trim();
  164. if(!oBusinessAbbreviation) {
  165. $.MsgBox.Alert('提示', '企业简称不能为空');
  166. return;
  167. }
  168. if(oBusinessAbbreviation.length > 10) {
  169. $.MsgBox.Alert('提示', '企业简称不能超过10个字');
  170. return;
  171. }
  172. /*
  173. var oTextArea = $("textarea").val().trim();
  174. var oBusinessType = $("#orgType").find("option").length;
  175. var oBusinessDimensions = $("#qualificationList").find("li.cmpBg.listactive").length;
  176. var oIndustryNumber = $("#industryList").find("li").length;
  177. var oSubjectNumber = $("#subjectList").find("li").length;
  178. var oEditUlistCNumber = $(".editUlistC ").find("li").length;
  179. if(!oTextArea) {
  180. $.MsgBox.Alert('提示', '企业简介不能为空');
  181. return;
  182. }
  183. if(oBusinessType == 0) {
  184. $.MsgBox.Alert('提示', '请选择企业类型');
  185. return;
  186. }
  187. if(oIndustryNumber == 0) {
  188. $.MsgBox.Alert('提示', '企业所属行业必填一项');
  189. return;
  190. }
  191. if(oSubjectNumber == 0) {
  192. $.MsgBox.Alert('提示', '企业所属领域必填一项');
  193. return;
  194. }
  195. if(oBusinessDimensions == 0) {
  196. $.MsgBox.Alert('提示', '请选择企业规模');
  197. return;
  198. }
  199. if(oEditUlistCNumber == 0) {
  200. $.MsgBox.Alert('提示', '企业资质必填一项');
  201. return;
  202. }*/
  203. var $info = {};
  204. $info.id = id;
  205. if(cacheImageKey != null) {
  206. $info.fn = cacheImageKey;
  207. }
  208. $info.forShort = $("#businessAbbreviation").val();
  209. if($("#orgType").find("option:selected").text() != "请选择最符合的一项") {
  210. $info.orgType = $("#orgType").find("option:selected").val()
  211. }
  212. if($("#qualificationList").find("option:selected").text() != "请选择员工数量范围") {
  213. $info.orgSize = $("#qualificationList").find("option:selected").val();
  214. }
  215. if($("#inteAddress").val().trim()) {
  216. if($("#inteAddress").val().trim().length > 20) {
  217. $.MsgBox.Alert('提示', '企业官网 20个字之内!');
  218. return;
  219. }
  220. $info.orgUrl = $("#inteAddress").val();
  221. }
  222. if($("#oprovince").text() != "请选择企业总部所在省或直辖市") {
  223. $info.province = $("#oprovince").text();
  224. }
  225. if($("#ocity").text() != "请选择企业总部所在城市") {
  226. $info.city = $("#ocity").text();
  227. }
  228. if($("#createTime").val()) {
  229. $info.foundTime = st6($("#createTime").val());
  230. }
  231. if($("#cmpAddress").val().trim()) {
  232. if($("#cmpAddress").val().trim().length > 20) {
  233. $.MsgBox.Alert('提示', '企业地址 20个字之内!');
  234. return;
  235. } else {
  236. $info.addr = $("#cmpAddress").val();
  237. }
  238. }
  239. if($("#phone").val().trim()) {
  240. if($("#phone").val().trim().length > 50) {
  241. $.MsgBox.Alert('提示', '办公电话50个字之内!');
  242. return;
  243. } else {
  244. $info.contactNum = $("#phone").val().trim();
  245. }
  246. }
  247. if($("#mail").val().trim()) {
  248. if($("#mail").val().trim().indexOf("@")!=-1) {
  249. $info.email = $("#mail").val();
  250. } else {
  251. $.MsgBox.Alert('提示', '邮箱格式不正确');
  252. return;
  253. }
  254. }
  255. $info.descp = $("textarea").val();
  256. $info.industry = oString("#industryList");
  257. $info.subject = oString("#subjectList");
  258. $info.qualification = oString(".editUlistC");
  259. $info.fieldOfCustomer=oString(subjectListIn);
  260. $info.fieldOfSupplier=oString(subjectListOut);
  261. $.ajax({
  262. url: "/ajax/org/update",
  263. type: "POST",
  264. data: $info,
  265. timeout: 10000,
  266. dataType: "json",
  267. beforeSend: function() {},
  268. success: function(data, textState) {
  269. if(data.success) {
  270. $.MsgBox.Alert('提示', '修改成功');
  271. $("#mb_msgicon").css("background", 'url("images/sign_icon_chenggong_nor.png") 0% 0% / contain');
  272. setTimeout(function() {
  273. location.reload(false)
  274. }, 500);
  275. }
  276. },
  277. error: function(XMLHttpRequest, textStats, errorThrown) {
  278. $.MsgBox.Alert('提示', '服务器请求失败')
  279. }
  280. })
  281. })
  282. /*应用行业,学术领域,企业纸质生成字符串*/
  283. function oString(sele) {
  284. var len = $(sele).find("li");
  285. var arry = new Array();
  286. for(var i = 0; i < len.length; i++) {
  287. arry.push(len[i].innerText);
  288. }
  289. return arry.join(",");
  290. }
  291. /*时间转换成6位传给后台*/
  292. function st6(osr) {
  293. var tim = osr.substring(0, 4) + osr.substring(5, 7) + osr.substring(8, 10);
  294. return tim;
  295. }
  296. /*企业图片上传*/
  297. var uploader = WebUploader.create({
  298. auto: true,
  299. fileNumLimit: 1,
  300. swf: '../js/webuploader/Uploader.swf',
  301. server: '../ajax/cachedFileUpload',
  302. fileSingleSizeLimit: 5 * 1024 * 1024,
  303. pick: {
  304. id: "#filePicker",
  305. multiple: false
  306. },
  307. accept: {
  308. title: 'Images',
  309. extensions: 'jpg,jpeg,png',
  310. mimeTypes: 'image/gif,image/jpg,image/jpeg,image/bmp,image/png'
  311. }
  312. });
  313. // 当有文件添加进来的时候
  314. uploader.on('fileQueued', function(file) {
  315. fileId = file.id;
  316. var $li = $('<div id="' + file.id + '" class="file-item thumbnail">' + '<img>' + '</div>')
  317. $img = $li.find('img');
  318. var $list = $('#fileList');
  319. /*//判断上传文件格式
  320. var fileNameAll = file.name;
  321. var AllImgExt = ".jpg|.jpeg|.png|";
  322. var extName = fileNameAll.substring(fileNameAll.lastIndexOf(".")).toLowerCase(); //(把路径中的所有字母全部转换为小写)
  323. if(AllImgExt.indexOf(extName + "|") == -1) {
  324. var ErrMsg = "该文件类型不允许上传。请上传 " + AllImgExt + " 类型的文件,当前文件类型为" + extName;
  325. $.MsgBox.Alert('提示', ErrMsg);
  326. return false;
  327. }*/
  328. });
  329. uploader.onError = function(code) {
  330. $.MsgBox.Alert('提示', '请上传jpg、jpeg、png格式的图片,大小不超过5M')
  331. };
  332. uploader.on('uploadSuccess', function(file, data) {
  333. uploader.removeFile(fileId);
  334. cacheImageKey = data.data[0].cacheKey;
  335. $("#oimg").attr("src", "/images/tmp/" + cacheImageKey);
  336. });
  337. /*取消*/
  338. $("#Ocancel").click(function() {
  339. location.href = "cmp-workspaces.html"
  340. })
  341. /*选择省份*/
  342. $(document).on("click", "#Province li a", function() {
  343. var aVal = $(this).text();
  344. $(this).parent().parent().parent().find('.mr_show').text(aVal);
  345. $(this).parent().parent().parent().find('input[name=cho_Province]').val(aVal);
  346. if($("#oprovince").text() == "请选择企业总部所在省或直辖市") {
  347. $("#oprovince").removeClass("mr_select");
  348. $("#ocity").removeClass("mr_select");
  349. } else {
  350. $("#oprovince").addClass("mr_select");
  351. $("#ocity").removeClass("mr_select");
  352. }
  353. });
  354. /*选择城市填充js */
  355. $(document).on("click", "#City li a", function() {
  356. var aVal = $(this).text();
  357. $(this).parent().parent().parent().find('.mr_show').text(aVal);
  358. $(this).parent().parent().parent().find('input[name=cho_City]').val(aVal);
  359. if($("#ocity").text() == "请选择企业总部所在城市") {
  360. $("#ocity").removeClass("mr_select");
  361. } else {
  362. $("#ocity").addClass("mr_select");
  363. }
  364. });
  365. })