Commit 82315bee authored by zhengke's avatar zhengke

1

parent e9cbadcd
<style>
.page-content p {
margin: 0 !important;
}
.quetion_Title {
background: transparent !important;
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
width: 400px;
}
</style>
<template>
<div class="page-body">
<div class="page-search row items-center">
<div class="col row wrap q-mr-lg q-col-gutter-md">
<div class="col-3">
<q-input @change="research" clearable standout="bg-primary text-white" v-model="msg.Title" label="关键字"
@clear="research" maxlength="20" />
</div>
<div class="col-3">
<q-select @input="research" standout="bg-primary text-white" option-value="Id" option-label="Name"
v-model="msg.QCategoryId" :options="questionCategoryList" emit-value map-options label="分类" multiple
clearable />
</div>
<div class="col-3">
<q-select @input="research" standout="bg-primary text-white" option-value="QId" option-label="Name"
v-model="msg.QuestionTypeId" :options="questionTypeList" emit-value map-options label="题型" multiple
clearable />
</div>
<div class="col-3">
<q-input @change="research" clearable standout="bg-primary text-white" v-model="msg.PointName" label="知识点"
@clear="research" maxlength="20" />
</div>
<div class="col-3">
<q-select @input="research" standout="bg-primary text-white" option-value="Id" option-label="Name"
v-model="msg.DifficultyType" :options="questionDifficultyTypeList" emit-value map-options label="难度"
multiple clearable />
</div>
</div>
</div>
<div class="page-content">
<q-table :pagination="msg" :loading="loading" no-data-label="暂无相关数据" flat class="sticky-column-table"
separator="none" :data="data" :columns="columns" row-key="name">
<template v-slot:top="props">
<div class="col-2 q-table__title">题库列表</div>
<q-space />
<div class="page-option">
<q-btn color="accent" size="sm" class="q-mr-md" icon="add" label="新增题目" @click="EditQuestion(null)" />
<q-btn-dropdown color="accent" label="批量导入" size="sm" class="q-mr-md" style="margin-left:5px;">
<q-list>
<q-item clickable v-close-popup>
<q-item-section @click="importQuestion(1)">
<q-item-label>模板导入(EXCEL)</q-item-label>
</q-item-section>
</q-item>
<q-item clickable v-close-popup>
<q-item-section @click="importQuestion(2)">
<q-item-label>智能导入(WORD)</q-item-label>
</q-item-section>
</q-item>
</q-list>
</q-btn-dropdown>
</div>
</template>
<template v-slot:body-cell-Title="props">
<td style="width:400px;">
<div v-html="props.row.Title" class="quetion_Title">
</div>
</td>
</template>
<template v-slot:bottom>
<q-pagination class="full-width justify-end" v-model="msg.pageIndex" color="primary" :max="pageCount"
:input="true" @input="changePage" />
</template>
<template v-slot:body-cell-optioned="props">
<q-td :props="props">
<q-btn flat size="xs" icon="edit" color="accent" style="font-weight:400" label="编辑"
@click="EditQuestion(props.row)" />
<q-btn flat size="xs" icon="edit" color="negative" style="font-weight:400" label="删除"
@click="setQuestionStatus(props.row)"></q-btn>
<q-btn flat size="xs" icon="iconfont icon-shangyi2" v-if="props.row.isShowFirst" color="accent" title="上移" style="font-weight:400;display:none;" label=""
@click="getUpStatus(props.row,1)"></q-btn>
<q-btn flat size="xs" icon="iconfont icon-xiayi" v-if="props.row.isShowLast" color="accent" title="下移" style="font-weight:400;display:none;" label=""
@click="getUpStatus(props.row,2)"></q-btn>
<q-btn flat size="xs" icon="iconfont icon-fuzhi" color="accent" style="font-weight:400;display:none;" label=""
@click="getCopyItem(props.row)"></q-btn>
</q-td>
</template>
</q-table>
<question-form v-if="isShowQuestionForm" :CourseId="msg.CourseId" :seting-obj="questionObj" @close="closeQuestion"
@success="refreshQuestion">
</question-form>
<question-upload v-if="isShowImportUpload" :CourseId="msg.CourseId" :importType="importType"
@close="closeQuestion" @success="refreshQuestion">
</question-upload>
</div>
</div>
</template>
<script>
import {
queryQuestionPageList,
queryQuestionTypeList,
deleteQuestion,
queryDifficultyType,
queryQuestionCategory,
UpdateQuestionSort
} from '../../api/question/question';
import questionForm from '../question/question-form';
import questionUpload from '../question/question-upload';
export default {
meta: {
title: "题库列表"
},
components: {
questionForm,
questionUpload
},
data() {
return {
columns: [{
name: 'Title',
label: '题目',
field: 'Title',
align: 'left'
},
{
name: 'CategoryName',
label: '分类',
field: 'CategoryName',
align: 'left',
},
{
name: 'QuestionTypeName',
label: '题型',
field: 'QuestionTypeName',
align: 'left',
},
{
name: 'DifficultyTypeName',
label: '难易',
field: 'DifficultyTypeName',
align: 'left'
},
{
name: 'CreateByName',
label: '创建者',
field: 'CreateByName',
align: 'left'
},
{
name: 'CreateTimeStr',
label: '创建时间',
field: 'CreateTimeStr',
align: 'left'
},
{
name: 'optioned',
label: '操作',
field: 'QuestionId'
}
],
data: [],
loading: false,
msg: {
pageIndex: 1,
pageSize: 12,
rowsPerPage: 12,
CourseId: 0,
Title: "",
PointName: "", //知识点
QuestionTypeId: [], //题型
DifficultyType: [], //难易程度
QCategoryId:[],//分类
},
pageCount: 0,
questionTypeList: [], //问题类型列表
questionDifficultyTypeList: [], //问题难易程度列表
isShowQuestionForm: false,
questionObj: null,
importType: 0, //导入类型(1-模板导入;2-智能导入)
isShowImportUpload: false, //是否显示导入模板
questionCategoryList: [], //问题分类
}
},
created() {
if (this.$route.query) {
this.msg.CourseId = this.$route.query.CourseId
}
this.getQuestionType();
this.getDifficultyType();
this.getQuestionCategory();
},
mounted() {
this.getQuestionList();
},
methods: {
//获取问题大类
getQuestionCategory() {
queryQuestionCategory().then(res => {
this.questionCategoryList = res.Data;
})
},
research() {
this.msg.pageIndex = 1;
this.getQuestionList();
},
importQuestion(type) {
this.importType = type;
this.isShowImportUpload = true;
},
//获取题型列表
getQuestionType() {
queryQuestionTypeList({}).then(res => {
if (res.Code == 1) {
this.questionTypeList = res.Data;
}
});
},
//获取问题难易程度列表
getDifficultyType() {
queryDifficultyType().then(res => {
if (res.Code == 1) {
var tempArray = res.Data;
tempArray.splice(0, 1);
this.questionDifficultyTypeList = tempArray;
}
});
},
//删除问题
setQuestionStatus(item) {
this.$q.dialog({
title: "删除问题",
message: "你正在进行删除问题行为,一旦执行无法找回,是否确认执行?",
persistent: true,
cancel: {
label: "取消",
flat: true
},
ok: {
label: "确认",
flat: true,
focus: true
}
}).onOk(() => {
deleteQuestion({
QuestionId: item.QuestionId
}).then(res => {
if (res.Code == 1) {
this.$q.notify({
icon: 'iconfont icon-chenggong',
color: 'accent',
timeout: 2000,
message: '删除成功!',
position: 'top'
})
this.getQuestionList();
} else {
this.$q.notify({
icon: 'iconfont icon-chenggong',
color: 'accent',
timeout: 2000,
message: res.Message,
position: 'top'
})
}
});
});
},
//翻页
changePage(val) {
this.msg.pageIndex = val;
this.getQuestionList()
},
//获取问题分页列表
getQuestionList() {
this.loading = true;
queryQuestionPageList(this.msg).then(res => {
this.loading = false;
this.data = res.Data.PageData;
this.pageCount = res.Data.PageCount;
this.data.forEach((x,index)=>{
if(index==0){
x.isShowFirst=false
}else{
x.isShowFirst=true
}
if(index==this.data.length-1){
x.isShowLast=false
}else{
x.isShowLast=true
}
})
}).catch(() => {
this.loading = false
})
},
//刷新页面
refreshQuestion() {
this.isShowQuestionForm = false;
this.isShowImportUpload = false;
this.getQuestionList();
},
//新增修改问题
EditQuestion(obj) {
if (obj) {
this.questionObj = obj
} else {
this.questionObj = null
}
this.isShowQuestionForm = true
},
//关闭弹窗
closeQuestion() {
this.isShowQuestionForm = false;
this.questionObj = null;
this.isShowImportUpload = false;
this.importType = 0;
},
//上移
getUpStatus(item,num){
console.log(item,'数据');
var QuestionId = item.QuestionId;
var index = -1;
for(var i=0;i<this.data.length;i++){
if(this.data[i].QuestionId==QuestionId){
index=i;
break;
}
}
if(num==1){ //上移
var targetQId = this.data[index-1].QuestionId;
}
if(num==2){ //下移
var targetQId = this.data[index+1].QuestionId;
}
console.log(targetQId,'targetQId');
var msg = {
curQId:QuestionId,
targetQId:targetQId
}
UpdateQuestionSort(msg).then(res => {
console.log(res,'数据');
if (res.Code == 1) {
this.getQuestionList();
}
});
},
//复制
getCopyItem(item){
}
}
}
</script>
<style lang="sass">
@import url('~assets/css/table.sass')
</style>
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