提交 f9bcc5c8 authored 作者: pengxiaohui's avatar pengxiaohui

内容管理列表增加修改权限

上级 342c8b96
...@@ -44,6 +44,7 @@ export function auditAd(id, data) { ...@@ -44,6 +44,7 @@ export function auditAd(id, data) {
* 置顶广告 * 置顶广告
* @param {string} id * @param {string} id
* @param {number} data.is_top 是否置顶:0否 1是 * @param {number} data.is_top 是否置顶:0否 1是
* @param {number} data.weight 权重:0-10
*/ */
export function topAd(id, data) { export function topAd(id, data) {
return httpRequest.post(`/api/cms/admin/v1/advertisement/${id}/top`, data) return httpRequest.post(`/api/cms/admin/v1/advertisement/${id}/top`, data)
......
...@@ -36,7 +36,7 @@ ...@@ -36,7 +36,7 @@
</div> </div>
<slot></slot> <slot></slot>
<div class="table-list-bd"> <div class="table-list-bd">
<el-table :data="dataList" size="mini" v-loading="loading" v-bind="$attrs" v-on="$listeners" style="height: 100%"> <el-table :data="dataList" size="mini" v-loading="loading" v-bind="$attrs" v-on="$listeners" height="100%">
<template v-for="item in columns"> <template v-for="item in columns">
<el-table-column v-bind="item" :key="item.prop" v-if="visible(item)"> <el-table-column v-bind="item" :key="item.prop" v-if="visible(item)">
<template v-slot:default="scope" v-if="item.slots || item.computed"> <template v-slot:default="scope" v-if="item.slots || item.computed">
......
...@@ -28,16 +28,18 @@ ...@@ -28,16 +28,18 @@
:inactive-value="0" :inactive-value="0"
v-model="row.is_publish" v-model="row.is_publish"
@change="handlePublish(row)" @change="handlePublish(row)"
:disabled="!hasCreate"
></el-switch> ></el-switch>
</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" @change="handleTop(row)"></el-switch> <div class="table-col-top">
<el-select v-model="row.weight" placeholder="请选择权重" size="small" clearable :disabled="isDetails"> <el-switch :active-value="1" :inactive-value="0" v-model="row.is_top" @change="handleTop(row)" :disabled="!hasCreate"></el-switch>
<el-option v-for="item in 10" :label="item" :value="item" :key="item"></el-option> <el-select v-model="row.weight" placeholder="权重" size="mini" clearable :disabled="!hasCreate" @change="handleWeight(row)">
</el-select> <el-option v-for="item in 10" :label="item" :value="item" :key="item"></el-option>
</el-select>
</div>
</template> </template>
<template #footer> <template #footer>
<el-button size="mini" :disabled="!multipleSelection.length" @click="handleRemove" v-if="hasDelete" <el-button size="mini" :disabled="!multipleSelection.length" @click="handleRemove" v-if="hasDelete"
>删除</el-button >删除</el-button
...@@ -95,8 +97,8 @@ export default { ...@@ -95,8 +97,8 @@ export default {
activeName: '', activeName: '',
drawerVisible: false, drawerVisible: false,
drawFormOptions: { drawFormOptions: {
type: '', type: '', // 操作类型,新建/查看/编辑
pageType: 2, pageType: 2, // 页面 1文章,2广告,3图文
details: {} details: {}
}, },
drawItem: '', drawItem: '',
...@@ -157,13 +159,14 @@ export default { ...@@ -157,13 +159,14 @@ export default {
} }
], ],
columns: [ columns: [
{ type: 'selection', visible: this.hasDelete }, { type: 'selection', visible: this.hasDelete, fixed: 'left' },
{ prop: 'image_url', label: '图片', slots: 'image' }, { prop: 'image_url', label: '图片', slots: 'image', minWidth: '80px', fixed: 'left' },
{ prop: 'id', label: '广告ID', slots: 'table-id' }, { prop: 'id', label: '广告ID', slots: 'table-id', minWidth: '90px', fixed: 'left' },
{ prop: 'title', label: '标题' }, { prop: 'title', label: '标题', minWidth: '100px' },
{ {
prop: 'start_time', prop: 'start_time',
label: '开始时间', label: '开始时间',
minWidth: '90px',
computed({ row }) { computed({ row }) {
return dateFormat(row.start_time) || '-' return dateFormat(row.start_time) || '-'
} }
...@@ -171,24 +174,33 @@ export default { ...@@ -171,24 +174,33 @@ export default {
{ {
prop: 'end_time', prop: 'end_time',
label: '结束时间', label: '结束时间',
minWidth: '90px',
computed({ row }) { computed({ row }) {
return dateFormat(row.end_time) || '-' return dateFormat(row.end_time) || '-'
} }
}, },
{ prop: 'project.name', label: '项目' }, { prop: 'project.name', label: '项目', minWidth: '120px' },
{ prop: 'type.name', label: '类型' }, { prop: 'type.name', label: '类型', minWidth: '120px' },
{ prop: 'weight', label: '权重' }, { prop: 'weight', label: '权重', minWidth: '70px' },
{ {
prop: 'sso_user.real_name', prop: 'sso_user.real_name',
label: '创建人', label: '创建人',
minWidth: '100px',
computed({ row }) { computed({ row }) {
return row.sso_user.real_name || row.sso_user.nickname return row.sso_user.real_name || row.sso_user.nickname
} }
}, },
{ prop: 'audit_status', label: '审核状态', slots: 'review-status' }, {
{ prop: 'is_publish', label: '发布状态', slots: 'publish-status' }, prop: 'created_at',
{ prop: 'is_top', label: '置顶状态/权重', slots: 'top-status' }, label: '创建时间',
{ prop: 'created_at', label: '创建时间' } minWidth: '90px',
computed({ row }) {
return dateFormat(row.created_at) || '-'
}
},
{ prop: 'audit_status', label: '审核状态', slots: 'review-status', fixed: 'right' },
{ prop: 'is_publish', label: '发布状态', slots: 'publish-status', fixed: 'right' },
{ prop: 'is_top', label: '置顶状态/权重', slots: 'top-status', minWidth: '140px', fixed: 'right' }
] ]
} }
} }
...@@ -217,14 +229,10 @@ export default { ...@@ -217,14 +229,10 @@ export default {
}, },
// 置顶 // 置顶
handleTop(row) { handleTop(row) {
topAd(row.id, { is_top: row.is_top }).then(res => { this.fetchAdTopWeight(row.id, { is_top: row.is_top })
if (res.code === 0) { },
this.$message.success('更改状态成功') handleWeight(row) {
} else { this.fetchAdTopWeight(row.id, { weight: row.weight })
row.is_top = row.is_top ? 0 : 1
this.$message.error(res.message)
}
})
}, },
// 选择 // 选择
handleSelectionChange(value) { handleSelectionChange(value) {
...@@ -303,6 +311,16 @@ export default { ...@@ -303,6 +311,16 @@ export default {
this.$message.error(res.message || '审核广告失败') this.$message.error(res.message || '审核广告失败')
} }
}) })
},
fetchAdTopWeight(id, data) {
topAd(id, data).then(res => {
if (res.code === 0) {
this.$message.success('更改置顶状态成功')
} else {
// row.is_top = row.is_top ? 0 : 1
this.$message.error(res.message)
}
})
} }
}, },
beforeMount() { beforeMount() {
...@@ -311,4 +329,7 @@ export default { ...@@ -311,4 +329,7 @@ export default {
} }
</script> </script>
<style scoped> <style scoped>
.table-col-top .el-select{
width:70px;
}
</style> </style>
...@@ -28,11 +28,17 @@ ...@@ -28,11 +28,17 @@
:inactive-value="0" :inactive-value="0"
v-model="row.is_publish" v-model="row.is_publish"
@change="handlePublish(row)" @change="handlePublish(row)"
:disabled="!hasCreate">
></el-switch> ></el-switch>
</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" @change="handleTop(row)"></el-switch> <div class="table-col-top">
<el-switch :active-value="1" :inactive-value="0" v-model="row.is_top" @change="handleTop(row)" :disabled="!hasCreate">></el-switch>
<el-select v-model="row.weight" placeholder="权重" size="mini" clearable :disabled="!hasCreate" @change="handleWeight(row)">
<el-option v-for="item in 10" :label="item" :value="item" :key="item"></el-option>
</el-select>
</div>
</template> </template>
<!-- 推荐状态 --> <!-- 推荐状态 -->
<template v-slot:recommend-status="{ row }"> <template v-slot:recommend-status="{ row }">
...@@ -41,6 +47,7 @@ ...@@ -41,6 +47,7 @@
:inactive-value="0" :inactive-value="0"
v-model="row.is_recommend" v-model="row.is_recommend"
@change="handleRecommend(row)" @change="handleRecommend(row)"
:disabled="!hasCreate">
></el-switch> ></el-switch>
</template> </template>
...@@ -89,8 +96,9 @@ export default { ...@@ -89,8 +96,9 @@ export default {
activeName: '', activeName: '',
drawerVisible: false, drawerVisible: false,
drawFormOptions: { drawFormOptions: {
type: '', type: '', // 操作类型,新建/查看/编辑
pageType: 1 pageType: 1, // 页面 1文章,2广告,3图文
details: {}
}, },
drawItem: '', drawItem: '',
dialogVisible: false, dialogVisible: false,
...@@ -150,13 +158,14 @@ export default { ...@@ -150,13 +158,14 @@ export default {
} }
], ],
columns: [ columns: [
{ type: 'selection', visible: this.hasDelete }, { type: 'selection', visible: this.hasDelete, fixed: 'left' },
{ prop: 'image_url', label: '图片', slots: 'image' }, { prop: 'image_url', label: '图片', slots: 'image', minWidth: '80px', fixed: 'left' },
{ prop: 'id', label: '文章ID', slots: 'table-id' }, { prop: 'id', label: '文章ID', slots: 'table-id', minWidth: '90px', fixed: 'left' },
{ prop: 'title', label: '标题' }, { prop: 'title', label: '标题', minWidth: '100px' },
{ {
prop: 'start_time', prop: 'start_time',
label: '开始时间', label: '开始时间',
minWidth: '90px',
computed({ row }) { computed({ row }) {
return dateFormat(row.start_time) || '-' return dateFormat(row.start_time) || '-'
} }
...@@ -164,19 +173,34 @@ export default { ...@@ -164,19 +173,34 @@ export default {
{ {
prop: 'end_time', prop: 'end_time',
label: '结束时间', label: '结束时间',
minWidth: '90px',
computed({ row }) { computed({ row }) {
return dateFormat(row.end_time) || '-' return dateFormat(row.end_time) || '-'
} }
}, },
{ prop: 'project.name', label: '项目' }, { prop: 'project.name', label: '项目', minWidth: '120px' },
{ prop: 'type.name', label: '类型' }, { prop: 'type.name', label: '类型', minWidth: '120px' },
{ prop: 'weight', label: '权重' }, { prop: 'weight', label: '权重', minWidth: '70px' },
{ prop: 'sso_user.real_name', label: '创建人' }, {
prop: 'sso_user.real_name',
label: '创建人',
minWidth: '100px',
computed({ row }) {
return row.sso_user.real_name || row.sso_user.nickname
}
},
{
prop: 'created_at',
label: '创建时间',
minWidth: '90px',
computed({ row }) {
return dateFormat(row.created_at) || '-'
}
},
{ 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', fixed: 'right' },
{ prop: 'is_top', label: '置顶状态/权重', slots: 'top-status' }, { prop: 'is_top', label: '置顶状态/权重', slots: 'top-status', minWidth: '140px', fixed: 'right' },
{ prop: 'is_recommend', label: '推荐状态', slots: 'recommend-status' }, { prop: 'is_recommend', label: '推荐状态', slots: 'recommend-status', fixed: 'right' }
{ prop: 'created_at', label: '创建时间' }
] ]
} }
} }
...@@ -206,14 +230,10 @@ export default { ...@@ -206,14 +230,10 @@ export default {
}, },
// 置顶 // 置顶
handleTop(row) { handleTop(row) {
topArticle(row.id, { is_top: row.is_top }).then(res => { this.fetchAdTopWeight(row.id, { is_top: row.is_top })
if (res.code === 0) { },
this.$message.success('更改状态成功') handleWeight(row) {
} else { this.fetchAdTopWeight(row.id, { weight: row.weight })
row.is_top = row.is_top ? 0 : 1
this.$message.error(res.message)
}
})
}, },
// 推荐 // 推荐
handleRecommend(row) { handleRecommend(row) {
...@@ -297,6 +317,16 @@ export default { ...@@ -297,6 +317,16 @@ export default {
this.$message.error(res.message || '更改文章失败') this.$message.error(res.message || '更改文章失败')
} }
}) })
},
fetchAdTopWeight(id, data) {
topArticle(id, data).then(res => {
if (res.code === 0) {
this.$message.success('更改置顶状态成功')
} else {
// row.is_top = row.is_top ? 0 : 1
this.$message.error(res.message)
}
})
} }
}, },
beforeMount() { beforeMount() {
...@@ -305,4 +335,7 @@ export default { ...@@ -305,4 +335,7 @@ export default {
} }
</script> </script>
<style scoped> <style scoped>
.table-col-top .el-select{
width:70px;
}
</style> </style>
...@@ -109,7 +109,7 @@ ...@@ -109,7 +109,7 @@
<el-form-item label="审核评审:" v-if="isDetails" class="mb-15"> <el-form-item label="审核评审:" v-if="isDetails" class="mb-15">
{{options.details.audit_remarks}} {{options.details.audit_remarks}}
</el-form-item> </el-form-item>
<slot name="form-item-review" v-if="isDetails"/> <slot name="form-item-review" v-if="isDetails && hasAudit"/>
<!-- <el-form-item v-if="isDetails"> <!-- <el-form-item v-if="isDetails">
<el-button type="primary" @click="handleReview" size="mini">审核</el-button> <el-button type="primary" @click="handleReview" size="mini">审核</el-button>
</el-form-item> --> </el-form-item> -->
...@@ -184,13 +184,20 @@ export default { ...@@ -184,13 +184,20 @@ export default {
} }
}, },
computed: { computed: {
...mapGetters(['projects']), ...mapGetters(['projects', 'permissions']),
pageName() {
return this.options.page
},
pageType() { pageType() {
return this.options.pageType return this.options.pageType
}, },
// 审核权限
hasAudit() {
const map = {
1: 'content-function-acticle-audit',
2: 'content-function-advert-audit',
3: 'content-function-imgtext-audit'
}
const type = this.pageType
return this.permissions.includes(map[type])
},
isDetails() { isDetails() {
return this.options.type === 'details' return this.options.type === 'details'
}, },
......
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
:inactive-value="0" :inactive-value="0"
v-model="row.is_publish" v-model="row.is_publish"
@change="handlePublish(row)" @change="handlePublish(row)"
:disabled="!hasCreate"
></el-switch> ></el-switch>
</template> </template>
...@@ -76,8 +77,9 @@ export default { ...@@ -76,8 +77,9 @@ export default {
activeName: '', activeName: '',
drawerVisible: false, drawerVisible: false,
drawFormOptions: { drawFormOptions: {
type: '', type: '', // 操作类型,新建/查看/编辑
pageType: 3 pageType: 3, // 页面 1文章,2广告,3图文
details: {}
}, },
drawItem: '', drawItem: '',
dialogVisible: false, dialogVisible: false,
...@@ -138,13 +140,14 @@ export default { ...@@ -138,13 +140,14 @@ export default {
} }
], ],
columns: [ columns: [
{ type: 'selection', visible: this.hasDelete }, { type: 'selection', visible: this.hasDelete, fixed: 'left' },
{ prop: 'image_url', label: '图片', slots: 'image' }, { prop: 'image_url', label: '图片', slots: 'image', minWidth: '80px', fixed: 'left' },
{ prop: 'id', label: '图文ID', slots: 'table-id' }, { prop: 'id', label: '图文ID', slots: 'table-id', minWidth: '90px', fixed: 'left' },
{ prop: 'title', label: '标题' }, { prop: 'title', label: '标题', minWidth: '100px' },
{ {
prop: 'start_time', prop: 'start_time',
label: '开始时间', label: '开始时间',
minWidth: '90px',
computed({ row }) { computed({ row }) {
return dateFormat(row.start_time) || '-' return dateFormat(row.start_time) || '-'
} }
...@@ -152,17 +155,32 @@ export default { ...@@ -152,17 +155,32 @@ export default {
{ {
prop: 'end_time', prop: 'end_time',
label: '结束时间', label: '结束时间',
minWidth: '90px',
computed({ row }) { computed({ row }) {
return dateFormat(row.end_time) || '-' return dateFormat(row.end_time) || '-'
} }
}, },
{ prop: 'project.name', label: '项目' }, { prop: 'project.name', label: '项目', minWidth: '120px' },
{ prop: 'type.name', label: '类型' }, { prop: 'type.name', label: '类型', minWidth: '120px' },
{ prop: 'weight', label: '权重' }, { prop: 'weight', label: '权重', minWidth: '70px' },
{ prop: 'sso_user.real_name', label: '创建人' }, {
prop: 'sso_user.real_name',
label: '创建人',
minWidth: '100px',
computed({ row }) {
return row.sso_user.real_name || row.sso_user.nickname
}
},
{
prop: 'created_at',
label: '创建时间',
minWidth: '90px',
computed({ row }) {
return dateFormat(row.created_at) || '-'
}
},
{ 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', fixed: 'right' }
{ prop: 'created_at', label: '创建时间' }
] ]
} }
} }
......
...@@ -3,6 +3,7 @@ const getters = { ...@@ -3,6 +3,7 @@ const getters = {
roles: state => state.user.roles, roles: state => state.user.roles,
sidebar: state => state.app.sidebar, sidebar: state => state.app.sidebar,
permission_routes: state => state.permission.routes, permission_routes: state => state.permission.routes,
projects: state => state.user.projects projects: state => state.user.projects,
permissions: state => state.user.permissions
} }
export default getters export default getters
...@@ -145,8 +145,8 @@ body { ...@@ -145,8 +145,8 @@ body {
/* page_container background */ /* page_container background */
.page_container{ .page_container{
width: calc(100% - 20px); width: calc(100% - 20px);
height: calc(100% - 20px); height: calc(100% - 10px);
margin: 10px; margin: 10px 10px 0;
background: #fff; background: #fff;
border-radius: 5px; border-radius: 5px;
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论