Explorar el Código

feat:批改界面相关文件下载

xiaoyu hace 2 años
padre
commit
02e9ee1f55

+ 1 - 1
src/views/CorrectPage/CorrectPage.vue

@@ -17,7 +17,7 @@
         <!-- TODO:AI评分及写作过程记录:框架已完成,内容调取待完成 -->
         <div class="my-correct-record">
             <h2>历史记录</h2><br>
-            <ContentSelector/>
+            <ContentSelector :dialogueId="dataForm.dialogueId" :messages="dataForm.messages"/>
         </div>
         
         <!-- 教师评分、修改意见及评价 -->

+ 24 - 17
src/views/Home/component/StudentEssay/StudentWritingRequirements.vue

@@ -16,9 +16,18 @@
             <span style="font-weight: 600">作业描述: </span>
             {{data.description}}
           </div>
-          <div class="item">
-                      <!-- TODO:相关文件下载逻辑补全 -->
-            <!-- <el-link type="primary" @click="downloadFile">相关文件下载</el-link> -->
+          <div class="file">
+
+            <template v-if="data.descriptionFile || data.attachments">
+              <div >
+                <template v-if="data.descriptionFile">
+                  &nbsp;&nbsp;<el-link  @click="downloadFile(data.descriptionFile,data.assignmentName)">相关文件下载:作业要求</el-link>
+                </template>
+                <template v-if="data.attachments">
+                  &nbsp;&nbsp;相关文件下载:<el-link  v-for="(item, index) in data.attachments" :key="index" @click="downloadFile(item, '附件' + index)">附件{{ index+1 }}</el-link>
+                </template>
+              </div>
+            </template>
           </div>
         </div>
       </div>
@@ -61,6 +70,8 @@
           Object.assign(data, res.data.data)
         })
   }
+
+  
   
   onMounted(() => {
     fetchData()
@@ -71,23 +82,19 @@
   export default {
     name: "StudentEssay",
     methods: {  
-    downloadFile() {  
-      // 假设这是文件的URL  
-      const url = 'https://example.com/path/to/your/file.pdf';  
-      // 创建一个a标签  
+    downloadFile(url:string, title:string) {  
+      // 创建一个链接元素  
       const link = document.createElement('a');  
-      // 设置a标签的href属性为文件的URL  
-      link.href = url;  
-      // 设置下载的文件名,这里假设服务器支持通过URL参数设置文件名  
-      // 如果不支持,可以省略这一步  
-      link.download = 'downloaded_file.pdf'; // 设置下载文件的名称  
-      // 触发点击事件  
+      link.href = url; // 设置链接的href为文件URL  
+      link.download = `${title}.docx`;  
+  
+      // 模拟点击链接以触发下载  
       document.body.appendChild(link);  
       link.click();  
-      // 清理工作,移除a标签  
-      document.body.removeChild(link);  
-    }  
-  }  
+  
+
+    },  
+  },  
 
   }
   </script>

+ 10 - 1
src/views/Home/component/StudentEssay/studentWritingRequirements.scss

@@ -25,7 +25,16 @@
         font-weight: 600;
       }
   
-      .item {
+      .file {
+        color: #597D3B;
+
+        a{
+          font-size: 16px;
+          color: #597D3B;
+        }
+      }
+      .item{
+
       }
     }