|
|
@@ -23,7 +23,7 @@
|
|
|
:border-color="''"
|
|
|
:component-move="componentMove"
|
|
|
/>
|
|
|
- <component :is="getSettingCom" ref="setting" />
|
|
|
+ <component :is="getSettingCom" ref="setting" @addAnswerAndAnalysis="addAnswerAndAnalysis" />
|
|
|
</div>
|
|
|
</div>
|
|
|
<footer style="text-align: right">
|
|
|
@@ -47,7 +47,10 @@ import FillSetting from '@/views/book/courseware/create/components/question/fill
|
|
|
import RecordInput from '@/views/book/courseware/create/components/question/record_input/RecordInput.vue';
|
|
|
import RecordInputSetting from '@/views/book/courseware/create/components/question/record_input/RecordInputSetting.vue';
|
|
|
import RichText from '@/components/RichText.vue';
|
|
|
+
|
|
|
import { SaveCoursewareExercise } from '@/api/book';
|
|
|
+import { getSelectData } from '@/views/book/courseware/data/select';
|
|
|
+
|
|
|
export default {
|
|
|
name: 'ExerciseAdd',
|
|
|
components: {
|
|
|
@@ -65,7 +68,12 @@ export default {
|
|
|
RecordInputSetting,
|
|
|
RichText,
|
|
|
},
|
|
|
- props: ['exerciseContent'],
|
|
|
+ props: {
|
|
|
+ exerciseContent: {
|
|
|
+ type: [Object, null],
|
|
|
+ required: true,
|
|
|
+ },
|
|
|
+ },
|
|
|
data() {
|
|
|
return {
|
|
|
typeList: [
|
|
|
@@ -131,19 +139,36 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
},
|
|
|
- // 生命周期 - 创建完成(可以访问当前this实例)
|
|
|
- created() {
|
|
|
- if (this.exerciseContent) {
|
|
|
- this.content = this.exerciseContent.content_exercise;
|
|
|
- this.title = this.exerciseContent.content_title;
|
|
|
- this.typeValue = this.exerciseContent.content_exercise
|
|
|
- ? JSON.parse(this.exerciseContent.content_exercise).type
|
|
|
- : 'select';
|
|
|
- this.exercise_id = this.exerciseContent.exercise_id;
|
|
|
- }
|
|
|
+ watch: {
|
|
|
+ exerciseContent: {
|
|
|
+ handler(newVal) {
|
|
|
+ if (newVal) {
|
|
|
+ this.content = this.exerciseContent.content_exercise;
|
|
|
+ this.title = this.exerciseContent.content_title;
|
|
|
+ this.typeValue = this.exerciseContent.content_exercise
|
|
|
+ ? JSON.parse(this.exerciseContent.content_exercise).type
|
|
|
+ : 'select';
|
|
|
+ this.exercise_id = this.exerciseContent.exercise_id;
|
|
|
+
|
|
|
+ this.$nextTick(() => {
|
|
|
+ this.$refs.setting.setSetting(this.$refs.component.data.property, {});
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ this.content = getSelectData();
|
|
|
+ this.title = '';
|
|
|
+ this.typeValue = 'select';
|
|
|
+ this.exercise_id = '';
|
|
|
+ }
|
|
|
+ },
|
|
|
+ immediate: true,
|
|
|
+ deep: true,
|
|
|
+ },
|
|
|
},
|
|
|
methods: {
|
|
|
componentMove() {},
|
|
|
+ addAnswerAndAnalysis(type) {
|
|
|
+ this.$refs.component.addAnswerAndAnalysis(type);
|
|
|
+ },
|
|
|
submitAdd() {
|
|
|
this.loading = true;
|
|
|
let data = {
|