This commit is contained in:
joylink_cuiweidong 2020-05-27 11:20:33 +08:00
commit eaa18f3539
4 changed files with 251 additions and 51 deletions

View File

@ -1,18 +1,21 @@
export default {
// 当被绑定的元素插入到 DOM 中时
inserted: function (el, obj) {
// 这是需要页面刚加载就能进行聚焦操作使用的钩子函数,可以省略的,视具体需求而定
// 对值进行判断
if (obj.value) {
// 聚焦元素
el.focus();
}
},
// 当指令所在组件的 VNode 及其子 VNode 全部更新后调用
// 这是每当绑定的值发生改变时触发的钩子函数
componentUpdated: function (el, obj) {
if (obj.value) {
el.focus();
}
}
// 当被绑定的元素插入到 DOM 中时
inserted: function (el, obj) {
// 这是需要页面刚加载就能进行聚焦操作使用的钩子函数,可以省略的,视具体需求而定
// 对值进行判断
const dom = el.querySelector('input') || el.querySelector('textarea');
dom.focus();
// el.focus();
// if (obj.value) {
// // 聚焦元素
// el.focus();
// }
},
// 当指令所在组件的 VNode 及其子 VNode 全部更新后调用
// 这是每当绑定的值发生改变时触发的钩子函数
componentUpdated: function (el, obj) {
if (obj.value) {
el.focus();
}
}
};

View File

