|
|
@@ -0,0 +1,481 @@
|
|
|
1
|
+<template>
|
|
|
2
|
+ <div class="divBox">
|
|
|
3
|
+ <el-card class="box-card">
|
|
|
4
|
+ <div slot="header" class="clearfix">
|
|
|
5
|
+ <div class="container">
|
|
|
6
|
+ <el-form size="small" label-width="100px">
|
|
|
7
|
+ <el-form-item label="时间选择:" class="width100">
|
|
|
8
|
+ <el-radio-group v-model="tableFrom.date" type="button" class="mr20" size="small" @change="selectChange(tableFrom.date)">
|
|
|
9
|
+ <el-radio-button v-for="(item,i) in fromList.fromTxt" :key="i" :label="item.val">{{ item.text }}</el-radio-button>
|
|
|
10
|
+ </el-radio-group>
|
|
|
11
|
+ <el-date-picker v-model="timeVal" value-format="yyyy/MM/dd" format="yyyy/MM/dd" size="small" type="daterange" placement="bottom-end" placeholder="自定义时间" style="width: 250px;" @change="onchangeTime" />
|
|
|
12
|
+ </el-form-item>
|
|
|
13
|
+ <el-form-item label="课程名称:" class="width100">
|
|
|
14
|
+ <el-input v-model="tableFrom.name" placeholder="请输入" class="selWidth" size="small">
|
|
|
15
|
+ </el-input>
|
|
|
16
|
+ </el-form-item>
|
|
|
17
|
+ <el-form-item label="课程分类:" class="selected-kuang">
|
|
|
18
|
+ <el-select
|
|
|
19
|
+ v-model="tableFrom.classify"
|
|
|
20
|
+ placeholder="全部"
|
|
|
21
|
+ class="filter-item"
|
|
|
22
|
+ @change="getList(1)"
|
|
|
23
|
+ >
|
|
|
24
|
+ <el-option
|
|
|
25
|
+ v-for="item in merSelect"
|
|
|
26
|
+ :key="item.id"
|
|
|
27
|
+ :label="item.name"
|
|
|
28
|
+ :value="item.id"
|
|
|
29
|
+ />
|
|
|
30
|
+ </el-select>
|
|
|
31
|
+ </el-form-item>
|
|
|
32
|
+ <el-form-item label="状态:" class="selected-kuang">
|
|
|
33
|
+ <el-select
|
|
|
34
|
+ v-model="tableFrom.state"
|
|
|
35
|
+ placeholder="全部"
|
|
|
36
|
+ class="filter-item"
|
|
|
37
|
+ @change="getList(1)"
|
|
|
38
|
+ >
|
|
|
39
|
+ <el-option label="全部" value="" />
|
|
|
40
|
+ <el-option label="上架" value="1" />
|
|
|
41
|
+ <el-option label="下架" value="0" />
|
|
|
42
|
+ </el-select>
|
|
|
43
|
+ </el-form-item>
|
|
|
44
|
+ <el-form-item label="课程类型:" class="selected-kuang">
|
|
|
45
|
+ <el-select
|
|
|
46
|
+ v-model="tableFrom.type"
|
|
|
47
|
+ placeholder="全部"
|
|
|
48
|
+ class="filter-item"
|
|
|
49
|
+ @change="getList(1)"
|
|
|
50
|
+ >
|
|
|
51
|
+ <el-option label="全部" value="" />
|
|
|
52
|
+ <el-option label="视频" value="0"></el-option>
|
|
|
53
|
+ <el-option label="图文" value="1"></el-option>
|
|
|
54
|
+
|
|
|
55
|
+ </el-select>
|
|
|
56
|
+ </el-form-item>
|
|
|
57
|
+
|
|
|
58
|
+ <div class="bottom-button">
|
|
|
59
|
+ <el-button size="small" @click="reset" style="width: 100px; margin-top: 20px; border: 1px solid; " >重置</el-button>
|
|
|
60
|
+ <!-- <el-button type="primary" size="small" @click="exportSearchResult" style="width: 100px; margin-top: 20px;">导出</el-button> -->
|
|
|
61
|
+ <el-button type="primary" size="small" @click="getList(1)" style="width: 100px; margin-top: 20px;">查询</el-button>
|
|
|
62
|
+ </div>
|
|
|
63
|
+ </el-form>
|
|
|
64
|
+ </div>
|
|
|
65
|
+ </div>
|
|
|
66
|
+
|
|
|
67
|
+ <div class="mid_button_box">
|
|
|
68
|
+ <el-button @click="onAddAction" size="small" type="primary">添加课程</el-button>
|
|
|
69
|
+ <el-button @click="upSaleAction" size="small" type="success" >批量上架</el-button>
|
|
|
70
|
+ <el-button @click="downSaleAction" size="small" type="warning">批量下架</el-button>
|
|
|
71
|
+ <el-button @click="deleteAction" size="small" type="danger">批量删除</el-button>
|
|
|
72
|
+ </div>
|
|
|
73
|
+
|
|
|
74
|
+ <el-table
|
|
|
75
|
+ v-loading="listLoading"
|
|
|
76
|
+ :data="tableData.data"
|
|
|
77
|
+ style="width: 100%"
|
|
|
78
|
+ size="small"
|
|
|
79
|
+ @selection-change="handleSelectionChange"
|
|
|
80
|
+ >
|
|
|
81
|
+
|
|
|
82
|
+ <el-table-column type="selection" width="55"> </el-table-column>
|
|
|
83
|
+
|
|
|
84
|
+ <el-table-column prop="id" label="ID" min-width="60" />
|
|
|
85
|
+ <el-table-column prop="create_time" label="添加时间" min-width="130" />
|
|
|
86
|
+ <el-table-column label="课程名称" min-width="130">
|
|
|
87
|
+ <template slot-scope="scope">
|
|
|
88
|
+ <span class="courseName">{{ scope.row.name }}</span>
|
|
|
89
|
+ </template>
|
|
|
90
|
+ </el-table-column>
|
|
|
91
|
+ <el-table-column prop="classify_name" label="课程分类" min-width="80" />
|
|
|
92
|
+ <el-table-column prop="sort" label="排序" min-width="60" />
|
|
|
93
|
+
|
|
|
94
|
+
|
|
|
95
|
+ <el-table-column prop="type" label="课程类型" min-width="80">
|
|
|
96
|
+ <template slot-scope="scope">
|
|
|
97
|
+ <span v-if="scope.row.type == 1" >图文</span>
|
|
|
98
|
+ <span v-else >视频</span>
|
|
|
99
|
+ </template>
|
|
|
100
|
+ </el-table-column>
|
|
|
101
|
+
|
|
|
102
|
+ <el-table-column prop="state" label="状态" min-width="80" >
|
|
|
103
|
+ <template slot-scope="scope">
|
|
|
104
|
+
|
|
|
105
|
+ <el-button v-if="scope.row.state != 1" type="text" size="small" class="mr10" @click="onchangeIsShow(scope.row)" >上架</el-button>
|
|
|
106
|
+ <el-button v-else type="text" size="small" class="mr10" @click="onchangeIsShow(scope.row)" >下架</el-button>
|
|
|
107
|
+ <!-- <el-button type="text" size="small" class="mr10" @click="handleDelete(scope.row.id)" >删除</el-button> -->
|
|
|
108
|
+ <!-- <el-switch
|
|
|
109
|
+ v-model="scope.row.state"
|
|
|
110
|
+ active-value="1"
|
|
|
111
|
+ inactive-value="0"
|
|
|
112
|
+ active-text="上架"
|
|
|
113
|
+ inactive-text="下架"
|
|
|
114
|
+ @change="onchangeIsShow(scope.row)"
|
|
|
115
|
+ /> -->
|
|
|
116
|
+ </template>
|
|
|
117
|
+ </el-table-column>
|
|
|
118
|
+ <el-table-column label="操作" min-width="100" fixed="right">
|
|
|
119
|
+ <template slot-scope="scope">
|
|
|
120
|
+ <el-button
|
|
|
121
|
+ type="text"
|
|
|
122
|
+ size="small"
|
|
|
123
|
+ class="mr10"
|
|
|
124
|
+ @click="onEdit(scope.row.id)"
|
|
|
125
|
+ >编辑</el-button>
|
|
|
126
|
+ <el-button type="text" size="small" class="mr10" @click="handleDelete(scope.row.id)" >删除</el-button>
|
|
|
127
|
+
|
|
|
128
|
+ <!-- </router-link> -->
|
|
|
129
|
+ </template>
|
|
|
130
|
+ </el-table-column>
|
|
|
131
|
+ </el-table>
|
|
|
132
|
+ <div class="block">
|
|
|
133
|
+
|
|
|
134
|
+ </div>
|
|
|
135
|
+ </el-card>
|
|
|
136
|
+
|
|
|
137
|
+ <div class="block">
|
|
|
138
|
+ <el-pagination :current-page="tableFrom.page" :page-size="tableFrom.limit"
|
|
|
139
|
+ :page-sizes="[20, 40, 60, 80]"
|
|
|
140
|
+ :total="tableData.total" layout="total, sizes, prev, pager, next, jumper"
|
|
|
141
|
+ @size-change="handleSizeChange"
|
|
|
142
|
+ @current-change="pageChange"/>
|
|
|
143
|
+ </div>
|
|
|
144
|
+ </div>
|
|
|
145
|
+</template>
|
|
|
146
|
+
|
|
|
147
|
+<script>
|
|
|
148
|
+import {business_school_lst, business_school_add,business_school_save,business_school_del, business_school_classify_list,business_school_save_state} from "@/api/sharephotos";
|
|
|
149
|
+import { roterPre } from "@/settings";
|
|
|
150
|
+export default {
|
|
|
151
|
+ name: "Article",
|
|
|
152
|
+ data() {
|
|
|
153
|
+ return {
|
|
|
154
|
+ roterPre: roterPre,
|
|
|
155
|
+ tableData: {
|
|
|
156
|
+ data: [],
|
|
|
157
|
+ },
|
|
|
158
|
+
|
|
|
159
|
+ listLoading: true,
|
|
|
160
|
+ tableFrom: {
|
|
|
161
|
+ type: "",
|
|
|
162
|
+ state: "",
|
|
|
163
|
+ classify: "",
|
|
|
164
|
+ name: "",
|
|
|
165
|
+ date: "",
|
|
|
166
|
+ page: 1,
|
|
|
167
|
+ limit: 20,
|
|
|
168
|
+
|
|
|
169
|
+ },
|
|
|
170
|
+ is_show: false,
|
|
|
171
|
+ fromList: {
|
|
|
172
|
+ title: "选择时间",
|
|
|
173
|
+ custom: true,
|
|
|
174
|
+ fromTxt: [{
|
|
|
175
|
+ text: "全部",
|
|
|
176
|
+ val: ""
|
|
|
177
|
+ },
|
|
|
178
|
+ {
|
|
|
179
|
+ text: "今天",
|
|
|
180
|
+ val: "today"
|
|
|
181
|
+ },
|
|
|
182
|
+ {
|
|
|
183
|
+ text: "昨天",
|
|
|
184
|
+ val: "yesterday"
|
|
|
185
|
+ },
|
|
|
186
|
+ {
|
|
|
187
|
+ text: "最近7天",
|
|
|
188
|
+ val: "lately7"
|
|
|
189
|
+ },
|
|
|
190
|
+ {
|
|
|
191
|
+ text: "最近30天",
|
|
|
192
|
+ val: "lately30"
|
|
|
193
|
+ },
|
|
|
194
|
+ {
|
|
|
195
|
+ text: "本月",
|
|
|
196
|
+ val: "month"
|
|
|
197
|
+ },
|
|
|
198
|
+ {
|
|
|
199
|
+ text: "本年",
|
|
|
200
|
+ val: "year"
|
|
|
201
|
+ },
|
|
|
202
|
+ ],
|
|
|
203
|
+ },
|
|
|
204
|
+ merSelect: [],
|
|
|
205
|
+ ids: [],
|
|
|
206
|
+ timeVal: [],
|
|
|
207
|
+ };
|
|
|
208
|
+ },
|
|
|
209
|
+
|
|
|
210
|
+ created() {
|
|
|
211
|
+
|
|
|
212
|
+ },
|
|
|
213
|
+
|
|
|
214
|
+ mounted() {
|
|
|
215
|
+ this.getList();
|
|
|
216
|
+ this.classifylist();
|
|
|
217
|
+ },
|
|
|
218
|
+ methods: {
|
|
|
219
|
+ // 分类列表
|
|
|
220
|
+ classifylist() {
|
|
|
221
|
+ business_school_classify_list()
|
|
|
222
|
+ .then((res) => {
|
|
|
223
|
+ if (res.status == 200) {
|
|
|
224
|
+ this.merSelect = res.data;
|
|
|
225
|
+ } else {
|
|
|
226
|
+ this.$message.error(res.message);
|
|
|
227
|
+ }
|
|
|
228
|
+ })
|
|
|
229
|
+ .catch((res) => {
|
|
|
230
|
+ this.$message.error(res.message);
|
|
|
231
|
+ });
|
|
|
232
|
+ },
|
|
|
233
|
+
|
|
|
234
|
+ handleSelectionChange(val) {
|
|
|
235
|
+ this.selectionList = val;
|
|
|
236
|
+ const data = [];
|
|
|
237
|
+ this.selectionList.map((item) => {
|
|
|
238
|
+ data.push(item.id);
|
|
|
239
|
+ });
|
|
|
240
|
+ this.ids = data.join(",");
|
|
|
241
|
+ },
|
|
|
242
|
+
|
|
|
243
|
+ // 添加
|
|
|
244
|
+ onAddAction() {
|
|
|
245
|
+ this.$router.push({
|
|
|
246
|
+ path: roterPre + "/setting/addCourse/",
|
|
|
247
|
+ });
|
|
|
248
|
+ },
|
|
|
249
|
+
|
|
|
250
|
+ // 编辑
|
|
|
251
|
+ onEdit(id) {
|
|
|
252
|
+
|
|
|
253
|
+ console.log('id')
|
|
|
254
|
+ console.log(id)
|
|
|
255
|
+ this.$router.push({
|
|
|
256
|
+ path: roterPre + "/setting/addCourse/",
|
|
|
257
|
+ query: {id: id}
|
|
|
258
|
+ });
|
|
|
259
|
+ },
|
|
|
260
|
+
|
|
|
261
|
+ // 重置
|
|
|
262
|
+ reset() {
|
|
|
263
|
+ this.tableFrom = {
|
|
|
264
|
+ type: "",
|
|
|
265
|
+ state: "",
|
|
|
266
|
+ classify: "",
|
|
|
267
|
+ name: "",
|
|
|
268
|
+ date: "",
|
|
|
269
|
+ page: 1,
|
|
|
270
|
+ limit: 20,
|
|
|
271
|
+ }
|
|
|
272
|
+
|
|
|
273
|
+ this.getList(1)
|
|
|
274
|
+ },
|
|
|
275
|
+
|
|
|
276
|
+ // 选择时间
|
|
|
277
|
+ selectChange(tab) {
|
|
|
278
|
+ this.timeVal = [];
|
|
|
279
|
+ this.tableFrom.date = tab;
|
|
|
280
|
+ this.getList(1);
|
|
|
281
|
+ },
|
|
|
282
|
+ // 具体日期
|
|
|
283
|
+ onchangeTime(e) {
|
|
|
284
|
+ this.timeVal = e;
|
|
|
285
|
+ this.tableFrom.date = e ? this.timeVal.join("-") : "";
|
|
|
286
|
+ this.getList(1);
|
|
|
287
|
+ },
|
|
|
288
|
+
|
|
|
289
|
+ // 列表
|
|
|
290
|
+ getList(num) {
|
|
|
291
|
+ this.listLoading = true;
|
|
|
292
|
+
|
|
|
293
|
+ this.tableFrom.page = num ? num : this.tableFrom.page;
|
|
|
294
|
+
|
|
|
295
|
+ business_school_lst(this.tableFrom)
|
|
|
296
|
+ .then((res) => {
|
|
|
297
|
+
|
|
|
298
|
+ this.tableData.data = res.data.list
|
|
|
299
|
+ this.tableData.total = res.data.count
|
|
|
300
|
+ this.listLoading = false;
|
|
|
301
|
+ })
|
|
|
302
|
+ .catch((res) => {
|
|
|
303
|
+ this.listLoading = false;
|
|
|
304
|
+ this.$message.error(res.message);
|
|
|
305
|
+ });
|
|
|
306
|
+ },
|
|
|
307
|
+
|
|
|
308
|
+ // 单个上架下架
|
|
|
309
|
+ onchangeIsShow(row) {
|
|
|
310
|
+ let courseStatus = {
|
|
|
311
|
+ id: row.id,
|
|
|
312
|
+ state: row.state
|
|
|
313
|
+ }
|
|
|
314
|
+ console.log(courseStatus)
|
|
|
315
|
+ business_school_save_state(courseStatus)
|
|
|
316
|
+ .then(({ message }) => {
|
|
|
317
|
+ this.$message.success(message);
|
|
|
318
|
+ this.getList()
|
|
|
319
|
+ })
|
|
|
320
|
+ .catch(({ message }) => {
|
|
|
321
|
+ this.$message.error(message);
|
|
|
322
|
+ });
|
|
|
323
|
+ },
|
|
|
324
|
+
|
|
|
325
|
+ // 批量上架
|
|
|
326
|
+ upSaleAction() {
|
|
|
327
|
+
|
|
|
328
|
+ let courseStatus = {
|
|
|
329
|
+ id: this.ids,
|
|
|
330
|
+ state: '1'
|
|
|
331
|
+ }
|
|
|
332
|
+
|
|
|
333
|
+ business_school_save_state(courseStatus)
|
|
|
334
|
+ .then(({ message }) => {
|
|
|
335
|
+ this.$message.success(message);
|
|
|
336
|
+ this.getList()
|
|
|
337
|
+ })
|
|
|
338
|
+ .catch(({ message }) => {
|
|
|
339
|
+ this.$message.error(message);
|
|
|
340
|
+ });
|
|
|
341
|
+ },
|
|
|
342
|
+
|
|
|
343
|
+ // 批量下架
|
|
|
344
|
+ downSaleAction() {
|
|
|
345
|
+
|
|
|
346
|
+ let courseStatus = {
|
|
|
347
|
+ id: this.ids,
|
|
|
348
|
+ state: '0'
|
|
|
349
|
+ }
|
|
|
350
|
+
|
|
|
351
|
+ business_school_save_state(courseStatus)
|
|
|
352
|
+ .then(({ message }) => {
|
|
|
353
|
+ this.$message.success(message);
|
|
|
354
|
+ this.getList()
|
|
|
355
|
+ })
|
|
|
356
|
+ .catch(({ message }) => {
|
|
|
357
|
+ this.$message.error(message);
|
|
|
358
|
+ });
|
|
|
359
|
+ },
|
|
|
360
|
+
|
|
|
361
|
+ // 删除
|
|
|
362
|
+ handleDelete(id) {
|
|
|
363
|
+ this.$modalSure().then(() => {
|
|
|
364
|
+ let courseStatus = {
|
|
|
365
|
+ id: id,
|
|
|
366
|
+ }
|
|
|
367
|
+ business_school_del(courseStatus)
|
|
|
368
|
+ .then(({ message }) => {
|
|
|
369
|
+ this.$message.success(message);
|
|
|
370
|
+ this.getList()
|
|
|
371
|
+ })
|
|
|
372
|
+ .catch(({ message }) => {
|
|
|
373
|
+ this.$message.error(message);
|
|
|
374
|
+ });
|
|
|
375
|
+ });
|
|
|
376
|
+
|
|
|
377
|
+
|
|
|
378
|
+ },
|
|
|
379
|
+
|
|
|
380
|
+ // 批量删除
|
|
|
381
|
+ deleteAction() {
|
|
|
382
|
+ this.$modalSure().then(() => {
|
|
|
383
|
+ let courseStatus = {
|
|
|
384
|
+ id: this.ids,
|
|
|
385
|
+ }
|
|
|
386
|
+ business_school_del(courseStatus)
|
|
|
387
|
+ .then(({ message }) => {
|
|
|
388
|
+ this.$message.success(message);
|
|
|
389
|
+ this.getList()
|
|
|
390
|
+ })
|
|
|
391
|
+ .catch(({ message }) => {
|
|
|
392
|
+ this.$message.error(message);
|
|
|
393
|
+ });
|
|
|
394
|
+ });
|
|
|
395
|
+
|
|
|
396
|
+ },
|
|
|
397
|
+
|
|
|
398
|
+
|
|
|
399
|
+
|
|
|
400
|
+ pageChange(page) {
|
|
|
401
|
+ this.tableFrom.page = page;
|
|
|
402
|
+ this.getList('');
|
|
|
403
|
+ },
|
|
|
404
|
+ handleSizeChange(val) {
|
|
|
405
|
+ this.tableFrom.limit = val;
|
|
|
406
|
+ this.getList('');
|
|
|
407
|
+ },
|
|
|
408
|
+
|
|
|
409
|
+ getDateDiff(dateTime) {
|
|
|
410
|
+ var str = dateTime;
|
|
|
411
|
+ let result = "";
|
|
|
412
|
+ //将字符串转换成时间格式
|
|
|
413
|
+ var timePublish = new Date(str);
|
|
|
414
|
+ var timeNow = new Date();
|
|
|
415
|
+ var minute = 1000 * 60;
|
|
|
416
|
+ var hour = minute * 60;
|
|
|
417
|
+ var day = hour * 24;
|
|
|
418
|
+ var month = day * 30;
|
|
|
419
|
+ var year = month * 12;
|
|
|
420
|
+ var diffValue = timeNow - timePublish;
|
|
|
421
|
+ var diffMonth = diffValue / month;
|
|
|
422
|
+ var diffWeek = diffValue / (7 * day);
|
|
|
423
|
+ var diffDay = diffValue / day;
|
|
|
424
|
+ var diffHour = diffValue / hour;
|
|
|
425
|
+ var diffMinute = diffValue / minute;
|
|
|
426
|
+ var diffYear = diffValue / year;
|
|
|
427
|
+ if (diffValue < 0) {
|
|
|
428
|
+ result = "刚刚发表";
|
|
|
429
|
+ } else if (diffYear > 1) {
|
|
|
430
|
+ result = parseInt(diffYear) + "年前";
|
|
|
431
|
+ } else if (diffMonth > 1) {
|
|
|
432
|
+ result = parseInt(diffMonth) + "月前";
|
|
|
433
|
+ } else if (diffWeek > 1) {
|
|
|
434
|
+ result = parseInt(diffWeek) + "周前";
|
|
|
435
|
+ } else if (diffDay > 1) {
|
|
|
436
|
+ result = parseInt(diffDay) + "天前";
|
|
|
437
|
+ } else if (diffHour > 1) {
|
|
|
438
|
+ result = parseInt(diffHour) + "小时前";
|
|
|
439
|
+ } else if (diffMinute > 1) {
|
|
|
440
|
+ result = parseInt(diffMinute) + "分钟前";
|
|
|
441
|
+ } else {
|
|
|
442
|
+ result = "刚刚发表";
|
|
|
443
|
+ }
|
|
|
444
|
+ return result;
|
|
|
445
|
+ },
|
|
|
446
|
+ },
|
|
|
447
|
+};
|
|
|
448
|
+</script>
|
|
|
449
|
+
|
|
|
450
|
+<style scoped lang="scss">
|
|
|
451
|
+.selWidth {
|
|
|
452
|
+ width: 300px;
|
|
|
453
|
+}
|
|
|
454
|
+.description {
|
|
|
455
|
+ width: 80%;
|
|
|
456
|
+ margin: 0 auto;
|
|
|
457
|
+ height: 50px;
|
|
|
458
|
+ line-height: 50px;
|
|
|
459
|
+ display: flex;
|
|
|
460
|
+ justify-content: space-between;
|
|
|
461
|
+ align-items: center;
|
|
|
462
|
+ text-align: center;
|
|
|
463
|
+}
|
|
|
464
|
+
|
|
|
465
|
+.bottom-button {
|
|
|
466
|
+ margin-top: 30px;
|
|
|
467
|
+ margin-left: 300px;
|
|
|
468
|
+ width: 250px;
|
|
|
469
|
+ display: flex;
|
|
|
470
|
+ justify-content: space-between;
|
|
|
471
|
+}
|
|
|
472
|
+
|
|
|
473
|
+.courseName {
|
|
|
474
|
+ overflow:hidden;
|
|
|
475
|
+ text-overflow: ellipsis;
|
|
|
476
|
+ -webkit-line-clamp: 2;
|
|
|
477
|
+ display: -webkit-box;
|
|
|
478
|
+ -webkit-box-orient: vertical;
|
|
|
479
|
+}
|
|
|
480
|
+
|
|
|
481
|
+</style>
|