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
<template>
<div classs="noLesson">
<el-row type="flex" class="add-btn" justify="end">
<el-col :span="6">
<el-button type="success" plain @click="add" v-if="!$store.state.readonly">添加不上课日期</el-button>
</el-col>
</el-row>
<div class="card" style="margin-bottom: 10px;">
<el-card :body-style="{ padding: '0px' }" v-for="(currentDate, index) in list" :key="index">
<span class="time">{{ currentDate }}</span>
<div class="bottom clearfix">
<el-button type="text" class="button" @click="del(currentDate)" v-if="$store.state.deletePermission && !$store.state.readonly">删除</el-button>
</div>
</el-card>
</div>
<dialog-com :dialogObj="dialogObj" @changeShow="changeShow" @reflash="getList"/>
</div>
</template>
<script>
import dialogCom from './dialog'
import {getConfigListApi,deleteConfigApi,getConfigDetailApi,updateConfigApi} from "../../service/api";
export default {
name: "index",
data() {
return {
dialogObj:{
value:'',
desc:'',
show:false,
id:''
},
list: [],
id: ''
}
},
components:{
dialogCom
},
mounted(){
this.getList()
},
methods: {
changeShow(data){
this.dialogObj.show=data
},
getList(){
let json = {
key:'no_lesson_date'
};
getConfigListApi(json).then(res => {
if(res.list.length > 0){
let _desc = res.list[0].desc;
this.id = res.list[0].id;
this.list = _desc ? JSON.parse(_desc) : [];
}
})
},
add(){
this.dialogObj.title = '添加不上课日期';
this.dialogObj.desc = this.list || [];
this.dialogObj.show = true
if (this.list.length > 0){
this.dialogObj.id = this.id;
} else {
this.dialogObj.id = '';
}
},
edit(data){
getConfigDetailApi(data.id).then((res) => {
this.dialogObj.title = '修改不上课日期';
this.dialogObj.desc = res.desc;
this.dialogObj.show = true
});
},
del(data){
this.$confirm('此操作将删除该记录?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
let json = {
key: 'no_lesson_date',
value: 'no_lesson_date'
}
let _desc = [];
this.list.forEach((val)=>{
if(val !== data) {
_desc.push(val);
}
})
json.desc = JSON.stringify(_desc);
updateConfigApi(this.id,json).then(res=>{
this.$message({
type: 'success',
message: '删除成功!'
});
this.getList();
})
});
}
}
}
</script>
<style scoped lang="less">
@import "../../util/public";
.add-btn {
margin: 10px 0;
}
.noLesson {
padding: 20px 0;
}
.card {
display: flex;
flex-flow: row wrap;
justify-content: flex-start;
align-items: center;
& >div {
width: 236px;
margin-top: 10px;
margin-left: 10px;
padding: 10px;
}
}
.time {
font-size: 13px;
color: #999;
}
.bottom {
margin-top: 13px;
line-height: 12px;
}
.button {
padding: 0;
float: right;
}
.image {
width: 100%;
display: block;
}
.clearfix:before,
.clearfix:after {
display: table;
content: "";
}
.clearfix:after {
clear: both
}
</style>