diff --git a/core/core-frontend/src/views/visualized/data/datasource/form/index.vue b/core/core-frontend/src/views/visualized/data/datasource/form/index.vue index 43e66ff474..ff8f3f98e6 100644 --- a/core/core-frontend/src/views/visualized/data/datasource/form/index.vue +++ b/core/core-frontend/src/views/visualized/data/datasource/form/index.vue @@ -381,7 +381,7 @@ const saveDS = () => { const validate = detail.value.submitForm() validate(val => { if (val) { - if (editDs.value) { + if (editDs.value && form.id) { let options = { confirmButtonType: 'danger', type: 'warning', @@ -478,7 +478,7 @@ const drawTitle = computed(() => { if (creator && id && currentDsType.value == 'Excel') { return editType === 1 ? '追加数据' : '替换数据' } - return editDs.value ? t('datasource.modify') : '创建数据源' + return editDs.value ? (!form.id ? '复制数据源' : t('datasource.modify')) : '创建数据源' }) const beforeClose = () => { diff --git a/core/core-frontend/src/views/visualized/data/datasource/index.vue b/core/core-frontend/src/views/visualized/data/datasource/index.vue index 7b0b1b2d7d..5714104ade 100644 --- a/core/core-frontend/src/views/visualized/data/datasource/index.vue +++ b/core/core-frontend/src/views/visualized/data/datasource/index.vue @@ -424,6 +424,7 @@ const handleNodeClick = data => { createTime, creator, type, + pid, configuration, syncSetting, apiConfigurationStr, @@ -440,6 +441,7 @@ const handleNodeClick = data => { } Object.assign(nodeInfo, { name, + pid, description, fileName, size, @@ -534,6 +536,13 @@ const handleEdit = async data => { datasourceEditor.value.init(nodeInfo) } +const handleCopy = async data => { + await handleNodeClick(data) + nodeInfo.id = '' + nodeInfo.name = '复制数据源' + datasourceEditor.value.init(nodeInfo) +} + const handleDatasourceTree = (cmd: string, data?: Tree) => { if (cmd === 'datasource') { createDatasource(data) @@ -543,6 +552,10 @@ const handleDatasourceTree = (cmd: string, data?: Tree) => { } } const operation = (cmd: string, data: Tree, nodeType: string) => { + if (cmd === 'copy') { + handleCopy(data) + return + } if (cmd === 'delete') { let options = { confirmButtonText: t('common.sure'), @@ -633,6 +646,18 @@ onMounted(() => { datasourceEditor.value.init(null, null) } }) + +const getMenuList = (val: boolean) => { + return !val + ? menuList + : [ + { + label: t('common.copy'), + svgName: 'icon_copy_filled', + command: 'copy' + } + ].concat(menuList) +}