From a57f1cab5efbbd118759b77568ffe0b5369d8599 Mon Sep 17 00:00:00 2001 From: 龚焕茏 <2842157468@qq.com> Date: 星期二, 04 六月 2024 12:00:37 +0800 Subject: [PATCH] feat:题目查询、新增 --- src/components/PopUp/multiple-choice.vue | 4 - src/views/Manage/TestPaper/QuestionBank.vue | 96 ++++++++++++++++++++++++++++++++++++------------ src/components/PopUp/gap-filling.vue | 4 - src/components/PopUp/single-choice.vue | 4 - src/components/PopUp/true-false.vue | 4 - src/components/PopUp/short-answer.vue | 4 - 6 files changed, 77 insertions(+), 39 deletions(-) diff --git a/src/components/PopUp/gap-filling.vue b/src/components/PopUp/gap-filling.vue index 4deb149..46992d7 100644 --- a/src/components/PopUp/gap-filling.vue +++ b/src/components/PopUp/gap-filling.vue @@ -186,9 +186,7 @@ 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') - }) + this.$emit('callback') } else { _this.$message.error(re.message) this.formLoading = false diff --git a/src/components/PopUp/multiple-choice.vue b/src/components/PopUp/multiple-choice.vue index cd1effc..4ee4d6c 100644 --- a/src/components/PopUp/multiple-choice.vue +++ b/src/components/PopUp/multiple-choice.vue @@ -175,9 +175,7 @@ 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') - }) + this.$emit('callback') } else { _this.$message.error(re.message) this.formLoading = false diff --git a/src/components/PopUp/short-answer.vue b/src/components/PopUp/short-answer.vue index 4f2994f..d5fc6ff 100644 --- a/src/components/PopUp/short-answer.vue +++ b/src/components/PopUp/short-answer.vue @@ -146,9 +146,7 @@ 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') - }) + this.$emit('callback') } else { _this.$message.error(re.message) this.formLoading = false diff --git a/src/components/PopUp/single-choice.vue b/src/components/PopUp/single-choice.vue index ad7e191..80338ba 100644 --- a/src/components/PopUp/single-choice.vue +++ b/src/components/PopUp/single-choice.vue @@ -175,9 +175,7 @@ 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') - }) + this.$emit('callback') } else { _this.$message.error(re.message) this.formLoading = false diff --git a/src/components/PopUp/true-false.vue b/src/components/PopUp/true-false.vue index 1b49929..45f1865 100644 --- a/src/components/PopUp/true-false.vue +++ b/src/components/PopUp/true-false.vue @@ -157,9 +157,7 @@ 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') - }) + this.$emit('callback') } else { _this.$message.error(re.message) this.formLoading = false diff --git a/src/views/Manage/TestPaper/QuestionBank.vue b/src/views/Manage/TestPaper/QuestionBank.vue index e7b4c3e..aeb052a 100644 --- a/src/views/Manage/TestPaper/QuestionBank.vue +++ b/src/views/Manage/TestPaper/QuestionBank.vue @@ -17,12 +17,12 @@ </div> <!-- 鎼滅储 --> <div> - <el-form :inline="true" :model="formLabelAlign" class="demo-form-inline" label-width="80px"> + <el-form :inline="true" :model="queryParam" class="demo-form-inline" label-width="80px"> <el-form-item> - <el-input v-model="formLabelAlign.type" placeholder="棰樼洰鍚�"></el-input> + <el-input v-model="queryParam.content" placeholder="棰樼洰鍚�"></el-input> </el-form-item> <el-form-item> - <el-select v-model="formLabelAlign.region" placeholder="鍏ㄩ儴绉戠洰"> + <el-select v-model="queryParam.subjectId" placeholder="鍏ㄩ儴绉戠洰"> <el-option label="鍏ㄩ儴绉戠洰" value="shanghai"></el-option> <el-option label="璇枃" value="beijing"></el-option> <el-option label="鏁板" value="beijing"></el-option> @@ -30,7 +30,7 @@ </el-select> </el-form-item> <el-form-item> - <el-select v-model="formLabelAlign.region" placeholder="閫夋嫨棰�"> + <el-select v-model="queryParam.questionType" placeholder="閫夋嫨棰�"> <el-option label="閫夋嫨棰�" value="shanghai"></el-option> <el-option label="闂瓟棰�" value="beijing"></el-option> <el-option label="鍒ゆ柇棰�" value="beijing"></el-option> @@ -44,17 +44,22 @@ </div> <!-- 琛ㄦ牸 --> <el-table v-loading="listLoading" :header-cell-style="getRowClass" :data="tableData" border style="width: 100%;"> - <el-table-column align="center" prop="title" label="棰樼洰鍚�"> + <el-table-column align="center" prop="shortTitle" label="棰樼洰鍚�"> </el-table-column> - <el-table-column align="center" prop="subject" label="绉戠洰"> + <el-table-column align="center" prop="subjectName" label="绉戠洰"> </el-table-column> - <el-table-column align="center" prop="type" label="棰樼洰绫诲瀷"> + <el-table-column align="center" prop="questionTypeName" label="棰樺瀷"> </el-table-column> - <el-table-column align="center" prop="score" label="鍙傝�冪瓟妗�"> + <el-table-column align="center" prop="score" label="鍒嗘暟"> </el-table-column> - <el-table-column label="鎿嶄綔" align="center"> - <el-button type="text">缂栬緫</el-button> - <el-button type="text">鍒犻櫎</el-button> + <el-table-column prop="difficult" label="闅惧害" width="60px"/> + <el-table-column prop="createTime" label="鍒涘缓鏃堕棿" width="160px"/> + <el-table-column label="鎿嶄綔" align="center" width="220px"> + <template slot-scope="{row}"> + <el-button size="mini" @click="showQuestion(row)">棰勮</el-button> + <el-button size="mini" @click="editQuestion(row)">缂栬緫</el-button> + <el-button size="mini" type="danger" @click="deleteQuestion(row)" class="link-left">鍒犻櫎</el-button> + </template> </el-table-column> </el-table> <div class="block" style="display: flex; margin-top: 40px;"> @@ -67,23 +72,27 @@ </div> <!-- 濉┖ --> <el-dialog :visible.sync="gapVisible" :close-on-click-modal="false"> - <gap ref="gap" @children="parentGoods" /> + <gap ref="gap" @children="parentGoods" @callback="callback" /> </el-dialog> <!-- 澶氶�� --> <el-dialog :visible.sync="multipleVisible" :close-on-click-modal="false"> - <multiple ref="multiple" @children="parentGoods" /> + <multiple ref="multiple" @children="parentGoods" @callback="callback" /> </el-dialog> <!-- 绠�绛� --> <el-dialog :visible.sync="shortVisible" :close-on-click-modal="false"> - <short ref="short" @children="parentGoods" /> + <short ref="short" @children="parentGoods" @callback="callback" /> </el-dialog> <!-- 鍗曢�� --> <el-dialog :visible.sync="singleVisible" :close-on-click-modal="false"> - <single ref="single" @children="parentGoods" /> + <single ref="single" @children="parentGoods" @callback="callback" /> </el-dialog> <!-- 鍒ゆ柇 --> <el-dialog :visible.sync="truesVisible" :close-on-click-modal="false"> - <trues ref="trues" @children="parentGoods" /> + <trues ref="trues" @children="parentGoods" @callback="callback" /> + </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> @@ -96,6 +105,7 @@ import trues from "@/components/PopUp/true-false.vue"; import { mapGetters, mapState } from 'vuex' import questionApi from '@/api/question' +import QuestionShow from '@/components/PopUp/question/Show' export default { // 娉ㄥ唽 @@ -105,13 +115,21 @@ short, single, trues, + QuestionShow }, data() { return { + questionShow: { + qType: 0, + dialog: false, + question: null, + loading: false + }, listLoading: true, queryParam: { questionType: null, subjectId: null, + content: null, pageIndex: 1, pageSize: 10 }, @@ -121,11 +139,6 @@ shortVisible: false, singleVisible: false, truesVisible: false, - formLabelAlign: { - type: "", - user: "", - region: "", - }, tableData: [], }; }, @@ -133,13 +146,22 @@ this.search() }, methods: { + callback() { + this.gapVisible = false; + this.multipleVisible = false; + this.shortVisible = false; + this.singleVisible = false; + this.truesVisible = false; + this.search() + }, // 鑾峰彇鍒楄〃 search() { this.listLoading = true questionApi.pageList(this.queryParam).then(re => { - this.tableData = re.data - this.total = re.total - this.queryParam.pageIndex = re.pageNum + this.tableData = re.data.list + this.total = re.data.total + this.queryParam.pageSize = re.data.pageSize + this.queryParam.pageIndex = re.data.pageNum this.listLoading = false }) }, @@ -184,6 +206,31 @@ parentGoods(obj) { console.log(obj, "寮圭獥缁勪欢鐨勮〃鍗曞��"); }, + showQuestion (row) { + let _this = this + this.questionShow.dialog = true + this.questionShow.loading = true + questionApi.select(row.id).then(re => { + _this.questionShow.qType = re.data.questionType + _this.questionShow.question = re.data + _this.questionShow.loading = false + }) + }, + editQuestion (row) { + let url = this.enumFormat(this.editUrlEnum, row.questionType) + this.$router.push({ path: url, query: { id: row.id } }) + }, + deleteQuestion (row) { + let _this = this + questionApi.deleteQuestion(row.id).then(re => { + if (re.code === 1) { + _this.search() + _this.$message.success(re.message) + } else { + _this.$message.error(re.message) + } + }) + }, }, computed: { ...mapGetters('enumItem', ['enumFormat']), @@ -191,6 +238,7 @@ questionTypeEnum: state => state.exam.question.typeEnum, editUrlEnum: state => state.exam.question.editUrlEnum }), + ...mapGetters('exam', ['subjectEnumFormat']), ...mapState('exam', { subjects: state => state.subjects }) } }; -- Gitblit v1.8.0