Browse Source

文本分析重构

dusenyao 1 năm trước cách đây
mục cha
commit
75bd1e1480

+ 15 - 0
src/api/api.js

@@ -363,6 +363,21 @@ export function analyse(data) {
     data,
   });
 }
+
+/**
+ * 重新解析
+ * @param {object} data
+ * @param {string} data.analyse_record_id 分析记录id
+ */
+export function reparse(data) {
+  return request({
+    method: 'post',
+    url: `/GCLSTCServer/tools/TS/reparse`,
+    params: getAccessToken(),
+    data,
+  });
+}
+
 // 消息部分
 export function getLearnWebContent(MethodName, data) {
   let userInfor = getToken();

+ 3 - 4
src/common/data.js

@@ -1,4 +1,4 @@
-const LevelMap = {
+const levelMap = {
   初等: { name: '初等', color: '#66AE5B' },
   中等: { name: '中等', color: '#4CA6EE' },
   高等: { name: '高等', color: '#9031AA' },
@@ -13,6 +13,5 @@ const LevelMap = {
   '中等(6级)': { name: '中等(6级)', color: '#3873CB' },
   '高等(7-9级)': { name: '高等(7-9级)', color: '#9031AA' },
 };
-export default {
-  LevelMap,
-};
+
+export { levelMap };

+ 35 - 37
src/main.js

@@ -1,49 +1,47 @@
-import Vue from 'vue'
-import App from './App.vue'
-import router from './router'
-import store from './store'
-Vue.config.productionTip = false
+import Vue from 'vue';
+import App from './App.vue';
+import router from './router';
+import store from './store';
+Vue.config.productionTip = false;
 import ElementUI from 'element-ui';
 import 'element-ui/lib/theme-chalk/index.css';
 Vue.use(ElementUI);
 
-import "./style/deleelement.css"
-import $ from "jquery"
-Vue.prototype.$ = $
+import './style/index.scss';
+import $ from 'jquery';
+Vue.prototype.$ = $;
 
-import "@/common/font/font.css"
-import "@/permission"
-import i18n from "@/utils/i18n"
-import '@/icons' // icon
+import '@/common/font/font.css';
+import '@/permission';
+import i18n from '@/utils/i18n';
+import '@/icons'; // icon
+import zh_tran from '@/utils/lang.js';
+Vue.prototype.$zh_tran = zh_tran;
 
+import htmlToPdf from '@/utils/htmlToPdf';
+Vue.use(htmlToPdf);
 
-import zh_tran from "@/utils/lang.js"
-Vue.prototype.$zh_tran = zh_tran
+import '@/utils/jquery-1.9.0.min.js';
+import '@/utils/playbackSDK.js';
+import '@/utils/liveSDK.js';
 
-import htmlToPdf from '@/utils/htmlToPdf'
-Vue.use(htmlToPdf)
-
-import "@/utils/jquery-1.9.0.min.js"
-import "@/utils/playbackSDK.js"
-import "@/utils/liveSDK.js"
 // element 下拉框下拉加载
 Vue.directive('loadmore', {
-    bind(el, binding) {
-        // 获取element-ui定义好的scroll盒子
-        const SELECTWRAP_DOM = el.querySelector('.el-select-dropdown .el-select-dropdown__wrap')
-        SELECTWRAP_DOM.addEventListener('scroll', function() {
-            const CONDITION = this.scrollHeight - this.scrollTop <= this.clientHeight
-            if (CONDITION) {
-                binding.value()
-            }
-        })
-    }
-})
-
+  bind(el, binding) {
+    // 获取element-ui定义好的scroll盒子
+    const SELECTWRAP_DOM = el.querySelector('.el-select-dropdown .el-select-dropdown__wrap');
+    SELECTWRAP_DOM.addEventListener('scroll', (e) => {
+      const CONDITION = e.scrollHeight - e.scrollTop <= e.clientHeight;
+      if (CONDITION) {
+        binding.value();
+      }
+    });
+  },
+});
 
 new Vue({
-    router,
-    store,
-    i18n,
-    render: h => h(App)
-}).$mount('#app')
+  router,
+  store,
+  i18n,
+  render: (h) => h(App),
+}).$mount('#app');

