浏览代码

研报权限勾选

shanbinzhang 1 周之前
父节点
当前提交
2b1a6a355e

+ 19 - 0
src/api/modules/businessCustom.js

@@ -185,4 +185,23 @@ export const businessCustomInterence = {
     chartClassifyRealTree:(params)=>{
     chartClassifyRealTree:(params)=>{
         return get('/chart/classify/real_tree',params)
         return get('/chart/classify/real_tree',params)
     },
     },
+
+    /**
+     * 获取报告分类权限
+     * @param {*} params EtaBusinessId
+     * @returns 
+     */
+    getReportPermission: params => {
+        return get('/eta_business/get_report_permission',params)
+    },
+
+    /**
+     * 设置报告分类权限
+     * @param {*} params 
+     * ChartPermissionIds EtaBusinessId
+     * @returns 
+     */
+    setReportPermission: params => {
+        return post('/eta_business/add_report_permission',params)
+    }
 }
 }

+ 17 - 4
src/views/business_manage/addBusiness.vue

@@ -133,6 +133,7 @@
         <div class="second-step-form-wrap tree">
         <div class="second-step-form-wrap tree">
           <SetPermission
           <SetPermission
             :isShowFoot="false"
             :isShowFoot="false"
+            :businessId="checkBusinessId"
             :PermissionList="PermissionList"
             :PermissionList="PermissionList"
             :allCheckedList="allCheckedList"
             :allCheckedList="allCheckedList"
             :currentStep="currentStep"
             :currentStep="currentStep"
@@ -360,7 +361,10 @@ const getCurrentState = () => {
   }
   }
 }
 }
 
 
