Browse Source

中文研报权限设置

cxmo 1 year ago
parent
commit
b076eec81b

+ 0 - 1
src/directives/AuthBtn.js

@@ -9,7 +9,6 @@ export default {
         // 拿出所有按钮的code
         const authBtnStore = useAuthBtnStore()
         let buttonCodes = authBtnStore.authBtnList.map(item => item.ButtonCode)
-        console.log('test',buttonCodes)
         if (value && typeof (value) == 'string') {
             // 字符类型
             if (!buttonCodes.includes(value)) {

+ 24 - 2
src/hooks/useAuthBtn.js

@@ -4,8 +4,30 @@ const authBtnStore = useAuthBtnStore()
 /*
 ---------------------------研报管理----------------- 
 */
-export const reportManageBtn = {}
-export const enReportManageBtn = {}
+export const reportManageBtn = {
+    reportManage_sendMsg:'reportManage:sendMsg',//推送消息/已推送消息
+    reportManage_reportView:'reportManage:reportView',//研报预览:即是否能点击研报名称跳转预览页面
+    reportManage_reportDel:'reportManage:reportDel',//删除研报
+    reportManage_reportEdit:'reportManage:reportEdit',//编辑研报
+    reportManage_cancelPublish:'reportManage:cancelPublish',//取消发布
+    reportManage_publish:'reportManage:publish',//发布研报
+    reportManage_reportList:'reportManage:reportList',//研报列表的选项
+    reportManage_reportList_uv:'reportManage:reportList:uv',//研报列表-PV/UV
+    reportManage_reportList_sendTime:'reportManage:reportList:sendTime',//研报列表-报告推送时间
+    reportManage_dayWeekReportAdd:'reportManage:dayWeekReportAdd',//添加晨报周报
+    reportManage_reportAdd:'reportManage:reportAdd',//添加研报
+}
+export const enReportManageBtn = {
+    enReport_reportView:'enReport:reportView',//研报预览:即是否能点击研报名称跳转预览页面
+    enReport_reportView_wechatShare:'enReport:reportView:wechatShare',//研报预览页面-微信分享
+    enReport_reportView_copyWechat:'enReport:reportView:copyWechat',//研报预览页面-复制链接
+    enReport_sendEmail:'enReport:sendEmail',//群发邮件/群发日志
+    enReport_reportDel:'enReport:reportDel',//删除研报
+    enReport_reportEdit:'enReport:reportEdit',//编辑研报
+    enReport_cancelPublish:'enReport:cancelPublish',//取消发布
+    enReport_publish:'enReport:publish',//发布研报
+    enReport_reportAdd:'enReport:reportAdd',//添加研报
+}
 
 /*
 --------------------------智能PPT-----------------

+ 11 - 1
src/store/modules/authBtn.js

@@ -15,7 +15,17 @@ export const useAuthBtnStore = defineStore('authBtn',{
                 /* apiGetAuthBtnList().then(res=>{
                     this.authBtnList = res.Data||[]
                 }) */
-                this.authBtnList = [{ButtonCode: "system:menu:add"}]
+                this.authBtnList = [
+                    {ButtonCode:'reportManage:reportAdd'},
+                    {ButtonCode:'reportManage:dayWeekReportAdd'},
+                    {ButtonCode:'reportManage:sendMsg'},
+                    {ButtonCode:'reportManage:reportList:uv'},
+                    {ButtonCode:'reportManage:reportDel'},
+                    {ButtonCode:'reportManage:reportEdit'},
+                    {ButtonCode:'reportManage:cancelPublish'},
+                    /* {ButtonCode:'reportManage:publish'},
+                    {ButtonCode:'reportManage:reportView'} */
+                ]
                 resolve('权限获取成功')
             })
         }

+ 4 - 3
src/views/report/EditReport.vue

@@ -10,6 +10,7 @@ import moment from 'moment'
 import { showToast,showDialog } from 'vant'
 import { useRoute, useRouter } from 'vue-router'
 import {useCachedViewsStore} from '@/store/modules/cachedViews'
+import {reportManageBtn} from '@/hooks/useAuthBtn'
 const cachedViewsStore=useCachedViewsStore()
 
 const router=useRouter()
