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
<template>
<div>
<div class="add-block">
<el-button class="add-btn" @click="onAdd">+新增课时</el-button>
</div>
<el-card v-for="data in list" :key="data.id" class="box-card">
<div class="id">
<img :src="data.cover">
</div>
<div class="btn">
<el-button
type=""
icon="el-icon-edit"
circle size="mini"
@click="onEdit(data)">
</el-button>
<el-button
type=""
icon="el-icon-delete"
circle size="mini"
@click="delLseeon(data)">
</el-button>
</div>
<div class="name">
{{data.title}}
<el-tag size="mini">level{{data.min_level}}-level{{data.max_level}}</el-tag>
<el-tag type="success" size="mini">{{data.min_age}}-{{data.max_age}}岁</el-tag>
</div>
</el-card>
<editor-dialog :editorObj="editorObj"/>
</div>
</template>
<script>
import {getCateListApi,delElementApi} from "../../service/api";
import EditorDialog from './editorDialog'
export default {
name: "list",
components:{
EditorDialog
},
props:[
'id'
],
data(){
return {
list:[],
editorObj:{
show:false,// 显示开关
category_id:0,// 分类id
type:0,//0 新增 1 修改
title:'',// 标题
id:''// 课程id
}
}
},
created(){
if(this.id !== '' && this.id !== null)this.getList()
},
methods:{
getList(){
getCateListApi({category_id:this.id}).then(res=>{
this.list = res.list
})
},
delLseeon(data){
this.$confirm('此操作将删除该课包?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
delElementApi(data.id).then(res=>{
this.$message({
type: 'success',
message: '删除成功!'
});
});
this.getList();
});
},
onUp(){},
onAdd(){
this.editorObj = {
show:true,
category_id:this.id,
type:0,
title:'新增课包'
}
},
onEdit(data){
this.editorObj = {
show:true,
category_id:this.id,
id:data.id,
type:1,
title:'编辑课包'
}
}
},
watch:{
id(value){
if(value !== '' && value !== null)this.getList()
}
}
}
</script>
<style scoped lang="less">
@import "../../util/public";
.box-card{
margin: 10px 0;
cursor: pointer;
padding: 0;
&:hover{
background: #3a8ee6;
color: white;
}
.id{
margin-right: 20px;
width: 4em;
text-align: center;
float: left;
img{
width: 100%;
}
}
.btn{
float: right;
}
.name{
span{
display: inline-block;
text-align: center;
}
}
}
.add-block{
.clear-both;
.add-btn{
float: right;
}
}
</style>