提交 84fc7563 authored 作者: lihuihui's avatar lihuihui

update

上级 61020542
...@@ -15,8 +15,7 @@ ...@@ -15,8 +15,7 @@
<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:input-filter>
<div class="filter-input"> <div class="filter-input">
<el-input v-model="filterInput" placeholder="请选择"></el-input> <question-type-cascader v-model="filterInput"></question-type-cascader>
<div class="pop" @click="dialogVisible = true"></div>
</div> </div>
</template> </template>
</app-list> </app-list>
...@@ -36,38 +35,23 @@ ...@@ -36,38 +35,23 @@
<el-button type="primary" @click="addQuestionConfirm">&nbsp;&nbsp;&nbsp;&nbsp;确定&nbsp;&nbsp;&nbsp;&nbsp;</el-button> <el-button type="primary" @click="addQuestionConfirm">&nbsp;&nbsp;&nbsp;&nbsp;确定&nbsp;&nbsp;&nbsp;&nbsp;</el-button>
</div> </div>
</template> </template>
<el-dialog title="提示" :visible="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>
import { getAppList, getQuestionCategory } from '../api' import { getAppList } from '../api'
import QuestionTypeCascader from '@/components/base/QuestionTypeCascader.vue'
export default { export default {
components: {
QuestionTypeCascader
},
data() { data() {
return { return {
dialogVisible: false,
filterInput: '', filterInput: '',
source: '1', source: '1',
questionBank: '1', questionBank: '1',
type: 1, type: 1,
visible: false,
treeList: [],
defaultProps: '', defaultProps: '',
treeValue: {
name: '',
id: ''
},
checkedList: [] checkedList: []
} }
}, },
...@@ -125,7 +109,7 @@ export default { ...@@ -125,7 +109,7 @@ export default {
question_types: [1, 2, 3, 6], question_types: [1, 2, 3, 6],
permission: this.questionBank, permission: this.questionBank,
project_prefix: 'x1', project_prefix: 'x1',
question_category: this.treeValue.id question_category: this.filterInput
}, },
callback(data) { callback(data) {
const questionType = { const questionType = {
...@@ -156,7 +140,7 @@ export default { ...@@ -156,7 +140,7 @@ export default {
{ label: '题目类型', prop: 'questionTypeName' }, { label: '题目类型', prop: 'questionTypeName' },
{ label: '试题分类', prop: 'question_category.category_name' }, { label: '试题分类', prop: 'question_category.category_name' },
{ label: '题目标题', prop: 'question_title' }, { label: '题目标题', prop: 'question_title' },
{ label: '知识点', prop: 'knowledge_point.title' }, // { label: '知识点', prop: 'knowledge_point.title' },
{ label: '等级难度', prop: 'question_difficulty' }, { label: '等级难度', prop: 'question_difficulty' },
{ label: '更新人', prop: 'operator.nickname' }, { label: '更新人', prop: 'operator.nickname' },
{ label: '更新时间', prop: 'updated_at' }, { label: '更新时间', prop: 'updated_at' },
...@@ -169,6 +153,7 @@ export default { ...@@ -169,6 +153,7 @@ export default {
this.getTreeList() this.getTreeList()
}, },
methods: { methods: {
// 列表checked点击 重整数据:组合成与题对应的数据
handleSelectionChange(data) { handleSelectionChange(data) {
this.checkedList = data.reduce((a, b) => { this.checkedList = data.reduce((a, b) => {
const data = {} const data = {}
...@@ -181,9 +166,11 @@ export default { ...@@ -181,9 +166,11 @@ export default {
return a return a
}, []) }, [])
}, },
// 筛选更新列表
radioChange() { radioChange() {
this.$refs.list.refetch() this.$refs.list.refetch()
}, },
// 添加题型
addQuestionConfirm() { addQuestionConfirm() {
const data = { const data = {
question_title: '', question_title: '',
...@@ -208,50 +195,6 @@ export default { ...@@ -208,50 +195,6 @@ export default {
data.question_options = options data.question_options = options
} }
this.$emit('questionList', data) this.$emit('questionList', data)
},
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()
},
// 获取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
})
}
} }
} }
} }
......
<template>
<div>
<!-- <el-divider content-position="center" class="divider">子题目1</el-divider> -->
<el-form :model="ruleForm" :ruleForm="ruleForm" ref="ruleForm" label-width="100px" class="demo-ruleForm">
<el-form-item label="子题目类型" prop="desc">
<el-select v-model="ruleForm.desc" placeholder="请选择活动区域">
<el-option label="单选题" value="questionType1"></el-option>
<el-option label="多选题" value="questionType2"></el-option>
<el-option label="判断题" value="questionType3"></el-option>
<el-option label="问答题" value="questionType4"></el-option>
</el-select>
</el-form-item>
<el-form-item label="难度等级" prop="desc">
<el-select v-model="ruleForm.desc" placeholder="请选择活动区域">
<el-option label="单选题" value="questionType1"></el-option>
<el-option label="多选题" value="questionType2"></el-option>
<el-option label="判断题" value="questionType3"></el-option>
<el-option label="问答题" value="questionType4"></el-option>
</el-select>
</el-form-item>
<el-form-item label="子题目标题" prop="data2">
<el-input v-model="ruleForm.data2"></el-input>
</el-form-item>
<el-form-item label="子题目内容" prop="data2">
<v-editor></v-editor>
</el-form-item>
<el-form-item label="选项">
<radio></radio>
<!-- <el-button type="primary" @click="submitForm('ruleForm')">立即创建</el-button> -->
<!-- <el-button @click="resetForm('ruleForm')">重置</el-button> -->
</el-form-item>
<el-form-item label="知识点/标签">
<el-input v-model="ruleForm.data2"></el-input>
</el-form-item>
<el-form-item label="子题目解析" prop="data2">
<v-editor></v-editor>
</el-form-item>
<el-form-item label="试题分类" prop="desc">
<el-select v-model="ruleForm.desc" placeholder="请选择活动区域">
<el-option label="单选题" value="questionType1"></el-option>
<el-option label="多选题" value="questionType2"></el-option>
<el-option label="判断题" value="questionType3"></el-option>
<el-option label="问答题" value="questionType4"></el-option>
</el-select>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="submitForm('ruleForm')">保存子题目</el-button>
<el-button type="primary" @click="resetForm('ruleForm')">删除子题目</el-button>
<!-- <el-input v-model="ruleForm.data2"></el-input> -->
</el-form-item>
</el-form>
</div>
</template>
<script>
import Radio from './QTypeRadio.vue'
import VEditor from '@/components/tinymce/Index.vue'
export default {
components: { VEditor, Radio },
data() {
return {
ruleForm: {}
}
}
}
</script>
<style lang="scss" scoped>
</style>
<template>
<div>
<el-form :model="ruleForm" :ruleForm="ruleForm" ref="ruleForm" label-width="100px" class="demo-ruleForm">
<el-form-item label="题目类型" prop="desc">
<el-select v-model="ruleForm.desc" placeholder="请选择活动区域">
<el-option label="单选题" value="questionType1"></el-option>
<el-option label="多选题" value="questionType2"></el-option>
<el-option label="判断题" value="questionType3"></el-option>
<el-option label="问答题" value="questionType4"></el-option>
</el-select>
</el-form-item>
<el-form-item label="题目标题" prop="data2">
<el-input v-model="ruleForm.data2"></el-input>
</el-form-item>
<el-form-item label="公共题干" prop="data2">
<v-editor></v-editor>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="submitForm('ruleForm')">添加子题目</el-button>
<el-button type="primary" @click="resetForm('ruleForm')">删除子题目</el-button>
</el-form-item>
</el-form>
<case-chidren></case-chidren>
</div>
</template>
<script>
import CaseChidren from './CaseChidren.vue'
import VEditor from '@/components/tinymce/Index.vue'
export default {
components: { VEditor, CaseChidren },
data() {
return {
ruleForm: {}
}
}
}
</script>
<style lang="scss" scoped>
</style>
...@@ -27,8 +27,6 @@ ...@@ -27,8 +27,6 @@
<el-form-item label="公共题干" prop="common_content"> <el-form-item label="公共题干" prop="common_content">
<v-editor :disabled="!!($route.query.type === 'view')" v-model="ruleForm.common_content"></v-editor> <v-editor :disabled="!!($route.query.type === 'view')" v-model="ruleForm.common_content"></v-editor>
</el-form-item> </el-form-item>
<!-- </el-form-item> -->
<!-- <el-form-item> -->
<el-form-item label="标签" prop="question_tag"> <el-form-item label="标签" prop="question_tag">
<el-input v-model="ruleForm.question_tag"></el-input> <el-input v-model="ruleForm.question_tag"></el-input>
</el-form-item> </el-form-item>
...@@ -158,10 +156,12 @@ export default { ...@@ -158,10 +156,12 @@ export default {
this.getTreeList() this.getTreeList()
}, },
methods: { methods: {
// 添加子题 drawer关闭
handleCloseDrawer() { handleCloseDrawer() {
this.drawer = false this.drawer = false
}, },
submitForm(formName) { // 提交
submitForm() {
this.ruleForm.children = this.chidrenList this.ruleForm.children = this.chidrenList
if (this.$route.query.id) { if (this.$route.query.id) {
updateQuestion(this.$route.query.id, this.ruleForm).then(res => { updateQuestion(this.$route.query.id, this.ruleForm).then(res => {
...@@ -178,6 +178,7 @@ export default { ...@@ -178,6 +178,7 @@ export default {
window.localStorage.removeItem('cacheQuestion') window.localStorage.removeItem('cacheQuestion')
} }
}, },
// 暂存本地
cacheQuestion() { cacheQuestion() {
const cacheData = { const cacheData = {
form: this.ruleForm, form: this.ruleForm,
...@@ -191,6 +192,7 @@ export default { ...@@ -191,6 +192,7 @@ export default {
type: 'success' type: 'success'
}) })
}, },
// 切换题型
questionTypeChange() { questionTypeChange() {
this.$emit('questionType', this.ruleForm.question_type) this.$emit('questionType', this.ruleForm.question_type)
}, },
......
...@@ -134,7 +134,7 @@ export default { ...@@ -134,7 +134,7 @@ export default {
{ label: '题目类型', prop: 'question_type' }, { label: '题目类型', prop: 'question_type' },
{ label: '试题分类', prop: 'question_category.category_name' }, { label: '试题分类', prop: 'question_category.category_name' },
{ label: '题目标题', prop: 'question_title' }, { label: '题目标题', prop: 'question_title' },
{ label: '知识点', prop: 'knowledge_point.title' }, // { label: '知识点', prop: 'knowledge_point.title' },
{ label: '等级难度', prop: 'question_difficulty' }, { label: '等级难度', prop: 'question_difficulty' },
{ label: '更新人', prop: 'operator.nickname' }, { label: '更新人', prop: 'operator.nickname' },
{ label: '更新时间', prop: 'updated_at' }, { label: '更新时间', prop: 'updated_at' },
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论