portal html css js resource

cmp-updateinfo.js 10KB

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