fix(数据集): 编辑数据集页面首先验证数据源是否存在

This commit is contained in:
fit2cloud-chenyw 2024-04-11 17:30:49 +08:00
parent 1ab11e64c1
commit 5d6623a526

View File

@ -34,7 +34,8 @@ import {
getTables,
getPreviewData,
getDatasetDetails,
saveDatasetTree
saveDatasetTree,
barInfoApi
} from '@/api/dataset'
import type { Table } from '@/api/dataset'
import DatasetUnion from './DatasetUnion.vue'
@ -581,14 +582,19 @@ const getTableName = async (datasourceId, tableName) => {
}
}
const initEdite = () => {
const initEdite = async () => {
const { id, datasourceId, tableName } = route.query
const { id: copyId } = route.params
const barRes = await barInfoApi(copyId || id)
if (!barRes || !barRes['id']) {
return
}
if (datasourceId) {
dataSource.value = datasourceId as string
getTableName(datasourceId as string, tableName)
}
if (!id && !copyId) return
loading.value = true
getDatasetDetails(copyId || id)
.then(res => {
@ -859,7 +865,7 @@ let p = null
const XpackLoaded = () => p(true)
onMounted(async () => {
await new Promise(r => (p = r))
initEdite()
await initEdite()
getDatasource()
useEmitt({
name: 'onDatasetSave',