学习园地

This commit is contained in:
yanran200730
2023-08-07 21:03:14 +08:00
parent a61a11d9f0
commit 9a5d91019a

View File

@@ -8,9 +8,9 @@
<template slot="content">
<ai-search-bar>
<template #left>
<el-radio-group v-model="search.categoryId">
<el-radio-group v-model="search.categoryId" @change="onChange">
<el-radio-button label="">全部</el-radio-button>
<el-radio-button label="学院">我的收藏</el-radio-button>
<el-radio-button label="isFavorite">我的收藏</el-radio-button>
<el-radio-button :label="item.id" :key="item.id" v-for="item in cateList">{{ item.name }}</el-radio-button>
</el-radio-group>
</template>
@@ -25,10 +25,10 @@
:size.sync="search.size"
style="margin-top: 8px;"
@getList="getList">
<el-table-column slot="options" label="操作" align="center" fixed="right" width="90px">
<el-table-column slot="options" label="操作" align="center" fixed="right" width="140px">
<template v-slot="{ row }">
<div class="table-options">
<el-button type="text">收藏</el-button>
<el-button type="text" @click="collection(row.id, row.isFavorite)">{{ row.isFavorite === '0' ? '收藏' : '已收藏' }}</el-button>
<el-button type="text" @click="toDetail(row.url)">详情</el-button>
</div>
</template>
@@ -46,13 +46,14 @@
return {
colConfigs: [
{ prop: 'title', label: '标题', align: 'left' },
{ prop: 'subPurchaseOrderSn', label: '是否收藏', align: 'center' },
{ prop: 'isFavorite', label: '是否收藏', align: 'center', format: v => v === '0' ? '否' : '是' },
],
tableData: [],
total: 0,
search: {
current: 1,
size: 10,
isFavorite: 0,
categoryId: ''
},
cateList: []
@@ -69,6 +70,33 @@
window.open(url)
},
onChange (e) {
if (e === 'isFavorite') {
this.search.isFavorite = 1
} else {
this.search.isFavorite = 0
}
this.search.current = 1
this.getList()
},
collection (id, isFavorite) {
this.$confirm(isFavorite === '1' ? '确定收藏该文章?' : '确定取消收藏?', '温馨提示', {
confirmButtonText: '确定',
callback: action => {
if (action === 'confirm') {
this.$http.post(isFavorite === '0' ? `/api/learning/addFavorite?id=${id}` : `/api/learning/delFavorite?id=${id}`).then(res => {
if (res.code === 0) {
this.$message.success(isFavorite === '1' ? '取消成功' : '收藏成功')
this.getList()
}
})
}
}
})
},
getCateList () {
this.$http.post('/api/learningCategory/page?size=50').then(res => {
if (res.code === 0) {
@@ -80,7 +108,8 @@
getList () {
this.$http.post('/api/learning/pluginPage', null, {
params: {
...this.search
...this.search,
categoryId: this.search.isFavorite === 1 ? '' : this.search.categoryId
}
}).then(res => {
if (res.code === 0) {