+ 3 - 0
src/style/common.scss

@@ -0,0 +1,3 @@
+.pointer {
+  cursor: pointer;
+}

+ 0 - 3
src/style/deleelement.css

@@ -1,3 +0,0 @@
-.el-dropdown {
-    /* width: 100px; */
-}

+ 0 - 3
src/style/deleelement.less

@@ -1,3 +0,0 @@
-.el-dropdown{
-  width: 100px;
-}

+ 5 - 0
src/style/index.scss

@@ -0,0 +1,5 @@
+@use './common.scss';
+
+.el-dropdown {
+  /* width: 100px; */
+}

Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 269 - 361
src/views/Textanalysis/WordTable.vue


+ 16 - 18
src/views/Textanalysis/index.vue

@@ -387,11 +387,12 @@ import 'echarts/lib/chart/bar';
 import 'echarts/lib/component/legend';
 import 'echarts/lib/component/title';
 import { postapi } from '@/api/api';
-import staticData from '../../common/data';
+import { levelMap } from '../../common/data';
 import { json2excel } from '@/utils/setMethods';
 
 import FileSaver from 'file-saver';
 import htmlDocx from 'html-docx-js/dist/html-docx';
+
 export default {
   components: {
     HeaderPage,
@@ -450,7 +451,7 @@ export default {
       subjectWords: null,
       partitionKey: null,
       base: {},
-      levelMap: null,
+      levelMap,
       allValue: 0,
       allRatio: 0,
       chartIndex: 0,
@@ -461,25 +462,22 @@ export default {
       routerData: null,
     };
   },
-  watch: {},
   created() {
-    this.routerData = JSON.parse(JSON.stringify(this.$route.query));
-    console.log(this.routerData);
-    this.partitionKey = Number(this.$route.query.partitionKey);
-    this.subjectWords = JSON.parse(this.$route.query.subjectWords || '[]');
-    this.base.wordTextCount = Number(this.$route.query.wordTextCount);
-    this.base.wordCount = Number(this.$route.query.wordCount);
-    this.base.vocabularyTextCount = Number(this.$route.query.vocabularyTextCount);
-    this.base.vocabularyCount = Number(this.$route.query.vocabularyCount);
-    this.base.pinyinCount = Number(this.$route.query.pinyinCount);
-    this.base.pinyinTextCount = Number(this.$route.query.pinyinTextCount);
-    this.difficulty.pinyinDifficulty = this.$route.query.pinyinDifficulty;
-    this.difficulty.vocabularyDifficulty = this.$route.query.vocabularyDifficulty;
-    this.difficulty.wordDifficulty = this.$route.query.wordDifficulty;
-    this.levelMap = staticData.LevelMap;
+    this.routerData = this.$route.query;
+    if (!this.routerData) return;
+    this.partitionKey = Number(this.routerData.partition_key);
+    this.subjectWords = JSON.parse(this.routerData.subject_words || '[]');
+    this.base.wordTextCount = Number(this.routerData.word_text_count);
+    this.base.wordCount = Number(this.routerData.word_count);
+    this.base.vocabularyTextCount = Number(this.routerData.vocabulary_text_count);
+    this.base.vocabularyCount = Number(this.routerData.vocabulary_count);
+    this.base.pinyinCount = Number(this.routerData.pinyin_count);
+    this.base.pinyinTextCount = Number(this.routerData.pinyin_text_count);
+    this.difficulty.pinyinDifficulty = this.routerData.pinyin_difficulty;
+    this.difficulty.vocabularyDifficulty = this.routerData.vocabulary_difficulty;
+    this.difficulty.wordDifficulty = this.routerData.word_difficulty;
     this.getstatistics();
   },
-  mounted() {},
   methods: {
     // 词表
     gowordTable() {

+ 63 - 99
src/views/teacher-dev/TextAnalysis.vue

@@ -28,10 +28,6 @@
       <div v-if="data" class="list_main">
         <div class="title">
           <span style="margin-right: 16px">文本列表:</span>
-          <span>
-            {{ data.cur_page_begin_index }} ~ {{ Math.min(data.cur_page_end_index, data.total_count) }} /
-            {{ data.total_count }}
-          </span>
         </div>
         <div class="list">
           <div v-for="(item, i) in data.record_list" :key="i + 'one'">
@@ -40,7 +36,14 @@
               {{ item.first_sentence }}
             </div>
             <div class="time">{{ item.create_time }}</div>
-            <div v-if="item.analysis_status === 3" class="cxjx" @click="anewSubmit(item.partition_key)">重新解析</div>
+            <div class="analysis_status">{{ analysis_status_list[item.analysis_status] }}</div>
+            <div
+              v-if="item.analysis_status === 3 || item.analysis_status === 0"
+              class="cxjx"
+              @click="anewSubmit(item.id)"
+            >
+              {{ item.analysis_status === 3 ? '重新解析' : '解析' }}
+            </div>
             <el-popconfirm title="确定删除这一条记录吗?" @confirm="deleteOne(item.id, i)">
               <img slot="reference" src="../../assets/teacherdev/delete-one.png" alt="删除" />
             </el-popconfirm>
@@ -59,7 +62,14 @@
 </template>
 
 <script>
-import { postapi, AddTextFile, GetTextAnalyseRecordInfo, PageQueryMyTextAnalyseRecordList, analyse } from '@/api/api';
+import {
+  postapi,
+  AddTextFile,
+  GetTextAnalyseRecordInfo,
+  PageQueryMyTextAnalyseRecordList,
+  analyse,
+  reparse,
+} from '@/api/api';
 import { getToken } from '@/utils/auth';
 
 import HeaderPage from '@/components/Header';
@@ -77,6 +87,12 @@ export default {
       pageSize: 20,
       data: null,
       file_id_list: [],
+      analysis_status_list: {
+        0: '未解析',
+        1: '解析中',
+        2: '解析成功',
+        3: '解析失败',
+      },
     };
   },
   computed: {
@@ -125,89 +141,39 @@ export default {
     },
 
     handleJump(item) {
-      if (item.analysis_status === 0) return this.analysisText(item.id);
+      if (item.analysis_status === 0) return this.anewSubmit(item.id);
       if (item.analysis_status === 1) return this.$message.warning('当前数据正在解析,请稍后');
       if (item.analysis_status === 2) {
         return this.getTextAnalyseRecordInfo(item.id).then((record) => {
-          this.jumpResultNew(record);
+          this.jumpResult(record);
         });
       }
-      if (item.analysis_status === 3) return this.anewSubmit(item.partition_key);
+      if (item.analysis_status === 3) return this.anewSubmit(item.id);
     },
+
     /**
-     * 解析上传但未解析的文本
+     * 跳转分析结果页
+     * @param {object} item
      */
-    analysisText(id) {
-      this.getTextAnalyseRecordInfo(id)
-        .then((record) => {
-          return record.txt;
-        })
-        .then((txt) => {
-          this.loading = true;
-          return analyse({
-            analyse_record_id: id,
-            tenantId: '',
-            text: txt,
-          });
-        })
-        .then((res) => {
-          this.jumpResult(res.data.result);
-          this.pageQueryMyTextAnalyseRecordList();
-        })
-        .finally(() => {
-          this.loading = false;
-        });
-    },
-
-    // 新的跳转分析结果页(参数采用蛇形命名法)
-    jumpResultNew(item) {
-      if (item.analysis_status !== 2) {
-        this.$message.warning('当前数据解析失败,请重新解析');
-        return;
-      }
-      window.open(
-        this.$router.resolve({
-          path: '/textanalysis/Result',
-          query: {
-            partitionKey: item.partition_key,
-            subjectWords: item.subject_words,
-            wordTextCount: item.word_text_count,
-            wordCount: item.word_count,
-            vocabularyTextCount: item.vocabulary_text_count,
-            vocabularyCount: item.vocabulary_count,
-            pinyinCount: item.pinyin_count,
-            pinyinTextCount: item.pinyin_text_count,
-            pinyinDifficulty: item.pinyin_difficulty,
-            wordDifficulty: item.word_difficulty,
-            vocabularyDifficulty: item.vocabulary_difficulty,
-            type: '文本分析',
-          },
-        }).href,
-        '_blank',
-      );
-    },
-
-    // 跳转分析结果页
     jumpResult(item) {
-      if (item.analysisStatus !== 2) {
-        this.$message.warning('当前数据解析失败,请重新解析');
-        return;
+      if (item.analysis_status !== 2) {
+        return this.$message.warning('当前数据解析失败,请重新解析');
       }
       window.open(
         this.$router.resolve({
           path: '/textanalysis/Result',
           query: {
-            partitionKey: item.partitionKey,
-            subjectWords: item.subjectWords,
-            wordTextCount: item.wordTextCount,
-            wordCount: item.wordCount,
-            vocabularyTextCount: item.vocabularyTextCount,
-            vocabularyCount: item.vocabularyCount,
-            pinyinCount: item.pinyinCount,
-            pinyinTextCount: item.pinyinTextCount,
-            pinyinDifficulty: item.pinyinDifficulty,
-            wordDifficulty: item.wordDifficulty,
-            vocabularyDifficulty: item.vocabularyDifficulty,
+            partition_key: item.partition_key,
+            subject_words: item.subject_words,
+            word_text_count: item.word_text_count,
+            word_count: item.word_count,
+            vocabulary_text_count: item.vocabulary_text_count,
+            vocabulary_count: item.vocabulary_count,
+            pinyin_count: item.pinyin_count,
+            pinyin_text_count: item.pinyin_text_count,
+            pinyin_difficulty: item.pinyin_difficulty,
+            word_difficulty: item.word_difficulty,
+            vocabulary_difficulty: item.vocabulary_difficulty,
             type: '文本分析',
           },
         }).href,
@@ -237,41 +203,38 @@ export default {
           this.loading = false;
         });
     },
-    anewSubmit(partitionKey) {
+    /**
+     * 重新解析
+     * @param {string} analyse_record_id
+     */
+    anewSubmit(analyse_record_id) {
       this.loading = true;
-      postapi({
-        url: '/GCLSTCServer/tools/TS/reparse',
-        data: {
-          partitionKey,
-        },
-      })
-        .then((res) => {
-          this.jumpResult(res.data.result);
+      reparse({ analyse_record_id })
+        .then(({ record }) => {
+          this.jumpResult(record);
           this.pageQueryMyTextAnalyseRecordList(true);
         })
         .finally(() => {
           this.loading = false;
         });
     },
-    // 分析
+    /**
+     * 分析
+     */
     submit() {
       if (this.txt === '') {
-        this.$message.warning('请先输入内容');
-        return;
+        return this.$message.warning('请先输入内容');
       }
       if (this.txt.length > 1000) {
-        this.$message.warning('超出字数限制');
-        return;
+        return this.$message.warning('超出字数限制');
       }
       this.loading = true;
       analyse({
-        analyse_record_id: '',
-        tenantId: '',
         text: this.txt,
       })
-        .then((res) => {
+        .then(({ record }) => {
           this.txt = '';
-          this.jumpResult(res.data.result);
+          this.jumpResult(record);
           this.pageQueryMyTextAnalyseRecordList(true);
         })
         .finally(() => {
@@ -407,6 +370,7 @@ export default {
 
         > div {
           display: flex;
+          column-gap: 24px;
           align-items: center;
           height: 48px;
           padding: 0 16px;
@@ -418,13 +382,11 @@ export default {
 
           .number {
             width: 20px;
-            margin-right: 24px;
             text-align: right;
           }
 
           .txt {
-            width: 774px;
-            margin-right: 24px;
+            width: 740px;
             overflow: hidden;
             text-overflow: ellipsis;
             white-space: nowrap;
@@ -432,15 +394,17 @@ export default {
           }
 
           .time {
-            width: 190px;
-            margin-right: 24px;
+            width: 135px;
           }
 
           .cxjx {
-            margin-right: 24px;
             cursor: pointer;
           }
 
+          .analysis_status {
+            flex: 1;
+          }
+
           img {
             width: 24px;
             height: 24px;

Một số tệp đã không được hiển thị bởi vì quá nhiều tập tin thay đổi trong này khác