提交 0c9619a0 authored 作者: lihuihui's avatar lihuihui

update

上级 9b95b3b4
...@@ -9,13 +9,13 @@ ...@@ -9,13 +9,13 @@
<template v-if="source == 1"> <template v-if="source == 1">
<div class="radio-box"> <div class="radio-box">
<div class="tips-tit index">请选择题库:</div> <div class="tips-tit index">请选择题库:</div>
<el-radio @change="radioChange" v-model="questionBank" label="1">我的题库</el-radio> <el-radio @change="refetchList" v-model="questionBank" label="1">我的题库</el-radio>
<el-radio @change="radioChange" v-model="questionBank" label="2" style="text-indent: 1.5em">公共题库</el-radio> <el-radio @change="refetchList" v-model="questionBank" label="2" style="text-indent: 1.5em">公共题库</el-radio>
</div> </div>
<app-list v-bind="tableOptions" ref="list" class="app-list" @selection-change="handleSelectionChange"> <app-list v-bind="tableOptions" ref="list" class="app-list" @selection-change="handleSelectionChange">
<template v-slot:input-filter> <template v-slot:filter-category="{ params }">
<div class="filter-input"> <div class="filter-input">
<question-type-cascader v-model="filterInput"></question-type-cascader> <question-type-cascader v-model="params.question_category" @change="refetchList"></question-type-cascader>
</div> </div>
</template> </template>
</app-list> </app-list>
...@@ -40,7 +40,7 @@ ...@@ -40,7 +40,7 @@
<script> <script>
import { getAppList } from '../api' import { getAppList } from '../api'
import QuestionTypeCascader from '@/components/base/QuestionTypeCascader.vue' import QuestionTypeCascader from '@/components/base/QuestionTypeTreeselect.vue'
export default { export default {
components: { components: {
QuestionTypeCascader QuestionTypeCascader
...@@ -56,6 +56,9 @@ export default { ...@@ -56,6 +56,9 @@ export default {
} }
}, },
computed: { computed: {
activeProject() {
return this.$store.state.activeProject || {}
},
tableOptions() { tableOptions() {
return { return {
limit: 10, limit: 10,
...@@ -92,7 +95,7 @@ export default { ...@@ -92,7 +95,7 @@ export default {
] ]
}, },
{ {
slots: 'input-filter', slots: 'filter-category',
prop: 'question_category', prop: 'question_category',
type: 'input', type: 'input',
label: '试题分类:' label: '试题分类:'
...@@ -108,8 +111,8 @@ export default { ...@@ -108,8 +111,8 @@ export default {
params: { params: {
question_types: [1, 2, 3, 6], question_types: [1, 2, 3, 6],
permission: this.questionBank, permission: this.questionBank,
project_prefix: 'x1', project_prefix: this.activeProject.tag,
question_category: this.filterInput question_category: ''
}, },
callback(data) { callback(data) {
const questionType = { const questionType = {
...@@ -150,7 +153,7 @@ export default { ...@@ -150,7 +153,7 @@ export default {
} }
}, },
mounted() { mounted() {
this.getTreeList() // this.getTreeList()
}, },
methods: { methods: {
// 列表checked点击 重整数据:组合成与题对应的数据 // 列表checked点击 重整数据:组合成与题对应的数据
...@@ -167,7 +170,7 @@ export default { ...@@ -167,7 +170,7 @@ export default {
}, []) }, [])
}, },
// 筛选更新列表 // 筛选更新列表
radioChange() { refetchList() {
this.$refs.list.refetch() this.$refs.list.refetch()
}, },
// 添加题型 // 添加题型
......
...@@ -39,12 +39,7 @@ ...@@ -39,12 +39,7 @@
<v-editor :disabled="!!($route.query.type === 'view')" v-model="ruleForm.question_analysis"></v-editor> <v-editor :disabled="!!($route.query.type === 'view')" v-model="ruleForm.question_analysis"></v-editor>
</el-form-item> </el-form-item>
<el-form-item label="试题分类" prop="question_category"> <el-form-item label="试题分类" prop="question_category">
<div class="filter-input"> <question-type-cascader v-model="ruleForm.question_category"></question-type-cascader>
<el-select v-model="ruleForm.question_category" placeholder="请选择试题分类">
<el-option v-if="!dialogVisible" :label="treeValue.name" :value="treeValue.id"></el-option>
</el-select>
<div class="pop" @click="dialogVisible = true"></div>
</div>
</el-form-item> </el-form-item>
<el-form-item label="知识点"> <el-form-item label="知识点">
<el-select <el-select
...@@ -65,21 +60,8 @@ ...@@ -65,21 +60,8 @@
<template v-else> <template v-else>
<el-button type="primary" @click="submitForm('ruleForm')">立即创建</el-button> <el-button type="primary" @click="submitForm('ruleForm')">立即创建</el-button>
</template> </template>
<!-- <el-button @click="resetForm('ruleForm')">重置</el-button> -->
</el-form-item> </el-form-item>
</el-form> </el-form>
<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>
</div> </div>
</template> </template>
<script> <script>
...@@ -87,9 +69,10 @@ import VEditor from '@/components/tinymce/Index.vue' ...@@ -87,9 +69,10 @@ import VEditor from '@/components/tinymce/Index.vue'
import Radio from '../components/QTypeRadio.vue' import Radio from '../components/QTypeRadio.vue'
import Checkbox from '../components/QTypeCheckbox.vue' import Checkbox from '../components/QTypeCheckbox.vue'
import Judgment from '../components/QTypeJudgment.vue' import Judgment from '../components/QTypeJudgment.vue'
import { getQuestionCategory, searchTag, addQuestion, updateQuestion } from '../api' import QuestionTypeCascader from '@/components/base/QuestionTypeTreeselect.vue'
import { searchTag, addQuestion, updateQuestion } from '../api'
export default { export default {
components: { VEditor, Radio, Checkbox, Judgment }, components: { VEditor, Radio, Checkbox, Judgment, QuestionTypeCascader },
props: { props: {
detailData: { detailData: {
type: Object type: Object
...@@ -98,13 +81,6 @@ export default { ...@@ -98,13 +81,6 @@ export default {
data() { data() {
return { return {
pointOptions: [], pointOptions: [],
treeList: [],
defaultProps: '',
treeValue: {
name: '',
id: ''
},
dialogVisible: false,
ruleForm: { ruleForm: {
permission: '1', permission: '1',
project_prefix: 'x1', project_prefix: 'x1',
...@@ -146,16 +122,11 @@ export default { ...@@ -146,16 +122,11 @@ export default {
created() { created() {
if (this.detailData) { if (this.detailData) {
this.ruleForm = this.detailData this.ruleForm = this.detailData
this.treeValue.name = this.detailData.question_category.category_name
this.treeValue.id = this.detailData.question_category.id
this.ruleForm.question_category = this.detailData.question_category.id this.ruleForm.question_category = this.detailData.question_category.id
this.pointOptions.push(this.detailData.knowledge_point) this.pointOptions.push(this.detailData.knowledge_point)
this.ruleForm.knowledge_point = this.detailData.knowledge_point.id this.ruleForm.knowledge_point = this.detailData.knowledge_point.id
} }
}, },
mounted() {
this.getTreeList()
},
computed: { computed: {
activeProject() { activeProject() {
return this.$store.state.activeProject || {} return this.$store.state.activeProject || {}
...@@ -187,50 +158,6 @@ export default { ...@@ -187,50 +158,6 @@ export default {
resetForm(formName) { resetForm(formName) {
this.$refs[formName].resetFields() this.$refs[formName].resetFields()
}, },
// 点击选中tree
handleNodeClick(data) {
this.treeValue.name = data.label
this.treeValue.id = data.id
},
// 关闭选择tree弹窗
handleClose() {
this.dialogVisible = false
},
// tree确认选择
dialogConfirm() {
this.dialogVisible = false
this.ruleForm.question_category = this.treeValue.id
},
// 获取tree列表
getTreeList() {
getQuestionCategory('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
})
}
},
// 知识点搜索 // 知识点搜索
remoteMethod(query) { remoteMethod(query) {
searchTag({ project_prefix: this.activeProject.tag, title: query }).then(res => { searchTag({ project_prefix: this.activeProject.tag, title: query }).then(res => {
......
...@@ -31,25 +31,8 @@ ...@@ -31,25 +31,8 @@
<el-input v-model="ruleForm.question_tag"></el-input> <el-input v-model="ruleForm.question_tag"></el-input>
</el-form-item> </el-form-item>
<el-form-item label="试题分类" prop="question_category"> <el-form-item label="试题分类" prop="question_category">
<div class="filter-input"> <question-type-cascader v-model="ruleForm.question_category"></question-type-cascader>
<el-select v-model="ruleForm.question_category" placeholder="请选择试题分类">
<el-option v-if="!dialogVisible" :label="treeValue.name" :value="treeValue.id"></el-option>
</el-select>
<div class="pop" @click="dialogVisible = true"></div>
</div>
</el-form-item> </el-form-item>
<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>
<el-form-item label="知识点"> <el-form-item label="知识点">
<el-select <el-select
v-model="ruleForm.knowledge_point" v-model="ruleForm.knowledge_point"
...@@ -77,9 +60,10 @@ ...@@ -77,9 +60,10 @@
import QuestionsChidren from './QuestionsChidren.vue' import QuestionsChidren from './QuestionsChidren.vue'
import VEditor from '@/components/tinymce/Index.vue' import VEditor from '@/components/tinymce/Index.vue'
import AddChidren from './AddChidren.vue' import AddChidren from './AddChidren.vue'
import { getQuestionCategory, searchTag, addQuestion, updateQuestion } from '../api' import QuestionTypeCascader from '@/components/base/QuestionTypeTreeselect.vue'
import { searchTag, addQuestion, updateQuestion } from '../api'
export default { export default {
components: { AddChidren, VEditor, QuestionsChidren }, components: { AddChidren, VEditor, QuestionsChidren, QuestionTypeCascader },
props: { props: {
questionTypeNumber: { questionTypeNumber: {
type: Number, type: Number,
...@@ -92,13 +76,6 @@ export default { ...@@ -92,13 +76,6 @@ export default {
data() { data() {
return { return {
pointOptions: [], pointOptions: [],
treeList: [],
defaultProps: '',
treeValue: {
name: '',
id: ''
},
dialogVisible: false,
chidrenList: [], chidrenList: [],
drawer: false, drawer: false,
ruleForm: { ruleForm: {
...@@ -136,8 +113,6 @@ export default { ...@@ -136,8 +113,6 @@ export default {
this.ruleForm.question_type = this.questionTypeNumber this.ruleForm.question_type = this.questionTypeNumber
if (this.detailData) { if (this.detailData) {
this.ruleForm = this.detailData this.ruleForm = this.detailData
this.treeValue.name = this.detailData.question_category.category_name
this.treeValue.id = this.detailData.question_category.id
this.ruleForm.question_category = this.detailData.question_category.id this.ruleForm.question_category = this.detailData.question_category.id
this.pointOptions.push(this.detailData.knowledge_point) this.pointOptions.push(this.detailData.knowledge_point)
this.ruleForm.knowledge_point = this.detailData.knowledge_point.id this.ruleForm.knowledge_point = this.detailData.knowledge_point.id
...@@ -146,7 +121,6 @@ export default { ...@@ -146,7 +121,6 @@ export default {
const cacheData = window.localStorage.cacheQuestion const cacheData = window.localStorage.cacheQuestion
if (cacheData) { if (cacheData) {
this.ruleForm = JSON.parse(cacheData).form this.ruleForm = JSON.parse(cacheData).form
this.treeValue = JSON.parse(cacheData).tree
this.pointOptions = JSON.parse(cacheData).pointOptions this.pointOptions = JSON.parse(cacheData).pointOptions
this.chidrenList = JSON.parse(cacheData).children this.chidrenList = JSON.parse(cacheData).children
} }
...@@ -157,9 +131,6 @@ export default { ...@@ -157,9 +131,6 @@ export default {
return this.$store.state.activeProject || {} return this.$store.state.activeProject || {}
} }
}, },
mounted() {
this.getTreeList()
},
methods: { methods: {
// 添加子题 drawer关闭 // 添加子题 drawer关闭
handleCloseDrawer() { handleCloseDrawer() {
...@@ -201,50 +172,6 @@ export default { ...@@ -201,50 +172,6 @@ export default {
questionTypeChange() { questionTypeChange() {
this.$emit('questionType', this.ruleForm.question_type) this.$emit('questionType', this.ruleForm.question_type)
}, },
// 点击选中tree
handleNodeClick(data) {
this.treeValue.name = data.label
this.treeValue.id = data.id
},
// 关闭选择tree弹窗
handleClose() {
this.dialogVisible = false
},
// tree确认选择
dialogConfirm() {
this.dialogVisible = false
this.ruleForm.question_category = this.treeValue.id
},
// 获取tree列表
getTreeList() {
getQuestionCategory('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
})
}
},
// 知识点搜索 // 知识点搜索
remoteMethod(query) { remoteMethod(query) {
searchTag({ project_prefix: this.activeProject.tag, title: query }).then(res => { searchTag({ project_prefix: this.activeProject.tag, title: query }).then(res => {
......
<template> <template>
<app-card> <app-card>
<template v-if="[1, 2, 3, 6].includes(questionTypeNum) && !cacheData"> <template v-if="[1, 2, 3, 6].includes(questionTypeNum) && !cache">
<template v-if="$route.query.id"> <template v-if="$route.query.id">
<detail v-if="Object.keys(detailData).length" :detailData="detailData" @questionType="questionType"></detail> <detail v-if="Object.keys(detailData).length" :detailData="detailData" @questionType="questionType"></detail>
</template> </template>
...@@ -24,12 +24,8 @@ export default { ...@@ -24,12 +24,8 @@ export default {
data() { data() {
return { return {
questionTypeNum: 1, questionTypeNum: 1,
detailData: {} detailData: {},
} cache: window.localStorage.cacheQuestion
},
computed: {
cacheData() {
return window.localStorage.cacheQuestion
} }
}, },
mounted() { mounted() {
...@@ -44,6 +40,7 @@ export default { ...@@ -44,6 +40,7 @@ export default {
}, },
methods: { methods: {
questionType(n) { questionType(n) {
this.cache = ''
this.questionTypeNum = n this.questionTypeNum = n
} }
} }
......
<template> <template>
<app-card> <app-card>
<app-list v-bind="tableOptions" ref="list" @selection-change="handleSelectionChange"> <app-list v-bind="tableOptions" ref="list" @selection-change="handleSelectionChange">
<template v-slot:radio-filter> <template v-slot:radio-filter="{ params }">
<el-radio @change="radioChange" v-model="filterRadio" :label=1>我的题库</el-radio> <el-radio @change="refetchList" v-model="params.permission" :label=1>我的题库</el-radio>
<el-radio @change="radioChange" v-model="filterRadio" :label=2>公共题库</el-radio> <el-radio @change="refetchList" v-model="params.permission" :label=2>公共题库</el-radio>
</template> </template>
<template v-slot:input-filter> <template v-slot:filter-category="{ params }">
<question-type-cascader v-model="filterInput"></question-type-cascader> <question-type-cascader v-model="params.question_category" @change="refetchList"></question-type-cascader>
</template> </template>
<div class="operate-btn"> <div class="operate-btn">
<el-button type="primary" icon="el-icon-plus" @click="$router.push({ path: '/question/create' })" <el-button type="primary" icon="el-icon-plus" @click="$router.push({ path: '/question/create' })"
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
<script> <script>
import { getAppList, deleteQuestion } from '../api' import { getAppList, deleteQuestion } from '../api'
import importQuestion from '../components/importQuestion.vue' import importQuestion from '../components/importQuestion.vue'
import QuestionTypeCascader from '@/components/base/QuestionTypeCascader.vue' import QuestionTypeCascader from '@/components/base/QuestionTypeTreeselect.vue'
export default { export default {
components: { importQuestion, QuestionTypeCascader }, components: { importQuestion, QuestionTypeCascader },
data() { data() {
...@@ -42,6 +42,9 @@ export default { ...@@ -42,6 +42,9 @@ export default {
} }
}, },
computed: { computed: {
activeProject() {
return this.$store.state.activeProject || {}
},
tableOptions() { tableOptions() {
return { return {
limit: 10, limit: 10,
...@@ -86,7 +89,7 @@ export default { ...@@ -86,7 +89,7 @@ export default {
] ]
}, },
{ {
slots: 'input-filter', slots: 'filter-category',
prop: 'question_category', prop: 'question_category',
type: 'input', type: 'input',
label: '试题分类:' label: '试题分类:'
...@@ -100,9 +103,9 @@ export default { ...@@ -100,9 +103,9 @@ export default {
remote: { remote: {
httpRequest: getAppList, httpRequest: getAppList,
params: { params: {
permission: this.filterRadio, permission: 1,
project_prefix: 'x1', project_prefix: this.activeProject.tag,
question_category: this.filterInput question_category: ''
}, },
callback(data) { callback(data) {
const questionType = { const questionType = {
...@@ -176,6 +179,11 @@ export default { ...@@ -176,6 +179,11 @@ export default {
}, },
radioChange() { radioChange() {
this.$refs.list.refetch() this.$refs.list.refetch()
},
// 刷新列表
refetchList() {
// 刷新列表
this.$refs.list.refetch()
} }
} }
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论