portal html css js resource

articalIssue.js 23KB

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