From 595f08770a5dca4954c4fc0225d3585504a4bbdd Mon Sep 17 00:00:00 2001 From: xiangpei <xiangpei@timesnew.cn> Date: 星期四, 11 七月 2024 09:48:15 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/dev' into dev --- src/views/exam/paper/list.vue | 4 vue.config.js | 4 src/components/UploadC.vue | 81 ++++++++------- src/views/exam/question/list.vue | 41 ++++++++ src/api/question.js | 5 src/views/education/resource/list.vue | 89 ++++++++++++++--- src/views/exam/exam/MarkPaper.vue | 39 ++++++- src/router.js | 9 + 8 files changed, 198 insertions(+), 74 deletions(-) diff --git a/src/api/question.js b/src/api/question.js index ca143bb..a8d584a 100644 --- a/src/api/question.js +++ b/src/api/question.js @@ -1,9 +1,10 @@ -import { post } from '@/utils/request' +import { post, download } from '@/utils/request' export default { pageList: query => post('/api/admin/question/page', query), edit: query => post('/api/admin/question/edit', query), select: id => post('/api/admin/question/select/' + id), deleteQuestion: id => post('/api/admin/question/delete/' + id), - updateStatus: query => post('/api/admin/question/status', query) + updateStatus: query => post('/api/admin/question/status', query), + downloadImportTemplate: () => download('/api/admin/question/download/importTemplate'), } diff --git a/src/components/UploadC.vue b/src/components/UploadC.vue index 1a2e57f..9ce5862 100644 --- a/src/components/UploadC.vue +++ b/src/components/UploadC.vue @@ -1,13 +1,14 @@ <template> <div> <el-upload :action="uploadUrl" :show-file-list="true" :limit="uploadNum" :accept="acceptList" multiple - :file-list="fileUrl" :on-remove="handleRemove" :before-remove="beforeRemove" :on-success="handleUploadSuccess" - :before-upload="beforeUpload"> + :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銆乵p3銆乵p4銆乤vi銆亀ebm銆乸ng銆乯pg銆乯pge銆乨oc銆乨ocx銆亁ls銆亁lsx銆乸pt銆乸ptx鏂囦欢锛屼笖涓嶈秴杩噞{ fileSizeLimitM }}M</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" /> + <img class="returnShow" v-if="fileType === 'img'" :src="'/api/files/' + fileUrl[0].url"/> </div> </el-upload> </div> @@ -16,7 +17,7 @@ <script> export default { - name: "UploadC", + name: 'UploadC', props: { uploadNum: { required: false, @@ -38,67 +39,73 @@ default: () => [] } }, - data() { + data () { return { - uploadUrl: "http://localhost:8000/api/upload/upload", + uploadUrl: 'http://localhost:8000/api/upload/upload', fileTypeList: { - 'video': ['mp4', 'avi'], + 'video': ['mp4', 'avi', 'webm'], 'img': ['jpg', 'png', 'jpeg'], 'pdf': ['pdf'], + 'word': ['doc', 'docx'], + 'excel': ['xlsx', 'xls'], + 'audio': ['mp3'], + 'ppt': ['ppt', 'pptx'], 'file': ['doc', 'docx', 'xls', 'xlsx', 'ppt', 'pptx', 'txt', 'png', 'jpg', 'jpeg', 'pdf'], } - }; + } }, methods: { - clearFile() { - this.fileUrl = []; + clearFile () { + this.fileUrl = [] + }, - beforeRemove(file, fileList) { - if (file && file.status === "success") { - return this.$confirm(`纭畾绉婚櫎 ${file.name}锛焋); + beforeRemove (file, fileList) { + if (file && file.status === 'success') { + return this.$confirm(`纭畾绉婚櫎 ${file.name}锛焋) } }, - handleRemove(file, fileList) { - this.$emit('removeFile', this.fileUrl, file.name); + handleRemove (file, fileList) { + this.$emit('removeFile', this.fileUrl, file.name) }, - handleUploadSuccess(res, file) { - this.fileUrl.push(res.data); - this.$emit('getUploadUrl', this.fileUrl); + handleUploadSuccess (res, file) { + this.fileUrl.push(res.data) + this.$emit('getUploadUrl', this.fileUrl) }, - beforeUpload(file) { - const { type } = file; - const typeList = this.fileTypeList[this.fileType]; - let limitType = true; + beforeUpload (file) { + const fileName = file.name // 鑾峰彇鏂囦欢鍚� + const extension = fileName.split('.').pop() // 鎻愬彇鎵╁睍鍚� + const typeList = this.fileTypeList[this.fileType] + let limitType = true if (typeList) { const tempType = typeList.find(item => { - if (type.includes(item)) { - return true; + if (extension.toLowerCase() === item) { + return true } else { - return false; + return false } - }); + }) if (!tempType) { - this.$message.error(`璇蜂笂浼犳纭殑鏂囦欢鏍煎紡锛乣); - limitType = false; + this.$message.error(`璇蜂笂浼犳纭殑鏂囦欢鏍煎紡锛乣) + limitType = false } } - const limit = file.size / 1024 / 1024 < this.fileSizeLimitM; + const limit = file.size / 1024 / 1024 < this.fileSizeLimitM if (!limit) { - this.$message.error(`涓婁紶鏂囦欢澶у皬涓嶈兘瓒呰繃 ${this.fileSizeLimitM}MB!`); + this.$message.error(`涓婁紶鏂囦欢澶у皬涓嶈兘瓒呰繃 ${this.fileSizeLimitM}MB!`) } - return limitType && limit; + return limitType && limit }, }, computed: { - acceptList() { - let temp = '.*'; + acceptList () { + let temp = '.*' if (this.fileTypeList[this.fileType]) { - temp = this.fileTypeList[this.fileType].map(item => '.' + item).join(','); + temp = this.fileTypeList[this.fileType].map(item => '.' + item).join(',') } - return temp; + return temp } } -}; +} </script> <style scoped> diff --git a/src/router.js b/src/router.js index 1e2c89f..0059a0d 100644 --- a/src/router.js +++ b/src/router.js @@ -50,21 +50,21 @@ path: '/exam/mark/paper', component: () => import('@/views/exam/exam/MarkPaper'), name: 'MarkPaper', - meta: { title: '闃呭嵎'}, + meta: { title: '闃呭嵎', noCache: true }, hidden: true }, { path: '/exam/mark/paper/detail', component: () => import('@/views/exam/exam/MarkPaperDetail'), name: 'MarkPaperDetail', - meta: { title: '闃呭嵎'}, + meta: { title: '闃呭嵎璇︽儏', noCache: true }, hidden: true }, { path: '/exam/monitor', component: () => import('@/views/exam/exam/monitor'), name: 'monitor', - meta: { title: '鐩戞帶'}, + meta: { title: '鐩戞帶', noCache: true }, hidden: true } ] @@ -385,7 +385,8 @@ } ] }, - { path: '*', + { + path: '*', hidden: true, component: () => import('@/views/error-page/404'), meta: { title: '404', noCache: true } diff --git a/src/views/education/resource/list.vue b/src/views/education/resource/list.vue index cde0a54..33d6b76 100644 --- a/src/views/education/resource/list.vue +++ b/src/views/education/resource/list.vue @@ -17,6 +17,16 @@ </el-option> </el-select> </el-form-item> + <el-form-item label="鏂囦欢绫诲瀷"> + <el-select v-model="searchForm.contentType" clearable @clear="page" @change="page" placeholder="鏂囦欢绫诲瀷"> + <el-option + v-for="item in contentTypeList" + :key="item.value" + :label="item.name" + :value="item.value"> + </el-option> + </el-select> + </el-form-item> <el-form-item> <el-button type="primary" @click="page" size="small">鏌ヨ</el-button> </el-form-item> @@ -46,8 +56,14 @@ 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)">鐐瑰嚮鏌ョ湅 + <audio controls v-if="scope.row.contentType === 'audio'" + class="showContent"> + <source :src="'/api/files/' + scope.row.contentUrl.url"> + </audio> + <el-link type="primary" + v-if="scope.row.contentType !== 'video' && scope.row.contentType !== 'audio' && scope.row.contentType !== 'img'" + class="showContent" + @click="check(scope.row)">鐐瑰嚮鏌ョ湅 </el-link> </template> </el-table-column> @@ -57,6 +73,13 @@ <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 prop="visitUrl" label="璁块棶閾炬帴"> + <template slot-scope="scope"> + <div v-if="scope.row.contentType === 'video'"> + {{ scope.row.visitUrl }} </div> </template> </el-table-column> @@ -81,7 +104,7 @@ <el-form-item label="涓婚绠�浠�" prop="introduction"> <el-input v-model="form.introduction" placeholder="涓婚鍐呭"></el-input> </el-form-item> - <el-form-item label="鐝骇" > + <el-form-item label="鐝骇"> <el-select v-model="form.classId" placeholder="鐝骇" @@ -98,9 +121,12 @@ </el-form-item> <el-form-item label="鏂囦欢绫诲瀷" prop="contentType"> <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-option + v-for="item in contentTypeList" + :key="item.value" + :label="item.name" + :value="item.value"> + </el-option> </el-select> </el-form-item> <el-form-item label="涓婁紶鏂囦欢(涓�涓�)" prop="contentUrl"> @@ -147,12 +173,22 @@ dialogTitle: '娣诲姞瀛︿範鍐呭', ids: [], typeList: [], + contentTypeList: [ + { name: '瑙嗛', value: 'video' }, + { name: '鍥剧墖', value: 'img' }, + { name: '闊抽', value: 'audio' }, + { name: 'PDF', value: 'pdf' }, + { name: 'EXCEL', value: 'excel' }, + { name: 'WORD', value: 'word' }, + { name: 'PPT', value: 'ppt' } + ], classesIds: [], searchForm: { pageNum: 1, pageSize: 5, subjectId: null, - introduction: null + introduction: null, + contentType: null }, total: 0, tableData: [], @@ -169,10 +205,10 @@ }, rules: { contentUrl: [ - { required: true, message: '璇蜂笂浼犳枃浠�', trigger: 'blur' }, + { required: true, message: '璇蜂笂浼犳枃浠�', trigger: 'blur' } ], introduction: [ - { required: true, message: '璇疯緭鍏ヤ富棰樺唴瀹�', trigger: 'blur' }, + { required: true, message: '璇疯緭鍏ヤ富棰樺唴瀹�', trigger: 'blur' } ], belongType: [ { required: true, message: '璇烽�夋嫨瀛︿範鍒嗙被', trigger: 'change' } @@ -190,9 +226,10 @@ this.classesIds = re.data.data }) }, - checkPdf (url) { - this.pdf = url - this.pdfDialog = true + check (row) { + // this.pdf = url + // this.pdfDialog = true + window.open(row.visitUrl) }, closePdfDialog () { this.pdfDialog = false @@ -213,9 +250,22 @@ if (row.contentType === 'img') { return '鍥剧墖' } + if (row.contentType === 'audio') { + return '闊抽' + } if (row.contentType === 'pdf') { return 'PDF' } + if (row.contentType === 'excel') { + return 'EXCEL' + } + if (row.contentType === 'word') { + return 'WORD' + } + if (row.contentType === 'ppt') { + return 'PPT' + } + }, clearFile () { this.form.contentUrl = [] @@ -244,13 +294,14 @@ batchRemove () { if (this.ids.length < 1) { this.$message.warning('璇烽�夋嫨瑕佸垹闄ょ殑鏁版嵁') + } else { + EducationResourceAPI.remove(this.ids).then(res => { + if (res.code === 1) { + this.$message.success('鍒犻櫎鎴愬姛') + this.ids = [] + } + }) } - EducationResourceAPI.remove(this.ids).then(res => { - if (res.code === 1) { - this.$message.success('鍒犻櫎鎴愬姛') - this.ids = [] - } - }) }, getTitle (typeName) { return '纭畾瑕佸垹闄�' + typeName + '杩欎釜鏂囦欢鍚楋紵' @@ -319,7 +370,7 @@ this.form.belongType = row.belongType this.dialogTitle = '淇敼瀛︿範鍐呭' this.open = true - } + }, }, mounted () { this.page() diff --git a/src/views/exam/exam/MarkPaper.vue b/src/views/exam/exam/MarkPaper.vue index 89565ff..3586dfd 100644 --- a/src/views/exam/exam/MarkPaper.vue +++ b/src/views/exam/exam/MarkPaper.vue @@ -4,31 +4,31 @@ <el-col :span="5"> <div class="nameClass"> <div class="bottom5">鑰冭瘯鍚嶇О</div> - <div class="title">{{examInfo.examName}}</div> + <div class="title">{{ examInfo.examName }}</div> </div> </el-col> <el-col :span="5"> <div class="nameClass"> <div class="bottom5">璇曞嵎鍚嶇О</div> - <div class="title">{{examInfo.examPaperName}}</div> + <div class="title">{{ examInfo.examPaperName }}</div> </div> </el-col> <el-col :span="4"> <div class="staticNum"> <div class="bottom5">搴旇�冧汉鏁�</div> - <div class="title">{{examInfo.shouldJoinNum}}</div> + <div class="title">{{ examInfo.shouldJoinNum }}</div> </div> </el-col> <el-col :span="4"> <div class="staticNum"> <div class="bottom5">缂鸿�冧汉鏁�</div> - <div class="title">{{examInfo.missJoinNum}}</div> + <div class="title">{{ examInfo.missJoinNum }}</div> </div> </el-col> <el-col :span="4"> <div class="staticNum"> <div class="bottom5">鍙傚姞浣嗘湭瀹屾垚浜烘暟</div> - <div class="title">{{examInfo.joinButNotFinishNum}}</div> + <div class="title">{{ examInfo.joinButNotFinishNum }}</div> </div> </el-col> </el-row> @@ -76,7 +76,7 @@ width="300px" > <template slot-scope="scope"> - <el-button @click="markPaper(scope.row.userId)" type="warning">闃呭嵎</el-button> + <el-button @click="markPaper(scope.row)" type="warning">闃呭嵎</el-button> </template> </el-table-column> </el-table> @@ -91,10 +91,18 @@ mounted () { this.examInfo.examName = this.$route.query.examName this.examInfo.examId = this.$route.query.examId + console.log('------->' + this.examInfo.examName + '------->' + this.examInfo.examId) if (this.examInfo.examId) { this.getExamInfo() } }, + // watch: { + // $route: { + // handler () { + // this.reloadPage() + // } + // } + // }, data () { return { examInfo: { @@ -111,6 +119,14 @@ } }, methods: { + // reloadPage () { + // this.examInfo.examName = this.$route.query.examName + // this.examInfo.examId = this.$route.query.examId + // console.log('------->' + this.examInfo.examName + '------->' + this.examInfo.examId) + // if (this.examInfo.examId) { + // this.getExamInfo() + // } + // }, statusFormatter (row, column, cellValue, index) { if (cellValue === 'finish') { return '瀹屾垚' @@ -118,9 +134,12 @@ return '鏈畬鎴�' } }, - markPaper (userId) { + markPaper (row) { // todo鎵撳紑闃呭嵎椤甸潰 - this.$router.push({path: "/exam/mark/paper/detail", query: {examId: this.examInfo.examId, examName: this.examInfo.examName, userId: userId}}) + this.$router.push({ + path: '/exam/mark/paper/detail', + query: { examId: this.examInfo.examId, examName: this.examInfo.examName, userId: row.userId } + }) }, getExamInfo () { getExamMarkPaperInfo(this.examInfo.examId).then(res => { @@ -136,14 +155,17 @@ .title { font-size: 18px; } + .bottom5 { margin-bottom: 5px; } + .nameInfo { width: 100%; display: flex; flex-direction: column; } + .nameClass { width: 100%; display: flex; @@ -153,6 +175,7 @@ height: 70px; background-color: #cb5858; } + .staticNum { width: 100%; display: flex; diff --git a/src/views/exam/paper/list.vue b/src/views/exam/paper/list.vue index e8c34ef..057b6d8 100644 --- a/src/views/exam/paper/list.vue +++ b/src/views/exam/paper/list.vue @@ -9,7 +9,7 @@ <router-link :to="{ path: '/exam/paper/edit' }" class="link-left"> <el-button type="primary" >娣诲姞</el-button> </router-link> - <el-button class="link-left" type="danger" @click="downloadImportTemplate">涓嬭浇瀵煎叆妯℃澘</el-button> + <el-button class="link-left" type="danger" @click="downloadImportTemplate">涓嬭浇妯℃澘</el-button> <router-link :to="{ path: '/exam/paper/import' }" class="link-left"> <el-button type="success">瀵煎叆</el-button> </router-link> @@ -75,7 +75,7 @@ // 涓嬭浇瀵煎叆妯℃澘 downloadImportTemplate() { examPaperApi.downloadImportTemplate().then(res => { - downloadExcel(res, '棰樼洰瀵煎叆妯℃澘') + downloadExcel(res, '璇曞嵎瀵煎叆妯℃澘') }) }, submitForm() { diff --git a/src/views/exam/question/list.vue b/src/views/exam/question/list.vue index 512f167..a2c39fc 100644 --- a/src/views/exam/question/list.vue +++ b/src/views/exam/question/list.vue @@ -28,6 +28,18 @@ </el-button> <el-button slot="reference" type="primary" class="link-left">娣诲姞</el-button> </el-popover> + <el-button class="link-left" type="danger" @click="downloadImportTemplate">涓嬭浇妯℃澘</el-button> + <el-upload + style="display: inline;" + class="op-item link-left" + action="/api/admin/question/import" + :with-credentials="true" + :on-success="handlePreview" + accept=".xls,.xlsx" + :show-file-list="false" + :before-upload="beforeAvatarUpload"> + <el-button v-loading="importLoading" type="primary">瀵煎叆</el-button> + </el-upload> </el-form-item> </el-form> <el-table v-loading="listLoading" :data="tableData" border fit highlight-current-row style="width: 100%"> @@ -73,11 +85,13 @@ import Pagination from '@/components/Pagination' import QuestionShow from './components/Show' import questionApi from '@/api/question' +import { downloadExcel } from '@/utils/download' export default { components: { Pagination, QuestionShow }, data() { return { + importLoading: '', queryParam: { id: null, questionType: null, @@ -103,6 +117,33 @@ this.search() }, methods: { + handlePreview (e) { + this.importLoading = false + if (e.code === 1) { + this.search() + this.$message.success(e.message) + } else { + this.$message.error(e.message) + } + }, + beforeAvatarUpload (file) { + this.importLoading = true + let legalName = ['xlsx', 'xls'] + // 鎷垮埌鍚庣紑鍚� + let name = file.name.substring(file.name.lastIndexOf('.') + 1, file.name.length) + if (legalName.includes(name)) { + // console.log(legalName.includes(name)); + } else { + this.$message.warning('璇蜂笂浼爔ls銆亁lsx鏂囦欢') + return false + } + }, + // 涓嬭浇瀵煎叆妯℃澘 + downloadImportTemplate() { + questionApi.downloadImportTemplate().then(res => { + downloadExcel(res, '棰樼洰瀵煎叆妯℃澘') + }) + }, statusQuestion(row) { let question = { id: row.id, diff --git a/vue.config.js b/vue.config.js index cc6f74c..7978686 100644 --- a/vue.config.js +++ b/vue.config.js @@ -19,8 +19,8 @@ hotOnly: false, proxy: { '/api': { - // target: 'http://localhost:8000', - target: 'http://192.168.3.64:8000', + target: 'http://localhost:8000', + // target: 'http://192.168.3.64:8000', changeOrigin: true } } -- Gitblit v1.8.0