Преглед на файлове

Merge branch 'web-v2' of http://192.168.1.43:3000/git/sass-lab-web into web-v2

dedsudiyu преди 2 години
родител
ревизия
081710cb87
променени са 1 файла, в които са добавени 27 реда и са изтрити 34 реда
  1. 27 34
      src/views/safetyEducationExam/safeLearning/el_resources/index.vue

+ 27 - 34
src/views/safetyEducationExam/safeLearning/el_resources/index.vue

@@ -454,7 +454,9 @@ export default {
       upTextList:[],
       //修改页面
       openEdit:false,
-      editForm:{},
+      editForm:{
+        id:'',
+      },
       //修改上传
       editTree:[],
       fileList:[],
@@ -581,7 +583,7 @@ export default {
       let self = this;
       if(type == 1){
         if(!this.queryParams.cateId){
-          this.msgError('请选择分类')
+          this.msgError('请在左侧列表选择分类')
           return
         }
         this.richTextForm = {};
@@ -594,9 +596,6 @@ export default {
         this.richTextForm.cateId = row.cateId;
         this.richTextForm.content = unescape(row.content);
         this.richTextEditType = true;
-        setTimeout(function(){
-          self.$refs.ditTree.setCheckedKeys([row.cateId]);
-        },100);
       }
     },
     //关闭富文本按钮
@@ -750,12 +749,6 @@ export default {
         }
       }
       self.typeTitle=text
-      // if(node.parent.data.title){
-      //   this.typeTitle=node.parent.data.title+'/'+data.title;//点击的分类名称
-      //   // this.typeTitle=data.title;//点击的分类名称
-      // }else{
-      //   this.typeTitle=data.title;//点击的分类名称
-      // }
       console.log('当前节点的父节点:',node.parent.data);
       //根据id查找父元素
       console.log(this.familyTree(this.treeData,data.id))
@@ -874,11 +867,14 @@ export default {
     /** 新增按钮操作 */
     handleAdd() {
       if(!this.queryParams.cateId){
-        this.msgError('请选择分类')
+        this.msgError('请在左侧列表选择分类')
         return
       }
       console.log(this.form.title)
       this.reset();
+      this.coursewareName='';
+      this.editForm.cateId='';
+      this.editForm.id='';
       this.uploadImgUrl = window.location.href.split('://')[0]+'://' + process.env.VUE_APP_BASE_API + "/exam/el_resources?cateId=" + this.queryParams.cateId
       this.upTextList = [];
       this.open = true;
@@ -907,12 +903,13 @@ export default {
         this.getList();
       });
     },
-    updateResource() {
+    updateResource(filePath) {
+      let _this=this;
       let obj = {
         id: this.editForm.id,
         cateId: this.editForm.cateId,
         title: this.editForm.title,
-        path: this.filePath,
+        path: filePath,
         fileName: this.fileName,
         size: this.fileSize
       }
@@ -920,6 +917,11 @@ export default {
         this.msgSuccess("修改成功");
         this.loading = false;
         this.openEdit = false;
+        this.coursewareName=response.data.fileName;//课件名称
+        this.loading = false;
+        setTimeout(function (){
+          _this.open = false;
+        },2000)
         this.allRemove();
         this.getList();
       });
@@ -927,22 +929,6 @@ export default {
     /** 修改按钮操作 */
     handleUpdate(row) {
       let self = this;
-      console.log(row)
-     /*
-      if(row.type=='5'){
-        this.richTextAddClick(2,row)
-        return
-      }
-      this.reset();
-      this.editForm = {};
-      this.fileList = [];
-      this.upTextList = [];
-      this.editForm =  JSON.parse(JSON.stringify(row));
-      this.title = "修改课件资源";
-      this.openEdit = true;
-      setTimeout(function(){
-        self.$refs.ditTree.setCheckedKeys([row.cateId]);
-      },100);*/
 
       //根据id查找父元素
       console.log(this.familyTree(this.treeData,row.cateId))
@@ -978,16 +964,19 @@ export default {
       }else{
         self.typeTitle='该分类已删除'
       }
-      // self.typeTitle=treeArr.join('/')
 
       if(row.type=='5'){
         this.richTextAddClick(2,row)
         return
       }
 
-      this.queryParams.cateId=row.cateId
+
       this.coursewareName=row.title
-      this.queryParams.id=row.id
+      // this.queryParams.cateId=row.cateId
+      //this.queryParams.id=row.id
+       this.editForm.cateId=row.cateId
+       this.editForm.id=row.id
+
       this.reset();
       this.uploadImgUrl = window.location.href.split('://')[0]+'://' + process.env.VUE_APP_BASE_API + "/exam/el_resources?cateId=" + this.queryParams.cateId
       this.upTextList = [];
@@ -1028,8 +1017,12 @@ export default {
             }
         }).then((res) => {
             if (res.data.code==200) {
-              if(!this.editForm.id){
+              if(!this.editForm.id){//新增
+                console.log(1)
                 this.addResource(res.data.data);
+              }else{//修改
+                console.log(2)
+                this.updateResource(res.data.data);
               }
               this.filePath=res.data.data;
             } else {