forked from github/dataease
Merge pull request #13015 from dataease/dev-v2@fixexportdata
fix: 【数据源】修复数据源校验结果会在前端影响到其他数据源状态
This commit is contained in:
commit
62beb3dba7
@ -139,7 +139,6 @@ const dsTableDetail = reactive({
|
|||||||
name: ''
|
name: ''
|
||||||
})
|
})
|
||||||
const rootManage = ref(false)
|
const rootManage = ref(false)
|
||||||
const nodeData = ref({})
|
|
||||||
const nickName = ref('')
|
const nickName = ref('')
|
||||||
const dsName = ref('')
|
const dsName = ref('')
|
||||||
const userDrawer = ref(false)
|
const userDrawer = ref(false)
|
||||||
@ -276,31 +275,31 @@ const validateDS = () => {
|
|||||||
.then(res => {
|
.then(res => {
|
||||||
if (res.data.type === 'API') {
|
if (res.data.type === 'API') {
|
||||||
let error = 0
|
let error = 0
|
||||||
const status = JSON.parse(res.data.status)
|
const dsStatus = JSON.parse(res.data.status)
|
||||||
for (let i = 0; i < status.length; i++) {
|
for (let i = 0; i < dsStatus.length; i++) {
|
||||||
if (status[i].status === 'Error') {
|
if (dsStatus[i].status === 'Error') {
|
||||||
error++
|
error++
|
||||||
}
|
}
|
||||||
for (let i = 0; i < nodeInfo.apiConfiguration.length; i++) {
|
for (let i = 0; i < nodeInfo.apiConfiguration.length; i++) {
|
||||||
if (nodeInfo.apiConfiguration[i].name === status[i].name) {
|
if (nodeInfo.apiConfiguration[i].name === dsStatus[i].name) {
|
||||||
nodeInfo.apiConfiguration[i].status = status[i].status
|
nodeInfo.apiConfiguration[i].status = dsStatus[i].status
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (error === 0) {
|
if (error === 0) {
|
||||||
nodeData.value.extraFlag = Math.abs(nodeData.value.extraFlag)
|
changeDsStatus(state.datasourceTree, nodeInfo.id, Math.abs(nodeInfo.extraFlag))
|
||||||
ElMessage.success(t('data_source.verification_successful'))
|
ElMessage.success(t('data_source.verification_successful'))
|
||||||
} else {
|
} else {
|
||||||
nodeData.value.extraFlag = -Math.abs(nodeData.value.extraFlag)
|
changeDsStatus(state.datasourceTree, nodeInfo.id, -Math.abs(nodeInfo.extraFlag))
|
||||||
ElMessage.error(t('data_source.verification_failed'))
|
ElMessage.error(t('data_source.verification_failed'))
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
nodeData.value.extraFlag = Math.abs(nodeData.value.extraFlag)
|
changeDsStatus(state.datasourceTree, nodeInfo.id, Math.abs(nodeInfo.extraFlag))
|
||||||
ElMessage.success(t('data_source.verification_successful'))
|
ElMessage.success(t('data_source.verification_successful'))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
nodeData.value.extraFlag = -Math.abs(nodeData.value.extraFlag)
|
changeDsStatus(state.datasourceTree, nodeInfo.id, -Math.abs(nodeInfo.extraFlag))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -412,7 +411,8 @@ const defaultInfo = {
|
|||||||
syncSetting: null,
|
syncSetting: null,
|
||||||
apiConfiguration: [],
|
apiConfiguration: [],
|
||||||
weight: 0,
|
weight: 0,
|
||||||
enableDataFill: false
|
enableDataFill: false,
|
||||||
|
extraFlag: 0
|
||||||
}
|
}
|
||||||
const nodeInfo = reactive<Node>(cloneDeep(defaultInfo))
|
const nodeInfo = reactive<Node>(cloneDeep(defaultInfo))
|
||||||
const infoList = computed(() => {
|
const infoList = computed(() => {
|
||||||
@ -490,6 +490,19 @@ const listDs = () => {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const changeDsStatus = (ds, id, extraFlag) => {
|
||||||
|
ds.some(ele => {
|
||||||
|
if (ele.id === id) {
|
||||||
|
ele.extraFlag = extraFlag
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
if (!!ele.children?.length) {
|
||||||
|
changeDsStatus(ele.children, id, extraFlag)
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
const dfsDatasourceTree = (ds, id) => {
|
const dfsDatasourceTree = (ds, id) => {
|
||||||
ds.some(ele => {
|
ds.some(ele => {
|
||||||
if (ele.id === id) {
|
if (ele.id === id) {
|
||||||
@ -530,7 +543,6 @@ const sortTypeTip = computed(() => {
|
|||||||
const tableData = shallowRef([])
|
const tableData = shallowRef([])
|
||||||
const tabData = shallowRef([])
|
const tabData = shallowRef([])
|
||||||
const handleNodeClick = data => {
|
const handleNodeClick = data => {
|
||||||
nodeData.value = data
|
|
||||||
if (!data.leaf) {
|
if (!data.leaf) {
|
||||||
dsListTree.value.setCurrentKey(null)
|
dsListTree.value.setCurrentKey(null)
|
||||||
return
|
return
|
||||||
@ -580,7 +592,8 @@ const handleNodeClick = data => {
|
|||||||
paramsConfiguration: paramsStr,
|
paramsConfiguration: paramsStr,
|
||||||
weight: data.weight,
|
weight: data.weight,
|
||||||
lastSyncTime,
|
lastSyncTime,
|
||||||
enableDataFill
|
enableDataFill,
|
||||||
|
extraFlag: data.extraFlag
|
||||||
})
|
})
|
||||||
activeTab.value = ''
|
activeTab.value = ''
|
||||||
activeName.value = 'config'
|
activeName.value = 'config'
|
||||||
|
Loading…
Reference in New Issue
Block a user