|
|
@@ -1,21 +1,127 @@
|
|
|
<template>
|
|
|
- <div></div>
|
|
|
+ <v-container>
|
|
|
+ <v-card>
|
|
|
+ <!-- <v-card-title>已选题目</v-card-title>-->
|
|
|
+ <!-- <v-list class="px-10 flex">-->
|
|
|
+ <!-- <v-list-item-group multiple>-->
|
|
|
+ <!-- <v-divider></v-divider>-->
|
|
|
+ <!-- <template v-for="question in selectedQuestions">-->
|
|
|
+ <!-- <v-list-item :key="question.id" :value="question.id">-->
|
|
|
+ <!-- <template v-slot:default="{ active }">-->
|
|
|
+ <!-- <v-list-item-action>-->
|
|
|
+ <!-- <v-checkbox hide-details :input-value="active"> </v-checkbox>-->
|
|
|
+ <!-- </v-list-item-action>-->
|
|
|
+ <!-- <v-list-item-content>-->
|
|
|
+ <!-- <v-list-item-title class="text-wrap">-->
|
|
|
+ <!-- {{ question.stem }}</v-list-item-title-->
|
|
|
+ <!-- >-->
|
|
|
+ <!-- </v-list-item-content>-->
|
|
|
+ <!-- </template>-->
|
|
|
+ <!-- </v-list-item>-->
|
|
|
+ <!-- <v-divider :key="' ' + question.id"></v-divider>-->
|
|
|
+ <!-- </template>-->
|
|
|
+ <!-- </v-list-item-group>-->
|
|
|
+ <!-- </v-list>-->
|
|
|
+ <!-- <v-card-title>题目列表</v-card-title>-->
|
|
|
+ <!-- <v-list class="px-10 flex">-->
|
|
|
+ <!-- <v-list-item-group v-model="selectedId" multiple>-->
|
|
|
+ <!-- <v-divider></v-divider>-->
|
|
|
+ <!-- <template v-for="question in questions">-->
|
|
|
+ <!-- <v-list-item :key="question.id" :value="question.id">-->
|
|
|
+ <!-- <template v-slot:default="{ active }">-->
|
|
|
+ <!-- <v-list-item-action>-->
|
|
|
+ <!-- <v-checkbox hide-details :input-value="active"> </v-checkbox>-->
|
|
|
+ <!-- </v-list-item-action>-->
|
|
|
+ <!-- <v-list-item-content>-->
|
|
|
+ <!-- <v-list-item-title class="text-wrap">-->
|
|
|
+ <!-- {{ question.stem }}</v-list-item-title-->
|
|
|
+ <!-- >-->
|
|
|
+ <!-- </v-list-item-content>-->
|
|
|
+ <!-- </template>-->
|
|
|
+ <!-- </v-list-item>-->
|
|
|
+ <!-- <v-divider :key="' ' + question.id"></v-divider>-->
|
|
|
+ <!-- </template>-->
|
|
|
+ <!-- </v-list-item-group>-->
|
|
|
+ <!-- <v-card-actions>-->
|
|
|
+ <!-- <v-btn color="primary" @click="fetchData">下一页</v-btn>-->
|
|
|
+ <!-- </v-card-actions>-->
|
|
|
+ <!-- </v-list>-->
|
|
|
+ <v-data-table
|
|
|
+ v-model="selectedId"
|
|
|
+ item-key="id"
|
|
|
+ show-select
|
|
|
+ :headers="headers"
|
|
|
+ :items="questions"
|
|
|
+ show-expand
|
|
|
+ style="width: 50vw"
|
|
|
+ class="text-wrap"
|
|
|
+ >
|
|
|
+ <template v-slot:expanded-item="{ headers, item }">
|
|
|
+ <td :colspan="headers.length">
|
|
|
+ {{ item.stem }}
|
|
|
+ </td>
|
|
|
+ </template>
|
|
|
+ </v-data-table>
|
|
|
+ </v-card>
|
|
|
+ </v-container>
|
|
|
</template>
|
|
|
|
|
|
<script lang="ts">
|
|
|
import Vue, { PropType } from 'vue'
|
|
|
-import { ChoiceQuestionSerializer, Pageable } from '@/api/types'
|
|
|
+import { ChoiceQuestionSerializer, ID, Pageable } from '@/api/types'
|
|
|
+import { getQuestions } from '@/api/question'
|
|
|
|
|
|
export default Vue.extend({
|
|
|
name: 'QuestionList',
|
|
|
- props: {
|
|
|
- questions: {
|
|
|
- required: true,
|
|
|
- type: Object as PropType<Pageable<ChoiceQuestionSerializer>>
|
|
|
+ props: {},
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ questions: [] as Array<ChoiceQuestionSerializer>,
|
|
|
+ selectedId: [] as Array<ID>,
|
|
|
+ selectedQuestions: [] as Array<ChoiceQuestionSerializer>,
|
|
|
+ headers: [
|
|
|
+ { text: '技能点', value: 'skillId' },
|
|
|
+ { text: '知识点', value: 'knowledgeId' },
|
|
|
+ // { text: '题干', value: 'stem', sortable: false },
|
|
|
+ { text: '题干', value: 'data-table-expand' }
|
|
|
+ ]
|
|
|
}
|
|
|
},
|
|
|
- data() {
|
|
|
- return {}
|
|
|
+ watch: {
|
|
|
+ selectedId: {
|
|
|
+ deep: true,
|
|
|
+ handler: function(newVal: Array<ID>, oldVal: Array<ID>): void {
|
|
|
+ if (newVal.length > oldVal.length) {
|
|
|
+ const changedId = newVal[newVal.length - 1]
|
|
|
+ const changeQuestion = this.questions.find((val) => {
|
|
|
+ return val.id === changedId
|
|
|
+ })
|
|
|
+ if (changeQuestion !== undefined) {
|
|
|
+ this.selectedQuestions.push(changeQuestion)
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ const changeId = oldVal.filter((val) => {
|
|
|
+ return !newVal.find((value) => {
|
|
|
+ return value === val
|
|
|
+ })
|
|
|
+ })[0]
|
|
|
+ this.selectedQuestions = this.selectedQuestions.filter((val) => {
|
|
|
+ return val.id !== changeId
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ created() {
|
|
|
+ this.fetchData()
|
|
|
+ },
|
|
|
+ mounted() {},
|
|
|
+ methods: {
|
|
|
+ fetchData() {
|
|
|
+ getQuestions({}).then(({ data }) => {
|
|
|
+ this.questions = data.res ?? []
|
|
|
+ })
|
|
|
+ }
|
|
|
}
|
|
|
})
|
|
|
</script>
|