|
@@ -22,31 +22,37 @@
|
22
|
22
|
<el-button type="primary" @click="onAddAnswer">添加答案</el-button>
|
23
|
23
|
|
24
|
24
|
<div v-for="(answer, index) in form.answerList" :key="index">
|
25
|
|
- <!-- <AddAnswerMatching
|
26
|
|
- :characterId="characterId"
|
27
|
|
- :value="answer"
|
28
|
|
- :wordList="wordList"
|
29
|
|
- @change="handleChange"
|
30
|
|
- @handleDelete="() => handleDelete(answer)"
|
31
|
|
- @handleWordListChange="handleWordListChange"
|
32
|
|
- /> -->
|
|
25
|
+ <el-row :gutter="20" style="padding-top: 20px">
|
|
26
|
+ <el-col :span="1">
|
|
27
|
+ {{ answer.option }}
|
|
28
|
+ </el-col>
|
|
29
|
+ <el-col :span="10">{{ answer.content }}</el-col>
|
|
30
|
+ </el-row>
|
|
31
|
+ <el-row :gutter="20">
|
|
32
|
+ <el-col :span="20">
|
|
33
|
+ {{ handleToString(answer.characterList) }}
|
|
34
|
+ </el-col>
|
|
35
|
+ <el-col :span="1">
|
|
36
|
+ <el-button type="danger" @click="()=>handleDelete(index)">X</el-button>
|
|
37
|
+ </el-col>
|
|
38
|
+ </el-row>
|
33
|
39
|
</div>
|
34
|
40
|
</el-form-item>
|
35
|
41
|
<el-form-item label="正确选项:">
|
36
|
42
|
<!-- <el-input v-model="form.option"></el-input> -->
|
37
|
43
|
<!-- filterable可搜索 multiple可多选 default-first-option回车可选-->
|
38
|
44
|
<el-select
|
39
|
|
- v-model="rightList"
|
|
45
|
+ v-model="form.rightAnswer"
|
40
|
46
|
multiple
|
41
|
47
|
filterable
|
42
|
48
|
default-first-option
|
43
|
49
|
placeholder="请选择"
|
44
|
50
|
>
|
45
|
51
|
<el-option
|
46
|
|
- v-for="item in form.answerList"
|
47
|
|
- :key="item.option"
|
48
|
|
- :label="item.option"
|
49
|
|
- :value="item.option"
|
|
52
|
+ v-for="item in rightList"
|
|
53
|
+ :key="item"
|
|
54
|
+ :label="item"
|
|
55
|
+ :value="item"
|
50
|
56
|
/>
|
51
|
57
|
</el-select>
|
52
|
58
|
</el-form-item>
|
|
@@ -55,26 +61,20 @@
|
55
|
61
|
<el-button @click="$router.go(-1)">返回</el-button>
|
56
|
62
|
</el-form-item>
|
57
|
63
|
</el-form>
|
58
|
|
- <QuestionDrawer :dialog="dialog" :wordList='wordList' @handleCloseDrawer='handleCloseDrawer' @handleEditDrawer='handleEditDrawer' />
|
|
64
|
+ <QuestionDrawer :dialog="dialog" @handleCloseDrawer="handleCloseDrawer" @handleEditDrawer="handleEditDrawer" />
|
59
|
65
|
</div>
|
60
|
66
|
</template>
|
61
|
67
|
<script>
|
62
|
68
|
|
63
|
69
|
import { saveQuestion, updateQuestion, getQuestionDetail } from '@/api/question'
|
64
|
|
-import { getGameCharacterList } from '@/api/gameCharacter'
|
65
|
70
|
import QuestionDrawer from '@/components/Question/drawer.vue'
|
66
|
71
|
|
67
|
|
-// import AddAnswerMatching from '@/components/AddAnswerMatching/index.vue'
|
68
|
|
-// import { getCharacterLibDetail } from '@/api/characterLib'
|
69
|
|
-
|
70
|
72
|
export default {
|
71
|
73
|
components: {
|
72
|
74
|
QuestionDrawer
|
73
|
|
- // AddAnswerMatching
|
74
|
75
|
},
|
75
|
76
|
props: {
|
76
|
77
|
gameId: String,
|
77
|
|
- // characterId: String,
|
78
|
78
|
questionId: String
|
79
|
79
|
},
|
80
|
80
|
data() {
|
|
@@ -88,11 +88,10 @@ export default {
|
88
|
88
|
// 答案列表(包括选项 内容 特征词列表)
|
89
|
89
|
answerList: []
|
90
|
90
|
},
|
91
|
|
- // 正确答案数组
|
|
91
|
+ // 正确答案数据源
|
92
|
92
|
rightList: [],
|
93
|
|
- // 特征数据源
|
94
|
|
- wordList: [],
|
95
|
|
- dialog: false
|
|
93
|
+ dialog: false,
|
|
94
|
+ isChange: 0
|
96
|
95
|
}
|
97
|
96
|
},
|
98
|
97
|
watch: {
|
|
@@ -102,10 +101,7 @@ export default {
|
102
|
101
|
this.rightList = []
|
103
|
102
|
getQuestionDetail(this.questionId).then((res) => {
|
104
|
103
|
this.form = res.data
|
105
|
|
- const list = res.data.answerList
|
106
|
|
- list.map((item) => {
|
107
|
|
- this.rightList.push(item.wordId)
|
108
|
|
- })
|
|
104
|
+ this.form.rightAnswer = res.data.rightAnswer.split(',')
|
109
|
105
|
})
|
110
|
106
|
} else {
|
111
|
107
|
this.form = {
|
|
@@ -118,40 +114,49 @@ export default {
|
118
|
114
|
}
|
119
|
115
|
this.rightList = []
|
120
|
116
|
}
|
|
117
|
+ if (this.gameId) {
|
|
118
|
+ this.form.gameId = this.gameId
|
|
119
|
+ }
|
121
|
120
|
},
|
122
|
121
|
gameId() {
|
123
|
|
- this.form.gameId = this.gameId
|
124
|
|
- getGameCharacterList({ gameId: this.gameId }).then((res) => {
|
125
|
|
- res.data.records.map(item => {
|
126
|
|
- this.wordList.push({ characterId: item.characterId, name: item.name })
|
127
|
|
- })
|
128
|
|
- console.log(this.wordList)
|
|
122
|
+ if (this.gameId) {
|
|
123
|
+ this.form.gameId = this.gameId
|
|
124
|
+ }
|
|
125
|
+ },
|
|
126
|
+ isChange() {
|
|
127
|
+ const list = []
|
|
128
|
+ this.form.answerList.map(item => {
|
|
129
|
+ list.push(item.option)
|
129
|
130
|
})
|
|
131
|
+ this.rightList = list
|
130
|
132
|
}
|
131
|
133
|
},
|
132
|
134
|
methods: {
|
133
|
135
|
onAddAnswer() {
|
134
|
136
|
this.dialog = true
|
135
|
|
- // this.form.answerList.push({
|
136
|
|
- // answerId: undefined,
|
137
|
|
- // questionId: undefined,
|
138
|
|
- // contentType: undefined,
|
139
|
|
- // option: undefined,
|
140
|
|
- // content: undefined,
|
141
|
|
- // characterWordList: [],
|
142
|
|
- // word: undefined,
|
143
|
|
- // wordId: undefined
|
144
|
|
- // })
|
145
|
137
|
},
|
146
|
138
|
handleCloseDrawer() {
|
147
|
139
|
this.dialog = false
|
148
|
140
|
},
|
149
|
141
|
handleEditDrawer(val) {
|
150
|
|
- console.log(val)
|
|
142
|
+ this.isChange++
|
|
143
|
+ this.form.answerList.push(val)
|
151
|
144
|
this.handleCloseDrawer()
|
152
|
145
|
},
|
|
146
|
+ handleDelete(index) {
|
|
147
|
+ this.isChange--
|
|
148
|
+ this.form.answerList.splice(index, 1)
|
|
149
|
+ },
|
|
150
|
+ handleToString(list) {
|
|
151
|
+ const nameList = []
|
|
152
|
+ list?.map(item => {
|
|
153
|
+ nameList.push(item.name)
|
|
154
|
+ })
|
|
155
|
+ return nameList.toString()
|
|
156
|
+ },
|
153
|
157
|
onSubmit() {
|
154
|
|
- if (this.form.name) {
|
|
158
|
+ if (this.form.title) {
|
|
159
|
+ this.form.rightAnswer = this.form.rightAnswer.toString()
|
155
|
160
|
if (this.questionId) {
|
156
|
161
|
updateQuestion(this.form, this.questionId).then((res) => {
|
157
|
162
|
this.$message('修改问题成功')
|
|
@@ -170,27 +175,6 @@ export default {
|
170
|
175
|
this.$message('请输入问题名称')
|
171
|
176
|
}
|
172
|
177
|
}
|
173
|
|
- // handleChange(answer) {
|
174
|
|
- // const index = this.form.answerList.indexOf(answer)
|
175
|
|
- // this.$set(this.form.answerList, index, answer)
|
176
|
|
- // },
|
177
|
|
-
|
178
|
|
- // handleWordListChange(val, list) {
|
179
|
|
- // getCharacterLibDetail(this.characterId).then((res) => {
|
180
|
|
- // this.wordList = res.data.wordList
|
181
|
|
- // })
|
182
|
|
- // const index = this.form.answerList.indexOf(val)
|
183
|
|
- // val.characterWordList = this.wordList.filter((item) =>
|
184
|
|
- // list.some((v) => v === item.wordId)
|
185
|
|
- // )
|
186
|
|
- // val.characterWordList.map(item => {
|
187
|
|
- // item = { ...item, characterId: this.characterId }
|
188
|
|
- // })
|
189
|
|
- // this.$set(this.form.answerList, index, val)
|
190
|
|
- // },
|
191
|
|
- // handleDelete(answer) {
|
192
|
|
- // this.form.answerList.splice(this.form.answerList.indexOf(answer), 1)
|
193
|
|
- // }
|
194
|
178
|
}
|
195
|
179
|
}
|
196
|
180
|
</script>
|