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

bug fixes

上级 9bddb8e8
...@@ -101,7 +101,7 @@ export default { ...@@ -101,7 +101,7 @@ export default {
// 是否含有翻页 // 是否含有翻页
hasPagination: { type: Boolean, default: true }, hasPagination: { type: Boolean, default: true },
// 每页多少条数据 // 每页多少条数据
limit: { type: Number, default: 20 }, limit: { type: Number, default: 10 },
pagationLayout: { type: String, default: 'total, prev, pager, next, sizes, jumper' } pagationLayout: { type: String, default: 'total, prev, pager, next, sizes, jumper' }
}, },
data() { data() {
......
...@@ -29,12 +29,13 @@ ...@@ -29,12 +29,13 @@
</template> </template>
<script> <script>
import { getQuestionCategory } from '@/api/base.js' import { isEqual } from 'lodash'
export default { export default {
props: { props: {
value: [String, Array], value: [String, Array],
multiple: { type: Boolean, default: false }, multiple: { type: Boolean, default: false },
checkStrictly: { type: Boolean, default: true } checkStrictly: { type: Boolean, default: true },
isRequestRemote: { type: Boolean, default: true } // 是否请求远程数据,
}, },
data() { data() {
return { return {
...@@ -63,16 +64,18 @@ export default { ...@@ -63,16 +64,18 @@ export default {
return { label: 'category_name', value: 'id' } return { label: 'category_name', value: 'id' }
} }
}, },
beforeMount() { mounted() {
this.getQuestionCategory() this.getQuestionCategory()
}, },
methods: { methods: {
getQuestionCategory() { async getQuestionCategory() {
getQuestionCategory({ project_prefix: this.activeProject.tag }).then(res => { let list = this.$store.state.questionCategory || []
this.$refs.select.options = res.data if (this.isRequestRemote || !list.length) {
this.options = res.data list = await this.$store.dispatch('getQuestionCategory', { project_prefix: this.activeProject.tag })
}
this.$refs.select.options = list
this.options = list
this.$nextTick(this.setChecked) this.$nextTick(this.setChecked)
})
}, },
setChecked() { setChecked() {
const RefTree = this.$refs.tree const RefTree = this.$refs.tree
...@@ -114,6 +117,9 @@ export default { ...@@ -114,6 +117,9 @@ export default {
this.handleUpdate(value) this.handleUpdate(value)
}, },
handleUpdate(value) { handleUpdate(value) {
if (isEqual(value, this.value)) {
return
}
this.$emit('input', value) this.$emit('input', value)
this.$emit('change', value) this.$emit('change', value)
} }
......
...@@ -42,6 +42,7 @@ ...@@ -42,6 +42,7 @@
<template slot-scope="{ row, $index }"> <template slot-scope="{ row, $index }">
<question-type-treeselect <question-type-treeselect
multiple multiple
:isRequestRemote="false"
v-model="row.question_categories" v-model="row.question_categories"
@change="getQuestionMaxCount($index, row)" @change="getQuestionMaxCount($index, row)"
style="width: 100%" style="width: 100%"
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
<el-descriptions :column="2" class="descriptionsCon"> <el-descriptions :column="2" class="descriptionsCon">
<el-descriptions-item label="试卷名称">{{ detail.paper_title }}</el-descriptions-item> <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_labels }}</el-descriptions-item>
<el-descriptions-item label="试卷分类">{{ detail.paper_category.category_name }}</el-descriptions-item> <el-descriptions-item label="试卷分类">{{ detail.paper_category.name }}</el-descriptions-item>
<el-descriptions-item label="组卷模式">{{ detail.paper_type_name }}</el-descriptions-item> <el-descriptions-item label="组卷模式">{{ detail.paper_type_name }}</el-descriptions-item>
<el-descriptions-item label="试卷总分">{{ detail.paper_total_score }}</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.pass_score }}</el-descriptions-item>
...@@ -42,6 +42,8 @@ export default { ...@@ -42,6 +42,8 @@ export default {
}, },
beforeMount() { beforeMount() {
this.getDetail() this.getDetail()
// 获取试题分类,组卷的时候用,只请求一次
this.$store.dispatch('getQuestionCategory', { project_prefix: this.$store.state.activeProject.tag })
}, },
methods: { methods: {
// 获取试卷详情 // 获取试卷详情
......
...@@ -99,7 +99,7 @@ export default { ...@@ -99,7 +99,7 @@ export default {
return map[row.paper_type] || row.paper_type return map[row.paper_type] || row.paper_type
} }
}, },
{ label: '试卷分类', prop: 'paper_category.category_name', minWidth: 200 }, { label: '试卷分类', prop: 'paper_category.name', minWidth: 200 },
{ label: '试卷名称', prop: 'paper_title', minWidth: 200 }, { label: '试卷名称', prop: 'paper_title', minWidth: 200 },
{ label: '总分', prop: 'paper_total_score' }, { label: '总分', prop: 'paper_total_score' },
{ label: '及格分数', prop: 'pass_score' }, { label: '及格分数', prop: 'pass_score' },
......
import Vue from 'vue' import Vue from 'vue'
import Vuex from 'vuex' import Vuex from 'vuex'
import { getUser, logout, getAllProjects } from '@/api/base' import { getUser, logout, getAllProjects, getQuestionCategory } from '@/api/base'
Vue.use(Vuex) Vue.use(Vuex)
...@@ -8,7 +8,8 @@ const store = new Vuex.Store({ ...@@ -8,7 +8,8 @@ const store = new Vuex.Store({
state: { state: {
user: {}, user: {},
projects: [], // 项目列表 projects: [], // 项目列表
activeProject: {} // 当前激活的项目 activeProject: {}, // 当前激活的项目
questionCategory: [] // 试题分类
}, },
mutations: { mutations: {
setUser(state, user) { setUser(state, user) {
...@@ -23,6 +24,9 @@ const store = new Vuex.Store({ ...@@ -23,6 +24,9 @@ const store = new Vuex.Store({
setActiveProjedct(state, project = {}) { setActiveProjedct(state, project = {}) {
state.activeProject = project state.activeProject = project
localStorage.setItem('project_tag', project.tag || '') localStorage.setItem('project_tag', project.tag || '')
},
setQuestionCategory(state, questionCategory) {
state.questionCategory = questionCategory
} }
}, },
actions: { actions: {
...@@ -69,6 +73,12 @@ const store = new Vuex.Store({ ...@@ -69,6 +73,12 @@ const store = new Vuex.Store({
return false return false
}) })
return isLogin return isLogin
},
getQuestionCategory({ commit }, params) {
return getQuestionCategory(params).then(res => {
commit('setQuestionCategory', res.data)
return res.data
})
} }
} }
}) })
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论