瀏覽代碼

上传功能及查询

zengyicheng 3 年之前
父節點
當前提交
e27f1f4dde
共有 3 個文件被更改,包括 79 次插入10 次删除
  1. 76 7
      src/components/liveProjectDetail.vue
  2. 1 1
      src/components/liveRoom.vue
  3. 2 2
      src/config/config.js

+ 76 - 7
src/components/liveProjectDetail.vue

@@ -254,7 +254,11 @@
                 </div>
               </div>
             </div>
-            <div class="uploadImg" @click="addImg($event)">
+            <div
+              class="uploadImg"
+              @click="addImg($event)"
+              v-if="upload[0].upImg.length == 0"
+            >
               <img src="../assets/icon/uploadImg.png" alt="" />
               <input
                 type="file"
@@ -273,7 +277,7 @@
               </div>
             </div>
           </div>
-          <div
+          <!-- <div
             style="
               display: flex;
               flex-direction: row;
@@ -314,7 +318,7 @@
                 上传视频
               </div>
             </div>
-          </div>
+          </div> -->
           <div style="padding-left: 25px">
             <span style="color: red">*</span> 简要描述
           </div>
@@ -333,9 +337,7 @@
             style="padding: 10% 10px 50px 0px"
           >
             <el-button @click="steps = 1">返回答题</el-button>
-            <el-button type="primary" @click="dialogVisible = true"
-              >确定</el-button
-            >
+            <el-button type="primary" @click="addWork">确定</el-button>
           </span>
         </div>
       </div>
@@ -392,11 +394,13 @@ export default {
       isLoading: false,
       formLabelWidth: "100px",
       userid: this.$route.query.userid,
+      cid: this.$route.query.courseId,
       oid: this.$route.query.oid,
       mr: require("../assets/kc1.png"),
       timu: [],
       dialogVisible: false,
       answerBox: "",
+      isNoHomeWork: false,
       answer: [
         { name: "A.1568" },
         { name: "B.720" },
@@ -602,9 +606,74 @@ export default {
           });
       }
     },
+    addWork() {
+      if (this.upload[0].upImg.length == 0) {
+        this.$message.error("请上传图片");
+        return;
+      }
+      //  else if (this.upload[0].upVedio.length == 0) {
+      //   this.$message.error("请上传视频");
+      //   return;
+      // }
+      else if (this.upload[0].upIntro == "") {
+        this.$message.error("请填写简要描述");
+        return;
+      }
+      if (this.isNoHomeWork == true) {
+        this.$confirm(
+          "您已经提交了该作业了,如果您再提交将覆盖上次提交的作业!",
+          "提示",
+          {
+            confirmButtonText: "确定",
+            cancelButtonText: "取消",
+            type: "warning",
+          }
+        )
+          .then(() => {
+            this.addSWork();
+          })
+          .catch(() => {});
+      } else {
+        this.addSWork();
+      }
+    },
+    addSWork() {
+      let params = {
+        uid: this.userid,
+        upload: JSON.stringify(this.upload),
+      };
+      this.ajax
+        .get(this.$store.state.api + "insertSWork", params)
+        .then((res) => {
+          this.isNoHomeWork = true;
+          this.selectSWork();
+          // this.upload = res.data[0][0].upload;
+        })
+        .catch((err) => {
+          this.$message.error("查询失败");
+          console.error(err);
+        });
+    },
+    selectSWork() {
+      let params = {
+        uid: this.userid,
+        cid: this.cid,
+      };
+      this.ajax
+        .get(this.$store.state.api + "selectSWork", params)
+        .then((res) => {
+          this.isNoHomeWork = true;
+        })
+        .catch((err) => {
+          this.$message.error("提交失败");
+          console.error(err);
+        });
+    },
     search() {},
   },
-  created() {},
+  created() {
+    this.selectSWork();
+  },
 };
 </script>
 

+ 1 - 1
src/components/liveRoom.vue

@@ -101,7 +101,7 @@ export default {
     return {
       myCourse: [
         //   {cover:[],title:"认识种子的起源",chapters:[],createTime:new Date().getTime()},
-          {cover:[],title:"湖心亭看雪可可乐博模拟展示课件",chapters:[],createTime:new Date().getTime()},
+          {cover:[],courseid:"9a4e8dbe-132e-438e-97db-b07eb01fa04c",title:"湖心亭看雪可可乐博模拟展示课件",chapters:[],createTime:new Date().getTime()},
       ],
       studentMessage: [],
       tx: require("../assets/avatar.png"),

+ 2 - 2
src/config/config.js

@@ -9,8 +9,8 @@ const store = new Vuex.Store({
         luyou: 1,
         userInfo: {},
         nCount: 0,
-        api: 'https://pbl.cocorobo.cn/api/pbl/',
-        // api: 'http://localhost:7003/api/pbl/',
+        // api: 'https://pbl.cocorobo.cn/api/pbl/',
+        api: 'http://localhost:7003/api/pbl/',
     },
 
     mutations: {