fix: 支持数据源的复制

This commit is contained in:
dataeaseShu 2023-11-08 15:48:13 +08:00
parent 60966fb6e3
commit 303be6026e
2 changed files with 28 additions and 3 deletions

View File

@ -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 = () => {

View File

@ -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)
}
</script>
<template>
@ -718,7 +743,7 @@ onMounted(() => {
@handle-command="
cmd => operation(cmd, data, data.leaf ? 'datasource' : 'folder')
"
:menu-list="menuList"
:menu-list="getMenuList(!['Excel', 'API'].includes(data.type) && data.leaf)"
></handle-more>
</div>
</span>