TextAnalysis.vue 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349
  1. <template>
  2. <div class="TextAnalysis" v-loading="loading">
  3. <Header />
  4. <div class="main">
  5. <div class="title">文本分析</div>
  6. <div class="input_main">
  7. <el-input
  8. type="textarea"
  9. placeholder="请输入文本"
  10. :autosize="{ minRows: 9 }"
  11. v-model="txt"
  12. >
  13. </el-input>
  14. <div class="text_btn">
  15. <span class="left">{{ txt.length }}/1000</span>
  16. <span class="btn" @click="submit">分析</span>
  17. </div>
  18. </div>
  19. <div class="list_main" v-if="data">
  20. <div class="title">
  21. <span style="margin-right: 16px">分析记录:</span>
  22. <span>{{ data.total }}/20</span>
  23. </div>
  24. <div class="list">
  25. <div v-for="(item, i) in data.list" :key="i + 'one'">
  26. <div class="number">{{ item.number }}</div>
  27. <div class="txt" @click="goresult(item)">
  28. {{ item.firstSentence }}
  29. </div>
  30. <div class="time">{{ item.createDate }}</div>
  31. <div class="cxjx" @click="anewSubmit(item)">重新解析</div>
  32. <img
  33. @click="deleteOne(item.id, i)"
  34. src="../../assets/teacherdev/delete-one.png"
  35. alt=""
  36. />
  37. </div>
  38. </div>
  39. </div>
  40. </div>
  41. </div>
  42. </template>
  43. <script>
  44. //这里可以导入其它文件(比如:组件,工具js,第三方插件js,json文件,图片文件等等)
  45. //例如:import 《组件名称》from ‘《组件路径》';
  46. import Header from "@/components/Header";
  47. import { postapi } from "@/api/api";
  48. import { getToken } from "@/utils/auth";
  49. export default {
  50. //import引入的组件需要注入到对象中才能使用
  51. components: {
  52. Header,
  53. },
  54. props: {},
  55. data() {
  56. //这里存放数据
  57. return {
  58. txt: "",
  59. loading: false,
  60. token: null,
  61. page: 1,
  62. pageSize: 20,
  63. data: null,
  64. };
  65. },
  66. //计算属性 类似于data概念
  67. computed: {},
  68. //监控data中数据变化
  69. watch: {},
  70. //方法集合
  71. methods: {
  72. // 分析结果统计
  73. goresult(item) {
  74. window.open(
  75. this.$router.resolve({
  76. path: "/textanalysis/Result",
  77. query: {
  78. partitionKey: item.partitionKey,
  79. subjectWords: item.subjectWords,
  80. wordTextCount: item.textCount,
  81. wordCount: item.wordCount,
  82. vocabularyTextCount: item.vocabularyTextCount,
  83. vocabularyCount: item.vocabularyCount,
  84. pinyinCount: item.pinyinCount,
  85. pinyinTextCount: item.pinyinTextCount,
  86. pinyinDifficulty: item.pinyinDifficulty,
  87. wordDifficulty: item.wordDifficulty,
  88. vocabularyDifficulty: item.vocabularyDifficulty,
  89. type: "文本分析",
  90. },
  91. }).href,
  92. "_blank"
  93. );
  94. },
  95. // 删除
  96. deleteOne(id, index) {
  97. this.loading = true;
  98. postapi({
  99. url: "/GCLSTCServer/tools/TS/analysis/record/del",
  100. data: {
  101. id,
  102. },
  103. })
  104. .then((res) => {
  105. this.data.list.splice(index, 1);
  106. this.data.total = this.data.total - 1;
  107. this.$message.success(res.msg);
  108. this.loading = false;
  109. })
  110. .catch((res) => {
  111. this.loading = false;
  112. });
  113. },
  114. anewSubmit(item) {
  115. this.loading = true;
  116. postapi({
  117. url: "/GCLSTCServer/tools/TS/reparse",
  118. data: {
  119. partitionKey: item.partitionKey,
  120. },
  121. })
  122. .then((res) => {
  123. window.open(
  124. this.$router.resolve({
  125. path: "/textanalysis/Result",
  126. query: {
  127. partitionKey: res.data.result.partitionKey,
  128. subjectWords: res.data.result.subjectWords,
  129. wordTextCount: res.data.result.textCount,
  130. wordCount: res.data.result.wordCount,
  131. vocabularyTextCount: res.data.result.vocabularyTextCount,
  132. vocabularyCount: res.data.result.vocabularyCount,
  133. pinyinCount: res.data.result.pinyinCount,
  134. pinyinTextCount: res.data.result.pinyinTextCount,
  135. pinyinDifficulty: res.data.result.pinyinDifficulty,
  136. wordDifficulty: res.data.result.wordDifficulty,
  137. vocabularyDifficulty: res.data.result.vocabularyDifficulty,
  138. type: "文本分析",
  139. },
  140. }).href,
  141. "_blank"
  142. );
  143. this.getlist(true);
  144. // this.loading = false;
  145. })
  146. .catch((res) => {
  147. this.loading = false;
  148. });
  149. },
  150. // 分析
  151. submit(msg) {
  152. if (this.txt == "") {
  153. this.$message.warning("请先输入内容");
  154. return;
  155. }
  156. this.loading = true;
  157. postapi({
  158. url: "/GCLSTCServer/tools/TS/analys",
  159. data: {
  160. tenantId: "",
  161. text: this.txt,
  162. },
  163. })
  164. .then((res) => {
  165. this.txt = "";
  166. window.open(
  167. this.$router.resolve({
  168. path: "/textanalysis/Result",
  169. query: {
  170. partitionKey: res.data.result.partitionKey,
  171. subjectWords: res.data.result.subjectWords,
  172. wordTextCount: res.data.result.textCount,
  173. wordCount: res.data.result.wordCount,
  174. vocabularyTextCount: res.data.result.vocabularyTextCount,
  175. vocabularyCount: res.data.result.vocabularyCount,
  176. pinyinCount: res.data.result.pinyinCount,
  177. pinyinTextCount: res.data.result.pinyinTextCount,
  178. pinyinDifficulty: res.data.result.pinyinDifficulty,
  179. wordDifficulty: res.data.result.wordDifficulty,
  180. vocabularyDifficulty: res.data.result.vocabularyDifficulty,
  181. type: "文本分析",
  182. },
  183. }).href,
  184. "_blank"
  185. );
  186. this.getlist(true);
  187. // this.loading = false;
  188. })
  189. .catch((res) => {
  190. this.loading = false;
  191. });
  192. },
  193. getlist(msg) {
  194. this.loading = true;
  195. postapi({
  196. url: "/GCLSTCServer/tools/TS/analysis/record/list",
  197. data: {
  198. pageIndex: this.page,
  199. pageSize: this.pageSize,
  200. },
  201. })
  202. .then((res) => {
  203. let num = this.page * this.pageSize - this.pageSize + 1;
  204. res.data.result.list.forEach((item) => {
  205. item.number = num;
  206. num++;
  207. });
  208. this.data = res.data.result;
  209. if (msg) {
  210. this.$message.success(res.msg);
  211. }
  212. this.loading = false;
  213. })
  214. .catch((res) => {
  215. this.loading = false;
  216. });
  217. },
  218. },
  219. //生命周期 - 创建完成(可以访问当前this实例)
  220. created() {
  221. let data = getToken();
  222. this.token = JSON.parse(data);
  223. this.getlist();
  224. },
  225. //生命周期 - 挂载完成(可以访问DOM元素)
  226. mounted() {},
  227. //生命周期-创建之前
  228. beforeCreated() {},
  229. //生命周期-挂载之前
  230. beforeMount() {},
  231. //生命周期-更新之前
  232. beforUpdate() {},
  233. //生命周期-更新之后
  234. updated() {},
  235. //生命周期-销毁之前
  236. beforeDestory() {},
  237. //生命周期-销毁完成
  238. destoryed() {},
  239. //如果页面有keep-alive缓存功能,这个函数会触发
  240. activated() {},
  241. };
  242. </script>
  243. <style lang="scss" scoped>
  244. /* @import url(); 引入css类 */
  245. .TextAnalysis {
  246. height: 100%;
  247. .main {
  248. height: 100%;
  249. background: #f6f6f6;
  250. padding-top: 54px;
  251. padding-bottom: 24px;
  252. > div {
  253. width: 1200px;
  254. margin: 0 auto;
  255. }
  256. > .title {
  257. font-weight: 700;
  258. font-size: 30px;
  259. line-height: 43px;
  260. color: #2c2c2c;
  261. }
  262. .input_main {
  263. width: 1168px;
  264. margin-top: 17px;
  265. padding: 16px;
  266. height: 295px;
  267. background: #ffffff;
  268. border-radius: 4px;
  269. .text_btn {
  270. margin-top: 16px;
  271. display: flex;
  272. justify-content: space-between;
  273. align-items: center;
  274. .left {
  275. font-weight: 400;
  276. font-size: 14px;
  277. line-height: 26px;
  278. color: #000000;
  279. }
  280. .btn {
  281. font-weight: 500;
  282. font-size: 16px;
  283. line-height: 40px;
  284. color: #000000;
  285. width: 124px;
  286. height: 40px;
  287. background: #ffc600;
  288. border: 1px solid rgba(0, 0, 0, 0.15);
  289. box-shadow: 0px 2px 0px rgba(0, 0, 0, 0.04);
  290. border-radius: 4px;
  291. text-align: center;
  292. cursor: pointer;
  293. }
  294. }
  295. }
  296. .list_main {
  297. margin-top: 37px;
  298. .title {
  299. font-weight: 400;
  300. font-size: 16px;
  301. line-height: 24px;
  302. color: #000000;
  303. }
  304. .list {
  305. margin-top: 16px;
  306. > div {
  307. display: flex;
  308. align-items: center;
  309. padding: 0 16px;
  310. height: 48px;
  311. background: #ffffff;
  312. border-bottom: 1px solid rgba(0, 0, 0, 0.08);
  313. font-weight: 400;
  314. font-size: 16px;
  315. color: #000000;
  316. .number {
  317. width: 20px;
  318. text-align: right;
  319. margin-right: 24px;
  320. }
  321. .txt {
  322. width: 774px;
  323. overflow: hidden;
  324. white-space: nowrap;
  325. text-overflow: ellipsis;
  326. margin-right: 24px;
  327. cursor: pointer;
  328. }
  329. .time {
  330. width: 190px;
  331. margin-right: 24px;
  332. }
  333. .cxjx {
  334. margin-right: 24px;
  335. cursor: pointer;
  336. }
  337. img {
  338. width: 24px;
  339. height: 24px;
  340. cursor: pointer;
  341. }
  342. }
  343. }
  344. }
  345. }
  346. }
  347. </style>