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

updates

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