提交 6255941b authored 作者: lihuihui's avatar lihuihui

修改bug

上级 377a5bf5
......@@ -2,14 +2,11 @@
<app-card>
<app-list v-bind="tableOptions" ref="list" @selection-change="handleSelectionChange">
<template v-slot:radio-filter>
<el-radio @change="radioChange" v-model="radio" label="1">我的题库</el-radio>
<el-radio @change="radioChange" v-model="radio" label="2">公共题库</el-radio>
<el-radio @change="radioChange" v-model="filterRadio" :label=1>我的题库</el-radio>
<el-radio @change="radioChange" v-model="filterRadio" :label=2>公共题库</el-radio>
</template>
<template v-slot:input-filter>
<div class="filter-input">
<el-input v-model="filterInput" placeholder="请选择"></el-input>
<div class="pop" @click="dialogVisible = true"></div>
</div>
<question-type-cascader v-model="filterInput"></question-type-cascader>
</template>
<div class="operate-btn">
<el-button type="primary" icon="el-icon-plus" @click="$router.push({ path: '/question/create' })"
......@@ -23,42 +20,25 @@
<el-button type="text" @click="handleView(row)">查看详情</el-button>
<el-button type="text" @click="handleDelete(row.id)">删除</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>
<import-question :visible.sync="importDialogVisible" />
</app-card>
</template>
<script>
import { getAppList, getQuestionCategory, deleteQuestion } from '../api'
import { getAppList, deleteQuestion } from '../api'
import importQuestion from '../components/importQuestion.vue'
import QuestionTypeCascader from '@/components/base/QuestionTypeCascader.vue'
export default {
components: { importQuestion },
components: { importQuestion, QuestionTypeCascader },
data() {
return {
importDialogVisible: false,
deleteQuestions: [],
dialogVisible: false,
visible: false,
radio: '1',
filterInput: '',
treeList: [],
defaultProps: '',
treeValue: {
name: '',
id: ''
}
importDialogVisible: false, // 模板导入弹窗
deleteQuestions: [], // 批量删除
treeDialogVisible: false, // tree弹窗
filterRadio: 1, // 题库筛选
filterInput: '', // tree回显内容
defaultProps: ''
}
},
computed: {
......@@ -120,9 +100,9 @@ export default {
remote: {
httpRequest: getAppList,
params: {
permission: this.radio,
permission: this.filterRadio,
project_prefix: 'x1',
question_category: this.treeValue.id
question_category: this.filterInput
},
callback(data) {
const questionType = {
......@@ -164,7 +144,6 @@ export default {
}
},
mounted() {
this.getTreeList()
},
methods: {
// 列表选择
......@@ -183,36 +162,6 @@ export default {
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
})
}
},
// 创建成功刷新列表
handleCreateSuccess() {
this.$refs.list.refetch()
......@@ -221,23 +170,10 @@ export default {
handleView(row) {
this.$router.push({ path: '/question/create', query: { id: row.id, type: 'view' } })
},
// 编辑
handleSettings(row) {
this.$router.push({ path: '/question/create', query: { id: row.id, type: 'edit' } })
},
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()
},
radioChange() {
this.$refs.list.refetch()
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论