From 1aec2bdf5d71df8e120b3ead4b104fb3438f4713 Mon Sep 17 00:00:00 2001
From: xiangpei <xiangpei@timesnew.cn>
Date: 星期四, 30 五月 2024 11:20:20 +0800
Subject: [PATCH] 编辑试卷时选择部门出现对应的课目
---
src/views/onlineStudy/file.vue | 305 +++++++++++++++++++++++++++-----------------------
1 files changed, 165 insertions(+), 140 deletions(-)
diff --git a/src/views/onlineStudy/file.vue b/src/views/onlineStudy/file.vue
index 14945bb..bb7a417 100644
--- a/src/views/onlineStudy/file.vue
+++ b/src/views/onlineStudy/file.vue
@@ -7,11 +7,7 @@
</el-form-item>
<el-form-item label="瀛︿範绫诲瀷">
<el-select v-model="searchForm.belongType" clearable @clear="page" @change="page" placeholder="瀛︿範绫诲瀷">
- <el-option
- v-for="type in typeList"
- :key="type.id"
- :label="type.typeName"
- :value="type.id">
+ <el-option v-for="item in typeList" :key="item.id" :label="item.typeName" :value="item.id">
</el-option>
</el-select>
</el-form-item>
@@ -24,69 +20,51 @@
<el-button type="danger" @click="batchRemove" size="small" style="margin-left: 5px">鍒犻櫎</el-button>
</div>
</div>
- <el-table
- :data="tableData"
- border
- @selection-change="handleSelectionChange"
- style="width: 100%">
- <el-table-column
- type="selection"
- width="55">
- </el-table-column>
- <el-table-column
- fixed
- prop="subject"
- label="涓婚 ">
- </el-table-column>
- <el-table-column
- prop="typeName"
- label="瀛︿範绫诲瀷">
- </el-table-column>
- <el-table-column
- prop="contentType"
- :formatter="typeFormatter"
- label="鏂囦欢绫诲瀷">
- </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" 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>
- </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>
- </template>
- </el-table-column>
- <el-table-column
- fixed="right"
- label="鎿嶄綔"
- width="140">
- <template slot-scope="scope">
- <el-button @click="handleUpdate(scope.row)" type="primary" size="small" style="margin-right: 5px">淇敼</el-button>
- <el-popconfirm
- :title="getTitle(scope.row.typeName)"
- @confirm="remove(scope.row.id)"
- >
+
+ <el-table :data="tableData" border @selection-change="handleSelectionChange" style="width: 100%">
+ <el-table-column type="selection" width="55">
+ </el-table-column>
+ <el-table-column fixed prop="subject" label="涓婚 ">
+ </el-table-column>
+ <el-table-column prop="typeName" label="瀛︿範绫诲瀷">
+ </el-table-column>
+ <el-table-column prop="contentType" :formatter="typeFormatter" label="鏂囦欢绫诲瀷">
+ </el-table-column>
+ <el-table-column label="鏂囦欢鍐呭" width="240">
+ <template slot-scope="scope">
+ <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"
+ 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">
+ <div v-for="item in scope.row.attachment" :key="item.url">
+ <el-link type="primary" :href="'/api/upload/download?url=' + item.url +'&fileName=' + item.name" >{{ item.name }}</el-link>
+ </div>
+ </template>
+ </el-table-column>
+ <el-table-column fixed="right" label="鎿嶄綔" width="140">
+ <template slot-scope="scope">
+ <el-button @click="handleUpdate(scope.row)" type="primary" size="small"
+ style="margin-right: 5px">淇敼</el-button>
+ <el-popconfirm :title="getTitle(scope.row.typeName)" @confirm="remove(scope.row.id)">
<el-button slot="reference" type="danger" size="small">鍒犻櫎</el-button>
</el-popconfirm>
</template>
</el-table-column>
</el-table>
- <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"
+ <pagination v-show="total > 0" :total="total" :page.sync="searchForm.pageNum" :limit.sync="searchForm.pageSize"
+ @pagination="page" />
+
+ <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">
@@ -94,26 +72,24 @@
</el-form-item>
<el-form-item label="瀛︿範绫诲瀷" prop="belongType">
<el-select v-model="form.belongType" placeholder="瀛︿範绫诲瀷">
- <el-option
- v-for="type in typeList"
- :key="type.id"
- :label="type.typeName"
- :value="type.id">
+ <el-option v-for="item in typeList" :key="item.id" :label="item.typeName" :value="item.id">
</el-option>
</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>
</el-select>
</el-form-item>
<el-form-item label="涓婁紶鏂囦欢(涓�涓�)" prop="contentUrl">
- <upload v-show="form.contentType" ref="upload" :fileUrl="fileContentUrl" :fileType="form.contentType" :fileSizeLimitM="1024" :uploadNum="1" @getUploadUrl="getUploadUrl" @removeFile="removeFile"/>
+ <upload v-show="form.contentType" ref="upload" :fileUrl="form.contentUrl" :fileType="form.contentType"
+ :fileSizeLimitM="1024" :uploadNum="1" @getUploadUrl="getUploadUrl" @removeFile="removeFile" />
</el-form-item>
<el-form-item label="闄勪欢(鏈�澶�3涓�)" prop="attachment">
- <upload :fileSizeLimitM="1024" :uploadNum="3" :fileUrl="form.attachment" @getUploadUrl="getUploadAttachmentUrl" @removeFile="removeAttachmentFile"/>
+ <upload :fileSizeLimitM="1024" :uploadNum="3" :fileUrl="form.attachment"
+ @getUploadUrl="getUploadAttachmentUrl" @removeFile="removeAttachmentFile" />
</el-form-item>
</el-form>
<span slot="footer" class="dialog-footer">
@@ -121,36 +97,50 @@
<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>
<script>
-import Pagination from '@/components/Pagination'
-import OnlineStudyAPI from '@/api/online-study'
-import StudyTypeAPI from '@/api/study-type'
-import Upload from '@/components/UploadC'
+import Pagination from '@/components/Pagination';
+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: function () {
- return this.form ? this.form.contentUrl ? [this.form.contentUrl] : [] : []
+ fileContentUrl: () => {
+ return this.form ? this.form.contentUrl ? [this.form.contentUrl] : [] : [];
}
},
- data () {
+ data() {
return {
+ pdf: '',
+ dialogTitle: '娣诲姞瀛︿範鍐呭',
ids: [],
typeList: [],
searchForm: {
pageNum: 1,
- pageSize: 10,
+ pageSize: 5,
typeName: ''
},
total: 0,
tableData: [],
open: false,
+ pdfDialog: false,
form: {
- contentType: 'video'
+ contentType: 'video',
+ subject: '',
+ belongType: 2,
+ contentUrl: [],
+ attachment: [],
+ temp: []
},
rules: {
contentUrl: [
@@ -166,131 +156,166 @@
{ required: true, message: '璇烽�夋嫨鏂囦欢绫诲瀷', trigger: 'change' }
]
}
- }
+ };
},
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);
},
typeFormatter(row) {
if (row.contentType === 'video') {
- return "瑙嗛"
+ return "瑙嗛";
}
if (row.contentType === 'img') {
- return "鍥剧墖"
+ return "鍥剧墖";
}
if (row.contentType === 'pdf') {
- return "PDF"
+ return "PDF";
}
},
clearFile() {
- this.form.contentUrl = null
- this.$refs.upload.clearFile()
+ 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)
+ this.form.attachment = fileList.filter(item => item.name !== fileName);
},
- getUploadAttachmentUrl (uploadData) {
- this.form.attachment = uploadData
+ getUploadAttachmentUrl(uploadData) {
+ this.form.attachment = uploadData;
},
getUploadUrl(uploadData) {
- this.form.contentUrl = uploadData[0]
+ this.form.contentUrl = uploadData;
},
- remove (id) {
+ remove(id) {
OnlineStudyAPI.remove([id]).then(res => {
if (res.code === 1) {
- this.$message.success('鍒犻櫎鎴愬姛')
+ this.$message.success('鍒犻櫎鎴愬姛');
+ this.page()
}
- })
+ });
},
- batchRemove () {
+ batchRemove() {
if (this.ids.length < 1) {
- this.$message.warning("璇烽�夋嫨瑕佸垹闄ょ殑鏁版嵁")
+ this.$message.warning("璇烽�夋嫨瑕佸垹闄ょ殑鏁版嵁");
}
OnlineStudyAPI.remove(this.ids).then(res => {
if (res.code === 1) {
- this.$message.success('鍒犻櫎鎴愬姛')
- this.ids = []
+ this.$message.success('鍒犻櫎鎴愬姛');
+ this.ids = [];
}
- })
+ });
},
- getTitle (typeName) {
- return '纭畾瑕佸垹闄�' + typeName + '杩欎釜鏂囦欢鍚楋紵'
+ getTitle(typeName) {
+ return '纭畾瑕佸垹闄�' + typeName + '杩欎釜鏂囦欢鍚楋紵';
},
- handlerSubmit () {
+ 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
- this.page()
+ this.$message.success('淇敼鎴愬姛');
+ this.open = false;
+ this.page();
}
- })
+ });
} else {
- OnlineStudyAPI.add(this.form).then(res => {
+ OnlineStudyAPI.add(temp).then(res => {
if (res.code === 1) {
- this.$message.success('娣诲姞鎴愬姛')
- this.open = false
- this.page()
+ this.$message.success('娣诲姞鎴愬姛');
+ this.open = false;
+ this.page();
}
- })
+ });
}
}
- })
+ });
},
- handleClose () {
- this.open = false
- this.form = {}
+ resetForm() {
+ this.form = {
+ contentType: 'video',
+ subject: '',
+ belongType: 2,
+ contentUrl: [],
+ attachment: [],
+ temp: []
+ };
},
- handlerAdd () {
- this.form = {}
- this.open = true
+ handleClose() {
+ this.open = false;
+ this.resetForm();
},
- page () {
+ handlerAdd() {
+ this.resetForm();
+ this.open = true;
+ this.dialogTitle = '娣诲姞瀛︿範鍐呭';
+ },
+ page() {
OnlineStudyAPI.page(this.searchForm).then(res => {
if (res.code === 1) {
- this.tableData = res.response
- this.total = res.total
+ this.tableData = res.response;
+ this.total = res.total;
}
- })
+ });
},
- handleUpdate (row) {
- this.form.id = row.id
- this.form.contentType = row.contentType
- this.form.contentUrl = row.contentUrl
- this.form.attachment = row.attachment
- this.form.subject = row.subject
- this.form.belongType = row.belongType
- console.log(row, "dfddddddd")
- this.open = true
+ handleUpdate(row) {
+ this.form.id = row.id;
+ this.form.contentType = row.contentType;
+ this.form.contentUrl = [row.contentUrl] || [];
+ this.form.attachment = row.attachment || [];
+ this.form.subject = row.subject;
+ this.form.belongType = row.belongType;
+ this.dialogTitle = '淇敼瀛︿範鍐呭';
+ this.open = true;
}
},
- mounted () {
- this.page()
+ mounted() {
+ this.page();
StudyTypeAPI.list().then(res => {
if (res.code === 1) {
- this.typeList = res.response
+ this.typeList = res.response;
}
- })
+ });
}
-}
+};
</script>
<style scoped>
.showContent {
- width: 200px;
- height: 100px;
+ width: 100%;
+ min-height: 80px;
+ object-fit: contain;
}
+
.warp {
margin: 40px 10px;
}
+
.search {
margin-top: 10px;
}
+::v-deep .el-image__error {
+ position: absolute;
+ top: 0;
+ bottom: 0;
+}
</style>
--
Gitblit v1.8.0