Commit a5189eeb authored by 郭铭瑶's avatar 郭铭瑶 🤘

搜索系统改为下拉&点击后直接显示下级&去掉不需要元素

parent 97113153
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
{{ `${n.name}(${n.val})` }} {{ `${n.name}(${n.val})` }}
</n-tag> </n-tag>
</n-space> </n-space>
<n-space> <!-- <n-space>
<n-tag <n-tag
v-for="n in linkList" v-for="n in linkList"
:key="n.name" :key="n.name"
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
> >
{{ `${n.name}(${n.val})` }} {{ `${n.name}(${n.val})` }}
</n-tag> </n-tag>
</n-space> </n-space> -->
</div> </div>
</div> </div>
</template> </template>
...@@ -70,12 +70,12 @@ export default { ...@@ -70,12 +70,12 @@ export default {
let instance = null let instance = null
const container = ref(null) const container = ref(null)
const menuData = [ const menuData = [
{ // {
key: 'branch', // key: 'branch',
icon: branch, // icon: branch,
action: (d) => ctx.emit('branch', d), // action: (d) => ctx.emit('branch', d),
title: '分支', // title: '分支',
}, // },
{ {
key: 'link', key: 'link',
icon: link, icon: link,
...@@ -108,6 +108,9 @@ export default { ...@@ -108,6 +108,9 @@ export default {
ctx.emit('del-link', d) ctx.emit('del-link', d)
} }
} }
const showBranch = (d) => {
ctx.emit('branch', d)
}
function init() { function init() {
if (!container.value) return if (!container.value) return
...@@ -141,7 +144,8 @@ export default { ...@@ -141,7 +144,8 @@ export default {
menuData, menuData,
colorList, colorList,
setCurNode, setCurNode,
handleLinkClick handleLinkClick,
showBranch
) )
} }
setLegend(data) setLegend(data)
...@@ -153,7 +157,11 @@ export default { ...@@ -153,7 +157,11 @@ export default {
watch( watch(
() => props.data, () => props.data,
() => init(), (cur, past) => {
if (JSON.stringify(cur) !== JSON.stringify(past)) {
init()
}
},
{ immediate: true } { immediate: true }
) )
......
...@@ -31,7 +31,16 @@ ...@@ -31,7 +31,16 @@
placeholder="请选择节点类型" placeholder="请选择节点类型"
:options="nodeOptions" :options="nodeOptions"
/> />
<n-select
v-if="searchType === 'System'"
v-model:value="searchKey"
placeholder="请选择"
:options="systemOptions"
:on-clear="clear"
clearable
/>
<n-input <n-input
v-else
v-model:value="searchKey" v-model:value="searchKey"
placeholder="请输入关键词..." placeholder="请输入关键词..."
clearable clearable
...@@ -40,7 +49,7 @@ ...@@ -40,7 +49,7 @@
/> />
<n-button type="primary" ghost @click="search">搜索</n-button> <n-button type="primary" ghost @click="search">搜索</n-button>
</n-input-group> </n-input-group>
<n-space v-if="!isNarrow"> <!-- <n-space v-if="!isNarrow">
<n-tag v-show="nodeVal" size="small" round :color="color"> <n-tag v-show="nodeVal" size="small" round :color="color">
{{ switchName(nodeVal && nodeVal._label_key) }} {{ switchName(nodeVal && nodeVal._label_key) }}
</n-tag> </n-tag>
...@@ -54,12 +63,12 @@ ...@@ -54,12 +63,12 @@
> >
{{ name }} {{ name }}
</n-button> </n-button>
</n-space> </n-space> -->
</div> </div>
</template> </template>
<script> <script>
import { defineComponent, ref, computed } from 'vue' import { defineComponent, ref, computed, watch } from 'vue'
export default defineComponent({ export default defineComponent({
name: 'Footer', name: 'Footer',
...@@ -74,6 +83,10 @@ export default defineComponent({ ...@@ -74,6 +83,10 @@ export default defineComponent({
type: Object, type: Object,
default: () => {}, default: () => {},
}, },
options: {
type: Array,
default: () => [],
},
}, },
emits: ['set', 'add', 'search'], emits: ['set', 'add', 'search'],
setup(props, ctx) { setup(props, ctx) {
...@@ -191,6 +204,12 @@ export default defineComponent({ ...@@ -191,6 +204,12 @@ export default defineComponent({
const isNarrow = computed(() => { const isNarrow = computed(() => {
return window.innerHeight / window.innerWidth > 0.75 return window.innerHeight / window.innerWidth > 0.75
}) })
const systemOptions = computed(() => props.options)
watch(
() => searchType.value,
() => (searchKey.value = null)
)
return { return {
curKey, curKey,
setKey, setKey,
...@@ -205,6 +224,7 @@ export default defineComponent({ ...@@ -205,6 +224,7 @@ export default defineComponent({
nodeOptions, nodeOptions,
switchName, switchName,
isNarrow, isNarrow,
systemOptions,
} }
}, },
}) })
...@@ -221,6 +241,7 @@ export default defineComponent({ ...@@ -221,6 +241,7 @@ export default defineComponent({
margin-top 4px margin-top 4px
flex-wrap wrap flex-wrap wrap
.search-bar .search-bar
flex 1 // flex 1
margin 0 2% margin 0 2%
max-width 40%
</style> </style>
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
style="grid-area: footer" style="grid-area: footer"
:node="curNode" :node="curNode"
:data="graphData" :data="graphData"
:options="systemOptions"
@add="openSubjectDrawer" @add="openSubjectDrawer"
@set="setLabelKey" @set="setLabelKey"
@search="searchNodes" @search="searchNodes"
...@@ -420,10 +421,14 @@ const searchNodes = (type, key) => { ...@@ -420,10 +421,14 @@ const searchNodes = (type, key) => {
fetchSubjects() fetchSubjects()
return return
} }
let params = { type, nodeName: key }
if (type === 'System') {
params = { type, nodeId: key }
}
ajax ajax
.get({ .get({
url: api.GET_NODES, url: api.GET_NODES,
params: { type, nodeName: key }, params,
}) })
.then((res) => { .then((res) => {
graphData.value = res.data.content graphData.value = res.data.content
......
...@@ -133,11 +133,13 @@ export default class RelationGraph { ...@@ -133,11 +133,13 @@ export default class RelationGraph {
menuData, menuData,
colorList, colorList,
setCurNode, setCurNode,
handleLinkClick handleLinkClick,
showBranch
) { ) {
this.menuData = menuData this.menuData = menuData
this.setCurNode = setCurNode this.setCurNode = setCurNode
this.handleLinkClick = handleLinkClick this.handleLinkClick = handleLinkClick
this.showBranch = showBranch
const mapW = selector.offsetWidth const mapW = selector.offsetWidth
const mapH = selector.offsetHeight const mapH = selector.offsetHeight
...@@ -489,6 +491,7 @@ export default class RelationGraph { ...@@ -489,6 +491,7 @@ export default class RelationGraph {
d d
) )
} }
this.showBranch(d)
if (this.curHighlightKey) { if (this.curHighlightKey) {
this.setHighlights(this.curHighlightKey) this.setHighlights(this.curHighlightKey)
} }
...@@ -650,7 +653,7 @@ export default class RelationGraph { ...@@ -650,7 +653,7 @@ export default class RelationGraph {
this.SVG.selectAll('circle') this.SVG.selectAll('circle')
.filter((d) => this.dependsNode.indexOf(d.index) == -1) .filter((d) => this.dependsNode.indexOf(d.index) == -1)
.transition() .transition()
.style('opacity', 0.3) .style('opacity', 0.2)
// 隐藏线 // 隐藏线
this.SVG.selectAll('.edge') this.SVG.selectAll('.edge')
...@@ -684,7 +687,7 @@ export default class RelationGraph { ...@@ -684,7 +687,7 @@ export default class RelationGraph {
return d.index != sourceIndex && d.index != targetIndex return d.index != sourceIndex && d.index != targetIndex
}) })
.transition() .transition()
.style('opacity', 0.3) .style('opacity', 0.2)
// 隐藏线 // 隐藏线
this.SVG.selectAll('.edge') this.SVG.selectAll('.edge')
...@@ -733,13 +736,13 @@ export default class RelationGraph { ...@@ -733,13 +736,13 @@ export default class RelationGraph {
this.SVG.selectAll('circle') this.SVG.selectAll('circle')
.filter((d) => this.dependsNode.indexOf(d.index) < 0) .filter((d) => this.dependsNode.indexOf(d.index) < 0)
.transition() .transition()
.style('opacity', 0.3) .style('opacity', 0.2)
// 隐藏线 // 隐藏线
this.SVG.selectAll('.edge') this.SVG.selectAll('.edge')
.filter((d) => this.dependsLink.indexOf(d.index) < 0) .filter((d) => this.dependsLink.indexOf(d.index) < 0)
.transition() .transition()
.style('opacity', 0.3) .style('opacity', 0.2)
return true return true
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment