GraphView.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. <template>
  2. <el-row>
  3. <span style="text-align: right;">
  4. <h2>知识图谱</h2>
  5. </span>
  6. </el-row>
  7. <el-row style="margin:15px;">
  8. <el-button @click="handleRefreshTable">刷新</el-button>
  9. <el-button @click="handleStreamTest">Stream</el-button>
  10. </el-row>
  11. <el-row>
  12. <template v-for="(index) in pageData.records" :key="index">
  13. <el-card shadow="hover" style="width: 300px; margin: 10px;">
  14. <div slot="header" style="border-bottom: 1px solid #EFEFEF; height: 50px; clear: both;">
  15. <span>#{{ index.graph_id }}</span>
  16. <el-button @click="handleViewGraph(index)" style="float: right; width:75px; padding: 3px 0"
  17. type="">查看</el-button>
  18. </div>
  19. <div class="card-content">
  20. <div style="margin-top:15px;font-size:16px; clear: both;">
  21. {{ index.name }}
  22. <el-button @click="handleApply(index)" type="primary"
  23. style="float: right; width:75px; padding: 3px 0;">应用</el-button>
  24. </div>
  25. </div>
  26. </el-card>
  27. </template>
  28. </el-row>
  29. <el-row style="margin-top:30px;">
  30. <el-pagination style="margin-left: auto;" background layout="prev, pager, next" :total="pageData.total"
  31. :page-size="pageData.page_size" @current-change="handleCurrentPageChange"
  32. :current-page.sync="pageData.page">
  33. </el-pagination>
  34. </el-row>
  35. </template>
  36. <script setup lang="ts">
  37. import { ref, onMounted, watch } from 'vue'
  38. import { useRoute, useRouter } from 'vue-router'
  39. import {
  40. getJob,
  41. getJobs,
  42. getQueue,
  43. browseJobFile,
  44. getJobStatus,
  45. getJobStatusTag,
  46. JobSatus,
  47. deleteJob,
  48. updateJob,
  49. updateJobStatus,
  50. serverStreamRequest,
  51. } from '@/api/AgentApi'
  52. import type { JobData, RequestBody, GraphData } from '@/api/AgentApi'
  53. import { getGraphs } from '@/api/GraphApi'
  54. import { getSessionVar } from '@/utils/session'
  55. //从路由参数中获取队列ID
  56. interface PageData {
  57. page: number;
  58. pages: number;
  59. page_size: number;
  60. total: number;
  61. records: GraphData[];
  62. }
  63. const pageData = ref<PageData>({ page: 1, pages: 1, page_size: 10, total: 0, records: [] })
  64. const route = useRoute()
  65. const router = useRouter()
  66. const handleRefreshTable = () => {
  67. pageData.value.page = 1
  68. loadGraphs()
  69. }
  70. function handleStreamTest() {
  71. var data: RequestBody = {
  72. id: "1",
  73. action: 'search_nodes',
  74. params: [
  75. ]
  76. }
  77. serverStreamRequest("/kb/stream", data)
  78. }
  79. function formatStatus(status: number) {
  80. return getJobStatus(status)
  81. }
  82. function handleViewGraph(graph: GraphData) {
  83. if (graph == null) {
  84. return
  85. }
  86. router.push({ name: `graph-mgr`, params: { id: graph.graph_id } })
  87. }
  88. function loadGraphs() {
  89. getGraphs({ page: pageData.value.page, page_size: pageData.value.page_size }).then((res: any) => {
  90. pageData.value.page = res.meta.page
  91. pageData.value.pages = res.meta.pages
  92. pageData.value.total = res.meta.total
  93. pageData.value.records = res.records
  94. })
  95. }
  96. function handleCurrentPageChange(page: number) {
  97. pageData.value.page = page
  98. loadGraphs()
  99. }
  100. function handleApply(record: GraphData) {
  101. // console.log("handleApply", record, record.name)
  102. loadGraphs()
  103. }
  104. onMounted(() => {
  105. loadGraphs()
  106. })
  107. </script>
  108. <style lang="less" scoped>
  109. .prop_header {
  110. font-weight: bold;
  111. margin-top: 10px;
  112. margin-bottom: 5px;
  113. }
  114. </style>