From ddfd2c45dea517f5330a2da02bba253479fe0fe0 Mon Sep 17 00:00:00 2001
From: zhangxiao <898441624@qq.com>
Date: 星期五, 23 八月 2024 19:24:06 +0800
Subject: [PATCH] fix: 权限

---
 src/views/dmx/knowledgeLib/index.vue |   76 ++++++++++++++++++++++++--------------
 1 files changed, 48 insertions(+), 28 deletions(-)

diff --git a/src/views/dmx/knowledgeLib/index.vue b/src/views/dmx/knowledgeLib/index.vue
index 4f8fefc..ca8e462 100644
--- a/src/views/dmx/knowledgeLib/index.vue
+++ b/src/views/dmx/knowledgeLib/index.vue
@@ -298,6 +298,7 @@
                   <template #status="{ record }">
                     <a-switch
                       v-model="record.status"
+                      :disabled="!getAut('/kb/data_status')"
                       size="small"
                       checked-value="1"
                       unchecked-value="0"
@@ -438,6 +439,7 @@
                           type="text"
                           size="large"
                           @click="run(record)"
+                          v-hasPermi="'/kb/data_analysis'"
                           :loading="record.loading"
                         >
                           <template #icon>
@@ -469,13 +471,18 @@
                       type="text"
                       :disabled="record.run == '1'"
                       @click="handleClick(record)"
+                      v-hasPermi="'/kb/data_update'"
                       size="small"
                     >
                       <template #icon>
                         <icon-tool />
                       </template>
                     </a-button>
-                    <edit :item="record" @upTabdateItem="upTabdateItem" />
+                    <edit
+                      :item="record"
+                      v-hasPermi="'/kb/rename'"
+                      @upTabdateItem="upTabdateItem"
+                    />
                     <a-popconfirm
                       :content="'纭畾鍒犻櫎鍚�'"
                       type="warning"
@@ -485,6 +492,7 @@
                         type="text"
                         size="small"
                         :disabled="record.run == '1'"
+                        v-hasPermi="'/kb/data_delete'"
                       >
                         <template #icon>
                           <icon-delete />
@@ -494,6 +502,7 @@
                     <a-button
                       type="text"
                       size="small"
+                      v-hasPermi="'/kb/data_download'"
                       :disabled="record.run == '1'"
                       @click="onDownloadDocument(record)"
                     >
@@ -517,7 +526,11 @@
               </a-card>
             </a-scrollbar>
           </a-tab-pane>
-          <a-tab-pane key="2" :title="t('dmx.list.test')">
+          <a-tab-pane
+            key="2"
+            :title="t('dmx.list.test')"
+            v-if="getAut('/kb/test')"
+          >
             <a-scrollbar
               class="rt-container-main"
               :style="{ height: documentHeight + 70 + 'px' }"
@@ -526,7 +539,11 @@
               <test ref="testForm"></test>
             </a-scrollbar>
           </a-tab-pane>
-          <a-tab-pane key="3" :title="t('dmx.list.disposition')">
+          <a-tab-pane
+            key="3"
+            :title="t('dmx.list.disposition')"
+            v-if="getAut('/kb/update')"
+          >
             <a-scrollbar
               class="rt-container-main"
               :style="{ height: documentHeight + 70 + 'px' }"
@@ -595,15 +612,16 @@
 </template>
 
 <script lang="ts" setup>
-import {
-  computed,
-  ref,
-  reactive,
-  watch,
-  nextTick,
-  onBeforeMount,
-  onMounted, onBeforeUnmount
-} from "vue";
+  import {
+    computed,
+    ref,
+    reactive,
+    watch,
+    nextTick,
+    onBeforeMount,
+    onMounted,
+    onBeforeUnmount,
+  } from 'vue';
   import { useI18n } from 'vue-i18n';
   import useLoading from '@/hooks/loading';
   import {
@@ -640,6 +658,7 @@
   import { documentHeight, parseTime } from '@/utils';
   import { deleteLlm } from '@/api/model';
   import { userModelState } from '@/store';
+  import { getUserResources } from '@/utils/auth';
 
   let modelStore = userModelState();
   const httpUrl = modelStore.hrefUrl;
@@ -697,9 +716,7 @@
     parser_idObj: {},
   });
   let tabs = ref([]);
-  let timer = null;// 瀹氭椂鍣�
-
-
+  let timer = null; // 瀹氭椂鍣�
 
   const selectTab = (index, item) => {
     selectedTab.value = index;
@@ -713,6 +730,12 @@
       ...basePagination,
     });
     getKbdetail(kbobj.id);
+  };
+
+  const getAut = (val) => {
+    const roleData = JSON.parse(getUserResources());
+    const roleBtn = roleData.map((item: any) => item.component);
+    return roleBtn.includes(val);
   };
 
   const basePagination: Pagination = {
@@ -844,19 +867,21 @@
         pagination.current = params.page;
         pagination.total = data.data.total;
 
-        if(timer){
+        if (timer) {
           clearInterval(timer);
         }
         // 瀹氭椂鍣ㄦ煡璇㈡枃妗�
         timer = setInterval(async () => {
-          let params = { ...basePagination, kb_id: kbobj.id }
+          let params = { ...basePagination, kb_id: kbobj.id };
           const data = await queryKbDocumentList(params);
           if (data.code == '0') {
-            parser_ids = kbtenantInfo.parser_ids.split(',').reduce((acc, pair) => {
-              const [key, value] = pair.split(':');
-              acc[key] = value;
-              return acc;
-            }, {});
+            parser_ids = kbtenantInfo.parser_ids
+              .split(',')
+              .reduce((acc, pair) => {
+                const [key, value] = pair.split(':');
+                acc[key] = value;
+                return acc;
+              }, {});
             // console.log(parser_ids, 'parser_ids');
             kbtenantInfo.parser_idObj = parser_ids;
             renderData.value = data.data.docs || [];
@@ -870,8 +895,6 @@
             // console.log(renderData.value, 'renderData');
           }
         }, 10000);
-
-
       }
     } catch (err) {
       // you can report use errorHandler or other
@@ -1212,9 +1235,6 @@
         kb_id: tabs.value[selectedTab.value].id,
         ...basePagination,
       });
-
-
-
     } else {
       // Message.error('瑙f瀽澶辫触');
       // row.run = '1';
@@ -1253,7 +1273,7 @@
   });
   onBeforeUnmount(() => {
     clearInterval(timer);
-  })
+  });
 </script>
 
 <style scoped lang="less">

--
Gitblit v1.8.0