Commit 1d6ca083 authored by 赵茹林's avatar 赵茹林

课程列表 修复 日课、月课切换异常的问题

parent 59f53120
...@@ -26,7 +26,10 @@ ...@@ -26,7 +26,10 @@
<el-row> <el-row>
<el-col :span="10"> <el-col :span="10">
<el-form-item label="课程类型"> <el-form-item label="课程类型">
<el-select v-model="form.type" placeholder="请选择课程类型" @change="selectedLesson = [],selectedLessonList = []"> <el-select
v-model="form.type" placeholder="请选择课程类型"
@change="changLessonItem">
<!--@change="selectedLesson = [], selectedLessonList = []">-->
<el-option label="月课" :value="0"></el-option> <el-option label="月课" :value="0"></el-option>
<el-option label="日课" :value="1"></el-option> <el-option label="日课" :value="1"></el-option>
</el-select> </el-select>
...@@ -35,14 +38,15 @@ ...@@ -35,14 +38,15 @@
<el-col :span="10"> <el-col :span="10">
<el-form-item label="选择课程"> <el-form-item label="选择课程">
<el-cascader <el-cascader
ref="cascader"
clearable clearable
:value="selectedLesson" :value="selectedLesson"
:options="showLessonList" :options="showLessonList"
:show-all-levels="false" :show-all-levels="false"
@active-item-change="changLessonItem"
@change="selectLesson" @change="selectLesson"
:props="{label: 'name',value:'id',children:'children'}" :props="{label: 'name',value:'id',children:'children'}"
></el-cascader> ></el-cascader>
<!--@active-item-change="changLessonItem"-->
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-row> </el-row>
...@@ -120,10 +124,12 @@ ...@@ -120,10 +124,12 @@
], ],
data(){ data(){
return{ return{
lessList: [],
fullList: [],
showLessonList:[],
selectedLesson:[], selectedLesson:[],
selectedLessonList:[], selectedLessonList:[],
lessonList:[], lessonList:[],
showLessonList:[],
selectedBox:[], selectedBox:[],
selectedBoxList:[], selectedBoxList:[],
boxList:[], boxList:[],
...@@ -152,18 +158,24 @@ ...@@ -152,18 +158,24 @@
}, },
changLessonItem(){ changLessonItem(){
if(this.form.type === 0){ this.selectedLesson = [];
this.showLessonList.forEach(a=>{ this.selectedLessonList = [];
// debugger
// this.$refs.cascader.clearCheckedNodes();
/*if(this.form.type == 0){
/!*var arr = JSON.parse(JSON.stringify(this.lessonList));
arr.forEach(a=>{
a.children = a.children || []; a.children = a.children || [];
a.children.forEach(b=>{ a.children.forEach(b=>{
if(b.children){ if(b.children){
delete b.children delete b.children
} }
}) })
}) })*!/
}else{ this.showLessonList = this.lessList;
this.showLessonList = this.lessonList } else {
} this.showLessonList = this.fullList;
}*/
}, },
delLesson(data){ delLesson(data){
this.selectedLessonList = this.selectedLessonList.filter(i=>{ this.selectedLessonList = this.selectedLessonList.filter(i=>{
...@@ -275,7 +287,25 @@ ...@@ -275,7 +287,25 @@
}); });
getCategoryApi().then(res=>{ getCategoryApi().then(res=>{
this.lessonList = res; this.lessonList = res;
this.showLessonList = JSON.parse(JSON.stringify(res))
var lessList = JSON.parse(JSON.stringify(res));
lessList.forEach(a=>{
a.children = a.children || [];
a.children.forEach(b=>{
if(b.children){
delete b.children
}
})
})
this.lessList = lessList;
this.fullList = JSON.parse(JSON.stringify(res));
if (this.form.type == 0) {
this.showLessonList = this.lessList;
} else {
this.showLessonList = this.fullList;
}
switch(this.dialogObj.type){ switch(this.dialogObj.type){
case 0: case 0:
this.form={ this.form={
...@@ -372,12 +402,19 @@ ...@@ -372,12 +402,19 @@
this.selectedLessonList.splice(second,1,oFirst); this.selectedLessonList.splice(second,1,oFirst);
} }
}, },
watch:{ watch: {
'dialogObj.show'(val){ 'form.type'() {
if(val){ if (this.form.type == 0) {
this.initDialog() this.showLessonList = this.lessList;
} } else {
} this.showLessonList = this.fullList;
}
},
'dialogObj.show'(val) {
if (val) {
this.initDialog()
}
}
}, },
// mounted(){ // mounted(){
// this.initDialog() // this.initDialog()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment