Explorar o código

feat:1、文件资源支持ppt、pptx格式文件的上传2、内容发布支持ppt文件的下发3、详情、审核多个页面支持ppt文件点击下载

lihao16 hai 3 meses
pai
achega
b671fdac81

+ 1 - 1
smsb-modules/smsb-source/src/main/java/com/inspur/source/domain/SmsbMinioData.java

@@ -54,7 +54,7 @@ public class SmsbMinioData extends TenantEntity {
     private Integer delFlag;
 
     /**
-     * 类型 1图片 ,2视频 3音频
+     * 类型 1图片 ,2视频 3音频 4ppt
      */
     private Integer type;
 

+ 17 - 2
smsb-modules/smsb-source/src/main/java/com/inspur/source/service/impl/SmsbMinioDataServiceImpl.java

@@ -91,6 +91,9 @@ public class SmsbMinioDataServiceImpl implements ISmsbMinioDataService {
     @Value("${server.minio.bucket}")
     private String minioServerBucket;
 
+    private static final String PPT_SUFFIX = ".ppt";
+    private static final String PPTX_SUFFIX = ".pptx";
+
     // 计算目标分辨率(高或宽压缩至480,保持比例)
     private static String calculateResolution(int width, int height) {
         String scaleFilter;
@@ -229,9 +232,10 @@ public class SmsbMinioDataServiceImpl implements ISmsbMinioDataService {
             case ".jpg", ".jpeg", ".png" -> 1;
             case ".mp4", ".avi" -> 2;
             case ".mp3", ".wav" -> 3;
+            case ".ppt", ".pptx" -> 4;
             default -> 3;
         };
-        smsbMinioDataBo.setType(boType); // 1图片 2视频 3音频
+        smsbMinioDataBo.setType(boType); // 1图片 2视频 3音频 4ppt
         smsbMinioDataBo.setTransState(0); // 待转码
         smsbMinioDataBo.setCreateUser(LoginHelper.getLoginUser().getNickname());
         return smsbMinioDataBo;
@@ -697,6 +701,10 @@ public class SmsbMinioDataServiceImpl implements ISmsbMinioDataService {
     }
 
     private SmsbMinioTransRecord createTransRecord(SmsbMinioData add) {
+        // 只对图片和视频进行转码
+        if (add.getType() != 1 && add.getType() != 2) {
+            return null;
+        }
         SmsbMinioTransRecord transRecord = new SmsbMinioTransRecord();
         transRecord.setCreateUser(LoginHelper.getUsername());
         transRecord.setFileId(add.getId());
@@ -1016,7 +1024,14 @@ public class SmsbMinioDataServiceImpl implements ISmsbMinioDataService {
         // 视频码率
         Integer codeRate = 0;
         // 文件类型
-        Integer fileType = isImage(file) ? 1 : 2;
+        Integer fileType = 0;
+
+        if (oss.getFileSuffix().endsWith(PPT_SUFFIX) || oss.getFileSuffix().endsWith(PPTX_SUFFIX)) {
+            fileType = 4;
+        }else {
+            fileType = isImage(file) ? 1 : 2;
+        }
+
         oss.setFileType(fileType);
         if (fileType == 1) {
             resolution = getImageResolution(file);

+ 3 - 2
smsb-plus-ui/src/components/SmsbFileUpload/SmsbFileUploader.vue

@@ -9,7 +9,7 @@
         <br />
         <el-button type="primary" class="select-button"> 点击选择文件 </el-button>
         <div class="file-restrictions">
-          支持文件类型: 图片(jpg/jpeg, png), 视频(mp4, avi)
+          支持文件类型: 图片(jpg/jpeg, png), 视频(mp4, avi), 文档(ppt,pptx)
         </div>
       </div>
     </el-upload>
@@ -78,7 +78,8 @@ import {uploadChunk} from '@/api/smsb/source/minioData';
 const ALLOWED_EXTENSIONS = {
   image: ['jpg', 'jpeg', 'png'],
   // audio: ['mp3', 'wav', 'ogg', 'aac', 'flac'],
-  video: ['mp4', 'avi']
+  video: ['mp4', 'avi'],
+  file: ['ppt', 'pptx']
 };
 
 // 检查文件类型是否允许

+ 40 - 2
smsb-plus-ui/src/views/smsb/itemPush/approval.vue

@@ -106,7 +106,21 @@
             <el-table-column label="大小" align="center" prop="size" width="80"/>
             <el-table-column label="截图" align="center" prop="screenshot" width="80">
               <template #default="scope">
-                <image-preview :src="scope.row.screenshot" style="width: 40px; height: 40px; cursor: pointer" />
+                <div v-if="scope.row.type === 1">
+                  <!-- 图片类型 -->
+                  <image-preview :src="scope.row.screenshot" style="width: 40px; height: 40px; cursor: pointer" />
+                </div>
+                <div v-else-if="scope.row.type === 2">
+                  <el-icon class="VideoPlay" @click="viewVideo(scope.row.screenshot)" size="40" style="cursor: pointer">
+                    <VideoPlay />
+                  </el-icon>
+                </div>
+                <div v-else-if="scope.row.type === 4">
+                  <!-- PPT类型 -->
+                  <el-icon :size="40" @click="downloadFile(scope.row.fileUrl)" style="cursor: pointer;">
+                    <Document />
+                  </el-icon>
+                </div>
               </template>
             </el-table-column>
           </el-table>
@@ -117,6 +131,10 @@
     <SubmitVerifySmsb ref="submitVerifyRef" :task-variables="taskVariables" @submit-callback="submitCallback" />
     <!-- 审批记录 -->
     <approvalRecordSmsb ref="approvalRecordRef" />
+    <!-- 用于展示播放的视频 -->
+    <el-dialog v-model="videoDialogVisible" append-to-body>
+      <video width="100%" controls :src="videoUrl"></video>
+    </el-dialog>
   </div>
 </template>
 
@@ -150,7 +168,8 @@ const itemPushBase = ref<ItemPushVO>();
 const deviceList = ref<DeviceVO[]>([]);
 const sourceList = ref<MinioDataVO[]>([]);
 const timeList = ref<ItemPushTimeRangeVO[]>([]);
-
+const videoUrl = ref('');
+const videoDialogVisible = ref(false);
 //提交组件
 const submitVerifyRef = ref<InstanceType<typeof SubmitVerifySmsb>>();
 //审批记录组件
@@ -248,7 +267,26 @@ const submitForm = (status: string) => {
     goBack();
   }
 };
+const viewVideo = (url: string) => {
+  videoUrl.value = url;
+  videoDialogVisible.value = true;
+};
+const downloadFile = (fileUrl) => {
+  if (fileUrl) {
+    // 创建一个隐藏的a标签来触发下载
+    const link = document.createElement('a');
+    link.href = fileUrl;
+    link.download = ''; // 浏览器会自动使用URL中的文件名
+    link.target = '_blank';
+    link.style.display = 'none';
 
+    document.body.appendChild(link);
+    link.click();
+    document.body.removeChild(link);
+  } else {
+    proxy?.$modal.msgError('文件地址不存在,无法下载');
+  }
+};
 //提交申请
 const handleStartWorkFlow = async (data: LeaveVO) => {
   try {

+ 28 - 0
smsb-plus-ui/src/views/smsb/itemPush/index.vue

@@ -242,6 +242,12 @@
                       <VideoPlay />
                     </el-icon>
                   </div>
+                  <div v-else-if="scope.row.type === 4">
+                    <!-- PPT类型 -->
+                    <el-icon :size="40" @click="downloadFile(scope.row.fileUrl)" style="cursor: pointer;">
+                      <Document />
+                    </el-icon>
+                  </div>
                 </template>
               </el-table-column>
             </el-table>
@@ -292,6 +298,12 @@
                     <VideoPlay />
                   </el-icon>
                 </div>
+                <div v-else-if="scope.row.fileType === 4">
+                  <!-- PPT类型 -->
+                  <el-icon :size="40" @click="downloadFile(scope.row.fileUrl)" style="cursor: pointer;">
+                    <Document />
+                  </el-icon>
+                </div>
               </template>
             </el-table-column>
           </el-table>
@@ -501,6 +513,22 @@ const viewVideo = (url: string) => {
   videoUrl.value = url;
   videoDialogVisible.value = true;
 };
+const downloadFile = (fileUrl) => {
+  if (fileUrl) {
+    // 创建一个隐藏的a标签来触发下载
+    const link = document.createElement('a');
+    link.href = fileUrl;
+    link.download = ''; // 浏览器会自动使用URL中的文件名
+    link.target = '_blank';
+    link.style.display = 'none';
+
+    document.body.appendChild(link);
+    link.click();
+    document.body.removeChild(link);
+  } else {
+    proxy?.$modal.msgError('文件地址不存在,无法下载');
+  }
+};
 const addTimePeriod = () => {
   const now = new Date();
   now.setHours(0, 0, 0, 0);

+ 41 - 1
smsb-plus-ui/src/views/smsb/itemPush/review.vue

@@ -85,7 +85,21 @@
             <el-table-column label="大小" align="center" prop="size" />
             <el-table-column label="截图" align="center" prop="screenshot">
               <template #default="scope">
-                <image-preview :src="scope.row.screenshot" style="width: 40px; height: 40px; cursor: pointer" />
+                <div v-if="scope.row.type === 1">
+                  <!-- 图片类型 -->
+                  <image-preview :src="scope.row.screenshot" style="width: 40px; height: 40px; cursor: pointer" />
+                </div>
+                <div v-else-if="scope.row.type === 2">
+                  <el-icon class="VideoPlay" @click="viewVideo(scope.row.screenshot)" size="40" style="cursor: pointer">
+                    <VideoPlay />
+                  </el-icon>
+                </div>
+                <div v-else-if="scope.row.type === 4">
+                  <!-- PPT类型 -->
+                  <el-icon :size="40" @click="downloadFile(scope.row.fileUrl)" style="cursor: pointer;">
+                    <Document />
+                  </el-icon>
+                </div>
               </template>
             </el-table-column>
           </el-table>
@@ -96,6 +110,11 @@
     <SubmitVerifySmsb ref="submitVerifyRef" :task-variables="taskVariables" @submit-callback="submitCallback" />
     <!-- 审批记录 -->
     <approvalRecordSmsb ref="approvalRecordRef" />
+
+    <!-- 用于展示播放的视频 -->
+    <el-dialog v-model="videoDialogVisible" append-to-body>
+      <video width="100%" controls :src="videoUrl"></video>
+    </el-dialog>
   </div>
 </template>
 
@@ -130,6 +149,8 @@ const itemPushBase = ref<ItemPushVO>();
 const deviceList = ref<DeviceVO[]>([]);
 const sourceList = ref<MinioDataVO[]>([]);
 const timeList = ref<ItemPushTimeRangeVO[]>([]);
+const videoUrl = ref('');
+const videoDialogVisible = ref(false);
 
 //提交组件
 const submitVerifyRef = ref<InstanceType<typeof SubmitVerifySmsb>>();
@@ -200,7 +221,26 @@ const getInfo = () => {
     }
   });
 };
+const viewVideo = (url: string) => {
+  videoUrl.value = url;
+  videoDialogVisible.value = true;
+};
+const downloadFile = (fileUrl) => {
+  if (fileUrl) {
+    // 创建一个隐藏的a标签来触发下载
+    const link = document.createElement('a');
+    link.href = fileUrl;
+    link.download = ''; // 浏览器会自动使用URL中的文件名
+    link.target = '_blank';
+    link.style.display = 'none';
 
+    document.body.appendChild(link);
+    link.click();
+    document.body.removeChild(link);
+  } else {
+    proxy?.$modal.msgError('文件地址不存在,无法下载');
+  }
+};
 /** 提交按钮 */
 const submitForm = (status: string) => {
   if (leaveTime.value.length === 0) {

+ 21 - 2
smsb-plus-ui/src/views/smsb/minioData/index.vue

@@ -113,12 +113,16 @@
               </div>
               <div v-else-if="scope.row.type === 2">
                 <!-- 视频类型 -->
-                <!-- <image-preview :src="scope.row.screenshot" style="width: 40px; height: 40px; cursor: pointer" -->
-                <!-- @click="viewVideo(scope.row.url)" /> -->
                 <el-icon class="VideoPlay" @click="viewVideo(scope.row.screenshot)" size="40" style="cursor: pointer">
                   <VideoPlay />
                 </el-icon>
               </div>
+              <div v-else-if="scope.row.type === 4">
+                <!-- PPT类型 -->
+                <el-icon :size="40" @click="downloadFile(scope.row.fileUrl)" style="cursor: pointer;">
+                  <Document />
+                </el-icon>
+              </div>
             </template>
           </el-table-column>
           <el-table-column label="转码" align="center" prop="transState" width="80" :show-overflow-tooltip="true">
@@ -520,7 +524,22 @@ const submitForm = () => {
     }
   });
 };
+const downloadFile = (fileUrl) => {
+  if (fileUrl) {
+    // 创建一个隐藏的a标签来触发下载
+    const link = document.createElement('a');
+    link.href = fileUrl;
+    link.download = ''; // 浏览器会自动使用URL中的文件名
+    link.target = '_blank';
+    link.style.display = 'none';
 
+    document.body.appendChild(link);
+    link.click();
+    document.body.removeChild(link);
+  } else {
+    proxy?.$modal.msgError('文件地址不存在,无法下载');
+  }
+};
 /** 删除按钮操作 */
 const handleDelete = async (row?: MinioDataVO) => {
   const _ids = row?.id || ids.value;