Commit 9483849d authored by 王's avatar

课程管理bug&..

parent edb86fab
......@@ -12,8 +12,8 @@ module.exports = {
//本地代理设置
proxyTable: {
'/api': {
// target: 'http://local.base-api.sing.com', // 接口的域名
target: 'http://wechat.test.singsingenglish.com/',
target: 'http://local.base-api.sing.com', // 接口的域名
// target: 'http://wechat.test.singsingenglish.com/',
changeOrigin: true, // 如果接口跨域,需要进行这个参数配置
}
},
......
......@@ -3,6 +3,7 @@
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<meta name="referrer" content="never">
<link rel="stylesheet" href="https://at.alicdn.com/t/font_746649_7dsnjecwkpg.css">
<title>singsing-new-admin</title>
</head>
......
......@@ -29,48 +29,58 @@
<el-option label="日课" :value="1"></el-option>
</el-select>
</el-form-item>
<el-form-item label="选择课程">
<el-cascader
clearable
:value="selectedLesson"
:options="showLessonList"
:show-all-levels="false"
@active-item-change="changLessonItem"
@change="selectLesson"
:props="{label: 'name',value:'id',children:'children'}"
></el-cascader>
</el-form-item>
<el-form-item label="已选课程">
<el-row>
<el-col :span="12" class="selected-block" v-for="data in selectedLessonList" :key="data.id">
<el-card shadow="always">
{{data.name}}
<el-button type="danger" icon="el-icon-close" @click="delLesson(data)" circle size="mini" style="float: right;padding: 3px"></el-button>
</el-card>
</el-col>
</el-row>
</el-form-item>
<el-form-item label="选择盒子">
<el-cascader
clearable
:value="selectedBox"
:options="showBoxList"
:show-all-levels="false"
@change="selectBox"
expand-trigger="hover"
:props="{label: 'name',value:'id',children:'children'}"
></el-cascader>
</el-form-item>
<el-form-item label="已选盒子">
<el-row>
<el-col :span="12" class="selected-block" v-for="data in selectedBoxList" :key="data.id">
<el-card shadow="always">
{{data.name}}
<el-button type="danger" icon="el-icon-close" @click="delBox(data)" circle size="mini" style="float: right;padding: 3px"></el-button>
</el-card>
</el-col>
</el-row>
</el-form-item>
<el-row>
<el-col :span="10">
<el-form-item label="选择课程">
<el-cascader
clearable
:value="selectedLesson"
:options="showLessonList"
:show-all-levels="false"
@active-item-change="changLessonItem"
@change="selectLesson"
:props="{label: 'name',value:'id',children:'children'}"
></el-cascader>
</el-form-item>
<el-form-item label="已选课程">
<div class="selected-block" v-for="(data, index) in selectedLessonList" :key="index">
<el-card shadow="always">
{{data.name}}
<el-button type="danger" icon="el-icon-close" @click="delLesson(data)" circle size="mini" style="float: right;padding: 3px"></el-button>
<div class="move">
<el-button type="text" class="button" v-if="index !== 0" @click="moveItem(index-1,index)">上移</el-button>
<el-button type="text" class="button" v-if="index !== selectedLessonList.length - 1" @click="moveItem(index,index+1)">下移</el-button>
</div>
</el-card>
</div>
</el-form-item>
</el-col>
<el-col :span="10">
<el-form-item label="选择盒子">
<el-cascader
clearable
:value="selectedBox"
:options="showBoxList"
:show-all-levels="false"
@change="selectBox"
expand-trigger="hover"
:props="{label: 'name',value:'id',children:'children'}"
></el-cascader>
</el-form-item>
<el-form-item label="已选盒子">
<div class="selected-block" v-for="(data,index) in selectedBoxList" :key="data.id">
<el-card shadow="always">
{{data.name}}
<el-button type="danger" icon="el-icon-close" @click="delBox(data)" circle size="mini" style="float: right;padding: 3px"></el-button>
<div class="move">
<el-button type="text" class="button" v-if="index !== 0" @click="moveBox(index-1, index)">上移</el-button>
<el-button type="text" class="button" v-if="index !== selectedBoxList.length - 1" @click="moveBox(index, index+1)">下移</el-button>
</div>
</el-card>
</div>
</el-form-item>
</el-col>
</el-row>
</el-form>
<span slot="footer" class="dialog-footer" v-if="dialogObj.type !== 2">
<el-button @click="dialogObj.show = false">取 消</el-button>
......@@ -144,7 +154,6 @@
})
},
selectLesson(data){
console.log('selectLesson', data, this.showLessonList)
let select = this.showLessonList.find(i=>{return i.id === data[0]});
if (select.children) {
select = select.children.find(i=>{return i.id === data[1]});
......@@ -176,16 +185,17 @@
},
sub(){
console.log('this.form.item_category_ids', this.form.item_category_ids)
console.log('this.form.text_category_ids', this.form.text_category_ids)
this.selectedBoxList.forEach(i=>{this.form.item_category_ids.push(i.id)});
this.selectedLessonList.forEach(i=>{this.form.text_category_ids.push(i.id)});
this.form.text_category_ids = this.form.text_category_ids.toString();
if(this.imageList[0]){
this.form.cover = this.imageList[0].url;
}
this.form.item_category_ids = this.form.item_category_ids.toString();
this.$refs['form'].validate((valid) => {
let itemIds = [];
let textIds = [];
this.selectedBoxList.forEach(i=>{itemIds.push(i.id)});
this.selectedLessonList.forEach(i=>{textIds.push(i.id)});
if(this.imageList[0]){
this.form.cover = this.imageList[0].name;
}
let json = this.form;
json.item_category_ids = itemIds.toString();
json.text_category_ids = textIds.toString();
if(valid){
if (!this.form.cover) {
this.$message({
......@@ -194,14 +204,14 @@
});
return
}
if (!this.form.text_category_ids) {
if (!json.text_category_ids) {
this.$message({
type: 'error',
message: '请选择课程!'
});
return
}
if (!this.form.item_category_ids) {
if (!json.item_category_ids) {
this.$message({
type: 'error',
message: '请选择盒子!'
......@@ -212,7 +222,7 @@
case 1:
// this.$refs['form'].validate((valid) => {
// if(valid){
editLessonApi(this.dialogObj.id,this.form).then(res=>{
editLessonApi(this.dialogObj.id,json).then(res=>{
this.$message({
type: 'success',
message: '修改成功!'
......@@ -227,7 +237,7 @@
console.log(this.form);
// this.$refs['form'].validate((valid) => {
// if(valid){
addLessonApi(this.form).then(res=>{
addLessonApi(json).then(res=>{
this.$message({
type: 'success',
message: '新增成功!'
......@@ -251,59 +261,57 @@
});
getCategoryApi().then(res=>{
this.lessonList = res;
console.log('res getCategoryApi', res)
this.showLessonList = JSON.parse(JSON.stringify(res))
});
switch(this.dialogObj.type){
case 0:
this.form={
title:'',
type:0,
text_category_ids:[],
item_category_ids:[],
cover:0,
};
this.uploadShow = true;
this.imageList = [];
this.selectedLessonList = [];
this.selectedBoxList = [];
break;
case 1:
getLessonDetailApi(this.dialogObj.id).then(res=>{
switch(this.dialogObj.type){
case 0:
this.form={
title:res.title,
type:res.type,
title:'',
type:0,
text_category_ids:[],
item_category_ids:[],
cover:'',
cover:0,
};
this.imageList = [{name:res.cover,url:res.cover}];
this.uploadShow = false;
this.uploadShow = true;
this.imageList = [];
this.selectedLessonList = [];
this.selectedBoxList = [];
if(res.type === 0){
res.detail['0'].forEach(i=>{
this.selectLesson([i.pid,i.id])
});
}else if(res.type === 1){
res.detail['1'].forEach(t=>{
let x = this.showLessonList.find(i=>{return i.children.find(j=>{return j.id === t.pid})})
this.selectLesson([x.id,t.pid,t.id])
})
}
if(res.detail['2']){
res.detail['2'].forEach(i=>{
this.selectBox([i.id])
});
}
break;
case 1:
getLessonDetailApi(this.dialogObj.id).then(resL=>{
this.form={
title:resL.title,
type:resL.type,
text_category_ids:[],
item_category_ids:[],
cover:'',
};
this.imageList = [{name:resL.cover,url: process.env.IMAGE_URL_HEAD + resL.cover}];
this.uploadShow = false;
this.selectedLessonList = [];
this.selectedBoxList = [];
if(resL.type === 0){
resL.detail['0'].forEach(i=>{
this.selectLesson([i.pid,i.id])
});
}else if(resL.type === 1){
resL.detail['1'].forEach(t=>{
let x = this.showLessonList.find(i=>{return i.children.find(j=>{return j.id === t.pid})})
this.selectLesson([x.id,t.pid,t.id])
})
}
if(resL.detail['2']){
resL.detail['2'].forEach(i=>{
this.selectBox([i.id])
});
}
});
break;
case 2:
this.title = '编辑';
this.show = this.dialogObj.show;
this.id = this.dialogObj.id;
this.type = 2;
});
break;
case 2:
this.title = '编辑';
this.show = this.dialogObj.show;
this.id = this.dialogObj.id;
this.type = 2;
// getTeacherDetailApi(this.id).then(res=>{
// this.form.name = res.name;
// this.form.alias = res.alias;
......@@ -312,8 +320,9 @@
// this.form.status = res.status;
// this.loading = false
// });
break
}
break
}
});
},
beforeAvatarUpload(){
this.uploadShow = false
......@@ -331,19 +340,37 @@
this.form.cover = process.env.IMAGE_URL_HEAD + res.url;
this.imageList[0] = {name:res.url,url:process.env.IMAGE_URL_HEAD + res.url,title:'',lable:''};
})
},
moveBox(first,second){
let list = this.selectedBoxList;
let oFirst = list[first];
let oSecond = list[second];
this.selectedBoxList.splice(first,1,oSecond);
this.selectedBoxList.splice(second,1,oFirst);
},
moveItem(first,second){
console.log('moveItem', first, second);
let list = this.selectedLessonList;
let oFirst = list[first];
let oSecond = list[second];
this.selectedLessonList.splice(first,1,oSecond);
this.selectedLessonList.splice(second,1,oFirst);
}
},
watch:{
dialogObj(){
this.initDialog()
}
// dialogObj(){
// this.initDialog()
// }
},
mounted(){
this.initDialog()
}
}
</script>
<style scoped lang="less">
.el-col{
height: 50px;
/*height: 50px;*/
text-align: center;
margin-bottom: 20px;
line-height: 40px;
......@@ -368,6 +395,12 @@
margin: 0;
text-align: left;
}
.move {
display: flex;
flex-flow: row;
justify-content: flex-end;
align-items: center;
}
</style>
<style>
.disabled .el-upload--picture-card {
......
......@@ -72,7 +72,7 @@
</el-table-column>
</el-table>
<page :total="total" v-model="nowPage"/>
<dialog-com :dialogObj="dialogObj" @changeShow="changeShow" @reflash="getUser"/>
<dialog-com v-if="dialogObj.show" :dialogObj="dialogObj" @changeShow="changeShow" @reflash="getUser"/>
</div>
</template>
......
......@@ -183,6 +183,8 @@
onAdd(){
this.newDialog.form.id = '';
this.newDialog.start_num = '';
this.newDialog.form.goods_id = '';
this.newDialog.form.title = '';
this.newDialog.form.start_at = '';
this.newDialog.form.rest_week_day = [];
this.newDialog.form.teacher_ids = [];
......
......@@ -26,7 +26,7 @@
<el-input v-model="form.title"></el-input>
</el-form-item>
<el-form-item label="开始主题" prop="start_num">
<el-select v-model="form.start_num" placeholder="请选择">
<el-select v-model="form.start_num" clearable placeholder="请选择">
<el-option
v-for="item in itemOptions"
:key="item.id"
......@@ -215,6 +215,8 @@
})
},
getLessonDetail(id){
console.log('getLessonDetail', id);
this.form.start_num=''
getLessonDetailApi(id,{}).then((res) => {
this.itemOptions = res.detail[res.type]
})
......
......@@ -171,7 +171,8 @@
this.form = {
name:res.name,
num:res.num,
cover:res.cover
cover:res.cover,
category_name: res.category_name
};
if(this.form.cover && this.form.cover !== ''){
this.imageList = [{name:res.cover,url:process.env.IMAGE_URL_HEAD + res.cover}];
......
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