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,6 +29,8 @@ ...@@ -29,6 +29,8 @@
<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-row>
<el-col :span="10">
<el-form-item label="选择课程"> <el-form-item label="选择课程">
<el-cascader <el-cascader
clearable clearable
...@@ -41,15 +43,19 @@ ...@@ -41,15 +43,19 @@
></el-cascader> ></el-cascader>
</el-form-item> </el-form-item>
<el-form-item label="已选课程"> <el-form-item label="已选课程">
<el-row> <div class="selected-block" v-for="(data, index) in selectedLessonList" :key="index">
<el-col :span="12" class="selected-block" v-for="data in selectedLessonList" :key="data.id">
<el-card shadow="always"> <el-card shadow="always">
{{data.name}} {{data.name}}
<el-button type="danger" icon="el-icon-close" @click="delLesson(data)" circle size="mini" style="float: right;padding: 3px"></el-button> <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> </el-card>
</el-col> </div>
</el-row>
</el-form-item> </el-form-item>
</el-col>
<el-col :span="10">
<el-form-item label="选择盒子"> <el-form-item label="选择盒子">
<el-cascader <el-cascader
clearable clearable
...@@ -62,15 +68,19 @@ ...@@ -62,15 +68,19 @@
></el-cascader> ></el-cascader>
</el-form-item> </el-form-item>
<el-form-item label="已选盒子"> <el-form-item label="已选盒子">
<el-row> <div class="selected-block" v-for="(data,index) in selectedBoxList" :key="data.id">
<el-col :span="12" class="selected-block" v-for="data in selectedBoxList" :key="data.id">
<el-card shadow="always"> <el-card shadow="always">
{{data.name}} {{data.name}}
<el-button type="danger" icon="el-icon-close" @click="delBox(data)" circle size="mini" style="float: right;padding: 3px"></el-button> <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> </el-card>
</div>
</el-form-item>
</el-col> </el-col>
</el-row> </el-row>
</el-form-item>
</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) this.$refs['form'].validate((valid) => {
console.log('this.form.text_category_ids', this.form.text_category_ids) let itemIds = [];
this.selectedBoxList.forEach(i=>{this.form.item_category_ids.push(i.id)}); let textIds = [];
this.selectedLessonList.forEach(i=>{this.form.text_category_ids.push(i.id)}); this.selectedBoxList.forEach(i=>{itemIds.push(i.id)});
this.form.text_category_ids = this.form.text_category_ids.toString(); this.selectedLessonList.forEach(i=>{textIds.push(i.id)});
if(this.imageList[0]){ if(this.imageList[0]){
this.form.cover = this.imageList[0].url; this.form.cover = this.imageList[0].name;
} }
this.form.item_category_ids = this.form.item_category_ids.toString(); let json = this.form;
this.$refs['form'].validate((valid) => { 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,9 +261,7 @@ ...@@ -251,9 +261,7 @@
}); });
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={ this.form={
...@@ -269,30 +277,30 @@ ...@@ -269,30 +277,30 @@
this.selectedBoxList = []; this.selectedBoxList = [];
break; break;
case 1: case 1:
getLessonDetailApi(this.dialogObj.id).then(res=>{ getLessonDetailApi(this.dialogObj.id).then(resL=>{
this.form={ this.form={
title:res.title, title:resL.title,
type:res.type, type:resL.type,
text_category_ids:[], text_category_ids:[],
item_category_ids:[], item_category_ids:[],
cover:'', cover:'',
}; };
this.imageList = [{name:res.cover,url:res.cover}]; this.imageList = [{name:resL.cover,url: process.env.IMAGE_URL_HEAD + resL.cover}];
this.uploadShow = false; this.uploadShow = false;
this.selectedLessonList = []; this.selectedLessonList = [];
this.selectedBoxList = []; this.selectedBoxList = [];
if(res.type === 0){ if(resL.type === 0){
res.detail['0'].forEach(i=>{ resL.detail['0'].forEach(i=>{
this.selectLesson([i.pid,i.id]) this.selectLesson([i.pid,i.id])
}); });
}else if(res.type === 1){ }else if(resL.type === 1){
res.detail['1'].forEach(t=>{ resL.detail['1'].forEach(t=>{
let x = this.showLessonList.find(i=>{return i.children.find(j=>{return j.id === t.pid})}) let x = this.showLessonList.find(i=>{return i.children.find(j=>{return j.id === t.pid})})
this.selectLesson([x.id,t.pid,t.id]) this.selectLesson([x.id,t.pid,t.id])
}) })
} }
if(res.detail['2']){ if(resL.detail['2']){
res.detail['2'].forEach(i=>{ resL.detail['2'].forEach(i=>{
this.selectBox([i.id]) this.selectBox([i.id])
}); });
} }
...@@ -314,6 +322,7 @@ ...@@ -314,6 +322,7 @@
// }); // });
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()
// }
},
mounted(){
this.initDialog() 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