浏览代码

feat: 说话人编码

Carson 9 月之前
父节点
当前提交
8da9939764
共有 1 个文件被更改,包括 53 次插入13 次删除
  1. 53 13
      src/components/pages/classroomObservation/components/chatArea.vue

+ 53 - 13
src/components/pages/classroomObservation/components/chatArea.vue

@@ -57,16 +57,25 @@
         v-model="editorBarData.content"
         v-if="pageStatus == 2 && !showIndexPage && editorBarData.type == '0'"
         v-loading="uploadFileLoading"
-        @change="changeEditor"
       >
-        <el-button
-          style="position: absolute; bottom: 20px; right: 100px; z-index: 10002"
-          type="primary"
-          @click.stop="generateActionTypesMap"
-          >自动编码</el-button
-        >
+        <el-popover placement="top" trigger="hover">
+          <el-button size="small" @click.stop="startContinuousJobs('role')">
+            说话人编码
+          </el-button>
+          <el-button size="small" @click.stop="startContinuousJobs('actionType')">
+            行为编码
+          </el-button>
+          <el-button
+            slot="reference"
+            style="position: absolute; bottom: 20px; right: 90px; z-index: 10002"
+            size="small"
+            type="primary"
+            >自动编码</el-button
+          >
+        </el-popover>
         <el-button
           style="position: absolute; bottom: 20px; right: 20px; z-index: 10002"
+          size="small"
           type="primary"
           @click.stop="saveEditorBar(true)"
           >保存</el-button
@@ -463,6 +472,9 @@ const ATTENTION_GROUP = {
   default:
     "- 先根据说话人角色判断,再在对应角色的选项中选择选项\n- 如果没有合适的选项,默认使用`老师其他`或者`学生其他`",
 };
+const ROLE_OPTIONS_GROUP = {
+  default: ["老师", "学生"],
+};
 
 // 自定义指令,用于处理点击外部区域的事件
 const clickOutside = {
@@ -2296,12 +2308,20 @@ ${JSON.stringify(_list)}
         this.$message.error(e);
       }
     },
-    async generateActionTypesMap() {
+    async startContinuousJobs(type /* role, actionType */) {
       const key = "default";
-      const appToken = "app-zOMxBqyEKoJSvW10e5SS0kgj";
-      // the default options
-      const options = OPTIONS_GROUP[key];
-      const attention = ATTENTION_GROUP[key];
+      const { appToken, options, attention } = {
+        role: {
+          appToken: "app-TonzLPv7rPG0EtnFKszOWjwt",
+          options: ROLE_OPTIONS_GROUP[key],
+          attention: undefined,
+        },
+        actionType: {
+          appToken: "app-zOMxBqyEKoJSvW10e5SS0kgj",
+          options: OPTIONS_GROUP[key],
+          attention: ATTENTION_GROUP[key],
+        },
+      }[type];
       const config = {
         headers: {
           Authorization: `Bearer ${appToken}`,
@@ -2340,6 +2360,7 @@ ${JSON.stringify(_list)}
         ""
       );
 
+      const jobsResult = [];
       const jobs = _.chunk(tableRows, chunkSize).map((rows, index) => {
         return async (pauseSignal) => {
           this.jobContext.progress.current = index * chunkSize;
@@ -2375,7 +2396,7 @@ ${JSON.stringify(_list)}
             throw err;
           }
           const chunkResult = _.get(res, ["data", "outputs", "result"], []);
-          this.actionTypesMap.jsonData[key].splice(
+          jobsResult.splice(
             index * chunkSize,
             rows.length,
             ...Object.assign(new Array(rows.length), chunkResult.slice(0, rows.length))
@@ -2424,6 +2445,25 @@ ${JSON.stringify(_list)}
           }
         }
       }
+      if (type === "actionType") {
+        this.actionTypesMap.jsonData[key] = jobsResult;
+      } else if (type === "role") {
+        const _div = document.createRange().createContextualFragment(this.editorBarData.content);
+        const _table = _div.querySelector('table')
+        const _rows = _table.querySelectorAll(`tbody tr`);
+        const _actionTypes = []
+        _rows.forEach((i, index) => {
+          while (i.cells.length > 7) {
+            i.removeChild(i.lastElementChild);
+          }
+          if (index == 0) return;
+          const actionTypeCell = i.cells[6] && i.removeChild(i.cells[6]);
+          i.cells[5].textContent = jobsResult[index - 1]
+          _actionTypes.push(_.get(actionTypeCell, "textContent", ""));
+        });
+        this.actionTypesMap.jsonData[key] = _actionTypes;
+        this.editorBarData.content = _table.outerHTML;
+      }
       this.changeEditorBar({
         transcriptionData: this.transcriptionData.content,
         editorBarData: this.editorBarData,