zengyicheng 1 year ago
parent
commit
f0cb77ac6b
2 changed files with 247 additions and 38 deletions
  1. 241 37
      src/components/components/englishEva.vue
  2. 6 1
      src/components/studyStudent.vue

+ 241 - 37
src/components/components/englishEva.vue

@@ -21,12 +21,22 @@
             @click="checkImg(getImgList(evaEngJson.teacherJson.englishText))"
           ></div>
         </div>
+        <div class="tcNewButton" @click="setType(1)">
+          {{
+            courseDetail &&
+            (courseDetail.userid == uid ||
+              (courseDetail.course_teacher &&
+                courseDetail.course_teacher.indexOf(uid) != -1))
+              ? "教师评价"
+              : "查看教师评价"
+          }}
+        </div>
       </div>
       <div
         class="correctBox"
         :style="{ height: `calc(100% - ${topHeight}px)` }"
       >
-        <div class="oldBox">
+        <div :class="type == 0 ? 'oldBox' : 'halfOldBox'">
           <div class="oldMes">
             原文( 作者:{{ evaEngJson.message.username }} )
           </div>
@@ -55,7 +65,114 @@
             </div>
           </div>
         </div>
-        <div class="oldBox" style="position: relative">
+        <div v-if="type == 1" class="halfOldBox">
+          <div
+            class="oldMes"
+            style="
+              background: rgb(224 236 255);
+              display: flex;
+              flex-direction: row;
+              flex-wrap: nowrap;
+              align-items: center;
+            "
+          >
+            <div
+              class="allName"
+              style="background: #aacaff; min-width: 100%; width: 100%"
+            >
+              教师评价
+            </div>
+          </div>
+          <div class="oldText" style="margin-top: 10px">
+            <div class="detailBox" style="position: relative">
+              <div
+                class="addEva"
+                v-if="
+                  evaEngJson.teacherJson.textJson &&
+                  evaEngJson.teacherJson.textJson.startJson.length > 0
+                "
+              >
+                <!-- <el-rate
+                  v-model="evaEngJson.teacherJson.textJson.score"
+                  class="engRate"
+                ></el-rate> -->
+                <div>评分标准:</div>
+                <div class="setEngEva">
+                  <div
+                    v-for="(item, index) in evaEngJson.teacherJson.textJson
+                      .startJson"
+                    :key="index"
+                    class="engStartBox"
+                  >
+                    <div class="scoreItem">
+                      <div>{{ item.title }}</div>
+                      <div>
+                        <el-rate
+                          v-model="startList.scoreList[index]"
+                          :disabled="
+                            !(
+                              courseDetail &&
+                              (courseDetail.userid == uid ||
+                                (courseDetail.course_teacher &&
+                                  courseDetail.course_teacher.indexOf(uid) !=
+                                    -1))
+                            )
+                          "
+                        ></el-rate>
+                      </div>
+                    </div>
+                    <div>{{ item.detile }}</div>
+                  </div>
+                </div>
+              </div>
+              <div v-else>
+                <div>评分:</div>
+                <div>
+                  <el-input
+                    v-model="startList.score"
+                    @change="isNumber($event)"
+                  ></el-input>
+                </div>
+              </div>
+              <div class="oldDetail">
+                <div>作业评价:</div>
+                <el-input
+                  type="textarea"
+                  :rows="10"
+                  resize="none"
+                  v-model="teacherList.engText"
+                  v-if="
+                    courseDetail &&
+                    (courseDetail.userid == uid ||
+                      (courseDetail.course_teacher &&
+                        courseDetail.course_teacher.indexOf(uid) != -1))
+                  "
+                />
+                <el-input
+                  type="textarea"
+                  :rows="10"
+                  resize="none"
+                  v-model="teacherList.engText"
+                  disabled
+                  v-else
+                />
+              </div>
+              <el-button
+                type="primary"
+                @click="getAiPj"
+                style="position: absolute; bottom: -50px; right: 0"
+                v-if="
+                  courseDetail &&
+                  (courseDetail.userid == uid ||
+                    (courseDetail.course_teacher &&
+                      courseDetail.course_teacher.indexOf(uid) != -1))
+                "
+                >AI评价</el-button
+              >
+            </div>
+          </div>
+        </div>
+        <!-- <div class="oldBox" style="position: relative">
           <div
             class="oldMes"
             style="
@@ -89,37 +206,16 @@
               overflow: auto;
             "
           >
