index.vue
7.1 KB
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
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
<template>
<div class="app-container">
<el-header height>
<el-input v-model="queryForm.title" style="width: 200px" placeholder="视频名称" clearable></el-input>
<el-select v-model="queryForm.playbackTypeCode" placeholder="请选择" clearable @change="searchPlayback">
<el-option
v-for="item in playbackTypeList"
:key="item.playbackTypeCode"
:label="item.typeName"
:value="item.playbackTypeCode">
</el-option>
</el-select>
<el-button @click="searchPlayback" type="primary">搜索</el-button>
<el-button type="primary" @click="playbackCreate">创建</el-button>
</el-header>
<el-main>
<el-table
:data="playbackList"
style="width: 100%"
stripe
highlight-current-row
v-loading="loading"
>
<el-table-column label="名称" prop="title"></el-table-column>
<el-table-column label="视频链接" prop="videoUrl"></el-table-column>
<el-table-column label="内容" prop="videoContent">
</el-table-column>
<el-table-column label="类型" prop="typeName"></el-table-column>
<el-table-column label="操作">
<template slot-scope="scope">
<el-link type="primary" @click="playbackEdit(scope.row)">编辑 </el-link>
<el-link type="primary" @click="playbackDelete(scope.row.playbackCode)">删除 </el-link>
</template>
</el-table-column>
</el-table>
</el-main>
<el-footer>
<div style="text-align:right;">
<el-pagination
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
:current-page="queryForm.page"
:page-size="queryForm.size"
layout="total, prev, pager, next"
:total="total">
</el-pagination>
</div>
</el-footer>
<el-dialog
width="60%"
:title="title"
:visible.sync="dialogVisible">
<el-form :model="playbackForm" ref="playbackForm" :rules="playbackRules" label-width="180px">
<el-form-item label="名称:" prop="title">
<el-input v-model="playbackForm.title" maxlength="100" show-word-limit></el-input>
</el-form-item>
<el-form-item label="视频链接:" prop="videoUrl">
<el-input v-model="playbackForm.videoUrl" maxlength="100" show-word-limit></el-input>
<div>视频链接提取方法:
<div>1.电脑打开qq视频链接
2.鼠标移动至视频左下角分享按钮
3.点击复制通用代码
4.取复制内容中src的值
</div>
</div>
</el-form-item>
<el-form-item label="类型:" prop="playbackTypeCode">
<el-select v-model="playbackForm.playbackTypeCode" placeholder="请选择">
<el-option
v-for="item in playbackTypeList"
:key="item.playbackTypeCode"
:label="item.typeName"
:value="item.playbackTypeCode">
</el-option>
</el-select>
</el-form-item>
<el-form-item label="内容描述:" prop="videoContent">
<el-input type="textarea" maxlength="100" show-word-limit v-model="playbackForm.videoContent"></el-input>
</el-form-item>
</el-form>
<span slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm('playbackForm')">提交</el-button>
<el-button @click="cancelCreate">取消</el-button>
</span>
</el-dialog>
</div>
</template>
<script>
import {request} from '@/api/fetch-api'
import UploadItem from '@/components/UploadItem'
let urls = {
playbackTypeListUrl: '/tianbao_edu_api/admin/playbackType/list',
playbackListUrl: '/tianbao_edu_api/admin/playback/list',
playbackSaveUrl: '/tianbao_edu_api/admin/playback/save',
playbackDelUrl: '/tianbao_edu_api/admin/playback/delete',
}
export default {
components: {UploadItem},
data() {
return {
playbackList: [],
total: 0,
loading: false,
queryForm: {
page: 1,
size: 10,
playbackTypeCode: '',
title: ''
},
dialogVisible: false,
title: '',
playbackForm: {},
playbackRules: {
title: [{required: true, message: '请输入名称', trigger: 'blur'}],
videoUrl: [{required: true, message: '请输入视频链接', trigger: 'blur'}],
playbackTypeCode: [{required: true, message: '请选择', trigger: 'blur'}],
videoContent: [{required: true, message: '请输入内容', trigger: 'blur'}]
},
playbackTypeList: []
}
},
methods: {
searchPlayback() {
this.queryForm.page = 1
this.initPlayBack()
},
initPlayBack() {
this.loading = true
request.get(urls.playbackListUrl, this.queryForm).then(data => {
this.loading = false
this.playbackList = data.content.list
this.total = data.content.total
}).catch(() => {
})
},
initPlayBackType() {
let form = {
page: 1,
size: 1000,
}
request.get(urls.playbackTypeListUrl, form).then(data => {
this.playbackTypeList = data.content.list
}).catch(() => {
})
},
playbackEdit(row) {
this.title = '编辑'
this.dialogVisible = true
this.playbackForm = JSON.parse(JSON.stringify(row))
},
playbackDelete(code) {
this.$confirm('是否永远删除, 是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
let form = {
playbackCode: code
}
request.post(urls.playbackDelUrl, form).then(data => {
this.initPlayBack()
this.$message.success("删除成功")
}).catch(() => {
})
}).catch(() => {
})
},
cancelCreate() {
this.dialogVisible = false
this.playbackForm = {}
},
playbackCreate() {
this.playbackForm = {}
this.dialogVisible = true
this.title = '创建'
},
submitForm(formName) {
this.$refs[formName].validate((valid) => {
if (valid) {
request.post(urls.playbackSaveUrl, this.playbackForm).then(response => {
this.dialogVisible = false
this.$message.success("保存成功")
this.initPlayBack()
}).catch(() => {
})
} else {
console.log('error submit!!')
return false
}
})
},
/*分页*/
handleSizeChange(val) {
console.log(`每页 ${val} 条`)
this.queryForm.size = val
this.queryForm.page = 1
this.initPlayBack()
},
handleCurrentChange(val) {
console.log(`当前页: ${val}`)
this.queryForm.page = val
this.initPlayBack()
},
},
created() {
this.initPlayBack()
this.initPlayBackType()
}
}
</script>
<style scoped>
</style>