mirror of
https://gitee.com/devlive-community/datacap.git
synced 2024-12-02 20:17:45 +08:00
[Core] [Source] [Metadata] Fixed code
This commit is contained in:
parent
bc9c1318a5
commit
7930b247f8
@ -5,7 +5,7 @@ export interface StructureModel
|
||||
database?: null | any
|
||||
databaseId?: string
|
||||
table?: null
|
||||
tableId?: null
|
||||
tableId?: string
|
||||
applyId?: null | number
|
||||
type?: null
|
||||
dataType?: null
|
||||
|
@ -23,8 +23,8 @@ export default defineComponent({
|
||||
Tree
|
||||
},
|
||||
props: {
|
||||
id: {
|
||||
type: String,
|
||||
code: {
|
||||
type: String
|
||||
}
|
||||
},
|
||||
data()
|
||||
@ -37,109 +37,120 @@ export default defineComponent({
|
||||
created()
|
||||
{
|
||||
this.handlerInitialize()
|
||||
watch(() => this.id, () => this.handlerInitialize())
|
||||
watch(() => this.code, () => this.handlerInitialize())
|
||||
},
|
||||
methods: {
|
||||
handlerInitialize()
|
||||
{
|
||||
this.dataTreeArray = []
|
||||
this.loading = true
|
||||
DatabaseService.getAllBySource(this.id as string)
|
||||
.then(response => {
|
||||
if (response.status) {
|
||||
response.data.forEach((item: { name: null; catalog: null; id: null }) => {
|
||||
const structure: StructureModel = {
|
||||
title: item.name,
|
||||
catalog: item.catalog,
|
||||
applyId: item.id,
|
||||
level: StructureEnum.DATABASE,
|
||||
loading: false,
|
||||
children: [] as StructureModel[],
|
||||
render: (h: any, {data}: { data: StructureModel }) => {
|
||||
return h('div', [
|
||||
h('span', [
|
||||
h(resolveComponent('FontAwesomeIcon'), {
|
||||
icon: 'database',
|
||||
style: {marginRight: '6px'}
|
||||
}),
|
||||
h('span', data.title)
|
||||
])
|
||||
])
|
||||
}
|
||||
}
|
||||
this.dataTreeArray.push(structure)
|
||||
})
|
||||
}
|
||||
})
|
||||
.finally(() => this.loading = false)
|
||||
DatabaseService.getAllBySource(this.code as string)
|
||||
.then(response => {
|
||||
if (response.status) {
|
||||
response.data
|
||||
.forEach((item: { name: null; catalog: null; code: undefined }) => {
|
||||
const structure: StructureModel = {
|
||||
title: item.name,
|
||||
catalog: item.catalog,
|
||||
code: item.code,
|
||||
level: StructureEnum.DATABASE,
|
||||
loading: false,
|
||||
children: [] as StructureModel[],
|
||||
render: (h: any, { data }: { data: StructureModel }) => {
|
||||
return h('div', [
|
||||
h('span', [
|
||||
h(resolveComponent('FontAwesomeIcon'), {
|
||||
icon: 'database',
|
||||
style: { marginRight: '6px' }
|
||||
}),
|
||||
h('span', data.title)
|
||||
])
|
||||
])
|
||||
}
|
||||
}
|
||||
this.dataTreeArray.push(structure)
|
||||
})
|
||||
}
|
||||
})
|
||||
.finally(() => this.loading = false)
|
||||
},
|
||||
handlerLoadChildData(item: StructureModel, callback: any)
|
||||
{
|
||||
const dataChildArray = [] as StructureModel[]
|
||||
if (item.level === StructureEnum.DATABASE) {
|
||||
TableService.getAllByDatabase(item.applyId as number)
|
||||
.then(response => {
|
||||
if (response.status) {
|
||||
response.data.forEach((item: { name: null; title: null; catalog: null; id: null; type: null; engine: null; database: { name: null }; }) => {
|
||||
const structure: StructureModel = {
|
||||
title: item.name,
|
||||
database: item.database.name,
|
||||
catalog: item.catalog,
|
||||
applyId: item.id,
|
||||
level: StructureEnum.TABLE,
|
||||
type: item.type,
|
||||
engine: item.engine,
|
||||
loading: false,
|
||||
children: [] as StructureModel[],
|
||||
render: (h: any, {data}: { data: StructureModel }) => {
|
||||
return h('div', [
|
||||
h('span', [
|
||||
h(resolveComponent('FontAwesomeIcon'), {
|
||||
icon: 'table',
|
||||
style: {marginRight: '6px'}
|
||||
}),
|
||||
h('span', data.title)
|
||||
])
|
||||
])
|
||||
}
|
||||
}
|
||||
dataChildArray.push(structure)
|
||||
})
|
||||
}
|
||||
})
|
||||
.finally(() => callback(dataChildArray))
|
||||
TableService.getAllByDatabase(item.code as string)
|
||||
.then(response => {
|
||||
if (response.status) {
|
||||
response.data
|
||||
.forEach((item: { name: null; title: null; catalog: null; code: undefined; type: null; engine: null; database: { name: null }; }) => {
|
||||
const structure: StructureModel = {
|
||||
title: item.name,
|
||||
database: item.database.name,
|
||||
catalog: item.catalog,
|
||||
code: item.code,
|
||||
level: StructureEnum.TABLE,
|
||||
type: item.type,
|
||||
engine: item.engine,
|
||||
loading: false,
|
||||
children: [] as StructureModel[],
|
||||
render: (h: any, { data }: { data: StructureModel }) => {
|
||||
return h('div', [
|
||||
h('span', [
|
||||
h(resolveComponent('FontAwesomeIcon'), {
|
||||
icon: 'table',
|
||||
style: { marginRight: '6px' }
|
||||
}),
|
||||
h('span', data.title)
|
||||
])
|
||||
])
|
||||
}
|
||||
}
|
||||
dataChildArray.push(structure)
|
||||
})
|
||||
}
|
||||
})
|
||||
.finally(() => callback(dataChildArray))
|
||||
}
|
||||
else if (item.level === StructureEnum.TABLE) {
|
||||
ColumnService.getAllByTable(item.applyId as number)
|
||||
.then(response => {
|
||||
if (response.status) {
|
||||
response.data.forEach((item: { name: null; title: null; catalog: null; id: null; type: null; engine: null; table: { name: null, database: { name: null } }; }) => {
|
||||
const structure: StructureModel = {
|
||||
title: item.name,
|
||||
database: item.table.database.name,
|
||||
table: item.table.name,
|
||||
catalog: item.catalog,
|
||||
applyId: item.id,
|
||||
level: StructureEnum.COLUMN,
|
||||
type: item.type,
|
||||
engine: item.engine,
|
||||
render: (h: any, {data}: { data: StructureModel }) => {
|
||||
return h('div', [
|
||||
h('span', [
|
||||
h(resolveComponent('FontAwesomeIcon'), {
|
||||
icon: 'columns',
|
||||
style: {marginRight: '6px'}
|
||||
}),
|
||||
h('span', data.title)
|
||||
])
|
||||
])
|
||||
}
|
||||
}
|
||||
dataChildArray.push(structure)
|
||||
})
|
||||
}
|
||||
})
|
||||
.finally(() => callback(dataChildArray))
|
||||
ColumnService.getAllByTable(item.code as string)
|
||||
.then(response => {
|
||||
if (response.status) {
|
||||
response.data
|
||||
.forEach((item: {
|
||||
name: null;
|
||||
title: null;
|
||||
catalog: null;
|
||||
code: undefined;
|
||||
type: null;
|
||||
engine: null;
|
||||
table: { name: null, database: { name: null } };
|
||||
}) => {
|
||||
const structure: StructureModel = {
|
||||
title: item.name,
|
||||
database: item.table.database.name,
|
||||
table: item.table.name,
|
||||
catalog: item.catalog,
|
||||
code: item.code,
|
||||
level: StructureEnum.COLUMN,
|
||||
type: item.type,
|
||||
engine: item.engine,
|
||||
render: (h: any, { data }: { data: StructureModel }) => {
|
||||
return h('div', [
|
||||
h('span', [
|
||||
h(resolveComponent('FontAwesomeIcon'), {
|
||||
icon: 'columns',
|
||||
style: { marginRight: '6px' }
|
||||
}),
|
||||
h('span', data.title)
|
||||
])
|
||||
])
|
||||
}
|
||||
}
|
||||
dataChildArray.push(structure)
|
||||
})
|
||||
}
|
||||
})
|
||||
.finally(() => callback(dataChildArray))
|
||||
}
|
||||
else {
|
||||
callback(dataChildArray)
|
||||
@ -151,7 +162,7 @@ export default defineComponent({
|
||||
let text: string = target.title as string
|
||||
switch (target.level) {
|
||||
case StructureEnum.TABLE:
|
||||
text = target.database + '.' + text;
|
||||
text = target.database + '.' + text
|
||||
break
|
||||
case StructureEnum.COLUMN:
|
||||
text = target.database + '.' + target.table + '.' + text
|
||||
@ -160,5 +171,5 @@ export default defineComponent({
|
||||
ObjectUtils.copy(text)
|
||||
}
|
||||
}
|
||||
});
|
||||
})
|
||||
</script>
|
||||
|
@ -17,22 +17,12 @@
|
||||
import { defineComponent } from 'vue'
|
||||
import MetadataSidebar from '@/views/layouts/metadata/components/MetadataSidebar.vue'
|
||||
import MetadataContent from '@/views/layouts/metadata/components/MetadataContent.vue'
|
||||
import { StructureModel } from '@/model/structure.ts'
|
||||
import router from '@/router'
|
||||
|
||||
export default defineComponent({
|
||||
name: 'MetadataContainer',
|
||||
components: {
|
||||
MetadataContent,
|
||||
MetadataSidebar
|
||||
},
|
||||
methods: {
|
||||
handlerChange(node: StructureModel)
|
||||
{
|
||||
this.dataInfo = node
|
||||
console.log(node)
|
||||
router.push(`/admin/source/manager/${ this.code }/d/${ node.code }`)
|
||||
}
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
@ -294,7 +294,7 @@ export default defineComponent({
|
||||
}
|
||||
this.selectNode = currentNode
|
||||
const type = this.$route.meta.type as string
|
||||
this.$router.push(`/admin/source/${ this.originalSource }/d/${ this.selectDatabase }/t/${ type }/${ currentNode.code }`)
|
||||
this.$router.push(`/admin/source/${ this.originalSource }/d/${ this.selectDatabase }/t/${ type ? type : 'info' }/${ currentNode.code }`)
|
||||
},
|
||||
handlerLoadChildData(item: StructureModel, callback: any)
|
||||
{
|
||||
@ -317,14 +317,14 @@ export default defineComponent({
|
||||
engine: null;
|
||||
isKey: null;
|
||||
defaultValue: null;
|
||||
table: { name: null, id: null, database: { name: null, id: string } };
|
||||
table: { name: null, code: undefined, database: { name: null, id: string } };
|
||||
}) => {
|
||||
const structure: StructureModel = {
|
||||
title: item.name,
|
||||
database: item.table.database.name,
|
||||
databaseId: item.table.database.id,
|
||||
table: item.table.name,
|
||||
tableId: item.table.id,
|
||||
tableId: item.table.code,
|
||||
catalog: item.catalog,
|
||||
code: item.code,
|
||||
level: StructureEnum.COLUMN,
|
||||
@ -365,6 +365,7 @@ export default defineComponent({
|
||||
},
|
||||
handlerContextMenu(node: StructureModel)
|
||||
{
|
||||
console.log(node)
|
||||
this.dataInfo = node
|
||||
// Simulate right-click to trigger right-click menu
|
||||
const element = document.getElementById('contextMenu') as HTMLElement
|
||||
|
@ -5,7 +5,7 @@
|
||||
<Card>
|
||||
<CardHeader class="p-0">
|
||||
<SourceSelect :value="selectSource.full as string" @changeValue="handlerChangeValue($event)"/>
|
||||
<DataStructureLazyTree v-if="selectSource.id" :id="selectSource.id as string"/>
|
||||
<DataStructureLazyTree v-if="selectSource.code" :code="selectSource.code as string"/>
|
||||
</CardHeader>
|
||||
</Card>
|
||||
</aside>
|
||||
|
@ -103,7 +103,6 @@ import { Minus, Plus } from 'lucide-vue-next'
|
||||
import { Input } from '@/components/ui/input'
|
||||
import Switch from '@/views/ui/switch'
|
||||
import { ToastUtils } from '@/utils/toast'
|
||||
import { toNumber } from 'lodash'
|
||||
import TableService from '@/services/table'
|
||||
import ColumnService from '@/services/column'
|
||||
import CircularLoading from '@/views/components/loading/CircularLoading.vue'
|
||||
@ -160,7 +159,7 @@ export default defineComponent({
|
||||
{
|
||||
if (this.info) {
|
||||
this.loading = true
|
||||
ColumnService.getById(toNumber(this.info.applyId))
|
||||
ColumnService.getByCode(this.info.code as string)
|
||||
.then(response => {
|
||||
if (response.status) {
|
||||
const data = response.data
|
||||
@ -187,11 +186,14 @@ export default defineComponent({
|
||||
{
|
||||
if (this.info) {
|
||||
this.submitting = true
|
||||
TableService.manageColumn(toNumber(this.info.tableId), this.formState)
|
||||
TableService.manageColumn(this.info.code as string, this.formState)
|
||||
.then(response => {
|
||||
if (response.data) {
|
||||
if (response.data.isSuccessful) {
|
||||
const columns = this.formState?.columns?.map(item => item.name).join(', ') as string
|
||||
const columns = this.formState
|
||||
?.columns
|
||||
?.map(item => item.name)
|
||||
.join(', ') as string
|
||||
ToastUtils.success(this.$t('source.tip.changeColumnSuccess').replace('$VALUE', columns))
|
||||
this.handlerCancel()
|
||||
}
|
||||
|
@ -110,7 +110,6 @@ import { Minus, Plus } from 'lucide-vue-next'
|
||||
import { Input } from '@/components/ui/input'
|
||||
import Switch from '@/views/ui/switch'
|
||||
import { ToastUtils } from '@/utils/toast'
|
||||
import { toNumber } from 'lodash'
|
||||
import TableService from '@/services/table'
|
||||
|
||||
export default defineComponent({
|
||||
@ -163,7 +162,7 @@ export default defineComponent({
|
||||
{
|
||||
if (this.info) {
|
||||
this.loading = true
|
||||
TableService.manageColumn(this.info.code, this.formState)
|
||||
TableService.manageColumn(this.info.code as string, this.formState)
|
||||
.then(response => {
|
||||
if (response.data) {
|
||||
if (response.data.isSuccessful) {
|
||||
|
@ -99,7 +99,7 @@ export default defineComponent({
|
||||
this.submitting = true
|
||||
}
|
||||
this.formState.preview = preview
|
||||
TableService.getData(toNumber(this.info.tableId), this.formState)
|
||||
TableService.getData(this.info.tableId as string, this.formState)
|
||||
.then(response => {
|
||||
if (response.status) {
|
||||
if (preview) {
|
||||
|
@ -35,7 +35,6 @@ import { SqlType, TableFilter, TableFilterRequest } from '@/model/table'
|
||||
import Button from '@/views/ui/button'
|
||||
import Alert from '@/views/ui/alert'
|
||||
import Divider from '@/views/ui/divider'
|
||||
import { toNumber } from 'lodash'
|
||||
import CircularLoading from '@/views/components/loading/CircularLoading.vue'
|
||||
import AceEditor from '@/views/components/editor/AceEditor.vue'
|
||||
|
||||
@ -98,7 +97,7 @@ export default defineComponent({
|
||||
this.submitting = true
|
||||
}
|
||||
this.formState.preview = preview
|
||||
TableService.getData(toNumber(this.info.applyId), this.formState)
|
||||
TableService.getData(this.info.code as string, this.formState)
|
||||
.then(response => {
|
||||
if (response.status) {
|
||||
if (preview) {
|
||||
|
@ -35,7 +35,6 @@ import { SqlType, TableFilter, TableFilterRequest } from '@/model/table'
|
||||
import Button from '@/views/ui/button'
|
||||
import Alert from '@/views/ui/alert'
|
||||
import Divider from '@/views/ui/divider'
|
||||
import { toNumber } from 'lodash'
|
||||
import CircularLoading from '@/views/components/loading/CircularLoading.vue'
|
||||
import AceEditor from '@/views/components/editor/AceEditor.vue'
|
||||
|
||||
@ -98,7 +97,7 @@ export default defineComponent({
|
||||
this.submitting = true
|
||||
}
|
||||
this.formState.preview = preview
|
||||
TableService.getData(toNumber(this.info.applyId), this.formState)
|
||||
TableService.getData(this.info.code as string, this.formState)
|
||||
.then(response => {
|
||||
if (response.status) {
|
||||
if (preview) {
|
||||
|
Loading…
Reference in New Issue
Block a user