@@ -394,7 +395,7 @@ function onConfirmDSFBTime(time){
                     <img src="@/assets/imgs/report/icon_refresh.png" alt="">
                     <span>刷新</span>
                 </div>
-                <div class="item" @click="handleReportOpt('yl')">
+                <div class="item" @click="handleReportOpt('yl')" v-permission="reportManageBtn.reportManage_reportView">
                     <img src="@/assets/imgs/report/icon_preview.png" alt="">
                     <span>预览</span>
                 </div>
@@ -402,11 +403,11 @@ function onConfirmDSFBTime(time){
                     <img src="@/assets/imgs/report/icon_save2.png" alt="">
                     <span>保存</span>
                 </div>
-                <div class="item" @click="handleReportOpt('dsfb')">
+                <div class="item" @click="handleReportOpt('dsfb')" v-permission="reportManageBtn.reportManage_publish">
                     <img src="@/assets/imgs/report/icon_time.png" alt="">
                     <span>定时发布</span>
                 </div>
-                <div class="item" @click="handleReportOpt('fb')">
+                <div class="item" @click="handleReportOpt('fb')" v-permission="reportManageBtn.reportManage_publish">
                     <img src="@/assets/imgs/report/icon_publish3.png" alt="">
                     <span>发布</span>
                 </div>

+ 42 - 16
src/views/report/List.vue

@@ -9,8 +9,27 @@ import { useRouter } from 'vue-router';
 import { useWindowSize } from '@vueuse/core'
 import {useCachedViewsStore} from '@/store/modules/cachedViews'
 import {reportFrequencyOpts} from './utils/config'
+import {reportManageBtn,useAuthBtn} from '@/hooks/useAuthBtn'
 const cachedViewsStore=useCachedViewsStore()
 
+const {checkAuthBtn} = useAuthBtn()
+
+//添加按钮和添加选项
+const isAddReportBtnShow = computed(()=>{
+    return checkAuthBtn(reportManageBtn.reportManage_reportAdd)||checkAuthBtn(reportManageBtn.reportManage_dayWeekReportAdd)
+})
+
+const addReportActions = computed(()=>{
+    let arr = []
+    if(checkAuthBtn(reportManageBtn.reportManage_reportAdd)){
+        arr.push({name:'研报'})
+    }
+    if(checkAuthBtn(reportManageBtn.reportManage_dayWeekReportAdd)){
+        arr.push({name:'晨报/周报'})
+    }
+    return arr.reverse()
+})
+
 const { width, height } = useWindowSize()
 
 const router=useRouter()
@@ -210,6 +229,8 @@ function handleConfirmClassify({firstClassify,secondClassify}){
 // 跳转详情
 function goDetail(item){
     console.log(item);
+    //若没有预览权限,则不跳转
+    if(!checkAuthBtn(reportManageBtn.reportManage_reportView)) return 
     router.push({
         path:"/report/preview",
         query:{
@@ -227,6 +248,18 @@ async function onLongPressItem(e){
         showToast(`${e.Editor}正在编辑中,不可操作!`)
         return
     }
+    //检验权限,如果该状态下无可操作项,则长按不弹出
+    let checkState = false
+    if(e.State===1){ //编辑、发布、删除
+        checkState = checkAuthBtn(reportManageBtn.reportManage_reportEdit)
+            ||checkAuthBtn(reportManageBtn.reportManage_publish)
+            ||checkAuthBtn(reportManageBtn.reportManage_reportDel)
+    }
+    if(e.State===2){ //推送消息、取消发布
+        checkState = checkAuthBtn(reportManageBtn.reportManage_sendMsg)
+            ||checkAuthBtn(reportManageBtn.reportManage_cancelPublish)
+    }
+    if(!checkState) return
     activeItem.value=e
     showReportItemOpt.value=true
 }
@@ -438,7 +471,7 @@ async function handleReportEdit(e){
                         </div>
                     </div>
                 </van-dropdown-item>
-                <van-dropdown-item title="推送状态" ref="statusDropMenuIns">
+                <van-dropdown-item title="推送状态" ref="statusDropMenuIns" v-if="checkAuthBtn(reportManageBtn.reportManage_sendMsg)">
                     <div class="report-status-box">
                         <ul>
                             <li 
@@ -507,7 +540,7 @@ async function handleReportEdit(e){
                         </div>
                         <div class="read-count">
                             <span>PV:{{item.Pv}}</span>
-                            <span>UV:{{item.Uv}}</span>
+                            <span v-permission="reportManageBtn.reportManage_reportList_uv">UV:{{item.Uv}}</span>
                         </div>
                         <div class="status">
                             <span v-if="item.State===1">未发布</span>
@@ -520,7 +553,7 @@ async function handleReportEdit(e){
     </div>
 
     <!-- 添加报告按钮 -->
-    <div class="add-report-btn" @click="showAddReportPop=true">
+    <div class="add-report-btn" @click="showAddReportPop=true" v-if="isAddReportBtnShow">
         <svg width="28" height="28" viewBox="0 0 28 28" fill="none" xmlns="http://www.w3.org/2000/svg">
             <path d="M12.0499 15.9499V27.5H15.9499V15.9499H27.5V12.0499H15.9499V0.5H12.0499V12.0499H0.5V15.9499H12.0499Z" fill="white"/>
         </svg>
@@ -532,14 +565,7 @@ async function handleReportEdit(e){
         v-model:show="showAddReportPop"
         cancel-text="取消"
         close-on-click-action
-        :actions="[
-            {
-                name:'研报'
-            },
-            {
-                name:'晨报/周报'
-            }
-        ]"
+        :actions="addReportActions"
         @select="handleSelectAddReportType"
     >
     </van-action-sheet>
@@ -554,13 +580,13 @@ async function handleReportEdit(e){
         <div class="report-item-action-box" v-if="activeItem">
             <!-- <div class="title">{{activeItem.Title}}</div> -->
             <template v-if="activeItem.State==1">
-                <div class="item" @click="handleReportEdit(activeItem)">编辑</div>
-                <div class="item" @click="handleReportPublish(activeItem)">发布</div>
-                <div class="item" @click="handleReportDel(activeItem)">删除</div>
+                <div class="item" @click="handleReportEdit(activeItem)" v-permission="reportManageBtn.reportManage_reportEdit">编辑</div>
+                <div class="item" @click="handleReportPublish(activeItem)" v-permission="reportManageBtn.reportManage_publish">发布</div>
+                <div class="item" @click="handleReportDel(activeItem)" v-permission="reportManageBtn.reportManage_reportDel">删除</div>
             </template>
             <template v-if="activeItem.State==2">
-                <div class="item" @click="handldReportMsgSend(activeItem)" v-if="activeItem.MsgIsSend==0">推送消息</div>
-                <div class="item" @click="handleReportPublishCancle(activeItem)">取消发布</div>
+                <div class="item" @click="handldReportMsgSend(activeItem)" v-if="activeItem.MsgIsSend==0&&checkAuthBtn(reportManageBtn.reportManage_sendMsg)">推送消息</div>
+                <div class="item" @click="handleReportPublishCancle(activeItem)" v-permission="reportManageBtn.reportManage_cancelPublish">取消发布</div>
             </template>
         </div>
     </van-action-sheet>

+ 3 - 1
src/views/report/PreviewDetail.vue

@@ -4,6 +4,8 @@ import { useRoute, useRouter } from "vue-router";
 import apiReport from '@/api/report'
 import AudioBox from './components/AudioBox.vue'
 import {showToast} from 'vant'
+import {reportManageBtn,useAuthBtn} from '@/hooks/useAuthBtn'
+const {checkAuthBtn} = useAuthBtn()
 
 const route=useRoute()
 const router=useRouter()
@@ -69,7 +71,7 @@ async function goEdit(){
     <div class="report-detail-page" v-if="reportInfo">
         <div class="top-stage-box" v-if="$route.query.id!=-1">
             <span class="stage">第{{reportInfo.Stage}}期 / {{reportInfo.Frequency}}</span>
-            <img v-if="reportInfo.State==1" class="edit-icon" src="@/assets/imgs/report/icon_edit2.png" alt="" @click="goEdit">
+            <img v-if="reportInfo.State==1&&checkAuthBtn(reportManageBtn.reportManage_reportEdit)" class="edit-icon" src="@/assets/imgs/report/icon_edit2.png" alt="" @click="goEdit">
         </div>
         <h1 class="report-title">{{reportInfo.Title}}</h1>
         <div class="auth-box">