liudong
2024-07-26 b308f037bb6f1365c51b367ed4db5f8372febc90
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">