ciyunPrint.html 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta http-equiv="Access-Control-Allow-Origin" content="*">
  5. <meta charset="utf-8" />
  6. <title>词云</title>
  7. <link rel="stylesheet" href="./layui/css/layui.css">
  8. <script src="./js/jquery-1.11.3.js"></script>
  9. <script type="text/javascript" src="./js/saveSvgAsPng.js"></script>
  10. <script type="text/javascript" src="./layer/layer.js"></script>
  11. <script type="text/javascript" src="./layui/layui.js"></script>
  12. <link rel="stylesheet" href="./css/common.css">
  13. <link rel="stylesheet" href="./css/jiaocai.css">
  14. <link rel="stylesheet" href="./css/font/font.css">
  15. <script src="../config.js"></script>
  16. <style type="text/css">
  17. body,
  18. html {
  19. min-width: 850px;
  20. overflow: hidden;
  21. }
  22. .content-inner {
  23. width: 850px;
  24. }
  25. #stop:hover {
  26. text-decoration: underline;
  27. color: #FF0000;
  28. }
  29. .shadow {
  30. position: absolute;
  31. width: 100%;
  32. height: 100%;
  33. left: 0;
  34. top: 0;
  35. background: rgba(0, 0, 0, 0.3);
  36. }
  37. .stop_word_table {
  38. width: 413px;
  39. position: fixed;
  40. top: 5%;
  41. left: 37%;
  42. background: #FFFFFF;
  43. border: 1px solid rgba(0, 0, 0, 0.1);
  44. padding: 24px;
  45. }
  46. .stop_word_table .title {
  47. display: flex;
  48. justify-content: space-between;
  49. align-items: center;
  50. font-weight: bold;
  51. font-size: 16px;
  52. color: #000000;
  53. padding-bottom: 16px;
  54. border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  55. }
  56. .stop_word_table .title img {
  57. width: 24px;
  58. height: 24px;
  59. cursor: pointer;
  60. }
  61. .stop_word_table .top {
  62. display: flex;
  63. align-items: center;
  64. margin-top: 16px;
  65. }
  66. .stop_word_table .top input {
  67. width: 278px;
  68. height: 40px;
  69. border: 1px solid #000000;
  70. outline: none;
  71. }
  72. .stop_word_table .top button {
  73. width: 87px;
  74. height: 40px;
  75. background: #000000;
  76. text-align: center;
  77. font-weight: bold;
  78. font-size: 16px;
  79. line-height: 40px;
  80. color: #ffffff;
  81. cursor: pointer;
  82. border: none;
  83. }
  84. .stop_word_table .main {
  85. margin-top: 16px;
  86. max-height: 340px;
  87. overflow: hidden;
  88. overflow-y: scroll;
  89. }
  90. .stop_word_table .one {
  91. display: flex;
  92. justify-content: space-between;
  93. font-size: 16px;
  94. color: #000000;
  95. height: 34px;
  96. line-height: 34px;
  97. padding: 0 8px;
  98. }
  99. .stop_word_table .right span {
  100. cursor: pointer;
  101. }
  102. .stop_word_table .main> :nth-child(2n) {
  103. background: #ffffff;
  104. }
  105. .stop_word_table .main> :nth-child(2n-1) {
  106. background: #f8f8f8;
  107. }
  108. .stop_word_table .bottom {
  109. display: flex;
  110. justify-content: space-between;
  111. margin-top: 16px;
  112. }
  113. .stop_word_table .bottom button {
  114. width: 173.5px;
  115. height: 48px;
  116. font-weight: bold;
  117. font-size: 16px;
  118. border: none;
  119. cursor: pointer;
  120. }
  121. .stop_word_table .bottom .close {
  122. background: #ebebeb;
  123. color: #000000;
  124. }
  125. .stop_word_table .bottom .add {
  126. background: #000000;
  127. color: #ffffff;
  128. }
  129. </style>
  130. </head>
  131. <body>
  132. <div class="wraps">
  133. <div class="contents">
  134. <div class="content-inner" style="padding: 0;">
  135. <div class="cloudDiv">
  136. <!-- <div class="cloud-copyright">Copyright © Jason Davies</div> -->
  137. <div class="cloud-con-div" id="cloudDiv"></div>
  138. </div>
  139. </div>
  140. </div>
  141. </div>
  142. <script src="./js/d3.min.js"></script>
  143. <script src="./js/cloud.min.js"></script>
  144. <script type="text/javascript">
  145. var stopWordList = null;
  146. var oldstopWordList = [];
  147. $(function() {
  148. initStopWords();
  149. jiekouData();
  150. })
  151. let query = location.href.split("?");
  152. let arr = query[1].split("&");
  153. var articleId = null;
  154. var searchType = null;
  155. var old_searchType = null
  156. var W_stopWordStatus = null
  157. var prefix = 'HM21St_User_Token='
  158. var start = document.cookie.indexOf(prefix)
  159. var end = document.cookie.indexOf(";", start + prefix.length)
  160. if (end == -1) {
  161. end = document.cookie.length;
  162. }
  163. var AccessToken = JSON.parse(unescape(document.cookie.substring(start + prefix.length, end))).access_token
  164. arr.forEach((item) => {
  165. if (item.split("=")[0] == "articleId") {
  166. articleId = item.split("=")[1];
  167. }
  168. if (item.split("=")[0] == "searchType") {
  169. searchType = item.split("=")[1];
  170. old_searchType = item.split("=")[1];
  171. }
  172. });
  173. // 如果是词汇 默认选中词
  174. if (old_searchType == 2) {
  175. $(".danwei div").removeClass("radio-active");
  176. $(".danwei").find("div").eq(1).addClass("radio-active")
  177. }
  178. if (old_searchType == 0) {
  179. $("#font").attr("value", "Arial");
  180. $(".danwei div").removeClass("radio-active");
  181. searchType = 3
  182. $(".danwei").find("div").eq(1).addClass("radio-active")
  183. for (let i = 0; i < $("#fontSel").children().length; i++) {
  184. if ($("#fontSel").children().eq(i)[0].value == "Arial") {
  185. $("#fontSel").children().eq(i)[0].selected = true;
  186. } else {
  187. $("#fontSel").children().eq(i)[0].selected = false;
  188. }
  189. }
  190. } else {
  191. $("#font").attr("value", "Arial");
  192. for (let i = 0; i < $("#fontSel").children().length; i++) {
  193. if ($("#fontSel").children().eq(i)[0].value == "Arial") {
  194. $("#fontSel").children().eq(i)[0].selected = true;
  195. } else {
  196. $("#fontSel").children().eq(i)[0].selected = false;
  197. }
  198. }
  199. }
  200. function getdata() {
  201. let data = {
  202. type: 0,
  203. id: articleId,
  204. stopWordStatus: W_stopWordStatus,
  205. }
  206. $.ajax({
  207. url: window.location.href.substring(0, window.location.href.indexOf('/#/')) + "/PaperServer/Client/Article/CalcArtWordCloud?AccessToken=" + AccessToken,
  208. // url: "/i21st-newspaper-management-test/api/article/detail/wordCloud",
  209. data: JSON.stringify(data),
  210. contentType: "application/json",
  211. dataType: "json",
  212. type: "post",
  213. success: function(res) {
  214. let str = ''
  215. res.data.forEach(item => {
  216. if (item.word.indexOf(" ") != -1) {
  217. item.word = item.word.replace(" ", "")
  218. }
  219. str += item.word + " "
  220. })
  221. ciyunData = res.data
  222. text = str
  223. $("#text").val(text);
  224. $("#go").trigger("click");
  225. console.log("2022-11-09 14点55分");
  226. }
  227. })
  228. }
  229. function initContent() {
  230. var dataType = $("#dataType").val();
  231. var ruleType = $("#rule").val();
  232. var fileId = "${fileId}";
  233. // $.ajax({
  234. // url: "${ctx}/bc/textKeyWords/wordCloud",
  235. // data: { "fileId": fileId, "ruleType": ruleType },
  236. // dataType: "JSON",
  237. // Type: "POST",
  238. // success: function (data) {
  239. let data = {
  240. count: 0,
  241. flag: true,
  242. jsonObject: null,
  243. listStr: [{
  244. frequency: 3,
  245. level: "L1",
  246. posStr: "[\"noun\"]",
  247. rate: "2762.15",
  248. word: "mine",
  249. }, {
  250. frequency: 2,
  251. level: "L0",
  252. posStr: "[\"adj\"]",
  253. rate: "996.51",
  254. word: "nice",
  255. }, {
  256. frequency: 3,
  257. level: "L0",
  258. posStr: "[\"noun\"]",
  259. rate: "340.09",
  260. word: "house",
  261. }, {
  262. frequency: 2,
  263. level: "L0",
  264. posStr: "[\"noun\"]",
  265. rate: "251.11",
  266. word: "friend",
  267. }],
  268. message: null,
  269. objects: null,
  270. userList: null,
  271. arr: ['5', '6', 'I', 'I', 'I', 'I', 'I', 'I', 'I', 'a', 'Hi', 'Is', 'It', 'My', 'am', 'is', 'I', 'I', 'I', 'I', 'I', 'I', 'I', 'my', 'my', 'my', 'my', 'my', 'my', 'Are', 'She', 'are', 'big', 'you', 'you', 'you', 'you', 'you', 'They', 'This', 'mine', 'mine', 'mine', 'name', 'nice', 'tall', 'than', 'than', 'than', 'than', 'than', 'than', 'than', 'than', 'than', 'than', 'very', 'very', 'very', 'very', 'you', 'you', 'you', 'you', 'you', 'Giant', 'Kendo', 'These', 'funny', 'house', 'house', 'house', 'nicer', 'think', 'think', 'three', 'yours', 'yours', 'yours', 'bigger', 'meters', 'school', 'school', 'taller', 'friends', 'funnier', 'teacher', 'teacher', 'younger', 'friendly', 'nineteen', 'friendlier', 'qinpeng']
  272. }
  273. if (data.flag) {
  274. var $stop = $(".stop");
  275. var stopFlag = $stop.hasClass("checkbox-active"); //选择了停用
  276. // if (!stopFlag) {
  277. // stopWordLists = null;
  278. // }
  279. // if (ruleType == 1) {
  280. // var themeList = data.listStr;
  281. // text = themeDeal(themeList, stopWordLists);
  282. // } else {
  283. // var object = data.jsonObject;
  284. // var words = "";
  285. // if (dataType == "Word") {
  286. // words = object['wordList'];
  287. // } else {
  288. // words = object['lemmaList'];
  289. // }
  290. let str = ''
  291. data.arr.forEach(item => {
  292. str += item + " "
  293. })
  294. // text = replaceStop(words, stopWordLists);
  295. // }
  296. text = str
  297. $("#text").val(text);
  298. $("#go").trigger("click");
  299. } else {
  300. layer.alert(data.message);
  301. }
  302. // }, error: function (jqXHR, textStatus, errorThrown) {
  303. // if (jqXHR.status == 401) {
  304. // var url = jqXHR.responseText;
  305. // layer.alert('会话已过期,请重新登陆。', function (index) {
  306. // layer.close(index);
  307. // location.reload();
  308. // });
  309. // } else {
  310. // layer.alert("网络异常,请稍后重试。(" + errorThrown + ")");
  311. // }
  312. // }
  313. // })
  314. }
  315. function initStopWords() {
  316. $.ajax({
  317. url: window.location.href.substring(0, window.location.href.indexOf('/#/')) + "/PaperServer/Client/Article/CalcArtWordCloud_stopWordList?AccessToken=" + AccessToken,
  318. // url: "/i21st-newspaper-management-test/api/user/stopVocab/get",
  319. data: JSON.stringify({}),
  320. contentType: "application/json;charset=UTF-8",
  321. dataType: "json",
  322. type: "post",
  323. success: function(res) {
  324. let arr = []
  325. res.data.result.forEach(item => {
  326. arr.push(item.word)
  327. })
  328. oldstopWordList = JSON.parse(JSON.stringify(arr))
  329. stopWordList = JSON.parse(JSON.stringify(arr))
  330. $("#allwordnumber").text(oldstopWordList.length)
  331. changeWordData()
  332. },
  333. error: function(jqXHR, textStatus, errorThrown) {
  334. if (jqXHR.status == 401) {
  335. var url = jqXHR.responseText;
  336. layer.alert('会话已过期,请重新登陆。', function(index) {
  337. layer.close(index);
  338. location.reload();
  339. });
  340. } else {
  341. layer.alert("网络异常,请稍后重试。(" + errorThrown + ")");
  342. }
  343. }
  344. });
  345. }
  346. $(".rule div").click(function() {
  347. $(".rule div").removeClass("radio-active");
  348. $(this).addClass("radio-active");
  349. $("#rule").attr("value", $(this).attr("value"))
  350. initContent();
  351. })
  352. $(".styleType div").click(function() {
  353. $(".styleType div").removeClass("radio-active");
  354. $(this).addClass("radio-active");
  355. $("#spiral").attr("value", $(this).attr("value"));
  356. $("#go").trigger("click");
  357. })
  358. // 切换单位
  359. $(".danwei div").click(function() {
  360. $(".danwei div").removeClass("radio-active");
  361. $(this).addClass("radio-active");
  362. var value = $(this).attr("value");
  363. let newvalue = null
  364. if (old_searchType == 0) { //拼音
  365. if (value == 'zi') {
  366. newvalue = 0
  367. } else {
  368. newvalue = 3
  369. }
  370. } else if (old_searchType == 2) {
  371. if (value == 'zi') {
  372. newvalue = 1
  373. } else {
  374. newvalue = 2
  375. }
  376. } else {
  377. if (value == 'zi') {
  378. newvalue = 1
  379. } else {
  380. newvalue = 4
  381. }
  382. }
  383. searchType = newvalue
  384. getdata()
  385. })
  386. $(".fontDriect div").click(function() {
  387. $(".fontDriect div").removeClass("radio-active");
  388. $(this).addClass("radio-active");
  389. var value = $(this).attr("value");
  390. if (value == 1) {
  391. $("#angle-from").val(0);
  392. $("#angle-to").val(0);
  393. $("#angle-count").val(1);
  394. inChange();
  395. $("#go").click();
  396. $("#angles svg").remove();
  397. } else if (value == 2) {
  398. $("#angle-from").val(90)
  399. $("#angle-to").val(90)
  400. $("#angle-count").val(1);
  401. inChange();
  402. $("#go").click();
  403. $("#angles svg").remove();
  404. } else if (value == 3) {
  405. $("#angle-from").val(0)
  406. $("#angle-to").val(90)
  407. $("#angle-count").val(2);
  408. inChange();
  409. $("#go").click();
  410. $("#angles svg").remove();
  411. }
  412. })
  413. $(".scaleSel div").click(function() {
  414. $(".scaleSel div").removeClass("radio-active");
  415. $(this).addClass("radio-active");
  416. var value = $(this).attr("value");
  417. $("#scale").attr("value", value);
  418. $("#go").trigger("click");
  419. })
  420. $("#fontSel").change(function() {
  421. var value = $(this).children('option:selected').val();
  422. $("#font").attr("value", value);
  423. $("#go").trigger("click");
  424. })
  425. $("#download-png").click(function() {
  426. var el = d3.select("#cloudDiv").node().children[0];
  427. saveSvgAsPng(el, "词云.png");
  428. })
  429. // $(".stopWordList").click(function () {
  430. // var openy = layer.open({
  431. // title: '停用词表'
  432. // , title: false
  433. // , content: '${ctx}/bc/textKeyWords/stopWordListHtml?fileId=${fileId}'
  434. // , area: ['440px', '595px']
  435. // , type: 2
  436. // , closeBtn: 0
  437. // });
  438. // initStopWords();
  439. // })
  440. $("#dataTypeSel").change(function() {
  441. var selvalue = $(this).children('option:selected').val();
  442. // var ruleVlue = $("#rule").attr("value");
  443. // $("#dataType").attr("value", selvalue);
  444. // initContent();
  445. jiekouData()
  446. });
  447. $(".stop").click(function() {
  448. var $stop = $(".stop");
  449. if ($stop.hasClass("checkbox-active")) {
  450. $stop.removeClass("checkbox-active");
  451. } else {
  452. $stop.addClass("checkbox-active");
  453. }
  454. jiekouData()
  455. })
  456. $(".biglittle").click(function() {
  457. var $stop = $(".biglittle");
  458. if ($stop.hasClass("checkbox-active")) {
  459. $stop.removeClass("checkbox-active");
  460. } else {
  461. $stop.addClass("checkbox-active");
  462. }
  463. jiekouData()
  464. })
  465. function jiekouData() {
  466. var $biglittle = $(".biglittle");
  467. var $stop = $(".stop");
  468. let isSelectCaseSensitive = false
  469. let isSelectLemma = false
  470. let stopWordStatus = false
  471. if ($biglittle.hasClass("checkbox-active")) {
  472. isSelectCaseSensitive = true
  473. } else {
  474. isSelectCaseSensitive = false
  475. }
  476. if ($stop.hasClass("checkbox-active")) {
  477. stopWordStatus = 1
  478. } else {
  479. stopWordStatus = 0
  480. }
  481. var selvalue = $("#dataTypeSel").children('option:selected').val();
  482. if (selvalue == 'Lemma') {
  483. isSelectLemma = true;
  484. } else {
  485. isSelectLemma = false;
  486. }
  487. W_stopWordStatus = stopWordStatus
  488. getdata()
  489. }
  490. function replaceStop(words, stopWordList) {
  491. var text = "";
  492. var wordListLow = new Array();
  493. if (stopWordList != null) {
  494. for (var i = 0; i < stopWordList.length; i++) {
  495. wordListLow.push(stopWordList[i].toLowerCase());
  496. }
  497. }
  498. for (var i = 0; i < words.length; i++) {
  499. var wordList = words[i];
  500. var word = wordList[0];
  501. var count = wordList[1];
  502. if (wordListLow.indexOf(word) < 0) {
  503. for (var j = 0; j < count; j++) {
  504. text += word + " ";
  505. }
  506. }
  507. }
  508. return text;
  509. }
  510. function themeDeal(theme, stopWordList) {
  511. var text = "";
  512. var wordListLow = new Array();
  513. if (stopWordList != null) {
  514. for (var i = 0; i < stopWordList.length; i++) {
  515. wordListLow.push(stopWordList[i].toLowerCase());
  516. }
  517. }
  518. for (var i = 0; i < theme.length; i++) {
  519. var themeWord = theme[i];
  520. var word = themeWord['word'];
  521. var flag = false;
  522. if (wordListLow.indexOf(word.toLowerCase()) > -1) {
  523. flag = true;
  524. }
  525. if (!flag) {
  526. var rate = Math.round(themeWord['rate']);
  527. for (var j = 0; j < rate; j++) {
  528. text += word + " ";
  529. }
  530. }
  531. }
  532. return text;
  533. }
  534. // 停用词表
  535. $("#stop").click(function() {
  536. $("#shadow").show()
  537. changeWordData()
  538. })
  539. // 处理词表数据
  540. var editOldVal = ""
  541. function changeWordData(msg, arr) {
  542. if (arr) {
  543. stopWordList = JSON.parse(JSON.stringify(arr));
  544. } else {
  545. stopWordList = JSON.parse(JSON.stringify(oldstopWordList));
  546. }
  547. $("#stop_word_table").empty()
  548. for (let i = 0; i < stopWordList.length; i++) {
  549. let node = ` <div class="one">
  550. <div>${stopWordList[i]}</div>
  551. <div class="right">
  552. <span style="margin-right: 24px" id="edit${i}" @click="edit(item)">编辑</span>
  553. <span @click="deleteOne(item, i)" id="delete${i}">删除</span>
  554. </div>
  555. </div>`
  556. $("#stop_word_table").append(node)
  557. $(`#edit${i}`).click(function() {
  558. $("#editwordDom").show()
  559. $("#wordTable").hide()
  560. $("#editwordContent").val(stopWordList[i])
  561. editOldVal = stopWordList[i]
  562. })
  563. $(`#delete${i}`).click(function() {
  564. oldstopWordList.forEach((item, i) => {
  565. if (stopWordList[i] == item) {
  566. oldstopWordList.splice(i, 1)
  567. }
  568. })
  569. updatawordData()
  570. })
  571. }
  572. if (msg) {
  573. layer.msg("成功")
  574. }
  575. }
  576. function updatawordData() {
  577. let userStopVocab = JSON.parse(JSON.stringify(oldstopWordList));
  578. $.ajax({
  579. url: window.location.href.substring(0, window.location.href.indexOf('/#/')) + "/PaperServer/Client/Article/CalcArtWordCloud_stopWordSave?AccessToken=" + AccessToken,
  580. // url: "/i21st-newspaper-management-test/api/user/stopVocab/update",
  581. data: JSON.stringify({
  582. tenantId: "",
  583. wordList: userStopVocab
  584. }),
  585. contentType: "application/json;charset=UTF-8",
  586. dataType: "json",
  587. type: "post",
  588. success: function(data) {
  589. let val = $("#wordContent").val()
  590. if (val != "") {
  591. $("#seekWordBtn").click()
  592. } else {
  593. changeWordData("msg")
  594. }
  595. },
  596. error: function(jqXHR, textStatus, errorThrown) {
  597. if (jqXHR.status == 401) {
  598. var url = jqXHR.responseText;
  599. layer.alert('会话已过期,请重新登陆。', function(index) {
  600. layer.close(index);
  601. location.reload();
  602. });
  603. } else {
  604. layer.alert("网络异常,请稍后重试。(" + errorThrown + ")");
  605. }
  606. }
  607. })
  608. }
  609. // 搜索
  610. $("#seekWordBtn").click(function() {
  611. let val = $("#wordContent").val()
  612. let arr = []
  613. if (val == "") {
  614. stopWordList = JSON.parse(JSON.stringify(oldstopWordList))
  615. changeWordData("msg")
  616. } else {
  617. oldstopWordList.forEach((item, i) => {
  618. if (item.indexOf(val) != -1) {
  619. arr.push(item);
  620. }
  621. })
  622. // stopWordList = JSON.parse(JSON.stringify(arr))
  623. changeWordData("msg", arr)
  624. }
  625. })
  626. // 清空
  627. $("#emptyWord").click(function() {
  628. oldstopWordList = []
  629. updatawordData()
  630. })
  631. // 关闭
  632. $("#closeWord").click(function() {
  633. $("#shadow").hide()
  634. getdata()
  635. })
  636. // 新增 addWord
  637. $("#addWord").click(function() {
  638. $("#addwordDom").show()
  639. $("#wordTable").hide()
  640. $("#addwordContent").val("")
  641. })
  642. // 确定新增 addSubmit
  643. $("#addSubmit").click(function() {
  644. let val = $("#addwordContent").val()
  645. if (val == '') {
  646. layer.msg("请输入内容")
  647. return
  648. } else {
  649. let flag = false;
  650. oldstopWordList.forEach(item => {
  651. if (item == val) {
  652. flag = true
  653. }
  654. })
  655. if (flag) {
  656. layer.msg("该词已经存在,请勿重复添加")
  657. return
  658. }
  659. oldstopWordList.unshift(val)
  660. stopWordList.unshift(val)
  661. $("#wordTable").show()
  662. $("#addwordDom").hide()
  663. updatawordData()
  664. }
  665. })
  666. // 确定修改
  667. $('#editSubmit').click(function() {
  668. let val = $("#editwordContent").val()
  669. if (val == '') {
  670. layer.msg("请输入内容")
  671. return
  672. } else {
  673. let flag = false;
  674. oldstopWordList.forEach(item => {
  675. if (item == val) {
  676. flag = true
  677. }
  678. })
  679. if (flag) {
  680. layer.msg("该词已经存在,请勿重复添加")
  681. return
  682. }
  683. let arr = JSON.parse(JSON.stringify(oldstopWordList))
  684. let index = null
  685. arr.forEach((item, i) => {
  686. if (item == editOldVal) {
  687. index = i
  688. }
  689. })
  690. arr[index] = val
  691. oldstopWordList = JSON.parse(JSON.stringify(arr))
  692. stopWordList = JSON.parse(JSON.stringify(arr))
  693. $("#wordTable").show()
  694. $("#editwordDom").hide()
  695. updatawordData()
  696. }
  697. })
  698. // 关闭新增词
  699. $("#closeWordadd").click(function() {
  700. $("#wordTable").show()
  701. $("#addwordDom").hide()
  702. })
  703. $("#canceladd").click(function() {
  704. $("#wordTable").show()
  705. $("#addwordDom").hide()
  706. })
  707. // 关闭编辑
  708. $("#closeWordedit").click(function() {
  709. $("#wordTable").show()
  710. $("#editwordDom").hide()
  711. })
  712. $("#canceledit").click(function() {
  713. $("#wordTable").show()
  714. $("#editwordDom").hide()
  715. })
  716. </script>
  717. </body>
  718. </html>