Kaynağa Gözat

同步代码

yangdr 1 ay önce
ebeveyn
işleme
47704976f1

+ 4 - 0
src/css/home.less

@@ -761,6 +761,10 @@
   }
 }
 
+.el-tabs__item {
+  width: auto !important;
+}
+
 // 调整el-autocomplete建议框的宽度,不隐藏文字
 .el-popper[x-placement^=bottom] {
   width: auto !important;

+ 22 - 0
src/css/selfKnowledgeGraph.less

@@ -0,0 +1,22 @@
+#app {
+  width: 100%;
+  height: 100%;
+
+  .kg-list {
+    li {
+      display: flex;
+
+      .index {
+        flex: 0 0 50px;
+      }
+
+      .name {
+        flex: 0 0 100px;
+      }
+
+      .op {
+        flex: 0 0 50px;
+      }
+    }
+  }
+}

+ 45 - 0
src/html/selfKnowledgeGraph.html

@@ -0,0 +1,45 @@
+<!DOCTYPE html>
+<html lang="zh-CN">
+
+<head>
+  <meta charset="UTF-8">
+  <meta name="viewport" content="width=device-width, initial-scale=1.0">
+  <title>自构建图谱查询</title>
+  <link rel="stylesheet" href="./elementUI/theme-chalk_2.7.2/index.css">
+  <!-- <link rel="stylesheet" href="./elementUI/theme-chalk/index.css"> -->
+  <style>
+
+  </style>
+
+</head>
+
+<body>
+  <div id="app" v-cloak>
+    <div v-show="!isShowKG">
+      <el-table :data="listData" style="width: 100%;" border class="kg-list">
+        <el-table-column type="index" :index="1" align="center" label="序号" width="100"></el-table-column>
+        <el-table-column prop="graph_name" align="center" label="名称"></el-table-column>
+        <el-table-column align="center" prop="nodeNum" sortable label="实体数量"></el-table-column>
+        <el-table-column prop="relationType" align="center" sortable label="相关关系类型"></el-table-column>
+        <el-table-column prop="relationNum" align="center" sortable label="相关关系数量"></el-table-column>
+        <li>
+          <div class="index">序号</div>
+          <div class="name">名称</div>
+          <div class="op">操作</div>
+        </li>
+
+        <li v-for="(item,idx) in listData">
+          <div class="index">{{idx+1}}</div>
+          <div class="name">{{item.graph_name}}</div>
+          <div class="op"><span @click="handleView(item)">查看</span></div>
+        </li>
+      </el-table>
+    </div>
+    <iframe v-show="isShowKG" :src="kgUrl" style="width: 100%;height: 100%;" frameborder="0"></iframe>
+  </div>
+</body>
+<script>
+
+</script>
+
+</html>

+ 2 - 1
src/js/api.js

