From b60049c4fd341d6a0d109408aa998e02528fc6d6 Mon Sep 17 00:00:00 2001 From: xiangpei <xiangpei@timesnew.cn> Date: 星期五, 17 五月 2024 14:49:48 +0800 Subject: [PATCH] pdf --- src/views/onlineStudy/file.vue | 48 +++++++++++++++++++++++++++++++++++++----------- 1 files changed, 37 insertions(+), 11 deletions(-) diff --git a/src/views/onlineStudy/file.vue b/src/views/onlineStudy/file.vue index 69fc203..609f826 100644 --- a/src/views/onlineStudy/file.vue +++ b/src/views/onlineStudy/file.vue @@ -33,12 +33,12 @@ </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" /> - <el-link type="primary" v-if="scope.row.contentType === 'pdf'" :src="'/api/files/' + scope.row.contentUrl.url" - class="showContent">鐐瑰嚮鏌ョ湅</el-link> + <el-link type="primary" v-if="scope.row.contentType === 'pdf'" + class="showContent" @click="checkPdf('/api/files/' + scope.row.contentUrl.url)">鐐瑰嚮鏌ョ湅</el-link> </template> </el-table-column> <el-table-column prop="attachment" label="闄勪欢"> @@ -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> @@ -102,6 +102,7 @@ import OnlineStudyAPI from '@/api/online-study'; import StudyTypeAPI from '@/api/study-type'; import Upload from '@/components/UploadC'; + export default { name: 'type', components: { Upload, Pagination }, @@ -117,14 +118,17 @@ typeList: [], searchForm: { pageNum: 1, - pageSize: 10, + pageSize: 5, typeName: '' }, total: 0, tableData: [], open: false, + pdfDialog: false, form: { contentType: 'video', + subject: '', + belongType: 2, contentUrl: [], attachment: [], temp: [] @@ -146,6 +150,15 @@ }; }, methods: { + checkPdf(url) { + window.open('/#/online/study/pdf/view?pdfUrl=' + url, '_blank') + }, + closePdfDialog() { + this.pdfDialog = false; + }, + fileChange() { + this.form.contentUrl = []; + }, handleSelectionChange(val) { this.ids = val.map(item => item.id); }, @@ -174,7 +187,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 +213,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 +225,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 +236,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