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

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

parent 20834103
...@@ -1442,7 +1442,9 @@ export default { ...@@ -1442,7 +1442,9 @@ export default {
let _this = this; let _this = this;
let obj = {}; let obj = {};
if (this.configJson.name == 1) { if (this.configJson.name == 1) {
obj.name = _this.referForm.name; obj.name = _this.ref
erForm.name;
} }
if (this.configJson.gender == 1) { if (this.configJson.gender == 1) {
obj.gender = _this.referForm.gender; obj.gender = _this.referForm.gender;
......
...@@ -49,7 +49,6 @@ ...@@ -49,7 +49,6 @@
<div class="item_name">暂无相关附件</div> <div class="item_name">暂无相关附件</div>
</div> </div>
</div> </div>
<div style="clear: both"></div> <div style="clear: both"></div>
</div> </div>
<!-- 我的作业(未提交) --> <!-- 我的作业(未提交) -->
...@@ -72,6 +71,7 @@ ...@@ -72,6 +71,7 @@
:disabled="student_status == 1 || student_status == 2" :disabled="student_status == 1 || student_status == 2"
/> />
</el-form-item> </el-form-item>
<!-- 上传相关附件 -->
<el-form-item label="相关附件" prop="stu_enclosure_url"> <el-form-item label="相关附件" prop="stu_enclosure_url">
<div class="fj_info">1、请上传1-10份相关附件;</div> <div class="fj_info">1、请上传1-10份相关附件;</div>
<div class="fj_info"> <div class="fj_info">
...@@ -80,24 +80,23 @@ ...@@ -80,24 +80,23 @@
<div class="upload_box"> <div class="upload_box">
<div <div
class="img_list" class="img_list"
v-for="(item, index) in fileList" v-for="(item, index) in stu_fileList"
:key="index" :key="index"
> >
<div> <div>
<el-image class="home_icon" :src="fileImg"></el-image> <el-image class="home_icon" :src="fileImg"></el-image>
<div class="item_name">{{ item.name }}</div> <div class="item_name">{{ item.name }}</div>
<div class="flex"> <div class="flex">
<div <div
v-show="student_status == 0"
class="item_remove" class="item_remove"
@click="handleRemove(item)" @click="handleRemove(item)"
> >
删除 删除
</div> </div>
<div <div
v-show="student_status == 0"
class="item_remove" class="item_remove"
@click="handleCheck(item.url)" @click="handleCheck(item.url_open)"
> >
查看作业 查看作业
</div> </div>
...@@ -110,21 +109,27 @@ ...@@ -110,21 +109,27 @@
append-to-body append-to-body
> >
<el-image <el-image
:src="item.url" :lazy='true'
:src="item.url_open"
:preview-src-list="srcList" :preview-src-list="srcList"
></el-image> ></el-image>
</el-dialog> </el-dialog>
</div> </div>
</div> </div>
</div> </div>
<!-- <div v-if="stu_fileList.length <= 0" class="img_list">-->
<!-- <div>-->
<!-- <div class="item_name">暂无相关附件</div>-->
<!-- </div>-->
<!-- </div>-->
<!-- </div>-->
<el-upload <el-upload
v-if="fileList.length < 10 && student_status == 0" v-if="stu_fileList.length < 10 "
ref="stu_enclosure_url" ref="stu_enclosure_url"
name="multipartFile" name="multipartFile"
action="#" action="#"
:file-list="fileList" :file-list="stu_fileList"
:disabled="isUploading || fileList.length >= 10" :disabled="isUploading || stu_fileList.length >= 10"
:limit="10" :limit="10"
list-type="picture-card" list-type="picture-card"
:show-file-list="false" :show-file-list="false"
...@@ -140,26 +145,7 @@ ...@@ -140,26 +145,7 @@
class="el-icon-loading avatar-uploader-icon" class="el-icon-loading avatar-uploader-icon"
></i> ></i>
</el-upload> </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>
<!-- </div> --> <!-- </div> -->
</el-form-item> </el-form-item>
...@@ -214,8 +200,6 @@ ...@@ -214,8 +200,6 @@
</div> </div>
<div v-if="this.time_out != 3" class="cont_title_2">导师评分</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_info">{{ score }}</div>
<div v-if="this.time_out == 3" class="cont_title_2">导师评语</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" v-html="teacher_commment" class="cont_info">}</div>
<div v-if="this.time_out != 3" class="cont_title_2">相关附件</div> <div v-if="this.time_out != 3" class="cont_title_2">相关附件</div>
...@@ -247,9 +231,10 @@ ...@@ -247,9 +231,10 @@
</div> </div>
</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 type="primary" v-preventReClick="1000" @click="confirm"
>提交</el-button >提交
</el-button
> >
</el-form-item> </el-form-item>
</el-form> </el-form>
...@@ -259,537 +244,545 @@ ...@@ -259,537 +244,545 @@
</template> </template>
<script> <script>
import { import {delPic, downloadTeacherWork, getStudentWork, PostWorkStudentOss, subStudentWork,} from "r/index/homework";
PostWorkStudentOss, import fileImg from "@/assets/img/homework/file_img.png";
delPic,
getStudentWork,
subStudentWork,
downloadTeacherWork,
} from "r/index/homework";
import fileImg from "@/assets/img/homework/file_img.png";
export default {
name: "ReadForm",
props: {
dialogVisibleFu: Boolean,
timeOut: [Number, String], //判断是超时
work_contexts: [Number, String], //作业内容
enclosure_urls: [Object, String], //老师作业地址
work_nums: [Number],
workName: [String], //作业名字
student_status: [Number], //作业状态
order_nums: [Number], //作业状态
},
data() {
var validateNum = (rule, value, callback) => {
console.log(value, "value");
// let code = this.$store.state.indexIdentity;
// this.formData.stu_enclosure_url = window.localStorage.getItem(
// "student_file_" + window.localStorage.getItem("phone" + code) + code
// );
// console.log(
// this.stu_fileList,' this.stu_fileList'
// );
// return
// this.formData.stu_enclosure_url = this.stu_fileList
console.log(this.formData.stu_answer);
console.log(this.formData.stu_enclosure_url);
if (
this.formData.stu_answer == "" &&
this.formData.stu_enclosure_url == ""
) {
callback(new Error("请至少填写一项"));
} else {
callback();
}
};
return { export default {
dialogVisibleImage: false, name: "ReadForm",
referRules: { props: {
stu_answer: [ dialogVisibleFu: Boolean,
{ required: true, validator: validateNum, trigger: "blur" }, timeOut: [Number, String], //判断是超时
], work_contexts: [Number, String], //作业内容
stu_enclosure_url: [ enclosure_urls: [Object, String], //老师作业地址
{ required: true, validator: validateNum, trigger: "blur" }, work_nums: [Number],
], workName: [String], //作业名字
}, student_status: [Number], //作业状态
titleName: "", order_nums: [Number], //作业状态
isUploading: false, // 图片上传蒙层
work_context: "", //简介
work_name: "", //作业名称
time_out: 1,
fileImg: fileImg,
loading: false,
dialogVisible: this.dialogVisibleFu,
dialogVisibleimage: false,
formData: {
teacher_id: "",
stu_answer: "",
stu_enclosure_url: "",
}, // 老师-评阅结果
disabled: false, //限制输入框
stu_fileListoss: "", // 学生-上传相关附件(展示-存在缓存)
teaFileList: [], // 老师-布置作业附件
fileList: [], //学生上传的作业文件
stu_fileList: [], //学生上传的文件(传给接口的格式)
score: "", //老师评分
teacher_commment: "", //老师评语
tea_scoreFileList: [], //老师评语的附件
srcList: [], //在线预览图片-放大
};
},
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
);
if (stu_fileListoss && JSON.parse(stu_fileListoss).length > 0) {
this.stu_fileListoss = JSON.parse(stu_fileListoss);
}
},
methods: {
open() {
console.log(this.timeOut)
console.log(this.time_out)
// console.log(this.student_status);
this.titleName = this.order_nums;
// console.log(this.student_status);
this.getTeachList();
if (this.student_status == 0) {
this.formData = {};
} else if (this.student_status == 1) {
this.getStudentWork(this.student_status);
} else if (this.student_status == 2) {
this.getStudentWork(this.student_status);
}
},
//老师作业展示
getTeachList() {
let url = this.enclosure_urls;
// console.log(this.enclosure_urls);
if (this.enclosure_urls) {
let arr = url.split(",");
arr.forEach((item) => {
this.teaFileList.push({
url: item,
name: item.split("work/")[1],
status: "success",
});
});
} else {
this.stu_fileList = [];
}
}, },
data() {
// 下载老师附件 var validateNum = (rule, value, callback) => {
downloadStuFile(url) { console.log(value, "value");
// this.download( // let code = this.$store.state.indexIdentity;
// "http://api.campcenter.cn/web/download/downloadTeacherWork", // this.formData.stu_enclosure_url = window.localStorage.getItem(
// { // "student_file_" + window.localStorage.getItem("phone" + code) + code
// enclosure_url: url, // );
// identity: this.$store.state.indexIdentity // console.log(
// }, // this.stu_fileList,' this.stu_fileList'
// "" // );
// ); // return
downloadTeacherWork({ enclosure_url: url }).then((res) => { // this.formData.stu_enclosure_url = this.stu_fileList
// console.log(res, "res"); console.log(this.formData.stu_answer);
if (res.data.code != 200) { console.log(this.formData.stu_enclosure_url);
return this.$message.error(res.data.message); if (
} this.formData.stu_answer == "" &&
let url = res.data.url; this.formData.stu_enclosure_url == ""
let reg = /^.+(\.pdf|\.txt|\.mp3|\.mp4)$/; ) {
if (reg.test(url)) { callback(new Error("请至少填写一项"));
window.open(url, "_black");
} else { } else {
window.open(url, "_self"); callback();
} }
this.$message.success("下载成功"); };
}); return {
dialogVisibleImage: false,
referRules: {
stu_answer: [
{required: true, validator: validateNum, trigger: "blur"},
],
stu_enclosure_url: [
{required: true, validator: validateNum, trigger: "blur"},
],
},
titleName: "",
isUploading: false, // 图片上传蒙层
work_context: "", //简介
work_name: "", //作业名称
time_out: 1,
fileImg: fileImg,
loading: false,
dialogVisible: this.dialogVisibleFu,
dialogVisibleimage: false,
formData: {
teacher_id: "",
stu_answer: "",
stu_enclosure_url: "",
}, // 老师-评阅结果
disabled: false, //限制输入框
stu_enclosure_url: "",//学生的已经提交的相关附件
stu_fileListoss: "", // 学生-上传相关附件(展示-存在缓存)
teaFileList: [], // 老师-布置作业附件
stu_fileList: [], //学生上传的文件(传给接口的格式)
score: "", //老师评分
teacher_commment: "", //老师评语
tea_scoreFileList: [], //老师评语的附件
srcList: [], //在线预览图片-放大
};
}, },
// 下载老师评分结果 created() {
downloadScoreFile(url) { // console.log(this.formData.stu_enclosure_url);
downloadTeacherWork({ enclosure_url: url }).then((res) => { let code = this.$store.state.indexIdentity;
// console.log(res, "res"); let stu_fileListoss = window.localStorage.getItem(
if (res.data.code != 200) { "student_file_" + window.localStorage.getItem("phone" + code) + code
return this.$message.error(res.data.message); );
} console.log(stu_fileListoss);
let url = res.data.url; if (stu_fileListoss && JSON.parse(stu_fileListoss).length > 0) {
let reg = /^.+(\.pdf|\.txt|\.mp3|\.mp4)$/; this.stu_fileListoss = JSON.parse(stu_fileListoss);
if (reg.test(url)) { }
window.open(url, "_black");
} else {
window.open(url, "_self");
}
this.$message.success("下载成功");
});
}, },
// 学生作业回显 methods: {
getStudentWork(student_status) { open() {
// console.log(student_status, "student_status"); console.log(this.timeOut)
let stu_work_num = this.work_nums; console.log(this.time_out)
// console.log(stu_work_num); // console.log(this.student_status);
// console.log(this.formData); this.titleName = this.order_nums;
// return // console.log(this.student_status);
getStudentWork({ teacher_id: stu_work_num }).then((res) => { this.getTeachList();
// console.log(res, "getStudentWork"); if (this.student_status == 0) {
if (res.data.code != 200) { this.formData = {};
return this.$message.error(res.data.message); } else if (this.student_status == 1) {
this.getStudentWork(this.student_status);
} else if (this.student_status == 2) {
this.getStudentWork(this.student_status);
} }
this.$message.success(res.data.message); },
if (student_status == 1) { //老师作业展示
// 学生已提交 getTeachList() {
this.formData.stu_answer = res.data.data.stu_answer; let url = this.enclosure_urls;
// console.log(this.formData); // console.log(this.enclosure_urls);
let gotfileList = res.data.data.stu_enclosure_url_arr; if (this.enclosure_urls) {
if (gotfileList) { let arr = url.split(",");
this.stu_fileList = gotfileList.map((item) => { arr.forEach((item) => {
return { this.teaFileList.push({
name: item.split("/work/")[1], url: item,
url: item, name: item.split("work/")[1],
}; status: "success",
}); });
});
} else {
this.stu_fileList = [];
}
},
// 下载老师附件
downloadStuFile(url) {
// this.download(
// "http://api.campcenter.cn/web/download/downloadTeacherWork",
// {
// enclosure_url: url,
// identity: this.$store.state.indexIdentity
// },
// ""
// );
downloadTeacherWork({enclosure_url: url}).then((res) => {
// console.log(res, "res");
if (res.data.code != 200) {
return this.$message.error(res.data.message);
} }
this.$forceUpdate(); let url = res.data.url;
} else if (student_status == 2) { let reg = /^.+(\.pdf|\.txt|\.mp3|\.mp4)$/;
//老师已评阅 if (reg.test(url)) {
this.formData.stu_answer = res.data.data.stu_answer; window.open(url, "_black");
let gotfileList = res.data.data.stu_enclosure_url_arr; } else {
if (gotfileList) { window.open(url, "_self");
this.stu_fileList = gotfileList.map((item) => {
return {
name: item.split("/work/")[1],
url: item,
};
});
} }
this.score = res.data.data.score; //老师评分 this.$message.success("下载成功");
this.teacher_commment = res.data.data.teacher_commment; //老师评语 });
// console.log(res.data.data.teacher_commment, " this.teacher_commment"); },
let scoreFileList = res.data.data.teacher_url; // 下载老师评分结果
if (scoreFileList) { downloadScoreFile(url) {
let arr = scoreFileList.split(","); downloadTeacherWork({enclosure_url: url}).then((res) => {
// console.log(arr, "arr"); // console.log(res, "res");
this.tea_scoreFileList = arr.map((item) => { if (res.data.code != 200) {
return { return this.$message.error(res.data.message);
name: item.split("workforstudent/")[1],
url: item,
};
});
} }
this.$forceUpdate(); //强制刷新 let url = res.data.url;
} let reg = /^.+(\.pdf|\.txt|\.mp3|\.mp4)$/;
}); if (reg.test(url)) {
}, window.open(url, "_black");
} else {
// 未完成 window.open(url, "_self");
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;
// }
// if (!this.formData.stu_answer) {
// delete this.formData.stu_answer;
// }
// console.log(this.stu_fileList, "this.stu_fileList");
// return
subStudentWork(this.formData)
.then((response) => {
// console.log(response);
if (response.data.code != 200) {
return this.$message.error(response.data.message);
} }
this.$message.success(response.data.message); this.$message.success("下载成功");
this.cancelBtnTrue();
})
.catch((error) => {
console.log(error);
}); });
}, },
// 学生作业回显
// 成功确认取消,关闭弹框,修改父组件的值 getStudentWork(student_status) {
cancelBtnTrue() { // console.log(student_status, "student_status");
let code = this.$store.state.indexIdentity; let stu_work_num = this.work_nums;
window.localStorage.removeItem( // console.log(stu_work_num);
"student_file_" + window.localStorage.getItem("phone" + code) + code // console.log(this.formData);
); // return
this.stu_fileList = []; getStudentWork({teacher_id: stu_work_num}).then((res) => {
this.fileList = []; // console.log(res, "getStudentWork");
this.stu_fileListoss = ""; if (res.data.code != 200) {
this.teaFileList = []; return this.$message.error(res.data.message);
}
this.$refs["formRef_stu"].resetFields(); this.$message.success(res.data.message);
this.dialogVisible = false; if (student_status == 1) {
this.$emit("closeDialog", this.dialogVisible, true); // 学生已提交
// this.$parent.getTeacherWork(); this.formData.stu_answer = res.data.data.stu_answer;
// location.reload(); // console.log(this.formData);
}, //学生的已经提交的相关附件
// 取消,关闭弹框,修改父组件的值 this.stu_enclosure_url = res.data.data.stu_enclosure_url;
cancelBtn() { let gotfileList = res.data.data.work;
let code = this.$store.state.indexIdentity; if (gotfileList) {
window.localStorage.removeItem( this.stu_fileList = gotfileList.map((item) => {
"student_file_" + window.localStorage.getItem("phone" + code) + code return {
); name: item.url.split("/work/")[1],
this.stu_fileList = []; url: item.url,
this.fileList = []; url_open: item.url_open,
this.stu_fileListoss = ""; type: item.type,
this.teaFileList = []; };
});
this.dialogVisible = false;
this.$emit("closeDialog", this.dialogVisible, false);
},
//上传前
beforeAvatarUpload(file) {
const isLt500M = file.size / 1024 / 1024 < 500;
if (!isLt500M) {
this.$message.info("上传图片大小不能超过 500MB!");
}
return isLt500M;
},
uploadPicture(params) { console.log(this.stu_fileList);
this.isUploading = true; }
// console.log("已经准备好上传图片", params); this.$forceUpdate();
this.file = params.file; } else if (student_status == 2) {
// console.log(this.file, "1111"); //老师已评阅
console.log(this.file, "1111"); this.formData.stu_answer = res.data.data.stu_answer;
let raw = params.file; let gotfileList = res.data.data.work;
let image = { if (gotfileList) {
name: raw.name, this.stu_fileList = gotfileList.map((item) => {
size: raw.size, return {
type: raw.type, name: item.url.split("/work/")[1],
}; url: item.url,
this.getOssConfigs(image, params.file); url_open: item.url_open,
}, type: item.type,
async getOssConfigs(image, file) {
let obj = {
url: "",
savefile: "",
};
await PostWorkStudentOss({
image: image,
teacher_id: this.work_nums,
})
.then((res) => {
// console.log(res, "开始上传图片");
if (res.data.code === 200) {
let oss_url = res.data.config.host;
let filename = res.data.config.file;
let formData = new FormData();
formData.append("OSSAccessKeyId", res.data.config.accessid);
formData.append("policy", res.data.config.policy);
formData.append("signature", res.data.config.signature);
formData.append("filename", res.data.config.file);
formData.append("key", res.data.config.savefile);
formData.append("callback", res.data.config.callback);
formData.append("success_action_status", 200);
formData.append("file", file);
// console.log(formData);
this.upload(oss_url, formData)
.then((ress) => {
console.log(ress, "ress");
if (ress.data.code != 200) {
// console.log(ress, "ress");
this.isUploading = false;
return this.$message.error(ress.data.message);
}
this.resultPicture = filename + "?t=" + Date.parse(new Date());
this.$forceUpdate();
this.$message.success("上传成功");
obj = {
url: 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
.map((item) => {
return item.url;
})
.join(",");
this.formData.stu_enclosure_url = this.stu_fileListoss;
// console.log(this.stu_fileListoss, "stu_fileListoss");
let code = this.$store.state.indexIdentity;
window.localStorage.setItem(
"student_file_" +
+window.localStorage.getItem("phone" + code) +
code,
JSON.stringify(this.stu_fileListoss)
);
this.isUploading = false;
})
.catch((err) => {
this.isUploading = false;
this.$message.error(err);
}); });
} else { }
this.isUploading = false; this.score = res.data.data.score; //老师评分
this.$message.error(res.data.message); this.teacher_commment = res.data.data.teacher_commment; //老师评语
// console.log(res.data.data.teacher_commment, " this.teacher_commment");
let scoreFileList = res.data.data.teacher_url;
if (scoreFileList) {
let arr = scoreFileList.split(",");
// console.log(arr, "arr");
this.tea_scoreFileList = arr.map((item) => {
return {
name: item.split("workforstudent/")[1],
url: item,
};
});
}
this.$forceUpdate(); //强制刷新
} }
})
.catch((err) => {
this.isUploading = false;
// console.log(err);
}); });
}, },
// 下载证明资料图片 // 未完成
handleDownload(file) { notReadHandle() {
// console.log(file,'file22'); this.formData.teacher_id = this.work_nums;
window.location.href = file.url; // if (!this.formData.stu_enclosure_url) {
}, // delete this.formData.stu_enclosure_url;
//删除图片 // } else {
handleRemove(file) { this.formData.stu_enclosure_url = this.stu_enclosure_url + ',' + this.stu_fileListoss;
// console.log(file, "file"); // console.log(this.formData.stu_enclosure_url , "this.formData.stu_enclosure_url ");
this.$confirm("此操作将永久删除该文件, 是否继续?", "提示", { // }
confirmButtonText: "确定", // if (!this.formData.stu_answer) {
cancelButtonText: "取消", // delete this.formData.stu_answer;
type: "warning", // }
}) // console.log(this.stu_fileList, "this.stu_fileList");
.then(() => { // return
let getfile = file.url; subStudentWork(this.formData)
// console.log(savefile.match(/^(?:[^\/]|\/\/)*/),'222222');//获取域名 .then((response) => {
let str = getfile.split( // console.log(response);
"https://campiste.oss-cn-beijing.aliyuncs.com/" if (response.data.code != 200) {
); //https://yingdi-achievement.oss-cn-beijing.aliyuncs.com/进行分割, return this.$message.error(response.data.message);
// 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) => {
// console.log(res, "delpic");
if (res.data.code != 200) {
return this.$message.error(res.data.message);
} }
// console.log(this.fileList); this.$message.success(response.data.message);
// console.log(this.stu_fileListoss); this.cancelBtnTrue();
this.fileList.forEach((item, idx) => { })
// console.log(idx, "idx"); .catch((error) => {
// console.log(item.url == file.url); console.log(error);
if (item.url == file.url) {
this.fileList.splice(idx, 1);
let code = this.$store.state.indexIdentity;
window.localStorage.setItem(
"student_file_" +
window.localStorage.getItem("phone" + code) +
code,
JSON.stringify(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);
}); });
}) },
.catch((err) => { // 成功确认取消,关闭弹框,修改父组件的值
// console.log(err, "err"); cancelBtnTrue() {
this.$message({ let code = this.$store.state.indexIdentity;
type: "info", window.localStorage.removeItem(
message: "取消删除", "student_file_" + window.localStorage.getItem("phone" + code) + code
}); );
}); this.stu_fileList = [];
}, this.stu_fileListoss = "";
// 查看已上传的学生作业 this.teaFileList = [];
handleCheck(url) { this.$refs["formRef_stu"].resetFields();
console.log(url, "url"); this.dialogVisible = false;
// console.log(url.match(/\.(jpeg|jpg|gif|png)$/) != null) this.$emit("closeDialog", this.dialogVisible, true);
// 是否为图片 // this.$parent.getTeacherWork();
if (url.match(/\.(jpeg|jpg|gif|png)$/) != null) { // location.reload();
this.dialogVisibleImage = true; },
// console.log(url.split(" "),'111') // 取消,关闭弹框,修改父组件的值
this.srcList = url.split(" "); cancelBtn() {
} else { let code = this.$store.state.indexIdentity;
let onlineViewType = [ window.localStorage.removeItem(
"doc", "student_file_" + window.localStorage.getItem("phone" + code) + code
"docx", );
"xls", this.stu_fileList = [];
"xlsx",
"xlsm", this.stu_fileListoss = "";
"ppt", this.teaFileList = [];
"pptx", this.dialogVisible = false;
]; this.$emit("closeDialog", this.dialogVisible, false);
let fileTypeName = url },
.substring(url.lastIndexOf(".") + 1, url.length) //上传前
.split("?")[0]; beforeAvatarUpload(file) {
let isWord = onlineViewType.find((type) => type === fileTypeName); const isLt500M = file.size / 1024 / 1024 < 500;
if (isWord) { if (!isLt500M) {
url = "http://view.officeapps.live.com/op/view.aspx?src=" + url; this.$message.info("上传图片大小不能超过 500MB!");
} }
window.open(url, "_blank"); return isLt500M;
} },
}, uploadPicture(params) {
handleImageClose(done) { this.isUploading = true;
this.$confirm("确认关闭?") // console.log("已经准备好上传图片", params);
.then((_) => { this.file = params.file;
done(); // console.log(this.file, "1111");
console.log(this.file, "1111");
let raw = params.file;
let image = {
name: raw.name,
size: raw.size,
type: raw.type,
};
this.getOssConfigs(image, params.file);
},
async getOssConfigs(image, file) {
let obj = {
url: "",
savefile: "",
};
await PostWorkStudentOss({
image: image,
teacher_id: this.work_nums,
}) })
.catch((_) => {}); .then((res) => {
}, // console.log(res, "开始上传图片");
// 提交按钮 if (res.data.code === 200) {
confirm() { let oss_url = res.data.config.host;
this.$confirm( let filename = res.data.config.file;
"提交后不可以修改本次作业和填写其他作业,您确认要提交本次作业吗?", let formData = new FormData();
"提示", formData.append("OSSAccessKeyId", res.data.config.accessid);
{ formData.append("policy", res.data.config.policy);
formData.append("signature", res.data.config.signature);
formData.append("filename", res.data.config.file);
formData.append("key", res.data.config.savefile);
formData.append("callback", res.data.config.callback);
formData.append("success_action_status", 200);
formData.append("file", file);
// console.log(formData);
this.upload(oss_url, formData)
.then((ress) => {
console.log(ress, "ress");
if (ress.data.code != 200) {
// console.log(ress, "ress");
this.isUploading = false;
return this.$message.error(ress.data.message);
}
this.resultPicture = filename + "?t=" + Date.parse(new Date());
this.$forceUpdate();
this.$message.success("上传成功");
obj = {
url_open: ress.data.picture_path,
savefile: res.data.config.savefile,
name: res.data.config.savefile.split("/work/")[1],
};
this.stu_fileList.push(obj);
console.log(this.stu_fileList, "this.stu_fileList");
this.stu_fileListoss = this.stu_fileList
.map((item) => {
return item.url_open;
})
.join(",");
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) => {
this.isUploading = false;
this.$message.error(err);
});
} else {
this.isUploading = false;
this.$message.error(res.data.message);
}
})
.catch((err) => {
this.isUploading = false;
// console.log(err);
});
},
// 下载证明资料图片
handleDownload(file) {
// console.log(file,'file22');
window.location.href = file.url;
},
//删除图片
handleRemove(file) {
console.log(file, "file");
console.log(this.stu_fileList);
console.log(file.url_open, "file");
this.$confirm("此操作将永久删除该文件, 是否继续?", "提示", {
confirmButtonText: "确定", confirmButtonText: "确定",
cancelButtonText: "取消", cancelButtonText: "取消",
type: "warning", type: "warning",
})
.then(() => {
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");
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) => {
// console.log(res, "delpic");
if (res.data.code != 200) {
return this.$message.error(res.data.message);
}
console.log(this.stu_fileList);
// console.log(this.stu_fileListoss);
this.stu_fileList.forEach((item, idx) => {
// console.log(idx, "idx");
console.log(111111);
console.log(item.url);
console.log(file.url);
// return
console.log(item.url == file.url);
if (item.url == file.url) {
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,
this.stu_fileListoss
);
}
});
});
console.log(this.stu_fileListoss);
console.log(this.stu_fileList);
})
.catch((err) => {
// console.log(err, "err");
this.$message({
type: "info",
message: "取消删除",
});
});
},
// 查看已上传的学生作业
handleCheck(url) {
console.log(url, "url");
// console.log(url.match(/\.(jpeg|jpg|gif|png)$/) != null)
// 是否为图片
if (url.match(/\.(jpeg|jpg|gif|png)$/) != null) {
this.dialogVisibleImage = true;
// console.log(url.split(" "), '111')
this.srcList = url.split(" ");
} else {
let onlineViewType = [
"doc",
"docx",
"xls",
"xlsx",
"xlsm",
"ppt",
"pptx",
];
let fileTypeName = url
.substring(url.lastIndexOf(".") + 1, url.length)
.split("?")[0];
let isWord = onlineViewType.find((type) => type === fileTypeName);
if (isWord) {
url = "http://view.officeapps.live.com/op/view.aspx?src=" + url;
}
window.open(url, "_blank");
} }
) },
.then(() => { handleImageClose(done) {
this.$refs["formRef_stu"].validate((valid) => { this.$confirm("确认关闭?")
if (!valid) return; .then((_) => {
// console.log(valid, "valid"); done();
// 未完成 })
// return .catch((_) => {
this.notReadHandle();
}); });
}) },
.catch(() => { // 提交按钮
this.$message({ confirm() {
type: "info", if (this.stu_fileList.length == 0) {
message: "已取消", return this.$message.success('请上传相关附件再提交')
}
this.$confirm(
"提交后不可以填写其他作业,但在截止日期前仍可以修改本次作业,江毅最后一次提交的为准。您确认要提交本次作业吗?",
"提示",
{
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning",
}
)
.then(() => {
this.$refs["formRef_stu"].validate((valid) => {
if (!valid) return;
// console.log(valid, "valid");
// 未完成
// return
this.notReadHandle();
});
})
.catch(() => {
this.$message({
type: "info",
message: "已取消",
});
}); });
}); },
}, },
},
watch: { watch: {
dialogVisibleFu() { dialogVisibleFu() {
this.dialogVisible = this.dialogVisibleFu; this.dialogVisible = this.dialogVisibleFu;
}, },
work_nums() { work_nums() {
this.formData.teacher_id = this.work_nums; this.formData.teacher_id = this.work_nums;
}, },
workName() { workName() {
this.work_name = this.workName; this.work_name = this.workName;
}, },
timeOut() { timeOut() {
this.time_out = this.timeOut; this.time_out = this.timeOut;
console.log(this.time_out, "timeout"); console.log(this.time_out, "timeout");
},
}, },
}, };
};
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
@import "a/scss/btn"; @import "a/scss/btn";
@import "a/scss/homework/refer"; @import "a/scss/homework/refer";
.flex {
display: flex; .flex {
} display: flex;
}
</style> </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