Merge pull request #8997 from dataease/pr@dev-v2_bug_fix

Pr@dev v2 bug fix
This commit is contained in:
dataeaseShu 2024-04-08 17:28:23 +08:00 committed by GitHub
commit e90da94055
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 67 additions and 17 deletions

View File

@ -1,5 +1,5 @@
<script lang="ts" setup>
import { reactive, computed, ref, nextTick, inject, type Ref } from 'vue'
import { reactive, computed, ref, nextTick, inject, type Ref, watch } from 'vue'
import AddSql from './AddSql.vue'
import { useI18n } from '@/hooks/web/useI18n'
import zeroNodeImg from '@/assets/img/drag.png'
@ -108,9 +108,22 @@ const dfsNodeNameList = (list, arr) => {
})
}
let isUpdate = false
watch(
() => state.nodeList,
() => {
if (isUpdate) {
emits('changeUpdate')
}
},
{ deep: true }
)
const initState = nodeList => {
Object.assign(state.nodeList, nodeList)
nextTick(() => {
isUpdate = true
emits('addComplete')
})
}
@ -775,7 +788,7 @@ const defaultParam = {
}
const dfsNodeListRename = arr => {
arr.some(ele => {
if (ele.id === renameParam.id) {
if (ele.id === renameParam.id && ele.tableName !== renameParam.name) {
ele.tableName = renameParam.name
return true
}
@ -829,7 +842,7 @@ const handleActiveNode = ele => {
handleCommand(ele, 'editerField')
}
const emits = defineEmits(['addComplete', 'joinEditor', 'updateAllfields'])
const emits = defineEmits(['addComplete', 'joinEditor', 'updateAllfields', 'changeUpdate'])
</script>
<template>

View File

@ -84,6 +84,7 @@ const currentField = ref({
name: '',
idArr: []
})
let isUpdate = false
const fieldTypes = index => {
return [
@ -96,6 +97,10 @@ const fieldTypes = index => {
][index]
}
const changeUpdate = () => {
isUpdate = true
}
const fieldOptions = [
{ label: t('dataset.text'), value: 0 },
{
@ -230,7 +235,7 @@ const pushDataset = () => {
}
const backToMain = () => {
if (!nodeInfo.id) {
if (isUpdate) {
ElMessageBox.confirm('数据集未保存,确认退出吗?', {
confirmButtonText: t('dataset.confirm'),
cancelButtonText: t('common.cancel'),
@ -307,7 +312,7 @@ const confirmCustomTime = () => {
}
watch(searchTable, val => {
state.tableData = tableList.filter(ele => ele.name.includes(val))
state.tableData = tableList.filter(ele => ele.name.toLowerCase().includes(val.toLowerCase()))
})
const editeSave = () => {
const union = []
@ -321,6 +326,7 @@ const editeSave = () => {
nodeType: 'dataset'
})
.then(() => {
isUpdate = false
ElMessage.success('保存成功')
if (willBack) {
pushDataset()
@ -332,6 +338,7 @@ const editeSave = () => {
}
const handleFieldMore = (ele, type) => {
changeUpdate()
if (tabActive.value === 'manage') {
dimensionsSelection.value = dimensionsTable.value.getSelectionRows().map(ele => ele.id)
quotaSelection.value = quotaTable.value.getSelectionRows().map(ele => ele.id)
@ -654,7 +661,6 @@ const addComplete = () => {
}
const state = reactive({
nameList: [],
nodeNameList: [],
editArr: [],
nodeList: [],
@ -1067,7 +1073,10 @@ const cascaderChangeArr = val => {
})
recoverSelection()
}
const filterNode = (value: string, data: BusiTreeNode) => {
if (!value) return true
return data.name?.toLowerCase().includes(value.toLowerCase())
}
const recoverSelection = () => {
nextTick(() => {
quota.value.forEach(ele => {
@ -1228,6 +1237,7 @@ const getDsIconName = data => {
@change="dsChange"
:placeholder="t('dataset.pls_slc_data_source')"
class="ds-list"
:filter-node-method="filterNode"
filterable
popper-class="tree-select-ds_popper"
v-model="dataSource"
@ -1294,16 +1304,11 @@ const getDsIconName = data => {
</div>
<template v-for="ele in state.tableData" :key="ele.name">
<div
:class="[
{
'not-allow': state.nodeNameList.includes(`${ele.tableName}${dataSource}`)
}
]"
class="list-item_primary"
:title="ele.name"
@dragstart="$event => dragstart($event, ele)"
@dragend="maskShow = false"
:draggable="!state.nodeNameList.includes(`${ele.tableName}${dataSource}`)"
:draggable="true"
@click="setActiveName(ele)"
>
<el-icon class="icon-color">
@ -1317,6 +1322,7 @@ const getDsIconName = data => {
<div class="drag-right" :style="{ width: `calc(100vw - ${showLeft ? LeftWidth : 0}px)` }">
<dataset-union
@join-editor="joinEditor"
@changeUpdate="changeUpdate"
:maskShow="maskShow"
:dragHeight="dragHeight"
:getDsName="getDsName"

View File

@ -494,7 +494,7 @@ const changeSideTreeStatus = val => {
const filterNode = (value: string, data: BusiTreeNode) => {
if (!value) return true
return data.name?.includes(value)
return data.name?.toLowerCase().includes(value.toLowerCase())
}
const mouseenter = () => {
appStore.setArrowSide(true)

View File

@ -44,6 +44,12 @@ const creatDsFolder = ref()
const router = useRouter()
const { wsCache } = useCache()
const dsLoading = ref(false)
let isFormUpdate = false
let isForm2Update = false
let isUpdate = false
const changeUpdate = val => {
isUpdate = val
}
const state = reactive({
datasourceTree: []
})
@ -302,6 +308,7 @@ const typeTitle = computed(() => {
})
const saveDS = () => {
isUpdate = false
const request = JSON.parse(JSON.stringify(form)) as unknown as Omit<
Form,
'configuration' | 'apiConfiguration'
@ -429,6 +436,26 @@ const visible = ref(false)
const editDs = ref(false)
const pid = ref('0')
watch(
() => form,
() => {
if (isFormUpdate) {
changeUpdate(true)
}
},
{ deep: true }
)
watch(
() => form2,
() => {
if (isForm2Update) {
changeUpdate(true)
}
},
{ deep: true }
)
const init = (nodeInfo: Form | Param, id?: string, res?: object) => {
editDs.value = !!nodeInfo
showFinishPage.value = false
@ -449,6 +476,10 @@ const init = (nodeInfo: Form | Param, id?: string, res?: object) => {
activeApiStep.value = activeStep.value
visible.value = true
nextTick(() => {
isForm2Update = true
isFormUpdate = true
})
if (!!nodeInfo) {
nextTick(() => {
currentDsType.value = nodeInfo.type
@ -477,7 +508,7 @@ const beforeClose = () => {
emits('refresh')
wsCache.set('ds-new-success', false)
}
if (!showFinishPage.value && (editDs.value || activeStep.value !== 0)) {
if (!showFinishPage.value && ((!editDs.value && activeStep.value !== 0) || isUpdate)) {
ElMessageBox.confirm(t('chart.tips'), {
confirmButtonType: 'primary',
tip: '你填写的信息未保存,确认退出吗?',
@ -625,7 +656,7 @@ defineExpose({
</div>
</div>
<div class="editor-footer" v-loading="dsLoading">
<el-button secondary @click="visible = false"> {{ t('common.cancel') }}</el-button>
<el-button secondary @click="beforeClose"> {{ t('common.cancel') }}</el-button>
<el-button
v-show="!(activeStep === 0 || (editDs && activeApiStep <= 1))"
secondary

View File

@ -563,7 +563,7 @@ const nodeCollapse = data => {
const filterNode = (value: string, data: BusiTreeNode) => {
if (!value) return true
return data.name?.includes(value)
return data.name?.toLowerCase().includes(value.toLowerCase())
}
const editDatasource = (editType?: number) => {