TextAnalysis.vue 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307
  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. type: "文本分析",
  87. },
  88. }).href,
  89. "_blank"
  90. );
  91. },
  92. // 删除
  93. deleteOne(id, index) {
  94. this.loading = true;
  95. postapi({
  96. url: "GCLSTRCServer/tools/TS/analysis/record/del",
  97. data: {
  98. id,
  99. },
  100. })
  101. .then((res) => {
  102. this.data.list.splice(index, 1);
  103. this.data.total = this.data.total - 1;
  104. this.$message.success(res.msg);
  105. this.loading = false;
  106. })
  107. .catch((res) => {
  108. this.loading = false;
  109. });
  110. },
  111. anewSubmit(item) {
  112. this.loading = true;
  113. postapi({
  114. url: "GCLSTRCServer/tools/TS/reparse",
  115. data: {
  116. partitionKey: item.partitionKey,
  117. },
  118. })
  119. .then((res) => {
  120. this.getlist(true);
  121. // this.loading = false;
  122. })
  123. .catch((res) => {
  124. this.loading = false;
  125. });
  126. },
  127. // 分析
  128. submit(msg) {
  129. if (this.txt == "") {
  130. this.$message.warning("请先输入内容");
  131. return;
  132. }
  133. this.loading = true;
  134. postapi({
  135. url: "GCLSTRCServer/tools/TS/analys",
  136. data: {
  137. tenantId: "",
  138. text: this.txt,
  139. },
  140. })
  141. .then((res) => {
  142. this.txt = "";
  143. this.getlist(true);
  144. // this.loading = false;
  145. })
  146. .catch((res) => {
  147. this.loading = false;
  148. });
  149. },
  150. getlist(msg) {
  151. this.loading = true;
  152. postapi({
  153. url: "GCLSTRCServer/tools/TS/analysis/record/list",
  154. data: {
  155. pageIndex: this.page,
  156. pageSize: this.pageSize,
  157. },
  158. })
  159. .then((res) => {
  160. let num = this.page * this.pageSize - this.pageSize + 1;
  161. res.data.result.list.forEach((item) => {
  162. item.number = num;
  163. num++;
  164. });
  165. this.data = res.data.result;
  166. if (msg) {
  167. this.$message.success(res.msg);
  168. }
  169. this.loading = false;
  170. })
  171. .catch((res) => {
  172. this.loading = false;
  173. });
  174. },
  175. },
  176. //生命周期 - 创建完成(可以访问当前this实例)
  177. created() {
  178. let data = getToken();
  179. this.token = JSON.parse(data);
  180. this.getlist();
  181. },
  182. //生命周期 - 挂载完成(可以访问DOM元素)
  183. mounted() {},
  184. //生命周期-创建之前
  185. beforeCreated() {},
  186. //生命周期-挂载之前
  187. beforeMount() {},
  188. //生命周期-更新之前
  189. beforUpdate() {},
  190. //生命周期-更新之后
  191. updated() {},
  192. //生命周期-销毁之前
  193. beforeDestory() {},
  194. //生命周期-销毁完成
  195. destoryed() {},
  196. //如果页面有keep-alive缓存功能,这个函数会触发
  197. activated() {},
  198. };
  199. </script>
  200. <style lang="scss" scoped>
  201. /* @import url(); 引入css类 */
  202. .TextAnalysis {
  203. height: 100%;
  204. .main {
  205. height: 100%;
  206. background: #f6f6f6;
  207. padding-top: 54px;
  208. padding-bottom: 24px;
  209. > div {
  210. width: 1200px;
  211. margin: 0 auto;
  212. }
  213. > .title {
  214. font-weight: 700;
  215. font-size: 30px;
  216. line-height: 43px;
  217. color: #2c2c2c;
  218. }
  219. .input_main {
  220. width: 1168px;
  221. margin-top: 17px;
  222. padding: 16px;
  223. height: 295px;
  224. background: #ffffff;
  225. border-radius: 4px;
  226. .text_btn {
  227. margin-top: 16px;
  228. display: flex;
  229. justify-content: space-between;
  230. align-items: center;
  231. .left {
  232. font-weight: 400;
  233. font-size: 14px;
  234. line-height: 26px;
  235. color: #000000;
  236. }
  237. .btn {
  238. font-weight: 500;
  239. font-size: 16px;
  240. line-height: 40px;
  241. color: #000000;
  242. width: 124px;
  243. height: 40px;
  244. background: #ffc600;
  245. border: 1px solid rgba(0, 0, 0, 0.15);
  246. box-shadow: 0px 2px 0px rgba(0, 0, 0, 0.04);
  247. border-radius: 4px;
  248. text-align: center;
  249. cursor: pointer;
  250. }
  251. }
  252. }
  253. .list_main {
  254. margin-top: 37px;
  255. .title {
  256. font-weight: 400;
  257. font-size: 16px;
  258. line-height: 24px;
  259. color: #000000;
  260. }
  261. .list {
  262. margin-top: 16px;
  263. > div {
  264. display: flex;
  265. align-items: center;
  266. padding: 0 16px;
  267. height: 48px;
  268. background: #ffffff;
  269. border-bottom: 1px solid rgba(0, 0, 0, 0.08);
  270. font-weight: 400;
  271. font-size: 16px;
  272. color: #000000;
  273. .number {
  274. width: 20px;
  275. text-align: right;
  276. margin-right: 24px;
  277. }
  278. .txt {
  279. width: 774px;
  280. overflow: hidden;
  281. white-space: nowrap;
  282. text-overflow: ellipsis;
  283. margin-right: 24px;
  284. cursor: pointer;
  285. }
  286. .time {
  287. width: 190px;
  288. margin-right: 24px;
  289. }
  290. .cxjx {
  291. margin-right: 24px;
  292. cursor: pointer;
  293. }
  294. img {
  295. width: 24px;
  296. height: 24px;
  297. cursor: pointer;
  298. }
  299. }
  300. }
  301. }
  302. }
  303. }
  304. </style>