|
@@ -1,5 +1,5 @@
|
|
|
<template>
|
|
<template>
|
|
|
- <el-space :fill="true" direction="vertical" style="width:100%;" alignment="flex-start" :size="30">
|
|
|
|
|
|
|
+ <el-space :fill="true" direction="vertical" alignment="flex-start" :size="30">
|
|
|
<h1>Question Search</h1>
|
|
<h1>Question Search</h1>
|
|
|
<el-input placeholder="请输入内容" v-model="searchContent" @keydown.enter="clickSearch">
|
|
<el-input placeholder="请输入内容" v-model="searchContent" @keydown.enter="clickSearch">
|
|
|
<template #append>
|
|
<template #append>
|
|
@@ -11,14 +11,12 @@
|
|
|
<el-space direction="vertical" alignment="flex-start">
|
|
<el-space direction="vertical" alignment="flex-start">
|
|
|
<button-filter :title="typeFilter.title" :checkboxOption="typeFilter.option" ref="typeFilter"
|
|
<button-filter :title="typeFilter.title" :checkboxOption="typeFilter.option" ref="typeFilter"
|
|
|
@filterChange="handleTypeFilter"/>
|
|
@filterChange="handleTypeFilter"/>
|
|
|
- <!-- <button-filter :title="levelFilter.title" :checkboxOption="levelFilter.option" ref="levelFilter"-->
|
|
|
|
|
- <!-- @filterChange="handleLevelFilter"/>-->
|
|
|
|
|
<search-filter :title="tagFilter.title" :keyword="tagFilter.keyword" ref="tagFilter"
|
|
<search-filter :title="tagFilter.title" :keyword="tagFilter.keyword" ref="tagFilter"
|
|
|
@filterChange="handleTagFilter"/>
|
|
@filterChange="handleTagFilter"/>
|
|
|
<search-filter :title="knowledgeFilter.title" :keyword="knowledgeFilter.keyword"
|
|
<search-filter :title="knowledgeFilter.title" :keyword="knowledgeFilter.keyword"
|
|
|
ref="knowledgeFilter"
|
|
ref="knowledgeFilter"
|
|
|
@filterChange="handleKnowledgeFilter"/>
|
|
@filterChange="handleKnowledgeFilter"/>
|
|
|
- <qr-sorter :option="sorter.option" @stdChange="handleSortStdChange" ref="sorter"/>
|
|
|
|
|
|
|
+ <qr-sorter :option="sorter.option" @stdChange="handleSorterChange" ref="sorter"/>
|
|
|
</el-space>
|
|
</el-space>
|
|
|
</el-collapse-item>
|
|
</el-collapse-item>
|
|
|
</el-collapse>
|
|
</el-collapse>
|
|
@@ -117,6 +115,13 @@ export default {
|
|
|
return _this.filteredQuestions.slice(start, end)
|
|
return _this.filteredQuestions.slice(start, end)
|
|
|
},
|
|
},
|
|
|
},
|
|
},
|
|
|
|
|
+ mounted() {
|
|
|
|
|
+ const _this = this
|
|
|
|
|
+ if(_this.$route.params.searchContent){
|
|
|
|
|
+ _this.searchContent = _this.$route.params.searchContent;
|
|
|
|
|
+ _this.clickSearch()
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
methods: {
|
|
methods: {
|
|
|
// 展开和收起
|
|
// 展开和收起
|
|
|
closeCollapse(val) {
|
|
closeCollapse(val) {
|
|
@@ -135,69 +140,115 @@ export default {
|
|
|
_this.$refs.sorter.reset();
|
|
_this.$refs.sorter.reset();
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
- // 处理题型的筛选
|
|
|
|
|
- handleTypeFilter(checkboxGroup) {
|
|
|
|
|
- if (this.resultQuestions.length !== 0)
|
|
|
|
|
- if (checkboxGroup.length === 0) {
|
|
|
|
|
- this.resultQuestions = this.resultQuestions.map(function (item) {
|
|
|
|
|
- item.type = true;
|
|
|
|
|
- return item
|
|
|
|
|
- })
|
|
|
|
|
- } else {
|
|
|
|
|
- this.resultQuestions = this.resultQuestions.map(function (item) {
|
|
|
|
|
- item.type = checkboxGroup.indexOf(item.entity.type) !== -1;
|
|
|
|
|
- return item
|
|
|
|
|
- })
|
|
|
|
|
- }
|
|
|
|
|
- this.getFilteredQuestions()
|
|
|
|
|
|
|
+ // 题型筛选器——筛选事件响应
|
|
|
|
|
+ async handleTypeFilter(checkboxGroup) {
|
|
|
|
|
+ const _this = this
|
|
|
|
|
+ if (this.resultQuestions.length !== 0) {
|
|
|
|
|
+ _this.resultQuestions = await _this.filterType(checkboxGroup);
|
|
|
|
|
+ _this.requestQuestion = await _this.sortQuestions(_this.resultQuestions);
|
|
|
|
|
+ this.getFilteredQuestions()
|
|
|
|
|
+ }
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
- // 处理知识点的筛选
|
|
|
|
|
- handleKnowledgeFilter(group) {
|
|
|
|
|
- // todo
|
|
|
|
|
- if (this.resultQuestions.length === 0) {
|
|
|
|
|
- return
|
|
|
|
|
|
|
+ // 筛选题型的具体方法
|
|
|
|
|
+ async filterType(checkboxGroup) {
|
|
|
|
|
+ let res;
|
|
|
|
|
+ if (checkboxGroup.length === 0) {
|
|
|
|
|
+ res = this.resultQuestions.map(function (item) {
|
|
|
|
|
+ item.type = true;
|
|
|
|
|
+ return item
|
|
|
|
|
+ })
|
|
|
|
|
+ } else {
|
|
|
|
|
+ res = this.resultQuestions.map(function (item) {
|
|
|
|
|
+ item.type = checkboxGroup.indexOf(item.entity.type) !== -1;
|
|
|
|
|
+ return item
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+ return res;
|
|
|
|
|
+ },
|
|
|
|
|
+
|
|
|
|
|
+ // 知识点筛选器——筛选事件响应
|
|
|
|
|
+ async handleKnowledgeFilter(checkboxGroup) {
|
|
|
|
|
+ const _this = this
|
|
|
|
|
+ if (this.resultQuestions.length !== 0) {
|
|
|
|
|
+ _this.resultQuestions = await _this.filterKnowledge(checkboxGroup);
|
|
|
|
|
+ _this.requestQuestion = await _this.sortQuestions(_this.resultQuestions);
|
|
|
|
|
+ this.getFilteredQuestions()
|
|
|
}
|
|
}
|
|
|
- console.log(group)
|
|
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
- // 处理难度的筛选
|
|
|
|
|
- // handleLevelFilter(checkboxGroup) {
|
|
|
|
|
- // // todo
|
|
|
|
|
- // if (this.resultQuestions.length === 0) {
|
|
|
|
|
- // return
|
|
|
|
|
- // }
|
|
|
|
|
- // console.log(checkboxGroup)
|
|
|
|
|
- // },
|
|
|
|
|
|
|
+ // 筛选知识点的具体方法
|
|
|
|
|
+ async filterKnowledge(checkboxGroup) {
|
|
|
|
|
+ let res;
|
|
|
|
|
+ if (checkboxGroup.length === 0) {
|
|
|
|
|
+ res = this.resultQuestions.map(function (item) {
|
|
|
|
|
+ item.knowledge = true;
|
|
|
|
|
+ return item
|
|
|
|
|
+ })
|
|
|
|
|
+ } else {
|
|
|
|
|
+ // todo
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return res;
|
|
|
|
|
+ },
|
|
|
|
|
|
|
|
- // 处理排序标准的筛选
|
|
|
|
|
- async handleSortStdChange(std) {
|
|
|
|
|
- // todo
|
|
|
|
|
|
|
+ // Tag筛选器——筛选事件响应
|
|
|
|
|
+ async handleTagFilter(checkboxGroup) {
|
|
|
|
|
+ const _this = this
|
|
|
if (this.resultQuestions.length !== 0) {
|
|
if (this.resultQuestions.length !== 0) {
|
|
|
- let dir = this.$refs.sorter.direction
|
|
|
|
|
|
|
+ _this.resultQuestions = await _this.filterTag(checkboxGroup);
|
|
|
|
|
+ _this.requestQuestion = await _this.sortQuestions(_this.resultQuestions);
|
|
|
|
|
+ this.getFilteredQuestions()
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
|
|
|
|
|
+ // 筛选Tag的具体方法
|
|
|
|
|
+ async filterTag(checkboxGroup) {
|
|
|
|
|
+ let res;
|
|
|
|
|
+ if (checkboxGroup.length === 0) {
|
|
|
|
|
+ res = this.resultQuestions.map(function (item) {
|
|
|
|
|
+ item.tag = true;
|
|
|
|
|
+ return item
|
|
|
|
|
+ })
|
|
|
|
|
+ } else {
|
|
|
|
|
+ // todo
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- const sortFunction = async function (item1, item2) {
|
|
|
|
|
- let id1 = await item1.id
|
|
|
|
|
- let id2 = await item2.id
|
|
|
|
|
- console.log(1)
|
|
|
|
|
- return id1 > id2 ? dir ? 1 : -1 : dir ? -1 : 1;
|
|
|
|
|
- }
|
|
|
|
|
- switch (std) {
|
|
|
|
|
- case "id":
|
|
|
|
|
- this.filteredQuestions = this.filteredQuestions.sort(sortFunction)
|
|
|
|
|
- break;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ return res;
|
|
|
|
|
+ },
|
|
|
|
|
+
|
|
|
|
|
+ // 排序事件响应
|
|
|
|
|
+ async handleSorterChange() {
|
|
|
|
|
+ const _this = this
|
|
|
|
|
+ if (this.resultQuestions.length !== 0) {
|
|
|
|
|
+ _this.resultQuestions = await _this.sortQuestions(_this.resultQuestions)
|
|
|
|
|
+ _this.getFilteredQuestions()
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
- // 处理Tag的筛选
|
|
|
|
|
- handleTagFilter(group) {
|
|
|
|
|
- // todo
|
|
|
|
|
- if (this.resultQuestions.length === 0) {
|
|
|
|
|
- return
|
|
|
|
|
|
|
+ // 排序的具体实现方法
|
|
|
|
|
+ async sortQuestions(questions) {
|
|
|
|
|
+ let res;
|
|
|
|
|
+ let std = this.$refs.sorter.standard
|
|
|
|
|
+ let dir = this.$refs.sorter.direction
|
|
|
|
|
+
|
|
|
|
|
+ const sortFunction1 = function (item1, item2) {
|
|
|
|
|
+ return item1.entity.id > item2.entity.id ? dir ? 1 : -1 : dir ? -1 : 1;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ const sortFunction2 = function (item1, item2) {
|
|
|
|
|
+ return item1.entity.type > item2.entity.type ? dir ? 1 : -1 : dir ? -1 : 1;
|
|
|
}
|
|
}
|
|
|
- console.log(group)
|
|
|
|
|
|
|
+
|
|
|
|
|
+ switch (std) {
|
|
|
|
|
+ case "id":
|
|
|
|
|
+ res = questions.sort(sortFunction1)
|
|
|
|
|
+ break;
|
|
|
|
|
+ case "type":
|
|
|
|
|
+ res = questions.sort(sortFunction2)
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+ return res;
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
// 进行关键词搜索
|
|
// 进行关键词搜索
|
|
@@ -207,7 +258,7 @@ export default {
|
|
|
alert("请输入关键词");
|
|
alert("请输入关键词");
|
|
|
} else {
|
|
} else {
|
|
|
await this.requestQuestion(this.searchContent, [], [], [], [])
|
|
await this.requestQuestion(this.searchContent, [], [], [], [])
|
|
|
- this.resultQuestions = this.resultQuestions.map(function (item) {
|
|
|
|
|
|
|
+ _this.resultQuestions = _this.resultQuestions.map(function (item) {
|
|
|
return {
|
|
return {
|
|
|
type: true,
|
|
type: true,
|
|
|
tag: true,
|
|
tag: true,
|
|
@@ -215,20 +266,34 @@ export default {
|
|
|
entity: item,
|
|
entity: item,
|
|
|
}
|
|
}
|
|
|
})
|
|
})
|
|
|
- // todo
|
|
|
|
|
let typeArray = _this.$refs.typeFilter.checkboxGroup;
|
|
let typeArray = _this.$refs.typeFilter.checkboxGroup;
|
|
|
- // let levelArray = _this.$refs.levelFilter.checkboxGroup;
|
|
|
|
|
let tagArray = _this.$refs.tagFilter.checkGroup;
|
|
let tagArray = _this.$refs.tagFilter.checkGroup;
|
|
|
let knowledgeArray = _this.$refs.knowledgeFilter.checkGroup;
|
|
let knowledgeArray = _this.$refs.knowledgeFilter.checkGroup;
|
|
|
- let sortStd = _this.$refs.sorter.standard;
|
|
|
|
|
// 初始筛选条件的处理
|
|
// 初始筛选条件的处理
|
|
|
- this.handleTypeFilter(typeArray);
|
|
|
|
|
- // todo 排序总是在落后执行
|
|
|
|
|
- // await this.handleSortStdChange(sortStd);
|
|
|
|
|
- console.log(this.filteredQuestions)
|
|
|
|
|
|
|
+ _this.resultQuestions = await _this.filterType(typeArray)
|
|
|
|
|
+ // _this.resultQuestions = await _this.filterTag(tagArray)
|
|
|
|
|
+ // _this.resultQuestions = await _this.filterKnowledge(knowledgeArray)
|
|
|
|
|
+ _this.resultQuestions = await _this.sortQuestions(_this.resultQuestions)
|
|
|
|
|
+ _this.getFilteredQuestions()
|
|
|
|
|
+ console.log(_this.filteredQuestions)
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
|
|
+ // 获取筛选后的题目
|
|
|
|
|
+ getFilteredQuestions() {
|
|
|
|
|
+ const _this = this
|
|
|
|
|
+ new Promise(function (resolve, reject) {
|
|
|
|
|
+ _this.filteredQuestions = _this.resultQuestions.filter(function (item) {
|
|
|
|
|
+ return (item.type && item.tag && item.knowledge)
|
|
|
|
|
+ }).map((item) => {
|
|
|
|
|
+ return item.entity
|
|
|
|
|
+ })
|
|
|
|
|
+ resolve()
|
|
|
|
|
+ }).then(() => {
|
|
|
|
|
+ console.log(_this.filteredQuestions)
|
|
|
|
|
+ })
|
|
|
|
|
+ },
|
|
|
|
|
+
|
|
|
// todo 注释 添加到api文件当中
|
|
// todo 注释 添加到api文件当中
|
|
|
async requestQuestion(stem, ...items) {
|
|
async requestQuestion(stem, ...items) {
|
|
|
await axios.get("/api/api/question", {
|
|
await axios.get("/api/api/question", {
|
|
@@ -266,15 +331,6 @@ export default {
|
|
|
handleCurrentChange(val) {
|
|
handleCurrentChange(val) {
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
- // 获取筛选后的题目
|
|
|
|
|
- getFilteredQuestions() {
|
|
|
|
|
- this.filteredQuestions = this.resultQuestions.filter(function (item) {
|
|
|
|
|
- return (item.type && item.tag && item.knowledge)
|
|
|
|
|
- }).map((item) => {
|
|
|
|
|
- return item.entity
|
|
|
|
|
- })
|
|
|
|
|
- },
|
|
|
|
|
-
|
|
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
</script>
|
|
</script>
|