|
@@ -22,14 +22,14 @@
|
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
|
|
25
|
+ <!-- <AddAnswerMatching
|
26
|
26
|
:characterId="characterId"
|
27
|
27
|
:value="answer"
|
28
|
28
|
:wordList="wordList"
|
29
|
29
|
@change="handleChange"
|
30
|
30
|
@handleDelete="() => handleDelete(answer)"
|
31
|
31
|
@handleWordListChange="handleWordListChange"
|
32
|
|
- />
|
|
32
|
+ /> -->
|
33
|
33
|
</div>
|
34
|
34
|
</el-form-item>
|
35
|
35
|
<el-form-item label="正确选项:">
|
|
@@ -55,21 +55,26 @@
|
55
|
55
|
<el-button @click="$router.go(-1)">返回</el-button>
|
56
|
56
|
</el-form-item>
|
57
|
57
|
</el-form>
|
|
58
|
+ <QuestionDrawer :dialog="dialog" :wordList='wordList' @handleCloseDrawer='handleCloseDrawer' @handleEditDrawer='handleEditDrawer' />
|
58
|
59
|
</div>
|
59
|
60
|
</template>
|
60
|
61
|
<script>
|
61
|
62
|
|
62
|
63
|
import { saveQuestion, updateQuestion, getQuestionDetail } from '@/api/question'
|
63
|
|
-import AddAnswerMatching from '@/components/AddAnswerMatching/index.vue'
|
64
|
|
-import { getCharacterLibDetail } from '@/api/characterLib'
|
|
64
|
+import { getGameCharacterList } from '@/api/gameCharacter'
|
|
65
|
+import QuestionDrawer from '@/components/Question/drawer.vue'
|
|
66
|
+
|
|
67
|
+// import AddAnswerMatching from '@/components/AddAnswerMatching/index.vue'
|
|
68
|
+// import { getCharacterLibDetail } from '@/api/characterLib'
|
65
|
69
|
|
66
|
70
|
export default {
|
67
|
71
|
components: {
|
68
|
|
- AddAnswerMatching
|
|
72
|
+ QuestionDrawer
|
|
73
|
+ // AddAnswerMatching
|
69
|
74
|
},
|
70
|
75
|
props: {
|
71
|
76
|
gameId: String,
|
72
|
|
- characterId: String,
|
|
77
|
+ // characterId: String,
|
73
|
78
|
questionId: String
|
74
|
79
|
},
|
75
|
80
|
data() {
|
|
@@ -85,8 +90,9 @@ export default {
|
85
|
90
|
},
|
86
|
91
|
// 正确答案数组
|
87
|
92
|
rightList: [],
|
88
|
|
- // 修饰词数据源
|
89
|
|
- wordList: []
|
|
93
|
+ // 特征数据源
|
|
94
|
+ wordList: [],
|
|
95
|
+ dialog: false
|
90
|
96
|
}
|
91
|
97
|
},
|
92
|
98
|
watch: {
|
|
@@ -115,20 +121,34 @@ export default {
|
115
|
121
|
},
|
116
|
122
|
gameId() {
|
117
|
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)
|
|
129
|
+ })
|
118
|
130
|
}
|
119
|
131
|
},
|
120
|
132
|
methods: {
|
121
|
133
|
onAddAnswer() {
|
122
|
|
- this.form.answerList.push({
|
123
|
|
- answerId: undefined,
|
124
|
|
- questionId: undefined,
|
125
|
|
- contentType: undefined,
|
126
|
|
- option: undefined,
|
127
|
|
- content: undefined,
|
128
|
|
- characterWordList: [],
|
129
|
|
- word: undefined,
|
130
|
|
- wordId: undefined
|
131
|
|
- })
|
|
134
|
+ 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
|
+ },
|
|
146
|
+ handleCloseDrawer() {
|
|
147
|
+ this.dialog = false
|
|
148
|
+ },
|
|
149
|
+ handleEditDrawer(val) {
|
|
150
|
+ console.log(val)
|
|
151
|
+ this.handleCloseDrawer()
|
132
|
152
|
},
|
133
|
153
|
onSubmit() {
|
134
|
154
|
if (this.form.name) {
|
|
@@ -136,40 +156,41 @@ export default {
|
136
|
156
|
updateQuestion(this.form, this.questionId).then((res) => {
|
137
|
157
|
this.$message('修改问题成功')
|
138
|
158
|
// 告诉父页面实例表需要刷新并且关闭当前组件
|
139
|
|
- this.$emit('handleRefresh', true)
|
|
159
|
+ this.$emit('handleRefreshQuestion', true)
|
140
|
160
|
})
|
141
|
161
|
} else {
|
142
|
162
|
saveQuestion(this.form).then((res) => {
|
143
|
163
|
this.$message('添加问题成功')
|
144
|
164
|
// 告诉父页面实例表需要刷新并且关闭当前组件
|
145
|
|
- this.$emit('handleRefresh', true)
|
|
165
|
+ this.$emit('handleRefreshQuestion', true)
|
|
166
|
+ this.$emit('handleEditQuestion', res.data.questionId)
|
146
|
167
|
})
|
147
|
168
|
}
|
148
|
169
|
} else {
|
149
|
170
|
this.$message('请输入问题名称')
|
150
|
171
|
}
|
151
|
|
- },
|
152
|
|
- handleChange(answer) {
|
153
|
|
- const index = this.form.answerList.indexOf(answer)
|
154
|
|
- this.$set(this.form.answerList, index, answer)
|
155
|
|
- },
|
156
|
|
-
|
157
|
|
- handleWordListChange(val, list) {
|
158
|
|
- getCharacterLibDetail(this.characterId).then((res) => {
|
159
|
|
- this.wordList = res.data.wordList
|
160
|
|
- })
|
161
|
|
- const index = this.form.answerList.indexOf(val)
|
162
|
|
- val.characterWordList = this.wordList.filter((item) =>
|
163
|
|
- list.some((v) => v === item.wordId)
|
164
|
|
- )
|
165
|
|
- val.characterWordList.map(item => {
|
166
|
|
- item = { ...item, characterId: this.characterId }
|
167
|
|
- })
|
168
|
|
- this.$set(this.form.answerList, index, val)
|
169
|
|
- },
|
170
|
|
- handleDelete(answer) {
|
171
|
|
- this.form.answerList.splice(this.form.answerList.indexOf(answer), 1)
|
172
|
172
|
}
|
|
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
|
+ // }
|
173
|
194
|
}
|
174
|
195
|
}
|
175
|
196
|
</script>
|