portal html css js resource

articalIssue.js 21KB

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