From 0a9d8e014803308c2eef22ca1e83c50d4086b37d Mon Sep 17 00:00:00 2001 From: ZhangXianQiang <1135831638@qq.com> Date: 星期五, 17 五月 2024 10:47:26 +0800 Subject: [PATCH] fix:上传类型限制 --- src/views/onlineStudy/file.vue | 34 ++++++++++++++++++++++++++-------- 1 files changed, 26 insertions(+), 8 deletions(-) diff --git a/src/views/onlineStudy/file.vue b/src/views/onlineStudy/file.vue index 69fc203..668b580 100644 --- a/src/views/onlineStudy/file.vue +++ b/src/views/onlineStudy/file.vue @@ -33,7 +33,7 @@ </el-table-column> <el-table-column label="鏂囦欢鍐呭"> <template slot-scope="scope"> - <video v-if="scope.row.contentType === 'video'" :src="'/api/files/' + scope.row.contentUrl.url" + <video controls v-if="scope.row.contentType === 'video'" :src="'/api/files/' + scope.row.contentUrl.url" class="showContent" /> <img v-if="scope.row.contentType === 'img'" :src="'/api/files/' + scope.row.contentUrl.url" class="showContent" /> @@ -74,7 +74,7 @@ </el-select> </el-form-item> <el-form-item label="鏂囦欢绫诲瀷" prop="contentType"> - <el-select v-model="form.contentType" placeholder="涓嶅悓绫诲瀷鐨勬枃浠堕槄瑙堟柟寮忎笉鍚岋紝澶氫綑鏂囦欢璇蜂互闄勪欢褰㈠紡涓婁紶"> + <el-select v-model="form.contentType" placeholder="涓嶅悓绫诲瀷鐨勬枃浠堕槄瑙堟柟寮忎笉鍚岋紝澶氫綑鏂囦欢璇蜂互闄勪欢褰㈠紡涓婁紶" @change="fileChange"> <el-option label="瑙嗛" value="video"></el-option> <el-option label="PDF" value="pdf"></el-option> <el-option label="鍥剧墖" value="img"></el-option> @@ -125,6 +125,8 @@ open: false, form: { contentType: 'video', + subject: '', + belongType: 2, contentUrl: [], attachment: [], temp: [] @@ -146,6 +148,9 @@ }; }, methods: { + fileChange() { + this.form.contentUrl = []; + }, handleSelectionChange(val) { this.ids = val.map(item => item.id); }, @@ -174,7 +179,7 @@ this.form.attachment = uploadData; }, getUploadUrl(uploadData) { - this.form.contentUrl = uploadData[0]; + this.form.contentUrl = uploadData; }, remove(id) { OnlineStudyAPI.remove([id]).then(res => { @@ -200,8 +205,11 @@ handlerSubmit() { this.$refs['form'].validate((valid) => { if (valid) { - if (this.form.id) { - OnlineStudyAPI.update(this.form).then(res => { + const temp = JSON.parse(JSON.stringify(this.form)); + // this.form.contentUrl = this.form.contentUrl[0] + temp.contentUrl = temp.contentUrl[0]; + if (temp.id) { + OnlineStudyAPI.update(temp).then(res => { if (res.code === 1) { this.$message.success('淇敼鎴愬姛'); this.open = false; @@ -209,7 +217,7 @@ } }); } else { - OnlineStudyAPI.add(this.form).then(res => { + OnlineStudyAPI.add(temp).then(res => { if (res.code === 1) { this.$message.success('娣诲姞鎴愬姛'); this.open = false; @@ -220,12 +228,22 @@ } }); }, + resetForm() { + this.form = { + contentType: 'video', + subject: '', + belongType: 2, + contentUrl: [], + attachment: [], + temp: [] + } + }, handleClose() { this.open = false; - this.form = {}; + this.resetForm(); }, handlerAdd() { - this.form = {}; + this.resetForm(); this.open = true; this.dialogTitle = '娣诲姞瀛︿範鍐呭'; }, -- Gitblit v1.8.0