|
|
@@ -1,9 +1,18 @@
|
|
|
<template>
|
|
|
<div class="question-table">
|
|
|
+ <div class="vertical-center mb-16" v-if="knowledgeTree">
|
|
|
+ <treeselect
|
|
|
+ v-model="selectedKnowledgeIdList"
|
|
|
+ :multiple="true"
|
|
|
+ :options="knowledgeTree ? knowledgeTree : null"
|
|
|
+ placeholder="选择相关知识点"
|
|
|
+ />
|
|
|
+ </div>
|
|
|
+ <div v-else class="mt-24">知识点加载中...</div>
|
|
|
<search-bar class="mb-16" v-model="inputStem" placeholder="题干搜索" @input="debounceFetchQuestions"/>
|
|
|
<pagination class="mt-16 mb-32" :page="page.number" :size="page.size" :total-elements="page.totalElements"
|
|
|
v-show="questionList && questionList.length > 0" @change="fetchQuestionList"></pagination>
|
|
|
- <div class="no-content-warning" v-if="questionList === null || questionList.length === 0">请输入关键字搜索</div>
|
|
|
+ <div class="no-content-warning" v-if="questionList === null || questionList.length === 0">请输`入关键字搜索</div>
|
|
|
<div class="question-card-container" v-else>
|
|
|
<template v-for="item in questionList">
|
|
|
<question-card
|
|
|
@@ -23,16 +32,20 @@
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
+import Treeselect from '@riophae/vue-treeselect'
|
|
|
+import '@riophae/vue-treeselect/dist/vue-treeselect.css'
|
|
|
import debounce from '@/utils/debounce'
|
|
|
import { getCreatedQuestionIds, getCreatedQuestions, getQuestionList } from '@/server/question'
|
|
|
import Pagination from '@/components/Pagination'
|
|
|
import { markdownToHTML } from '@/utils/markdown'
|
|
|
import QuestionCard from '@/views/quiz/components/QuestionCard'
|
|
|
import SearchBar from '@/components/Basic/SearchBar'
|
|
|
+import { getKnowledgeNodes } from '@/server/knowledge'
|
|
|
+import { constructTree } from '@/utils/construct-tree'
|
|
|
|
|
|
export default {
|
|
|
name: 'QuestionTable',
|
|
|
- components: { SearchBar, QuestionCard, Pagination },
|
|
|
+ components: { Treeselect, SearchBar, QuestionCard, Pagination },
|
|
|
props: {
|
|
|
selectable: {
|
|
|
type: Boolean,
|
|
|
@@ -45,6 +58,10 @@ export default {
|
|
|
showOwn: {
|
|
|
type: Boolean,
|
|
|
default: false
|
|
|
+ },
|
|
|
+ showOld: {
|
|
|
+ type: Boolean,
|
|
|
+ default: false
|
|
|
}
|
|
|
},
|
|
|
model: {
|
|
|
@@ -57,10 +74,18 @@ export default {
|
|
|
watch: {
|
|
|
showOwn () {
|
|
|
this.fetchQuestionList()
|
|
|
+ },
|
|
|
+ showOld () {
|
|
|
+ this.fetchQuestionList()
|
|
|
+ },
|
|
|
+ selectedKnowledgeIdList () {
|
|
|
+ this.fetchQuestionList()
|
|
|
}
|
|
|
},
|
|
|
data () {
|
|
|
return {
|
|
|
+ knowledgeTree: null,
|
|
|
+ selectedKnowledgeIdList: [],
|
|
|
inputStem: '',
|
|
|
questionList: [],
|
|
|
ownQuestionList: [],
|
|
|
@@ -73,6 +98,13 @@ export default {
|
|
|
debounceFetchQuestions: debounce(() => this.fetchQuestionList())
|
|
|
}
|
|
|
},
|
|
|
+ created () {
|
|
|
+ getKnowledgeNodes()
|
|
|
+ .then(res => {
|
|
|
+ this.knowledgeTree = constructTree(res)
|
|
|
+ })
|
|
|
+ .catch(err => this.$setErrorMessage(err.response.data.msg))
|
|
|
+ },
|
|
|
mounted () {
|
|
|
this.fetchQuestionList()
|
|
|
this.fetchOwnQuestionIds()
|
|
|
@@ -81,15 +113,18 @@ export default {
|
|
|
fetchQuestionList ({
|
|
|
stem = this.inputStem,
|
|
|
page = 1,
|
|
|
- size = 10
|
|
|
+ size = 10,
|
|
|
+ sortCondition1 = this.showOld ? 'id,asc' : 'id,desc',
|
|
|
+ sortCondition2 = this.showOld ? 'lastModifiedTime,asc' : 'lastModifiedTime,desc',
|
|
|
+ knowledgeId = this.selectedKnowledgeIdList
|
|
|
} = {}) {
|
|
|
this.showOwn
|
|
|
- ? getCreatedQuestions({ key: stem, size, page })
|
|
|
+ ? getCreatedQuestions({ key: stem, size, page, sort: sortCondition1, knowledgeId })
|
|
|
.then(({ data: questions, page }) => {
|
|
|
this.questionList = questions
|
|
|
this.page = page
|
|
|
})
|
|
|
- : getQuestionList({ key: stem, size, page })
|
|
|
+ : getQuestionList({ key: stem, size, page, sort: sortCondition2, knowledgeId })
|
|
|
.then(({ data: questions, page }) => {
|
|
|
this.questionList = questions
|
|
|
this.page = page
|