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
<template>
<div class="box-index">
<box-type-list @changeCategoryId="changeCategoryId"/>
<div class="add-block">
<el-button class="add-btn" type="success" @click="onAdd()" v-if="!$store.state.readonly">+新增盒子</el-button>
</div>
<el-row>
<el-col :span="5" v-for="(data, index) in list" :key="index" class="card-col">
<el-card :body-style="{ padding: '0px' }" shadow="hover" class="card">
<img v-if="data.cover !== ''" :src="defaultImgPath + data.cover" class="image">
<img v-if="data.cover === ''" :src="defaultImgPath + data.cover" class="image">
<div style="padding: 14px;">
<span>
{{data.title}}
</span>
<div class="bottom clearfix">
<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 class="btn-block">
<el-button type="warning" icon="el-icon-edit" circle plain size="mini" v-if="!$store.state.readonly" @click="onEdit(data.id)"></el-button>
<el-button type="danger" icon="el-icon-delete" circle plain size="mini" v-if="$store.state.deletePermission && !$store.state.readonly" @click="delBox(data.id)" ></el-button>
</div>
</div>
</div>
</el-card>
</el-col>
</el-row>
<box-dialog :boxDialogObj="boxDialogObj" v-if="boxDialogObj.show" @reflash="initPage"/>
</div>
</template>
<script>
import { getBoxListApi,delBoxApi} from "../../service/api";
import BoxTypeList from './boxTypeList'
import boxDialog from './boxDialog';
export default {
name: "index",
components:{
BoxTypeList,
boxDialog
},
data(){
return {
category_id:'',
defaultImgPath:process.env.IMAGE_URL_HEAD ,
list:[],
boxDialogObj:{
show:false,
id:'',
category_id:'',
title:'',
type:0
},
}
},
mounted(){
},
methods: {
initPage (id){
getBoxListApi(id).then(res=>{
this.list = res.list
})
},
onEdit(id){
this.boxDialogObj = {
show:true,
type:1,
title:'修改盒子',
id:id,
category_id:this.category_id
}
},
onAdd(){
this.boxDialogObj = {
show:true,
type:0,
title:'添加盒子',
category_id:this.category_id
}
},
changeCategoryId(data){
this.category_id = data
},
delBox(id){
this.$confirm('此操作将删除该盒子?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
delBoxApi(id).then(res=>{
this.$message({
type: 'success',
message: '删除成功!'
});
});
this.initPage(this.category_id)
});
}
},
watch:{
category_id(value){
this.initPage(value)
}
}
}
</script>
<style scoped lang="less">
.box-index{
overflow: hidden;
position: relative;
padding: 20px 0;
display: block;
.add-block{
display: block;
text-align: right;
margin: 10px 0;
}
.card-col{
padding: 15px;
}
.card{
cursor: pointer;
.image{
width: 100%;
height: 300px;
background: #f0f0f0;
display: inline-block;
}
.bottom {
height: 30px;
line-height: 30px;
.btn-block {
float: right;
.el-button {
margin: 0;
}
}
}
}
}
</style>