-            <!-- <el-button
-              type="primary"
-              @click="getAiPj"
-              v-if="!isPj"
-              style="margin: 10px 0 0 0"
-              >AI评价</el-button
-            > -->
             <div class="oldText loadingText" style="margin-top: 10px">
               <div class="detailBox" style="min-width: 300px">
                 <div class="oldDetail" style="min-width: 300px">
                   <div>作业原文:</div>
                   <div v-html="evaEngJson.studentJson.engText"></div>
-                  <!-- <el-input
-                    type="textarea"
-                    :rows="10"
-                    resize="none"
-                    v-model="aiList.engTitle"
-                    disabled
-                  /> -->
                 </div>
                 <div class="oldDetail" style="min-width: 300px">
                   <div>作业评价:</div>
                   <div v-if="!aiList.engText">暂无AI评价</div>
                   <div v-else v-html="html"></div>
-                  <!-- <el-input
-                    type="textarea"
-                    :rows="10"
-                    resize="none"
-                    v-model="aiList.engText"
-                    disabled
-                  /> -->
                 </div>
               </div>
             </div>
@@ -147,7 +243,7 @@
               </div>
             </div>
           </div>
-        </div>
+        </div> -->
       </div>
     </div>
     <span
@@ -164,7 +260,7 @@
 <script>
 import MarkdownIt from "markdown-it";
 export default {
-  props: ["engEvaDialogVisible", "evaEngJson", "uid"],
+  props: ["engEvaDialogVisible", "evaEngJson", "uid", "tType", "courseDetail"],
   data() {
     return {
       topHeight: 0,
@@ -179,11 +275,17 @@ export default {
       },
       time: null,
       md: new MarkdownIt(),
+      startList: {
+        scoreList: [],
+        score: 0,
+      },
     };
   },
   computed: {
     html() {
-      return this.aiList.engText ? this.md.render(this.aiList.engText) : "";
+      return this.teacherList.engText
+        ? this.md.render(this.teacherList.engText)
+        : "";
     },
   },
   methods: {
@@ -194,6 +296,25 @@ export default {
     close() {
       this.$emit("update:engEvaDialogVisible", false);
     },
+    isNumber(e) {
+      let value = /^\d+$/.test(e);
+      // let value = e.replace(/[^d]/g, ""); // 只能输入数字
+      if (value == true) {
+        if (e < 0) {
+          this.$message.error("请输入大于0的数值");
+          this.startList.score = "";
+          return;
+        } else if (e > 100) {
+          this.$message.error("数值不能大于100");
+          this.startList.score = "";
+          return;
+        }
+      } else {
+        this.startList.score = "";
+        this.$message.error("请输入数字");
+        return;
+      }
+    },
     checkImg(list) {
       if (!list.length) {
         return;
@@ -218,7 +339,11 @@ export default {
       };
     },
     setType(i) {
-      this.type = i;
+      if (this.type == i) {
+        this.type = 0;
+      } else {
+        this.type = i;
+      }
       this.$forceUpdate();
     },
     getAiPj() {
@@ -255,7 +380,7 @@ export default {
             this.$message.error("你的作文内容太长,无法使用Ai评价!");
             return;
           }
-          this.aiList.engText =
+          this.teacherList.engText =
             res.data.FunctionResponse.choices[0].message.content;
           loading.close();
         },
@@ -268,9 +393,8 @@ export default {
     addCode() {
       let params = {
         id: this.evaEngJson.message.id,
-        aic: this.aiList.engText,
+        aic: JSON.stringify(this.startList),
         tc: this.teacherList.engText,
-        t: this.type,
       };
       this.ajax
         .get(this.$store.state.api + "addEngEva", params)
@@ -288,24 +412,48 @@ export default {
     engEvaDialogVisible: {
       handler(newVal) {
         if (newVal) {
-          this.aiList.engText = this.evaEngJson.message.aiCode;
+          if (this.evaEngJson.message.aiCode) {
+            if (
+              JSON.parse(this.evaEngJson.message.aiCode).scoreList.length > 0
+            ) {
+              this.startList.scoreList = JSON.parse(
+                this.evaEngJson.message.aiCode
+              ).scoreList;
+            } else {
+              this.startList.score = JSON.parse(
+                this.evaEngJson.message.aiCode
+              ).score;
+            }
+          }
           this.teacherList.engText = this.evaEngJson.message.teacherCode;
+          if (this.startList.scoreList.length == 0) {
+            for (
+              var i = 0;
+              i < this.evaEngJson.teacherJson.textJson.startJson.length;
+              i++
+            ) {
+              this.startList.scoreList.push(0);
+            }
+          }
           this.$forceUpdate();
           this.timer = setInterval(() => {
-            this.topHeight =
-              document.querySelectorAll(".engUpTop2")[0].offsetHeight ? document.querySelectorAll(".engUpTop2")[0].offsetHeight : 0 - 50;
+            this.topHeight = document.querySelectorAll(".engUpTop2")[0]
+              .offsetHeight
+              ? document.querySelectorAll(".engUpTop2")[0].offsetHeight + 50
+              : 0 - 50;
           }, 500);
           // setTimeout(() => {
           //   this.topHeight =
           //     document.querySelectorAll(".engUpTop2")[0].offsetHeight;
           // }, 500);
-        }else{
+        } else {
           clearInterval(this.timer);
         }
       },
       deep: true,
     },
   },
+  created() {},
 };
 </script>
 
@@ -387,8 +535,9 @@ export default {
   align-items: flex-start;
 }
 
-.oldBox {
-  width: 50%;
+.oldBox,
+.halfOldBox {
+  width: 100%;
   height: 100%;
   display: flex;
   flex-direction: column;
@@ -398,7 +547,11 @@ export default {
   border-left: 1px solid #d9d9d9;
   border-right: 1px solid #d9d9d9;
 }
-.oldBox > div:first-child {
+.halfOldBox {
+  width: 50% !important;
+}
+.oldBox > div:first-child,
+.halfOldBox > div:first-child {
   width: 100%;
   text-align: center;
   background: #d9d9d9;
@@ -514,4 +667,55 @@ ol {
   overflow-wrap: break-word;
   -webkit-line-break: after-white-space;
 }
+.tcNewButton {
+  color: #fff;
+  background-color: #409eff;
+  border-color: #409eff;
+  width: 90px;
+  height: 40px;
+  min-width: 90px;
+  border-radius: 5px;
+  line-height: 40px;
+  float: right;
+  margin: 0 20px 10px 0;
+  text-align: center;
+  cursor: pointer;
+}
+.setEngEva {
+  background: #fff;
+  padding: 10px;
+  margin: 5px 0;
+  border: 1px solid #ccc;
+  border-radius: 5px;
+  box-sizing: border-box;
+}
+.engStartBox {
+  display: flex;
+  flex-direction: column;
+  flex-wrap: nowrap;
+  align-items: flex-start;
+  margin-bottom: 5px;
+}
+.scoreItem {
+  display: flex;
+  flex-direction: row;
+  flex-wrap: nowrap;
+  justify-content: space-between;
+  align-items: center;
+  width: 100%;
+  margin-bottom: 5px;
+}
+.scoreItem > div:first-child {
+  font-size: 15px;
+  font-weight: bold;
+}
+.scoreItem > div:last-child >>> .el-rate {
+  height: 25px !important;
+}
+.scoreItem > div:last-child >>> .el-rate__item {
+  font-size: 25px !important;
+}
+.scoreItem > div:last-child >>> .el-rate__icon {
+  font-size: 25px !important;
+}
 </style>

+ 6 - 1
src/components/studyStudent.vue

@@ -3834,6 +3834,7 @@
                             src="../assets/evaEnglish.png"
                             @click.stop="openEnglishEva(w.wid,toolIndex)"
                             alt
+                            v-if="(courseDetail && (courseDetail.userid == userid || (courseDetail.course_teacher && courseDetail.course_teacher.indexOf(userid) != -1))) || (w.aiCode || w.teacherCode)"
                           />
                           <img
                             class="deleteImg deleteImg2"
@@ -11371,7 +11372,7 @@
         <el-button type="primary" @click="addCorrect">确 定</el-button>
       </span>
     </el-dialog>
-    <englishEva :evaEngJson="evaEngJson" :engEvaDialogVisible.sync="engEvaDialogVisible" :uid="userid"></englishEva>
+    <englishEva :evaEngJson="evaEngJson" :engEvaDialogVisible.sync="engEvaDialogVisible" :uid="userid" :tType="tType" :courseDetail="courseDetail"></englishEva>
     <interVideo
       :dialogVisibleVideo.sync="dialogVisibleVideo"
       :videoJson="videoJson"
@@ -13340,6 +13341,8 @@ export default {
                     time: b[j].time,
                     userid: b[j].userid,
                     wid: b[j].id,
+                    aiCode: b[j].aiCode,
+                    teacherCode: b[j].teacherCode
                   });
                 }
               }
@@ -14428,6 +14431,8 @@ export default {
                     commentCount: commentCount,
                     isLikes: isLikes,
                     commentJson: commentJson,
+                    aiCode: b[j].aiCode,
+                    teacherCode: b[j].teacherCode
                   };
                   _worksStudent[i].push(_work);
                   _worksStudent2[i].push(_work);