Commit adef92ff authored by 杨梦雪's avatar 杨梦雪

修改】查看和提交作业(用户端)

parent 20834103
......@@ -1442,7 +1442,9 @@ export default {
let _this = this;
let obj = {};
if (this.configJson.name == 1) {
obj.name = _this.referForm.name;
obj.name = _this.ref
erForm.name;
}
if (this.configJson.gender == 1) {
obj.gender = _this.referForm.gender;
......
......@@ -49,7 +49,6 @@
<div class="item_name">暂无相关附件</div>
</div>
</div>
<div style="clear: both"></div>
</div>
<!-- 我的作业(未提交) -->
......@@ -72,6 +71,7 @@
:disabled="student_status == 1 || student_status == 2"
/>
</el-form-item>
<!-- 上传相关附件 -->
<el-form-item label="相关附件" prop="stu_enclosure_url">
<div class="fj_info">1、请上传1-10份相关附件;</div>
<div class="fj_info">
......@@ -80,24 +80,23 @@
<div class="upload_box">
<div
class="img_list"
v-for="(item, index) in fileList"
v-for="(item, index) in stu_fileList"
:key="index"
>
<div>
<el-image class="home_icon" :src="fileImg"></el-image>
<div class="item_name">{{ item.name }}</div>
<div class="flex">
<div
v-show="student_status == 0"
class="item_remove"
@click="handleRemove(item)"
>
删除
</div>
<div
v-show="student_status == 0"
class="item_remove"
@click="handleCheck(item.url)"
@click="handleCheck(item.url_open)"
>
查看作业
</div>
......@@ -110,21 +109,27 @@
append-to-body
>
<el-image
:src="item.url"
:lazy='true'
:src="item.url_open"
:preview-src-list="srcList"
></el-image>
</el-dialog>
</div>
</div>
</div>
<!-- <div v-if="stu_fileList.length <= 0" class="img_list">-->
<!-- <div>-->
<!-- <div class="item_name">暂无相关附件</div>-->
<!-- </div>-->
<!-- </div>-->
<!-- </div>-->
<el-upload
v-if="fileList.length < 10 && student_status == 0"
v-if="stu_fileList.length < 10 "
ref="stu_enclosure_url"
name="multipartFile"
action="#"
:file-list="fileList"
:disabled="isUploading || fileList.length >= 10"
:file-list="stu_fileList"
:disabled="isUploading || stu_fileList.length >= 10"
:limit="10"
list-type="picture-card"
:show-file-list="false"
......@@ -140,26 +145,7 @@
class="el-icon-loading avatar-uploader-icon"
></i>
</el-upload>
<div
class="upload_box"
v-if="student_status == 1 || student_status == 2"
>
<div
class="img_list"
v-for="(item, index) in stu_fileList"
:key="index"
>
<div>
<el-image :src="fileImg"></el-image>
<div class="item_name">{{ item.name }}</div>
</div>
</div>
<div v-if="stu_fileList.length <= 0" class="img_list">
<div>
<div class="item_name">暂无相关附件</div>
</div>
</div>
</div>
</div>
<!-- </div> -->
</el-form-item>
......@@ -214,8 +200,6 @@
</div>
<div v-if="this.time_out != 3" class="cont_title_2">导师评分</div>
<div v-if="this.time_out != 3" class="cont_info">{{ score }}</div>
<div v-if="this.time_out == 3" class="cont_title_2">导师评语</div>
<div v-if="this.time_out == 3" v-html="teacher_commment" class="cont_info">}</div>
<div v-if="this.time_out != 3" class="cont_title_2">相关附件</div>
......@@ -247,9 +231,10 @@
</div>
</div>
<el-form-item class="btn" v-if="student_status == 0">
<el-form-item class="btn">
<el-button type="primary" v-preventReClick="1000" @click="confirm"
>提交</el-button
>提交
</el-button
>
</el-form-item>
</el-form>
......@@ -259,16 +244,10 @@
</template>
<script>
import {
PostWorkStudentOss,
delPic,
getStudentWork,
subStudentWork,
downloadTeacherWork,
} from "r/index/homework";
import fileImg from "@/assets/img/homework/file_img.png";
import {delPic, downloadTeacherWork, getStudentWork, PostWorkStudentOss, subStudentWork,} from "r/index/homework";
import fileImg from "@/assets/img/homework/file_img.png";
export default {
export default {
name: "ReadForm",
props: {
dialogVisibleFu: Boolean,
......@@ -303,15 +282,14 @@ export default {
callback();
}
};
return {
dialogVisibleImage: false,
referRules: {
stu_answer: [
{ required: true, validator: validateNum, trigger: "blur" },
{required: true, validator: validateNum, trigger: "blur"},
],
stu_enclosure_url: [
{ required: true, validator: validateNum, trigger: "blur" },
{required: true, validator: validateNum, trigger: "blur"},
],
},
titleName: "",
......@@ -329,9 +307,9 @@ export default {
stu_enclosure_url: "",
}, // 老师-评阅结果
disabled: false, //限制输入框
stu_enclosure_url: "",//学生的已经提交的相关附件
stu_fileListoss: "", // 学生-上传相关附件(展示-存在缓存)
teaFileList: [], // 老师-布置作业附件
fileList: [], //学生上传的作业文件
stu_fileList: [], //学生上传的文件(传给接口的格式)
score: "", //老师评分
teacher_commment: "", //老师评语
......@@ -340,12 +318,12 @@ export default {
};
},
created() {
// console.log(this.formData.stu_enclosure_url);
let code = this.$store.state.indexIdentity;
let stu_fileListoss = window.localStorage.getItem(
"student_file_" + window.localStorage.getItem("phone" + code) + code
);
console.log(stu_fileListoss);
if (stu_fileListoss && JSON.parse(stu_fileListoss).length > 0) {
this.stu_fileListoss = JSON.parse(stu_fileListoss);
}
......@@ -383,7 +361,6 @@ export default {
this.stu_fileList = [];
}
},
// 下载老师附件
downloadStuFile(url) {
// this.download(
......@@ -394,7 +371,7 @@ export default {
// },
// ""
// );
downloadTeacherWork({ enclosure_url: url }).then((res) => {
downloadTeacherWork({enclosure_url: url}).then((res) => {
// console.log(res, "res");
if (res.data.code != 200) {
return this.$message.error(res.data.message);
......@@ -411,7 +388,7 @@ export default {
},
// 下载老师评分结果
downloadScoreFile(url) {
downloadTeacherWork({ enclosure_url: url }).then((res) => {
downloadTeacherWork({enclosure_url: url}).then((res) => {
// console.log(res, "res");
if (res.data.code != 200) {
return this.$message.error(res.data.message);
......@@ -433,7 +410,7 @@ export default {
// console.log(stu_work_num);
// console.log(this.formData);
// return
getStudentWork({ teacher_id: stu_work_num }).then((res) => {
getStudentWork({teacher_id: stu_work_num}).then((res) => {
// console.log(res, "getStudentWork");
if (res.data.code != 200) {
return this.$message.error(res.data.message);
......@@ -443,25 +420,33 @@ export default {
// 学生已提交
this.formData.stu_answer = res.data.data.stu_answer;
// console.log(this.formData);
let gotfileList = res.data.data.stu_enclosure_url_arr;
//学生的已经提交的相关附件
this.stu_enclosure_url = res.data.data.stu_enclosure_url;
let gotfileList = res.data.data.work;
if (gotfileList) {
this.stu_fileList = gotfileList.map((item) => {
return {
name: item.split("/work/")[1],
url: item,
name: item.url.split("/work/")[1],
url: item.url,
url_open: item.url_open,
type: item.type,
};
});
console.log(this.stu_fileList);
}
this.$forceUpdate();
} else if (student_status == 2) {
//老师已评阅
this.formData.stu_answer = res.data.data.stu_answer;
let gotfileList = res.data.data.stu_enclosure_url_arr;
let gotfileList = res.data.data.work;
if (gotfileList) {
this.stu_fileList = gotfileList.map((item) => {
return {
name: item.split("/work/")[1],
url: item,
name: item.url.split("/work/")[1],
url: item.url,
url_open: item.url_open,
type: item.type,
};
});
}
......@@ -483,14 +468,14 @@ export default {
}
});
},
// 未完成
notReadHandle() {
this.formData.teacher_id = this.work_nums;
// if (!this.formData.stu_enclosure_url) {
// delete this.formData.stu_enclosure_url;
// } else {
this.formData.stu_enclosure_url = this.stu_fileListoss;
this.formData.stu_enclosure_url = this.stu_enclosure_url + ',' + this.stu_fileListoss;
// console.log(this.formData.stu_enclosure_url , "this.formData.stu_enclosure_url ");
// }
// if (!this.formData.stu_answer) {
// delete this.formData.stu_answer;
......@@ -510,7 +495,6 @@ export default {
console.log(error);
});
},
// 成功确认取消,关闭弹框,修改父组件的值
cancelBtnTrue() {
let code = this.$store.state.indexIdentity;
......@@ -518,10 +502,8 @@ export default {
"student_file_" + window.localStorage.getItem("phone" + code) + code
);
this.stu_fileList = [];
this.fileList = [];
this.stu_fileListoss = "";
this.teaFileList = [];
this.$refs["formRef_stu"].resetFields();
this.dialogVisible = false;
this.$emit("closeDialog", this.dialogVisible, true);
......@@ -535,10 +517,9 @@ export default {
"student_file_" + window.localStorage.getItem("phone" + code) + code
);
this.stu_fileList = [];
this.fileList = [];
this.stu_fileListoss = "";
this.teaFileList = [];
this.dialogVisible = false;
this.$emit("closeDialog", this.dialogVisible, false);
},
......@@ -550,7 +531,6 @@ export default {
}
return isLt500M;
},
uploadPicture(params) {
this.isUploading = true;
// console.log("已经准备好上传图片", params);
......@@ -601,26 +581,28 @@ export default {
this.$forceUpdate();
this.$message.success("上传成功");
obj = {
url: ress.data.picture_path,
url_open: ress.data.picture_path,
savefile: res.data.config.savefile,
name: res.data.config.savefile.split("/work/")[1],
};
this.fileList.push(obj);
// console.log(this.fileList, "fileList");
this.stu_fileListoss = this.fileList
this.stu_fileList.push(obj);
console.log(this.stu_fileList, "this.stu_fileList");
this.stu_fileListoss = this.stu_fileList
.map((item) => {
return item.url;
return item.url_open;
})
.join(",");
this.formData.stu_enclosure_url = this.stu_fileListoss;
// console.log(this.stu_fileListoss, "stu_fileListoss");
console.log(this.stu_fileListoss, "stu_fileListoss");
// this.formData.stu_enclosure_url = this.stu_fileListoss;
let code = this.$store.state.indexIdentity;
console.log(typeof (this.stu_fileListoss))
window.localStorage.setItem(
"student_file_" +
+window.localStorage.getItem("phone" + code) +
code,
JSON.stringify(this.stu_fileListoss)
);
console.log('student_file_')
this.isUploading = false;
})
.catch((err) => {
......@@ -644,54 +626,60 @@ export default {
},
//删除图片
handleRemove(file) {
// console.log(file, "file");
console.log(file, "file");
console.log(this.stu_fileList);
console.log(file.url_open, "file");
this.$confirm("此操作将永久删除该文件, 是否继续?", "提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning",
})
.then(() => {
let getfile = file.url;
let getfile = file.url_open;
// console.log(savefile.match(/^(?:[^\/]|\/\/)*/),'222222');//获取域名
let str = getfile.split(
"https://campiste.oss-cn-beijing.aliyuncs.com/"
); //https://yingdi-achievement.oss-cn-beijing.aliyuncs.com/进行分割,
// console.log(str, "str");
console.log(str, "str");
let savefile = str[1];
// console.log(savefile, "savefile");
let stu_work_num = this.work_nums;
delPic({ object: savefile, teacher_id: stu_work_num }).then((res) => {
delPic({object: savefile, teacher_id: stu_work_num}).then((res) => {
// console.log(res, "delpic");
if (res.data.code != 200) {
return this.$message.error(res.data.message);
}
// console.log(this.fileList);
console.log(this.stu_fileList);
// console.log(this.stu_fileListoss);
this.fileList.forEach((item, idx) => {
this.stu_fileList.forEach((item, idx) => {
// console.log(idx, "idx");
// console.log(item.url == file.url);
console.log(111111);
console.log(item.url);
console.log(file.url);
// return
console.log(item.url == file.url);
if (item.url == file.url) {
this.fileList.splice(idx, 1);
this.stu_fileList.splice(idx, 1);
let code = this.$store.state.indexIdentity;
this.stu_fileListoss = this.stu_fileList
.map(function (item, index) {
return item.url;
})
.join(",");
console.log(this.stu_fileListoss);
console.log(this.stu_fileList);
this.$message.success(res.data.message);
window.localStorage.setItem(
"student_file_" +
window.localStorage.getItem("phone" + code) +
code,
JSON.stringify(this.stu_fileListoss)
this.stu_fileListoss
);
}
});
this.stu_fileListoss = this.fileList
.map(function (item, index) {
undefined;
return item.url;
})
.join(",");
// console.log(this.stu_fileListoss);
// console.log(this.fileList);
this.$message.success(res.data.message);
});
console.log(this.stu_fileListoss);
console.log(this.stu_fileList);
})
.catch((err) => {
// console.log(err, "err");
......@@ -708,7 +696,7 @@ export default {
// 是否为图片
if (url.match(/\.(jpeg|jpg|gif|png)$/) != null) {
this.dialogVisibleImage = true;
// console.log(url.split(" "),'111')
// console.log(url.split(" "), '111')
this.srcList = url.split(" ");
} else {
let onlineViewType = [
......@@ -735,12 +723,16 @@ export default {
.then((_) => {
done();
})
.catch((_) => {});
.catch((_) => {
});
},
// 提交按钮
confirm() {
if (this.stu_fileList.length == 0) {
return this.$message.success('请上传相关附件再提交')
}
this.$confirm(
"提交后不可以修改本次作业和填写其他作业,您确认要提交本次作业吗?",
"提交后不可以填写其他作业,但在截止日期前仍可以修改本次作业,江毅最后一次提交的为准。您确认要提交本次作业吗?",
"提示",
{
confirmButtonText: "确定",
......@@ -781,15 +773,16 @@ export default {
console.log(this.time_out, "timeout");
},
},
};
};
</script>
<style scoped lang="scss">
@import "a/scss/btn";
@import "a/scss/homework/refer";
.flex {
@import "a/scss/btn";
@import "a/scss/homework/refer";
.flex {
display: flex;
}
}
</style>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment