From b43bad8ef992d4abdebf96feb6f4fe862e8f4d8a Mon Sep 17 00:00:00 2001
From: fuliqi <fuliqi@qq.com>
Date: 星期一, 17 六月 2024 09:38:14 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'
---
src/views/exam/question/edit/analysis.vue | 193 ++++++++++++++++++++++++
src/views/exam/question/edit/calculate.vue | 193 ++++++++++++++++++++++++
src/views/answer/components/QuestionAnswerShow.vue | 6
src/store/modules/enumItem.js | 6
src/views/answer/list.vue | 4
src/router.js | 14 +
src/views/exam/question/components/Show.vue | 2
src/views/exam/question/edit/audio.vue | 19 ++
8 files changed, 429 insertions(+), 8 deletions(-)
diff --git a/src/router.js b/src/router.js
index 5dede70..4be4188 100644
--- a/src/router.js
+++ b/src/router.js
@@ -173,6 +173,20 @@
name: 'audioPage',
meta: { title: '璇煶棰樼紪杈�', noCache: true, activeMenu: '/exam/question/list' },
hidden: true
+ },
+ {
+ path: 'question/edit/calculate',
+ component: () => import('@/views/exam/question/edit/calculate'),
+ name: 'audioPage',
+ meta: { title: '璁$畻棰樼紪杈�', noCache: true, activeMenu: '/exam/question/list' },
+ hidden: true
+ },
+ {
+ path: 'question/edit/analysis',
+ component: () => import('@/views/exam/question/edit/analysis'),
+ name: 'audioPage',
+ meta: { title: '鍒嗘瀽棰樼紪杈�', noCache: true, activeMenu: '/exam/question/list' },
+ hidden: true
}
]
},
diff --git a/src/store/modules/enumItem.js b/src/store/modules/enumItem.js
index eee505a..9572098 100644
--- a/src/store/modules/enumItem.js
+++ b/src/store/modules/enumItem.js
@@ -15,13 +15,15 @@
paperTypeEnum: [{ key: 1, value: '鍥哄畾璇曞嵎' }, { key: 2, value: '闅忔満璇曞嵎' }, { key: 3, value: '闅忓簭璇曞嵎' }]
},
question: {
- typeEnum: [{ key: 1, value: '鍗曢�夐' }, { key: 2, value: '澶氶�夐' }, { key: 3, value: '鍒ゆ柇棰�' }, { key: 4, value: '濉┖棰�' }, { key: 5, value: '绠�绛旈' }, { key: 6, value: '璇煶棰�' }],
+ typeEnum: [{ key: 1, value: '鍗曢�夐' }, { key: 2, value: '澶氶�夐' }, { key: 3, value: '鍒ゆ柇棰�' }, { key: 4, value: '濉┖棰�' }, { key: 5, value: '绠�绛旈' }, { key: 6, value: '璇煶棰�' }, { key: 7, value: '璁$畻棰�' }, { key: 8, value: '鍒嗘瀽棰�' }],
editUrlEnum: [{ key: 1, value: '/exam/question/edit/singleChoice', name: '鍗曢�夐' },
{ key: 2, value: '/exam/question/edit/multipleChoice', name: '澶氶�夐' },
{ key: 3, value: '/exam/question/edit/trueFalse', name: '鍒ゆ柇棰�' },
{ key: 4, value: '/exam/question/edit/gapFilling', name: '濉┖棰�' },
{ key: 5, value: '/exam/question/edit/shortAnswer', name: '绠�绛旈' },
- { key: 6, value: '/exam/question/edit/audio', name: '璇煶棰�' }]
+ { key: 6, value: '/exam/question/edit/audio', name: '璇煶棰�' },
+ { key: 7, value: '/exam/question/edit/calculate', name: '璁$畻棰�' },
+ { key: 8, value: '/exam/question/edit/analysis', name: '鍒嗘瀽棰�' }]
}
}
}
diff --git a/src/views/answer/components/QuestionAnswerShow.vue b/src/views/answer/components/QuestionAnswerShow.vue
index 087f037..f84e195 100644
--- a/src/views/answer/components/QuestionAnswerShow.vue
+++ b/src/views/answer/components/QuestionAnswerShow.vue
@@ -1,6 +1,6 @@
<template>
<div v-loading="qLoading" style="line-height:1.8">
- <div v-if="qType == 1 || qType == 2 || qType == 3 || qType == 4 || qType == 5 || qType == 6">
+ <div v-if="qType == 1 || qType == 2 || qType == 3 || qType == 4 || qType == 5 || qType == 6 || qType == 7 || qType == 8">
<div v-if="qType == 1 || qType == 6">
<div class="q-title" v-html="question.title" />
<div class="q-content">
@@ -42,7 +42,7 @@
</el-form-item>
</div>
</div>
- <div v-else-if="qType == 5">
+ <div v-else-if="qType == 5 || qType == 7 || qType == 8">
<div class="q-title" v-html="question.title" />
<div>
<el-input v-model="answer.content" type="textarea" rows="5"></el-input>
@@ -69,7 +69,7 @@
</div>
<div class="question-answer-show-item">
<span class="question-show-item">姝g‘绛旀锛�</span>
- <span v-if="qType == 1 || qType == 2 || qType == 5 || qType == 6" v-html="question.correct" class="q-item-span-content" />
+ <span v-if="qType == 1 || qType == 2 || qType == 5 || qType == 6 || qType == 7 || qType == 8" v-html="question.correct" class="q-item-span-content" />
<span v-if="qType == 3" v-html="trueFalseFormatter(question)" class="q-item-span-content" />
<span v-if="qType == 4">{{ question.correctArray }}</span>
</div>
diff --git a/src/views/answer/list.vue b/src/views/answer/list.vue
index 8b8e238..63d1414 100644
--- a/src/views/answer/list.vue
+++ b/src/views/answer/list.vue
@@ -2,6 +2,9 @@
<div class="app-container">
<el-form :inline="true" :model="queryParam" class="demo-form-inline" label-width="80px">
<el-form-item>
+ <el-input v-model="queryParam.examName" placeholder="璇疯緭鍏ヨ�冭瘯鍚嶇О" clearable></el-input>
+ </el-form-item>
+ <el-form-item>
<el-input v-model="queryParam.name" placeholder="璇疯緭鍏ヨ瘯鍗峰悕绉�" clearable></el-input>
</el-form-item>
<el-form-item>
@@ -15,6 +18,7 @@
</el-form>
<el-table v-loading="listLoading" :data="tableData" border style="width: 100%;">
+ <el-table-column align="center" prop="examName" label="鑰冭瘯鍚嶇О" />
<el-table-column align="center" prop="paperName" label="璇曞嵎鍚嶇О" />
<el-table-column align="center" prop="subjectName" label="绉戠洰" />
<el-table-column align="center" prop="paperType" label="璇曞嵎绫诲瀷" width="150px">
diff --git a/src/views/exam/question/components/Show.vue b/src/views/exam/question/components/Show.vue
index 468780b..2179805 100644
--- a/src/views/exam/question/components/Show.vue
+++ b/src/views/exam/question/components/Show.vue
@@ -29,7 +29,7 @@
<div v-else-if="qType==4" v-loading="qLoading">
<div class="q-title" v-html="question.title"/>
</div>
- <div v-else-if="qType==5" v-loading="qLoading">
+ <div v-else-if="qType==5 || qType == 7 || qType == 8" v-loading="qLoading">
<div class="q-title" v-html="question.title"/>
</div>
<div v-else>
diff --git a/src/views/exam/question/edit/analysis.vue b/src/views/exam/question/edit/analysis.vue
new file mode 100644
index 0000000..eb200f0
--- /dev/null
+++ b/src/views/exam/question/edit/analysis.vue
@@ -0,0 +1,193 @@
+<template>
+ <div class="app-container">
+ <el-form :model="form" ref="form" label-width="100px" v-loading="formLoading" :rules="rules">
+ <el-form-item label="瀛︾锛�" prop="subjectId" required>
+ <el-select v-model="form.subjectId" placeholder="瀛︾" >
+ <el-option v-for="item in subjects" :key="item.id" :value="item.id" :label="item.name"></el-option>
+ </el-select>
+ </el-form-item>
+ <el-form-item label="棰樺共锛�" prop="title" required>
+ <el-input v-model="form.title" @focus="inputClick(form,'title')" />
+ </el-form-item>
+ <el-form-item label="绛旀锛�" prop="correct" required>
+ <el-input v-model="form.correct" @focus="inputClick(form,'correct')" />
+ </el-form-item>
+ <el-form-item label="瑙f瀽锛�" prop="analyze" required>
+ <el-input v-model="form.analyze" @focus="inputClick(form,'analyze')" />
+ </el-form-item>
+ <el-form-item label="闅惧害锛�" required>
+ <el-rate v-model="form.difficult" class="question-item-rate"></el-rate>
+ </el-form-item>
+ <el-form-item>
+ <el-button type="primary" @click="submitForm">鎻愪氦</el-button>
+ <el-button @click="resetForm">閲嶇疆</el-button>
+ <el-button type="success" @click="showQuestion">棰勮</el-button>
+ </el-form-item>
+ </el-form>
+ <el-dialog :visible.sync="richEditor.dialogVisible" append-to-body :close-on-click-modal="false" style="width: 100%;height: 100%" :show-close="false" center>
+ <Ueditor @ready="editorReady"/>
+ <span slot="footer" class="dialog-footer">
+ <el-button type="primary" @click="editorConfirm">纭� 瀹�</el-button>
+ <el-button @click="richEditor.dialogVisible = false">鍙� 娑�</el-button>
+ </span>
+ </el-dialog>
+ <el-dialog :visible.sync="questionShow.dialog" style="width: 100%;height: 100%">
+ <QuestionShow :qType="questionShow.qType" :question="questionShow.question" :qLoading="questionShow.loading"/>
+ </el-dialog>
+ </div>
+</template>
+
+<script>
+import QuestionShow from '../components/Show'
+import Ueditor from '@/components/Ueditor'
+import { mapGetters, mapState, mapActions } from 'vuex'
+import questionApi from '@/api/question'
+
+export default {
+ components: {
+ Ueditor, QuestionShow
+ },
+ data () {
+ return {
+ form: {
+ id: null,
+ questionType: 8,
+ gradeLevel: null,
+ subjectId: null,
+ title: '',
+ items: [],
+ analyze: '',
+ correct: '',
+ score: '',
+ difficult: 0
+ },
+ subjectFilter: null,
+ formLoading: false,
+ rules: {
+ gradeLevel: [
+ { required: true, message: '璇烽�夋嫨骞寸骇', trigger: 'change' }
+ ],
+ subjectId: [
+ { required: true, message: '璇烽�夋嫨瀛︾', trigger: 'change' }
+ ],
+ title: [
+ { required: true, message: '璇疯緭鍏ラ骞�', trigger: 'blur' }
+ ],
+ correct: [
+ { required: true, message: '璇疯緭鍏ョ瓟妗�', trigger: 'blur' }
+ ],
+ analyze: [
+ { required: true, message: '璇疯緭鍏ヨВ鏋�', trigger: 'blur' }
+ ],
+ score: [
+ { required: true, message: '璇疯緭鍏ュ垎鏁�', trigger: 'blur' }
+ ]
+ },
+ richEditor: {
+ dialogVisible: false,
+ object: null,
+ parameterName: '',
+ instance: null
+ },
+ questionShow: {
+ qType: 0,
+ dialog: false,
+ question: null,
+ loading: false
+ }
+ }
+ },
+ created () {
+ let id = this.$route.query.id
+ let _this = this
+ this.initSubject(function () {
+ _this.subjectFilter = _this.subjects
+ })
+ if (id && parseInt(id) !== 0) {
+ _this.formLoading = true
+ questionApi.select(id).then(re => {
+ _this.form = re.data
+ _this.formLoading = false
+ })
+ }
+ },
+ methods: {
+ editorReady (instance) {
+ this.richEditor.instance = instance
+ let currentContent = this.richEditor.object[this.richEditor.parameterName]
+ this.richEditor.instance.setContent(currentContent)
+ // 鍏夋爣瀹氫綅鍒癠editor
+ this.richEditor.instance.focus(true)
+ },
+ inputClick (object, parameterName) {
+ this.richEditor.object = object
+ this.richEditor.parameterName = parameterName
+ this.richEditor.dialogVisible = true
+ },
+ editorConfirm () {
+ let content = this.richEditor.instance.getContent()
+ this.richEditor.object[this.richEditor.parameterName] = content
+ this.richEditor.dialogVisible = false
+ },
+ submitForm () {
+ let _this = this
+ this.$refs.form.validate((valid) => {
+ if (valid) {
+ this.formLoading = true
+ questionApi.edit(this.form).then(re => {
+ if (re.code === 1) {
+ _this.$message.success(re.message)
+ _this.delCurrentView(_this).then(() => {
+ _this.$router.push('/exam/question/list')
+ })
+ } else {
+ _this.$message.error(re.message)
+ this.formLoading = false
+ }
+ }).catch(e => {
+ this.formLoading = false
+ })
+ } else {
+ return false
+ }
+ })
+ },
+ resetForm () {
+ let lastId = this.form.id
+ this.$refs['form'].resetFields()
+ this.form = {
+ id: null,
+ questionType: 5,
+ gradeLevel: null,
+ subjectId: null,
+ title: '',
+ items: [],
+ analyze: '',
+ correct: '',
+ score: '',
+ difficult: 0
+ }
+ this.form.id = lastId
+ },
+ levelChange () {
+ this.form.subjectId = null
+ this.subjectFilter = this.subjects.filter(data => data.level === this.form.gradeLevel)
+ },
+ showQuestion () {
+ this.questionShow.dialog = true
+ this.questionShow.qType = this.form.questionType
+ this.questionShow.question = this.form
+ },
+ ...mapActions('exam', { initSubject: 'initSubject' }),
+ ...mapActions('tagsView', { delCurrentView: 'delCurrentView' })
+ },
+ computed: {
+ ...mapGetters('enumItem', ['enumFormat']),
+ ...mapState('enumItem', {
+ questionTypeEnum: state => state.exam.question.typeEnum,
+ levelEnum: state => state.user.levelEnum
+ }),
+ ...mapState('exam', { subjects: state => state.subjects })
+ }
+}
+</script>
diff --git a/src/views/exam/question/edit/audio.vue b/src/views/exam/question/edit/audio.vue
index 7f88df7..4743443 100644
--- a/src/views/exam/question/edit/audio.vue
+++ b/src/views/exam/question/edit/audio.vue
@@ -11,8 +11,10 @@
</el-form-item>
<el-form-item label="璇煶锛�" prop="audioFile" required>
<el-upload v-model="form.audioFile" :action="uploadUrl" :limit="1" accept="audio/*" :on-success="uploadSuccess"
- :file-list="audioList">
+ :on-remove="handleRemove" :file-list="audioList">
<el-button size="small" type="primary">鐐瑰嚮涓婁紶</el-button>
+ <el-button v-if="form.audioFile" size="small" type="primary" @click.stop="audioPlay(form.audioFile)">{{
+ audioInstance ? '鏆傚仠' : '璇曞惉' }}</el-button>
</el-upload>
</el-form-item>
<el-form-item label="閫夐」锛�" required>
@@ -125,7 +127,8 @@
dialog: false,
question: null,
loading: false
- }
+ },
+ audioInstance: null
}
},
created() {
@@ -144,6 +147,18 @@
}
},
methods: {
+ handleRemove() {
+ this.form.audioFile = ''
+ },
+ audioPlay(url) {
+ if (this.audioInstance) {
+ this.audioInstance.pause();
+ this.audioInstance = null;
+ } else {
+ this.audioInstance = new Audio('/api/files/' + url);
+ this.audioInstance.play();
+ }
+ },
uploadSuccess(response) {
this.form.audioFile = response.data.url;
this.form.originalFile = response.data.name;
diff --git a/src/views/exam/question/edit/calculate.vue b/src/views/exam/question/edit/calculate.vue
new file mode 100644
index 0000000..7533456
--- /dev/null
+++ b/src/views/exam/question/edit/calculate.vue
@@ -0,0 +1,193 @@
+<template>
+ <div class="app-container">
+ <el-form :model="form" ref="form" label-width="100px" v-loading="formLoading" :rules="rules">
+ <el-form-item label="瀛︾锛�" prop="subjectId" required>
+ <el-select v-model="form.subjectId" placeholder="瀛︾" >
+ <el-option v-for="item in subjects" :key="item.id" :value="item.id" :label="item.name"></el-option>
+ </el-select>
+ </el-form-item>
+ <el-form-item label="棰樺共锛�" prop="title" required>
+ <el-input v-model="form.title" @focus="inputClick(form,'title')" />
+ </el-form-item>
+ <el-form-item label="绛旀锛�" prop="correct" required>
+ <el-input v-model="form.correct" @focus="inputClick(form,'correct')" />
+ </el-form-item>
+ <el-form-item label="瑙f瀽锛�" prop="analyze" required>
+ <el-input v-model="form.analyze" @focus="inputClick(form,'analyze')" />
+ </el-form-item>
+ <el-form-item label="闅惧害锛�" required>
+ <el-rate v-model="form.difficult" class="question-item-rate"></el-rate>
+ </el-form-item>
+ <el-form-item>
+ <el-button type="primary" @click="submitForm">鎻愪氦</el-button>
+ <el-button @click="resetForm">閲嶇疆</el-button>
+ <el-button type="success" @click="showQuestion">棰勮</el-button>
+ </el-form-item>
+ </el-form>
+ <el-dialog :visible.sync="richEditor.dialogVisible" append-to-body :close-on-click-modal="false" style="width: 100%;height: 100%" :show-close="false" center>
+ <Ueditor @ready="editorReady"/>
+ <span slot="footer" class="dialog-footer">
+ <el-button type="primary" @click="editorConfirm">纭� 瀹�</el-button>
+ <el-button @click="richEditor.dialogVisible = false">鍙� 娑�</el-button>
+ </span>
+ </el-dialog>
+ <el-dialog :visible.sync="questionShow.dialog" style="width: 100%;height: 100%">
+ <QuestionShow :qType="questionShow.qType" :question="questionShow.question" :qLoading="questionShow.loading"/>
+ </el-dialog>
+ </div>
+</template>
+
+<script>
+import QuestionShow from '../components/Show'
+import Ueditor from '@/components/Ueditor'
+import { mapGetters, mapState, mapActions } from 'vuex'
+import questionApi from '@/api/question'
+
+export default {
+ components: {
+ Ueditor, QuestionShow
+ },
+ data () {
+ return {
+ form: {
+ id: null,
+ questionType: 7,
+ gradeLevel: null,
+ subjectId: null,
+ title: '',
+ items: [],
+ analyze: '',
+ correct: '',
+ score: '',
+ difficult: 0
+ },
+ subjectFilter: null,
+ formLoading: false,
+ rules: {
+ gradeLevel: [
+ { required: true, message: '璇烽�夋嫨骞寸骇', trigger: 'change' }
+ ],
+ subjectId: [
+ { required: true, message: '璇烽�夋嫨瀛︾', trigger: 'change' }
+ ],
+ title: [
+ { required: true, message: '璇疯緭鍏ラ骞�', trigger: 'blur' }
+ ],
+ correct: [
+ { required: true, message: '璇疯緭鍏ョ瓟妗�', trigger: 'blur' }
+ ],
+ analyze: [
+ { required: true, message: '璇疯緭鍏ヨВ鏋�', trigger: 'blur' }
+ ],
+ score: [
+ { required: true, message: '璇疯緭鍏ュ垎鏁�', trigger: 'blur' }
+ ]
+ },
+ richEditor: {
+ dialogVisible: false,
+ object: null,
+ parameterName: '',
+ instance: null
+ },
+ questionShow: {
+ qType: 0,
+ dialog: false,
+ question: null,
+ loading: false
+ }
+ }
+ },
+ created () {
+ let id = this.$route.query.id
+ let _this = this
+ this.initSubject(function () {
+ _this.subjectFilter = _this.subjects
+ })
+ if (id && parseInt(id) !== 0) {
+ _this.formLoading = true
+ questionApi.select(id).then(re => {
+ _this.form = re.data
+ _this.formLoading = false
+ })
+ }
+ },
+ methods: {
+ editorReady (instance) {
+ this.richEditor.instance = instance
+ let currentContent = this.richEditor.object[this.richEditor.parameterName]
+ this.richEditor.instance.setContent(currentContent)
+ // 鍏夋爣瀹氫綅鍒癠editor
+ this.richEditor.instance.focus(true)
+ },
+ inputClick (object, parameterName) {
+ this.richEditor.object = object
+ this.richEditor.parameterName = parameterName
+ this.richEditor.dialogVisible = true
+ },
+ editorConfirm () {
+ let content = this.richEditor.instance.getContent()
+ this.richEditor.object[this.richEditor.parameterName] = content
+ this.richEditor.dialogVisible = false
+ },
+ submitForm () {
+ let _this = this
+ this.$refs.form.validate((valid) => {
+ if (valid) {
+ this.formLoading = true
+ questionApi.edit(this.form).then(re => {
+ if (re.code === 1) {
+ _this.$message.success(re.message)
+ _this.delCurrentView(_this).then(() => {
+ _this.$router.push('/exam/question/list')
+ })
+ } else {
+ _this.$message.error(re.message)
+ this.formLoading = false
+ }
+ }).catch(e => {
+ this.formLoading = false
+ })
+ } else {
+ return false
+ }
+ })
+ },
+ resetForm () {
+ let lastId = this.form.id
+ this.$refs['form'].resetFields()
+ this.form = {
+ id: null,
+ questionType: 5,
+ gradeLevel: null,
+ subjectId: null,
+ title: '',
+ items: [],
+ analyze: '',
+ correct: '',
+ score: '',
+ difficult: 0
+ }
+ this.form.id = lastId
+ },
+ levelChange () {
+ this.form.subjectId = null
+ this.subjectFilter = this.subjects.filter(data => data.level === this.form.gradeLevel)
+ },
+ showQuestion () {
+ this.questionShow.dialog = true
+ this.questionShow.qType = this.form.questionType
+ this.questionShow.question = this.form
+ },
+ ...mapActions('exam', { initSubject: 'initSubject' }),
+ ...mapActions('tagsView', { delCurrentView: 'delCurrentView' })
+ },
+ computed: {
+ ...mapGetters('enumItem', ['enumFormat']),
+ ...mapState('enumItem', {
+ questionTypeEnum: state => state.exam.question.typeEnum,
+ levelEnum: state => state.user.levelEnum
+ }),
+ ...mapState('exam', { subjects: state => state.subjects })
+ }
+}
+</script>
--
Gitblit v1.8.0