|
@@ -0,0 +1,80 @@
|
|
|
+<template>
|
|
|
+ <div class="app-container">
|
|
|
+ <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" label-width="68px">
|
|
|
+ <el-form-item :label="name" prop="name">
|
|
|
+ <el-input v-model="queryParams.name" placeholder="请输入" clearable @keyup.enter.native="handleQuery" />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item>
|
|
|
+ <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
|
|
|
+ <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+ <Graph ref="charts" :chartList="chartData" />
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+
|
|
|
+ <script>
|
|
|
+ import Graph from "@/components/Echarts/graph";
|
|
|
+ import { getRelationByLikeName } from "@/api/knowledge/search";
|
|
|
+
|
|
|
+ export default {
|
|
|
+ name: "GranphSearch",
|
|
|
+ dicts: ["graph_search_length"],
|
|
|
+ components: { Graph },
|
|
|
+ props: {
|
|
|
+ name: {
|
|
|
+ type: String,
|
|
|
+ required: true
|
|
|
+ },
|
|
|
+ },
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ queryParams: {
|
|
|
+ name: "",
|
|
|
+ },
|
|
|
+ chartData: {
|
|
|
+ seriesData: [],
|
|
|
+ linksData: [],
|
|
|
+ },
|
|
|
+ };
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ handleQuery() {
|
|
|
+ if (!this.queryParams.name) {
|
|
|
+ this.$message.error('请输入一个关键字');
|
|
|
+ return
|
|
|
+ }
|
|
|
+ getRelationByLikeName(this.queryParams).then((resp) => {
|
|
|
+ let respData = resp.data
|
|
|
+ let seriesData = []
|
|
|
+ let linksData = []
|
|
|
+ for (let item of respData.data) {
|
|
|
+ seriesData.push(
|
|
|
+ { name: item.name }
|
|
|
+ )
|
|
|
+ }
|
|
|
+ for (let link of respData.links) {
|
|
|
+ linksData.push(
|
|
|
+ {
|
|
|
+ source: link.fromName,
|
|
|
+ target: link.toName,
|
|
|
+ label: {
|
|
|
+ show: true, // 是否显示line的文字
|
|
|
+ formatter: link.name // line的文字
|
|
|
+ },
|
|
|
+ }
|
|
|
+ )
|
|
|
+ }
|
|
|
+ this.chartData = {
|
|
|
+ seriesData,
|
|
|
+ linksData,
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+ resetQuery() {
|
|
|
+ this.resetForm("queryForm");
|
|
|
+ },
|
|
|
+ },
|
|
|
+ };
|
|
|
+ </script>
|
|
|
+
|