提交 ef96bacc authored 作者: 王鹏飞's avatar 王鹏飞

updates

上级 47c73abe
......@@ -32,3 +32,10 @@ export function uploadFile(data) {
export function getAllProjects() {
return httpRequest.get('/api/qbs/admin/v1/projects')
}
/**
* 获取试卷分类
*/
export function getQuestionCategory(params) {
return httpRequest.get(`/api/qbs/admin/v1/question-category/tree/${params.project_prefix}`, { params })
}
......@@ -163,7 +163,7 @@ export default {
.then(res => {
const { data = {} } = res || {}
this.page.total = parseInt(data.total || 0)
this.dataList = callback ? callback(data) : data.list
this.dataList = callback ? callback(data) : data.list || data.data
})
.catch(() => {
this.page.total = 0
......
<template>
<el-cascader
clearable
:options="options"
:props="defaultProps"
v-on="$listeners"
@change="handleChange"
></el-cascader>
</template>
<script>
import { getQuestionCategory } from '@/api/base.js'
export default {
data() {
return {
options: [],
defaultProps: {
label: 'category_name',
value: 'id',
checkStrictly: true
}
}
},
computed: {
activeProject() {
return this.$store.state.activeProject || {}
}
},
beforeMount() {
this.getQuestionCategory()
},
methods: {
getQuestionCategory() {
getQuestionCategory({ project_prefix: this.activeProject.tag }).then(res => {
// 移除空数组
const options = JSON.parse(JSON.stringify(res.data).replaceAll(',"children":[]', ''))
this.options = options
})
},
handleChange(value = []) {
const lastValue = value[value.length - 1]
this.$emit('input', lastValue)
}
}
}
</script>
<style></style>
......@@ -38,7 +38,7 @@ export default {
name: '试卷中心',
path: '/paper',
icon: 'el-icon-toilet-paper',
children: [{ name: '我的试卷库', path: '/paper/list' }]
children: [{ name: '我的试卷库', path: '/paper' }]
},
{
name: '考试中心',
......
......@@ -10,17 +10,33 @@ export function getKnowledge(params) {
* 获取试卷列表
*/
export function getPaperList(params) {
return httpRequest.get('/api/qbs/admin/v1/question-papers/x1', { params })
return httpRequest.get(`/api/qbs/admin/v1/question-papers/${params.project_prefix}`, { params })
}
/**
* 新建试卷
*/
export function createNewPaper(data) {
export function createPaper(data) {
return httpRequest.post('/api/qbs/admin/v1/question-paper', data)
}
/**
* 更新试卷
*/
export function updatePaper(data) {
return httpRequest.put(`/api/qbs/admin/v1/question-paper/${data.id}`, data)
}
/**
* 获取试卷详情
*/
export function getPaper(params) {
return httpRequest.get(`/api/qbs/admin/v1/question-paper/${params.id}`, { params })
}
/**
* 获取试卷分类
*/
export function getPaperCategory(params) {
return httpRequest.get(`/api/qbs/admin/v1/question-category/tree/${params}`, { params })
return httpRequest.get(`/api/qbs/admin/v1/question-category/tree/${params.project_prefix}`, { params })
}
......@@ -3,8 +3,8 @@
<el-row :gutter="20">
<!-- 试题列表 -->
<el-col :span="18">
<el-card id="questionMain"
><div slot="header" class="clearfix">
<el-card id="questionMain">
<div slot="header" class="clearfix">
<span class="clearfix_tit"> 试题列表</span>
<el-button class="clearfix_del" type="primary" @click="delCheckedQuestion" v-if="questionList.length > 0"
>删除所选试题</el-button
......
<template>
<el-dialog title="添加试卷试题" v-bind="$attrs" v-on="$listeners"></el-dialog>
</template>
<script>
export default {
props: { data: { type: Object, default: () => ({}) } },
data() {
return {}
}
}
</script>
<style></style>
......@@ -5,33 +5,32 @@ const routes = [
path: '/paper',
component: AppLayout,
meta: { title: '试卷中心' },
redirect: '/paper/list',
children: [
{
path: '',
redirect: '/paper/list'
},
{
path: 'list',
component: () => import('./views/List.vue'),
meta: { title: '我的试卷库' }
},
{
path: 'newPaper',
name: 'newPaper',
name: 'createPaper',
path: 'create',
component: () => import('./views/NewPaper.vue'),
meta: { title: '新建试卷' }
},
{
path: 'newPapers',
name: 'newPaper',
name: 'editPaper',
path: 'update/:id',
component: () => import('./views/NewPaper.vue'),
meta: { title: '编辑试卷' }
meta: { title: '编辑试卷' },
props: true
},
{
path: 'detail',
name: 'detail',
name: 'viewPaper',
path: 'detail/:id',
component: () => import('./views/Detail.vue'),
meta: { title: '试卷详情' }
meta: { title: '试卷详情' },
props: true
}
]
}
......
<template>
<div>
<!-- 试卷描述 -->
<el-card>
<el-descriptions :column="2" class="descriptionsCon">
<template slot="extra">
<el-button type="primary" @click="editPaper">编辑试卷</el-button>
<app-card title="试卷信息">
<template #header-aside>
<el-button type="primary" size="mini" @click="handleUpdate">编辑试卷</el-button>
</template>
<el-descriptions-item label="试卷名称">{{ paperDetail.paperName }}</el-descriptions-item>
<el-descriptions-item label="标签">1111</el-descriptions-item>
<el-descriptions-item label="试卷分类">{{ paperDetail.paperType }}</el-descriptions-item>
<el-descriptions-item label="组卷模式">{{ paperDetail.paperMode }}</el-descriptions-item>
<el-descriptions-item label="试卷总分">{{ paperDetail.paperTotalScore }}</el-descriptions-item>
<el-descriptions-item label="及格分数">{{ paperDetail.paperPassScore }}</el-descriptions-item>
<el-descriptions-item label="考试时长">40分钟</el-descriptions-item>
<el-descriptions-item label="最短交卷时长">20分钟</el-descriptions-item>
<el-descriptions-item label="试题顺序">固定</el-descriptions-item>
<el-descriptions-item label="多次考试"></el-descriptions-item>
<el-descriptions-item label="多次考试成绩计算规则">平均计算法 </el-descriptions-item>
<el-descriptions :column="2" class="descriptionsCon">
<el-descriptions-item label="试卷名称">{{ detail.paper_title }}</el-descriptions-item>
<el-descriptions-item label="标签">{{ detail.paper_labels }}</el-descriptions-item>
<el-descriptions-item label="试卷分类">{{ detail.paper_category }}</el-descriptions-item>
<el-descriptions-item label="组卷模式">{{ detail.paper_type }}</el-descriptions-item>
<el-descriptions-item label="试卷总分">{{ detail.paper_total_score }}</el-descriptions-item>
<el-descriptions-item label="及格分数">{{ detail.pass_score }}</el-descriptions-item>
<el-descriptions-item label="考试时长">{{ detail.paper_times }}分钟</el-descriptions-item>
<el-descriptions-item label="最短交卷时长">{{ detail.minimum_paper_handing_time }}分钟</el-descriptions-item>
<el-descriptions-item label="试题顺序">{{ detail.paper_question_order }}</el-descriptions-item>
<el-descriptions-item label="多次考试">{{ detail.is_multiple_exams }}</el-descriptions-item>
<el-descriptions-item label="多次考试成绩计算规则">{{ detail.multiple_test_score_rule }}</el-descriptions-item>
</el-descriptions>
</el-card>
</app-card>
<!-- 试卷列表 -->
<QuestionList :paperMode="paperDetail.paperMode" :paperTotalScore="paperDetail.paperTotalScore" />
<QuestionList :paperMode="detail.paperMode" :paperTotalScore="detail.paperTotalScore" />
</div>
</template>
<script>
import QuestionList from '../components/QuestionList.vue'
import { getPaper } from '../api.js'
export default {
props: { id: { type: String } },
components: { QuestionList },
computed: {
paperDetail() {
return JSON.parse(this.$route.query.paperDetail)
data() {
return {
detail: {}
}
},
// watch: {
// paperDetail: {
// paperDetail: {
// immediate: true,
// handler(data) {
// this.form = Object.assign({}, this.form, data)
// }
// }
// }
// },
computed: {},
beforeMount() {
this.getDetail()
},
methods: {
// 编辑试卷
editPaper() {
this.$router.push({
path: 'newPaper',
query: {
paperDetail: this.paperDetail,
isEdit: true
}
// 获取试卷详情
getDetail() {
getPaper({ id: this.id }).then(res => {
this.detail = Object.assign({}, this.detail, res.data)
})
},
// 编辑试卷
handleUpdate() {
this.$router.push({ name: 'editPaper', params: { id: this.detail.id } })
}
}
}
......
......@@ -2,65 +2,49 @@
<app-card>
<app-list v-bind="tableOptions" ref="list" @selection-change="handleSelectionChange">
<div class="btn_operate">
<el-button type="primary" icon="el-icon-plus" @click="handleCreatePaper">新建试卷</el-button>
<el-button type="primary" icon="el-icon-plus" @click="batchDelete">批量删除</el-button>
</div>
<template v-slot:input-filter>
<div class="filter-input">
<el-select v-model="filterInput" placeholder="请选择试题分类">
<el-option :label="treeValue.name" :value="treeValue.id"></el-option>
</el-select>
<div class="pop" @click="dialogVisible = true"></div>
<el-button type="primary" icon="el-icon-plus" @click="handleCreate">新建试卷</el-button>
<el-button type="primary" icon="el-icon-delete" @click="batchDelete">批量删除</el-button>
</div>
<template v-slot:filter-category="{ params }">
<question-type-cascader v-model="params.paper_category"></question-type-cascader>
</template>
<template v-slot:table-x="{ row }">
<el-button type="text" @click="handleDdit(row)">编辑</el-button>
<el-button type="text" @click="handleDetail(row)">查看详情</el-button>
<el-button type="text" @click="handleUpdate(row)">编辑</el-button>
<el-button type="text" @click="handleView(row)">查看详情</el-button>
<el-button type="text" @click="handleDelete(row)">删除</el-button>
</template>
<el-dialog title="提示" :visible.sync="dialogVisible" width="30%" :before-close="handleClose">
<el-tree
:data="treeList"
:props="defaultProps"
@node-click="handleNodeClick"
:expand-on-click-node="false"
></el-tree>
<span slot="footer" class="dialog-footer">
<el-button @click="handleClose">取 消</el-button>
<el-button type="primary" @click="dialogConfirm">确 定</el-button>
</span>
</el-dialog>
</app-list>
</app-card>
</template>
<script>
import { getPaperList, getPaperCategory } from '../api'
import { getPaperList } from '../api'
import QuestionTypeCascader from '@/components/base/QuestionTypeCascader.vue'
const paperType = [
{ label: '选题组卷', value: 0 },
{ label: '自动组卷', value: 1 }
{ label: '选题组卷', value: 1 },
{ label: '自动组卷', value: 2 }
]
export default {
components: { QuestionTypeCascader },
data() {
return {
visible: false,
multipleSelection: [], // 选择项
treeList: [],
dialogVisible: false,
defaultProps: '',
filterInput: '',
treeValue: {
name: '',
id: ''
}
paperCategoryList: []
}
},
computed: {
activeProject() {
return this.$store.state.activeProject || {}
},
tableOptions() {
return {
remote: {
httpRequest: getPaperList,
params: {
project_prefix: this.activeProject.tag,
id: '',
paper_title: '',
paper_type: '',
......@@ -92,111 +76,47 @@ export default {
},
{
slots: 'input-filter',
prop: 'question_category',
type: 'input',
label: '试卷分类:'
type: 'select',
prop: 'paperType',
label: '试卷分类:',
slots: 'filter-category'
}
],
columns: [
{ type: 'selection', minWidth: '50px', fixed: 'left' },
{ type: 'selection', width: '50px', fixed: 'left' },
{ type: 'index', label: '序号', minWidth: '50px', fixed: 'left' },
{ label: '组卷模式', prop: 'paper_type' },
{ label: '试卷分类', prop: 'paper_category' },
{ label: '试卷名称', prop: 'paper_title' },
{ label: '总分', prop: 'paper_total_score' },
{ label: '及格分数', prop: 'paperPassScore' },
{ label: '更新人', prop: 'operator.username' },
{ label: '及格分数', prop: 'pass_score' },
{ label: '更新人', prop: 'operator.realname' },
{ label: '更新时间', prop: 'updated_at' },
{ label: '操作', slots: 'table-x', align: 'right', width: 150 }
]
}
}
},
mounted() {
// 获取试卷分类
this.getTreeList()
},
methods: {
getTreeList() {
getPaperCategory('x1').then(res => {
if (Array.isArray(res.data)) {
this.initTree(res.data)
}
})
},
// 过滤数据 变成tree组件需要的数据
initTree(data) {
this.treeList = data.reduce((a, b) => {
b.label = b.category_name
if (b.children.length) {
setData(b.children)
}
a.push(b)
return a
}, [])
function setData(item) {
return item.map(element => {
if (element.children.length) {
setData(element.children)
element.label = element.category_name
} else {
element.label = element.category_name
}
return element
})
}
},
handleNodeClick(data) {
this.treeValue.name = data.label
this.treeValue.id = data.id
},
handleClose() {
this.treeValue.name = ''
this.treeValue.id = ''
this.dialogVisible = false
},
dialogConfirm() {
this.dialogVisible = false
this.filterInput = this.treeValue.name
this.$refs.list.refetch()
},
// 新建试卷
handleCreatePaper() {
this.$router.push({
path: 'newPaper',
query: { isEdit: false }
})
handleCreate() {
this.$router.push({ name: 'createPaper' })
},
// 编辑试卷
handleDdit(row) {
console.log(row)
this.$router.push({
path: 'newPapers',
query: {
rowDetail: row,
isEdit: true
}
})
handleUpdate(row) {
this.$router.push({ name: 'editPaper', params: { id: row.id } })
},
// 查看详情
handleView(row) {
this.$router.push({ name: 'viewPaper', params: { id: row.id } })
},
handleSelectionChange(val) {
this.multipleSelection = val
console.log(val)
},
// 批量删除
batchDelete() {
console.log('111')
},
// 查看详情
handleDetail(row) {
this.$router.push({
path: 'detail',
query: {
paperDetail: JSON.stringify(row)
}
})
},
// 单个删除
handleDelete(row) {
// this.$refs.list.refetch()
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论