From 85e10f08753643e5dee2480bd8510945c68a9c52 Mon Sep 17 00:00:00 2001 From: 龚焕茏 <2842157468@qq.com> Date: 星期三, 22 五月 2024 11:36:02 +0800 Subject: [PATCH] feat:问答支持上传附件、部门管理员隐藏删除、禁用按钮、试卷列表菜单 --- src/views/questionAnswer/edit.vue | 37 ++++++++++++++++-- src/views/user/departmentExamine/list.vue | 8 ++-- src/views/questionAnswer/list.vue | 10 +++++ src/views/user/student/list.vue | 30 ++++++-------- src/router.js | 26 ++++++------ 5 files changed, 73 insertions(+), 38 deletions(-) diff --git a/src/router.js b/src/router.js index 81a3245..8428af1 100644 --- a/src/router.js +++ b/src/router.js @@ -496,19 +496,19 @@ }, alwaysShow: true, children: [ - { - path: 'paper/list', - component: () => import('@/views/exam/paper/list'), - name: 'ExamPaperPageList', - meta: { title: '璇曞嵎鍒楄〃', noCache: true } - }, - { - path: 'paper/edit', - component: () => import('@/views/exam/paper/edit'), - name: 'ExamPaperEdit', - meta: { title: '璇曞嵎缂栬緫', noCache: true, activeMenu: '/exam/paper/list' }, - hidden: true - }, + // { + // path: 'paper/list', + // component: () => import('@/views/exam/paper/list'), + // name: 'ExamPaperPageList', + // meta: { title: '璇曞嵎鍒楄〃', noCache: true } + // }, + // { + // path: 'paper/edit', + // component: () => import('@/views/exam/paper/edit'), + // name: 'ExamPaperEdit', + // meta: { title: '璇曞嵎缂栬緫', noCache: true, activeMenu: '/exam/paper/list' }, + // hidden: true + // }, { path: 'personalRandomTemplate/list', component: () => import('@/views/exam/personalRandomTemplate/list'), diff --git a/src/views/questionAnswer/edit.vue b/src/views/questionAnswer/edit.vue index 222ffd2..e8325f5 100644 --- a/src/views/questionAnswer/edit.vue +++ b/src/views/questionAnswer/edit.vue @@ -3,10 +3,13 @@ <el-form :model="form" ref="form" label-width="100px" v-loading="formLoading" :rules="rules"> <el-form-item label="闂锛�" prop="question"> - <el-input v-model="form.question"></el-input> + <el-input v-model="form.question" maxlength="48"></el-input> </el-form-item> <el-form-item label="绛旀锛�" prop="answer"> - <el-input v-model="form.answer"></el-input> + <el-input v-model="form.answer" maxlength="1000"></el-input> + </el-form-item> + <el-form-item label="闄勪欢锛�" prop="attachment"> + <upload :fileUrl="form.contentUrl" :fileSizeLimitM="1024" :uploadNum="1" @getUploadUrl="getUploadAttachmentUrl" @removeFile="removeAttachmentFile"/> </el-form-item> <el-form-item> <el-button type="primary" @click="submitForm">鎻愪氦</el-button> @@ -19,14 +22,27 @@ <script> import { mapGetters, mapState, mapActions } from 'vuex' import questionAnswerApi from '@/api/questionAnswer' +import Upload from '@/components/UploadC' export default { + components: { Upload }, + computed: { + fileContentUrl: () => { + return this.form ? this.form.contentUrl ? [this.form.contentUrl] : [] : []; + } + }, data () { return { form: { id: null, question: '', - answer: '' + answer: '', + contentType: 'file', + subject: '', + belongType: 2, + contentUrl: [], + attachment: '', + temp: [] }, formLoading: false, rules: { @@ -45,17 +61,30 @@ if (id && parseInt(id) !== 0) { _this.formLoading = true questionAnswerApi.query(id).then(re => { - _this.form = re.response + _this.form.id = re.response.id + _this.form.question = re.response.question + _this.form.answer = re.response.answer + _this.form.attachment = re.response.attachment ? re.response.attachment : '' + _this.form.contentUrl = re.response.attachment ? JSON.parse(re.response.attachment) : [] _this.formLoading = false }) } }, methods: { + removeAttachmentFile(fileList, fileName) { + this.form.attachment = JSON.stringify(fileList.filter(item => item.name !== fileName)); + this.form.contentUrl = fileList.filter(item => item.name !== fileName); + }, + getUploadAttachmentUrl(uploadData) { + this.form.attachment = JSON.stringify(uploadData); + this.form.contentUrl = uploadData; + }, submitForm () { let _this = this this.$refs.form.validate((valid) => { if (valid) { this.formLoading = true + questionAnswerApi.save(this.form).then(data => { if (data.code === 1) { _this.$message.success(data.message) diff --git a/src/views/questionAnswer/list.vue b/src/views/questionAnswer/list.vue index 0910646..5309804 100644 --- a/src/views/questionAnswer/list.vue +++ b/src/views/questionAnswer/list.vue @@ -17,6 +17,13 @@ <el-table v-loading="listLoading" :data="tableData" border fit highlight-current-row style="width: 100%"> <el-table-column prop="question" label="闂" /> <el-table-column prop="answer" label="鍥炵瓟" /> + <el-table-column prop="attachment" label="闄勪欢" show-overflow-tooltip> + <template slot-scope="scope"> + <div v-for="item in getUrl(scope.row.attachment)" :key="item.url"> + <el-link :underline="false" type="primary" :href="'/api/upload/download?url=' + item.url +'&fileName=' + item.name" >{{ item.name }}</el-link> + </div> + </template> + </el-table-column> <el-table-column label="鐘舵��" prop="status" width="70px"> <template slot-scope="{row}"> <el-tag :type="row.status !== '鍚敤' ? 'danger' : 'success'"> @@ -67,6 +74,9 @@ this.search() }, methods: { + getUrl(urlJson) { + return urlJson ? JSON.parse(urlJson) : []; + }, search() { this.listLoading = true questionAnswerApi.pageList(this.queryParam).then(data => { diff --git a/src/views/user/departmentExamine/list.vue b/src/views/user/departmentExamine/list.vue index 9dd0732..9bd7341 100644 --- a/src/views/user/departmentExamine/list.vue +++ b/src/views/user/departmentExamine/list.vue @@ -19,7 +19,7 @@ <el-table-column prop="attachment" label="闄勪欢" show-overflow-tooltip> <template slot-scope="scope"> <div v-for="item in getUrl(scope.row.attachment)" :key="item.url"> - <el-link type="primary" :href="'/api/upload/download?url=' + item.url +'&fileName=' + item.name" >{{ item.name }}</el-link> + <el-link :underline="false" type="primary" :href="'/api/upload/download?url=' + item.url +'&fileName=' + item.name" >{{ item.name }}</el-link> </div> </template> </el-table-column> @@ -31,7 +31,7 @@ <el-table-column prop="remark" label="瀹℃牳鎰忚" show-overflow-tooltip /> <el-table-column prop="createUserName" label="鍒涘缓浜�" /> <el-table-column prop="createTime" label="鍒涘缓鏃堕棿" width="160px" /> - <el-table-column label="鎿嶄綔" align="center" v-if="isDeptAdmin()"> + <el-table-column label="鎿嶄綔" align="center" v-if="!deptAdmin()"> <template slot-scope="{row}"> <el-button v-if="row.result === '寰呭鏍�'" type="primary" size="mini" @click="transposition(row)" class="link-left">瀹℃牳</el-button> <el-popconfirm title="纭鍒犻櫎" @confirm="deleteUser(row)"> @@ -89,8 +89,8 @@ getUrl(urlJson) { return urlJson ? JSON.parse(urlJson) : []; }, - isDeptAdmin() { - return sessionStorage.getItem('deptAdmin') !== '1' + deptAdmin() { + return sessionStorage.getItem('deptAdmin') === '1' }, transposition(user) { this.statusVisible = true; diff --git a/src/views/user/student/list.vue b/src/views/user/student/list.vue index fb67075..35740e3 100644 --- a/src/views/user/student/list.vue +++ b/src/views/user/student/list.vue @@ -51,9 +51,9 @@ </el-tag> </template> </el-table-column> - <el-table-column width="400px" label="鎿嶄綔" fixed="right" align="center"> + <el-table-column :width="deptAdmin() ? '310px' : '400px'" label="鎿嶄綔" fixed="right" align="center"> <template slot-scope="{row}"> - <el-button size="mini" @click="changeStatus(row)" class="link-left"> + <el-button size="mini" v-if="!deptAdmin()" @click="changeStatus(row)" class="link-left"> {{ statusBtnFormatter(row.status) }} </el-button> <router-link :to="{path:'/user/student/edit', query:{id:row.id}}" class="link-left"> @@ -65,7 +65,7 @@ <el-button size="mini" @click="status(row)" class="link-left">鐘舵��</el-button> <el-button type="primary" size="mini" @click="transposition(row)" class="link-left">璋冨姩</el-button> <el-popconfirm title="纭鍒犻櫎鍚�" @confirm="deleteUser(row)"> - <el-button slot="reference" size="mini" type="danger" class="link-left">鍒犻櫎</el-button> + <el-button v-if="!deptAdmin()" slot="reference" size="mini" type="danger" class="link-left">鍒犻櫎</el-button> </el-popconfirm> </template> </el-table-column> @@ -102,8 +102,7 @@ </el-option> </el-select> <el-input type="textarea" maxlength="100" show-word-limit :autosize="{ minRows: 4}" :rows="2" v-model="examine.reason" placeholder="璇疯緭鍏ユ儏鍐佃鏄�" style="margin-top: 30px;"></el-input> - <upload v-show="form.contentType" ref="upload" :fileUrl="form.contentUrl" :fileType="form.contentType" - :fileSizeLimitM="1024" :uploadNum="1" @getUploadUrl="getUploadUrl" @removeFile="removeFile" style="margin-top: 30px;"/> + <upload :fileUrl="examine.contentUrl" :fileSizeLimitM="1024" :uploadNum="1" @getUploadUrl="getUploadAttachmentUrl" @removeFile="removeAttachmentFile" style="margin-top: 30px;"/> <span slot="footer" class="dialog-footer"> <el-button @click="dialogVisible = false">鍙� 娑�</el-button> <el-button type="primary" @click="submitExamine">纭� 瀹�</el-button> @@ -128,15 +127,6 @@ }, data () { return { - - form: { - contentType: 'file', - subject: '', - belongType: 2, - contentUrl: [], - attachment: [], - temp: [] - }, user:{}, statusVisible: false, upLoadUrl:'/api/admin/user/import', @@ -155,6 +145,7 @@ departmentId: [], departmentIds: '', nowDepartmentIds: '', + contentUrl: [], attachment: '' }, title: '閮ㄩ棬璋冨姩', @@ -166,11 +157,16 @@ this.search() }, methods: { - removeFile() { - this.examine.attachment = []; + deptAdmin() { + return sessionStorage.getItem('deptAdmin') === '1' }, - getUploadUrl(uploadData) { + removeAttachmentFile(fileList, fileName) { + this.examine.attachment = JSON.stringify(fileList.filter(item => item.name !== fileName)); + this.examine.contentUrl = fileList.filter(item => item.name !== fileName); + }, + getUploadAttachmentUrl(uploadData) { this.examine.attachment = JSON.stringify(uploadData); + this.examine.contentUrl = uploadData; }, submitExamine() { this.examine.departmentIds = this.examine.departmentId.join(',') -- Gitblit v1.8.0