@@ -27,7 +27,8 @@ const api = {
   deleteEntityProperty: "/api/property/deleteEntityProperty", //删除实体属性
 
   getCountList: "/api/kg/count/getCountList",
-  getCountInfo: "/api/kg/count/getCountInfo"
+  getCountInfo: "/api/kg/count/getCountInfo",
+  userGraphs: "/open-platform/kb/user_sub_graphs",
 };
 $(".goto-homeStatic").on("click", function () {
   window.location.href = "http://192.168.2.121:5666" + $(this).attr("link");

+ 4 - 4
src/js/graphMap.js

@@ -24,10 +24,10 @@ function getGraph(val, type) {
 
             if (res.data.code === 200) {
                 let records = res.data.records[0].records || []
-                for (let i = 0; i < records.node.length; i++) {
-                    records.node[i].label = records.node[i].name
-                    records.node[i].name = i + 1
-                }
+                // for (let i = 0; i < records.node.length; i++) {
+                //     records.node[i].label = records.node[i].name
+                //     records.node[i].name = (i + 1).toString()
+                // }
                 // console.log("getSelfGraph", records.node)
                 // select_type = select_type_noSearch
                 $('#searchInp').val(val)

+ 2 - 1
src/js/home.js

@@ -153,7 +153,8 @@ const vm = new Vue({
             },
             {
               id: "selfKnowledgeGraph",
-              url: "./knowledgeGraph.html?self=true&input=头痛&label=症状",
+              // url: "./knowledgeGraph.html?self=true&input=头痛&label=症状",
+              url: "./selfKnowledgeGraph.html",
               title: '自构建图谱查询',
               children: null
             },

+ 77 - 0
src/js/selfKnowledgeGraph.js

@@ -0,0 +1,77 @@
+require("../css/selfKnowledgeGraph.less")
+require("./../css/common.less");
+// require("element-ui/lib/theme-chalk/index.css")
+const { post, get, api, getUrlArgObject } = require('./api.js');
+const $ = require('jquery')
+const Vue = require("vue/dist/vue.esm.js").default;
+// const ElementUI = require("../public/elementUI/index.js");
+
+const ElementUI = require("element-ui/lib/index.js");
+// import UmyUi from 'umy-ui'
+// Vue.use(UmyUi);
+
+Vue.use(ElementUI)
+
+const vm = new Vue({
+  el: "#app",
+  name: "selfKnowledgeGraph",
+  data() {
+    return {
+      isShowKG: false,
+      currentKnowledgeGraph: {
+        label: '症状',
+        name: "头痛"
+      },
+      listData: [
+        {
+          id: 1,
+          title: "测试图1",
+          label: '症状',
+          name: "头痛"
+        },
+        {
+          id: 2,
+          title: "测试图2",
+          label: '症状',
+          name: "头痛"
+        }
+      ]
+    }
+  },
+  methods: {
+    handleView(data) {
+      // Object.assign(this.currentKnowledgeGraph, { ...data })
+      this.currentKnowledgeGraph.label = data.label
+      this.currentKnowledgeGraph.name = data.name
+      this.isShowKG = true
+    },
+    getUserGraphs: function () {
+      get(api.userGraphs, {
+        user_id: localStorage.getItem("userId") ? +JSON.parse(localStorage.getItem("userId")) : -1,
+        pageNo: 1,
+        pageSize: 10,
+      }).then(res => {
+        const { code, records } = res.data
+        if (code === 200) {
+          this.listData = records
+        }
+      }).catch(e => {
+        console.log(e)
+      })
+    }
+  },
+  computed: {
+    kgUrl() {
+      return `./knowledgeGraph.html?self=true&input=${this.currentKnowledgeGraph.name}&label=${this.currentKnowledgeGraph.label}`;
+    }
+  },
+  watch: {
+
+  },
+  mounted() {
+    this.getUserGraphs()
+  },
+  beforeDestroy() {
+
+  },
+})

+ 14 - 1
webpack.config.js

@@ -22,6 +22,7 @@ module.exports = {
     home: path.resolve(__dirname, 'src/js', 'home.js'),
     knowledgeUpdate: path.resolve(__dirname, 'src/js', 'knowledgeUpdate.js'),
     graphDataStatistics: path.resolve(__dirname, 'src/js', 'graphDataStatistics.js'),
+    selfKnowledgeGraph: path.resolve(__dirname, 'src/js', 'selfKnowledgeGraph.js'),
     vendor: 'lodash'// 多个页面所需的公共库文件,防止重复打包带入
   },
   output: {
@@ -60,7 +61,19 @@ module.exports = {
         collapseWhitespace: true //删除空白符与换行符
       }
     }),
-
+    new HtmlWebpackPlugin({
+      title: '自构建图谱查询',
+      template: path.resolve(__dirname, 'src/html', 'selfKnowledgeGraph.html'),
+      filename: 'selfKnowledgeGraph.html',
+      chunks: ['selfKnowledgeGraph', 'vendor', 'common'],
+      inject: true,
+      hash: true, //防止缓存
+      minify: {
+        removeAttributeQuotes: true, //压缩 去掉引号
+        removeComments: true, //移除HTML中的注释
+        collapseWhitespace: true //删除空白符与换行符
+      }
+    }),
     new HtmlWebpackPlugin({
       title: '登录界面',
       template: path.resolve(__dirname, 'src/html', 'login.html'),