From ff46cc24356b2cd2f23ab3cd7892e61b682d2b8c Mon Sep 17 00:00:00 2001
From: 祖安之光 <11848914+light-of-zuan@user.noreply.gitee.com>
Date: Mon, 11 May 2026 10:03:42 +0800
Subject: [PATCH] 主线提交
---
src/views/onlineEducation/questionBankManagement/questionManage/components/questionDialog.vue | 175 ++++++++++++++++++++++++++++++++++++++++++++--------------
1 files changed, 133 insertions(+), 42 deletions(-)
diff --git a/src/views/onlineEducation/questionBankManagement/questionManage/components/questionDialog.vue b/src/views/onlineEducation/questionBankManagement/questionManage/components/questionDialog.vue
index a4a5ab9..92a67f4 100644
--- a/src/views/onlineEducation/questionBankManagement/questionManage/components/questionDialog.vue
+++ b/src/views/onlineEducation/questionBankManagement/questionManage/components/questionDialog.vue
@@ -3,12 +3,14 @@
<el-dialog
v-model="dialogVisible"
:title="title"
- width="50%"
+ width="750px"
:before-close="handleClose"
+ :close-on-press-escape="false"
+ :close-on-click-modal="false"
>
<el-form :model="state.form" size="default" ref="busRef" :rules="state.formRules" label-width="150px" >
<el-form-item label="题目类型:" prop="questionType">
- <el-select v-model="state.form.questionType" placeholder="请选择题型" style="width: 100%">
+ <el-select v-model="state.form.questionType" placeholder="请选择题型" style="width: 100%" @change="changeType">
<el-option
v-for="item in state.questionTypeList"
:key="item.id"
@@ -20,13 +22,16 @@
</el-form-item>
<el-form-item label="归属题库:" prop="bankName">
<el-select
+ clearable
v-model="state.form.bankName"
+ filterable
+ remote
+ reserve-keyword
+ placeholder="请输入题库名称"
+ remote-show-suffix
+ :remote-method="getBankList"
style="width: 100%"
- v-loadMoreNew:[reselect]="handleScroll"
- :popper-class="reselect.name"
@change="selectValue"
- class="item-width"
- placeholder="请选择题库"
>
<el-option
v-for="item in state.bankList"
@@ -35,36 +40,54 @@
:value="item.name"
/>
</el-select>
+<!-- <el-select-->
+<!-- v-model="state.form.bankName"-->
+<!-- style="width: 100%"-->
+<!-- v-loadMoreNew:[reselect]="handleScroll"-->
+<!-- :popper-class="reselect.name"-->
+<!-- @change="selectValue"-->
+<!-- class="item-width"-->
+<!-- placeholder="请选择题库"-->
+<!-- >-->
+<!-- <el-option-->
+<!-- v-for="item in state.bankList"-->
+<!-- :key="item.id"-->
+<!-- :label="item.name"-->
+<!-- :value="item.name"-->
+<!-- />-->
+<!-- </el-select>-->
</el-form-item>
<el-form-item label="题目内容:" prop="title">
<el-input v-model.trim="state.form.title" type="textarea" placeholder="请输入题目内容"></el-input>
</el-form-item>
- <el-form-item label="选项:" prop="content">
+ <el-form-item label="选项:" prop="content" v-if="state.form.questionType != 4">
<div style="display: flex;flex-direction: column;width: 100%">
- <el-button type="primary" @click="addOption" size="default" style="width: 65px;margin-bottom: 15px">添加</el-button>
+ <el-button :disabled="state.form.questionType ===3 || state.form.questionType==null " type="primary" @click="addOption" size="default" style="width: 65px;margin-bottom: 15px">添加</el-button>
<div v-for="(item,index) in state.optionItem.items" :key="index" style="width: 100%">
<div style="display: flex;align-items: center">
<span>{{String.fromCharCode(index + 65)}}</span>
- <el-input type="textarea" v-model="state.optionItem.items[index].content" placeholder="请输入选项内容" style="width: 100%;margin-left: 20px;margin-bottom: 10px"></el-input>
- <Delete style="width: 15px; height: 15px; margin-left: 8px;color: #ed5565" @click="delOption(index)" />
+ <el-input :disabled="state.form.questionType ===3" type="textarea" v-model="state.optionItem.items[index].content" placeholder="请输入选项内容" style="width: 100%;margin-left: 20px;margin-bottom: 10px"></el-input>
+ <Delete v-if="state.form.questionType !==3" style="width: 15px; height: 15px; margin-left: 8px;color: #ed5565" @click="delOption(index)" />
</div>
</div>
</div>
</el-form-item>
- <el-form-item label="解析:" prop="answer">
- <el-input type="textarea" v-model="state.optionItem.analyze" placeholder="请输入题目解析" style="width: 100%;margin-bottom: 10px"></el-input>
- </el-form-item>
+
<el-form-item label="正确答案:" prop="answer">
<el-radio-group v-model="state.form.answer" v-if="state.form.questionType === 1 || state.form.questionType === 3">
<div v-for="(item,index) in state.optionItem.items">
<el-radio :label="String.fromCharCode(index + 65)" style="margin-left: 20px">{{String.fromCharCode(index + 65)}}</el-radio>
</div>
</el-radio-group>
- <el-checkbox-group v-model="state.checkList" v-if="state.form.questionType === 2" style="display: flex" >
+ <el-checkbox-group v-model="state.checkList" v-if="state.form.questionType === 2" style="display: flex" @change="changeCheck">
<div v-for="(item,index) in state.optionItem.items">
<el-checkbox :label="String.fromCharCode(index + 65)" style="margin-left: 20px;">{{String.fromCharCode(index + 65)}}</el-checkbox>
</div>
</el-checkbox-group>
+ <el-input v-if="state.form.questionType === 4" v-model="state.form.answer" type="textarea" placeholder="请输入正确答案"></el-input>
+ </el-form-item>
+ <el-form-item label="解析:" >
+ <el-input type="textarea" v-model="state.optionItem.analyze" placeholder="请输入题目解析" style="width: 100%;margin-bottom: 10px"></el-input>
</el-form-item>
</el-form>
<template #footer>
@@ -117,7 +140,7 @@
questionType: [{required: true, trigger: "blur", message: '请选择题目类型'}],
bankName: [{required: true, trigger: "blur", message: '请选择归属题库'}],
title: [{required: true, trigger: "blur", message: '请输入题目内容'}],
- // answer: [{required: true, trigger: "blur", message: '请选择正确答案'}],
+ answer: [{required: true, trigger: "blur", message: '请选择正确答案'}],
},
classifyList: [],
isAdmin: false,
@@ -136,6 +159,10 @@
{
id: 3,
name: '判断题'
+ },
+ {
+ id: 4,
+ name: '简答题'
}
],
optionItem: {
@@ -159,6 +186,10 @@
}
})
}
+const changeCheck = (val) => {
+ console.log('val',val)
+ state.form.answer = val.join(',')
+}
const addOption = () => {
@@ -171,10 +202,11 @@
}
const delOption = (val) => {
state.optionItem.items.splice(val,1)
+ state.form.answer = ''
console.log(" state.optionItem.items.", state.optionItem.items)
}
const openDialog = async (type, value) => {
- await loadMoreBankData();
+ await getBankList('');
const userInfo = JSON.parse(Cookies.get('userInfo'))
console.log("userInfo",userInfo)
if(userInfo.userType === 0){
@@ -202,6 +234,32 @@
dialogVisible.value = true;
}
+const getBankList = async (val)=>{
+ if(val != ""){
+ const queryParams = {
+ name: val
+ }
+ const res = await getQuestionBank(queryParams)
+ if (res.code == 200) {
+ state.bankList = res.data.list
+
+ } else {
+ ElMessage.warning(res.message)
+ }
+ }else {
+ const queryParams = {
+ pageNum: 1,
+ pageSize: 10
+ }
+ const res = await getQuestionBank(queryParams)
+ if (res.code == 200) {
+ state.bankList = res.data.list
+ } else {
+ ElMessage.warning(res.message)
+ }
+ }
+}
+
const handleScroll = () => {
if(state.bankPageNum >= state.hasMoreItems) return
state.bankPageNum++;
@@ -225,24 +283,31 @@
const onSubmit = async () => {
+ console.log(" state.form", state.form)
const valid = await busRef.value.validate();
if(valid){
if(title.value === '新增'){
const {id,bankName, ...data} = JSON.parse(JSON.stringify(state.form))
- data.answer = data.questionType === 1 || data.questionType === 3 ? data.answer : state.checkList.join(',')
- // data.content = data.questionType === 1 ? JSON.stringify(state.singleQuestion) : data.questionType === 2 ? JSON.stringify(state.multiQuestion) : JSON.stringify(state.judgeQuestion)
- const options = state.optionItem.items.map((op,index) => {
- return {
- prefix: String.fromCharCode(index + 65),
- content: op.content,
- }
- })
- data.content = JSON.stringify(
- {
- analyze: state.optionItem.analyze,
- items: options
+ data.answer = data.questionType === 1 || data.questionType === 3 || data.questionType === 4? data.answer : state.checkList.join(',')
+ if(data.questionType !== 4){
+ const options = state.optionItem.items.map((op,index) => {
+ return {
+ prefix: String.fromCharCode(index + 65),
+ content: op.content,
}
- )
+ })
+ data.content = JSON.stringify(
+ {
+ analyze: state.optionItem.analyze,
+ items: options
+ }
+ )
+ }else {
+ data.content = JSON.stringify(
+ {
+ analyze: state.optionItem.analyze,
+ })
+ }
console.log('state.form',data)
const res = await addQuestion(data)
if(res.code === 200){
@@ -259,20 +324,26 @@
dialogVisible.value = false;
}else if(title.value === '编辑'){
const {bankName,...data} = JSON.parse(JSON.stringify(state.form))
- data.answer = data.questionType === 1 || data.questionType === 3 ? data.answer : state.checkList.join(',')
- // data.content = data.questionType === 1 ? JSON.stringify(state.singleQuestion) : data.questionType === 2 ? JSON.stringify(state.multiQuestion) : JSON.stringify(state.judgeQuestion)
- const options = state.optionItem.items.map((op,index) => {
- return {
- prefix: String.fromCharCode(index + 65),
- content: op.content,
- }
- })
- data.content = JSON.stringify(
- {
- analyze: state.optionItem.analyze,
- items: options
+ data.answer = data.questionType === 1 || data.questionType === 3 || data.questionType === 4 ? data.answer : state.checkList.join(',')
+ if(data.questionType !== 4){
+ const options = state.optionItem.items.map((op,index) => {
+ return {
+ prefix: String.fromCharCode(index + 65),
+ content: op.content,
}
- )
+ })
+ data.content = JSON.stringify(
+ {
+ analyze: state.optionItem.analyze,
+ items: options
+ }
+ )
+ }else {
+ data.content = JSON.stringify(
+ {
+ analyze: state.optionItem.analyze,
+ })
+ }
const res = await editQuestion(data)
if(res.code === 200){
ElMessage({
@@ -289,7 +360,27 @@
}
}
}
+const changeType = () => {
+ state.optionItem = {
+ analyze: '',
+ items: []
+ }
+ if(state.form.questionType === 3) {
+ state.optionItem.items = [
+ {
+ prefix: 'A',
+ content: '是'
+ },
+ {
+ prefix: 'B',
+ content: '否'
+ }
+ ]
+ }
+
+
+}
const handleClose = () => {
busRef.value.clearValidate();
reset();
--
Gitblit v1.9.2