lrf402788946 4 年之前
父节点
当前提交
42ead538c0
共有 1 个文件被更改,包括 22 次插入1 次删除
  1. 22 1
      src/views/user/chuanzuoye.vue

+ 22 - 1
src/views/user/chuanzuoye.vue

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