|
|
@@ -1,11 +1,11 @@
|
|
|
<template>
|
|
|
<div class="edit-quiz">
|
|
|
- <quiz-editor back-title="修改测试" :init-quiz="initQuiz" @submit="handleSubmit"/>
|
|
|
+ <quiz-editor back-title="修改测试" :init-quiz="initQuiz" @submit="handleSubmit" @delete="handleDelete"/>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
-import { updateQuiz, getOneQuiz } from '@/server/quiz'
|
|
|
+import { updateQuiz, getOneQuiz, deleteQuiz } from '@/server/quiz'
|
|
|
import QuizEditor from '@/views/quiz/components/QuizEditor'
|
|
|
|
|
|
export default {
|
|
|
@@ -31,11 +31,18 @@ export default {
|
|
|
},
|
|
|
handleSubmit (quizData) {
|
|
|
updateQuiz({ ...quizData, slideId: this.initQuiz?.slide?.id })
|
|
|
- .then(() => this.$setSuccessMessage('创建成功'))
|
|
|
+ .then(() => this.$setSuccessMessage('修改成功'))
|
|
|
.then(() => this.$router.go(-1))
|
|
|
.catch(err =>
|
|
|
this.$setErrorMessage(err.response.data.msg)
|
|
|
)
|
|
|
+ },
|
|
|
+ handleDelete ({ quizId }) {
|
|
|
+ deleteQuiz({ quizId }).then(() => {
|
|
|
+ this.$setSuccessMessage('删除成功')
|
|
|
+ }).catch(err => {
|
|
|
+ this.$setErrorMessage(err.response.data.msg)
|
|
|
+ })
|
|
|
}
|
|
|
}
|
|
|
}
|