mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/vue/learning-system-portal.git
synced 2025-12-10 03:16:42 +08:00
提交修改
This commit is contained in:
@@ -14,19 +14,11 @@
|
||||
</el-col> -->
|
||||
<el-col :span="4">
|
||||
<el-select v-model="params.type" clearable placeholder="类型" >
|
||||
<el-option
|
||||
v-for="item in optionsList"
|
||||
:key="item.value"
|
||||
:label="item.label"
|
||||
:value="item.value">
|
||||
</el-option>
|
||||
</el-select>
|
||||
<el-option v-for="item in optionsList" :key="item.value" :label="item.label" :value="item.value"> </el-option>
|
||||
</el-select>
|
||||
</el-col>
|
||||
<el-col :span="3">
|
||||
<el-input style="margin-left:10px"
|
||||
v-model="params.title"
|
||||
placeholder="题干"
|
||||
clearable></el-input>
|
||||
<el-input style="margin-left:10px" v-model="params.title" placeholder="题干" clearable></el-input>
|
||||
</el-col>
|
||||
<el-col :span="17" style="display:flex;justify-content: space-between;">
|
||||
<div style="flex: 1;">
|
||||
@@ -81,8 +73,7 @@
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<div v-if="tableData.length > 0" style="text-align: center;margin-top:70px">
|
||||
<el-pagination
|
||||
background
|
||||
<el-pagination background
|
||||
@size-change="handleSizeChange"
|
||||
@current-change="handleCurrentChange"
|
||||
:current-page="pageIndex"
|
||||
@@ -93,11 +84,10 @@
|
||||
</el-pagination>
|
||||
</div>
|
||||
</el-main>
|
||||
<el-dialog :title="isAdd ? '新建试题' : '编辑试题'" :visible.sync="addQuestionDialog">
|
||||
<span style=" font-weight: 700; font-size: 14px; margin-left: 42px; margin-right: 10px; ">类型</span>
|
||||
<el-radio-group
|
||||
v-model="question.type"
|
||||
:disabled="question.id != null">
|
||||
<el-dialog :title="isAdd ? '新建试题' : '编辑试题'" :visible.sync="addQuestionDialog" width="700px">
|
||||
<div >
|
||||
<span style="font-weight: 700; font-size: 14px; margin-left: 42px; margin-right: 10px;">类型</span>
|
||||
<el-radio-group v-model="question.type" :disabled="question.id != null">
|
||||
<el-radio :label="1">单选</el-radio>
|
||||
<el-radio :label="2">多选</el-radio>
|
||||
<el-radio :label="3">判断题</el-radio>
|
||||
@@ -105,45 +95,36 @@
|
||||
<div v-if="question.type == 1 || question.type == 2">
|
||||
<div style="padding-top: 10px; overflow: auto">
|
||||
<div>
|
||||
<el-form
|
||||
size="mini"
|
||||
label-width="80px"
|
||||
:model="question"
|
||||
ref="questionForm"
|
||||
:rules="questionRules">
|
||||
<el-form size="mini" label-width="80px" :model="question" ref="questionForm" :rules="questionRules">
|
||||
<!-- <el-form-item label="资源归属">
|
||||
<el-cascader v-model="ownership" :options="resOwnerListMap" :props="resourceProps"></el-cascader>
|
||||
</el-form-item> -->
|
||||
<el-form-item label="题干" prop="title">
|
||||
<el-input
|
||||
class="inputclass"
|
||||
type="textarea"
|
||||
:rows="3"
|
||||
maxlength="500"
|
||||
show-word-limit
|
||||
v-model="question.title"
|
||||
placeholder="请输入题干">
|
||||
</el-input>
|
||||
<el-upload
|
||||
class="upload-demo"
|
||||
:action="uploadImgUrl"
|
||||
:on-success="handleUploadSuccess"
|
||||
:on-remove="handleRemove"
|
||||
:before-remove="beforeRemove"
|
||||
:limit="1"
|
||||
:on-exceed="handleExceed"
|
||||
:file-list="fileList">
|
||||
<el-button size="small" type="primary">点击上传图片</el-button>
|
||||
<div slot="tip" class="el-upload__tip">只能上传jpg/png文件,且不超过500kb</div>
|
||||
</el-upload>
|
||||
<el-col :span="15">
|
||||
<el-input class="inputclass" type="textarea" :rows="5" maxlength="500" show-word-limit v-model="question.title" placeholder="请输入题干"></el-input>
|
||||
</el-col>
|
||||
<el-col :span="7">
|
||||
<div v-if="question.images" style="display: flex;padding-left: 10px;">
|
||||
<el-image :src="imageBaseUrl+question.images" style="width: 100px; height: 80px;margin: 2px;"></el-image>
|
||||
<el-button @click="deleteQImage" type="text">删除</el-button>
|
||||
</div>
|
||||
<div v-else style="padding-left: 10px;">
|
||||
<el-upload
|
||||
class="upload-drag"
|
||||
:action="uploadImgUrl"
|
||||
:on-success="handleUploadSuccess"
|
||||
:on-remove="handleRemove"
|
||||
:limit="1"
|
||||
:on-exceed="handleExceed">
|
||||
<el-button type="text">点击上传图片</el-button>
|
||||
<div slot="tip" class="el-upload__tip">jpg/png文件不超过500kb</div>
|
||||
</el-upload>
|
||||
</div>
|
||||
</el-col>
|
||||
</el-form-item>
|
||||
<div v-for="(o, i) in question.optionList" :key="i" >
|
||||
<div v-for="(opt, i) in question.optionList" :key="i" >
|
||||
<el-form-item :label="'选项' + (i + 1)">
|
||||
<el-input
|
||||
style="width: 300px; margin-right: 10px"
|
||||
v-model="question.optionList[i].content"
|
||||
placeholder="填写选择题的选项内容">
|
||||
</el-input>
|
||||
<el-input style="width: 300px; margin-right: 10px" v-model="opt.content" placeholder="填写选择题的选项内容"></el-input>
|
||||
<!-- <el-input
|
||||
v-if="question.type == 2"
|
||||
style="width: 80px; margin-right: 10px"
|
||||
@@ -155,35 +136,28 @@
|
||||
<el-upload
|
||||
class="upload-demo Optionsimage"
|
||||
:action="uploadImgUrl"
|
||||
:data=" curOption"
|
||||
:on-success="handleUploadOptionsSuccess"
|
||||
:data="opt"
|
||||
:before-upload="handleBeforeUploadOption"
|
||||
:on-success="(response)=>handleUploadOptionsSuccess(i,response)"
|
||||
:on-remove="handleRemove"
|
||||
:before-remove="beforeRemove"
|
||||
:limit="1"
|
||||
:on-exceed="handleExceed"
|
||||
:file-list="fileList"
|
||||
:file-list="opt.imgList"
|
||||
list-type="picture">
|
||||
<el-button style="padding-top:0;" type="text">点击上传图片</el-button>
|
||||
<!-- <div slot="tip" class="el-upload__tip">只能上传jpg/png文件,且不超过500kb</div> -->
|
||||
</el-upload>
|
||||
<!-- </div> -->
|
||||
<el-radio v-if="question.type == 1" v-model="question.optionList[i].isAnswer" @change="radioChange(i)" :label="true">正确</el-radio>
|
||||
<el-checkbox
|
||||
v-else
|
||||
v-model="question.optionList[i].isAnswer"
|
||||
style="width: 80px; margin-right: 10px">正确
|
||||
</el-checkbox>
|
||||
<el-radio v-if="question.type == 1" v-model="opt.isAnswer" @change="radioChange(i)" :label="true">正确</el-radio>
|
||||
<el-checkbox v-else v-model="opt.isAnswer" style="width: 80px; margin-right: 10px">正确</el-checkbox>
|
||||
<el-button type="text" @click="removeOption(i)">删除</el-button>
|
||||
</el-form-item>
|
||||
|
||||
</div>
|
||||
<center>
|
||||
<el-button type="text" @click="addOption">添加选项</el-button>
|
||||
</center>
|
||||
<el-form-item label="难度">
|
||||
<el-select
|
||||
v-model="question.difficulty"
|
||||
placeholder="请选择">
|
||||
<el-select v-model="question.difficulty" placeholder="请选择">
|
||||
<el-option
|
||||
v-for="item in difficultyOptions"
|
||||
:key="item.value"
|
||||
@@ -192,19 +166,10 @@
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="默认分" prop="defaultScore">
|
||||
<el-input
|
||||
type="number"
|
||||
v-model="question.defaultScore"
|
||||
placeholder="请输入默认分"></el-input>
|
||||
<el-input type="number" v-model="question.defaultScore" placeholder="请输入默认分"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="解析">
|
||||
<el-input
|
||||
v-model="question.analysis"
|
||||
placeholder="请输入解析"
|
||||
type="textarea"
|
||||
maxlength="200"
|
||||
show-word-limit
|
||||
:rows="3"></el-input>
|
||||
<el-input v-model="question.analysis" placeholder="请输入解析" type="textarea" maxlength="200" show-word-limit :rows="3"></el-input>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</div>
|
||||
@@ -216,61 +181,59 @@
|
||||
<div v-if="question.type == 3">
|
||||
<div style="padding-top: 10px; overflow: auto">
|
||||
<div>
|
||||
<el-form
|
||||
size="mini"
|
||||
label-width="80px"
|
||||
:model="question"
|
||||
ref="questionForm"
|
||||
:rules="questionRules">
|
||||
<el-form size="mini" label-width="80px" :model="question" ref="questionForm" :rules="questionRules">
|
||||
<!-- <el-form-item label="资源归属">
|
||||
<el-cascader v-model="ownership" :options="resOwnerListMap" :props="resourceProps" ></el-cascader>
|
||||
</el-form-item> -->
|
||||
<el-form-item label="题干" prop="title"
|
||||
><el-input
|
||||
type="textarea"
|
||||
:rows="3"
|
||||
v-model="question.title"
|
||||
placeholder="请输入题干"
|
||||
maxlength="500"
|
||||
show-word-limit
|
||||
></el-input
|
||||
></el-form-item>
|
||||
<el-form-item label="题干" prop="title">
|
||||
<el-col :span="15">
|
||||
<el-input class="inputclass" type="textarea" :rows="5" maxlength="500" show-word-limit v-model="question.title" placeholder="请输入题干"></el-input>
|
||||
</el-col>
|
||||
<el-col :span="7">
|
||||
<div v-if="question.images" style="display: flex;padding-left: 10px;">
|
||||
<el-image :src="imageBaseUrl+question.images" style="width: 100px; height: 80px;margin: 2px;"></el-image>
|
||||
<el-button @click="deleteQImage" type="text">删除</el-button>
|
||||
</div>
|
||||
<div v-else style="padding-left: 10px;">
|
||||
<el-upload
|
||||
class="upload-drag"
|
||||
:action="uploadImgUrl"
|
||||
:on-success="handleUploadSuccess"
|
||||
:on-remove="handleRemove"
|
||||
:limit="1"
|
||||
:on-exceed="handleExceed">
|
||||
<el-button type="text">点击上传图片</el-button>
|
||||
<div slot="tip" class="el-upload__tip">jpg/png文件不超过500kb</div>
|
||||
</el-upload>
|
||||
</div>
|
||||
</el-col>
|
||||
</el-form-item>
|
||||
<el-form-item label="正确/错误">
|
||||
<el-radio v-model="question.answer" :label="true"
|
||||
>正确</el-radio>
|
||||
<el-radio v-model="question.answer" :label="false"
|
||||
>错误</el-radio>
|
||||
<el-radio v-model="question.answer" :label="true">正确</el-radio>
|
||||
<el-radio v-model="question.answer" :label="false">错误</el-radio>
|
||||
</el-form-item>
|
||||
<el-form-item label="难度">
|
||||
<el-select
|
||||
v-model="question.difficulty"
|
||||
placeholder="请选择">
|
||||
<el-select v-model="question.difficulty" placeholder="请选择">
|
||||
<el-option
|
||||
v-for="item in difficultyOptions"
|
||||
:key="item.value"
|
||||
:label="item.label"
|
||||
:value="item.value"
|
||||
></el-option>
|
||||
:value="item.value" ></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<!-- <el-form-item label="知识点"><el-input v-model="question.dian" placeholder="请输入知识点"></el-input></el-form-item> -->
|
||||
<el-form-item label="默认分" prop="defaultScore"
|
||||
><el-input
|
||||
type="number"
|
||||
v-model="question.defaultScore"
|
||||
placeholder="请输入默认分"
|
||||
></el-input
|
||||
></el-form-item>
|
||||
<el-form-item label="解析"
|
||||
><el-input
|
||||
<el-form-item label="默认分" prop="defaultScore">
|
||||
<el-input type="number" v-model="question.defaultScore"placeholder="请输入默认分"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="解析">
|
||||
<el-input
|
||||
v-model="question.analysis"
|
||||
placeholder="请输入解析"
|
||||
type="textarea"
|
||||
:rows="3"
|
||||
maxlength="200"
|
||||
show-word-limit
|
||||
></el-input
|
||||
></el-form-item>
|
||||
show-word-limit></el-input>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</div>
|
||||
<div style="text-align: right">
|
||||
@@ -278,6 +241,7 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</el-dialog>
|
||||
<el-dialog title="查看试题" append-to-body :visible.sync="viewVolumeShow" width="40%" custom-class="g-dialog">
|
||||
<div style="padding: 10px; font-size: 20px">
|
||||
@@ -323,6 +287,7 @@ import { numberToLetter} from "../../utils/tools.js";
|
||||
import { mapGetters,mapActions} from 'vuex';
|
||||
import fileUpload from '@/components/FileUpload/index.vue';
|
||||
import { setTimeout } from 'timers';
|
||||
import { getToken } from "@/utils/token";
|
||||
// import {resOwnerIndexName} from '@/utils/type.js';
|
||||
const questionData = {
|
||||
type: 1,
|
||||
@@ -335,10 +300,10 @@ const questionData = {
|
||||
images:"",
|
||||
statue: 0,
|
||||
optionList: [
|
||||
{ content: "", score: "", isAnswer: false ,images:""},
|
||||
{ content: "", score: "", isAnswer: false ,images:""},
|
||||
{ content: "", score: "", isAnswer: false ,images:""},
|
||||
{ content: "", score: "", isAnswer: false ,images:""},
|
||||
{ content: "", score: "", isAnswer: false ,images:"",imgList:[]},
|
||||
{ content: "", score: "", isAnswer: false ,images:"",imgList:[]},
|
||||
{ content: "", score: "", isAnswer: false ,images:"",imgList:[]},
|
||||
{ content: "", score: "", isAnswer: false ,images:"",imgList:[]},
|
||||
],
|
||||
// resSysId: [], // 试题目录
|
||||
difficulty: "", // 难度
|
||||
@@ -354,6 +319,10 @@ export default {
|
||||
return {
|
||||
curOption:[],
|
||||
uploadImgUrl: process.env.VUE_APP_BASE_API + "/xboe/sys/xuploader/file/upload", // 上传的图片服务器地址
|
||||
imageBaseUrl:process.env.VUE_APP_FILE_BASE_URL,
|
||||
headers: {
|
||||
'XBOE-Access-Token': getToken(),
|
||||
},
|
||||
fileList:[],
|
||||
resOwnerListMap: [],
|
||||
// resOwnerName: resOwnerIndexName,
|
||||
@@ -363,18 +332,9 @@ export default {
|
||||
viewVolumeShow: false,
|
||||
isAdd: false,
|
||||
optionsList: [
|
||||
{
|
||||
value: "1",
|
||||
label: "单选",
|
||||
},
|
||||
{
|
||||
value: "2",
|
||||
label: "多选",
|
||||
},
|
||||
{
|
||||
value: "3",
|
||||
label: "判断",
|
||||
},
|
||||
{value: "1",label: "单选"},
|
||||
{value: "2",label: "多选"},
|
||||
{value: "3",label: "判断"},
|
||||
],
|
||||
inputValue: "",
|
||||
params: { type: "", resSysId: "", title: "", ownership: [] },
|
||||
@@ -383,24 +343,12 @@ export default {
|
||||
count: 0,
|
||||
pageIndex: 1,
|
||||
url: `${this.webBaseUrl}/temp/exam.png`,
|
||||
resourceProps: {
|
||||
value: "code",
|
||||
label: "name",
|
||||
},
|
||||
resourceProps: {value: "code",label: "name"},
|
||||
question: questionData,
|
||||
difficultyOptions: [
|
||||
{
|
||||
value: 1,
|
||||
label: "容易",
|
||||
},
|
||||
{
|
||||
value: 2,
|
||||
label: "中等",
|
||||
},
|
||||
{
|
||||
value: 3,
|
||||
label: "困难",
|
||||
},
|
||||
{value: 1,label: "容易"},
|
||||
{value: 2,label: "中等"},
|
||||
{value: 3,label: "困难"},
|
||||
],
|
||||
addQuestionDialog: false,
|
||||
questionRules: {
|
||||
@@ -415,24 +363,29 @@ export default {
|
||||
this.loadData(1);
|
||||
},
|
||||
mounted() {
|
||||
|
||||
|
||||
this.getResOwnerTree().then(rs=>{
|
||||
this.resOwnerListMap=rs;
|
||||
});
|
||||
},
|
||||
methods: {
|
||||
handleUploadOptionsSuccess(res){
|
||||
this.curOption.push(res.result.filePath);
|
||||
this.question.optionList[0].images = this.curOption[0];
|
||||
this.question.optionList[1].images = this.curOption[1];
|
||||
this.question.optionList[2].images = this.curOption[2];
|
||||
this.question.optionList[3].images = this.curOption[3];
|
||||
console.log(this.question)
|
||||
handleBeforeUploadOption(file){
|
||||
//上传前的处理,与data关联
|
||||
console.log(file);
|
||||
return true;
|
||||
},
|
||||
handleUploadOptionsSuccess(optIdx,res){
|
||||
console.log(optIdx,'optIdx');
|
||||
console.log(res,'res');
|
||||
this.question.optionList[optIdx].images=res.result.filePath;
|
||||
this.question.optionList[optIdx].imgList=[
|
||||
{url:res.result.httpPath},
|
||||
]
|
||||
},
|
||||
handleUploadSuccess(res) {
|
||||
console.log(res.result.filePath);
|
||||
questionData.images = res.result.filePath;
|
||||
console.log(questionData.images)
|
||||
this.question.images=res.result.filePath;
|
||||
|
||||
},
|
||||
handleRemove(file, fileList) {
|
||||
console.log(file, fileList);
|
||||
@@ -641,9 +594,8 @@ export default {
|
||||
},
|
||||
editQuestion(row) {
|
||||
this.isAdd = false;
|
||||
examQuestionApi
|
||||
.detail(row.id)
|
||||
.then((res) => {
|
||||
let $this=this;
|
||||
examQuestionApi.detail(row.id).then((res) => {
|
||||
if (res.status == 200) {
|
||||
this.addQuestionDialog = true;
|
||||
this.question = res.result;
|
||||
@@ -661,9 +613,16 @@ export default {
|
||||
if (this.question.optionList == null) {
|
||||
this.question.optionList = [];
|
||||
}
|
||||
this.question.optionList.forEach(opt=>{
|
||||
if(opt.images){
|
||||
opt.imgList=[{url:this.imageBaseUrl+opt.images}];
|
||||
}else{
|
||||
opt.imgList=[];
|
||||
}
|
||||
|
||||
})
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
}).catch((err) => {
|
||||
this.$message({ type: "error", message: err });
|
||||
});
|
||||
},
|
||||
@@ -674,6 +633,10 @@ export default {
|
||||
this.addQuestionDialog = true;
|
||||
this.question.type = type;
|
||||
},
|
||||
deleteQImage(){
|
||||
this.question.images='';
|
||||
//同时后吧删除图片,后续要补上
|
||||
},
|
||||
addOption() {
|
||||
if (this.question.optionList.length < 10) {
|
||||
this.question.optionList.push({ content: "", score: "", isAnswer: 0 ,images:""});
|
||||
@@ -757,4 +720,16 @@ export default {
|
||||
flex: 12;
|
||||
}
|
||||
}
|
||||
.upload-drag{
|
||||
.el-uoload{
|
||||
.el-upload-dragger{
|
||||
height: 50px;
|
||||
width: 120px
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
::v-deep .el-upload-dragger{
|
||||
height: 50px;
|
||||
}
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user