TextAnalysis.vue 9.8 KB

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