@ -49,7 +49,7 @@
<el-card style="width: 45%;margin-left: calc(10% - 100px);margin-top: 60px;display: inline-block;height: calc(100% - 100px);">
<div slot="header">
<span>实操试题列表</span>
<el-button style="float: right; padding: 3px 0" type="text">添加试题</el-button>
<el-button style="float: right; padding: 3px 0" type="text" @click="addOperateQuestion">添加试题</el-button>
<el-button style="float: right; padding: 3px 0;margin-right: 5px" type="text" @click="operateReview">预览</el-button>
</div>
<el-table
@ -57,19 +57,12 @@
style="width: 100%"
>
<el-table-column
prop="type"
label="类型"
>
<template slot-scope="scope">
<el-tag
type="primary"
disable-transitions
>{{ QuestionTypeMap[scope.row.type] }}</el-tag>
</template>
</el-table-column>
prop="name"
label="实操名称"
/>
<el-table-column
prop="topic"
label="题目"
prop="creatorName"
label="创建人"
/>
<el-table-column prop="score" label="分值">
<template slot-scope="scope">
@ -85,17 +78,20 @@
</el-card>
<theory-review ref="theoryReview" :theory-question-list="theoryQuestionList" />
<theory-question ref="theoryQuestion" :theory-index-list="theoryIndexList" @addQuestion="addTheoryQuestionList" @removeQuestion="removeTheoryQuestion" />
<operate-question ref="operateQuestion" :operate-index-list="operateIndexList" @addQuestion="addOperateQuestionList" @removeQuestion="removeOperateQuestion" />
</div>
</template>
<script>
import TheoryReview from './theoryReview';
import TheoryQuestion from './theoryQuestion';
import OperateQuestion from './operateQuestion';
export default {
name: 'GeneratPaper',
components: {
TheoryReview,
TheoryQuestion
TheoryQuestion,
OperateQuestion
},
data() {
return {
@ -131,6 +127,9 @@ export default {
addTheoryQuestion() {
this.$refs.theoryQuestion.doShow();
},
addOperateQuestion() {
this.$refs.operateQuestion.doShow();
},
goBack() {
this.$router.go(-1);
},

View File

@ -0,0 +1,218 @@
<template>
<el-dialog :visible.sync="dialogVisible" :before-close="handleClose" title="实操试题" width="80%">
<query-list-page ref="user" :pager-config="pagerConfig" :query-form="queryForm" :query-list="queryList" />
</el-dialog>
</template>
<script>
export default {
mixins: [
// WindowResizeHandler
],
props: {
operateIndexList: {
type: Array,
default() {
return [];
}
}
},
data() {
return {
index: 0,
height: 0,
loading: false,
dialogVisible: false,
pagerConfig: {
pageSize: 'pageSize',
pageIndex: 'pageNum'
},
queryForm: {
reset: true,
labelWidth: '80px',
queryObject: {
name: {
type: 'text',
label: '实操名称'
}
}
},
queryList: {
// query: getPracticeList,
data:[
{id:1, raceId:2, name:'行调进行扣车操作', creatorName:'水墨'},
{id:2, raceId:4, name:'行调进行扣车操作', creatorName:'zyy'},
{id:3, raceId:3, name:'行调进行扣车操作', creatorName:'水墨'}
],
selectCheckShow: false,
indexShow: true,
columns: [
{
title: '实操名称',
prop: 'name'
},
{
title: '创建人',
prop: 'creatorName',
width: '100'
},
{
type: 'button',
title: '操 作',
width: '420',
buttons: [
{
name: '添加',
handleClick: this.addQuestion,
showControl: (row) => { return !row.paper; },
type: 'success'
},
{
name: '移出',
handleClick: this.removeQuestion,
showControl: (row) => { return row.paper; },
type: 'warning'
}
]
}
]
}
};
},
computed: {
},
watch: {
},
methods: {
loadInitData() {
this.$nextTick(() => {
this.queryList.reload();
});
},
doShow() {
this.dialogVisible = true;
this.loadInitData();
},
handleClose() {
this.dialogVisible = false;
},
addQuestion(index, row) {
this.$set(row, 'paper', true);
this.$emit('addQuestion', row);
},
afterQuery(data) {
if (data && data.list) {
const that = this;
const list = data.list;
if (list) {
list.map(elem => {
this.$set(elem, 'paper', that.operateIndexList.includes(elem.id));
});
}
}
return data;
},
removeQuestion(index, row) {
this.$set(row, 'paper', false);
this.$emit('removeQuestion', row);
},
answerTags(row) {
const answer = [];
row.optionList.forEach((el, i) => {
switch (row.type) {
case 'select':
if (el.correct) {
answer.push(this.$asc2chart(i + 65));
}
break;
case 'judge':
if (el.correct) {
answer.push(el.content);
}
break;
}
});
return answer;
}
}
};
</script>
<style lang="scss" scoped>
.layer-center {
width: 900px;
height: 100%;
margin: auto;
background: #fff;
}
.quiz {
background: #eee;
height: 100%;
&::-webkit-scrollbar {
display:none
}
&__card {
height: 100%;
.dir-item {
padding-left: 25px;
}
.dir-caption {
padding-left: 10px;
line-height: 26px;
background: #f1f1f1;
}
}
&__container {
height: 100%;
&-header {
height: auto !important;
.title {
font-size: 24px;
line-height: 60px;
font-weight: bold;
text-align: center;
}
.notes {
color:#606266;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
margin: 0 20px;
}
}
&-main {
.section {
padding: 5px 20px;
.caption {
line-height: 26px;
}
.context {
}
}
}
&-footer {
text-align: right;
position: sticky;
bottom: 0px;
padding: 40px ;
.buttons {
position: relative;
bottom: 20px;
}
}
}
}
</style>

View File

@ -57,27 +57,7 @@ export default {
status: '',
totalScore: 0,
passScore: 10
},
examQuestions: [
{
topic: 'PH玻璃电极只能在5~60℃范围内使用而且还应通过温度校正装置来消除影响。',
type: 'judge',
optionList: [
{id: '160', content: '√', correct: true},
{id: '161', content: '×', correct: false}
]
},
{
topic: '调度工作是( ___ )工作中的一个重要组成部分。',
type: 'select',
optionList: [
{id: '40', content: '<span style="color: windowtext;">煤矿管理</span>', correct: false},
{id: '41', content: '<span style="color: windowtext;">企业管理</span>', correct: true},
{id: '42', content: '<span style="color: windowtext;">安全生产</span>', correct: false},
{id: '43', content: '<span style="color: windowtext;">生产组织</span>', correct: false}
]
}
]
}
};
},
computed: {