Skip to content

Commit

Permalink
fix: 节点详情重构测试问题修复优化 --ignore
Browse files Browse the repository at this point in the history
# Reviewed, transaction id: 3630
  • Loading branch information
ywywZhou authored and luofann committed Mar 11, 2024
1 parent 717f5d4 commit 8ff3675
Show file tree
Hide file tree
Showing 7 changed files with 141 additions and 195 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,10 @@
type: Object,
default: () => ({})
},
subprocessState: {
type: String,
default: ''
},
subprocessPipeline: {
type: Object,
default: () => ({})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
<NoData v-else :message="$t('暂无执行信息')"></NoData>
</section>
<!-- 任务节点才允许展示输入、输出配置 -->
<template v-if="['tasknode', 'subflow'].includes(location.type)">
<template v-if="['ServiceActivity', 'SubProcess'].includes(nodeDetailConfig.type)">
<InputParams
:admin-view="adminView"
:inputs="executeInfo.inputs"
Expand Down Expand Up @@ -71,14 +71,6 @@
type: Boolean,
default: false
},
loading: {
type: Boolean,
default: false
},
location: {
type: Object,
default: () => ({})
},
executeInfo: {
type: Object,
default: () => ({})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@
isShow: Boolean,
gateways: Object,
conditionData: Object,
backToVariablePanel: Boolean,
isReadonly: {
type: Boolean,
default: false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
ext-cls="execute-info-tab"
@tab-change="onTabChange">
<bk-tab-panel name="record" v-if="!isCondition" :label="$t('执行详情')"></bk-tab-panel>
<bk-tab-panel name="config" v-if="isCondition || (!loading && ['tasknode', 'subflow'].includes(location.type))" :label="$t('配置快照')"></bk-tab-panel>
<bk-tab-panel name="config" v-if="isCondition || (!loading && ['ServiceActivity', 'SubProcess'].includes(nodeDetailConfig.type))" :label="$t('配置快照')"></bk-tab-panel>
<bk-tab-panel name="history" v-if="!isCondition" :label="$t('操作历史')"></bk-tab-panel>
<bk-tab-panel name="log" v-if="!isCondition" :label="$t('调用日志')"></bk-tab-panel>
</bk-tab>
Expand Down Expand Up @@ -64,10 +64,6 @@
<ExecuteRecord
v-if="curActiveTab === 'record'"
:admin-view="adminView"
:loading="loading"
:location="location"
:node-state="nodeState"
:node-activity="nodeActivity"
:execute-info="executeRecord"
:node-detail-config="nodeDetailConfig"
:not-performed-sub-node="notPerformedSubNode"
Expand All @@ -82,12 +78,10 @@
:constants="pipelineTree.constants"
:is-third-party-node="isThirdPartyNode"
:third-party-node-code="thirdPartyNodeCode"
:not-performed-sub-node="notPerformedSubNode"
:is-sub-process-node="isSubProcessNode">
</ExecuteInfoForm>
<section class="info-section" data-test-id="taskExecute_form_operatFlow" v-else-if="curActiveTab === 'history'">
<NodeOperationFlow
:locations="pipelineTree.location"
:node-id="executeInfo.id"
:sub-process-task-id="nodeDetailConfig.taskId"
:not-performed-sub-node="notPerformedSubNode">
Expand Down Expand Up @@ -151,6 +145,10 @@
type: Object,
default: () => ({})
},
nodeActivity: {
type: Object,
default: () => ({})
},
nodeDetailConfig: {
type: Object,
default: () => ({}),
Expand All @@ -160,10 +158,6 @@
type: Object,
default: () => ({})
},
location: {
type: Object,
default: () => ({})
},
notPerformedSubNode: {
type: Boolean,
default: false
Expand All @@ -176,10 +170,6 @@
type: Object,
default: () => ({})
},
nodeState: {
type: String,
default: ''
},
subprocessPipeline: {
type: Object,
default: () => ({})
Expand Down Expand Up @@ -229,17 +219,6 @@
if (!this.isThirdPartyNode) return ''
const nodeInfo = this.pipelineTree.activities[this.nodeDetailConfig.node_id]
return nodeInfo ? nodeInfo.component.data?.plugin_code?.value : ''
},
nodeActivity () {
const { node_id: nodeId } = this.nodeDetailConfig
const { activities, end_event, start_event, gateways } = this.pipelineTree
const nodeMap = {
...activities,
...gateways,
[start_event.id]: { ...start_event, name: this.$t('开始节点') },
[end_event.id]: { ...end_event, name: this.$t('结束节点') }
}
return nodeMap[nodeId]
}
},
watch: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<NodeTreeItem
:active-id="activeId"
:node-list="nodeData"
@dynamicLoad="$emit('dynamicLoad', $event)"
@dynamicLoad="handleDynamicLoad"
@click="handleClickNode">
</NodeTreeItem>
</div>
Expand Down Expand Up @@ -52,10 +52,6 @@
type: Object,
default: () => ({})
},
subNodesExpanded: {
type: Array,
default: () => ([])
},
loading: {
type: Boolean,
default: true
Expand All @@ -72,7 +68,8 @@
nodeSourceMaps: {},
nodeTargetMaps: {},
allCheckoutNodes: [],
subprocessLoading: false
subprocessLoading: false,
subNodesExpanded: [] // 节点树展开的独立子流程节点
}
},
watch: {
Expand Down Expand Up @@ -123,14 +120,18 @@
this.subprocessLoading = true
// 获取子流程任务详情
await this.getSubprocessData(taskId, nodeInfo, true)
this.$emit('updateSubprocessState', taskId)
this.$emit('updateSubprocessState', {
root_node,
node_id,
taskId
})
} catch (error) {
console.warn(error)
}
} else {
nodeInfo.dynamicLoad = false
this.subprocessLoading = false
this.$emit('setSubNodeExpanded', nodeInfo)
this.setSubNodeExpanded(nodeInfo)
}
}
},
Expand Down Expand Up @@ -757,12 +758,15 @@
nodeInfo.dynamicLoad = false
nodeInfo.expanded = true
this.canvasRandomKey = new Date().getTime()
this.$emit('updateNodeTree', {
this.$emit('updateParentPipelineData', {
parentId,
nodeId: nodeInfo.id,
pipeline: { ...pipelineTree, taskId }
})
// 如果当前选中的节点是子流程下的节点,且是子流程未执行时选中的,那么当节点树变更时默认选中该子流程
if (this.executeInfo.state === 'READY' && this.nodeDetailConfig.root_node?.indexOf(nodeInfo.id) > -1) {
this.handleClickNode(nodeInfo)
}
}
} catch (error) {
console.warn(error)
Expand All @@ -772,9 +776,9 @@
// 设置节点树状态
nodeAddStatus (treeData = [], states) {
treeData.forEach(node => {
const { id, conditionType, children } = node
const { id, conditionType, children = [] } = node
if (conditionType) {
if (children?.length) {
if (children.length) {
this.nodeAddStatus(children, states)
}
return
Expand All @@ -788,18 +792,101 @@
const index = this.subNodesExpanded.findIndex(item => item === node.id)
if (index > -1) {
this.subNodesExpanded.splice(index, 1)
this.$emit('dynamicLoad', node, true)
this.handleDynamicLoad(node, true)
}
if (children) {
if (children.length) {
this.nodeAddStatus(children, states)
}
})
},
// 只点击子流程展开/收起
async handleDynamicLoad (node, updateState) {
try {
// 检查是否需要更新子流程状态
if (!updateState) {
// 如果节点未动态加载、已收起或未执行,则不进行更新
if (!node.dynamicLoad || !node.expanded || !node.state) {
if (!node.state) {
// 子流程任务未执行,更新节点状态并记录
node.dynamicLoad = false
this.subprocessLoading = false
this.setSubNodeExpanded(node)
}
return
}
}
const { instance_id } = this.$route.query
// 该独立子流程节点的父流程也可能为独立子流程
const nodeDetailConfig = this.getNodeDetailConfig(node, node.taskId || instance_id)
const parentInstance = this.$parent.$parent
const nodeConfig = await parentInstance.getTaskNodeDetail(nodeDetailConfig)
if (!nodeConfig) return
// 获取子流程任务id
const taskInfo = nodeConfig.outputs.find(item => item.key === 'task_id') || {}
this.subprocessLoading = false
// 更新子流程树
const taskId = taskInfo.value
if (taskId) {
await this.getSubprocessData(taskId, node, updateState)
this.$emit('updateSubprocessState', {
root_node: node.parentId,
node_id: node.id,
taskId
})
}
} catch (error) {
console.warn(error)
}
},
// 获取节点配置
getNodeDetailConfig (node, instance_id) {
const { id, parentId, taskId } = node
let pipelineData = this.pipelineData
if (parentId) {
parentId.split('-').forEach(item => {
const nodeData = pipelineData.activities[item]
pipelineData = nodeData.pipeline || nodeData.component.data?.subprocess?.value?.pipeline || pipelineData
})
}
let code, version, componentData
const nodeInfo = pipelineData.activities[id]
if (nodeInfo) {
componentData = nodeInfo.component.data
code = nodeInfo.component.code
version = nodeInfo.component.version || 'legacy'
}
this.isCondition = false
const subprocessStack = parentId && !taskId ? parentId.split('-') : []
return {
component_code: code,
version: version,
node_id: id,
instance_id,
root_node: parentId,
subprocess_stack: JSON.stringify(subprocessStack),
componentData
}
},
// 记录独立子流程展开收起
setSubNodeExpanded (node) {
// 子任务展开收起
if (node.expanded) { // 记录展开的子流程id
if (!this.subNodesExpanded.includes(node.id)) {
this.subNodesExpanded.push(node.id)
}
} else {
const index = this.subNodesExpanded.findIndex(item => item === node.id)
if (index > -1) {
this.subNodesExpanded.splice(index, 1)
}
}
},
// 获取节点树节点详情
getNodeInfo (data, rootId, nodeId) {
let nodes = data
if (rootId) {
const parentId = rootId.split('-') || []
parentId.forEach(id => {
rootId.split('-').forEach(id => {
nodes.some(item => {
if (item.id === id) {
nodes = item.children
Expand All @@ -810,11 +897,10 @@
}
let nodeInfo
nodes.some(item => {
const { id, children } = item
if (id === nodeId) {
if (item.id === nodeId) {
nodeInfo = item
return true
} else if (children && children.length) {
} else if (item.children?.length) {
nodeInfo = this.getNodeInfo(item.children, '', nodeId)
return !!nodeInfo
}
Expand Down
Loading

0 comments on commit 8ff3675

Please sign in to comment.