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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
<template>
<div class="user">
<el-form ref="searchFrom" :model="searchFrom" label-width="100px" inline="" class="search-form">
<el-form-item label="课程标题">
<el-input v-model="searchFrom.title"></el-input>
</el-form-item>
<el-form-item label="">
<div class="search-btn-block">
<el-button type="primary" plain @click="getUser" icon="el-icon-search">搜索</el-button>
<el-button type="success" plain @click="add" v-if="!$store.state.readonly" icon="el-icon-plus">新增课程</el-button>
</div>
</el-form-item>
</el-form>
<el-tabs v-model="searchFrom.type" type="card" style="background: white;padding-top: 10px" @tab-click="getUser">
<el-tab-pane label="全部" name="-1"></el-tab-pane>
<el-tab-pane label="日课" name="1"></el-tab-pane>
<el-tab-pane label="月课" name="0"></el-tab-pane>
</el-tabs>
<el-table
:data="userList"
style="width: 100%">
<el-table-column
prop="title"
label="课程名">
<template slot-scope="scope">
<router-link :to="{name:'periods', query: { id: scope.row.id}}" >
{{scope.row.title}}
</router-link>
</template>
</el-table-column>
<el-table-column
label="课程类型">
<template slot-scope="scope">
{{scope.row.type | lessonType}}
</template>
</el-table-column>
<el-table-column
prop="theme_num"
label="主题数">
</el-table-column>
<el-table-column
prop="sing_num"
label="歌曲数">
</el-table-column>
<el-table-column
prop="item_num"
label="实体包数量">
</el-table-column>
<el-table-column
width="250"
label="操作">
<template slot-scope="scope">
<el-button size="mini" plain type="primary" @click="detail(scope.row)">
查看详情
</el-button>
<el-button size="mini" plain type="warning" @click="edit(scope.row)" v-if="!$store.state.readonly">
编辑
</el-button>
<el-button size="mini" plain type="danger" @click="delTeacher(scope.row)" v-if="$store.state.deletePermission && !$store.state.readonly">
删除
</el-button>
</template>
</el-table-column>
</el-table>
<page :total="total" :limit="limit" @pageChange="onPageChange" @sizeChange="onSizeChange"/>
<dialog-com :dialogObj="dialogObj" @changeShow="changeShow" @reflash="getUser"/>
</div>
</template>
<script>
import {getLessonApi,deleteLessonAPI} from "../../service/api";
import page from '../framework/page'
import dialogCom from './dialog'
import {LESSONTYPE} from "../../util/wordbook";
export default {
name: "index",
data(){
return {
searchFrom:{
title:'',
type:'-1'
},
userList:[],
total:0,
nowPage:1,
limit: 10,
dialogObj:{
type:0,
show:false,
id:''
},
}
},
components:{
page,
dialogCom
},
filters:{
lessonType(value){
return LESSONTYPE[value]
}
},
mounted(){
this.getUser()
},
methods:{
onPageChange(val){
this.nowPage = val
this.getUser()
},
onSizeChange(val){
this.limit = val
this.nowPage = 1
this.getUser()
},
getUser(){
this.searchFrom.page = this.nowPage;
let json = {
limit: this.limit,
page: this.nowPage
}
if (this.searchFrom.title) {
json.title = this.searchFrom.title
}
if (this.searchFrom.type && this.searchFrom.type !== '-1') {
json.type = this.searchFrom.type
}
getLessonApi(json).then(res=>{
this.userList = res.list;
this.total = res.total
})
},
edit(data){
this.dialogObj = {
type:1,
show:true,
id:data.id,
title:'编辑课程'
};
},
add(){
this.dialogObj = {
type:0,
show:true,
id:'',
title:'新增课程'
}
},
detail(data){
this.dialogObj.id = data.id;
this.dialogObj.type = 1;
this.dialogObj.show = true;
this.dialogObj.read = true;
},
delTeacher(data){
this.$confirm('此操作将删除该课程?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
deleteLessonAPI(data.id).then(res=>{
this.$message({
type: 'success',
message: '删除成功!'
});
this.getUser()
});
});
},
changeShow(data){
this.dialogObj.show=data
},
}
}
</script>
<style scoped lang="less">
@import "../../util/public";
.el-form-item{
margin: 0;
}
.user{
height: 100%;
overflow: auto;
padding: 20px 0;
.btn-content{
text-align: center;
}
}
</style>