portal html css js resource

articalIssue.js 21KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737
  1. $(function() {
  2. var experarray = [];
  3. var resourcesarray = [];
  4. var $data = {};
  5. var articleId;
  6. var fa = false;
  7. var orgId = $.cookie("orgId");
  8. var colMgr = $.cookie("colMgr");
  9. var resMgr = $.cookie("resMgr");
  10. if(colMgr =='false' && resMgr=='false') {
  11. $(".conItem").hide().eq(0).show();
  12. }else if(resMgr=='true') {
  13. $(".conItem").eq(1).hide();
  14. $(".conItem").eq(4).hide();
  15. }
  16. var hbur,hburEnd;
  17. var pr,prEnd;
  18. var re,reEnd;
  19. var orgr,orgrEnd;
  20. if(orgId == "" || orgId == null || orgId == "null"){
  21. location.href = "cmp-settled-log.html";
  22. }
  23. //校验标题
  24. $("#newstitle").on({
  25. focus: function() {
  26. $(this).prev().find("span").text("50字以内");
  27. },
  28. blur: function() {
  29. $(this).prev().find("span").text("");
  30. },
  31. keyup: function() {
  32. if($(this).val().length > 50) {
  33. $(this).val($(this).val().substr(0, 50));
  34. }
  35. }
  36. })
  37. hotKey(".oinput");
  38. //校验关键字
  39. $("#KeyWord").on({
  40. focus: function() {
  41. $("#keyPrompt").text("最多可添加5个关键词,每个关键词15字以内");
  42. },
  43. blur: function() {
  44. $("#keyPrompt").text("");
  45. }
  46. })
  47. $("#keyWordlist").on("click", ".closeThis", function() {
  48. $(this).parent().remove();
  49. var liNum = $("#keyWordlist").find("li").length;
  50. if(liNum < 5) {
  51. $("#keyWordlist").parents(".keyResult").siblings("div.col-w-12").show();
  52. }
  53. })
  54. //校验右侧专家和资源
  55. $("#checkZj").on("focus", function() {
  56. $(this).prev().find("span").text("最多选择5位专家");
  57. })
  58. $("#checkZy").on("focus", function() {
  59. $(this).prev().find("span").text("最多选择5个资源");
  60. })
  61. $("#sevrice").on("focus", function() {
  62. $(this).prev().find("span").text("最多选择5个服务");
  63. })
  64. $("#checkZj,#checkZy,#sevrice").on("blur", function() {
  65. $(this).prev().find("span").text("");
  66. //$(this).val("");
  67. //$(this).parents(".otherBlock").find(".form-drop").addClass("displayNone");
  68. })
  69. $("#checkZj").on("keyup", function() {
  70. var _this = this;
  71. var ti=$(this).val();
  72. pr=ti;
  73. if($(this).val()=="") {
  74. return;
  75. }
  76. setTimeout(function(){
  77. if( ti===pr && ti!== prEnd) {
  78. checkZj(_this,ti);
  79. }
  80. },500)
  81. })
  82. $("#checkZy").on("keyup", function() {
  83. var ti=$(this).val();
  84. re=ti;
  85. if($(this).val()=="") {
  86. return;
  87. }
  88. var _this = this;
  89. setTimeout(function(){
  90. if( ti===re && ti!== reEnd) {
  91. checkZy(_this,ti);
  92. }
  93. },500)
  94. })
  95. var se,seEnd;
  96. $("#sevrice").on("keyup", function() {
  97. var ti=$(this).val();
  98. se=ti;
  99. if($(this).val()=="") {
  100. return;
  101. }
  102. var _this = this;
  103. setTimeout(function(){
  104. if( ti===se && ti!== seEnd) {
  105. checkSy(_this,ti);
  106. }
  107. },500)
  108. })
  109. $("#expertlist").on("click", "li", function() {
  110. var _this = this;
  111. expertlist(_this, "该专家已选择");
  112. });
  113. $("#resouselist").on("click", "li", function() {
  114. var _this = this;
  115. expertlist(_this, "该资源已选择");
  116. });
  117. $("#sevricelist").on("click", "li", function() {
  118. var _this = this;
  119. expertlist(_this, "该服务已选择");
  120. });
  121. //点击右侧搜索出的专家和资源列表
  122. function expertlist(_this, title) {
  123. var liId = $(_this).html();
  124. var plength = $(_this).parents(".otherBlock").find(".addexpert li");
  125. for(var i = 0; i < plength.length; i++) {
  126. if(plength[i].innerHTML == liId) {
  127. $(_this).parents(".otherBlock").find(".aboutTit span").text(title);
  128. $(_this).parents(".otherBlock").find(".form-drop").addClass("displayNone");
  129. $(_this).parents(".otherBlock").find("input").val("");
  130. return;
  131. }
  132. }
  133. if(plength.length > 5) {
  134. $(_this).parents(".otherBlock").find("input").hide();
  135. $(_this).parents(".otherBlock").find(".addexpert").append($(_this).clone());
  136. $(_this).parents(".otherBlock").find("input").val("");
  137. $(_this).parents(".otherBlock").find(".form-drop").addClass("displayNone");
  138. } else {
  139. $(_this).parents(".otherBlock").find(".addexpert").append($(_this).clone());
  140. $(_this).parents(".otherBlock").find("input").val("");
  141. $(_this).parents(".otherBlock").find(".form-drop").addClass("displayNone");
  142. }
  143. }
  144. //删除右侧搜索出的专家和资源
  145. $(".addexpert").on("click", ".deleteThis", function() {
  146. var plength = $(this).parent().parent().find("li").length;
  147. if(plength < 6) {
  148. $(this).parents(".otherBlock").find("input").show();
  149. }
  150. $(this).parent().remove();
  151. })
  152. function checkZj(_this,prd) {
  153. prEnd=prd;
  154. $.ajax({
  155. "url": "/ajax/professor/qaByName",
  156. "type": "get",
  157. "data": {
  158. "name": $("#checkZj").val(),
  159. "total": 3
  160. },
  161. "success": function(data) {
  162. console.log(data);
  163. if(data.success) {
  164. if(data.data != "") {
  165. if(prEnd == prd){
  166. $(_this).next().removeClass("displayNone");
  167. var itemlist = '';
  168. $("#expertlist").html("");
  169. for(var i = 0; i < data.data.length; i++) {
  170. var itemlist = '<li id="usid" class="flexCenter">';
  171. itemlist += '<div class="madiaHead useHead" id="userimg"></div>';
  172. itemlist += '<div class="madiaInfo">';
  173. itemlist += '<p class="ellipsisSty"><span class="h1Font" id="name"></span><span class="h2Font" style="margin-left:10px;" id="title"></span></p>';
  174. itemlist += '<p class="h2Font ellipsisSty" id="orgName"></p>';
  175. itemlist += '</div><div class="deleteThis"></div></li>';
  176. $itemlist = $(itemlist);
  177. $("#expertlist").append($itemlist);
  178. var datalist = data.data[i];
  179. $itemlist.attr("data-id", datalist.id);
  180. $itemlist.find("#name").text(datalist.name);
  181. $itemlist.find("#title").text(datalist.title);
  182. $itemlist.find("#orgName").text(datalist.orgName);
  183. if(datalist.hasHeadImage == 1) {
  184. $itemlist.find("#userimg").attr("style", "background-image: url(/images/head/" + datalist.id + "_l.jpg);");
  185. }
  186. }
  187. }
  188. } else {
  189. $(_this).next().addClass("displayNone");
  190. }
  191. } else {
  192. $(_this).next().addClass("displayNone");
  193. }
  194. },
  195. "error": function() {
  196. $.MsgBox.Alert('提示', '链接服务器超时')
  197. }
  198. });
  199. }
  200. function checkZy(_this, prd) {
  201. reEnd = prd;
  202. $.ajax({
  203. "url": "/ajax/resource/lq/publish/org",
  204. "type": "get",
  205. "data": {
  206. "orgid": orgId,
  207. "resourceName": $("#checkZy").val(),
  208. "rows": 3
  209. },
  210. "success": function(data) {
  211. console.log(data);
  212. if(data.success) {
  213. if(data.data != "") {
  214. if(reEnd == prd) {
  215. $(_this).next().removeClass("displayNone");
  216. $("#resouselist").html("");
  217. for(var i = 0; i < data.data.length; i++) {
  218. var itemlist = '<li id="usid" class="flexCenter" >' +
  219. '<p class="h1Font ellipsisSty-2 childElement" id="resourceName"></p>' +
  220. '<div class="deleteThis"></div></li>'
  221. $itemlist = $(itemlist);
  222. $("#resouselist").append($itemlist);
  223. var datalist = data.data[i];
  224. $itemlist.attr("data-id", datalist.resourceId);
  225. $itemlist.find("#resourceName").text(datalist.resourceName);
  226. }
  227. }
  228. } else {
  229. $(_this).next().addClass("displayNone");
  230. }
  231. } else {
  232. $(_this).next().addClass("displayNone");
  233. }
  234. },
  235. "error": function() {
  236. $.MsgBox.Alert('提示', '链接服务器超时')
  237. }
  238. });
  239. }
  240. function checkSy(_this, prd) {
  241. seEnd = prd;
  242. $.ajax({
  243. "url": "../ajax/ware/publish",
  244. "type": "get",
  245. "data": {
  246. category:2,
  247. owner:orgId,
  248. rows:5
  249. },
  250. "success": function(data) {
  251. console.log(data);
  252. if(data.success) {
  253. if(data.data != "") {
  254. if(seEnd == prd) {
  255. $(_this).next().removeClass("displayNone");
  256. $("#sevricelist").html("");
  257. for(var i = 0; i < data.data.length; i++) {
  258. var itemlist = '<li id="usid" class="flexCenter" >' +
  259. '<p class="h1Font ellipsisSty-2 childElement" id="resourceName"></p>' +
  260. '<div class="deleteThis"></div></li>'
  261. $itemlist = $(itemlist);
  262. $("#sevricelist").append($itemlist);
  263. var datalist = data.data[i];
  264. $itemlist.attr("data-id", datalist.id);
  265. $itemlist.find("#resourceName").text(datalist.name);
  266. }
  267. }
  268. } else {
  269. $(_this).next().addClass("displayNone");
  270. }
  271. } else {
  272. $(_this).next().addClass("displayNone");
  273. }
  274. },
  275. "error": function() {
  276. $.MsgBox.Alert('提示', '链接服务器超时')
  277. }
  278. });
  279. }
  280. var titleflase = false;
  281. var imgflase = false;
  282. //交验图片和标题不能为空
  283. function noTitleImg() {
  284. var ImageKey = $("#uploader").attr("data-id");
  285. var newstitle = $("#newstitle").val();
  286. if(ImageKey == "") {
  287. //$(".imgtis").text("请上传封面图片");
  288. $.MsgBox.Alert('提示', '请上传封面图片');
  289. return;
  290. } else {
  291. $(".imgtis").text("");
  292. imgflase = true;
  293. }
  294. if(newstitle == "") {
  295. //$("#aboutTit span").text("请输入文章标题");
  296. $.MsgBox.Alert('提示', '请输入文章标题');
  297. return;
  298. } else {
  299. $("#aboutTit span").text("");
  300. titleflase = true;
  301. }
  302. }
  303. //获取相关专家
  304. function expertli() {
  305. experarray=[];
  306. $("#expertli li").each(function(i) {
  307. var liid = $(this).attr("data-id");
  308. experarray.push(liid);
  309. });
  310. return $.unique(experarray);
  311. }
  312. //获取相关资源
  313. function resourcesli() {
  314. resourcesarray=[];
  315. $("#resources li").each(function(i) {
  316. var liid = $(this).attr("data-id");
  317. resourcesarray.push(liid);
  318. });
  319. return $.unique(resourcesarray);
  320. }
  321. function seli() {
  322. var arr=[];
  323. $("#sevriceli li").each(function(i) {
  324. var liid = $(this).attr("data-id");
  325. arr.push(liid);
  326. });
  327. return $.unique(arr);
  328. }
  329. var seleClum ='<div class="mb-list mb-listL"><p>请选择文章发布的栏目:</p>'+
  330. '<select class="form-control form-column" id="seletColum"></select></div>';
  331. var seleTime = '<div class="mb-list mb-listR"><p>请设置文章发布的时间:</p>'+
  332. '<div class="formTime"><div class="form-group">'+
  333. '<input size="16" type="text" value="" readonly class="form-control form_datetime">'+
  334. '</div></div></div>';
  335. //文章发布
  336. $("#release").on("click", function() {
  337. if($(this).hasClass("disableLi")){
  338. return;
  339. }
  340. noTitleImg();
  341. if(imgflase && titleflase) {
  342. console.log(colMgr)
  343. if(colMgr=="true"){
  344. $(".blackcover2").fadeIn();
  345. var btnOk='<input class="mb_btn mb_btnOk mb_btnOkpub" type="button" value="确定">'
  346. $(".mb_btnOk").remove(); $("#promotGt").prepend(btnOk);
  347. $(".modelContain").show(); $("body").addClass("modelOpen");
  348. $(".mb-listR").remove();
  349. $(".mb-listL").remove();
  350. $("#promotTh").prepend(seleClum);
  351. fillColum(7);//填充select栏目
  352. $(".mb_btnOkpub").on("click", function() {
  353. $(".blackcover2").fadeOut();
  354. $(".modelContain").hide();
  355. $("body").removeClass("modelOpen");
  356. $.MsgBox.Confirm("提示", "确认发布该文章?", newsAdd);
  357. })
  358. }else{
  359. $.MsgBox.Confirm("提示", "确认发布该文章?", newsAdd);
  360. }
  361. }
  362. })
  363. //定时文章发布
  364. $("#setTimeIssue").on("click", function() {
  365. if($(this).hasClass("disableLi")){
  366. return;
  367. }
  368. noTitleImg();
  369. if(imgflase && titleflase) {
  370. $(".blackcover2").fadeIn();
  371. var btnOk='<input class="mb_btn mb_btnOk mb_btnOkset" type="button" value="确定">'
  372. $(".mb_btnOk").remove(); $("#promotGt").prepend(btnOk);
  373. $(".modelContain").show(); $("body").addClass("modelOpen");
  374. $(".mb-listR").remove(); $("#promotTh").append(seleTime);//时间选择器
  375. $(".mb-listR .form_datetime").datetimepicker({
  376. format: 'yyyy-mm-dd hh:ii',
  377. forceParse: true,
  378. autoclose: true,
  379. });
  380. $(".mb-listR .form_datetime").val(getNowFormatDate());
  381. if(colMgr=="true"){
  382. $(".mb-listL").remove();
  383. $("#promotTh").prepend(seleClum);
  384. fillColum(7);//填充select栏目
  385. }
  386. $(".mb_btnOkset").on("click", function() {
  387. var publishTime = $(".form_datetime").val();
  388. console.log(st6(publishTime));
  389. setTimeIssue(st6(publishTime));
  390. })
  391. }
  392. })
  393. //文章存草稿
  394. $("#draft").on("click", function() {
  395. if($(this).hasClass("disableLi")){
  396. return;
  397. }
  398. noTitleImg();
  399. if(imgflase && titleflase) {
  400. draftAdd(1);
  401. }
  402. })
  403. //文章预览
  404. $("#preview").on("click", function() {
  405. if($(this).hasClass("disableLi")){
  406. return;
  407. }
  408. noTitleImg();
  409. if(imgflase && titleflase) {
  410. draftAdd(2);
  411. }
  412. })
  413. function getAttrId() {
  414. var arr=[];
  415. this.each(function(){
  416. arr.push( $(this).attr("data-id"));
  417. });
  418. return arr;
  419. }
  420. /*获取数据*/
  421. function getdata(publishTime) {
  422. var industrys = $("#keyWordlist li");
  423. var industryAll = "";
  424. if(industrys.size() > 0) {
  425. for(var i = 0; i < industrys.size(); i++) {
  426. industryAll += industrys[i].innerText.trim();
  427. industryAll += ',';
  428. };
  429. industryAll = industryAll.substring(0, industryAll.length - 1);
  430. }
  431. expertli(); //相关专家
  432. resourcesli(); //相关咨询
  433. $data.orgId = orgId;
  434. if($("#companys li").length) {
  435. $data.orgs = getAttrId.call($("#companys li"));
  436. }
  437. $data.articleTitle = $("#newstitle").val();
  438. $data.subject = industryAll;
  439. $data.articleImg = $("#uploader").attr("data-id");
  440. $data.articleContent = ue.getContent();
  441. $data.professors = experarray;
  442. $data.resources = resourcesarray;
  443. $data.wares=seli();
  444. if(colMgr=="true"){
  445. $data.colNum = $("#seletColum").val();
  446. if(publishTime!="") {
  447. $data.publishTime = publishTime;
  448. }
  449. }else{
  450. if(publishTime!="") {
  451. $data.publishTime = publishTime;
  452. }
  453. $data.colNum=2;
  454. }
  455. if($("#hidearticleId").val().length != 0) {
  456. $data.articleId = $("#hidearticleId").val();
  457. }
  458. console.log($data);
  459. }
  460. /*文章发布*/
  461. function newsAdd() {
  462. getdata();
  463. $(".operateBlock").find("li").addClass("disableLi");
  464. $.ajax({
  465. "url": "/ajax/article/save",
  466. "type": "post",
  467. "dataType": "json",
  468. "data": $data,
  469. "traditional": true, //传数组必须加这个
  470. "complete":function(){
  471. $(".operateBlock").find("li").removeClass("disableLi");
  472. },
  473. "success": function(data) {
  474. console.log(data);
  475. if(data.success) {
  476. $("#hidearticleId").val(data.data);
  477. $.MsgBox.Alert("提示", "文章发表成功!", function articalList() {
  478. location.href = "cmp-articalList.html";
  479. });
  480. $("#mb_msgicon").css("background", 'url("images/sign_icon_chenggong_nor.png") 0% 0% / contain');
  481. } else {
  482. if(data.code==90) {
  483. $.MsgBox.Alert('提示', '由于操作时间过久,上传图片已失效,请重新上传。');
  484. }else{
  485. $.MsgBox.Alert("提示", "文章发表失败!");
  486. }
  487. }
  488. },
  489. "error": function() {
  490. $.MsgBox.Alert('提示', '链接服务器超时')
  491. }
  492. });
  493. }
  494. /*文章定时发布*/
  495. function setTimeIssue(publishTime) {
  496. var opublishTime=publishTime+"01";
  497. getdata(opublishTime);
  498. $(".operateBlock").find("li").addClass("disableLi");
  499. $.ajax({
  500. "url": "/ajax/article/timing",
  501. "type": "post",
  502. "dataType": "json",
  503. "data": $data,
  504. "traditional": true, //传数组必须加这个
  505. "complete":function(){
  506. $(".operateBlock").find("li").removeClass("disableLi");
  507. },
  508. "success": function(data) {
  509. console.log(data);
  510. if(data.success) {
  511. $("#hidearticleId").val(data.data);
  512. location.href = "cmp-articalList.html";
  513. } else {
  514. if(data.code==90) {
  515. $.MsgBox.Alert('提示', '由于操作时间过久,上传图片已失效,请重新上传。');
  516. }else{
  517. $.MsgBox.Alert("提示", "文章发表失败!");
  518. }
  519. }
  520. },
  521. "error": function() {
  522. $.MsgBox.Alert('提示', '链接服务器超时')
  523. }
  524. });
  525. }
  526. /*文章添加草稿和文章预览*/
  527. function draftAdd(num) {
  528. getdata();
  529. $(".operateBlock").find("li").addClass("disableLi");
  530. $.ajax({
  531. "url": "/ajax/article/draft",
  532. "type": "post",
  533. "dataType": "json",
  534. "data": $data,
  535. "traditional": true, //传数组必须加这个
  536. "complete":function(){
  537. $(".operateBlock").find("li").removeClass("disableLi");
  538. },
  539. "success": function(data) {
  540. console.log(data);
  541. if(num == 1) {
  542. if(data.success) {
  543. $("#hidearticleId").val(data.data);
  544. articleId = data.data;
  545. $.MsgBox.Alert("提示", "文章已保存草稿。");
  546. $("#mb_msgicon").css("background", 'url("images/sign_icon_chenggong_nor.png") 0% 0% / contain');
  547. $("#delete").removeClass("disableLi").addClass("odele");
  548. }else{
  549. if(data.code==90) {
  550. $.MsgBox.Alert('提示', '由于操作时间过久,上传图片已失效,请重新上传。');
  551. }else{
  552. $.MsgBox.Alert("提示", "文章发表失败!");
  553. }
  554. }
  555. }
  556. if(num == 2) {
  557. if(data.success) {
  558. $("#hidearticleId").val(data.data);
  559. articleId = data.data;
  560. $("#delete").removeClass("disableLi").addClass("odele");
  561. fa = true;
  562. }else{
  563. if(data.code==90) {
  564. $.MsgBox.Alert('提示', '由于操作时间过久,上传图片已失效,请重新上传。');
  565. }else{
  566. $.MsgBox.Alert("提示", "文章发表失败!");
  567. }
  568. }
  569. if(fa) {
  570. window.open("../articalPreview.html?articleId=" + articleId)
  571. }
  572. }
  573. },
  574. "error": function() {
  575. $.MsgBox.Alert('提示', '链接服务器超时')
  576. }
  577. });
  578. }
  579. function st6(osr) {
  580. var tim = osr.substring(0, 4) + osr.substring(5, 7) + osr.substring(8, 10) + osr.substring(11, 13) + osr.substring(14, 16);
  581. return tim;
  582. }
  583. /*删除文章*/
  584. $(".operateBlock").on("click",".odele",function(){
  585. $.MsgBox.Confirm("提示","确认删除该文章?",newsDelet);
  586. })
  587. /*文章删除*/
  588. function newsDelet() {
  589. $.ajax({
  590. "url" : "/ajax/article/deleteArticle",
  591. "type" : "POST",
  592. "dataType" : "json",
  593. "data": {
  594. "articleId": articleId
  595. },
  596. "success" : function($data) {
  597. if ($data.success) {
  598. location.href = "cmp-articalList.html";
  599. }
  600. },
  601. "error":function(){
  602. $.MsgBox.Alert('提示','链接服务器超时')
  603. }
  604. })
  605. }
  606. relatCompanies("#company");
  607. /*添加相关企业*/
  608. function relatCompanies(sel) {
  609. $(sel).bind({
  610. paste: function(e) {
  611. var pastedText;
  612. if (window.clipboardData  &&  window.clipboardData.getData)  {  // IE
  613.             
  614. pastedText  = $(this).val() +  window.clipboardData.getData('Text');          
  615. else  {            
  616. pastedText  = $(this).val() +  e.originalEvent.clipboardData.getData('Text'); //e.clipboardData.getData('text/plain');
  617.           
  618. }
  619. $(this).val(pastedText);
  620. e.preventDefault();
  621. },
  622. cut: function(e) {
  623. var $this = $(this);
  624. },
  625. blur: function() {
  626. var $this = $(this);
  627. $(this).siblings(".aboutTit").find("span").text("");
  628. setTimeout(function() {
  629. $this.siblings(".form-drop").hide();
  630. }, 500)
  631. },
  632. focus: function() {
  633. $(this).siblings(".form-drop").show();
  634. $(this).siblings(".aboutTit").find("span").text("最多选择5家企业");
  635. },
  636. keyup: function(e) {
  637. var ti=$(this).val();
  638. orgr=ti;
  639. var $this=$(this);
  640. if($(this).val().trim()) {
  641. var lNum = $.trim($(this).val()).length;
  642. if(0 < lNum) {
  643. setTimeout(function(){
  644. if( ti===orgr && ti!== orgrEnd) {
  645. var tt=ti;
  646. orgrEnd=tt;
  647. $("#companylist").parent().show();
  648. $.ajax({
  649. "url": "/ajax/org/qr",
  650. "type": "GET",
  651. "data":{
  652. kw: $this.val(),
  653. limit:3
  654. },
  655. "success": function(data) {
  656. console.log(data);
  657. if(data.success) {
  658. if(orgrEnd==tt) {
  659. if(data.data.length == 0) {
  660. $this.siblings(".form-drop").addClass("displayNone");
  661. $this.siblings(".form-drop").find("ul").html("");
  662. } else {
  663. $this.siblings(".form-drop").removeClass("displayNone");
  664. var oSr = "";
  665. for(var i = 0; i < data.data.length; i++) {
  666. var busName=(data.data[i].forShort)?data.data[i].forShort:data.data[i].name;
  667. oSr += '<li style="min-height:40px;position:static;"data-id="'+data.data[i].id+'">' + busName + '</li>';
  668. }
  669. $this.siblings(".form-drop").find("ul").html(oSr);
  670. }
  671. }
  672. } else {
  673. $this.siblings(".form-drop").addClass("displayNone");
  674. $this.siblings(".form-drop").find("ul").html("");
  675. }
  676. },
  677. dataType: "json",
  678. 'error': function() {
  679. $.MsgBox.Alert('提示', '服务器连接超时!');
  680. }
  681. });
  682. }
  683. },500)
  684. }
  685. } else {
  686. $(this).siblings(".form-drop").addClass("displayNone");
  687. $(this).siblings(".form-drop").find("ul").html("");
  688. }
  689. }
  690. })
  691. $("#company").siblings(".form-drop").on("click", "li", function() {
  692. var oValue = $(this).text();
  693. var oJudge = $(this).parents(".form-drop").siblings(".form-result").find("ul li");
  694. for(var i = 0; i < oJudge.length; i++) {
  695. if(oValue == oJudge[i].innerText) {
  696. $.MsgBox.Alert('提示', '该企业已选择.');
  697. return;
  698. }
  699. }
  700. $(this).parents(".form-drop").siblings(".form-result").find("ul").append('<li class="ellipsisSty" style="min-height:40px;padding-right:42px;" data-id="'+$(this).attr("data-id")+'">' + oValue + '<div class="deleteThis"></div></li>');
  701. $(this).parents(".form-drop").siblings("input").val("");
  702. if(oJudge.length == 4) {
  703. $(this).parents(".form-drop").siblings("input").val("");
  704. $("#company").hide();
  705. }
  706. $(this).parent("ul").html("")
  707. })
  708. }
  709. });