portal html css js resource

articalIssue.js 22KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749
  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 class="msg-tit">请设置文章发布的时间:</p>'+
  332. '<div style="position:relative"><div class="input-append date form_date form_datetime" data-link-field="dtp_input2" >'+
  333. '<em class="mr_sj"></em>'+
  334. '<input size="16" type="text" readonly class="frmtype frmcontype fColor" placeholder="请设置文章发布的时间">'+
  335. '<span class="dateIcon"><i class="icon-calendar displayNone"></i></span>'+
  336. '<span class="add-on"><i class="icon-th displayNone"></i></span>'+
  337. '</div>'+
  338. '<input type="hidden" id="dtp_input2"/>'+
  339. '<span></span></div></div>';
  340. var a = new Date();
  341. var c = a.getFullYear() + "-" + (Number(a.getMonth()) + 1) + "-" + (Number(a.getDate()));
  342. //文章发布
  343. $("#release").on("click", function() {
  344. if($(this).hasClass("disableLi")){
  345. return;
  346. }
  347. noTitleImg();
  348. if(imgflase && titleflase) {
  349. console.log(colMgr)
  350. if(colMgr=="true"){
  351. $(".blackcover2").fadeIn();
  352. var btnOk='<input class="mb_btn mb_btnOk mb_btnOkpub" type="button" value="确定">'
  353. $(".mb_btnOk").remove(); $("#promotGt").prepend(btnOk);
  354. $(".modelContain").show(); $("body").addClass("modelOpen");
  355. $(".mb-listR").remove();
  356. $(".mb-listL").remove();
  357. $("#promotTh").prepend(seleClum);
  358. fillColum(7);//填充select栏目
  359. $(".mb_btnOkpub").on("click", function() {
  360. $(".blackcover2").fadeOut();
  361. $(".modelContain").hide();
  362. $("body").removeClass("modelOpen");
  363. $.MsgBox.Confirm("提示", "确认发布该文章?", newsAdd);
  364. })
  365. }else{
  366. $.MsgBox.Confirm("提示", "确认发布该文章?", newsAdd);
  367. }
  368. }
  369. })
  370. //定时文章发布
  371. $("#setTimeIssue").on("click", function() {
  372. if($(this).hasClass("disableLi")){
  373. return;
  374. }
  375. noTitleImg();
  376. if(imgflase && titleflase) {
  377. $(".blackcover2").fadeIn();
  378. var btnOk='<input class="mb_btn mb_btnOk mb_btnOkset" type="button" value="确定">'
  379. $(".mb_btnOk").remove(); $("#promotGt").prepend(btnOk);
  380. $(".modelContain").show(); $("body").addClass("modelOpen");
  381. $(".mb-listR").remove(); $("#promotTh").append(seleTime);//时间选择器
  382. $(".mb-listR .form_datetime").datetimepicker({
  383. language: 'ch',
  384. format: 'yyyy-mm-dd hh:ii',
  385. forceParse: 1,
  386. autoclose: 1,
  387. todayBtn: 1,
  388. todayHighlight: 1,
  389. startDate: c,
  390. oflag: 1,
  391. });
  392. $(".mb-listR .form_datetime .frmcontype").val(getNowFormatDate());
  393. if(colMgr=="true"){
  394. $(".mb-listL").remove();
  395. $("#promotTh").prepend(seleClum);
  396. fillColum(7);//填充select栏目
  397. }
  398. $(".mb_btnOkset").on("click", function() {
  399. var publishTime = $(".mb-listR .form_datetime .frmcontype").val();
  400. console.log(st6(publishTime));
  401. setTimeIssue(st6(publishTime));
  402. })
  403. }
  404. })
  405. //文章存草稿
  406. $("#draft").on("click", function() {
  407. if($(this).hasClass("disableLi")){
  408. return;
  409. }
  410. noTitleImg();
  411. if(imgflase && titleflase) {
  412. draftAdd(1);
  413. }
  414. })
  415. //文章预览
  416. $("#preview").on("click", function() {
  417. if($(this).hasClass("disableLi")){
  418. return;
  419. }
  420. noTitleImg();
  421. if(imgflase && titleflase) {
  422. draftAdd(2);
  423. }
  424. })
  425. function getAttrId() {
  426. var arr=[];
  427. this.each(function(){
  428. arr.push( $(this).attr("data-id"));
  429. });
  430. return arr;
  431. }
  432. /*获取数据*/
  433. function getdata(publishTime) {
  434. var industrys = $("#keyWordlist li");
  435. var industryAll = "";
  436. if(industrys.size() > 0) {
  437. for(var i = 0; i < industrys.size(); i++) {
  438. industryAll += industrys[i].innerText.trim();
  439. industryAll += ',';
  440. };
  441. industryAll = industryAll.substring(0, industryAll.length - 1);
  442. }
  443. expertli(); //相关专家
  444. resourcesli(); //相关咨询
  445. $data.orgId = orgId;
  446. if($("#companys li").length) {
  447. $data.orgs = getAttrId.call($("#companys li"));
  448. }
  449. $data.articleTitle = $("#newstitle").val();
  450. $data.subject = industryAll;
  451. $data.articleImg = $("#uploader").attr("data-id");
  452. $data.articleContent = ue.getContent();
  453. $data.professors = experarray;
  454. $data.resources = resourcesarray;
  455. $data.wares=seli();
  456. if(colMgr=="true"){
  457. $data.colNum = $("#seletColum").val();
  458. if(publishTime!="") {
  459. $data.publishTime = publishTime;
  460. }
  461. }else{
  462. if(publishTime!="") {
  463. $data.publishTime = publishTime;
  464. }
  465. $data.colNum=2;
  466. }
  467. if($("#hidearticleId").val().length != 0) {
  468. $data.articleId = $("#hidearticleId").val();
  469. }
  470. console.log($data);
  471. }
  472. /*文章发布*/
  473. function newsAdd() {
  474. getdata();
  475. $(".operateBlock").find("li").addClass("disableLi");
  476. $.ajax({
  477. "url": "/ajax/article/save",
  478. "type": "post",
  479. "dataType": "json",
  480. "data": $data,
  481. "traditional": true, //传数组必须加这个
  482. "complete":function(){
  483. $(".operateBlock").find("li").removeClass("disableLi");
  484. },
  485. "success": function(data) {
  486. console.log(data);
  487. if(data.success) {
  488. $("#hidearticleId").val(data.data);
  489. $.MsgBox.Alert("提示", "文章发表成功!", function articalList() {
  490. location.href = "cmp-articalList.html";
  491. });
  492. $("#mb_msgicon").css("background", 'url("images/sign_icon_chenggong_nor.png") 0% 0% / contain');
  493. } else {
  494. if(data.code==90) {
  495. $.MsgBox.Alert('提示', '由于操作时间过久,上传图片已失效,请重新上传。');
  496. }else{
  497. $.MsgBox.Alert("提示", "文章发表失败!");
  498. }
  499. }
  500. },
  501. "error": function() {
  502. $.MsgBox.Alert('提示', '链接服务器超时')
  503. }
  504. });
  505. }
  506. /*文章定时发布*/
  507. function setTimeIssue(publishTime) {
  508. var opublishTime=publishTime+"01";
  509. getdata(opublishTime);
  510. $(".operateBlock").find("li").addClass("disableLi");
  511. $.ajax({
  512. "url": "/ajax/article/timing",
  513. "type": "post",
  514. "dataType": "json",
  515. "data": $data,
  516. "traditional": true, //传数组必须加这个
  517. "complete":function(){
  518. $(".operateBlock").find("li").removeClass("disableLi");
  519. },
  520. "success": function(data) {
  521. console.log(data);
  522. if(data.success) {
  523. $("#hidearticleId").val(data.data);
  524. location.href = "cmp-articalList.html";
  525. } else {
  526. if(data.code==90) {
  527. $.MsgBox.Alert('提示', '由于操作时间过久,上传图片已失效,请重新上传。');
  528. }else{
  529. $.MsgBox.Alert("提示", "文章发表失败!");
  530. }
  531. }
  532. },
  533. "error": function() {
  534. $.MsgBox.Alert('提示', '链接服务器超时')
  535. }
  536. });
  537. }
  538. /*文章添加草稿和文章预览*/
  539. function draftAdd(num) {
  540. getdata();
  541. $(".operateBlock").find("li").addClass("disableLi");
  542. $.ajax({
  543. "url": "/ajax/article/draft",
  544. "type": "post",
  545. "dataType": "json",
  546. "data": $data,
  547. "traditional": true, //传数组必须加这个
  548. "complete":function(){
  549. $(".operateBlock").find("li").removeClass("disableLi");
  550. },
  551. "success": function(data) {
  552. console.log(data);
  553. if(num == 1) {
  554. if(data.success) {
  555. $("#hidearticleId").val(data.data);
  556. articleId = data.data;
  557. $.MsgBox.Alert("提示", "文章已保存草稿。");
  558. $("#mb_msgicon").css("background", 'url("images/sign_icon_chenggong_nor.png") 0% 0% / contain');
  559. $("#delete").removeClass("disableLi").addClass("odele");
  560. }else{
  561. if(data.code==90) {
  562. $.MsgBox.Alert('提示', '由于操作时间过久,上传图片已失效,请重新上传。');
  563. }else{
  564. $.MsgBox.Alert("提示", "文章发表失败!");
  565. }
  566. }
  567. }
  568. if(num == 2) {
  569. if(data.success) {
  570. $("#hidearticleId").val(data.data);
  571. articleId = data.data;
  572. $("#delete").removeClass("disableLi").addClass("odele");
  573. fa = true;
  574. }else{
  575. if(data.code==90) {
  576. $.MsgBox.Alert('提示', '由于操作时间过久,上传图片已失效,请重新上传。');
  577. }else{
  578. $.MsgBox.Alert("提示", "文章发表失败!");
  579. }
  580. }
  581. if(fa) {
  582. window.open("../articalPreview.html?articleId=" + articleId)
  583. }
  584. }
  585. },
  586. "error": function() {
  587. $.MsgBox.Alert('提示', '链接服务器超时')
  588. }
  589. });
  590. }
  591. function st6(osr) {
  592. var tim = osr.substring(0, 4) + osr.substring(5, 7) + osr.substring(8, 10) + osr.substring(11, 13) + osr.substring(14, 16);
  593. return tim;
  594. }
  595. /*删除文章*/
  596. $(".operateBlock").on("click",".odele",function(){
  597. $.MsgBox.Confirm("提示","确认删除该文章?",newsDelet);
  598. })
  599. /*文章删除*/
  600. function newsDelet() {
  601. $.ajax({
  602. "url" : "/ajax/article/deleteArticle",
  603. "type" : "POST",
  604. "dataType" : "json",
  605. "data": {
  606. "articleId": articleId
  607. },
  608. "success" : function($data) {
  609. if ($data.success) {
  610. location.href = "cmp-articalList.html";
  611. }
  612. },
  613. "error":function(){
  614. $.MsgBox.Alert('提示','链接服务器超时')
  615. }
  616. })
  617. }
  618. relatCompanies("#company");
  619. /*添加相关企业*/
  620. function relatCompanies(sel) {
  621. $(sel).bind({
  622. paste: function(e) {
  623. var pastedText;
  624. if (window.clipboardData  &&  window.clipboardData.getData)  {  // IE
  625.             
  626. pastedText  = $(this).val() +  window.clipboardData.getData('Text');          
  627. else  {            
  628. pastedText  = $(this).val() +  e.originalEvent.clipboardData.getData('Text'); //e.clipboardData.getData('text/plain');
  629.           
  630. }
  631. $(this).val(pastedText);
  632. e.preventDefault();
  633. },
  634. cut: function(e) {
  635. var $this = $(this);
  636. },
  637. blur: function() {
  638. var $this = $(this);
  639. $(this).siblings(".aboutTit").find("span").text("");
  640. setTimeout(function() {
  641. $this.siblings(".form-drop").hide();
  642. }, 500)
  643. },
  644. focus: function() {
  645. $(this).siblings(".form-drop").show();
  646. $(this).siblings(".aboutTit").find("span").text("最多选择5家企业");
  647. },
  648. keyup: function(e) {
  649. var ti=$(this).val();
  650. orgr=ti;
  651. var $this=$(this);
  652. if($(this).val().trim()) {
  653. var lNum = $.trim($(this).val()).length;
  654. if(0 < lNum) {
  655. setTimeout(function(){
  656. if( ti===orgr && ti!== orgrEnd) {
  657. var tt=ti;
  658. orgrEnd=tt;
  659. $("#companylist").parent().show();
  660. $.ajax({
  661. "url": "/ajax/org/qr",
  662. "type": "GET",
  663. "data":{
  664. kw: $this.val(),
  665. limit:3
  666. },
  667. "success": function(data) {
  668. console.log(data);
  669. if(data.success) {
  670. if(orgrEnd==tt) {
  671. if(data.data.length == 0) {
  672. $this.siblings(".form-drop").addClass("displayNone");
  673. $this.siblings(".form-drop").find("ul").html("");
  674. } else {
  675. $this.siblings(".form-drop").removeClass("displayNone");
  676. var oSr = "";
  677. for(var i = 0; i < data.data.length; i++) {
  678. var busName=(data.data[i].forShort)?data.data[i].forShort:data.data[i].name;
  679. oSr += '<li style="min-height:40px;position:static;"data-id="'+data.data[i].id+'">' + busName + '</li>';
  680. }
  681. $this.siblings(".form-drop").find("ul").html(oSr);
  682. }
  683. }
  684. } else {
  685. $this.siblings(".form-drop").addClass("displayNone");
  686. $this.siblings(".form-drop").find("ul").html("");
  687. }
  688. },
  689. dataType: "json",
  690. 'error': function() {
  691. $.MsgBox.Alert('提示', '服务器连接超时!');
  692. }
  693. });
  694. }
  695. },500)
  696. }
  697. } else {
  698. $(this).siblings(".form-drop").addClass("displayNone");
  699. $(this).siblings(".form-drop").find("ul").html("");
  700. }
  701. }
  702. })
  703. $("#company").siblings(".form-drop").on("click", "li", function() {
  704. var oValue = $(this).text();
  705. var oJudge = $(this).parents(".form-drop").siblings(".form-result").find("ul li");
  706. for(var i = 0; i < oJudge.length; i++) {
  707. if(oValue == oJudge[i].innerText) {
  708. $.MsgBox.Alert('提示', '该企业已选择.');
  709. return;
  710. }
  711. }
  712. $(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>');
  713. $(this).parents(".form-drop").siblings("input").val("");
  714. if(oJudge.length == 4) {
  715. $(this).parents(".form-drop").siblings("input").val("");
  716. $("#company").hide();
  717. }
  718. $(this).parent("ul").html("")
  719. })
  720. }
  721. });