forked from github/dataease
Merge pull request #4338 from dataease/pr@dev@feat_relation_tree_select
Merge branch 'dev' into pr@dev@feat_relation_tree_select
This commit is contained in:
commit
ac1ff9eefd
@ -923,7 +923,7 @@ export default {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const { queryType = 'dataset', id } = data
|
const { queryType = 'dataset', id, name } = data
|
||||||
if (checkPermission(['relationship:read'])) {
|
if (checkPermission(['relationship:read'])) {
|
||||||
let hasSubRelation = false
|
let hasSubRelation = false
|
||||||
await getDatasetRelationship(id).then((res) => {
|
await getDatasetRelationship(id).then((res) => {
|
||||||
@ -938,7 +938,7 @@ export default {
|
|||||||
options.templateDel = msgContent
|
options.templateDel = msgContent
|
||||||
options.confirmButtonText = undefined
|
options.confirmButtonText = undefined
|
||||||
options.type = 'danger'
|
options.type = 'danger'
|
||||||
options.linkTo = this.linkTo.bind(this, { queryType, id })
|
options.linkTo = this.linkTo.bind(this, { queryType, id, name })
|
||||||
this.withLink(options, this.$t('commons.delete'))
|
this.withLink(options, this.$t('commons.delete'))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -760,7 +760,7 @@ export default {
|
|||||||
params.link = this.$t('datasource.click_to_check')
|
params.link = this.$t('datasource.click_to_check')
|
||||||
params.content = this.$t('datasource.cannot_be_deleted_datasource')
|
params.content = this.$t('datasource.cannot_be_deleted_datasource')
|
||||||
params.templateDel = msgContent
|
params.templateDel = msgContent
|
||||||
params.linkTo = this.linkTo.bind(this, { queryType, id })
|
params.linkTo = this.linkTo.bind(this, { queryType, id, name: label })
|
||||||
this.withLink(params)
|
this.withLink(params)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,14 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="consanguinity">
|
<div
|
||||||
|
class="consanguinity"
|
||||||
|
@click.stop="resetFilter"
|
||||||
|
>
|
||||||
<div class="route-title">{{ $t('commons.consanguinity') }}</div>
|
<div class="route-title">{{ $t('commons.consanguinity') }}</div>
|
||||||
<div class="container-wrapper">
|
<div class="container-wrapper">
|
||||||
<el-form
|
<el-form
|
||||||
|
ref="form"
|
||||||
:rules="rules"
|
:rules="rules"
|
||||||
:inline="true"
|
:inline="true"
|
||||||
ref="form"
|
|
||||||
:model="formInline"
|
:model="formInline"
|
||||||
class="de-form-inline"
|
class="de-form-inline"
|
||||||
>
|
>
|
||||||
@ -15,59 +18,114 @@
|
|||||||
>
|
>
|
||||||
<el-select
|
<el-select
|
||||||
v-model="formInline.queryType"
|
v-model="formInline.queryType"
|
||||||
@change="queryTypeChange"
|
|
||||||
:placeholder="$t('fu.search_bar.please_select')"
|
:placeholder="$t('fu.search_bar.please_select')"
|
||||||
|
@change="queryTypeChange"
|
||||||
|
@focus="resetFilter"
|
||||||
>
|
>
|
||||||
<el-option
|
<el-option
|
||||||
v-for="item in queryTypeNameList"
|
v-for="item in queryTypeNameList"
|
||||||
:key="item.value"
|
:key="item.value"
|
||||||
:label="$t(item.label)"
|
:label="$t(item.label)"
|
||||||
:value="item.value"
|
:value="item.value"
|
||||||
>
|
/>
|
||||||
</el-option>
|
|
||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item prop="dataSourceName" :label="queryTypeTitle">
|
<el-form-item
|
||||||
|
prop="dataSourceName"
|
||||||
|
:label="queryTypeTitle"
|
||||||
|
>
|
||||||
|
<el-popover
|
||||||
|
v-model="showTree"
|
||||||
|
placement="bottom"
|
||||||
|
trigger="manual"
|
||||||
|
:width="popoverSize"
|
||||||
|
>
|
||||||
|
<el-tree
|
||||||
|
v-show="showTree"
|
||||||
|
ref="resourceTree"
|
||||||
|
accordion
|
||||||
|
node-key="id"
|
||||||
|
:indent="8"
|
||||||
|
:data="resourceTreeData"
|
||||||
|
:highlight-current="true"
|
||||||
|
:filter-node-method="filterNodeMethod"
|
||||||
|
:current-node-key="formInline.dataSourceName"
|
||||||
|
@node-click="nodeClick"
|
||||||
|
>
|
||||||
|
<span
|
||||||
|
slot-scope="{ data }"
|
||||||
|
>
|
||||||
|
<span>
|
||||||
|
<span>
|
||||||
|
<svg-icon
|
||||||
|
:icon-class="getIconClass(formInline.queryType, data)"
|
||||||
|
:class="getNodeClass(formInline.queryType, data)"
|
||||||
|
/>
|
||||||
|
</span>
|
||||||
|
<span
|
||||||
|
:title="data.name"
|
||||||
|
style="padding-right: 8px"
|
||||||
|
>
|
||||||
|
{{ data.name }}
|
||||||
|
</span>
|
||||||
|
</span>
|
||||||
|
</span>
|
||||||
|
</el-tree>
|
||||||
<el-select
|
<el-select
|
||||||
|
ref="treeSelect"
|
||||||
|
slot="reference"
|
||||||
v-model="formInline.dataSourceName"
|
v-model="formInline.dataSourceName"
|
||||||
filterable
|
filterable
|
||||||
:placeholder="$t('fu.search_bar.please_select')"
|
remote
|
||||||
|
:filter-method="filterMethod"
|
||||||
|
:title="nodeData.name"
|
||||||
|
popper-class="tree-select"
|
||||||
|
@focus="showTree = true"
|
||||||
>
|
>
|
||||||
<el-option
|
<el-option
|
||||||
v-for="item in dataSourceNameList"
|
v-for="item in ignoredOptions"
|
||||||
:key="item.value"
|
:key="item.id"
|
||||||
:label="item.label"
|
:label="item.name"
|
||||||
:value="item.value"
|
:value="item.id"
|
||||||
>
|
/>
|
||||||
</el-option>
|
|
||||||
</el-select>
|
</el-select>
|
||||||
|
</el-popover>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item style="float: right">
|
<el-form-item style="float: right">
|
||||||
<de-btn type="primary" @click="onSubmit">{{
|
<de-btn
|
||||||
$t('commons.adv_search.search')
|
type="primary"
|
||||||
}}</de-btn>
|
@click="onSubmit"
|
||||||
|
>
|
||||||
|
{{ $t('commons.adv_search.search') }}
|
||||||
|
</de-btn>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-form>
|
</el-form>
|
||||||
<div class="select-icon">
|
<div class="select-icon">
|
||||||
<i
|
<i
|
||||||
@click="activeQueryType('date')"
|
|
||||||
:class="[activeIcon === 'date' ? 'active-icon' : '']"
|
:class="[activeIcon === 'date' ? 'active-icon' : '']"
|
||||||
class="el-icon-date"
|
class="el-icon-date"
|
||||||
></i>
|
@click="activeQueryType('date')"
|
||||||
|
/>
|
||||||
<svg-icon
|
<svg-icon
|
||||||
icon-class="sys-relationship"
|
icon-class="sys-relationship"
|
||||||
:class="[activeIcon === 'share' ? 'active-icon' : '']"
|
:class="[activeIcon === 'share' ? 'active-icon' : '']"
|
||||||
@click="activeQueryType('share')"
|
@click="activeQueryType('share')"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div v-show="activeIcon === 'share'" id="consanguinity">
|
<div
|
||||||
|
v-show="activeIcon === 'share'"
|
||||||
|
id="consanguinity"
|
||||||
|
>
|
||||||
<consanguinity
|
<consanguinity
|
||||||
:chartSize="chartSize"
|
|
||||||
:current="current"
|
|
||||||
ref="consanguinity"
|
ref="consanguinity"
|
||||||
|
:chart-size="chartSize"
|
||||||
|
:current="current"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div v-show="activeIcon === 'date'" class="consanguinity-table">
|
<div
|
||||||
|
v-show="activeIcon === 'date'"
|
||||||
|
class="consanguinity-table"
|
||||||
|
>
|
||||||
<grid-table
|
<grid-table
|
||||||
v-loading="loading"
|
v-loading="loading"
|
||||||
:table-data="tableData"
|
:table-data="tableData"
|
||||||
@ -75,7 +133,11 @@
|
|||||||
@size-change="handleSizeChange"
|
@size-change="handleSizeChange"
|
||||||
@current-change="handleCurrentChange"
|
@current-change="handleCurrentChange"
|
||||||
>
|
>
|
||||||
<el-table-column :label="$t('table.id')" type="index" width="50" />
|
<el-table-column
|
||||||
|
:label="$t('table.id')"
|
||||||
|
type="index"
|
||||||
|
width="50"
|
||||||
|
/>
|
||||||
<el-table-column
|
<el-table-column
|
||||||
prop="datasource"
|
prop="datasource"
|
||||||
:formatter="formatter"
|
:formatter="formatter"
|
||||||
@ -106,15 +168,14 @@ import {
|
|||||||
getDatasetRelationship,
|
getDatasetRelationship,
|
||||||
getPanelRelationship
|
getPanelRelationship
|
||||||
} from '@/api/chart/chart.js'
|
} from '@/api/chart/chart.js'
|
||||||
import {
|
import { listDatasource } from '@/api/dataset/dataset'
|
||||||
listDatasource,
|
|
||||||
getDatasetList,
|
|
||||||
getPanelGroupList
|
|
||||||
} from '@/api/dataset/dataset'
|
|
||||||
import _ from 'lodash'
|
import _ from 'lodash'
|
||||||
import GridTable from '@/components/gridTable/index.vue'
|
import GridTable from '@/components/gridTable/index.vue'
|
||||||
import consanguinity from './consanguinity.vue'
|
import consanguinity from './consanguinity.vue'
|
||||||
import { log } from '@antv/g2plot/lib/utils'
|
import { groupTree } from '@/api/panel/panel'
|
||||||
|
import { queryAuthModel } from '@/api/authModel/authModel'
|
||||||
|
import { data } from 'vue2-ace-editor'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'Consanguinity',
|
name: 'Consanguinity',
|
||||||
components: { GridTable, consanguinity },
|
components: { GridTable, consanguinity },
|
||||||
@ -128,7 +189,6 @@ export default {
|
|||||||
queryType: [{ required: true, trigger: 'blur' }],
|
queryType: [{ required: true, trigger: 'blur' }],
|
||||||
dataSourceName: [{ required: true, trigger: 'blur', message: this.$t('chart.name_can_not_empty') }]
|
dataSourceName: [{ required: true, trigger: 'blur', message: this.$t('chart.name_can_not_empty') }]
|
||||||
},
|
},
|
||||||
dataSourceNameList: [],
|
|
||||||
queryTypeNameList: [
|
queryTypeNameList: [
|
||||||
{
|
{
|
||||||
label: 'commons.datasource',
|
label: 'commons.datasource',
|
||||||
@ -155,19 +215,21 @@ export default {
|
|||||||
currentPage: 1,
|
currentPage: 1,
|
||||||
pageSize: 10,
|
pageSize: 10,
|
||||||
total: 0
|
total: 0
|
||||||
}
|
},
|
||||||
|
resourceTreeData: [],
|
||||||
|
ignoredOptions: [],
|
||||||
|
showTree: false,
|
||||||
|
nodeData: {},
|
||||||
|
popoverSize: 400,
|
||||||
|
currentNode: {}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
current() {
|
current() {
|
||||||
const { queryType = '', dataSourceName } = this.formInline
|
|
||||||
const obj =
|
|
||||||
this.dataSourceNameList.find((ele) => dataSourceName === ele.value) ||
|
|
||||||
{}
|
|
||||||
return {
|
return {
|
||||||
queryType,
|
queryType: this.formInline.queryType,
|
||||||
num: obj.value,
|
num: this.formInline.dataSourceName,
|
||||||
label: obj.label
|
label: this.nodeData.name
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
queryTypeTitle() {
|
queryTypeTitle() {
|
||||||
@ -189,9 +251,9 @@ export default {
|
|||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
this.routerWithParams = this.$route.query
|
this.routerWithParams = this.$route.query
|
||||||
const { id, queryType } = this.routerWithParams
|
const { id, queryType, name } = this.routerWithParams
|
||||||
if (id && queryType) {
|
if (id && queryType) {
|
||||||
this.searchDetail(id, queryType)
|
this.searchDetail(id, queryType, name)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
this.listDatasource()
|
this.listDatasource()
|
||||||
@ -204,11 +266,12 @@ export default {
|
|||||||
this.getChartSize()
|
this.getChartSize()
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
data,
|
||||||
activeQueryType(activeIcon) {
|
activeQueryType(activeIcon) {
|
||||||
this.activeIcon = activeIcon
|
this.activeIcon = activeIcon
|
||||||
this.onSubmit()
|
this.onSubmit()
|
||||||
},
|
},
|
||||||
async searchDetail(id, queryType) {
|
async searchDetail(id, queryType, name) {
|
||||||
switch (queryType) {
|
switch (queryType) {
|
||||||
case 'datasource':
|
case 'datasource':
|
||||||
await this.listDatasource()
|
await this.listDatasource()
|
||||||
@ -223,6 +286,13 @@ export default {
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
this.formInline = { queryType, dataSourceName: id }
|
this.formInline = { queryType, dataSourceName: id }
|
||||||
|
this.nodeData = { id, name }
|
||||||
|
this.ignoredOptions = [this.nodeData]
|
||||||
|
this.$refs.resourceTree.setCurrentKey(id)
|
||||||
|
const currentParents = this.$refs.resourceTree.getNodePath(this.nodeData)
|
||||||
|
currentParents.forEach((node) => {
|
||||||
|
this.$refs.resourceTree.store.nodesMap[node.id].expanded = true
|
||||||
|
})
|
||||||
this.getChartData()
|
this.getChartData()
|
||||||
},
|
},
|
||||||
getChartData() {
|
getChartData() {
|
||||||
@ -270,7 +340,7 @@ export default {
|
|||||||
})
|
})
|
||||||
},
|
},
|
||||||
formatter(row, column, cellValue) {
|
formatter(row, column, cellValue) {
|
||||||
return cellValue ? cellValue : '-'
|
return cellValue || '-'
|
||||||
},
|
},
|
||||||
initTable() {
|
initTable() {
|
||||||
this.paginationConfig.total = this.treeData.length
|
this.paginationConfig.total = this.treeData.length
|
||||||
@ -313,44 +383,55 @@ export default {
|
|||||||
}, 200),
|
}, 200),
|
||||||
listDatasource() {
|
listDatasource() {
|
||||||
return listDatasource().then((res) => {
|
return listDatasource().then((res) => {
|
||||||
const arr = res?.data || []
|
const dsArr = res?.data || []
|
||||||
this.dataSourceNameList = arr.map((ele) => ({
|
const typeMap = {}
|
||||||
value: ele.id,
|
dsArr.forEach((item) => {
|
||||||
label: ele.name
|
if (!typeMap[item.type]) {
|
||||||
}))
|
typeMap[item.type] = [{ id: item.id, name: item.name, type: 'datasource' }]
|
||||||
|
this.resourceTreeData.push({
|
||||||
|
id: item.type,
|
||||||
|
name: item.typeDesc,
|
||||||
|
type: 'folder',
|
||||||
|
children: typeMap[item.type]
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
typeMap[item.type].push({ id: item.id, name: item.name, type: 'datasource' })
|
||||||
|
}
|
||||||
|
})
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
getDatasetList() {
|
getDatasetList() {
|
||||||
return getDatasetList().then((res) => {
|
return queryAuthModel({ modelType: 'dataset' }, false).then((res) => {
|
||||||
const arr = res?.data || []
|
this.resourceTreeData = res.data
|
||||||
this.dataSourceNameList = arr.map((ele) => ({
|
|
||||||
value: ele.id,
|
|
||||||
label: ele.name
|
|
||||||
}))
|
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
getPanelGroupList() {
|
getPanelGroupList() {
|
||||||
return getPanelGroupList().then((res) => {
|
const form = {
|
||||||
const arr = res?.data || []
|
panelType: 'self',
|
||||||
this.dataSourceNameList = arr.map((ele) => ({
|
sort: 'create_time desc,node_type desc,name asc'
|
||||||
value: ele.id,
|
}
|
||||||
label: ele.name
|
return groupTree(form, true).then((res) => {
|
||||||
}))
|
this.resourceTreeData = res.data
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
queryTypeChange(val) {
|
queryTypeChange(val) {
|
||||||
this.formInline.dataSourceName = ''
|
this.formInline.dataSourceName = ''
|
||||||
this.dataSourceNameList = []
|
this.resourceTreeData = []
|
||||||
|
this.nodeData = {}
|
||||||
|
this.currentNode = {}
|
||||||
switch (val) {
|
switch (val) {
|
||||||
case 'datasource':
|
case 'datasource': {
|
||||||
this.listDatasource()
|
this.listDatasource()
|
||||||
break
|
break
|
||||||
case 'dataset':
|
}
|
||||||
|
case 'dataset': {
|
||||||
this.getDatasetList()
|
this.getDatasetList()
|
||||||
break
|
break
|
||||||
case 'panel':
|
}
|
||||||
|
case 'panel': {
|
||||||
this.getPanelGroupList()
|
this.getPanelGroupList()
|
||||||
break
|
break
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
@ -374,6 +455,88 @@ export default {
|
|||||||
handleCurrentChange(currentPage) {
|
handleCurrentChange(currentPage) {
|
||||||
this.paginationConfig.currentPage = currentPage
|
this.paginationConfig.currentPage = currentPage
|
||||||
this.onSubmit()
|
this.onSubmit()
|
||||||
|
},
|
||||||
|
getIconClass(queryType, nodeData) {
|
||||||
|
switch (queryType) {
|
||||||
|
case 'datasource': {
|
||||||
|
if (nodeData.type === 'folder') {
|
||||||
|
return 'scene'
|
||||||
|
}
|
||||||
|
return 'db-de'
|
||||||
|
}
|
||||||
|
case 'dataset': {
|
||||||
|
if (nodeData.modelInnerType === 'group') {
|
||||||
|
return 'scene'
|
||||||
|
}
|
||||||
|
return `ds-${nodeData.modelInnerType}`
|
||||||
|
}
|
||||||
|
case 'panel':
|
||||||
|
if (nodeData.nodeType === 'panel') {
|
||||||
|
let iconClass = 'panel-'
|
||||||
|
if (nodeData.mobileLayout) {
|
||||||
|
iconClass += 'mobile-'
|
||||||
|
}
|
||||||
|
iconClass += nodeData.status
|
||||||
|
return iconClass
|
||||||
|
}
|
||||||
|
return 'scene'
|
||||||
|
default:
|
||||||
|
break
|
||||||
|
}
|
||||||
|
},
|
||||||
|
getNodeClass(queryType, nodeData) {
|
||||||
|
switch (queryType) {
|
||||||
|
case 'dataset': {
|
||||||
|
if (nodeData.modelInnerType !== 'group') {
|
||||||
|
return `ds-icon-${nodeData.modelInnerType}`
|
||||||
|
}
|
||||||
|
return ''
|
||||||
|
}
|
||||||
|
case 'panel': {
|
||||||
|
if (nodeData.nodeType === 'panel') {
|
||||||
|
return 'ds-icon-scene'
|
||||||
|
}
|
||||||
|
return ''
|
||||||
|
}
|
||||||
|
default: {
|
||||||
|
return ''
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
filterNodeMethod(value, data) {
|
||||||
|
if (!value) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return data.name.toLowerCase().indexOf(value.toLowerCase()) !== -1
|
||||||
|
},
|
||||||
|
filterMethod(filterText) {
|
||||||
|
this.$refs.resourceTree.filter(filterText)
|
||||||
|
},
|
||||||
|
nodeClick(data, node) {
|
||||||
|
if (node.isLeaf) {
|
||||||
|
this.ignoredOptions = [{ id: data.id, name: data.name }]
|
||||||
|
this.formInline.dataSourceName = data.id
|
||||||
|
this.showTree = false
|
||||||
|
this.nodeData = data
|
||||||
|
this.currentNode = node
|
||||||
|
}
|
||||||
|
},
|
||||||
|
resetFilter() {
|
||||||
|
if (this.showTree) {
|
||||||
|
this.showTree = false
|
||||||
|
this.$refs.resourceTree.filter()
|
||||||
|
this.$refs.resourceTree.setCurrentKey(this.formInline.dataSourceName)
|
||||||
|
if (this.formInline.dataSourceName === '') {
|
||||||
|
this.$refs.resourceTree.setCurrentKey(null)
|
||||||
|
}
|
||||||
|
if (this.formInline.dataSourceName) {
|
||||||
|
const currentParents = this.$refs.resourceTree.getNodePath(this.nodeData).map((item) => item.id)
|
||||||
|
const nodesMap = this.$refs.resourceTree.store.nodesMap || {}
|
||||||
|
for (const key in nodesMap) {
|
||||||
|
nodesMap[key].expanded = currentParents.includes(key)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -428,4 +591,31 @@ export default {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
.custom-tree-node {
|
||||||
|
flex: 1;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
font-size: 14px;
|
||||||
|
padding-right: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.custom-tree-node-list {
|
||||||
|
flex: 1;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
font-size: 14px;
|
||||||
|
padding: 0 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.father .child {
|
||||||
|
/*display: none;*/
|
||||||
|
visibility: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.father:hover .child {
|
||||||
|
/*display: inline;*/
|
||||||
|
visibility: visible;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
Loading…
Reference in New Issue
Block a user