|
|
@@ -59,6 +59,7 @@ export default {
|
|
|
homeworkList:[],
|
|
|
homeworkType:"",
|
|
|
assignmentId:0,
|
|
|
+ seCourseId:0,
|
|
|
homeworkForm:{
|
|
|
assignmentName:"作业2",
|
|
|
description:"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
|
|
|
@@ -110,42 +111,68 @@ export default {
|
|
|
methods:{
|
|
|
init() {
|
|
|
this.assignmentId = this.$route.params.homeworkId;
|
|
|
- this.homeworkType = this.$route.params.type === "speaking"?"口语":"写作";
|
|
|
+ this.seCourseId = this.$route.params.seCourseId;
|
|
|
+ this.homeworkType =
|
|
|
+ (this.$route.params.type === "speaking"||this.$route.params.type === "AI口语")?"AI口语":"写作";
|
|
|
const temp = ElLoading.service();
|
|
|
- this.$apis.getHomeworkDetail(this.assignmentId,this.homeworkType)
|
|
|
+ this.$apis.getHomeworkDetail(this.assignmentId,this.homeworkType==="AI口语"?"口语":"写作")
|
|
|
.then(res => {
|
|
|
console.log(res);
|
|
|
if (this.homeworkType === "写作"){
|
|
|
this.homeworkInfo = res.data.data;
|
|
|
+ if (this.homeworkInfo.attachments===null){
|
|
|
+ this.homeworkInfo.attachments = [];
|
|
|
+ }
|
|
|
this.homeworkForm.assignmentName = this.homeworkInfo.assignmentName;
|
|
|
this.homeworkForm.description = this.homeworkInfo.description;
|
|
|
this.homeworkForm.type = this.homeworkInfo.type;
|
|
|
- this.homeworkForm.descriptionFile = this.homeworkInfo.descriptionFile;
|
|
|
+ this.homeworkForm.descriptionFile = null;
|
|
|
this.homeworkForm.attachments = this.homeworkInfo.attachments;
|
|
|
this.homeworkForm.timeRange = [this.homeworkInfo.startTime,this.homeworkInfo.endTime];
|
|
|
+ if (this.homeworkForm.attachments.length!==0&&
|
|
|
+ this.homeworkForm.attachments[0] === ""){
|
|
|
+ this.homeworkForm.attachments.splice(0,1);
|
|
|
+ this.homeworkInfo.attachments.splice(0,1);
|
|
|
+ }
|
|
|
+ if (this.homeworkForm.attachments.length!==0&&
|
|
|
+ this.homeworkForm.attachments[0] === ""){
|
|
|
+ this.homeworkForm.attachments.splice(0,1);
|
|
|
+ this.homeworkInfo.attachments.splice(0,1);
|
|
|
+ }
|
|
|
+ this.homeworkForm.attachments = [];
|
|
|
}
|
|
|
else{
|
|
|
this.speakingHomeworkInfo = res.data.data;
|
|
|
+ if (this.speakingHomeworkInfo.attachments===null){
|
|
|
+ this.speakingHomeworkInfo.attachments = [];
|
|
|
+ }
|
|
|
this.speakingHomeworkForm.assignmentName = this.speakingHomeworkInfo.assignmentName;
|
|
|
this.speakingHomeworkForm.description = this.speakingHomeworkInfo.description;
|
|
|
this.speakingHomeworkForm.type = this.speakingHomeworkInfo.type;
|
|
|
- this.speakingHomeworkForm.descriptionFile = this.speakingHomeworkInfo.descriptionFile;
|
|
|
+ this.speakingHomeworkForm.descriptionFile = null;
|
|
|
this.speakingHomeworkForm.attachments = this.speakingHomeworkInfo.attachments;
|
|
|
this.speakingHomeworkForm.timeRange = [this.speakingHomeworkInfo.startTime,this.speakingHomeworkInfo.endTime];
|
|
|
this.speakingHomeworkForm.minDuration = this.speakingHomeworkInfo.minDuration;
|
|
|
this.speakingHomeworkForm.minInteraction = this.speakingHomeworkInfo.minInteraction;
|
|
|
this.speakingHomeworkForm.surveyLinks = [...this.speakingHomeworkInfo.surveyLinks];
|
|
|
this.speakingHomeworkForm.surveyDuration = this.speakingHomeworkInfo.surveyDuration;
|
|
|
+ if (this.speakingHomeworkForm.attachments&&this.speakingHomeworkForm.attachments.length!==0&&
|
|
|
+ this.speakingHomeworkForm.attachments[0] === ""){
|
|
|
+ this.speakingHomeworkForm.attachments.splice(0,1);
|
|
|
+ this.speakingHomeworkInfo.attachments.splice(0,1);
|
|
|
+ }
|
|
|
if (this.speakingHomeworkForm.surveyLinks.length!==0&&
|
|
|
this.speakingHomeworkForm.surveyLinks[0] === ""){
|
|
|
this.speakingHomeworkForm.surveyLinks.splice(0,1);
|
|
|
this.speakingHomeworkInfo.surveyLinks.splice(0,1);
|
|
|
}
|
|
|
+ this.speakingHomeworkForm.attachments = [];
|
|
|
}
|
|
|
temp.close();
|
|
|
})
|
|
|
.catch(_err => {
|
|
|
ElMessage.error("获取作业信息失败");
|
|
|
+ console.log(_err);
|
|
|
});
|
|
|
},
|
|
|
deleteHomework(){
|
|
|
@@ -198,6 +225,9 @@ export default {
|
|
|
this.dialog.update = false;
|
|
|
this.speakingDialog.update = false;
|
|
|
this.recoverForm();
|
|
|
+ this.homeworkForm.descriptionFile = null;
|
|
|
+ this.homeworkForm.assignmentName = [];
|
|
|
+ this.speakingHomeworkForm.descriptionFile = null;
|
|
|
this.$refs.homeworkFormRef.resetFields();
|
|
|
this.$refs.speakingHomeworkFormRef.resetFields();
|
|
|
done();
|
|
|
@@ -238,22 +268,49 @@ export default {
|
|
|
startTime: this.dateTimeFormatter(this.homeworkForm.timeRange[0]),
|
|
|
endTime: this.dateTimeFormatter(this.homeworkForm.timeRange[1]),
|
|
|
};
|
|
|
+
|
|
|
// console.log(homeworkVO);
|
|
|
- this.$apis.updateHomework(this.assignmentId,homeworkVO)
|
|
|
- .then(res => {
|
|
|
- console.log( res);
|
|
|
- if (res && res.data.code === 200){
|
|
|
- ElMessage.success("作业修改成功");
|
|
|
- this.dialog.update = false;
|
|
|
- this.init();
|
|
|
- }
|
|
|
- else{
|
|
|
- ElMessage.error("作业修改失败");
|
|
|
- }
|
|
|
- })
|
|
|
- .catch(error => {
|
|
|
- ElMessage.error("作业修改失败");
|
|
|
+ if (this.homeworkForm.descriptionFile){
|
|
|
+ // if (this.homeworkInfo.descriptionFile){
|
|
|
+ // this.$apis.getCourseWaresByCourseId(this.seCourseId)
|
|
|
+ // .then(res =>{
|
|
|
+ // for (let i = 0; i < res.data.data.length; i++){
|
|
|
+ // if (res.data.data[i].url === this.homeworkInfo.descriptionFile){
|
|
|
+ // this.$apis.deleteCourseWare(this.seCourseId)
|
|
|
+ // .then(res2 =>{
|
|
|
+ // console.log(res2);
|
|
|
+ // });
|
|
|
+ // break;
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // });
|
|
|
+ // }
|
|
|
+ this.uploadFile(this.homeworkForm.descriptionFile,"作业描述文件",(url)=>{
|
|
|
+ console.log(url);
|
|
|
+ homeworkVO.descriptionFile = url;
|
|
|
+ if (this.homeworkForm.attachments.length!==0){
|
|
|
+ this.uploadFile(this.homeworkForm.attachments[0],"作业附件",(url2)=>{
|
|
|
+ homeworkVO.attachments = [url2];
|
|
|
+ this.updateWritingHomeworkByVO(homeworkVO);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ this.updateWritingHomeworkByVO(homeworkVO);
|
|
|
+ }
|
|
|
+
|
|
|
+ });
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ if (this.homeworkForm.attachments.length!==0){
|
|
|
+ this.uploadFile(this.homeworkForm.attachments[0],(url2)=>{
|
|
|
+ homeworkVO.attachments = [url2];
|
|
|
+ this.updateWritingHomeworkByVO(homeworkVO);
|
|
|
});
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ this.updateWritingHomeworkByVO(homeworkVO);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
});
|
|
|
},
|
|
|
@@ -278,21 +335,17 @@ export default {
|
|
|
homeworkVO.surveyLinks = [""];
|
|
|
}
|
|
|
// console.log(homeworkVO);
|
|
|
- this.$apis.updateSpeakingHomework(this.assignmentId,homeworkVO)
|
|
|
- .then(res => {
|
|
|
- console.log( res);
|
|
|
- if (res && res.data.code === 200){
|
|
|
- ElMessage.success("作业修改成功");
|
|
|
- this.speakingDialog.update = false;
|
|
|
- this.init();
|
|
|
- }
|
|
|
- else{
|
|
|
- ElMessage.error("作业修改失败");
|
|
|
- }
|
|
|
- })
|
|
|
- .catch(error => {
|
|
|
- ElMessage.error("作业修改失败");
|
|
|
- });
|
|
|
+ if (this.speakingHomeworkForm.descriptionFile){
|
|
|
+ console.log(this.speakingHomeworkForm.descriptionFile);
|
|
|
+ this.uploadFile(this.speakingHomeworkForm.descriptionFile,"作业描述文件",(url)=>{
|
|
|
+ console.log(url);
|
|
|
+ homeworkVO.descriptionFile = url;
|
|
|
+ this.updateSpeakingHomeworkByVO(homeworkVO);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ this.updateSpeakingHomeworkByVO(homeworkVO);
|
|
|
+ }
|
|
|
}
|
|
|
});
|
|
|
},
|
|
|
@@ -338,6 +391,139 @@ export default {
|
|
|
},
|
|
|
checkInteraction(rule,value,callback){
|
|
|
this.checkNumberRange(rule,value,callback,1,50);
|
|
|
+ },
|
|
|
+ handleUploadDesFile(file, fileList){
|
|
|
+ console.log(file,fileList);
|
|
|
+ if (file.size >= 512000){
|
|
|
+ ElMessage.error("文件过大");
|
|
|
+ if (this.dialog.update === true){
|
|
|
+ this.$refs.writingDesFileUploadRef.clearFiles();
|
|
|
+ }
|
|
|
+ else if (this.speakingDialog.update === true){
|
|
|
+ this.$refs.speakingDesFileUploadRef.clearFiles();
|
|
|
+ }
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (file.name.endsWith(".doc")||file.name.endsWith(".docx")){
|
|
|
+ this.homeworkForm.descriptionFile = file;
|
|
|
+ if (this.dialog.update === true){
|
|
|
+ this.homeworkForm.descriptionFile = file;
|
|
|
+ }
|
|
|
+ else if (this.speakingDialog.update === true){
|
|
|
+ this.speakingHomeworkForm.descriptionFile = file;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ ElMessage.error("请上传doc或docx格式的描述文件");
|
|
|
+ if (this.dialog.update === true){
|
|
|
+ this.$refs.writingDesFileUploadRef.clearFiles();
|
|
|
+ }
|
|
|
+ else if (this.speakingDialog.update === true){
|
|
|
+ this.$refs.speakingDesFileUploadRef.clearFiles();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ handleUploadAttachmentFile(file, fileList){
|
|
|
+ console.log(file,fileList);
|
|
|
+ if (file.size >= 512000){
|
|
|
+ ElMessage.error("文件过大");
|
|
|
+ if (this.dialog.update === true){
|
|
|
+ this.$refs.writingDesFileUploadRef.handleRemove(file,file.raw);
|
|
|
+ }
|
|
|
+ else if (this.speakingDialog.update === true){
|
|
|
+ this.$refs.speakingDesFileUploadRef.handleRemove(file,file.raw);
|
|
|
+ }
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (file.name.endsWith(".doc")||file.name.endsWith(".docx")){
|
|
|
+ if (this.dialog.update === true){
|
|
|
+ this.homeworkForm.attachments.push(file);
|
|
|
+ }
|
|
|
+ else if (this.speakingDialog.update === true){
|
|
|
+ this.speakingHomeworkForm.attachments.push(file);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ ElMessage.error("请上传doc或docx格式的附件");
|
|
|
+ if (this.dialog.update === true){
|
|
|
+ this.$refs.writingDesFileUploadRef.handleRemove(file,file.raw);
|
|
|
+ }
|
|
|
+ else if (this.speakingDialog.update === true){
|
|
|
+ this.$refs.speakingDesFileUploadRef.handleRemove(file,file.raw);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ handleAttachmentsExceed(files){
|
|
|
+ ElMessage.warning("最多只能上传一个附件");
|
|
|
+ },
|
|
|
+ handleExceedDesFile(files){
|
|
|
+ ElMessage.warning("最多只能上传一个描述文件");
|
|
|
+ },
|
|
|
+ updateSpeakingHomeworkByVO(homeworkVO) {
|
|
|
+ this.$apis.updateSpeakingHomework(this.assignmentId,homeworkVO)
|
|
|
+ .then(res => {
|
|
|
+ console.log( res);
|
|
|
+ if (res && res.data.code === 200){
|
|
|
+ ElMessage.success("作业修改成功");
|
|
|
+ this.speakingDialog.update = false;
|
|
|
+ this.init();
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ ElMessage.error("作业修改失败");
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .catch(error => {
|
|
|
+ ElMessage.error("修改失败");
|
|
|
+ });
|
|
|
+ },
|
|
|
+ updateWritingHomeworkByVO(homeworkVO) {
|
|
|
+ this.$apis.updateHomework(this.assignmentId,homeworkVO)
|
|
|
+ .then(res => {
|
|
|
+ console.log( res);
|
|
|
+ if (res && res.data.code === 200){
|
|
|
+ ElMessage.success("作业修改成功");
|
|
|
+ this.dialog.update = false;
|
|
|
+ this.init();
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ ElMessage.error("作业修改失败");
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .catch(error => {
|
|
|
+ ElMessage.error("修改失败");
|
|
|
+ });
|
|
|
+ },
|
|
|
+ uploadFile(file,type,callback){
|
|
|
+ this.$apis.uploadCourseWareFile(this.seCourseId+"/"+type+":"+file.name,file.raw)
|
|
|
+ .then(res => {
|
|
|
+ let fileUrl = res.data.data;
|
|
|
+ this.$apis.createCourseWare({
|
|
|
+ name: file.name,
|
|
|
+ size: file.size,
|
|
|
+ senderId: this.$store.state.user.id,
|
|
|
+ courseId: this.seCourseId,
|
|
|
+ createdTime: new Date(),
|
|
|
+ useTime: "BEFORE_CLASS",
|
|
|
+ useMethod: "SCAN",
|
|
|
+ fileUrl: fileUrl,
|
|
|
+ }).then(res => {
|
|
|
+ //this.percentage= 100;
|
|
|
+ callback(fileUrl);
|
|
|
+ }).catch(err => {
|
|
|
+ ElMessage.error("上传文件失败");console.log(err);
|
|
|
+ });
|
|
|
+ })
|
|
|
+ .catch(error => {
|
|
|
+ ElMessage.error("文件上传失败");
|
|
|
+ });
|
|
|
+ },
|
|
|
+ cancelEdit(){
|
|
|
+ this.speakingDialog.update = false;
|
|
|
+ dialog.update = false;
|
|
|
+ this.homeworkForm.descriptionFile = null;
|
|
|
+ this.homeworkForm.assignmentName = [];
|
|
|
+ this.speakingHomeworkForm.descriptionFile = null;
|
|
|
+ this.recoverForm();
|
|
|
}
|
|
|
},
|
|
|
computed:{
|
|
|
@@ -374,10 +560,20 @@ export default {
|
|
|
</div>
|
|
|
<el-descriptions column="1" >
|
|
|
<template v-if="isWritingType">
|
|
|
- <el-descriptions-item label="作业类型">{{homeworkInfo.type==="speaking"?"AI对话":"写作"}}</el-descriptions-item>
|
|
|
+ <el-descriptions-item label="作业类型">{{homeworkInfo.type==="speaking"?"AI口语":"写作"}}</el-descriptions-item>
|
|
|
<el-descriptions-item label="作业描述">{{homeworkInfo.description}}</el-descriptions-item>
|
|
|
- <el-descriptions-item label="作业描述文件">无</el-descriptions-item>
|
|
|
- <el-descriptions-item label="附件">无</el-descriptions-item>
|
|
|
+ <el-descriptions-item label="作业描述文件">
|
|
|
+ <span v-if="!homeworkInfo.descriptionFile">无</span>
|
|
|
+ <a v-if="homeworkInfo.descriptionFile" :href="homeworkInfo.descriptionFile" target="_blank">
|
|
|
+ 查看描述文件
|
|
|
+ </a>
|
|
|
+ </el-descriptions-item>
|
|
|
+ <el-descriptions-item label="附件">
|
|
|
+ <span v-if="homeworkInfo.attachments.length===0">无</span>
|
|
|
+ <a v-if="homeworkInfo.attachments&&homeworkInfo.attachments.length!==0" :href="homeworkInfo.attachments[0]" target="_blank">
|
|
|
+ 查看附件
|
|
|
+ </a>
|
|
|
+ </el-descriptions-item>
|
|
|
<el-descriptions-item label="作业期限">
|
|
|
{{(homeworkInfo.startTime.substring(0, 16) + ' ~ ' + homeworkInfo.endTime.substring(0, 16)).replaceAll("T"," ")}}
|
|
|
</el-descriptions-item>
|
|
|
@@ -385,8 +581,18 @@ export default {
|
|
|
<template v-else>
|
|
|
<el-descriptions-item label="作业类型">{{speakingHomeworkInfo.type==="speaking"?"AI对话":"写作"}}</el-descriptions-item>
|
|
|
<el-descriptions-item label="作业描述">{{speakingHomeworkInfo.description}}</el-descriptions-item>
|
|
|
- <el-descriptions-item label="作业描述文件">无</el-descriptions-item>
|
|
|
- <el-descriptions-item label="附件">无</el-descriptions-item>
|
|
|
+ <el-descriptions-item label="作业描述文件">
|
|
|
+ <span v-if="!speakingHomeworkInfo.descriptionFile">无</span>
|
|
|
+ <a v-if="speakingHomeworkInfo.descriptionFile"
|
|
|
+ :href="speakingHomeworkInfo.descriptionFile"
|
|
|
+ style="width: 100px;overflow: hidden;text-overflow: ellipsis"
|
|
|
+ target="_blank">
|
|
|
+ 查看描述文件
|
|
|
+ </a>
|
|
|
+ </el-descriptions-item>
|
|
|
+ <el-descriptions-item label="附件">
|
|
|
+ 无
|
|
|
+ </el-descriptions-item>
|
|
|
<el-descriptions-item label="作业期限">
|
|
|
{{(speakingHomeworkInfo.startTime.substring(0, 16) + ' ~ ' + speakingHomeworkInfo.endTime.substring(0, 16)).replaceAll("T"," ")}}
|
|
|
</el-descriptions-item>
|
|
|
@@ -490,8 +696,10 @@ export default {
|
|
|
show-file-list
|
|
|
:auto-upload="false"
|
|
|
multiple
|
|
|
+ :on-change="handleUploadDesFile"
|
|
|
+ :on-exceed="handleExceedDesFile"
|
|
|
:limit="1"
|
|
|
- ref="attachmentUploadRef"
|
|
|
+ ref="writingDesFileUploadRef"
|
|
|
>
|
|
|
<el-icon :size="50" style="padding-top: 30px" >
|
|
|
<upload-filled />
|
|
|
@@ -515,7 +723,9 @@ export default {
|
|
|
show-file-list
|
|
|
:auto-upload="false"
|
|
|
multiple
|
|
|
- :limit="5"
|
|
|
+ :on-change="handleUploadAttachmentFile"
|
|
|
+ :on-exceed="handleAttachmentsExceed"
|
|
|
+ :limit="1"
|
|
|
ref="attachmentUploadRef"
|
|
|
>
|
|
|
<el-icon :size="50" style="padding-top: 30px" >
|
|
|
@@ -545,7 +755,7 @@ export default {
|
|
|
</el-form>
|
|
|
<template #footer>
|
|
|
<div class="dialog-footer">
|
|
|
- <el-button @click="dialog.create = false;this.recoverForm()">取消</el-button>
|
|
|
+ <el-button @click="cancelEdit">取消</el-button>
|
|
|
<el-button type="primary" @click="updateHomework">
|
|
|
保存
|
|
|
</el-button>
|
|
|
@@ -605,6 +815,8 @@ export default {
|
|
|
action=""
|
|
|
show-file-list
|
|
|
:auto-upload="false"
|
|
|
+ :on-change="handleUploadDesFile"
|
|
|
+ :on-exceed="handleExceedDesFile"
|
|
|
multiple
|
|
|
:limit="1"
|
|
|
ref="attachmentUploadRef"
|
|
|
@@ -623,6 +835,7 @@ export default {
|
|
|
</el-upload>
|
|
|
</el-form-item>
|
|
|
<el-form-item label="作业附件"
|
|
|
+ v-if="false"
|
|
|
prop="attachment"
|
|
|
class="homework-form-item">
|
|
|
<el-upload
|
|
|
@@ -742,7 +955,7 @@ export default {
|
|
|
</el-form>
|
|
|
<template #footer>
|
|
|
<div class="dialog-footer">
|
|
|
- <el-button @click="speakingDialog.update = false;this.recoverForm()">取消</el-button>
|
|
|
+ <el-button @click="cancelEdit">取消</el-button>
|
|
|
<el-button type="primary" @click="updateSpeakingHomework">
|
|
|
保存
|
|
|
</el-button>
|