Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improvement: 子流程更新时保留当前输入参数值 #76 #79

Merged
Merged
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
39 changes: 27 additions & 12 deletions pipeline/blueflow/src/pages/template/TemplateEdit/NodeConfig.vue
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@ export default {
const isSubAtomChanged = this.currentAtom !== this.nodeConfigData.template_id
try {
this.subAtomConfigData = await this.loadSubflowConfig({templateId: id, version, common: this.common})
this.nodeConfigData.version = this.subAtomConfigData.version
const constants = {}
const inputConfig = []
const outputConfig = []
let variableArray = []
Expand Down Expand Up @@ -525,7 +525,6 @@ export default {
// 遍历加载标准插件表单配置文件
for (let form of variableArray) {
let key = form.key
let constantData = {}
const sourceTag = form.source_tag
if (sourceTag) {
const [ atomType, tagCode ] = sourceTag.split('.')
Expand Down Expand Up @@ -569,9 +568,9 @@ export default {
// 子流程表单项的取值
// 首次添加、子流程切换、子流程更新时,取接口返回的 form
// 编辑时,取 activities 里对应的全局变量 form
constantData = this.activities[this.nodeId].constants[key] || form
this.$set(this.nodeConfigData.constants, key, tools.deepClone(constantData))
constants[key] = this.activities[this.nodeId].constants[key] || form
}
this.$set(this.nodeConfigData, 'constants', tools.deepClone(constants))
for ( let key in this.subAtomConfigData.outputs ) {
const output = this.subAtomConfigData.outputs[key]
const item = {
Expand Down Expand Up @@ -642,7 +641,6 @@ export default {
}
} else {
this.currentAtom = formData.template_id

for (let key in formData.constants) {
const form = formData.constants[key]
const tagCode = key.match(varKeyReg)[1]
Expand Down Expand Up @@ -800,9 +798,8 @@ export default {
/**
* 切换标准插件节点,清空勾选的变量
*/
clearHookedVaribles () {
const hookedVariables = this.getHookedInputVariables()
hookedVariables.forEach(item => {
clearHookedVaribles (hookedInputs, outputs) {
hookedInputs.forEach(item => {
const {id, variableKey, formKey, tagCode} = item
const variable = this.constants[variableKey]
this.setVariableSourceInfo({type: 'delete', id, key: variableKey, tagCode: formKey})
Expand All @@ -811,7 +808,7 @@ export default {
}
})
this.taskTypeEmpty = false
this.renderOutputData.forEach(item => {
outputs.forEach(item => {
if (item.hook) {
this.deleteVariable(item.key)
}
Expand All @@ -820,7 +817,7 @@ export default {
onAtomSelect (id, data) {
this.isAtomChanged = true
let nodeName
this.clearHookedVaribles()
tthis.clearHookedVaribles(this.getHookedInputVariables(), this.renderOutputData)
this.currentAtom = id
if (this.isSingleAtom) {
nodeName = data.name.split('-').slice(1).join().replace(/\s/g, '')
Expand Down Expand Up @@ -852,15 +849,33 @@ export default {
* 更新 store 数据状态
*/
onUpdateSubflowVersion () {
this.clearHookedVaribles()
const oldInputAtomHook = this.inputAtomHook
const oldInputAtomData = this.inputAtomData

// 清空 store 里的 constants 值
this.subAtomConfigData.form = {}
this.inputAtomHook = {}
this.inputAtomData = {}
this.updateActivities()

this.getSubflowConfig(this.currentAtom).then( ()=> {
this.getSubflowConfig(this.currentAtom).then(()=> {
const newInputAtomData = tools.deepClone(this.inputAtomData)
Object.keys(oldInputAtomData).forEach(key => {
if (this.inputAtomData.hasOwnProperty(key)) {
this.$set(this.inputAtomData, key, oldInputAtomData[key])
} else if (oldInputAtomHook[key]) {
const variable = [
{
variableKey: key,
formKey: key,
id: this.nodeId,
tagCode: key
}
]
this.clearHookedVaribles(variable, [])
}
})
this.updateActivities()
this.subflowHasUpdate = false
this.$emit('onUpdateNodeInfo', this.idOfNodeInConfigPanel, { hasUpdated: false })
this.setSubprocessUpdated({
Expand Down