|
@@ -114,6 +114,15 @@ export default {
|
|
|
});
|
|
|
return;
|
|
|
}
|
|
|
+ // 验证图片地址是否是空
|
|
|
+ if (obj.picurl.some(f => !f)) {
|
|
|
+ this.$message({
|
|
|
+ showClose: true,
|
|
|
+ message: '图片数据错误,请删除重新上传',
|
|
|
+ type: 'error',
|
|
|
+ });
|
|
|
+ return;
|
|
|
+ }
|
|
|
if (!obj.id) {
|
|
|
let res = await this.add(obj);
|
|
|
if (this.$checkRes(res)) {
|
|
@@ -148,7 +157,19 @@ export default {
|
|
|
this.pic.splice(this.pic.length - 1, 1, { status: 'uploading', message: '上传中...' });
|
|
|
try {
|
|
|
const { file } = data;
|
|
|
- const res = await this.taskUpload(file);
|
|
|
+ let upuri = `/files/task/`;
|
|
|
+ if (this.user.classid) {
|
|
|
+ upuri = `${upuri}${this.user.classid}_`;
|
|
|
+ }
|
|
|
+ if (this.taskAnswer.lessonname) {
|
|
|
+ upuri = `${upuri}${this.taskAnswer.lessonname}_`;
|
|
|
+ }
|
|
|
+ if (this.user.name) {
|
|
|
+ upuri = `${upuri}${this.user.name}_`;
|
|
|
+ }
|
|
|
+ if (upuri.endsWith('_')) upuri = _.trimEnd(upuri, '_');
|
|
|
+ upuri = `${upuri}/upload`;
|
|
|
+ const res = await this.taskUpload({ file, uri: upuri });
|
|
|
const { uri } = res.data;
|
|
|
if (uri) this.pic.splice(this.pic.length - 1, 1, { url: uri });
|
|
|
else this.pic.splice(this.pic.length - 1, 1, { status: 'failed', message: '上传失败' });
|