Преглед изворни кода

课程管理-视频库 视频上传修改、关联题目修改

Long пре 1 месец
родитељ
комит
8e40844c7f
3 измењених фајлова са 54 додато и 30 уклоњено
  1. 1 1
      src/utils/cos.js
  2. 1 1
      src/utils/obs.js
  3. 52 28
      src/views/course/videoResource/index.vue

+ 1 - 1
src/utils/cos.js

@@ -3,7 +3,7 @@ import { Message } from 'element-ui';
 import { getTmpSecretKey } from '@/api/common';
 
 const config = {
-    Bucket: 'fby-1323137866',
+    Bucket: 'hylj-1323137866',
     Region: 'ap-chongqing',
 };
 

+ 1 - 1
src/utils/obs.js

@@ -29,7 +29,7 @@ export const uploadToOBS = async(file,progressCallback,type) =>  {
         return new Promise((resolve, reject) => {
             //上传对象
             obsClient.putObject({
-                Bucket: 'fby-hw079058881',//桶名称
+                Bucket: 'ylrz-obs2024',//桶名称
                 Key: key,//文件名
                 Body: file,
                 ProgressCallback: callback,//进度回调

+ 52 - 28
src/views/course/videoResource/index.vue

@@ -117,7 +117,7 @@
       <el-table-column label="关联题目" align="center" width="150">
         <template slot-scope="scope">
           <a
-            @click="handleViewProject(scope.row)"
+            @click="handleViewProject(scope.row, 3)"
             :style="scope.row.projectIds ? {
               backgroundColor: '#409EFF',
               color: 'white',
@@ -132,7 +132,7 @@
               backgroundColor: 'rgb(154 156 159)',
               color: 'white',
               border: 'none',
-              cursor: 'not-allowed',
+              cursor: 'pointer',
               borderRadius: '4px',
               padding: '4px 12px',
               fontSize: '12px',
@@ -183,7 +183,7 @@
           <el-input v-model="form.resourceName" placeholder="请输入" />
         </el-form-item>
 
-        <el-form-item label="文件名称" prop="fileName" style="margin-top: 20px">
+        <el-form-item label="文件名称" prop="fileName" style="margin-top: 20px;display: none">
           <el-input v-model="form.fileName" placeholder="请输入" />
         </el-form-item>
 
@@ -325,8 +325,7 @@
         <el-table-column label="关联项目" align="center" min-width="100">
           <template slot-scope="scope">
           <a
-            :diabled="scope.row.progress < 100"
-            @click="handleViewProject(scope.row)"
+            @click="handleViewProject(scope.row, 4)"
             :style="scope.row.projectIds.length > 0 ? {
               backgroundColor: '#409EFF',
               color: 'white',
@@ -341,7 +340,7 @@
               backgroundColor: 'rgb(154 156 159)',
               color: 'white',
               border: 'none',
-              cursor: 'not-allowed',
+              cursor: 'pointer',
               borderRadius: '4px',
               padding: '4px 12px',
               fontSize: '12px',
@@ -423,7 +422,7 @@
             </el-select>
           </el-form-item>
 
-          <el-form-item label="关联题目" prop="projectIds">
+          <el-form-item label="关联题目" prop="projectIds" style="display: none">
             <el-select
               ref="customSelect"
               class="custom-select-class"
@@ -464,7 +463,7 @@
             <el-input v-model="batchEditDialog.form.resourceName" placeholder="请输入" />
           </el-form-item>
 
-          <el-form-item label="文件名称" prop="fileName" style="margin-top: 20px">
+          <el-form-item label="文件名称" prop="fileName" style="margin-top: 20px;display: none">
             <el-input v-model="batchEditDialog.form.fileName" placeholder="请输入" />
           </el-form-item>
 
@@ -726,10 +725,6 @@ export default {
       batchAddVisible: false,
       batchLoading: false,
       videoList: [],
-      batchForm: {
-        resourceName: null,
-        typeId: null
-      },
 
       // 批量上传相关
       showUpload: false,
@@ -772,7 +767,7 @@ export default {
             { required: true, message: "文件名称不能为空", trigger: "blur" }
           ]
         },
-      }
+      },
     }
   },
   watch: {
@@ -887,9 +882,9 @@ export default {
       const id = row.id
 
       // 获取数据并设置表单
-      getVideoResource(id).then(response => {
+      getVideoResource(id).then(async response => {
         this.form = response.data;
-        this.changeCateType(this.form.typeId)
+        await this.changeCateType(this.form.typeId)
 
         // 处理projectIds,确保是数组格式
         if (this.form.projectIds && typeof this.form.projectIds === 'string') {
@@ -901,7 +896,7 @@ export default {
         // 如果存在关联项目,获取项目详情用于回显
         if (this.form.projectIds && this.form.projectIds.length > 0) {
           // 加载项目列表信息用于回显
-          getByIds({ids: this.form.projectIds.join(',')}).then(reponse => {
+          await getByIds({ids: this.form.projectIds.join(',')}).then(reponse => {
             this.projectShowList = reponse.data
           });
         }
@@ -977,12 +972,12 @@ export default {
         this.rootTypeList = response.data
       });
     },
-    changeCateType(val) {
+    async changeCateType(val) {
       if (!val) {
         this.subTypeList = []
         return
       }
-      getCateListByPid(val).then(response => {
+      await getCateListByPid(val).then(response => {
         this.subTypeList = response.data
       })
     },
@@ -1034,7 +1029,7 @@ export default {
           onProgress(progressEvent);
         }, 1);
 
-        let line_1 = `https://blytcpv.ylrzcloud.com${data.urlPath}`;
+        let line_1 = `https://rttcpv.ylrzcloud.com${data.urlPath}`;
 
         form.fileKey = data.urlPath.substring(1);
         form.videoUrl = line_1;
@@ -1058,7 +1053,7 @@ export default {
           onProgress(progressEvent);
         }, 1);
 
-        form.line2 = `https://blyobs.ylrztop.com/${data.urlPath}`;
+        form.line2 = `https://rtobs.ylrztop.com/${data.urlPath}`;
         this.$message.success("线路二上传成功");
       } catch (error) {
         this.$message.error("线路二上传失败");
@@ -1101,13 +1096,13 @@ export default {
     /** 批量新增 */
     handleBatchAdd() {
       this.batchAddVisible = true;
-      this.batchForm = {
-        resourceName: null,
-        typeId: null
-      };
       this.videoList = []; // 清空之前的视频列表
     },
     cancelBeforeBatch(done, cancel) {
+      if (!this.videoList || this.videoList.length === 0) {
+        done()
+        return
+      }
       this.$confirm('关闭窗口视频需要重新上传,确定关闭吗?', '提示', {
         confirmButtonText: '确定',
         cancelButtonText: '取消',
@@ -1120,6 +1115,10 @@ export default {
     },
     /** 取消批量 */
     cancelBatch() {
+      if (!this.videoList || this.videoList.length === 0) {
+        this.batchAddVisible = false
+        return
+      }
       this.$confirm('关闭窗口视频需要重新上传,确定关闭吗?', '提示', {
         confirmButtonText: '确定',
         cancelButtonText: '取消',
@@ -1332,7 +1331,9 @@ export default {
     /** 打开项目选择弹窗 */
     openProjectDialog(projectIds, type) {
       this.$nextTick(() => {
-        this.$refs.customSelect.blur();
+        if (this.$refs.customSelect) {
+          this.$refs.customSelect.blur();
+        }
       });
       // 重置查询参数
       this.projectQueryParams = {
@@ -1372,12 +1373,34 @@ export default {
       // 更新表单中的项目ID
       if (this.selectedType === 0) {
         this.form.projectIds = this.selectedProjectIds;
-      } else if (this.selectedType === 1) {
+      }
+
+      else if (this.selectedType === 1) {
         this.batchUploadForm.projectIds = this.selectedProjectIds;
-      } else if (this.selectedType === 2) {
+      }
+
+      else if (this.selectedType === 2) {
         this.batchEditDialog.form.projectIds = this.selectedProjectIds;
       }
 
+      else if (this.selectedType === 3) {
+        const params = {
+          id: this.currentRow.id,
+          projectIds: this.selectedProjectIds.join(",")
+        }
+        updateVideoResource(params).then(response => {
+          if (response.code === 200) {
+            this.msgSuccess("修改成功");
+            this.open = false;
+            this.getList();
+          }
+        });
+      }
+
+      else if (this.selectedType === 4) {
+        this.currentRow.projectIds = this.selectedProjectIds
+      }
+
       this.projectDialogVisible = false;
     },
 
@@ -1413,7 +1436,7 @@ export default {
     },
 
     /** 处理查看项目 */
-    handleViewProject(row) {
+    handleViewProject(row, type) {
       // 保存当前选择的行,以便后续操作
       this.currentRow = row;
 
@@ -1421,6 +1444,7 @@ export default {
       this.projectShowList = [];
 
       if (!row.projectIds || row.projectIds.length === 0) {
+        this.openProjectDialog(null, type)
         return;
       }