+
+const checkBusinessId = ref(0)
 const getChartPermission = async (EtaBusinessId, Keyword, isSearch = false) => {
 const getChartPermission = async (EtaBusinessId, Keyword, isSearch = false) => {
+  checkBusinessId.value = EtaBusinessId;
   try {
   try {
     const res = await businessCustomInterence.getChartPermission({
     const res = await businessCustomInterence.getChartPermission({
       EtaBusinessId: EtaBusinessId,
       EtaBusinessId: EtaBusinessId,
@@ -498,10 +502,19 @@ const handleStepSecond = async (stepName) => {
 };
 };
 
 
 const handleAddBusiness = async (isEdit = '') => {
 const handleAddBusiness = async (isEdit = '') => {
-  const res = await businessCustomInterence.addChartPermission({
-    ChartClassifyIdStr: permissionRef.value && permissionRef.value.actuallyAllChecked.join(',') || '',
-    EtaBusinessId: handleEtaBusinessId.value === 0 ? businessId.value : handleEtaBusinessId.value
-  });
+  const res = permissionRef.value.activeTab === '研报'
+      ? await businessCustomInterence.setReportPermission({
+          ChartPermissionIds: permissionRef.value && permissionRef.value.actuallyAllChecked || [],
+          EtaBusinessId: handleEtaBusinessId.value === 0 ? businessId.value : handleEtaBusinessId.value
+       })
+      : await businessCustomInterence.addChartPermission({
+          ChartClassifyIdStr: permissionRef.value && permissionRef.value.actuallyAllChecked.join(',') || '',
+          EtaBusinessId: handleEtaBusinessId.value === 0 ? businessId.value : handleEtaBusinessId.value
+       });
+  // const res = await businessCustomInterence.addChartPermission({
+  //   ChartClassifyIdStr: permissionRef.value && permissionRef.value.actuallyAllChecked.join(',') || '',
+  //   EtaBusinessId: handleEtaBusinessId.value === 0 ? businessId.value : handleEtaBusinessId.value
+  // });
   if (res.Ret !== 200) return;
   if (res.Ret !== 200) return;
   if(isEdit === 'edit') return MessagePlugin.success('保存成功');
   if(isEdit === 'edit') return MessagePlugin.success('保存成功');
   MessagePlugin.success('添加成功');
   MessagePlugin.success('添加成功');

+ 14 - 8
src/views/business_manage/businessList.vue

@@ -152,7 +152,7 @@
       <!-- 添加续约 -->
       <!-- 添加续约 -->
       <t-dialog
       <t-dialog
         header="添加续约"
         header="添加续约"
-        :visible.sync="showRenewal"
+        v-model:visible="showRenewal"
         :footer="false"
         :footer="false"
         @close="showRenewal = false"
         @close="showRenewal = false"
       >
       >
@@ -162,7 +162,7 @@
       <!-- 修改销售 -->
       <!-- 修改销售 -->
       <t-dialog
       <t-dialog
         header="修改销售"
         header="修改销售"
-        :visible.sync="showModifySaller"
+        v-model:visible="showModifySaller"
         @close="showModifySaller = false"
         @close="showModifySaller = false"
         :footer="false"
         :footer="false"
       >
       >
@@ -177,7 +177,7 @@
       <t-dialog
       <t-dialog
         header="资源库权限设置"
         header="资源库权限设置"
         width="772px"
         width="772px"
-        :visible.sync="showSetPermission"
+        v-model:visible="showSetPermission"
         @close="showSetPermission = false"
         @close="showSetPermission = false"
         :footer="false"
         :footer="false"
       >
       >
@@ -186,6 +186,7 @@
             @getSearch="handleGetSearch"
             @getSearch="handleGetSearch"
             @close="showSetPermission = false"
             @close="showSetPermission = false"
             :isShowFoot="true"
             :isShowFoot="true"
+            :businessId="handleEtaBusinessId"
             :isSearch=isPermissionSearch
             :isSearch=isPermissionSearch
             :showSetPermission="showSetPermission"
             :showSetPermission="showSetPermission"
             :allCheckedList="allCheckedList"
             :allCheckedList="allCheckedList"
@@ -410,11 +411,16 @@
   };
   };
 
 
   // 权限设置弹窗确认按钮
   // 权限设置弹窗确认按钮
-  const handleSetPermission = async (allCheckedList) => {
-    const res = await businessCustomInterence.addChartPermission({
-      ChartClassifyIdStr: allCheckedList.join(','),
-      EtaBusinessId: handleEtaBusinessId.value
-    });
+  const handleSetPermission = async ({type,checkedList}) => {
+    const res = type === '研报'
+      ? await businessCustomInterence.setReportPermission({
+          ChartPermissionIds: checkedList,
+          EtaBusinessId: handleEtaBusinessId.value
+       })
+      : await businessCustomInterence.addChartPermission({
+          ChartClassifyIdStr: checkedList.join(','),
+          EtaBusinessId: handleEtaBusinessId.value
+       });
     if (res.Ret !== 200) return;
     if (res.Ret !== 200) return;
     MessagePlugin.success('权限修改成功');
     MessagePlugin.success('权限修改成功');
     showSetPermission.value = false;
     showSetPermission.value = false;

+ 101 - 29
src/views/business_manage/components/SetPermission.vue

@@ -1,6 +1,6 @@
 <template>
 <template>
     <div class="add-renewal-wrap">
     <div class="add-renewal-wrap">
-        <t-input
+        <!-- <t-input
             :class="!props.isShowFoot ? 'input-wrap' : ''"
             :class="!props.isShowFoot ? 'input-wrap' : ''"
             placeholder="分类名称"
             placeholder="分类名称"
             v-model="searchTxt"
             v-model="searchTxt"
@@ -8,7 +8,17 @@
             @Blur="changeSearchTxt"
             @Blur="changeSearchTxt"
         >
         >
           <template #prefixIcon><SearchIcon /></template>
           <template #prefixIcon><SearchIcon /></template>
-        </t-input>
+        </t-input> -->
+        
+        <div class="tab-nav">
+          <span 
+            v-for="tab in tabs" 
+            :key="tab.name" 
+            :class="{'act':tab.name===activeTab}"
+            @click="handleChangeTab(tab)"
+          >{{tab.name}}</span>
+        </div>
+
         <div class="tree">
         <div class="tree">
             <t-tree
             <t-tree
                 :expandAll="searchTxt !== ''"
                 :expandAll="searchTxt !== ''"
@@ -31,9 +41,10 @@
 </template>
 </template>
 
 
 <script setup>
 <script setup>
-import { ref, watch, nextTick } from 'vue';
+import { ref, watch, nextTick, computed } from 'vue';
 import { SearchIcon } from 'tdesign-icons-vue-next';
 import { SearchIcon } from 'tdesign-icons-vue-next';
 import { useRoute } from 'vue-router'
 import { useRoute } from 'vue-router'
+ import {  businessCustomInterence } from '@/api/api.js';
 
 
 const route = useRoute()
 const route = useRoute()
 const props = defineProps({
 const props = defineProps({
@@ -61,32 +72,82 @@ const props = defineProps({
     type: Number,
     type: Number,
     default: 1,
     default: 1,
   },
   },
+  businessId: {
+    type: Number
+  }
 
 
 });
 });
 // emit事件
 // emit事件
 const emit = defineEmits(['close', 'setPermission', 'getSearch']);
 const emit = defineEmits(['close', 'setPermission', 'getSearch']);
 const searchTxt = ref('');
 const searchTxt = ref('');
+
+
+const tabs = [
+  { name:'图库',key:'图库' },
+  { name:'研报',key:'研报' },
+]
+const activeTab=ref('图库')
+function handleChangeTab(item) {
+  if(activeTab.value === item.key) return
+  activeTab.value = item.key;
+
+  activeTab.value === '研报' ? getReportPermissionList() : initPermission(props.PermissionList);
+}
+
+async function getReportPermissionList() {
+  const res = await businessCustomInterence.getReportPermission({
+    EtaBusinessId: props.businessId
+  })
+
+  if(res.Ret !== 200) return 
+  if(res.Data) {
+    treeList.value =  filterNodes(res.Data.List);
+    allChecked.value = res.Data.CheckList;
+    actuallyAllChecked.value = res.Data.CheckList;
+  }
+}
+
+function initPermission(newValue) {
+  treeList.value = newValue.length !== 0 ? filterNodes(newValue) : [];
+    
+  if (!props.isSearch && newValue.length > 0) {                           // 如果不是搜索,则直接把后端返回的赋值为选中项
+    allChecked.value = props.allCheckedList;
+    actuallyAllChecked.value = props.allCheckedList;
+  } else {                                         // 如果是搜索,则把本地选中项赋值为实际上选中的值
+    allChecked.value = actuallyAllChecked.value
+  }
+}
+
  
  
 // tree相关
 // tree相关
 const treeList = ref([]);
 const treeList = ref([]);
 const tree = ref();
 const tree = ref();
 const valueMode = ref('all');
 const valueMode = ref('all');
 const checkable = ref(true);
 const checkable = ref(true);
-const checkStrictly = ref(true);
+const checkStrictly = computed(() => activeTab.value === '图库' ? true : false);
 const allChecked = ref([]);
 const allChecked = ref([]);
 const actuallyAllChecked = ref([]);
 const actuallyAllChecked = ref([]);
-const treeKeys = reactive({
-    value: 'ChartClassifyId',
-    children: 'Children',
-    label: 'ChartClassifyName',
+const treeKeys = computed( () => {
+   return activeTab.value === '图库'
+    ? {
+        value: 'ChartClassifyId',
+        children: 'Children',
+        label: 'ChartClassifyName',
+      }
+    : {
+        value: 'PermissionId',
+        children: 'Child',
+        label: 'PermissionName',
+      }
 });
 });
+const singleKey = computed(() => activeTab.value === '图库' ? 'ChartClassifyId' : 'PermissionId')
 
 
 // 用于存储ChartClassifyId到节点引用的映射
 // 用于存储ChartClassifyId到节点引用的映射
 const nodeMap = new Map();
 const nodeMap = new Map();
 // 构建nodeIdMap的函数
 // 构建nodeIdMap的函数
 const buildNodeMap = (arr) => {
 const buildNodeMap = (arr) => {
   arr.forEach(node => {
   arr.forEach(node => {
-    nodeMap.set(node.ChartClassifyId, node);
+    nodeMap.set(node[singleKey.value], node);
     if (node.Children && node.Children.length) {
     if (node.Children && node.Children.length) {
       buildNodeMap(node.Children);
       buildNodeMap(node.Children);
     }
     }
@@ -99,7 +160,7 @@ const filterNodes = (arr) => {
   const processNodes = (nodes) => {
   const processNodes = (nodes) => {
     nodes.forEach(node => {
     nodes.forEach(node => {
       // 检查当前节点的ChartClassifyId是否在allCheckedList中
       // 检查当前节点的ChartClassifyId是否在allCheckedList中
-      if (props.allCheckedList.includes(node.ChartClassifyId)) {
+      if (props.allCheckedList.includes(node[singleKey.value])) {
         // 标记当前节点为expanded
         // 标记当前节点为expanded
         node.expanded = true;
         node.expanded = true;
 
 
@@ -130,14 +191,7 @@ watch(
   () => props.PermissionList,
   () => props.PermissionList,
   (newValue) => {
   (newValue) => {
     console.log('newValue', newValue);
     console.log('newValue', newValue);
-    treeList.value = newValue.length !== 0 ? filterNodes(newValue) : [];
-    
-    if (!props.isSearch && newValue.length > 0) {                           // 如果不是搜索,则直接把后端返回的赋值为选中项
-      allChecked.value = props.allCheckedList;
-      actuallyAllChecked.value = props.allCheckedList;
-    } else {                                         // 如果是搜索,则把本地选中项赋值为实际上选中的值
-      allChecked.value = actuallyAllChecked.value
-    }
+    initPermission(newValue)
   },
   },
   { immediate: true }
   { immediate: true }
 );
 );
@@ -160,6 +214,7 @@ watch(
   (newValue) => {
   (newValue) => {
     if (newValue) {
     if (newValue) {
       searchTxt.value = '';
       searchTxt.value = '';
+      activeTab.value = '图库';
     }
     }
   },
   },
   { immediate: true }
   { immediate: true }
@@ -172,16 +227,18 @@ const onChange = (checked, context) => {
   //   expanded: true,
   //   expanded: true,
   // })
   // })
   const { node } = context;
   const { node } = context;
+  const childList = activeTab.value==='研报' ? node.data.Child : node.data.Children;
+
   if (node.checked) {
   if (node.checked) {
-    if (node.data.Children.length) {                    // 如果当前节点有子节点,则把所有子节点的id都加上去  
-      allChecked.value = [...new Set([...allChecked.value, node.value, ...getAllChildIds(node.data.Children)])];
-      actuallyAllChecked.value = [...new Set([...actuallyAllChecked.value, node.value, ...getAllChildIds(node.data.Children)])];
+    if (childList.length) {                    // 如果当前节点有子节点,则把所有子节点的id都加上去  
+      allChecked.value = [...new Set([...allChecked.value, node.value, ...getAllChildIds(childList)])];
+      actuallyAllChecked.value = [...new Set([...actuallyAllChecked.value, node.value, ...getAllChildIds(childList)])];
     } else {                                            // 如果当前节点有子节点,则直接加上该节点的id
     } else {                                            // 如果当前节点有子节点,则直接加上该节点的id
       actuallyAllChecked.value = [...new Set([...actuallyAllChecked.value, node.value])];                                                  
       actuallyAllChecked.value = [...new Set([...actuallyAllChecked.value, node.value])];                                                  
     }
     }
   } else {
   } else {
-    if (node.data.Children.length) {                    // 如果当前节点有子节点,则直接去掉该节点和子节点的所有id 
-      const temp = [...getAllChildIds(node.data.Children), node.value];
+    if (childList.length) {                    // 如果当前节点有子节点,则直接去掉该节点和子节点的所有id 
+      const temp = [...getAllChildIds(childList), node.value];
       allChecked.value = removeChildren(allChecked.value, temp);
       allChecked.value = removeChildren(allChecked.value, temp);
       actuallyAllChecked.value = removeChildren(actuallyAllChecked.value, temp);
       actuallyAllChecked.value = removeChildren(actuallyAllChecked.value, temp);
     } else {                                          // 如果当前节点没有子节点,则直接去掉该节点的id
     } else {                                          // 如果当前节点没有子节点,则直接去掉该节点的id
@@ -195,13 +252,13 @@ const getAllChildIds = (arr) => {
   function traverse(current) {
   function traverse(current) {
     if (!Array.isArray(current) || !current.length) return;
     if (!Array.isArray(current) || !current.length) return;
     current.forEach(item => {
     current.forEach(item => {
-      if (item.ChartClassifyId) {
-        ids.push(item.ChartClassifyId);
+      if (item[singleKey.value]) {
+        ids.push(item[singleKey.value]);
       }
       }
       if (item.Children && Array.isArray(item.Children)) {
       if (item.Children && Array.isArray(item.Children)) {
         item.Children.forEach(child => {
         item.Children.forEach(child => {
-          if (child.ChartClassifyId) {
-            ids.push(child.ChartClassifyId);
+          if (child[singleKey.value]) {
+            ids.push(child[singleKey.value]);
           }
           }
           traverse(child.Children); // 递归遍历子元素
           traverse(child.Children); // 递归遍历子元素
         });
         });
@@ -218,7 +275,10 @@ const removeChildren = (arrayA, arrayB) => {
 
 
 // 保存按钮
 // 保存按钮
 const handleSave = async () => {
 const handleSave = async () => {
-  emit('setPermission', actuallyAllChecked.value);
+  emit('setPermission', {
+    type: activeTab.value,
+    checkedList:actuallyAllChecked.value
+  });
 };
 };
 // 搜索
 // 搜索
 const changeSearchTxt = () => {
 const changeSearchTxt = () => {
@@ -230,7 +290,8 @@ const handleClose = () => {
 };
 };
 
 
 defineExpose({
 defineExpose({
-    actuallyAllChecked
+    actuallyAllChecked,
+    activeTab
 })
 })
 </script>
 </script>
 <style scoped lang="scss">
 <style scoped lang="scss">
@@ -247,5 +308,16 @@ defineExpose({
         gap: 10px;
         gap: 10px;
         justify-content: flex-end;
         justify-content: flex-end;
     }
     }
+
+    .tab-nav {
+      display: flex;
+      gap: 0 30px;
+      >span {
+        cursor: pointer;
+      }
+      span.act {
+        color: #0052D9;
+      }
+    }
 }
 }
 </style>
 </style>

+ 2 - 1
vite.config.js

@@ -93,7 +93,8 @@ export default defineConfig(({ mode }) => {
       proxy:{
       proxy:{
         '/v1': {
         '/v1': {
           // target: 'http://192.168.20.10:8912/v1',
           // target: 'http://192.168.20.10:8912/v1',
-          target: 'http://8.136.199.33:8900/v1',
+          // target: 'http://8.136.199.33:8900/v1',
+          target: 'http://192.168.77.34:8912/v1',
           // target: 'http://8.136.199.33:7777/adminapi/',
           // target: 'http://8.136.199.33:7777/adminapi/',
           changeOrigin: true,
           changeOrigin: true,
           rewrite: (path) => path.replace(/^\/v1/, ''),
           rewrite: (path) => path.replace(/^\/v1/, ''),