Commit 0169dfed by 宋珺琪

多选题、修改不用cookie、

parent 23171b4a
...@@ -29,10 +29,13 @@ export default { ...@@ -29,10 +29,13 @@ export default {
}).then(res=>{ }).then(res=>{
let resData = res.data.data let resData = res.data.data
if(resData != null) { if(resData != null) {
this.$cookies.set("cname", resData.studentName) this.$router.push({
this.$cookies.set("cid", resData.studentId) path: '/answer?examCode=20190001',
this.$cookies.set("role", resData.role) query:{
this.$router.push({path: '/answer?examCode=20190001'}) cname:resData.studentName,
cid: resData.studentId,
role:resData.role
}})
} }
if(resData == null) { //错误提示 if(resData == null) { //错误提示
this.$message({ this.$message({
...@@ -49,4 +52,4 @@ export default { ...@@ -49,4 +52,4 @@ export default {
}, },
computed: mapState(["userInfo"]), computed: mapState(["userInfo"]),
} }
</script> </script>
\ No newline at end of file
...@@ -9,7 +9,17 @@ ...@@ -9,7 +9,17 @@
<li><i class="iconfont icon-menufold icon20" ref="toggle" @click="slider_flag = !slider_flag"></i></li> <li><i class="iconfont icon-menufold icon20" ref="toggle" @click="slider_flag = !slider_flag"></i></li>
<li>{{examData.type}}-{{examData.source}}</li> <li>{{examData.type}}-{{examData.source}}</li>
<li>{{userInfo.name}}</li> <li>{{userInfo.name}}</li>
<li><router-link to="/scoreTable" class = "router1">个人统计</router-link></li> <li>
<router-link
:to="{
path: '/scoreTable',
query: {
cid: this.$route.query.cid,
cname:this.$route.query.cname,
role:this.$route.query.role
}}" class="router1">个人统计
</router-link>
</li>
<li><i class="iconfont icon-arrLeft icon20"></i></li> <li><i class="iconfont icon-arrLeft icon20"></i></li>
</ul> </ul>
</div> </div>
...@@ -217,7 +227,7 @@ export default { ...@@ -217,7 +227,7 @@ export default {
} }
}, },
created() { created() {
this.getCookies() this.getUrlParams()
this.getExamData() this.getExamData()
this.showTime() this.showTime()
}, },
...@@ -242,10 +252,13 @@ export default { ...@@ -242,10 +252,13 @@ export default {
// 拼接 // 拼接
return year+"-"+month+"-"+day+" "+hours+":"+minutes+":"+seconds; return year+"-"+month+"-"+day+" "+hours+":"+minutes+":"+seconds;
}, },
getCookies() { //获取cookie getUrlParams() { //从路由上获取参数
this.userInfo.name = this.$cookies.get("cname") this.userInfo.name = this.$route.query.cname
this.userInfo.id = this.$cookies.get("cid") this.userInfo.id = this.$route.query.cid
let role = this.$cookies.get("role") let role = this.$route.query.role
console.log(this.userInfo.name)
console.log(this.userInfo.id)
console.log(role)
if(role == "0"){ if(role == "0"){
this.roleflag = true; this.roleflag = true;
} }
...@@ -580,7 +593,7 @@ export default { ...@@ -580,7 +593,7 @@ export default {
}).then(res => { }).then(res => {
if(res.data.code == 200) { if(res.data.code == 200) {
console.log("关闭当前页面") console.log("关闭当前页面")
window.open("http://www.xz.cq/#/home","_self") // window.open("http://www.xz.cq/#/home","_self")
// http://localhost:8088/#/jumplogin // http://localhost:8088/#/jumplogin
// this.$router.push("/answer") // this.$router.push("/answer")
// 模拟用户按下 Alt+F4 快捷键,并调用 window.close() 方法来关闭当前窗口 // 模拟用户按下 Alt+F4 快捷键,并调用 window.close() 方法来关闭当前窗口
...@@ -601,9 +614,6 @@ export default { ...@@ -601,9 +614,6 @@ export default {
}) })
} }
}, },
/* closeCurrentWindow(){
window.close();
},*/
showTime() { //倒计时 showTime() { //倒计时
setInterval(() => { setInterval(() => {
this.time -= 1 this.time -= 1
...@@ -619,123 +629,6 @@ export default { ...@@ -619,123 +629,6 @@ export default {
} }
},1000 * 60) },1000 * 60)
}, },
/* MoreTrueOrFalse(boo){
if (boo){
//定位目标元素,并获取它的样式对象:
var myElement = document.querySelector(".is-checked");
var inputElement = myElement.querySelector('.el-checkbox__input');
var innerElement = inputElement.querySelector('.el-checkbox__inner');
console.log(innerElement)
// 创建一个<style>标签
var styleTag = document.createElement('style');
document.head.appendChild(styleTag);
// 动态生成的内联样式规则
styleTag.innerHTML = `
.el-checkbox__input.is-disabled.is-checked .el-checkbox__inner::before {
content: "";
position: absolute;
top: -10px;
left: 3px;
width: 12px;
height: 25px;
border: 2px solid transparent;
border-bottom: 5px solid #f50808;
border-right: 5px solid #fa0909;
transform: rotate(45deg);
}`;
// 将样式规则应用到页面上的元素
innerElement.classList.add('styleTag');
}else {
}
},
//动态添加是否对错
OnetrueOrFalse(boo){
if (boo){
/!* var myElements = document.querySelectorAll(".el-radio__input");
var uncheckedElements = Array.from(myElements).filter(function(element) {
return !element.classList.contains('is-checked');
});
console.log(uncheckedElements)
var styleTag2 = document.createElement('style2');
document.head.appendChild(styleTag2);
// 动态生成的内联样式规则
styleTag2.innerHTML = `
.el-radio__input.is-disabled .el-radio__inner::before {
content: "×";
position: absolute;
top: -8px;
left: -5px;
color: #f50808;
font-size: 30px;
text-shadow:
-1px -1px 0 #f50808,
1px -1px 0 #f50808,
-1px 1px 0 #f50808,
1px 1px 0 #f50808;
}`;
uncheckedElements.forEach(e=>{
var innerElements = e.querySelectorAll(".el-radio__inner");
Array.from(innerElements).forEach(function(element) {
console.log(element)
element.classList.add("style2");
});
})*!/
//定位目标元素,并获取它的样式对象:
var myElement = document.querySelector(".is-checked");
var inputElement = myElement.querySelector('.el-radio__input');
var innerElement = inputElement.querySelector('.el-radio__inner');
// console.log(innerElement)
// 创建一个<style>标签
var styleTag = document.createElement('style');
document.head.appendChild(styleTag);
// 动态生成的内联样式规则
styleTag.innerHTML = `
.el-radio__input.is-disabled.is-checked .el-radio__inner::before {
content: "";
position: absolute;
top: -20px;
left: 3px;
width: 10px;
height: 25px;
border: 2px solid transparent;
border-bottom: 5px solid #f50808;
border-right: 5px solid #fa0909;
transform: rotate(45deg);
}`;
// 将样式规则应用到页面上的元素
console.log(innerElement)
innerElement.classList.add('style');
}else {
var myElement = document.querySelector(".is-checked");
var inputElement = myElement.querySelector('.el-radio__input');
var innerElement = inputElement.querySelector('.el-radio__inner');
console.log(innerElement)
// 创建一个<style>标签
var styleTag = document.createElement('style');
document.head.appendChild(styleTag);
// 动态生成的内联样式规则
styleTag.innerHTML = `
.el-radio__input.is-disabled.is-checked .el-radio__inner::before {
content: "×";
position: absolute;
top: -8px;
left: -5px;
color: #f50808;
font-size: 30px;
text-shadow:
-1px -1px 0 #f50808,
1px -1px 0 #f50808,
-1px 1px 0 #f50808,
1px 1px 0 #f50808;
}`;
// 将样式规则应用到页面上的元素
innerElement.classList.add('styleTag');
}
}*/
}, },
computed:mapState(["isPractice"]) computed:mapState(["isPractice"])
} }
...@@ -1196,10 +1089,10 @@ export default { ...@@ -1196,10 +1089,10 @@ export default {
} }
.el-checkbox__label{ .el-checkbox__label{
/*color: red;*/ /*color: red;*/
font-size: 25px; font-size: 25px !important;
font-family: 'SimSun', sans-serif; font-family: 'SimSun', sans-serif;
white-space:normal; white-space:normal;
line-height: 25px; line-height: 25px !important;
} }
.content .el-checkbox-group{ .content .el-checkbox-group{
display: flex; display: flex;
......
...@@ -5,14 +5,44 @@ ...@@ -5,14 +5,44 @@
<el-row class="padding-50"> <el-row class="padding-50">
<el-col :span="24"> <el-col :span="24">
<ul class="list"> <ul class="list">
<!-- <li><a href="javascript:;" @click="exam()">我的试卷</a></li> --> <li>
<!-- <li><a href="javascript:;" @click="practice()">我的练习</a></li> --> <router-link
<li><router-link to="/scoreTable">我的分数</router-link></li> :to="{
<li><router-link to="/scoreTjTable">我的分数统计</router-link></li> path: '/scoreTable',
<li v-if="roleflag"><router-link to="/scoreDwTjTable">单位分数统计</router-link></li> query: {
cid: this.$route.query.cid,
cname:this.$route.query.cname,
role:this.$route.query.role
}}"
>我的分数
</router-link>
</li>
<li>
<router-link
:to="{
path: '/scoreTjTable',
query: {
cid: this.$route.query.cid,
cname:this.$route.query.cname,
role:this.$route.query.role
}}"
>我的分数统计
</router-link>
</li>
<li v-if="roleflag">
<router-link
:to="{
path: '/scoreDwTjTable',
query: {
cid: this.$route.query.cid,
cname:this.$route.query.cname,
role:this.$route.query.role
}}"
>单位分数统计
</router-link>
</li>
<li class="right"> <li class="right">
{{user.userName}} {{this.$route.query.cname}}
<!-- <div class="final" @click="over()">结束考试</div>-->
</li> </li>
</ul> </ul>
</el-col> </el-col>
...@@ -37,33 +67,27 @@ export default { ...@@ -37,33 +67,27 @@ export default {
return { return {
flag: false, flag: false,
user: {}, user: {},
roleflag: false roleflag: false,
} }
}, },
created() { mounted() {
this.userInfo() this.userInfo()
}, },
methods: { methods: {
exit() { //退出登录 exit() { //退出登录
this.$router.push({path:"/"}) //跳转到登录页面 this.$router.push({path:"/"}) //跳转到登录页面
this.$cookies.remove("cname") //清除cookie
this.$cookies.remove("cid")
}, },
manage() { //跳转到修改密码页面 manage() { //跳转到修改密码页面
this.$router.push({path: '/manager'}) this.$router.push({path: '/manager'})
}, },
userInfo() { userInfo() {
let role = this.$cookies.get("role")
debugger debugger
if(role == "0"){ if(this.$route.query.role == "0"){
this.roleflag = true; this.roleflag = true;
} }
let studentName = this.$cookies.get("cname") let self = this;
let studentId = this.$cookies.get("cid") self.user.userName = this.$route.query.cname
console.log(`studentId${studentId}`) self.user.studentId = this.$route.query.cid
console.log(`studentName ${studentName}`)
this.user.userName = studentName
this.user.studentId = studentId
}, },
practice() { //跳转练习模式 practice() { //跳转练习模式
let isPractice = true let isPractice = true
......
...@@ -59,12 +59,13 @@ export default { ...@@ -59,12 +59,13 @@ export default {
} }
}, },
created() { created() {
this.getScore() this.getScore()
this.loading = true //数据加载则遮罩表格 this.loading = true //数据加载则遮罩表格
}, },
methods: { methods: {
getScore() { getScore() {
let studentId = this.$cookies.get("cid") let studentId = this.$route.query.cid;
this.$axios(`/api/score/${this.pagination.current}/${this.pagination.size}/${studentId}`).then(res => { this.$axios(`/api/score/${this.pagination.current}/${this.pagination.size}/${studentId}`).then(res => {
if(res.data.code == 200) { if(res.data.code == 200) {
this.loading = false //数据加载完成去掉遮罩 this.loading = false //数据加载完成去掉遮罩
......
...@@ -48,7 +48,7 @@ export default { ...@@ -48,7 +48,7 @@ export default {
}, },
methods: { methods: {
getScoreTj() { getScoreTj() {
let studentId = this.$cookies.get("cid") let studentId = this.$route.query.cid
this.$axios(`/api/scoreTj/${studentId}`).then(res => { this.$axios(`/api/scoreTj/${studentId}`).then(res => {
debugger debugger
if(res.data.code == 200) { if(res.data.code == 200) {
......
...@@ -3,12 +3,13 @@ ...@@ -3,12 +3,13 @@
<div class="add"> <div class="add">
<el-tabs v-model="activeName"> <el-tabs v-model="activeName">
<el-tab-pane name="first"> <el-tab-pane name="first">
<span slot="label"><i class="el-icon-circle-plus"></i>添加试题</span> <span slot="label" v-if="isAddOrEdit"><i class="el-icon-circle-plus"></i>添加试题</span>
<span slot="label" v-else><i class="el-icon-circle-plus"></i>修改试题</span>
<section class="append"> <section class="append">
<ul> <ul>
<li> <li>
<span>题目类型:</span> <span>题目类型:</span>
<el-select v-model="optionValue" placeholder="请选择题型" class="w150"> <el-select v-model="optionValue" placeholder="请选择题型" class="w150" :disabled = !isAddOrEdit>
<el-option <el-option
v-for="item in options" v-for="item in options"
:key="item.value" :key="item.value"
...@@ -17,7 +18,7 @@ ...@@ -17,7 +18,7 @@
</el-option> </el-option>
</el-select> </el-select>
</li> </li>
<li v-if="optionValue == '选择题' || optionValue=='多选题'"> <li v-if="optionValue == '单选题' || optionValue=='多选题'">
<span>所属章节:</span> <span>所属章节:</span>
<el-input <el-input
placeholder="请输入对应章节" placeholder="请输入对应章节"
...@@ -44,7 +45,7 @@ ...@@ -44,7 +45,7 @@
clearable> clearable>
</el-input> </el-input>
</li> </li>
<li v-if="optionValue == '选择题' || optionValue=='多选题'"> <li v-if="optionValue == '单选题' || optionValue=='多选题'">
<span>难度等级:</span> <span>难度等级:</span>
<el-select v-model="postChange.level" placeholder="选择难度等级" class="w150"> <el-select v-model="postChange.level" placeholder="选择难度等级" class="w150">
<el-option <el-option
...@@ -77,9 +78,9 @@ ...@@ -77,9 +78,9 @@
</el-option> </el-option>
</el-select> </el-select>
</li> </li>
<li v-show="optionValue == '选择题'"> <li v-show="optionValue == '单选题'">
<span>正确选项:</span> <span>正确选项:</span>
<el-select v-model="postChange.rightAnswer" placeholder="选择正确答案" class="w150"> <el-select v-model="oneSelect" placeholder="选择正确答案" class="w150">
<el-option <el-option
v-for="item in rights" v-for="item in rights"
:key="item.value" :key="item.value"
...@@ -90,7 +91,7 @@ ...@@ -90,7 +91,7 @@
</li> </li>
<li v-show="optionValue=='多选题'"> <li v-show="optionValue=='多选题'">
<span>正确选项:</span> <span>正确选项:</span>
<el-select v-model="postChange.rightAnswer" multiple placeholder="选择正确答案" class="w150"> <el-select v-model="moreSelect" multiple placeholder="选择正确答案" class="w150">
<el-option <el-option
v-for="item in rights" v-for="item in rights"
:key="item.value" :key="item.value"
...@@ -101,7 +102,7 @@ ...@@ -101,7 +102,7 @@
</li> </li>
</ul> </ul>
<!-- 选择题部分 --> <!-- 选择题部分 -->
<div class="change" v-if="optionValue == '选择题' || optionValue=='多选题'"> <div class="change" v-if="optionValue == '单选题' || optionValue=='多选题'">
<div class="title"> <div class="title">
<el-tag>题目:</el-tag><span>在下面的输入框中输入题目,形如--DNS 服务器和DHCP服务器的作用是()</span> <el-tag>题目:</el-tag><span>在下面的输入框中输入题目,形如--DNS 服务器和DHCP服务器的作用是()</span>
<el-input <el-input
...@@ -112,6 +113,22 @@ ...@@ -112,6 +113,22 @@
resize="none" resize="none"
class="answer"> class="answer">
</el-input> </el-input>
<!-- <el-upload
class="upload-demo"
action="#"
accept="image/jpg,image/jpeg,image/png"
:auto-upload="false"
:on-change="
(file, fileList) => {
handlePhotoChange(file, fileList);
}
"
:on-remove="handleRemove"
:file-list="photoList"
list-type="picture">
<el-button size="small" type="primary">点击上传</el-button>
&lt;!&ndash; <div slot="tip" class="el-upload__tip">只能上传jpg/png文件,且不超过500kb</div>&ndash;&gt;
</el-upload>-->
</div> </div>
<div class="options"> <div class="options">
<ul> <ul>
...@@ -161,7 +178,8 @@ ...@@ -161,7 +178,8 @@
</el-input> </el-input>
</div> </div>
<div class="submit"> <div class="submit">
<el-button type="primary" @click="changeSubmit()">立即添加</el-button> <el-button v-if="isAddOrEdit" type="primary" @click="changeSubmit()">立即添加</el-button>
<el-button v-else type="primary" @click="editSubmit()">确认修改</el-button>
</div> </div>
</div> </div>
<!-- 填空题部分 --> <!-- 填空题部分 -->
...@@ -225,7 +243,9 @@ ...@@ -225,7 +243,9 @@
</el-input> </el-input>
</div> </div>
<div class="submit"> <div class="submit">
<el-button type="primary" @click="judgeSubmit()">立即添加</el-button> <el-button v-if="isAddOrEdit" type="primary" @click="judgeSubmit()">立即添加</el-button>
<el-button v-else type="primary" @click="editSubmit2()">确认修改</el-button>
</div> </div>
</div> </div>
</section> </section>
...@@ -239,14 +259,19 @@ ...@@ -239,14 +259,19 @@
export default { export default {
data() { data() {
return { return {
oneSelect:'',
moreSelect:"",
row:{},//路由上的参数
isAddOrEdit:true,
photoList: [],
changeNumber: null, //选择题出题数量 changeNumber: null, //选择题出题数量
fillNumber: null, //填空题出题数量 fillNumber: null, //填空题出题数量
judgeNumber: null, //判断题出题数量 judgeNumber: null, //判断题出题数量
activeName: 'first', //活动选项卡 activeName: 'first', //活动选项卡
options: [ //题库类型 options: [ //题库类型
{ {
value: '选择题', value: '单选题',
label: '选择题' label: '单选题'
}, },
{ {
value: '判断题', value: '判断题',
...@@ -313,10 +338,10 @@ export default { ...@@ -313,10 +338,10 @@ export default {
}, },
], ],
paperId: null, paperId: null,
optionValue: '选择题', //题型选中值 选择题就是单选题 optionValue: '单选题', //题型选中值 选择题就是单选题
subject: '', //试卷名称用来接收路由参数 subject: '', //试卷名称用来接收路由参数
postChange: { //选择题提交内容 postChange: { //选择题提交内容
oneOrMore: this.optionValue=='选择题'? '1':'2', oneOrMore: this.optionValue=='单选题'? '1':'2',
subject: '', //试卷名称 subject: '', //试卷名称
level: '', //难度等级选中值 level: '', //难度等级选中值
rightAnswer: '', //正确答案选中值 rightAnswer: '', //正确答案选中值
...@@ -354,18 +379,63 @@ export default { ...@@ -354,18 +379,63 @@ export default {
//监听optionValue题目类型的变化 去重置正确选项的值 //监听optionValue题目类型的变化 去重置正确选项的值
watch: { watch: {
optionValue(newValue) { optionValue(newValue) {
console.log('optionValue 的值发生了变化:', newValue);
// 在这里执行你想要的操作
this.postChange.rightAnswer='' this.postChange.rightAnswer=''
} }
}, },
created() { created() {
//编辑的时候从路由上获取参数
if (this.$route.query.row){
const row = JSON.parse(this.$route.query.row);
this.row = row
console.log(this.row)
this.isAddOrEdit = false
if (row.oneOrMore=='1'){ //单选题
this.postChange.answerA = row.answerA
this.postChange.answerB = row.answerB
this.postChange.answerC = row.answerC
this.postChange.answerD = row.answerD
this.postChange.section = row.section //所属章节
this.postChange.level = row.level //难度等级
this.oneSelect = row.rightAnswer //正确选项
this.postChange.question = row.question //题干
this.postChange.analysis = row.analysis //解析
this.optionValue = "单选题" //题目类型
}else if (row.oneOrMore=='2'){//多选
this.postChange.answerA = row.answerA
this.postChange.answerB = row.answerB
this.postChange.answerC = row.answerC
this.postChange.answerD = row.answerD
this.postChange.section = row.section //所属章节
this.postChange.level = row.level //难度等级
this.postChange.question = row.question //题干
this.postChange.analysis = row.analysis //解析
this.optionValue = "多选题" //题目类型
this.moreSelect = row.rightAnswer.split(",").map(item => item.trim());//正确选项
console.log(this.moreSelect)
}else {
//判断
this.optionValue = "判断题" //题目类型
this.postJudge.section = row.section //所属章节
this.postJudge.level = row.level //难度等级
this.postJudge.question = row.question //题干
this.postJudge.answer = row.rightAnswer
this.postJudge.analysis = row.analysis //解析
}
}
this.getParams() this.getParams()
}, },
methods: { methods: {
// handleClick(tab, event) { //添加照片
// console.log(tab, event); handlePhotoChange(file, fileList) {
// }, let self = this;
self.photoList = fileList
},
//移除照片
handleRemove(file,fileList) {
this.photoList =fileList
},
create() { create() {
this.$axios({ this.$axios({
url: '/api/item', url: '/api/item',
...@@ -378,7 +448,6 @@ export default { ...@@ -378,7 +448,6 @@ export default {
subject: '试题1' //题目数量太少,指定为计算机网络出题 subject: '试题1' //题目数量太少,指定为计算机网络出题
} }
}).then(res => { }).then(res => {
console.log(res)
let data = res.data let data = res.data
if(data.code==200){ if(data.code==200){
setTimeout(() => { setTimeout(() => {
...@@ -405,9 +474,13 @@ export default { ...@@ -405,9 +474,13 @@ export default {
this.postPaper.paperId = paperId this.postPaper.paperId = paperId
}, },
changeSubmit() { //选择题题库提交 changeSubmit() { //选择题题库提交
// console.log(this.textcccc)
this.postChange.oneOrMore = '1'
this.postChange.rightAnswer = this.oneSelect
this.postChange.subject = this.subject this.postChange.subject = this.subject
if (this.optionValue=='多选题' && this.postChange.rightAnswer){ if (this.optionValue=='多选题' && this.moreSelect){
this.postChange.rightAnswer = this.postChange.rightAnswer.join(', '); this.postChange.rightAnswer = this.moreSelect.join(', ');
this.postChange.oneOrMore = '2'
} }
this.$axios({ //提交数据到选择题题库表 this.$axios({ //提交数据到选择题题库表
url: '/api/MultiQuestion', url: '/api/MultiQuestion',
...@@ -423,6 +496,8 @@ export default { ...@@ -423,6 +496,8 @@ export default {
type: 'success' type: 'success'
}) })
this.postChange = {} this.postChange = {}
this.oneSelect= ''
this.moreSelect = ""
} }
}).then(() => { }).then(() => {
this.$axios(`/api/multiQuestionId`).then(res => { //获取当前题目的questionId this.$axios(`/api/multiQuestionId`).then(res => { //获取当前题目的questionId
...@@ -439,6 +514,62 @@ export default { ...@@ -439,6 +514,62 @@ export default {
}) })
}) })
}, },
//单选多选修改
editSubmit(){
this.postChange.oneOrMore = '1'
this.postChange.rightAnswer = this.oneSelect
//如果是多选拼接答案转为字符串
if (this.optionValue=='多选题' && this.moreSelect){
this.postChange.rightAnswer = this.moreSelect.join(', ');
this.postChange.oneOrMore = '2'
}
this.postChange.subject = this.row.subject
this.postChange.questionid = this.row.questionid
this.postChange.tablename = this.row.tablename
this.$axios({ //提交数据到选择题题库表
url: '/api/updateAnswers',
method: 'post',
data: {
...this.postChange
}
}).then(res => { //添加成功显示提示
let status = res.data.code
if(status == 200) {
this.$message({
message: '已修改当前题库',
type: 'success'
})
}
})
},
//判断修改
editSubmit2(){
this.$axios({ //提交数据到选择题题库表
url: '/api/updateAnswers',
method: 'post',
data: {
analysis:this.postJudge.analysis,
level:this.postJudge.level,
question:this.postJudge.question,
rightAnswer:this.postJudge.answer,
section:this.postJudge.section,//所属章节
subject:this.row.subject,
tablename:this.row.tablename,
questionid:this.row.questionid,
type:"判断题"
}
}).then(res => { //添加成功显示提示
let status = res.data.code
if(status == 200) {
this.$message({
message: '已修改当前题库',
type: 'success'
})
}
})
},
fillSubmit() { //填空题提交 fillSubmit() { //填空题提交
this.postFill.subject = this.subject this.postFill.subject = this.subject
this.$axios({ this.$axios({
......
//查询所有题库 <!--查询所有题库-->
<template> <template>
<div class="exam"> <div class="exam">
<div class="tabs">
<el-form ref="searchForm" :model="searchForm" >
<el-row >
<el-col :span="6">
<el-form-item label="题目信息 :" style="display: flex">
<el-input v-model="searchForm.question" clearable></el-input>
</el-form-item>
</el-col>
<el-col :span="6">
<el-button
class="toEmptyButton"
@click="toEmpty">
<span class="skyp icon-sousuo"></span>
清空
</el-button>
<el-button
class="searchListButton"
@click="searchList()"
>
<span class="skyp icon-sousuo"></span>
查询
</el-button>
<el-button
class="addTableButton"
@click="addTable"
>
<span class="skyp icon-tianjia"></span>
新增
</el-button>
</el-col>
</el-row>
</el-form>
</div>
<el-table :data="pagination.records" border :row-class-name="tableRowClassName"> <el-table :data="pagination.records" border :row-class-name="tableRowClassName">
<el-table-column fixed="left" prop="subject" label="试卷名称" width="180"></el-table-column> <el-table-column fixed="left" prop="subject" label="试卷名称" width="180"></el-table-column>
<el-table-column prop="question" label="题目信息" width="490"></el-table-column> <el-table-column prop="question" label="题目信息" width="490"></el-table-column>
<el-table-column prop="section" label="所属章节" width="200"></el-table-column> <el-table-column prop="section" label="所属章节" width="200"></el-table-column>
<el-table-column prop="type" label="题目类型" width="200"></el-table-column> <el-table-column prop="type" label="题目类型" width="200">
<template slot-scope="scope">
<template v-if="scope.row.oneOrMore === '1'">
单选题
</template>
<template v-else-if="scope.row.oneOrMore === '2'">
多选题
</template>
<template v-else>
判断题
</template>
</template>
</el-table-column>
<el-table-column prop="score" label="试题分数" width="150"></el-table-column> <el-table-column prop="score" label="试题分数" width="150"></el-table-column>
<el-table-column prop="level" label="难度等级" width="133"></el-table-column> <el-table-column prop="level" label="难度等级" width="133"></el-table-column>
<el-table-column fixed="right" label="操作" width="200" align="center">
<template slot-scope="scope">
<el-button type="text" size="small" @click="edit(scope.row)"
>编辑</el-button
>
<el-button type="text" size="small" @click="del(scope.row)"
>删除</el-button
>
</template>
</el-table-column>
</el-table> </el-table>
<el-pagination <el-pagination
@size-change="handleSizeChange" @size-change="handleSizeChange"
...@@ -26,6 +83,9 @@ ...@@ -26,6 +83,9 @@
export default { export default {
data() { data() {
return { return {
searchForm:{
question:'',
},
pagination: { pagination: {
//分页后的考试信息 //分页后的考试信息
current: 1, //当前页 current: 1, //当前页
...@@ -38,11 +98,27 @@ export default { ...@@ -38,11 +98,27 @@ export default {
this.getAnswerInfo(); this.getAnswerInfo();
}, },
methods: { methods: {
getAnswerInfo() { //查询按钮
//分页查询所有试卷信息 searchList(){
this.$axios( this.getAnswerInfo(this.searchForm.question)
`/api/answers/${this.pagination.current}/${this.pagination.size}` },
) //清空按钮
toEmpty() {
let self = this;
self.searchForm.question = "";
self.getAnswerInfo();
},
//新增按钮
addTable(){
this.$router.push('/addAnswer')
},
//分页查询所有试卷信息
getAnswerInfo(likeSelect) {
let url =`/api/answers/${this.pagination.current}/${this.pagination.size}/null`
if (likeSelect){
url = `/api/answers/${this.pagination.current}/${this.pagination.size}/${likeSelect}`
}
this.$axios(url)
.then(res => { .then(res => {
this.pagination = res.data.data; this.pagination = res.data.data;
console.log(res); console.log(res);
...@@ -52,12 +128,12 @@ export default { ...@@ -52,12 +128,12 @@ export default {
//改变当前记录条数 //改变当前记录条数
handleSizeChange(val) { handleSizeChange(val) {
this.pagination.size = val; this.pagination.size = val;
this.getAnswerInfo(); this.getAnswerInfo(this.searchForm.question);
}, },
//改变当前页码,重新发送请求 //改变当前页码,重新发送请求
handleCurrentChange(val) { handleCurrentChange(val) {
this.pagination.current = val; this.pagination.current = val;
this.getAnswerInfo(); this.getAnswerInfo(this.searchForm.question);
}, },
tableRowClassName({ row, rowIndex }) { tableRowClassName({ row, rowIndex }) {
if (rowIndex % 2 == 0) { if (rowIndex % 2 == 0) {
...@@ -65,11 +141,78 @@ export default { ...@@ -65,11 +141,78 @@ export default {
} else { } else {
return "success-row"; return "success-row";
} }
} },
//编辑 跳转到新增页面
edit(row){
this.$router.push({
path: "/addAnswerChildren",
query:{
paperId:row.paperId,
subject:row.subject,
row:JSON.stringify(row),
}
});
},
//删除
del(row) {
console.log(row)
let self = this;
this.$confirm("此操作将永久删除该文件, 是否继续?", "提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning",
})
.then(() => {
self.removeData(row);
})
.catch(() => {
this.$message({
type: "info",
message: "已取消删除",
});
});
},
//点击二次确认删除后执行的操作
removeData(row) {
let self = this;
console.log(row)
//删除的时候传主键和类型
this.$axios(`/api/deleteAnswers/${row.questionid}/${row.tablename}/${row.subject}`).then((res) => {
if (res.status == 200) {
self.$message.success("删除成功");
self.getAnswerInfo();
} else {
this.$message.error("删除失败");
}
});
},
} }
}; };
</script> </script>
<style lang="less" scoped> <style lang="less" scoped>
/deep/.el-input__suffix{
display: none;
}
/*添加按钮*/
.addTableButton{
margin-top: 0;
background-color: #266fe8;
color: #fff;
/*color: #266fe8;*/
/*border: 1px solid #266fe8;*/
}
/*查询按钮*/
.searchListButton{
margin-top: 0;
background-color: #266fe8;
color: #fff;
}
/*清空按钮*/
.toEmptyButton{
margin-top: 0;
background-color: #266fe8;
color: #fff;
}
.exam { .exam {
padding: 0px 40px; padding: 0px 40px;
.page { .page {
...@@ -87,7 +230,7 @@ export default { ...@@ -87,7 +230,7 @@ export default {
} }
.el-table .warning-row { .el-table .warning-row {
background: #000 !important; background: #000 !important;
} }
.el-table .success-row { .el-table .success-row {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment