forked from github/dataease
fix(数据集): 修复保存数据集的时候出现错误
This commit is contained in:
parent
8bb8b2b9fe
commit
cd35f3629d
@ -1,5 +1,5 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { reactive, computed, ref, nextTick, inject, type Ref, watch } from 'vue'
|
import { reactive, computed, ref, nextTick, inject, type Ref, watch, unref } from 'vue'
|
||||||
import AddSql from './AddSql.vue'
|
import AddSql from './AddSql.vue'
|
||||||
import { useI18n } from '@/hooks/web/useI18n'
|
import { useI18n } from '@/hooks/web/useI18n'
|
||||||
import zeroNodeImg from '@/assets/img/drag.png'
|
import zeroNodeImg from '@/assets/img/drag.png'
|
||||||
@ -113,14 +113,14 @@ const dfsForDsId = (arr, datasourceId) => {
|
|||||||
if (arr.children?.length) {
|
if (arr.children?.length) {
|
||||||
return dfsForDsId(arr.children, datasourceId)
|
return dfsForDsId(arr.children, datasourceId)
|
||||||
}
|
}
|
||||||
return ele.datasourceId === datasourceId
|
return ele.datasourceId === datasourceId || !ele.datasourceId
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
const crossDatasources = computed(() => {
|
const crossDatasources = computed(() => {
|
||||||
const { datasourceId, children = [] } = state.nodeList[0] || {}
|
const { datasourceId, children = [] } = state.nodeList[0] || {}
|
||||||
if (datasourceId && !!children.length) {
|
if (datasourceId && !!children.length) {
|
||||||
return dfsForDsId(children, datasourceId)
|
return !dfsForDsId(children, datasourceId)
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
})
|
})
|
||||||
@ -251,6 +251,8 @@ const changeNodeFields = val => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const closeEditUnion = () => {
|
const closeEditUnion = () => {
|
||||||
|
nodeField.value = []
|
||||||
|
currentNode.value = null
|
||||||
const [fir] = state.nodeList
|
const [fir] = state.nodeList
|
||||||
if (fir.isShadow) {
|
if (fir.isShadow) {
|
||||||
delete fir.isShadow
|
delete fir.isShadow
|
||||||
@ -848,9 +850,13 @@ const notConfirm = () => {
|
|||||||
confirm()
|
confirm()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const getNodeList = () => {
|
||||||
|
return cloneDeep(unref(state.nodeList))
|
||||||
|
}
|
||||||
|
|
||||||
defineExpose({
|
defineExpose({
|
||||||
nodeNameList,
|
nodeNameList,
|
||||||
nodeList: state.nodeList,
|
getNodeList,
|
||||||
setStateBack,
|
setStateBack,
|
||||||
notConfirm,
|
notConfirm,
|
||||||
dfsNodeFieldBack,
|
dfsNodeFieldBack,
|
||||||
|
@ -318,7 +318,7 @@ watch(searchTable, val => {
|
|||||||
const editeSave = () => {
|
const editeSave = () => {
|
||||||
const union = []
|
const union = []
|
||||||
loading.value = true
|
loading.value = true
|
||||||
dfsNodeList(union, datasetDrag.value.nodeList)
|
dfsNodeList(union, datasetDrag.value.getNodeList())
|
||||||
saveDatasetTree({
|
saveDatasetTree({
|
||||||
...nodeInfo,
|
...nodeInfo,
|
||||||
name: datasetName.value,
|
name: datasetName.value,
|
||||||
@ -448,7 +448,7 @@ const deleteField = item => {
|
|||||||
callback: (action: Action) => {
|
callback: (action: Action) => {
|
||||||
if (action === 'confirm') {
|
if (action === 'confirm') {
|
||||||
delFieldById([item.id])
|
delFieldById([item.id])
|
||||||
datasetDrag.value.dfsNodeFieldBack(datasetDrag.value.nodeList, item)
|
datasetDrag.value.dfsNodeFieldBack(datasetDrag.value.getNodeList(), item)
|
||||||
ElMessage({
|
ElMessage({
|
||||||
message: t('chart.delete_success'),
|
message: t('chart.delete_success'),
|
||||||
type: 'success'
|
type: 'success'
|
||||||
@ -671,7 +671,6 @@ const addComplete = () => {
|
|||||||
const state = reactive({
|
const state = reactive({
|
||||||
nodeNameList: [],
|
nodeNameList: [],
|
||||||
editArr: [],
|
editArr: [],
|
||||||
nodeList: [],
|
|
||||||
dataSourceList: [],
|
dataSourceList: [],
|
||||||
tableData: [],
|
tableData: [],
|
||||||
fieldCollapse: ['dimension', 'quota']
|
fieldCollapse: ['dimension', 'quota']
|
||||||
@ -750,7 +749,7 @@ const fieldUnion = ref()
|
|||||||
|
|
||||||
const setFieldAll = () => {
|
const setFieldAll = () => {
|
||||||
const arr = []
|
const arr = []
|
||||||
dfsFields(arr, datasetDrag.value.nodeList)
|
dfsFields(arr, datasetDrag.value.getNodeList())
|
||||||
const delIdArr = getDelIdArr(arr, allfields.value)
|
const delIdArr = getDelIdArr(arr, allfields.value)
|
||||||
allfields.value = diffArr(arr, allfields.value)
|
allfields.value = diffArr(arr, allfields.value)
|
||||||
delFieldById(delIdArr)
|
delFieldById(delIdArr)
|
||||||
@ -924,7 +923,7 @@ const resetAllfieldsId = arr => {
|
|||||||
|
|
||||||
const resetAllfieldsUnionId = (arr, idMap) => {
|
const resetAllfieldsUnionId = (arr, idMap) => {
|
||||||
let strUnion = JSON.stringify(arr) as string
|
let strUnion = JSON.stringify(arr) as string
|
||||||
let strNodeList = JSON.stringify(toRaw(datasetDrag.value.nodeList)) as string
|
let strNodeList = JSON.stringify(toRaw(datasetDrag.value.getNodeList())) as string
|
||||||
let strAllfields = JSON.stringify(unref(allfields.value)) as string
|
let strAllfields = JSON.stringify(unref(allfields.value)) as string
|
||||||
Object.entries(idMap).forEach(([key, value]) => {
|
Object.entries(idMap).forEach(([key, value]) => {
|
||||||
strUnion = strUnion.replaceAll(key, value as string)
|
strUnion = strUnion.replaceAll(key, value as string)
|
||||||
@ -942,7 +941,7 @@ const datasetSave = () => {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
let union = []
|
let union = []
|
||||||
dfsNodeList(union, datasetDrag.value.nodeList)
|
dfsNodeList(union, datasetDrag.value.getNodeList())
|
||||||
const pid = route.query.pid || nodeInfo.pid
|
const pid = route.query.pid || nodeInfo.pid
|
||||||
if (!union.length) {
|
if (!union.length) {
|
||||||
ElMessage.error('数据集不能为空')
|
ElMessage.error('数据集不能为空')
|
||||||
@ -969,7 +968,7 @@ const datasetPreviewLoading = ref(false)
|
|||||||
const datasetPreview = () => {
|
const datasetPreview = () => {
|
||||||
if (datasetPreviewLoading.value) return
|
if (datasetPreviewLoading.value) return
|
||||||
const arr = []
|
const arr = []
|
||||||
dfsNodeList(arr, datasetDrag.value.nodeList)
|
dfsNodeList(arr, datasetDrag.value.getNodeList())
|
||||||
datasetPreviewLoading.value = true
|
datasetPreviewLoading.value = true
|
||||||
getPreviewData({ union: arr, allFields: allfields.value })
|
getPreviewData({ union: arr, allFields: allfields.value })
|
||||||
.then(res => {
|
.then(res => {
|
||||||
|
Loading…
Reference in New Issue
Block a user