TextAnalysis.vue 6.9 KB

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