fix(嵌入式): div嵌入方式下,数据源树和数据集树中无法新建资源

This commit is contained in:
dataeaseShu 2024-07-04 11:53:23 +08:00
parent 3b105d1c6f
commit b3e081f9f8
5 changed files with 84 additions and 33 deletions

View File

@ -12,6 +12,9 @@ const Dashboard = defineAsyncComponent(() => import('./DashboardPreview.vue'))
const ViewWrapper = defineAsyncComponent(() => import('./ViewWrapper.vue'))
const Iframe = defineAsyncComponent(() => import('./Iframe.vue'))
const Dataset = defineAsyncComponent(() => import('@/views/visualized/data/dataset/index.vue'))
const DatasetEditor = defineAsyncComponent(
() => import('@/views/visualized/data/dataset/form/index.vue')
)
const Datasource = defineAsyncComponent(
() => import('@/views/visualized/data/datasource/index.vue')
)
@ -37,7 +40,8 @@ const componentMap = {
Iframe,
Datasource,
ScreenPanel,
DashboardPanel
DashboardPanel,
DatasetEditor
}
const changeCurrentComponent = val => {

View File

@ -15,6 +15,11 @@ interface AppState {
templateParams: string
jumpInfoParam: string
outerUrl: string
datasourceId: string
tableName: string
datasetId: string
datasetCopyId: string
datasetPid: string
}
export const userStore = defineStore('embedded', {
@ -33,7 +38,12 @@ export const userStore = defineStore('embedded', {
createType: '',
templateParams: '',
outerUrl: '',
jumpInfoParam: ''
jumpInfoParam: '',
datasourceId: '',
tableName: '',
datasetId: '',
datasetCopyId: '',
datasetPid: ''
}
},
getters: {
@ -96,6 +106,21 @@ export const userStore = defineStore('embedded', {
setType(type: string) {
this.type = type
},
setdatasetPid(datasetPid: string) {
this.datasetPid = datasetPid
},
setDatasourceId(datasourceId: string) {
this.datasourceId = datasourceId
},
setTableName(tableName: string) {
this.tableName = tableName
},
setDatasetId(datasetId: string) {
this.datasetId = datasetId
},
setDatasetCopyId(datasetCopyId: string) {
this.datasetCopyId = datasetCopyId
},
setOuterUrl(outerUrl: string) {
this.outerUrl = outerUrl
},
@ -154,6 +179,11 @@ export const userStore = defineStore('embedded', {
this.setDvId('')
this.setJumpInfoParam('')
this.setOuterUrl('')
this.setDatasourceId('')
this.setTableName('')
this.setDatasetId('')
this.setDatasetCopyId('')
this.setdatasetPid('')
}
}
})

View File

@ -581,8 +581,14 @@ const getTableName = async (datasourceId, tableName) => {
}
const initEdite = async () => {
const { id, datasourceId, tableName } = route.query
const { id: copyId } = route.params
let { id, datasourceId, tableName } = route.query
let { id: copyId } = route.params
if (appStore.getIsDataEaseBi) {
id = embeddedStore.datasetId
datasourceId = embeddedStore.datasourceId
tableName = embeddedStore.tableName
copyId = embeddedStore.datasetCopyId || copyId
}
if (copyId || id) {
const barRes = await barInfoApi(copyId || id)
if (!barRes || !barRes['id']) {
@ -954,7 +960,7 @@ const datasetSave = () => {
}
let union = []
dfsNodeList(union, datasetDrag.value.getNodeList())
const pid = route.query.pid || nodeInfo.pid
const pid = appStore.getIsDataEaseBi ? embeddedStore.datasetPid : route.query.pid || nodeInfo.pid
if (!union.length) {
ElMessage.error('数据集不能为空')
return

View File

@ -2,6 +2,8 @@
import { useI18n } from '@/hooks/web/useI18n'
import { ref, reactive, shallowRef, computed, watch, onBeforeMount, nextTick, unref } from 'vue'
import ArrowSide from '@/views/common/DeResourceArrow.vue'
import { useEmbedded } from '@/store/modules/embedded'
import { useEmitt } from '@/hooks/web/useEmitt'
import {
ElIcon,
ElMessageBox,
@ -284,8 +286,15 @@ const handleNodeClick = (data: BusiTreeNode) => {
const editorDataset = () => {
handleEdit(nodeInfo.id)
}
const embedded = useEmbedded()
const handleEdit = id => {
if (isDataEaseBi.value) {
embedded.clearState()
embedded.setDatasetId(id as string)
useEmitt().emitter.emit('changeCurrentComponent', 'DatasetEditor')
return
}
router.push({
path: '/dataset-form',
query: {
@ -295,6 +304,12 @@ const handleEdit = id => {
}
const createDataset = (data?: BusiTreeNode) => {
if (isDataEaseBi.value) {
embedded.clearState()
embedded.setdatasetPid(data?.id as string)
useEmitt().emitter.emit('changeCurrentComponent', 'DatasetEditor')
return
}
router.push({
path: '/dataset-form',
query: {
@ -340,6 +355,12 @@ const handleClick = (tabName: TabPaneName) => {
const operation = (cmd: string, data: BusiTreeNode, nodeType: string) => {
if (cmd === 'copy') {
if (isDataEaseBi.value) {
embedded.clearState()
embedded.setDatasetCopyId(data.id as string)
useEmitt().emitter.emit('changeCurrentComponent', 'DatasetEditor')
return
}
router.push({
name: 'dataset-form',
params: {

View File

@ -8,6 +8,7 @@ import ArrowSide from '@/views/common/DeResourceArrow.vue'
import { HandleMore } from '@/components/handle-more'
import { Icon } from '@/components/icon-custom'
import { fieldType } from '@/utils/attr'
import { useEmitt } from '@/hooks/web/useEmitt'
import { getHidePwById, listSyncRecord, uploadFile } from '@/api/datasource'
import CreatDsGroup from './form/CreatDsGroup.vue'
import type { Tree } from '../dataset/form/CreatDsGroup.vue'
@ -43,6 +44,7 @@ import { cloneDeep } from 'lodash-es'
import { interactiveStoreWithOut } from '@/store/modules/interactive'
import treeSort from '@/utils/treeSortUtils'
import { useCache } from '@/hooks/web/useCache'
import { useEmbedded } from '@/store/modules/embedded'
const route = useRoute()
const interactiveStore = interactiveStoreWithOut()
interface Field {
@ -77,8 +79,15 @@ const recordState = reactive({
})
const isDataEaseBi = computed(() => appStore.getIsDataEaseBi)
const isIframe = computed(() => appStore.getIsIframe)
const embedded = useEmbedded()
const createDataset = (tableName?: string) => {
if (isDataEaseBi.value) {
embedded.clearState()
embedded.setDatasourceId(nodeInfo.id as string)
embedded.setTableName(tableName)
useEmitt().emitter.emit('changeCurrentComponent', 'DatasetEditor')
return
}
router.push({
path: '/dataset-form',
query: {
@ -127,7 +136,7 @@ const typeMap = dsTypes.reduce((pre, next) => {
}, {})
const datasetTypeList = computed(() => {
const list = [
return [
{
label: '新建数据源',
svgName: 'icon_dataset',
@ -140,11 +149,6 @@ const datasetTypeList = computed(() => {
command: 'folder'
}
]
if (isDataEaseBi.value) {
list.shift()
list[0].divided = false
}
return list
})
const dsTableDataLoading = ref(false)
@ -825,7 +829,7 @@ const mouseleave = () => {
}
const getMenuList = (val: boolean) => {
return !val || isDataEaseBi.value
return !val
? menuList
: [
{
@ -865,18 +869,13 @@ const getMenuList = (val: boolean) => {
<el-tooltip effect="dark" content="新建文件夹" placement="top">
<el-icon
class="custom-icon btn"
:style="{ marginRight: isDataEaseBi ? 0 : '20px' }"
:style="{ marginRight: '20px' }"
@click="handleDatasourceTree('folder')"
>
<Icon name="dv-new-folder" />
</el-icon>
</el-tooltip>
<el-tooltip
v-if="!isDataEaseBi"
effect="dark"
:content="t('datasource.create')"
placement="top"
>
<el-tooltip effect="dark" :content="t('datasource.create')" placement="top">
<el-icon class="custom-icon btn" @click="createDatasource">
<Icon name="icon_file-add_outlined" />
</el-icon>
@ -966,7 +965,7 @@ const getMenuList = (val: boolean) => {
<el-icon
class="hover-icon"
@click.stop="handleEdit(data)"
v-else-if="data.type !== 'Excel' && !isDataEaseBi"
v-else-if="data.type !== 'Excel'"
>
<icon name="icon_edit_outlined"></icon>
</el-icon>
@ -993,11 +992,7 @@ const getMenuList = (val: boolean) => {
>
<template v-if="!state.datasourceTree.length && mounted">
<empty-background description="暂无数据源" img-type="none">
<el-button
v-if="rootManage && !isDataEaseBi"
@click="() => createDatasource()"
type="primary"
>
<el-button v-if="rootManage" @click="() => createDatasource()" type="primary">
<template #icon>
<Icon name="icon_add_outlined"></Icon>
</template>
@ -1029,7 +1024,7 @@ const getMenuList = (val: boolean) => {
:creator="infoList.creator"
></dataset-detail>
</el-popover>
<div class="right-btn flex-align-center" v-if="!isDataEaseBi">
<div class="right-btn flex-align-center">
<el-button secondary @click="createDataset(null)" v-permission="['dataset']">
<template #icon>
<Icon name="icon_dataset_outlined"></Icon>
@ -1175,12 +1170,7 @@ const getMenuList = (val: boolean) => {
width="108"
>
<template #default="scope">
<el-tooltip
v-if="!isDataEaseBi"
effect="dark"
content="新建数据集"
placement="top"
>
<el-tooltip effect="dark" content="新建数据集" placement="top">
<el-button
@click.stop="createDataset(scope.row.tableName)"
text