From b308f037bb6f1365c51b367ed4db5f8372febc90 Mon Sep 17 00:00:00 2001
From: liudong <liudong>
Date: 星期五, 26 七月 2024 19:09:42 +0800
Subject: [PATCH] 知识库页面接口调用开发

---
 src/views/dmx/knowledgeLib/index.vue |   53 ++++++++++++++++++++++++++++++++++++++++-------------
 1 files changed, 40 insertions(+), 13 deletions(-)

diff --git a/src/views/dmx/knowledgeLib/index.vue b/src/views/dmx/knowledgeLib/index.vue
index 7531a6f..e079595 100644
--- a/src/views/dmx/knowledgeLib/index.vue
+++ b/src/views/dmx/knowledgeLib/index.vue
@@ -16,10 +16,10 @@
               class="tab"
               v-for="(tab, index) in tabs"
               :key="index"
-              @click="selectTab(index)"
+              @click="selectTab(index,tab)"
               :class="{ 'active': selectedTab === index }"
             >
-              {{ tab }}
+              {{ tab.name }}
             </div>
           </div>
         </div>
@@ -271,10 +271,10 @@
 </template>
 
 <script lang="ts" setup>
-  import { computed, ref, reactive, watch, nextTick } from 'vue';
+import { computed, ref, reactive, watch, nextTick, onBeforeMount } from "vue";
   import { useI18n } from 'vue-i18n';
   import useLoading from '@/hooks/loading';
-  import { queryPolicyList, PolicyRecord, PolicyParams } from '@/api/list';
+  import { queryKbList, PolicyRecord, PolicyParams } from '@/api/kbList';
   import { Pagination } from '@/types/global';
   import type { SelectOptionData } from '@arco-design/web-vue/es/select/interface';
   import type { TableColumnData } from '@arco-design/web-vue/es/table/interface';
@@ -312,10 +312,11 @@
   let visible = ref(false)
   let detailsShow = ref(false)
   let selectedTab = ref(0)
-  let tabs = reactive(['娉曞緥鐭ヨ瘑搴�', '鏀垮姟鐭ヨ瘑搴�', '鍖诲鐭ヨ瘑搴�', '鍏朵粬鐭ヨ瘑搴�'])
+  let tabs = ref([])
 
-  const  selectTab = (index) => {
+  const  selectTab = (index,item) => {
     selectedTab.value= index;
+    console.log(item.id);
   }
 
   const basePagination: Pagination = {
@@ -418,15 +419,16 @@
     },
   ]);
   const fetchData = async (
-    params: PolicyParams = { current: 1, pageSize: 20 }
+    params = { page: 1, page_size: 20 }
   ) => {
     setLoading(true);
     try {
-      const { data } = await queryPolicyList(params);
-      renderData.value = data.list;
-      console.log(renderData, 'renderData');
-      pagination.current = params.current;
-      pagination.total = data.total;
+      const { data } = await queryKbList(params);
+      console.log(data, 'data');
+      // renderData.value = data.list;
+      // console.log(renderData, 'renderData');
+      // pagination.current = params.current;
+      // pagination.total = data.total;
     } catch (err) {
       // you can report use errorHandler or other
     } finally {
@@ -449,7 +451,27 @@
     fetchData({ ...basePagination, current });
   };
 
-  fetchData();
+  const knowledgeData = async (
+    params = { page: 1, page_size: 20 }
+  ) => {
+    setLoading(true);
+    try {
+      const { data } = await queryKbList(params);
+      console.log(data, 'data');
+      tabs.value = data;
+      console.log(tabs.value, 'tabs');
+      // fetchData()
+      // renderData.value = data.list;
+      // console.log(renderData, 'renderData');
+      // pagination.current = params.current;
+      // pagination.total = data.total;
+    } catch (err) {
+      // you can report use errorHandler or other
+    } finally {
+      setLoading(false);
+    }
+  };
+
   const reset = () => {
     formModel.value = generateFormModel();
   };
@@ -540,6 +562,11 @@
     },
     { deep: true, immediate: true }
   );
+
+  onBeforeMount(()=>{
+    knowledgeData()
+  })
+
 </script>
 
 <script lang="ts">

--
Gitblit v1.8.0