diff --git a/core/datacap-ui/src/model/structure.ts b/core/datacap-ui/src/model/structure.ts index 8918a801..8a89aaf7 100644 --- a/core/datacap-ui/src/model/structure.ts +++ b/core/datacap-ui/src/model/structure.ts @@ -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 diff --git a/core/datacap-ui/src/views/components/tree/DataStructureLazyTree.vue b/core/datacap-ui/src/views/components/tree/DataStructureLazyTree.vue index ff8d5288..56b8face 100644 --- a/core/datacap-ui/src/views/components/tree/DataStructureLazyTree.vue +++ b/core/datacap-ui/src/views/components/tree/DataStructureLazyTree.vue @@ -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) } } -}); +}) diff --git a/core/datacap-ui/src/views/layouts/metadata/MetadataContainer.vue b/core/datacap-ui/src/views/layouts/metadata/MetadataContainer.vue index dc559323..67527ec7 100644 --- a/core/datacap-ui/src/views/layouts/metadata/MetadataContainer.vue +++ b/core/datacap-ui/src/views/layouts/metadata/MetadataContainer.vue @@ -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 }`) - } } }) diff --git a/core/datacap-ui/src/views/layouts/metadata/components/MetadataSidebar.vue b/core/datacap-ui/src/views/layouts/metadata/components/MetadataSidebar.vue index b43ae731..fc850232 100644 --- a/core/datacap-ui/src/views/layouts/metadata/components/MetadataSidebar.vue +++ b/core/datacap-ui/src/views/layouts/metadata/components/MetadataSidebar.vue @@ -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 diff --git a/core/datacap-ui/src/views/pages/admin/query/QueryHome.vue b/core/datacap-ui/src/views/pages/admin/query/QueryHome.vue index ba74fe8f..a91b844d 100644 --- a/core/datacap-ui/src/views/pages/admin/query/QueryHome.vue +++ b/core/datacap-ui/src/views/pages/admin/query/QueryHome.vue @@ -5,7 +5,7 @@ - + diff --git a/core/datacap-ui/src/views/pages/admin/source/components/ColumnChange.vue b/core/datacap-ui/src/views/pages/admin/source/components/ColumnChange.vue index 2ef6ba3f..944d68ff 100644 --- a/core/datacap-ui/src/views/pages/admin/source/components/ColumnChange.vue +++ b/core/datacap-ui/src/views/pages/admin/source/components/ColumnChange.vue @@ -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() } diff --git a/core/datacap-ui/src/views/pages/admin/source/components/ColumnCreate.vue b/core/datacap-ui/src/views/pages/admin/source/components/ColumnCreate.vue index 05d28c44..765d064f 100644 --- a/core/datacap-ui/src/views/pages/admin/source/components/ColumnCreate.vue +++ b/core/datacap-ui/src/views/pages/admin/source/components/ColumnCreate.vue @@ -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) { diff --git a/core/datacap-ui/src/views/pages/admin/source/components/ColumnDrop.vue b/core/datacap-ui/src/views/pages/admin/source/components/ColumnDrop.vue index acf1594b..86e4c3f0 100644 --- a/core/datacap-ui/src/views/pages/admin/source/components/ColumnDrop.vue +++ b/core/datacap-ui/src/views/pages/admin/source/components/ColumnDrop.vue @@ -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) { diff --git a/core/datacap-ui/src/views/pages/admin/source/components/TableDrop.vue b/core/datacap-ui/src/views/pages/admin/source/components/TableDrop.vue index 35a9b22c..7df9cbb5 100644 --- a/core/datacap-ui/src/views/pages/admin/source/components/TableDrop.vue +++ b/core/datacap-ui/src/views/pages/admin/source/components/TableDrop.vue @@ -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) { diff --git a/core/datacap-ui/src/views/pages/admin/source/components/TableTruncate.vue b/core/datacap-ui/src/views/pages/admin/source/components/TableTruncate.vue index ecde3590..49d88566 100644 --- a/core/datacap-ui/src/views/pages/admin/source/components/TableTruncate.vue +++ b/core/datacap-ui/src/views/pages/admin/source/components/TableTruncate.vue @@ -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) {