2022-11-24
const nodesAA = [{
"type": "start",
"meta": {
"label": "流程启动",
"name": "start",
"allowDraft": false,
"summaryFields": [],
"hiddenFields": [],
"readonlyFields": []
}
},
{
"type": "userTask",
"meta": {
"label": "审批1",
"name": "v1_x3jTC",
"title": "请审批示例申请",
"summaryFields": [],
"hiddenFields": [],
"writableFields": [],
"readonlyFields": null,
"participants": [],
"approvalType": "Single",
"actions": [{
"name": "approve",
"label": "同意",
"enable": true,
"enableComment": true,
"requireComment": false
},
{
"name": "reject",
"label": "拒绝",
"enable": true,
"enableComment": true,
"requireComment": false
},
{
"name": "transfer",
"label": "Transfer",
"enable": false,
"enableComment": null,
"requireComment": null
}],
"form": {
"viewName": ""
},
"notify": false,
"notifyByWechat": false,
"delayAction": null,
"allowBatch": false,
"rejectToReturn": true,
"returnableNodes": [{
"name": "start",
"label": "流程启动"
}],
"isFillingTask": false
}
},
{
"type": "excludeGateway",
"meta": {
"label": "条件分支",
"name": "v1_bAfRh",
"branches": [{
"label": "条件分支",
"condition": {
"conjunction": "OR",
"conditions": [{
"conjunction": "or",
"conditions": [{
"conjunction": "and",
"conditions": null,
"condition": {
"field": "gjs__text__CST",
"operator": "contains",
"value": "aaa",
"fieldType": "Text",
"operatorDisplayName": "包含"
},
"fieldFormat": "{!form.%s}"
}],
"condition": null,
"fieldFormat": "{!form.%s}"
}],
"condition": null,
"fieldFormat": "{!form.%s}"
},
"nodes": [{
"type": "userTask",
"meta": {
"label": "条件1审批1-1",
"name": "v1_bBmMG",
"title": "请审批示例申请",
"summaryFields": [],
"hiddenFields": [],
"writableFields": [],
"readonlyFields": null,
"participants": [],
"approvalType": "Single",
"actions": [{
"name": "approve",
"label": "同意",
"enable": true,
"enableComment": true,
"requireComment": false,
"isEditFlag": false
},
{
"name": "reject",
"label": "拒绝",
"enable": true,
"enableComment": true,
"requireComment": false,
"isEditFlag": false
},
{
"name": "transfer",
"label": "Transfer",
"enable": false,
"enableComment": null,
"requireComment": null,
"isEditFlag": false
}],
"form": {
"viewName": ""
},
"notify": false,
"notifyByWechat": false,
"delayAction": null,
"allowBatch": false,
"rejectToReturn": false,
"returnableNodes": [],
"isFillingTask": false
}
},
{
"type": "excludeGateway",
"meta": {
"name": "v1_y6RXh",
"label": "条件分支",
"branches": [{
"label": "条件分支",
"type": "excludeBranch",
"condition": {
"conjunction": "OR",
"conditions": [{
"conjunction": "or",
"conditions": [{
"conjunction": "and",
"condition": {
"field": "gjs__text__CST",
"operator": "contains",
"value": "AAA",
"fieldType": "Text",
"operatorDisplayName": "包含"
}
}]
}]
},
"nodes": [{
"type": "userTask",
"meta": {
"name": "v1_y6Mmh",
"label": "审批",
"approvalType": "Single",
"title": "请审批示例申请",
"participants": [],
"actions": [{
"name": "approve",
"label": "同意",
"enable": true,
"isEditFlag": false,
"enableComment": true,
"requireComment": false
},
{
"name": "reject",
"label": "拒绝",
"enable": true,
"isEditFlag": false,
"enableComment": true,
"requireComment": false
},
{
"name": "transfer",
"label": "Transfer",
"enable": false,
"isEditFlag": false
}],
"form": {},
"notify": false,
"summaryFields": [],
"hiddenFields": [],
"writableFields": [],
"delayAction": null,
"rejectToReturn": false,
"returnableNodes": []
}
},
{
"type": "userTask",
"meta": {
"name": "v1_rnDPY",
"label": "审批",
"approvalType": "Single",
"title": "请审批示例申请",
"participants": [],
"actions": [{
"name": "approve",
"label": "同意",
"enable": true,
"isEditFlag": false,
"enableComment": true,
"requireComment": false
},
{
"name": "reject",
"label": "拒绝",
"enable": true,
"isEditFlag": false,
"enableComment": true,
"requireComment": false
},
{
"name": "transfer",
"label": "Transfer",
"enable": false,
"isEditFlag": false
}],
"form": {},
"notify": false,
"summaryFields": [],
"hiddenFields": [],
"writableFields": [],
"delayAction": null,
"rejectToReturn": true,
"returnableNodes": [{
"label": "审批",
"name": "v1_y6Mmh"
}]
}
}]
},
{
"label": "条件分支",
"type": "excludeBranch",
"condition": {
"conjunction": "OR",
"conditions": [{
"conjunction": "or",
"conditions": [{
"conjunction": "and",
"condition": {
"field": "gjs__text__CST",
"operator": "contains",
"value": "BBB",
"fieldType": "Text",
"operatorDisplayName": "包含"
}
}]
}]
},
"nodes": [{
"type": "userTask",
"meta": {
"name": "v1_phe4t",
"label": "审批",
"approvalType": "Single",
"title": "请审批示例申请",
"participants": [],
"actions": [{
"name": "approve",
"label": "同意",
"enable": true
},
{
"name": "reject",
"label": "拒绝",
"enable": true
},
{
"name": "transfer",
"label": "Transfer",
"enable": false
}],
"form": {}
}
},
{
"type": "userTask",
"meta": {
"name": "v1_dEJFG",
"label": "审批",
"approvalType": "Single",
"title": "请审批示例申请",
"participants": [],
"actions": [{
"name": "approve",
"label": "同意",
"enable": true
},
{
"name": "reject",
"label": "拒绝",
"enable": true
},
{
"name": "transfer",
"label": "Transfer",
"enable": false
}],
"form": {}
}
}]
}]
}
},
{
"type": "userTask",
"meta": {
"label": "条件1审批1-2",
"name": "v1_w2d7k",
"title": "请审批示例申请",
"summaryFields": [],
"hiddenFields": [],
"writableFields": [],
"readonlyFields": null,
"participants": [],
"approvalType": "Single",
"actions": [{
"name": "approve",
"label": "同意",
"enable": true,
"enableComment": true,
"requireComment": false,
"isEditFlag": false
},
{
"name": "reject",
"label": "拒绝",
"enable": true,
"enableComment": true,
"requireComment": false,
"isEditFlag": false
},
{
"name": "transfer",
"label": "Transfer",
"enable": false,
"enableComment": null,
"requireComment": null,
"isEditFlag": false
}],
"form": {
"viewName": ""
},
"notify": false,
"notifyByWechat": false,
"delayAction": null,
"allowBatch": false,
"rejectToReturn": true,
"returnableNodes": [{
"label": "条件1审批1-1",
"name": "v1_bBmMG"
}],
"isFillingTask": false
}
}],
"type": "excludeBranch"
},
{
"label": "条件分支",
"condition": {
"conjunction": "OR",
"conditions": [{
"conjunction": "or",
"conditions": [{
"conjunction": "and",
"conditions": null,
"condition": {
"field": "gjs__text__CST",
"operator": "contains",
"value": "bbb",
"fieldType": "Text",
"operatorDisplayName": "包含"
},
"fieldFormat": "{!form.%s}"
}],
"condition": null,
"fieldFormat": "{!form.%s}"
}],
"condition": null,
"fieldFormat": "{!form.%s}"
},
"nodes": [{
"type": "userTask",
"meta": {
"label": "条件1审批2-1",
"name": "v1_rmxQc",
"title": "请审批示例申请",
"summaryFields": [],
"hiddenFields": [],
"writableFields": [],
"readonlyFields": null,
"participants": [],
"approvalType": "Single",
"actions": [{
"name": "approve",
"label": "同意",
"enable": true,
"enableComment": true,
"requireComment": false
},
{
"name": "reject",
"label": "拒绝",
"enable": true,
"enableComment": true,
"requireComment": false
},
{
"name": "transfer",
"label": "Transfer",
"enable": false,
"enableComment": null,
"requireComment": null
}],
"form": {
"viewName": ""
},
"notify": false,
"notifyByWechat": false,
"delayAction": null,
"allowBatch": false,
"rejectToReturn": false,
"returnableNodes": [],
"isFillingTask": false
}
},
{
"type": "userTask",
"meta": {
"label": "条件1审批2-2",
"name": "v1_spYhW",
"title": "请审批示例申请",
"summaryFields": [],
"hiddenFields": [],
"writableFields": [],
"readonlyFields": null,
"participants": [],
"approvalType": "Single",
"actions": [{
"name": "approve",
"label": "同意",
"enable": true,
"enableComment": true,
"requireComment": false
},
{
"name": "reject",
"label": "拒绝",
"enable": true,
"enableComment": true,
"requireComment": false
},
{
"name": "transfer",
"label": "Transfer",
"enable": false,
"enableComment": null,
"requireComment": null
}],
"form": {
"viewName": ""
},
"notify": false,
"notifyByWechat": false,
"delayAction": null,
"allowBatch": false,
"rejectToReturn": false,
"returnableNodes": [{
"name": "v1_rmxQc",
"label": "条件1审批2-1"
}],
"isFillingTask": false
}
}],
"type": "excludeBranch"
}],
"isExclude": true
}
},
{
"type": "userTask",
"meta": {
"label": "审批2",
"name": "v1_rk7N8",
"title": "请审批示例申请",
"summaryFields": [],
"hiddenFields": [],
"writableFields": [],
"readonlyFields": null,
"participants": [],
"approvalType": "Single",
"actions": [{
"name": "approve",
"label": "同意",
"enable": true,
"enableComment": true,
"requireComment": false
},
{
"name": "reject",
"label": "拒绝",
"enable": true,
"enableComment": true,
"requireComment": false
},
{
"name": "transfer",
"label": "Transfer",
"enable": false,
"enableComment": null,
"requireComment": null
}],
"form": {
"viewName": ""
},
"notify": false,
"notifyByWechat": false,
"delayAction": null,
"allowBatch": false,
"rejectToReturn": false,
"returnableNodes": [{
"name": "start",
"label": "流程启动"
},
{
"name": "v1_x3jTC",
"label": "审批1"
}],
"isFillingTask": false
}
},
{
"type": "userTask",
"meta": {
"label": "审批3",
"name": "v1_nd4za",
"title": "请审批示例申请",
"summaryFields": [],
"hiddenFields": [],
"writableFields": [],
"readonlyFields": null,
"participants": [],
"approvalType": "Single",
"actions": [{
"name": "approve",
"label": "同意",
"enable": true,
"enableComment": true,
"requireComment": false
},
{
"name": "reject",
"label": "拒绝",
"enable": true,
"enableComment": true,
"requireComment": false
},
{
"name": "transfer",
"label": "Transfer",
"enable": false,
"enableComment": null,
"requireComment": null
}],
"form": {
"viewName": ""
},
"notify": false,
"notifyByWechat": false,
"delayAction": null,
"allowBatch": false,
"rejectToReturn": false,
"returnableNodes": [{
"name": "start",
"label": "流程启动"
},
{
"name": "v1_x3jTC",
"label": "审批1"
},
{
"name": "v1_rk7N8",
"label": "审批2"
}],
"isFillingTask": false
}
},
{
"type": "excludeGateway",
"meta": {
"label": "条件分支",
"name": "v1_maXst",
"branches": [{
"label": "条件分支",
"condition": {
"conjunction": "OR",
"conditions": [{
"conjunction": "or",
"conditions": [{
"conjunction": "and",
"conditions": null,
"condition": {
"field": "gjs__text__CST",
"operator": "contains",
"value": "aaa",
"fieldType": "Text",
"operatorDisplayName": "包含"
},
"fieldFormat": "{!form.%s}"
}],
"condition": null,
"fieldFormat": "{!form.%s}"
}],
"condition": null,
"fieldFormat": "{!form.%s}"
},
"nodes": [{
"type": "userTask",
"meta": {
"label": "条件2审批1-1",
"name": "v1_maypC",
"title": "请审批示例申请",
"summaryFields": [],
"hiddenFields": [],
"writableFields": [],
"readonlyFields": null,
"participants": [],
"approvalType": "Single",
"actions": [{
"name": "approve",
"label": "同意",
"enable": true,
"enableComment": true,
"requireComment": false
},
{
"name": "reject",
"label": "拒绝",
"enable": true,
"enableComment": true,
"requireComment": false
},
{
"name": "transfer",
"label": "Transfer",
"enable": false,
"enableComment": null,
"requireComment": null
}],
"form": {
"viewName": ""
},
"notify": false,
"notifyByWechat": false,
"delayAction": null,
"allowBatch": false,
"rejectToReturn": false,
"returnableNodes": [],
"isFillingTask": false
}
},
{
"type": "userTask",
"meta": {
"label": "条件2审批1-2",
"name": "v1_rkKJE",
"title": "请审批示例申请",
"summaryFields": [],
"hiddenFields": [],
"writableFields": [],
"readonlyFields": null,
"participants": [],
"approvalType": "Single",
"actions": [{
"name": "approve",
"label": "同意",
"enable": true,
"enableComment": true,
"requireComment": false
},
{
"name": "reject",
"label": "拒绝",
"enable": true,
"enableComment": true,
"requireComment": false
},
{
"name": "transfer",
"label": "Transfer",
"enable": false,
"enableComment": null,
"requireComment": null
}],
"form": {
"viewName": ""
},
"notify": false,
"notifyByWechat": false,
"delayAction": null,
"allowBatch": false,
"rejectToReturn": false,
"returnableNodes": [{
"name": "v1_maypC",
"label": "条件2审批1-1"
}],
"isFillingTask": false
}
}],
"type": "excludeBranch"
},
{
"label": "条件分支",
"condition": {
"conjunction": "OR",
"conditions": [{
"conjunction": "or",
"conditions": [{
"conjunction": "and",
"conditions": null,
"condition": {
"field": "gjs__text__CST",
"operator": "contains",
"value": "bbb",
"fieldType": "Text",
"operatorDisplayName": "包含"
},
"fieldFormat": "{!form.%s}"
}],
"condition": null,
"fieldFormat": "{!form.%s}"
}],
"condition": null,
"fieldFormat": "{!form.%s}"
},
"nodes": [],
"type": "excludeBranch"
}],
"isExclude": true
}
}]
// v1_x3jTC v1_bBmMG v1_y6Mmh v1_rnDPY v1_w2d7k v1_rk7N8 v1_nd4za v1_rkKJE
function returnNodeList(nodes, name, parentName){
debugger;
for(let i = 0; i < nodes.length; i++){
if(nodes[i].meta.name === name){
return {
nodes: nodes,
name: parentName
}
}
if(nodes[i].type === 'gateway' || nodes[i].type === 'excludeGateway'){
for(let j = 0; j < nodes[i].meta.branches.length; j++) {
const nodesList = returnNodeList(nodes[i].meta.branches[j].nodes, name, nodes[i].meta.name)
console.log('nodesList',nodesList)
if(nodesList){
return {
nodes: nodesList.nodes,
name: nodesList.name
};
}
}
}
}
}
function recursionNodesList(aa, name) {
const currentNodeList = returnNodeList(nodesAA ,name , '')
console.log('currentNodeList:' , currentNodeList)
if(currentNodeList?.name){
let nodesList = [];
let nodes = currentNodeList.nodes;
for(let i = 0; i < nodes.length; i++) {
if(nodes[i].meta.name === name) {
break;
}
if(nodes[i].type !== 'gateway' && nodes[i].type !== 'excludeGateway'
&& nodes[i].type !== 'notify') {
if(nodes[i].type === 'start') {
let startNode = {
label: 'startNode',
name : nodes[i].meta.name
}
nodesList.push(startNode);
} else {
nodesList.push(nodes[i].meta);
}
}
}
aa.unshift(...nodesList);
recursionNodesList(aa, currentNodeList?.name)
}else{
let nodesList = [];
console.log(currentNodeList.nodes, '12121');
let nodes = currentNodeList.nodes;
console.log(nodes, '3333');
for(let i = 0; i < nodes.length; i++) {
if(nodes[i].meta.name === name) {
break;
}
if(nodes[i].type !== 'gateway' && nodes[i].type !== 'excludeGateway'
&& nodes[i].type !== 'notify') {
if(nodes[i].type === 'start') {
let startNode = {
label: 'startNode',
name : nodes[i].meta.name
}
nodesList.push(startNode);
} else {
nodesList.push(nodes[i].meta);
}
}
}
aa.unshift(...nodesList);
console.log(aa,'8888')
}
}
const aa = [];
recursionNodesList(aa, 'v1_bBmMG')
recursionNodesList(aa, 'v1_rnDPY')