From 1ebaa957950091621bf29227579243e9a4134c5c Mon Sep 17 00:00:00 2001 From: xiangpei <xiangpei@timesnew.cn> Date: 星期二, 03 十二月 2024 10:39:36 +0800 Subject: [PATCH] 在线学习文件非必穿、支持flv格式 --- src/components/UploadC.vue | 15 ++++++++------- src/views/onlineStudy/file.vue | 17 +++++++++-------- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/src/components/UploadC.vue b/src/components/UploadC.vue index 173c70b..78bf9c8 100644 --- a/src/components/UploadC.vue +++ b/src/components/UploadC.vue @@ -4,10 +4,10 @@ :file-list="fileUrl" :on-remove="handleRemove" :before-remove="beforeRemove" :on-success="handleUploadSuccess" :before-upload="beforeUpload"> <el-button size="small" type="primary">鐐瑰嚮涓婁紶</el-button> - <div slot="tip" class="el-upload__tip">鍙兘涓婁紶pdf銆乵p4銆乤vi銆乸ng銆乯pg銆乯pge鏂囦欢锛屼笖涓嶈秴杩噞{ fileSizeLimitM }}M</div> + <div slot="tip" class="el-upload__tip">鍙兘涓婁紶pdf銆乵p4銆乤vi銆乸ng銆乯pg銆乯pge銆乫lv鏂囦欢锛屼笖涓嶈秴杩噞{ fileSizeLimitM }}G</div> <div v-if="fileUrl && fileUrl.length > 0 && uploadNum === 1"> - <video controls class="returnShow" v-if="fileType === 'video'" :src="'/api/files/' + fileUrl[0].url"></video> - <img class="returnShow" v-if="fileType === 'img'" :src="'/api/files/' + fileUrl[0].url" /> + <video controls class="returnShow" v-if="fileType === 'video' && fileUrl[0]" :src="'/api/files/' + fileUrl[0].url"></video> + <img class="returnShow" v-if="fileType === 'img' && fileUrl[0]" :src="'/api/files/' + fileUrl[0].url" /> </div> </el-upload> </div> @@ -42,7 +42,7 @@ return { uploadUrl: "/api/upload/upload", fileTypeList: { - 'video': ['mp4', 'avi'], + 'video': ['mp4', 'avi', 'flv'], 'img': ['jpg', 'png', 'jpeg'], 'pdf': ['pdf'], 'file': ['doc', 'docx', 'xls', 'xlsx', 'ppt', 'pptx', 'txt', 'png', 'jpg', 'jpeg', 'pdf'], @@ -63,6 +63,7 @@ }, handleUploadSuccess(res, file) { this.fileUrl.push(res.response); + console.log("褰撳墠鏂囦欢淇℃伅") this.$emit('getUploadUrl', this.fileUrl); }, beforeUpload(file) { @@ -71,7 +72,7 @@ let limitType = true; if (typeList) { const tempType = typeList.find(item => { - if (type.includes(item)) { + if (type.includes(item) || file.name.endsWith(".flv")) { return true; } else { return false; @@ -82,9 +83,9 @@ limitType = false; } } - const limit = file.size / 1024 / 1024 < this.fileSizeLimitM; + const limit = file.size / 1024 / 1024 / 1024 < this.fileSizeLimitM; if (!limit) { - this.$message.error(`涓婁紶鏂囦欢澶у皬涓嶈兘瓒呰繃 ${this.fileSizeLimitM}MB!`); + this.$message.error(`涓婁紶鏂囦欢澶у皬涓嶈兘瓒呰繃 ${this.fileSizeLimitM}G!`); } return limitType && limit; }, diff --git a/src/views/onlineStudy/file.vue b/src/views/onlineStudy/file.vue index c8bb0b5..89ba1bd 100644 --- a/src/views/onlineStudy/file.vue +++ b/src/views/onlineStudy/file.vue @@ -32,7 +32,7 @@ <el-table-column prop="contentType" :formatter="typeFormatter" label="鏂囦欢绫诲瀷"> </el-table-column> <el-table-column label="鏂囦欢鍐呭" width="240"> - <template slot-scope="scope"> + <template slot-scope="scope" v-if="scope.row.contentUrl"> <video controls v-if="scope.row.contentType === 'video'" :src="'/api/files/' + scope.row.contentUrl.url" class="showContent" /> <el-image v-if="scope.row.contentType === 'img'" :src="'/api/files/' + scope.row.contentUrl.url" @@ -84,11 +84,11 @@ </el-select> </el-form-item> <el-form-item label="涓婁紶鏂囦欢(涓�涓�)" prop="contentUrl"> - <upload v-show="form.contentType" ref="upload" :fileUrl="form.contentUrl" :fileType="form.contentType" - :fileSizeLimitM="1024" :uploadNum="1" @getUploadUrl="getUploadUrl" @removeFile="removeFile" /> + <upload v-if="form.contentType" ref="upload" :fileUrl="form.contentUrl" :fileType="form.contentType" + :fileSizeLimitM="10" :uploadNum="1" @getUploadUrl="getUploadUrl" @removeFile="removeFile" /> </el-form-item> <el-form-item label="闄勪欢(鏈�澶�3涓�)" prop="attachment"> - <upload :fileSizeLimitM="1024" :uploadNum="3" :fileUrl="form.attachment" + <upload :fileSizeLimitM="10" :uploadNum="3" :fileUrl="form.attachment" @getUploadUrl="getUploadAttachmentUrl" @removeFile="removeAttachmentFile" /> </el-form-item> </el-form> @@ -143,9 +143,9 @@ temp: [] }, rules: { - contentUrl: [ - { required: true, message: '璇蜂笂浼犳枃浠�', trigger: 'blur' }, - ], + // contentUrl: [ + // { required: true, message: '璇蜂笂浼犳枃浠�', trigger: 'blur' }, + // ], subject: [ { required: true, message: '璇疯緭鍏ヤ富棰樺唴瀹�', trigger: 'blur' }, ], @@ -200,6 +200,7 @@ this.form.attachment = uploadData; }, getUploadUrl(uploadData) { + console.log("鏀跺埌锛�", uploadData) this.form.contentUrl = uploadData; }, remove(id) { @@ -280,7 +281,7 @@ handleUpdate(row) { this.form.id = row.id; this.form.contentType = row.contentType; - this.form.contentUrl = [row.contentUrl] || []; + this.form.contentUrl = row.contentUrl ? [row.contentUrl] : []; this.form.attachment = row.attachment || []; this.form.subject = row.subject; this.form.belongType = row.belongType; -- Gitblit v1.8.0