1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
<template>
<el-dialog
:title="editorObj.title"
:visible.sync="editorObj.show"
:close-on-click-modal="false"
:close-on-press-escape="false"
:modal="false"
:center="true"
:fullscreen="true">
<el-tabs v-model="activeName2" type="card" >
<el-tab-pane label="基本信息" name="base">
<base-block :formData="formData"/>
</el-tab-pane>
<el-tab-pane label="课程内容" name="content">
<lesson-content :formData="formData"/>
</el-tab-pane>
<el-tab-pane label="爸妈看一看" name="look">
<look-block :formData="formData.content"/>
</el-tab-pane>
<el-tab-pane label="宝贝玩一玩" name="play">
<play-block :formData="formData.content"/>
</el-tab-pane>
<el-tab-pane label="磨磨小耳朵" name="fun">
<fun-block :formData="formData.content"/>
</el-tab-pane>
</el-tabs>
<span slot="footer" class="dialog-footer">
<el-button @click="editorObj.show= false">取 消</el-button>
<el-button type="primary" @click="onSave">保 存</el-button>
</span>
</el-dialog>
</template>
<script>
import {getElemenetDetailApi,editElementApi,addElementApi} from "../../service/api";
import baseBlock from '../mould/baseBlock'
import lookBlock from '../mould/lookBlock'
import playBlock from '../mould/playBlock'
import funBlock from '../mould/funBlock'
import lessonContent from '../mould/lessonContent'
export default {
props:[
'editorObj'
],
components:{
lessonContent,
baseBlock,
lookBlock,
playBlock,
funBlock
},
data() {
return {
activeName2:'base',
formData:{
title:'',
cover:'',
content:{
base:{},
tips:{
content:'',
title1:'',
title1_content:'',
title2:'',
title2_content:''
},
look:{
content:'',
},
play:{
type:false,
audio:[],
audio2:[],
video:[],
video2:[],
change:false,
change2:false,
age:false
},
fun:{
type:false,
audio:[],
audio2:[],
video:[],
video2:[],
change:false,
change2:false,
age:false
}
},
type:0
}
}
},
methods:{
onSave(){
if(this.editorObj.type===1){
let json = {
category_id:this.editorObj.category_id,
title:this.formData.title,
content:JSON.stringify(this.formData.content),
cover:this.formData.cover
};
editElementApi(json,this.editorObj.id).then(res=>{
this.$message({
type: 'success',
message: '保存成功!'
});
this.$emit('reflash');
this.editorObj.show=false
})
}else if(this.editorObj.type===0){
let json = {
category_id:this.editorObj.category_id,
title:this.formData.title,
content:JSON.stringify(this.formData.content),
cover:this.formData.cover
};
addElementApi(json,0).then(res=>{
this.$message({
type: 'success',
message: '保存成功!'
});
this.$emit('reflash');
})
}
}
},
watch:{
'editorObj.show'(t){
if(t){
let value = this.editorObj.id
if(value){
getElemenetDetailApi(value).then(res=>{
res.content = JSON.parse(res.content);
this.formData = res
})
}else{
this.formData={
title:'',
cover:'',
content:{
base:{},
tips:{
content:'',
title1:'',
title1_content:'',
title2:'',
title2_content:''
},
look:{
content:'',
},
play:{
type:false,
audio:[],
audio2:[],
video:[],
video2:[],
change:false,
change2:false,
age:false
},
fun:{
type:false,
audio:[],
audio2:[],
video:[],
video2:[],
change:false,
change2:false,
age:false
}
},
type:0
}
}
}
}
}
}
</script>
<style scoped lang="less">
@import "../../util/public";
</style>