Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,10 @@ export default {
const indexOfParent = parentNode.children.findIndex(n => n.id === id)
~indexOfParent && parentNode.children.splice(indexOfParent, 1)
parentNode.children.push(...childrenNodes)

// 从父节点的输入上删除
const oldIndex = this.inputsMap[parentNode.id].indexOf(id)
this.inputsMap[parentNode.id].splice(oldIndex, 1)
} else {
const { mergeProperties } = this.activeNode
const index = mergeProperties.findIndex(n => n.id === id)
Expand Down Expand Up @@ -647,7 +651,7 @@ export default {
if (this.targetNode?.id) {
// 更新目标节点schema
await this.afterTaskSaved()
await this.loadNodeSchema(this.targetNode.id)
await this.onLoadTargetSchema(this.targetNode.id)
}
},

Expand Down
125 changes: 83 additions & 42 deletions packages/dag/src/components/materialized-view/Node.vue
Original file line number Diff line number Diff line change
Expand Up @@ -303,51 +303,29 @@ export default {
},

treeData() {
// console.log('computed:treeData')
let { schema } = this
let schema = this.schema ? [...this.schema] : []

if (!schema) return []

const richFields = (inputs, targetPath) => {
let arr = []
for (const input of inputs) {
const inputNode = this.nodeMap[input]
let fields = this.nodeSchemaMap[input]
if (!fields) continue
const inputs = this.inputsMap?.[this.node.id]

let nodeTargetPath = inputNode.targetPath
if (nodeTargetPath && targetPath) {
nodeTargetPath = nodeTargetPath.replace(new RegExp(`${targetPath}?.`), '')
}
if (inputs?.length) {
const { targetPath } = this.node
let mergedFields = this.richFields(this.inputsMap[this.node.id], this.node.targetPath)

if (targetPath) {
mergedFields = mergedFields
.map(field => {
return {
...field,
field_name: field.field_name.replace(new RegExp(`^${targetPath}\\.|^${targetPath}$`), '')
}
})
.filter(field => !!field.field_name)

if (this.inputsMap[input]?.length) {
arr = unionBy(arr, fields, richFields(this.inputsMap[input], nodeTargetPath), 'field_name')
} else {
// if (nodeTargetPath && targetPath) {
// nodeTargetPath.replace(new RegExp(`${targetPath}?.`), '')
// }

if (nodeTargetPath) {
fields = fields.map(field => {
return {
...field,
field_name: `${nodeTargetPath}.${field.field_name}`
}
})
fields.unshift({
field_name: nodeTargetPath,
dataType: 'DOCUMENT'
})
}
arr = unionBy(arr, fields)
}
console.log('mergedFields', mergedFields)
}
return arr
}
const inputs = this.inputsMap?.[this.node.id]

if (inputs?.length) {
const mergedFields = richFields(this.inputsMap[this.node.id], this.node.targetPath)
schema = unionBy(schema, mergedFields, 'field_name')
schema.sort((a, b) => {
let aVal, bVal
Expand All @@ -366,12 +344,9 @@ export default {

return aVal - bVal
})
console.log('schema', schema)
}

const treeData = this.createTree(schema)

return treeData
return this.createTree(schema)
},

sourceNodes() {
Expand Down Expand Up @@ -813,6 +788,8 @@ export default {
Object.keys(nodeAttrs).forEach(key => {
this.$set(this.dagNode.attrs, key, nodeAttrs[key])
})

console.log('this.dagNode.attrs', this.dagNode.attrs.connectionName, connection)
},

async onChangeConnection() {
Expand Down Expand Up @@ -866,6 +843,70 @@ export default {
}

animationId = requestAnimationFrame(revalidate)
},

/**
* 根据写入路径,收集上游字段
* @param inputs
* @param targetPath
* @returns {*[]}
*/
richFields(inputs, targetPath) {
let arr = []

for (const input of inputs) {
const inputNode = this.nodeMap[input]
let fields = this.nodeSchemaMap[input]

if (!fields) continue

let nodeTargetPath = inputNode.targetPath

/*if (nodeTargetPath && targetPath) {
nodeTargetPath = nodeTargetPath.replace(new RegExp(`^${targetPath}\\.|^${targetPath}$`), '')
}*/

if (this.isMainTable) {
console.log('path', targetPath, nodeTargetPath, inputNode.targetPath)
}

if (this.inputsMap[input]?.length) {
if (nodeTargetPath /* && inputNode.targetPath === nodeTargetPath*/) {
fields = fields.map(field => {
return {
...field,
field_name: `${nodeTargetPath}.${field.field_name}`
}
})

fields.unshift({
field_name: nodeTargetPath,
dataType: 'DOCUMENT'
})
}

const newFields = this.richFields(this.inputsMap[input], nodeTargetPath)

arr = unionBy(arr, fields, newFields, 'field_name')
} else {
if (nodeTargetPath) {
fields = fields.map(field => {
return {
...field,
field_name: `${nodeTargetPath}.${field.field_name}`
}
})

fields.unshift({
field_name: nodeTargetPath,
dataType: 'DOCUMENT'
})
}
arr = unionBy(arr, fields)
}
}

return arr
}
}
}
Expand Down
15 changes: 5 additions & 10 deletions packages/form/src/components/async-select/AsyncSelect.vue
Original file line number Diff line number Diff line change
Expand Up @@ -421,16 +421,7 @@ export default {
async setSelected() {
if (!this.multiple) {
let option = await this.getOption(this.value)
// 不添加!this.lazy 会导致 onSetSelected 的参数为 { value: this.value, currentLabel: this.currentLabel}
// 防止开启了lazy 同时设置了currentLabel,进入这个判断
if (this.currentLabel && !this.lazy) {
option = {
value: this.value,
currentLabel: this.currentLabel
}
} else {
option = await this.getOption(this.value)
}

if (this.onSetSelected && ~this.hoverIndex) {
if (!option.$el) {
this.onSetSelected(option)
Expand All @@ -448,6 +439,10 @@ export default {
this.selectedLabel = option.currentLabel
this.selected = option
if (this.filterable) this.query = this.selectedLabel

if (option.currentLabel === option.value && this.itemType === 'object' && this.currentLabel) {
this.selectedLabel = this.currentLabel
}
return
}
let result = []
Expand Down