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

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

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