From 678d1992dea7addb4be862428a3c98169e80b16c Mon Sep 17 00:00:00 2001
From: 龚焕茏 <2842157468@qq.com>
Date: 星期五, 17 五月 2024 17:51:42 +0800
Subject: [PATCH] 新增用户选择一个部门
---
src/views/onlineStudy/file.vue | 92 ++++++++++++++++++++++++++++++++++-----------
1 files changed, 69 insertions(+), 23 deletions(-)
diff --git a/src/views/onlineStudy/file.vue b/src/views/onlineStudy/file.vue
index a393cc3..d2dd6a2 100644
--- a/src/views/onlineStudy/file.vue
+++ b/src/views/onlineStudy/file.vue
@@ -31,19 +31,21 @@
</el-table-column>
<el-table-column prop="contentType" :formatter="typeFormatter" label="鏂囦欢绫诲瀷">
</el-table-column>
- <el-table-column label="鏂囦欢鍐呭">
+ <el-table-column label="鏂囦欢鍐呭" width="240">
<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-image v-if="scope.row.contentType === 'img'" :src="'/api/files/' + scope.row.contentUrl.url"
+ class="showContent"></el-image>
+ <!-- <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'" class="showContent"
+ @click="checkPdf('/api/files/' + scope.row.contentUrl.url)">鐐瑰嚮鏌ョ湅</el-link>
</template>
</el-table-column>
<el-table-column prop="attachment" label="闄勪欢">
<template slot-scope="scope">
- <el-link type="primary" v-for="item in scope.row.attachment">{{ item.name }}</el-link>
+ <el-link type="primary" :href="'/api/upload/download?url=' + item.url +'&fileName=' + item.name" v-for="item in scope.row.attachment" :key="item.url">{{ item.name }}</el-link>
</template>
</el-table-column>
<el-table-column fixed="right" label="鎿嶄綔" width="140">
@@ -61,7 +63,7 @@
<pagination v-show="total > 0" :total="total" :page.sync="searchForm.pageNum" :limit.sync="searchForm.pageSize"
@pagination="page" />
- <el-dialog title="娣诲姞瀛︿範鍐呭" :visible.sync="open" width="600px" :close-on-click-modal="false"
+ <el-dialog :title="dialogTitle" :visible.sync="open" width="600px" :close-on-click-modal="false"
:before-close="handleClose">
<el-form label-position="left" label-width="120px" ref="form" :rules="rules" :model="form">
<el-form-item label="涓婚" prop="subject">
@@ -74,7 +76,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>
@@ -94,6 +96,10 @@
<el-button type="primary" @click="handlerSubmit">淇� 瀛�</el-button>
</span>
</el-dialog>
+
+ <el-dialog title="PDF鏌ョ湅" :visible.sync="pdfDialog" width="80%" :before-close="closePdfDialog">
+ <vue-office-pdf :src="pdf" @rendered="rendered" />
+ </el-dialog>
</div>
</template>
@@ -102,9 +108,11 @@
import OnlineStudyAPI from '@/api/online-study';
import StudyTypeAPI from '@/api/study-type';
import Upload from '@/components/UploadC';
+
+import VueOfficePdf from '@vue-office/pdf';
export default {
name: 'type',
- components: { Upload, Pagination },
+ components: { Upload, Pagination, VueOfficePdf },
computed: {
fileContentUrl: () => {
return this.form ? this.form.contentUrl ? [this.form.contentUrl] : [] : [];
@@ -112,18 +120,24 @@
},
data() {
return {
+ pdf: '',
+ dialogTitle: '娣诲姞瀛︿範鍐呭',
ids: [],
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: []
},
@@ -144,6 +158,19 @@
};
},
methods: {
+ checkPdf(url) {
+ this.pdf = url;
+ this.pdfDialog = true;
+ },
+ closePdfDialog() {
+ this.pdfDialog = false;
+ },
+ rendered() {
+
+ },
+ fileChange() {
+ this.form.contentUrl = [];
+ },
handleSelectionChange(val) {
this.ids = val.map(item => item.id);
},
@@ -159,21 +186,20 @@
}
},
clearFile() {
- this.form.contentUrl = null;
+ this.form.contentUrl = [];
this.$refs.upload.clearFile();
},
removeFile() {
- this.form.contentUrl = null;
+ this.form.contentUrl = [];
},
removeAttachmentFile(fileList, fileName) {
- console.log(fileList, fileName, "dddddddd");
this.form.attachment = fileList.filter(item => item.name !== fileName);
},
getUploadAttachmentUrl(uploadData) {
this.form.attachment = uploadData;
},
getUploadUrl(uploadData) {
- this.form.contentUrl = uploadData[0];
+ this.form.contentUrl = uploadData;
},
remove(id) {
OnlineStudyAPI.remove([id]).then(res => {
@@ -199,8 +225,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;
@@ -208,7 +237,7 @@
}
});
} else {
- OnlineStudyAPI.add(this.form).then(res => {
+ OnlineStudyAPI.add(temp).then(res => {
if (res.code === 1) {
this.$message.success('娣诲姞鎴愬姛');
this.open = false;
@@ -219,13 +248,24 @@
}
});
},
+ 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 = '娣诲姞瀛︿範鍐呭';
},
page() {
OnlineStudyAPI.page(this.searchForm).then(res => {
@@ -242,7 +282,7 @@
this.form.attachment = row.attachment || [];
this.form.subject = row.subject;
this.form.belongType = row.belongType;
- console.log(row, "dfddddddd");
+ this.dialogTitle = '淇敼瀛︿範鍐呭';
this.open = true;
}
},
@@ -259,8 +299,9 @@
<style scoped>
.showContent {
- width: 200px;
- height: 100px;
+ width: 100%;
+ min-height: 80px;
+ object-fit: contain;
}
.warp {
@@ -270,4 +311,9 @@
.search {
margin-top: 10px;
}
+::v-deep .el-image__error {
+ position: absolute;
+ top: 0;
+ bottom: 0;
+}
</style>
--
Gitblit v1.8.0