增加题目启用功能完成
This commit is contained in:
parent
3545c29c45
commit
d65c17c793
|
@ -121,4 +121,12 @@ export function exportQuestion(query) {
|
|||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
}
|
||||
|
||||
export function enableQuestions(data) {
|
||||
return request({
|
||||
url: '/question/question/enable/',
|
||||
method: 'post',
|
||||
data
|
||||
})
|
||||
}
|
|
@ -44,6 +44,9 @@
|
|||
>刷新重置</el-button>
|
||||
<div style="margin-top:10px">
|
||||
<el-button type="primary" slot="reference" @click="handleAdd()">新增</el-button>
|
||||
<el-button
|
||||
@click="handleEnabled"
|
||||
>启用</el-button>
|
||||
<el-popover
|
||||
placement="top"
|
||||
width="160"
|
||||
|
@ -79,20 +82,27 @@
|
|||
highlight-current-row
|
||||
max-height="600"
|
||||
@sort-change="changeSort"
|
||||
@selection-change="handleSelectionChange"
|
||||
>
|
||||
<el-table-column type="index" width="50"></el-table-column>
|
||||
<el-table-column align="left" label="题干" sortable="custom" prop="name">
|
||||
<el-table-column type="selection" width="55"></el-table-column>
|
||||
<el-table-column label="题干" sortable="custom" prop="name">
|
||||
<template slot-scope="scope">{{ scope.row.name }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column align="left" label="所属题库">
|
||||
<el-table-column label="所属题库">
|
||||
<template slot-scope="scope">{{ scope.row.questioncat_name }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column align="left" label="题型">
|
||||
<el-table-column label="题型">
|
||||
<template slot-scope="scope">{{ scope.row.type }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column align="left" label="难易度">
|
||||
<el-table-column label="难易度">
|
||||
<template slot-scope="scope">{{ scope.row.level }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="是否启用">
|
||||
<template slot-scope="scope">
|
||||
<el-tag v-if="scope.row.enabled" type="success">是</el-tag>
|
||||
<el-tag v-else type="danger">否</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="创建日期">
|
||||
<template slot-scope="scope">
|
||||
<span>{{ scope.row.create_time }}</span>
|
||||
|
@ -137,7 +147,7 @@
|
|||
<div>{{question.type}}</div>
|
||||
<div >{{question.name}}</div>
|
||||
<ul id="repeat">
|
||||
<li v-for="(value,key,index) in question.options">
|
||||
<li v-for="(value,key) in question.options" v-bind:key="key">
|
||||
{{ key }}:
|
||||
<span>{{value}}</span>
|
||||
</li>
|
||||
|
@ -157,7 +167,8 @@ import {
|
|||
getQuestionList,
|
||||
deleteQuestion,
|
||||
importQuestion,
|
||||
exportQuestion
|
||||
exportQuestion,
|
||||
enableQuestions
|
||||
} from "@/api/question";
|
||||
import { genTree, deepClone } from "@/utils";
|
||||
import checkPermission from "@/utils/permission";
|
||||
|
@ -202,6 +213,7 @@ export default {
|
|||
],
|
||||
question:{},
|
||||
questioncatC:[],
|
||||
selects:[],
|
||||
};
|
||||
},
|
||||
computed: {},
|
||||
|
@ -313,6 +325,23 @@ export default {
|
|||
|
||||
this.getList();
|
||||
},
|
||||
handleSelectionChange(val) {
|
||||
let selects = [];
|
||||
for (var i = 0; i < val.length; i++) {
|
||||
selects.push(val[i].id);
|
||||
}
|
||||
this.selects = selects;
|
||||
},
|
||||
handleEnabled() {
|
||||
if (this.selects.length) {
|
||||
enableQuestions({ids:this.selects}).then(res=>{
|
||||
this.$message.success("成功");
|
||||
this.getList();
|
||||
})
|
||||
} else {
|
||||
this.$message.warning("请先选择题目");
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
|
|
@ -143,6 +143,13 @@ class QuestionViewSet(ModelViewSet):
|
|||
i.save()
|
||||
return Response()
|
||||
|
||||
@action(methods=['post'], detail=False, url_name='enable_question', permission_classes=[IsAuthenticated])
|
||||
def enable(self, request):
|
||||
ids = request.data.get('ids',None)
|
||||
if ids:
|
||||
Question.objects.filter(pk__in=ids).update(enabled=True)
|
||||
return Response(status=status.HTTP_200_OK)
|
||||
|
||||
@action(methods=['post'], detail=False,
|
||||
url_path='import', url_name='import_question',perms_map=[{'post':'question_import'}])
|
||||
def import_question(self, request):
|
||||
|
|
Loading…
Reference in New Issue