mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/vue/learning-system-portal.git
synced 2025-12-11 20:06:44 +08:00
732 lines
28 KiB
Vue
732 lines
28 KiB
Vue
<template>
|
||
<div class="examManger">
|
||
<el-container>
|
||
<el-header style="height:70px;padding: 12px 20px 10px 20px;" >
|
||
<el-row>
|
||
<!-- <el-col :span="4">
|
||
<el-cascader
|
||
:options="resOwnerListMap"
|
||
v-model="params.ownership"
|
||
placeholder="资源归属"
|
||
clearable
|
||
:props="resourceProps">
|
||
</el-cascader>
|
||
</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-col>
|
||
<el-col :span="3">
|
||
<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;">
|
||
<el-button type="primary" @click="getsearch(1)" style="margin-left: 20px" icon="el-icon-search" >搜索</el-button>
|
||
<el-button icon="el-icon-refresh-right" type="primary" @click="reset"> 重置 </el-button>
|
||
<el-button type="primary" @click="addQuestion(1)" style="margin-left: 10px" icon="el-icon-plus"> 添加 </el-button>
|
||
<div style="display: inline-block;margin-left: 10px;">
|
||
<file-upload dir="files" text="导入" :loading="true" size="medium" url="/xboe/m/exam/question/import"
|
||
:isShowTip="false" @success="uploadFile" @remove="removeFile" >
|
||
</file-upload>
|
||
</div>
|
||
</div>
|
||
<div style="display: inline-block;margin-top: 10px;"><el-link @click="downloadTemplate">下载模板文件</el-link></div>
|
||
</el-col>
|
||
</el-row>
|
||
</el-header>
|
||
<el-container style="margin:0 10px;">
|
||
<el-main>
|
||
<el-table border stripe :data="tableData" style="width: 100%">
|
||
<el-table-column label="序号" type="index" width="50"></el-table-column>
|
||
<el-table-column prop="title" label="题干" show-overflow-tooltip>
|
||
<template slot-scope="scope">
|
||
<span class="previewStyle" @click="viewTopic(scope.row)">{{ scope.row.title }}</span>
|
||
</template>
|
||
</el-table-column>
|
||
<!-- <el-table-column prop="resSysId" label="资源归属" width="240px" show-overflow-tooltip>
|
||
<template slot-scope="scope">
|
||
<span>{{resOwnerName(scope.row.resOwner1)}}</span>
|
||
<span v-if="scope.row.resOwner2 != ''">/{{resOwnerName(scope.row.resOwner2)}}</span>
|
||
<span v-if="scope.row.resOwner3 != ''">/{{resOwnerName(scope.row.resOwner3)}}</span>
|
||
</template>
|
||
</el-table-column> -->
|
||
<el-table-column prop="type" label="类型" width="70px">
|
||
<template slot-scope="scope">
|
||
{{ scope.row.type == 1 ? "单选" : scope.row.type == 2 ? "多选" : scope.row.type == 3 ? "判断题" : "" }}
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column prop="sysCreateBy" label="创建者" width="70px" ></el-table-column>
|
||
<el-table-column prop="sysCreateTime" label="创建时间" width="180px" ></el-table-column>
|
||
<el-table-column label="操作" width="140px" fixed="right">
|
||
<template slot-scope="scope">
|
||
<el-button type="text" icon="el-icon-edit" @click="editQuestion(scope.row)" >编辑</el-button>
|
||
<el-button type="text" icon="el-icon-delete" @click="deleteQuestion(scope.row)" >删除</el-button>
|
||
</template>
|
||
</el-table-column>
|
||
</el-table>
|
||
<div v-if="tableData.length > 0" style="text-align: center;margin-top:70px">
|
||
<el-pagination background
|
||
@size-change="handleSizeChange"
|
||
@current-change="handleCurrentChange"
|
||
:current-page="pageIndex"
|
||
:page-sizes="[10, 20, 50, 100]"
|
||
:page-size="pageSize"
|
||
layout="total, sizes, prev, pager, next, jumper"
|
||
:total="count">
|
||
</el-pagination>
|
||
</div>
|
||
</el-main>
|
||
<el-dialog :title="isAdd ? '新建试题' : '编辑试题'" :visible.sync="addQuestionDialog" width="750px" top="10vh">
|
||
<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>
|
||
</el-radio-group>
|
||
<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-item label="资源归属">
|
||
<el-cascader v-model="ownership" :options="resOwnerListMap" :props="resourceProps"></el-cascader>
|
||
</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">
|
||
<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="(opt, i) in question.optionList" :key="i" >
|
||
<el-form-item :label="'选项' + (i + 1)">
|
||
<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"
|
||
v-model="question.optionList[i].score"
|
||
placeholder="得分"></el-input> -->
|
||
<!-- v-else -->
|
||
<!-- <div class="optionbox"> -->
|
||
|
||
<el-upload
|
||
class="upload-demo Optionsimage"
|
||
:action="uploadImgUrl"
|
||
:data="opt"
|
||
:on-success="(response)=>handleUploadOptionsSuccess(i,response)"
|
||
:on-remove="handleRemove"
|
||
:before-remove="beforeRemove"
|
||
:limit="1"
|
||
:file-list="opt.imgList"
|
||
list-type="picture">
|
||
<el-button style="padding-top:0;" type="text">点击上传图片</el-button>
|
||
</el-upload>
|
||
<!-- </div> -->
|
||
<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-col :span="12">
|
||
<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>
|
||
</el-select>
|
||
</el-col>
|
||
<el-col :span="12">
|
||
<el-form-item label="默认分" prop="defaultScore">
|
||
<el-input type="number" v-model="question.defaultScore" placeholder="请输入默认分"></el-input>
|
||
</el-form-item>
|
||
</el-col>
|
||
</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-form-item>
|
||
</el-form>
|
||
</div>
|
||
<div style="text-align: right">
|
||
<el-button @click="handleAdd" type="primary">提交</el-button>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<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-item label="资源归属">
|
||
<el-cascader v-model="ownership" :options="resOwnerListMap" :props="resourceProps" ></el-cascader>
|
||
</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">
|
||
<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-form-item>
|
||
<el-form-item label="难度">
|
||
<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>
|
||
</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
|
||
v-model="question.analysis"
|
||
placeholder="请输入解析"
|
||
type="textarea"
|
||
:rows="3"
|
||
maxlength="200"
|
||
show-word-limit></el-input>
|
||
</el-form-item>
|
||
</el-form>
|
||
</div>
|
||
<div style="text-align: right">
|
||
<el-button @click="handleAdd" type="primary">提交</el-button>
|
||
</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">
|
||
<div v-if="question.type == 1">
|
||
<div>【单选题】{{question.title}}({{question.defaultScore}}分)</div>
|
||
<div v-for="(item, i) in question.optionList" :key="i">
|
||
<div>
|
||
<span style="width: 20px;color:green;display: inline-block;">{{item.isAnswer? '√':''}} </span>
|
||
<span>{{numberToLetter(i + 1)}}:</span>
|
||
<span>{{item.content}}</span>
|
||
</div>
|
||
<div v-if="item.images" style="padding-left: 50px;">
|
||
<span ><el-image :src="imageBaseUrl+item.images" style="width: 60px;height: 50px;"></el-image> </span>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div v-if="question.type == 2">
|
||
<div>【多选题】{{question.title}}({{question.defaultScore}}分)</div>
|
||
<div v-for="(item, i) in question.optionList" :key="i">
|
||
<div>
|
||
<span style="width: 20px;color:green;display: inline-block;">{{item.isAnswer? '√':''}} </span>
|
||
<span>{{numberToLetter(i + 1)}}:</span>
|
||
<span>{{item.content}}</span>
|
||
</div>
|
||
<div v-if="item.images" style="padding-left: 50px;">
|
||
<span ><el-image :src="imageBaseUrl+item.images" style="width: 60px;height: 50px;"></el-image> </span>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div v-if="question.type == 3">
|
||
<div>【判断题】{{question.title}}({{question.defaultScore}}分)</div>
|
||
<el-radio disabled :value="question.answer" :label="true" style="margin-right: 0px;"> </el-radio><span style="margin-right: 30px;">正确</span>
|
||
<el-radio disabled :value="question.answer" :label="false" style="margin-right: 0px;"> </el-radio><span>错误</span>
|
||
</div>
|
||
</div>
|
||
<span slot="footer" class="dialog-footer"><el-button @click="viewVolumeShow = false">关闭</el-button></span>
|
||
</el-dialog>
|
||
</el-container>
|
||
</el-container>
|
||
<!-- <div style="display:none"> -->
|
||
|
||
<!-- </div> -->
|
||
</div>
|
||
</template>
|
||
|
||
<script>
|
||
// import { resourceAttribution } from '../../data/resource';
|
||
import resSysApi from "@/api/modules/resowner";
|
||
// import examQuestionApi from "@/api/modules/examquestion";
|
||
import examQuestionApi from "@/api/modules/question";
|
||
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,
|
||
type: "", // 类型
|
||
code: "1",
|
||
title: "",
|
||
project: "",
|
||
createPerson: "",
|
||
moduel: "",
|
||
images:"",
|
||
statue: 0,
|
||
optionList: [
|
||
{ 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: "", // 难度
|
||
defaultScore: "", // 默认分
|
||
analysis: "", // 解析
|
||
};
|
||
export default {
|
||
components: {fileUpload},
|
||
computed: {
|
||
...mapGetters(['resOwnerMap','sysTypeMap']),
|
||
},
|
||
data() {
|
||
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,
|
||
ownership: [],
|
||
pageSize: 10,
|
||
testRadio: "",
|
||
viewVolumeShow: false,
|
||
isAdd: false,
|
||
optionsList: [
|
||
{value: "1",label: "单选"},
|
||
{value: "2",label: "多选"},
|
||
{value: "3",label: "判断"},
|
||
],
|
||
inputValue: "",
|
||
params: { type: "", resSysId: "", title: "", ownership: [] },
|
||
defaultProps: { children: "children", label: "label" },
|
||
tableData: [],
|
||
count: 0,
|
||
pageIndex: 1,
|
||
url: `${this.webBaseUrl}/temp/exam.png`,
|
||
resourceProps: {value: "code",label: "name"},
|
||
question: questionData,
|
||
difficultyOptions: [
|
||
{value: 1,label: "容易"},
|
||
{value: 2,label: "中等"},
|
||
{value: 3,label: "困难"},
|
||
],
|
||
addQuestionDialog: false,
|
||
questionRules: {
|
||
type: [{ required: true, message: "请选择类型", trigger: "blur" }],
|
||
title: [{ required: true, message: "请输入题干", trigger: "blur" }],
|
||
},
|
||
};
|
||
},
|
||
created() {
|
||
// this.question = questionData;
|
||
//this.initResSys();
|
||
this.loadData(1);
|
||
},
|
||
mounted() {
|
||
|
||
this.getResOwnerTree().then(rs=>{
|
||
this.resOwnerListMap=rs;
|
||
});
|
||
},
|
||
methods: {
|
||
|
||
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);
|
||
this.question.images=res.result.filePath;
|
||
},
|
||
handleRemove(file, fileList) {
|
||
console.log(file, fileList);
|
||
//需要同时删除已上传的图片,后续完善要加上
|
||
},
|
||
beforeRemove(file, fileList) {
|
||
return this.$confirm(`您确定移除图片吗?`);
|
||
},
|
||
downloadTemplate(){
|
||
let fileName = "试题导入模板.xls";
|
||
let link = document.createElement('a'); //创建a标签
|
||
link.style.display = 'none'; //使其隐藏
|
||
link.download = this.webBaseUrl+'/template/test-question-template.xls';
|
||
link.setAttribute('target', '_blank');
|
||
link.href = this.webBaseUrl+'/template/test-question-template.xls'; //赋予文件下载地址
|
||
link.setAttribute('download', fileName); //设置下载属性 以及文件名
|
||
document.body.appendChild(link); //a标签插至页面中
|
||
link.click(); //强制触发a标签事件
|
||
document.body.removeChild(link);
|
||
},
|
||
uploadFile(file) {
|
||
this.loadData(1);
|
||
setTimeout(this.$message.warning('请耐心等待片刻,正在导入'), 2000 );
|
||
},
|
||
removeFile(file) {
|
||
|
||
},
|
||
radioChange(i) {
|
||
this.question.optionList.forEach((item, index)=>{
|
||
item.isAnswer = false;
|
||
if(i == index) {
|
||
item.isAnswer = true;
|
||
}
|
||
})
|
||
},
|
||
getsearch(){
|
||
this.params.pageIndex = 1;
|
||
this.loadData(1)
|
||
|
||
},
|
||
reset(){
|
||
this.params.ownership = [];
|
||
this.params.type = '';
|
||
this.params.title = '';
|
||
this.params.pageIndex = 1;
|
||
this.loadData(1)
|
||
},
|
||
...mapActions({
|
||
getResOwnerTree:'resOwner/getResOwnerTree',
|
||
loadResOwners:'resOwner/loadResOwners',
|
||
getSysTypeTree:'sysType/getSysTypeTree',
|
||
loadSysTypes:'sysType/loadSysTypes'
|
||
}),
|
||
resOwnerName(code){
|
||
if(code==''){return '';}
|
||
return this.resOwnerMap.get(code);
|
||
},
|
||
numberToLetter(x){
|
||
return numberToLetter(x);
|
||
},
|
||
handleSizeChange(val) {
|
||
this.pageSize = val;
|
||
this.pageIndex = 1;
|
||
this.loadData(1);
|
||
},
|
||
handleCurrentChange(val) {
|
||
this.pageIndex = val;
|
||
this.loadData(this.pageIndex);
|
||
},
|
||
loadData(pageIndex) {
|
||
this.pageIndex = pageIndex;
|
||
let ownership = [];
|
||
if (this.params.ownership.length != 0) {
|
||
ownership = this.params.ownership;
|
||
} else {
|
||
ownership = [];
|
||
}
|
||
examQuestionApi
|
||
.querylist({
|
||
pageIndex: this.pageIndex,
|
||
pageSize: this.pageSize,
|
||
title: this.params.title,
|
||
type: this.params.type,
|
||
resOwner1: ownership[0],
|
||
resOwner2: ownership[1],
|
||
resOwner3: ownership[2],
|
||
})
|
||
.then((res) => {
|
||
if (res.status == 200) {
|
||
const result = res.result;
|
||
this.tableData = result.list;
|
||
this.count = result.count;
|
||
}
|
||
})
|
||
.catch((err) => {
|
||
this.$message({ type: "error", message: "查询数据错误:" + err });
|
||
});
|
||
},
|
||
handleAdd() {
|
||
let isOk = true;
|
||
if(this.question.type == 3) {
|
||
if(this.question.answer != undefined) {
|
||
isOk = false;
|
||
}
|
||
} else {
|
||
this.question.optionList.forEach(item=>{
|
||
if(item.isAnswer == true) {
|
||
isOk = false;
|
||
}
|
||
})
|
||
}
|
||
if(isOk) {
|
||
this.$message.warning('请选择正确选项!');
|
||
return;
|
||
}
|
||
|
||
|
||
this.$refs.questionForm.validate((valid) => {
|
||
if (valid) {
|
||
this.question.resOwner1 = this.ownership[0];
|
||
this.question.resOwner2 = this.ownership[1];
|
||
this.question.resOwner3 = this.ownership[2];
|
||
if (this.question.id != null && this.question.id != "") {
|
||
examQuestionApi
|
||
.update(this.question)
|
||
.then((res) => {
|
||
if (res.status == 200) {
|
||
this.$message({ type: "success", message: "保存成功" });
|
||
this.addQuestionDialog = false;
|
||
this.loadData(1);
|
||
}
|
||
})
|
||
.catch((err) => {
|
||
this.$message({ type: "error", message: err });
|
||
});
|
||
} else {
|
||
if (this.question.type == 3) {
|
||
// 判断题没有optionList
|
||
this.question.optionList = [];
|
||
}
|
||
console.log(questionData,'llkk')
|
||
examQuestionApi
|
||
.save(this.question)
|
||
.then((res) => {
|
||
if (res.status == 200) {
|
||
this.$message({ type: "success", message: "保存成功" });
|
||
this.addQuestionDialog = false;
|
||
this.loadData(1);
|
||
}
|
||
})
|
||
.catch((err) => {
|
||
this.$message({ type: "error", message: err });
|
||
});
|
||
}
|
||
}
|
||
});
|
||
},
|
||
viewTopic(row) {
|
||
examQuestionApi
|
||
.detail(row.id)
|
||
.then((res) => {
|
||
if (res.status == 200) {
|
||
this.viewVolumeShow = true;
|
||
this.question = res.result;
|
||
if (res.result.answer === "false") this.question.answer = false;
|
||
if (res.result.answer === "true") this.question.answer = true;
|
||
if (this.question.optionList == null) {
|
||
this.question.optionList = [];
|
||
}
|
||
}
|
||
})
|
||
.catch((err) => {
|
||
this.$message({ type: "error", message: err });
|
||
});
|
||
},
|
||
deleteQuestion(row) {
|
||
this.$confirm("此操作将数据永久删除, 是否继续?", "提示", {
|
||
confirmButtonText: "确定",
|
||
cancelButtonText: "取消",
|
||
type: "warning",
|
||
})
|
||
.then(() => {
|
||
examQuestionApi
|
||
.del(row.id)
|
||
.then((res) => {
|
||
if (res.status == 200) {
|
||
this.loadData(this.pageIndex);
|
||
this.$message({
|
||
type: "success",
|
||
message: "删除成功!",
|
||
});
|
||
}
|
||
})
|
||
.catch((err) => {
|
||
this.$message({ type: "error", message: err });
|
||
});
|
||
})
|
||
.catch(() => {
|
||
this.$message({
|
||
type: "info",
|
||
message: "已取消删除",
|
||
});
|
||
});
|
||
},
|
||
editQuestion(row) {
|
||
this.isAdd = false;
|
||
let $this=this;
|
||
examQuestionApi.detail(row.id).then((res) => {
|
||
if (res.status == 200) {
|
||
this.addQuestionDialog = true;
|
||
this.question = res.result;
|
||
if (res.result.resOwner3) {
|
||
this.ownership = [
|
||
res.result.resOwner1,
|
||
res.result.resOwner2,
|
||
res.result.resOwner3,
|
||
];
|
||
} else {
|
||
this.ownership = [res.result.resOwner1, res.result.resOwner2];
|
||
}
|
||
if (res.result.answer === "false") this.question.answer = false;
|
||
if (res.result.answer === "true") this.question.answer = true;
|
||
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) => {
|
||
this.$message({ type: "error", message: err });
|
||
});
|
||
},
|
||
addQuestion(type) {
|
||
this.isAdd = true;
|
||
this.question = JSON.parse(JSON.stringify(questionData));
|
||
this.ownership = [];
|
||
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:""});
|
||
}
|
||
},
|
||
removeOption(i) {
|
||
if (this.question.optionList.length > 2) {
|
||
this.question.optionList.splice(i, 1);
|
||
}
|
||
},
|
||
},
|
||
};
|
||
</script>
|
||
|
||
<style scoped lang="scss">
|
||
::v-deep .el-upload-list__item-name{
|
||
display: none;
|
||
}
|
||
::v-deep .el-upload-list--picture .el-upload-list__item-thumbnail{
|
||
width: 60px !important;
|
||
height: 60px !important;
|
||
}
|
||
::v-deep .el-upload-list--picture .el-upload-list__item.is-success .el-upload-list__item-name{
|
||
display: none;
|
||
}
|
||
::v-deep .el-upload-list--picture .el-upload-list__item{
|
||
border: none !important;
|
||
}
|
||
::v-deep .el-upload-list__item-status-label{
|
||
display: none !important;
|
||
}
|
||
::v-deep .el-form-item--mini.el-form-item, .el-form-item--small.el-form-item{
|
||
margin-bottom: 37px !important;
|
||
}
|
||
.inputclass{
|
||
position: relative;
|
||
}
|
||
::v-deep .el-upload-list{
|
||
position: absolute !important;
|
||
// right: 10px !important;
|
||
// top:0 !important;
|
||
// height: 60px;
|
||
margin-top: -68px !important;
|
||
}
|
||
.optionbox{
|
||
float: right;
|
||
}
|
||
.Optionsimage{
|
||
margin-right: 28px;
|
||
margin-top: 0 !important;
|
||
display: inline-block;
|
||
height: 30px;
|
||
}
|
||
.upload-demo{
|
||
margin-top: 10px;
|
||
}
|
||
.svg-icon {
|
||
margin-right: 8px;
|
||
font-size: 19px;
|
||
padding-top: 0px;
|
||
|
||
// line-height: 36px;
|
||
// margin-top: 20px;
|
||
}
|
||
.el-aside {
|
||
padding: 0px 2px 10px 0px;
|
||
}
|
||
.el-main {
|
||
padding: 0px 10px;
|
||
}
|
||
.examManger {
|
||
// height: 430px;
|
||
// width: 100px;
|
||
display: flex;
|
||
justify-content: flex-start;
|
||
.left {
|
||
flex: 3;
|
||
margin-right: 10px;
|
||
}
|
||
.right {
|
||
flex: 12;
|
||
}
|
||
}
|
||
.upload-drag{
|
||
.el-uoload{
|
||
.el-upload-dragger{
|
||
height: 50px;
|
||
width: 120px
|
||
}
|
||
}
|
||
|
||
}
|
||
::v-deep .el-upload-dragger{
|
||
height: 50px;
|
||
}
|
||
</style>
|