Bläddra i källkod

将文件链接改为下载接口

yangdr 3 veckor sedan
förälder
incheckning
f0945389ff

+ 6 - 0
components.d.ts

@@ -24,6 +24,7 @@ declare module 'vue' {
     ElContainer: typeof import('element-plus/es')['ElContainer']
     ElDatePicker: typeof import('element-plus/es')['ElDatePicker']
     ElDialog: typeof import('element-plus/es')['ElDialog']
+    ElDivider: typeof import('element-plus/es')['ElDivider']
     ElDrawer: typeof import('element-plus/es')['ElDrawer']
     ElDropdown: typeof import('element-plus/es')['ElDropdown']
     ElDropdownItem: typeof import('element-plus/es')['ElDropdownItem']
@@ -41,6 +42,7 @@ declare module 'vue' {
     ElMenuItem: typeof import('element-plus/es')['ElMenuItem']
     ElMenuItemGroup: typeof import('element-plus/es')['ElMenuItemGroup']
     ElOption: typeof import('element-plus/es')['ElOption']
+    ElPageHeader: typeof import('element-plus/es')['ElPageHeader']
     ElPagination: typeof import('element-plus/es')['ElPagination']
     ElPopover: typeof import('element-plus/es')['ElPopover']
     ElRadio: typeof import('element-plus/es')['ElRadio']
@@ -59,6 +61,7 @@ declare module 'vue' {
     ElTabs: typeof import('element-plus/es')['ElTabs']
     ElTag: typeof import('element-plus/es')['ElTag']
     ElText: typeof import('element-plus/es')['ElText']
+    ElTooltip: typeof import('element-plus/es')['ElTooltip']
     ElTree: typeof import('element-plus/es')['ElTree']
     ElTreeSelect: typeof import('element-plus/es')['ElTreeSelect']
     ElUpload: typeof import('element-plus/es')['ElUpload']
@@ -84,4 +87,7 @@ declare module 'vue' {
     TheWelcome: typeof import('./src/components/TheWelcome.vue')['default']
     WelcomeItem: typeof import('./src/components/WelcomeItem.vue')['default']
   }
+  export interface GlobalDirectives {
+    vLoading: typeof import('element-plus/es')['ElLoadingDirective']
+  }
 }

+ 20 - 9
src/api/GraphApi.ts

@@ -80,6 +80,17 @@ export function getGraphs(params: any): Promise<StandardResponse> {
     return serverRequest(URL_GET_GRAPHS, data)
 }
 
+export function applyGraph(graph_id: number): Promise<StandardResponse> {
+    var data: RequestBody = {
+        id: getRequestId(),
+        action: 'confirm_graph',
+        params: [
+            { name: 'graph_id', value: graph_id },
+        ]
+    }
+    return serverRequest(URL_GET_GRAPHS, data)
+}
+
 export function searchNodes(keyword: string, graph_id: number, category: string = "any"): Promise<StandardResponse> {
     var data: RequestBody = {
         id: getRequestId(),
@@ -127,7 +138,7 @@ export function getNode(node_id: number, graph_id: number): Promise<StandardResp
 //     return serverRequest(URL_GET_NODE, data)
 // }
 export function updateNode(params: any): Promise<StandardResponse> {
-    console.log(params)
+    // console.log(params)
     var data: RequestBody = {
         id: getRequestId(),
         action: 'update_node',
@@ -176,7 +187,7 @@ export function getGraphSummary(params: any): Promise<StandardResponse> {
 }
 
 export function getGraphNodeSchema(params: any): Promise<StandardResponse> {
-    console.log(params)
+    // console.log(params)
     var data: RequestBody = {
         id: getRequestId(),
         action: 'get_nodes_schemas',
@@ -189,7 +200,7 @@ export function getGraphNodeSchema(params: any): Promise<StandardResponse> {
 
 
 export function getGraphEdgeSchema(params: any): Promise<StandardResponse> {
-    console.log(params)
+    // console.log(params)
     var data: RequestBody = {
         id: getRequestId(),
         action: 'get_edges_schemas',
@@ -214,7 +225,7 @@ export function getGraphStdSchemas(params: any): Promise<StandardResponse> {
 }
 
 export function reindexSchema(params: any): Promise<StandardResponse> {
-    console.log(params)
+    // console.log(params)
     var data: RequestBody = {
         id: getRequestId(),
         action: 'index_std_schema',
@@ -226,7 +237,7 @@ export function reindexSchema(params: any): Promise<StandardResponse> {
 }
 
 export function searchStdSchema(params: any): Promise<StandardResponse> {
-    console.log(params)
+    // console.log(params)
     var data: RequestBody = {
         id: getRequestId(),
         action: 'std_schema_search',
@@ -239,7 +250,7 @@ export function searchStdSchema(params: any): Promise<StandardResponse> {
     return serverRequest(URL_GET_STD_SCHEMA, data)
 }
 export function updateStdSchemaContent(params: any): Promise<StandardResponse> {
-    console.log("updateStdSchemaContent", params)
+    // console.log("updateStdSchemaContent", params)
     var data: RequestBody = {
         id: getRequestId(),
         action: 'std_schema_update_content',
@@ -251,7 +262,7 @@ export function updateStdSchemaContent(params: any): Promise<StandardResponse> {
     return serverRequest(URL_GET_STD_SCHEMA, data)
 }
 export function updateGraphNodeSchema(params: any): Promise<StandardResponse> {
-    console.log(params)
+    // console.log(params)
     var data: RequestBody = {
         id: getRequestId(),
         action: 'update_node_schema',
@@ -264,7 +275,7 @@ export function updateGraphNodeSchema(params: any): Promise<StandardResponse> {
     return serverRequest(URL_GET_SCHEMA, data)
 }
 export function updateGraphEdgeSchema(params: any): Promise<StandardResponse> {
-    console.log(params)
+    // console.log(params)
     var data: RequestBody = {
         id: getRequestId(),
         action: 'update_edge_schema',
@@ -278,7 +289,7 @@ export function updateGraphEdgeSchema(params: any): Promise<StandardResponse> {
 }
 
 export function createGraphCheckReport(params: any): Promise<StandardResponse> {
-    console.log(params)
+    // console.log(params)
     var data: RequestBody = {
         id: getRequestId(),
         action: 'create_graph_check_report',

+ 1 - 0
src/assets/css/common.less

@@ -2,6 +2,7 @@
 @import './reset.css';
 
 .hide-scrollbar {
+  overflow: hidden;
 
   &::--webkit--scrollbar {
     display: none

+ 2 - 16
src/components/FileViewer/FileViewer.vue

@@ -1,5 +1,5 @@
 <template>
-  <div class="document-viewer">
+  <div class="document-viewer" :style="props.fileType === 'pdf' ? { overflow: 'hidden' } : {}">
     <div class="mask"></div>
     <div ref="containerRef" class="container"
       :style="{ width: props.width + 'px', paddingTop: containerSize.offset + 'px' }">
@@ -79,7 +79,7 @@ const handleResize = () => {
   containerSize.value = {
     offset: topRef.value.offsetHeight,
     width: containerRef.value.offsetWidth,
-    height: containerRef.value.offsetHeight - topRef.value.offsetHeight - 3
+    height: containerRef.value.offsetHeight - topRef.value.offsetHeight
   }
 }
 
@@ -132,7 +132,6 @@ onBeforeUnmount(() => {
     bottom: 0;
     right: 0;
     z-index: 50;
-
     background-color: rgb(128, 128, 128, 0.8);
     opacity: 0.5;
   }
@@ -150,22 +149,11 @@ onBeforeUnmount(() => {
     &:deep(.vue-office-pptx) {
       height: auto;
 
-      // .slide-background,
-      // .slide-wrapper,
-      // .slide-master-wrapper,
-      // .slide-layout-wrapper,
-      // .pptx-preview-slide-wrapper {
-      //   display: grid;
-      // }
-
       .vue-office-pptx-main {
         height: auto !important;
 
-
         .pptx-preview-wrapper {
           height: auto !important;
-
-
         }
       }
     }
@@ -175,10 +163,8 @@ onBeforeUnmount(() => {
       clear: both;
       padding: 5px 10px;
       position: fixed;
-      // width: 100%;
       z-index: 65;
       top: 0px;
-      // bottom: -1000000000px;
       display: flex;
       justify-content: end;
       position: -webkit-sticky;

+ 0 - 4
src/components/FileViewer/PdfViewer.vue

@@ -11,9 +11,5 @@ import { pdfjsAddr } from '@/utils/config';
 <style lang="less" scoped>
 iframe {
   width: 100%;
-  // height: 1000px;
-  // box-sizing: margin-box;
-  margin: 0px;
-  padding: 0px;
 }
 </style>

+ 3 - 3
src/components/LayoutHeader.vue

@@ -62,7 +62,7 @@ user.value = {
 
 // 机构相关
 const orgList = ref([])
-const currentOrg = ref(getSessionVar('org_id') || '') // 当前机构id
+let currentOrg = ref(getSessionVar('org_id') || '') // 当前机构id
 
 // 获取机构列表
 const fetchOrgList = async () => {
@@ -72,8 +72,8 @@ const fetchOrgList = async () => {
   // 默认选中第一个
   const res = await proxy.$http.get('/open-platform/sys/currSURO')
   // console.log('当前机构11:', res)
-  currentOrg.value = res
-  saveSessionVar('org_id', res)
+  currentOrg.value = +res
+  saveSessionVar('org_id', +res)
 
   // console.log('机构列表:', orgList.value)
   // console.log('当前机构:', currentOrg.value)

+ 24 - 11
src/dialogs/OCRDialog.vue

@@ -25,7 +25,7 @@
       <el-button type="primary" @click="handleConfirm">确 定</el-button>
       <el-button @click="dialogFormVisible = false">取 消</el-button>
     </footer>
-    <div class="knowledge-base" v-show="knowledgeBase.visible">
+    <div class="knowledge-base" v-show="knowledgeBase.visible" v-loading="loading" element-loading-text="导入中...">
       <div class="topbar">
         <span @click="knowledgeBase.visible = false" class="close-knowledge-base"><el-icon>
             <Close />
@@ -119,7 +119,7 @@
                   <template #default="{ row }">
                     <div class="operation">
                       <el-button link type="primary" :disabled="!row.status"
-                        @click="handleImportFiles([toRaw(row)])">导入</el-button>
+                        @click="handleImportFiles([{ ...row, file_url: `/open-platform/files/${row.id}/download` }])">导入</el-button>
                     </div>
                   </template>
                 </el-table-column>
@@ -155,6 +155,7 @@ const formRef = ref()
 const dialogFormVisible = ref(false)
 const formLabelWidth = ref('120px')
 
+let loading = ref<boolean>(false)
 const paginationData = ref<any>({
   currentPage: 1,
   pageSizes: [10, 50, 100, 1000, 10000],
@@ -300,7 +301,12 @@ async function handleAllImport() {
     })
     const { data, code } = res
     if (code === 200) {
-      handleImportFiles(data.list.filter((it: any) => it.status))
+      let filterData = data.list.filter((it: any) => it.status)
+      filterData = filterData.map((it: any) => {
+        it.file_url = `/open-platform/files/${it.id}/download`
+        return it
+      })
+      handleImportFiles(filterData)
     }
 
   } catch (e) {
@@ -356,10 +362,14 @@ function handleSelectable(row: any, index: number) {
   return row.status
 }
 function handleSelectedImport() {
-  const selectionRows = KBTableRef.value.getSelectionRows()
+  const selectionRows = KBTableRef.value.getSelectionRows().map((it: any) => {
+    let copyIt: any = JSON.parse(JSON.stringify(it))
+    copyIt.file_url = `/open-platform/files/${copyIt.id}/download`
+    return copyIt
+  })
   if (selectionRows.length == 0) return;
-  handleImportFiles(toRaw(selectionRows))
-  knowledgeBase.value.visible = false
+  handleImportFiles(selectionRows)
+
   // console.log(SelectionRows)
 }
 // 使用原生方法计算文件的hash值,该方法兼容性较差
@@ -493,11 +503,12 @@ async function calculateFileHash(file: File) {
   });
 }
 
-function handleImportFiles(filesList: any[]) {
-  filesList.forEach(async (fileInfo) => {
-    const { file_name, minio_url } = fileInfo;
+async function handleImportFiles(filesList: any[]) {
+  loading.value = true
+  await Promise.allSettled(filesList.map(async (fileInfo) => {
+    const { file_name, minio_url, file_url } = fileInfo;
     try {
-      const response = await axios.get(minio_url, { responseType: 'blob' });
+      const response = await axios.get(file_url, { responseType: 'blob' });
       const rawFile = new File([response.data], file_name, { type: response.data.type });
       const fileHash = await calculateFileHash(rawFile);
 
@@ -526,7 +537,9 @@ function handleImportFiles(filesList: any[]) {
       });
       console.log(error);
     }
-  });
+  }))
+  loading.value = false
+  knowledgeBase.value.visible = false
 }
 
 const handleSuccess = (response: any, file: any, fileList: any) => {

+ 1 - 2
src/utils/http.js

@@ -2,7 +2,7 @@ import axios from 'axios'
 import { ElMessage } from 'element-plus'
 import { getSessionVar, clearSessionVar } from "@/utils/session";
 import { useRouter } from "vue-router"
-
+const router = useRouter();
 const NETWORK_ERROR = '网络错误,请稍后重试!'
 // 创建 axios 实例
 const http = axios.create({
@@ -52,7 +52,6 @@ http.interceptors.response.use(
   (error) => {
     // 处理未登录
     if (error.response.status == 401) {
-      const router = useRouter();
       clearSessionVar()
       router.push("/login")
       return null

+ 10 - 5
src/views/GraphView.vue

@@ -57,7 +57,7 @@ import {
     serverStreamRequest,
 } from '@/api/AgentApi'
 import type { JobData, RequestBody, GraphData } from '@/api/AgentApi'
-import { getGraphs } from '@/api/GraphApi'
+import { getGraphs, applyGraph } from '@/api/GraphApi'
 
 import { getSessionVar } from '@/utils/session'
 //从路由参数中获取队列ID
@@ -81,8 +81,7 @@ function handleStreamTest() {
     var data: RequestBody = {
         id: "1",
         action: 'search_nodes',
-        params: [
-        ]
+        params: []
     }
     serverStreamRequest("/kb/stream", data)
 }
@@ -110,8 +109,14 @@ function handleCurrentPageChange(page: number) {
     loadGraphs()
 }
 function handleApply(record: GraphData) {
-    // console.log("handleApply", record, record.name)
-    loadGraphs()
+    applyGraph(record.graph_id).then((res: any) => {
+        const { code } = res
+        if (code === 200) {
+            loadGraphs()
+        }
+    }).catch((err: any) => {
+        console.log(err)
+    })
 }
 onMounted(() => {
     loadGraphs()

+ 26 - 14
src/views/KMPlatform/KnowledgeBase/KM/KnowledgeManagement.vue

@@ -35,11 +35,10 @@
                   <span class="icon-area">
                     <i :class="`${row.file_type}-icon file-icon`"></i>
                   </span>
-                  <span
-                    @click="operationPermissions['a-7'] ? handleViewFile(row.minio_url, row.file_type, row.file_name) : null"
-                    class="text-area">
+                  <el-text line-clamp="1" class="text-area"
+                    @click="operationPermissions['a-7'] ? handleViewFile(row) : null">
                     {{ row.file_name }}
-                  </span>
+                  </el-text>
                 </div>
               </template>
             </el-table-column>
@@ -57,7 +56,7 @@
               </template>
             </el-table-column>
             <el-table-column prop="created_at" label="上传时间" width="155" />
-            <el-table-column prop="status" label="状态">
+            <el-table-column prop="status" label="状态" width="107">
               <template #default="{ row, $index }">
                 <div class="status">
                   <span v-if="row.status">
@@ -81,11 +80,11 @@
               <template #default="{ row }">
                 <div style="text-align: center;">
                   <i class="document-download-icon" :disabled="row.status ? true : false"
-                    @click="handleDownloadFile(row.minio_url, row.file_name, row.status)"></i>
+                    @click="handleDownloadFile(row)"></i>
                 </div>
               </template>
             </el-table-column>
-            <el-table-column fixed="right" label="操作">
+            <el-table-column fixed="right" label="操作" min-width="85">
               <template #default="{ row }">
                 <div class="operation">
                   <el-button link type="primary" v-if="operationPermissions['a-10']"
@@ -221,15 +220,19 @@ function handleEditFile(data) {
   editKBFileData.value.data = data;
 }
 
-const handleViewFile = (url, type, name) => {
+const handleViewFile = (fileData) => {
+  const { minio_url, file_type, file_name, id } = fileData
+  const url = `/open-platform/files/${id}/download`
   viewFileData.value.show = true;
   viewFileData.value.url = url;
-  viewFileData.value.type = type
-  viewFileData.value.name = name
+  viewFileData.value.type = file_type
+  viewFileData.value.name = file_name
   // console.log(viewFileData.value)
 }
-function handleDownloadFile(file_url, file_name, status = true) {
+function handleDownloadFile(fileData) {
+  const { minio_url, file_name, status, id } = fileData
   if (status) {
+    const file_url = `/open-platform/files/${id}/download`
     saveAs(file_url, file_name)
   }
 }
@@ -426,14 +429,23 @@ onMounted(() => {
       }
 
       .list-name {
-        white-space: nowrap;
-        text-overflow: ellipsis;
-        display: inline;
+        // white-space: nowrap;
+        // text-overflow: ellipsis;
+        display: flex;
+        align-items: center;
 
         .text-area,
         .icon-area {
           vertical-align: bottom;
         }
+
+        .icon-area {
+          flex: 0 0 auto;
+        }
+
+        .text-area {
+          flex: 1 1 auto;
+        }
       }
 
       .status {

+ 1 - 1
src/views/KMPlatform/Layout.vue

@@ -26,7 +26,7 @@ function beforeEnter() {
   $('#app').addClass('hide-scrollbar')
   setTimeout(() => {
     $('#app').removeClass('hide-scrollbar')
-  }, 2000)
+  }, 1000)
 }
 function afterLeave() {
   // $('#app').removeClass('hide-scrollbar')