Commit 9483849d authored by 王's avatar

课程管理bug&..

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