提交 88ad610c authored 作者: 王鹏飞's avatar 王鹏飞

update

上级 b0bd4238
...@@ -40,6 +40,21 @@ export function publishAd(id, data) { ...@@ -40,6 +40,21 @@ export function publishAd(id, data) {
export function auditAd(id, data) { export function auditAd(id, data) {
return httpRequest.post(`/api/cms/admin/v1/advertisement/${id}/audit`, data) return httpRequest.post(`/api/cms/admin/v1/advertisement/${id}/audit`, data)
} }
/**
* 置顶广告
* @param {string} id
* @param {number} data.is_top 是否置顶:0否 1是
*/
export function topAd(id, data) {
return httpRequest.post(`/api/cms/admin/v1/advertisement/${id}/top`, data)
}
/**
* 批量删除广告
* @param {string} data.ids
*/
export function batchDeleteAd(data) {
return httpRequest.post('/api/cms/admin/v1/advertisement/batch-delete', data)
}
/* ------------------------------------文章------------------------------------ */ /* ------------------------------------文章------------------------------------ */
/** /**
...@@ -57,6 +72,14 @@ export function getArticleList(params) { ...@@ -57,6 +72,14 @@ export function getArticleList(params) {
export function createArticle(data) { export function createArticle(data) {
return httpRequest.post('/api/cms/admin/v1/article/create', data) return httpRequest.post('/api/cms/admin/v1/article/create', data)
} }
/**
* 更新文章
* @param {string} id
* @param {number} data
*/
export function updateArticle(id, data) {
return httpRequest.put(`/api/cms/admin/v1/article/${id}/update`, data)
}
/** /**
* 发布文章 * 发布文章
* @param {string} id * @param {string} id
...@@ -65,6 +88,29 @@ export function createArticle(data) { ...@@ -65,6 +88,29 @@ export function createArticle(data) {
export function publishArticle(id, data) { export function publishArticle(id, data) {
return httpRequest.post(`/api/cms/admin/v1/article/${id}/publish`, data) return httpRequest.post(`/api/cms/admin/v1/article/${id}/publish`, data)
} }
/**
* 置顶文章
* @param {string} id
* @param {number} data.is_top 是否置顶:0否 1是
*/
export function topArticle(id, data) {
return httpRequest.post(`/api/cms/admin/v1/article/${id}/top`, data)
}
/**
* 推荐文章
* @param {string} id
* @param {number} data.is_recommend 是否推荐:0否 1是
*/
export function recommendArticle(id, data) {
return httpRequest.post(`/api/cms/admin/v1/article/${id}/recommend`, data)
}
/**
* 批量删除文章
* @param {string} data.ids
*/
export function batchDeleteArticle(data) {
return httpRequest.post('/api/cms/admin/v1/article/batch-delete', data)
}
/* ------------------------------------图文------------------------------------ */ /* ------------------------------------图文------------------------------------ */
/** /**
...@@ -76,6 +122,14 @@ export function publishArticle(id, data) { ...@@ -76,6 +122,14 @@ export function publishArticle(id, data) {
export function getImgTextList(params) { export function getImgTextList(params) {
return httpRequest.get('/api/cms/admin/v1/img-texts', { params }) return httpRequest.get('/api/cms/admin/v1/img-texts', { params })
} }
/**
* 更新图文
* @param {string} id
* @param {number} data
*/
export function updateImgText(id, data) {
return httpRequest.put(`/api/cms/admin/v1/img-text/${id}/update`, data)
}
/** /**
* 发布图文 * 发布图文
* @param {string} id * @param {string} id
...@@ -92,3 +146,18 @@ export function publishImgText(id, data) { ...@@ -92,3 +146,18 @@ export function publishImgText(id, data) {
export function getProjectContentTypeList(type, id) { export function getProjectContentTypeList(type, id) {
return httpRequest.get(`/api/cms/admin/v1/type/${type}/project/${id}`) return httpRequest.get(`/api/cms/admin/v1/type/${type}/project/${id}`)
} }
/**
* 置顶图文
* @param {string} id
* @param {number} data.is_top 是否置顶:0否 1是
*/
export function topImgText(id, data) {
return httpRequest.post(`/api/cms/admin/v1/img-text/${id}/top`, data)
}
/**
* 批量删除图文
* @param {string} data.ids
*/
export function batchDeleteImgText(data) {
return httpRequest.post('/api/cms/admin/v1/img-text/batch-delete', data)
}
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
<div class="ads page_container"> <div class="ads page_container">
<table-list v-bind="tableOptions" ref="tableList" @selection-change="handleSelectionChange"> <table-list v-bind="tableOptions" ref="tableList" @selection-change="handleSelectionChange">
<template #header-aside> <template #header-aside>
<el-button type="primary" size="mini" @click="handleCreate">新建广告</el-button> <el-button type="primary" size="mini" @click="handleCreate" v-if="hasCreate">新建广告</el-button>
</template> </template>
<el-tabs v-model="activeName" type="card" @tab-click="handleTabClick"> <el-tabs v-model="activeName" type="card" @tab-click="handleTabClick">
<el-tab-pane label="全部" name="0"></el-tab-pane> <el-tab-pane label="全部" name="0"></el-tab-pane>
...@@ -32,11 +32,13 @@ ...@@ -32,11 +32,13 @@
</template> </template>
<!-- 置顶状态 --> <!-- 置顶状态 -->
<template v-slot:top-status="{ row }"> <template v-slot:top-status="{ row }">
<el-switch :active-value="1" :inactive-value="0" v-model="row.is_top"></el-switch> <el-switch :active-value="1" :inactive-value="0" v-model="row.is_top" @change="handleTop(row)"></el-switch>
</template> </template>
<template #footer> <template #footer>
<el-button size="mini" :disabled="!multipleSelection.length" @click="handleRemove">删除</el-button> <el-button size="mini" :disabled="!multipleSelection.length" @click="handleRemove" v-if="hasDelete"
>删除</el-button
>
</template> </template>
</table-list> </table-list>
<el-drawer :visible.sync="drawerVisible" size="1100px" :destroy-on-close="true" ref="ad_drawer"> <el-drawer :visible.sync="drawerVisible" size="1100px" :destroy-on-close="true" ref="ad_drawer">
...@@ -64,7 +66,14 @@ ...@@ -64,7 +66,14 @@
</el-form-item> </el-form-item>
</template> </template>
</drawer-form> </drawer-form>
<el-dialog title="审核广告" :visible.sync="dialogVisible" width="460px" append-to-body :destroy-on-close="true" ref="auditDialog"> <el-dialog
title="审核广告"
:visible.sync="dialogVisible"
width="460px"
append-to-body
:destroy-on-close="true"
ref="auditDialog"
>
<audit-form @dialogClose="dialogVisible = false" @auditSubmit="handleAuditSubmit" /> <audit-form @dialogClose="dialogVisible = false" @auditSubmit="handleAuditSubmit" />
</el-dialog> </el-dialog>
</el-drawer> </el-drawer>
...@@ -74,22 +83,13 @@ ...@@ -74,22 +83,13 @@
import TableList from '@/components/TableList' import TableList from '@/components/TableList'
import DrawerForm from '../components/DrawerForm.vue' import DrawerForm from '../components/DrawerForm.vue'
import AuditForm from '../components/AuditForm.vue' import AuditForm from '../components/AuditForm.vue'
import { getAdList, createAd, publishAd, updateAd, auditAd } from '@/api/contentManage' import { getAdList, createAd, updateAd, publishAd, topAd, batchDeleteAd, auditAd } from '@/api/contentManage'
export default { export default {
components: { TableList, DrawerForm, AuditForm }, components: { TableList, DrawerForm, AuditForm },
data() { data() {
return { return {
activeName: '', activeName: '',
drawerVisible: false, drawerVisible: false,
projectList: [
{ project_id: '111', project_name: '官网' },
{ project_id: '222', project_name: 'kellet' }
],
typeList: [
{ id: '111', name: 'banner广告' },
{ id: '222', name: '侧边栏广告' },
{ id: '333', name: '正文区广告' }
],
drawFormOptions: { drawFormOptions: {
type: '', type: '',
pageType: 2, pageType: 2,
...@@ -101,6 +101,21 @@ export default { ...@@ -101,6 +101,21 @@ export default {
} }
}, },
computed: { computed: {
// 权限列表
permissions() {
return this.$store.state.user.permissions
},
// 创建权限
hasCreate() {
return this.permissions.includes('content-function-advert-create')
},
// 删除权限
hasDelete() {
return this.permissions.includes('content-function-advert-delete')
},
projectList() {
return this.$store.state.user.projects
},
drawTitle() { drawTitle() {
if (this.drawFormOptions.type === 'create') return '新建广告' if (this.drawFormOptions.type === 'create') return '新建广告'
else if (this.drawFormOptions.type === 'edit') return '编辑广告' else if (this.drawFormOptions.type === 'edit') return '编辑广告'
...@@ -119,8 +134,8 @@ export default { ...@@ -119,8 +134,8 @@ export default {
placeholder: '项目', placeholder: '项目',
prop: 'project_id', prop: 'project_id',
options: this.projectList, options: this.projectList,
labelKey: 'project_name', labelKey: 'name',
valueKey: 'project_id' valueKey: 'id'
}, },
{ type: 'input', placeholder: 'ID', prop: 'id_title' }, { type: 'input', placeholder: 'ID', prop: 'id_title' },
{ {
...@@ -165,7 +180,23 @@ export default { ...@@ -165,7 +180,23 @@ export default {
// 发布 // 发布
handlePublish(row) { handlePublish(row) {
publishAd(row.id, { is_publish: row.is_publish }).then(res => { publishAd(row.id, { is_publish: row.is_publish }).then(res => {
this.$message.success('更改状态成功') if (res.code === 0) {
this.$message.success('更改状态成功')
} else {
row.is_publish = row.is_publish ? 0 : 1
this.$message.error(res.message)
}
})
},
// 置顶
handleTop(row) {
topAd(row.id, { is_top: row.is_top }).then(res => {
if (res.code === 0) {
this.$message.success('更改状态成功')
} else {
row.is_top = row.is_top ? 0 : 1
this.$message.error(res.message)
}
}) })
}, },
// 选择 // 选择
...@@ -173,7 +204,17 @@ export default { ...@@ -173,7 +204,17 @@ export default {
this.multipleSelection = value this.multipleSelection = value
}, },
// 删除 // 删除
handleRemove() {}, handleRemove() {
const ids = this.multipleSelection.map(item => item.id)
batchDeleteAd({ ids }).then(res => {
if (res.code === 0) {
this.$message.success('删除成功')
this.$refs.tableList.refetch(true)
} else {
this.$message.error(res.message)
}
})
},
handleCreate() { handleCreate() {
this.drawFormOptions.type = 'create' this.drawFormOptions.type = 'create'
this.drawerVisible = true this.drawerVisible = true
......
<template> <template>
<div class="article page_container"> <div class="article page_container">
<table-list v-bind="tableOptions" ref="tableList"> <table-list v-bind="tableOptions" ref="tableList" @selection-change="handleSelectionChange">
<template #header-aside> <template #header-aside>
<el-button type="primary" size="mini" @click="handleCreate">新建文章</el-button> <el-button type="primary" size="mini" @click="handleCreate" v-if="hasCreate">新建文章</el-button>
</template> </template>
<el-tabs v-model="activeName" type="card" @tab-click="handleTabClick"> <el-tabs v-model="activeName" type="card" @tab-click="handleTabClick">
<el-tab-pane label="全部" name="0"></el-tab-pane> <el-tab-pane label="全部" name="0"></el-tab-pane>
...@@ -32,11 +32,22 @@ ...@@ -32,11 +32,22 @@
</template> </template>
<!-- 置顶状态 --> <!-- 置顶状态 -->
<template v-slot:top-status="{ row }"> <template v-slot:top-status="{ row }">
<el-switch :active-value="1" :inactive-value="0" v-model="row.is_top"></el-switch> <el-switch :active-value="1" :inactive-value="0" v-model="row.is_top" @change="handleTop(row)"></el-switch>
</template> </template>
<!-- 推荐状态 --> <!-- 推荐状态 -->
<template v-slot:recommend-status="{ row }"> <template v-slot:recommend-status="{ row }">
<el-switch :active-value="1" :inactive-value="0" v-model="row.is_recommend"></el-switch> <el-switch
:active-value="1"
:inactive-value="0"
v-model="row.is_recommend"
@change="handleRecommend(row)"
></el-switch>
</template>
<template #footer>
<el-button size="mini" :disabled="!multipleSelection.length" @click="handleRemove" v-if="hasDelete"
>删除</el-button
>
</template> </template>
</table-list> </table-list>
<el-drawer :visible.sync="drawerVisible" size="1100px" :destroy-on-close="true"> <el-drawer :visible.sync="drawerVisible" size="1100px" :destroy-on-close="true">
...@@ -69,30 +80,37 @@ ...@@ -69,30 +80,37 @@
<script> <script>
import DrawerForm from '../components/DrawerForm.vue' import DrawerForm from '../components/DrawerForm.vue'
import TableList from '@/components/TableList' import TableList from '@/components/TableList'
import { getArticleList, publishArticle } from '@/api/contentManage' import { getArticleList, publishArticle, topArticle, recommendArticle, batchDeleteArticle } from '@/api/contentManage'
export default { export default {
data() { data() {
return { return {
activeName: '0', activeName: '',
drawerVisible: false, drawerVisible: false,
projectList: [
{ project_id: '111', project_name: '官网' },
{ project_id: '222', project_name: 'kellet' }
],
typeList: [
{ id: '111', name: 'banner广告' },
{ id: '222', name: '侧边栏广告' },
{ id: '333', name: '正文区广告' }
],
drawFormOptions: { drawFormOptions: {
type: '', type: '',
pageType: 1 pageType: 1
}, },
drawItem: '', drawItem: '',
dialogVisible: false dialogVisible: false,
multipleSelection: []
} }
}, },
computed: { computed: {
// 权限列表
permissions() {
return this.$store.state.user.permissions
},
// 创建权限
hasCreate() {
return this.permissions.includes('content-function-acticle-create')
},
// 删除权限
hasDelete() {
return this.permissions.includes('content-function-acticle-delete')
},
projectList() {
return this.$store.state.user.projects
},
drawTitle() { drawTitle() {
if (this.drawFormOptions.type === 'create') return '新建文章' if (this.drawFormOptions.type === 'create') return '新建文章'
else if (this.drawFormOptions.type === 'edit') return '编辑文章' else if (this.drawFormOptions.type === 'edit') return '编辑文章'
...@@ -111,8 +129,8 @@ export default { ...@@ -111,8 +129,8 @@ export default {
placeholder: '项目', placeholder: '项目',
prop: 'project_id', prop: 'project_id',
options: this.projectList, options: this.projectList,
labelKey: 'project_name', labelKey: 'name',
valueKey: 'project_id' valueKey: 'id'
}, },
{ type: 'input', placeholder: 'ID', prop: 'id_title' }, { type: 'input', placeholder: 'ID', prop: 'id_title' },
{ {
...@@ -125,6 +143,7 @@ export default { ...@@ -125,6 +143,7 @@ export default {
} }
], ],
columns: [ columns: [
{ type: 'selection' },
{ prop: 'image_url', label: '图片', slots: 'image' }, { prop: 'image_url', label: '图片', slots: 'image' },
{ prop: 'id', label: '文章ID', slots: 'table-id' }, { prop: 'id', label: '文章ID', slots: 'table-id' },
{ prop: 'title', label: '标题' }, { prop: 'title', label: '标题' },
...@@ -158,7 +177,49 @@ export default { ...@@ -158,7 +177,49 @@ export default {
// 发布 // 发布
handlePublish(row) { handlePublish(row) {
publishArticle(row.id, { is_publish: row.is_publish }).then(res => { publishArticle(row.id, { is_publish: row.is_publish }).then(res => {
this.$message.success('更改状态成功') if (res.code === 0) {
this.$message.success('更改状态成功')
} else {
row.is_publish = row.is_publish ? 0 : 1
this.$message.error(res.message)
}
})
},
// 置顶
handleTop(row) {
topArticle(row.id, { is_top: row.is_top }).then(res => {
if (res.code === 0) {
this.$message.success('更改状态成功')
} else {
row.is_top = row.is_top ? 0 : 1
this.$message.error(res.message)
}
})
},
// 推荐
handleRecommend(row) {
recommendArticle(row.id, { is_recommend: row.is_recommend }).then(res => {
if (res.code === 0) {
this.$message.success('更改状态成功')
} else {
row.is_recommend = row.is_recommend ? 0 : 1
this.$message.error(res.message)
}
})
},
// 选择
handleSelectionChange(value) {
this.multipleSelection = value
}, // 删除
handleRemove() {
const ids = this.multipleSelection.map(item => item.id)
batchDeleteArticle({ ids }).then(res => {
if (res.code === 0) {
this.$message.success('删除成功')
this.$refs.tableList.refetch(true)
} else {
this.$message.error(res.message)
}
}) })
}, },
handleCreate() { handleCreate() {
......
<template> <template>
<div class="image-text page_container"> <div class="image-text page_container">
<table-list v-bind="tableOptions" ref="tableList"> <table-list v-bind="tableOptions" ref="tableList" @selection-change="handleSelectionChange">
<template #header-aside> <template #header-aside>
<el-button type="primary" size="mini" @click="handleCreate">新建文章</el-button> <el-button type="primary" size="mini" @click="handleCreate" v-if="hasCreate">新建文章</el-button>
</template> </template>
<el-tabs v-model="activeName" type="card" @tab-click="handleTabClick"> <el-tabs v-model="activeName" type="card" @tab-click="handleTabClick">
<el-tab-pane label="全部" name="0"></el-tab-pane> <el-tab-pane label="全部" name="0"></el-tab-pane>
...@@ -30,9 +30,11 @@ ...@@ -30,9 +30,11 @@
@change="handlePublish(row)" @change="handlePublish(row)"
></el-switch> ></el-switch>
</template> </template>
<!-- 置顶状态 -->
<template v-slot:top-status="{ row }"> <template #footer>
<el-switch :active-value="1" :inactive-value="0" v-model="row.is_top"></el-switch> <el-button size="mini" :disabled="!multipleSelection.length" @click="handleRemove" v-if="hasDelete"
>删除</el-button
>
</template> </template>
</table-list> </table-list>
<el-drawer :visible.sync="drawerVisible" size="1100px" :destroy-on-close="true"> <el-drawer :visible.sync="drawerVisible" size="1100px" :destroy-on-close="true">
...@@ -65,30 +67,37 @@ ...@@ -65,30 +67,37 @@
<script> <script>
import DrawerForm from '../components/DrawerForm.vue' import DrawerForm from '../components/DrawerForm.vue'
import TableList from '@/components/TableList' import TableList from '@/components/TableList'
import { getImgTextList, publishImgText } from '@/api/contentManage' import { getImgTextList, publishImgText, batchDeleteImgText } from '@/api/contentManage'
export default { export default {
data() { data() {
return { return {
activeName: '0', activeName: '',
drawerVisible: false, drawerVisible: false,
projectList: [
{ project_id: '111', project_name: '官网' },
{ project_id: '222', project_name: 'kellet' }
],
typeList: [
{ id: '111', name: 'banner广告' },
{ id: '222', name: '侧边栏广告' },
{ id: '333', name: '正文区广告' }
],
drawFormOptions: { drawFormOptions: {
type: '', type: '',
pageType: 3 pageType: 3
}, },
drawItem: '', drawItem: '',
dialogVisible: false dialogVisible: false,
multipleSelection: []
} }
}, },
computed: { computed: {
// 权限列表
permissions() {
return this.$store.state.user.permissions
},
// 创建权限
hasCreate() {
return this.permissions.includes('content-function-imgtext-create')
},
// 删除权限
hasDelete() {
return this.permissions.includes('content-function-imgtext-delete')
},
projectList() {
return this.$store.state.user.projects
},
drawTitle() { drawTitle() {
const type = this.drawFormOptions.type const type = this.drawFormOptions.type
if (type === 'create') return '新建图文' if (type === 'create') return '新建图文'
...@@ -108,8 +117,8 @@ export default { ...@@ -108,8 +117,8 @@ export default {
placeholder: '项目', placeholder: '项目',
prop: 'project_id', prop: 'project_id',
options: this.projectList, options: this.projectList,
labelKey: 'project_name', labelKey: 'name',
valueKey: 'project_id' valueKey: 'id'
}, },
{ type: 'input', placeholder: 'ID', prop: 'id_title' }, { type: 'input', placeholder: 'ID', prop: 'id_title' },
{ {
...@@ -122,8 +131,9 @@ export default { ...@@ -122,8 +131,9 @@ export default {
} }
], ],
columns: [ columns: [
{ type: 'selection' },
{ prop: 'image_url', label: '图片', slots: 'image' }, { prop: 'image_url', label: '图片', slots: 'image' },
{ prop: 'id', label: '广告ID', slots: 'table-id' }, { prop: 'id', label: '图文ID', slots: 'table-id' },
{ prop: 'title', label: '标题' }, { prop: 'title', label: '标题' },
{ prop: 'start_time', label: '开始时间' }, { prop: 'start_time', label: '开始时间' },
{ prop: 'end_time', label: '结束时间' }, { prop: 'end_time', label: '结束时间' },
...@@ -133,7 +143,6 @@ export default { ...@@ -133,7 +143,6 @@ export default {
{ prop: 'sso_user.real_name', label: '创建人' }, { prop: 'sso_user.real_name', label: '创建人' },
{ prop: 'audit_status', label: '审核状态', slots: 'review-status' }, { prop: 'audit_status', label: '审核状态', slots: 'review-status' },
{ prop: 'is_show', label: '发布状态', slots: 'publish-status' }, { prop: 'is_show', label: '发布状态', slots: 'publish-status' },
{ prop: 'is_top', label: '置顶状态/权重', slots: 'top-status' },
{ prop: 'created_at', label: '创建时间' } { prop: 'created_at', label: '创建时间' }
] ]
} }
...@@ -154,7 +163,28 @@ export default { ...@@ -154,7 +163,28 @@ export default {
// 发布 // 发布
handlePublish(row) { handlePublish(row) {
publishImgText(row.id, { is_publish: row.is_publish }).then(res => { publishImgText(row.id, { is_publish: row.is_publish }).then(res => {
this.$message.success('更改状态成功') if (res.code === 0) {
this.$message.success('更改状态成功')
} else {
row.is_publish = row.is_publish ? 0 : 1
this.$message.error(res.message)
}
})
},
// 选择
handleSelectionChange(value) {
this.multipleSelection = value
},
// 删除
handleRemove() {
const ids = this.multipleSelection.map(item => item.id)
batchDeleteImgText({ ids }).then(res => {
if (res.code === 0) {
this.$message.success('删除成功')
this.$refs.tableList.refetch(true)
} else {
this.$message.error(res.message)
}
}) })
}, },
handleCreate() { handleCreate() {
......
...@@ -23,6 +23,9 @@ const user = { ...@@ -23,6 +23,9 @@ const user = {
setPermissions(state, permissions) { setPermissions(state, permissions) {
state.permissions = permissions state.permissions = permissions
}, },
setHasRolesPermissions(state, hasRolesPermissions) {
state.hasRolesPermissions = hasRolesPermissions
},
setProjects(state, projects) { setProjects(state, projects) {
state.projects = projects state.projects = projects
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论