dataParse.js
5.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
var DataParse = function() {
this.parse = function(data) {
var workflowBase = new WorkflowBase();
workflowBase.workflowid = data.workflowid;
//workflowBase.requestid = data.requestid;
//xml = "<xml>" + xml + "</xml>";
$(data.nodes).each(function() {
//var $bpxml = $(this).children('BaseProperties');
//var $vmlpxml = $(this).children('VMLProperties');
var node = new NodeBase();
node.id = this.id;
node.text = this.name;
//node.procType = $bpxml.attr("procType");
node.nodetype = this.nodeType; //$bpxml.attr("nodetype");
//node.nodeattribute = this.nodeAttrbute; //$vmlpxml.attr("nodeattribute");
//node.passNum = $bpxml.attr("passNum");
node.nodeOptType = this.status; //$bpxml.attr("optType");
node.nodeOperatorName = this.operator; // $bpxml.attr("nodeOperatorName");
try {
var operatorArray = this.operator.split('->');
if (operatorArray.length > 1) {
node.nodeOperatorName = operatorArray[0].split("_#WFSPSTR_OPTTP#_")[2];
node.nodeOperatorName = '->';
node.nodeOperatorName += operatorArray[1].split("_#WFSPSTR_OPTTP#_")[2];
} else {
if(node.nodeOperatorName.split("_#WFSPSTR_OPTTP#_").length>2){
node.nodeOperatorName = node.nodeOperatorName.split("_#WFSPSTR_OPTTP#_")[2];
}
}
} catch (e) {}
node.nodeOperatorNames = this.operators; //$bpxml.attr("nodeOperatorNames");
node.nodeViewNames = this.viewers; //$bpxml.attr("nodeViewNames");
node.nodeNotOperatorNames = this.notOperators; //$bpxml.attr("nodeNotOperatorNames");
if (node.nodeNotOperatorNames == "" || node.nodeNotOperatorNames == null) {
node.nodeNotOperatorNames = node.nodeOperatorName;
}
node.shapetype = this.shapeType; //$vmlpxml.attr("shapetype");
node.width = this.width; //$vmlpxml.attr("width");
node.height = this.height; //$vmlpxml.attr("height");
node.x = this.point.x - 48; // parseInt($vmlpxml.attr("x")) - 48 + 60;
node.y = this.point.y - 30; // parseInt($vmlpxml.attr("y")) - 30 + 40;
node.zIndex = this.zIndex; //$vmlpxml.attr("zIndex");
workflowBase.nodeBases.push(node);
});
var newLineCount = 0;
$(data.links).each(function() {
//var $bpxml = $(this).children('BaseProperties');
//var $vmlpxml = $(this).children('VMLProperties');
var nl = new NodeLink();
nl.id = this.id; //$bpxml.attr("id");
nl.text = this.text; //$bpxml.attr("text");
nl.isNew = false;
nl.from = this.from; //$bpxml.attr("from");
nl.to = this.to; //$bpxml.attr("to");
nl.remindMsg = this.remindMsg; //$bpxml.attr("remindMsg");
nl.isreject = this.isreject; //$bpxml.attr("isreject");
//nl.ismustpass = $bpxml.attr("ismustpass");
nl.directionfrom = this.directionfrom; // $bpxml.attr("directionfrom");
nl.directionto = this.directionto; //$bpxml.attr("directionto");
var startDirection = this.startDirection; // $bpxml.attr("startDirection");
var endDirection = this.endDirection; //$bpxml.attr("endDirection");
nl.startDirection = startDirection;
nl.endDirection = endDirection;
nl.hasRole = this.hasRole; //$bpxml.attr("hasRole");
nl.hasCondition = this.hasCondition; //$bpxml.attr("hasCondition");
nl.ispass = this.ispass; //$bpxml.attr("ispass");
nl.points = this.points; //this.$vmlpxml.attr("newPoints");
//console.log(nl.points);
nl.startNode = workflowBase.getnNodeByNodeId(nl.from);
nl.endNode = workflowBase.getnNodeByNodeId(nl.to);
var isdrawlineflag = false;
var ishorizontal = false;
/*
if (nl.points && nl.points.length > 0) {
//两个节点之间距离特别近的时候的处理 START
if (nl.startNode != nl.endNode && ((nl.directionfrom == 90 && nl.endDirection == -90) || (nl.directionfrom == -90 && nl.endDirection == 90))) {
if (Math.abs(nl.xFrom - nl.xTo) <= 100 && Math.abs((nl.startNode.y + nl.startNode.height / 2) - (nl.endNode.y + nl.endNode.height / 2)) < 15) {
isdrawlineflag = true;
ishorizontal = true;
}
} else if (nl.startNode != nl.endNode && ((nl.directionfrom == 180 && nl.endDirection == 0) || (nl.directionfrom == 0 && nl.endDirection == 180))) {
if (Math.abs(nl.yFrom - nl.yTo) <= 100 && Math.abs((nl.startNode.x + nl.startNode.width / 2) - (nl.endNode.x + nl.endNode.width / 2)) < 15) {
}
isdrawlineflag = true;
}
}
if (!nl.points || nl.points.length == 0 || isdrawlineflag) {
*/
if (nl.points && nl.points.length > 0) {
var sp = nl.points[0];
var ep = nl.points[nl.points.length - 1];
if (nl.startDirection) {
}
}
if (!nl.points || nl.points.length == 0) {
//nl.points = $vmlpxml.attr("points");
var bl = new BaseLine();
bl.startNode = nl.startNode;
bl.endNode = nl.endNode;
bl.startRotation = startDirection;
bl.endDirection = endDirection;
bl.oldPoints = this.oldPoints;
bl.isreject = nl.isreject;
nl.points = bl.calPoints();
nl.startDirection = bl.startRotation;
nl.endDirection = bl.endRotation;
}
nl.shapetype = this.shapetype; //$vmlpxml.attr("shapetype");
nl.zIndex = this.zIndex; //$vmlpxml.attr("zIndex");
nl.fromRelX = this.fromRelX; //$vmlpxml.attr("fromRelX");
nl.fromRelY = this.fromRelY; //$vmlpxml.attr("fromRelY");
nl.toRelX = this.toRelX; //$vmlpxml.attr("toRelX");
nl.toRelY = this.toRelY; //$vmlpxml.attr("toRelY");
workflowBase.nodeLinks.push(nl);
});
$(data.groups).each(function() {
//var $bpxml = $(this);
var g = new Group();
g.id = this.id; //$bpxml.attr("id");
g.workflowid = this.workflowid; //$bpxml.attr("workflowid");
g.groupName = this.groupName; //$bpxml.attr("text");
g.direction = this.direction; //parseInt($bpxml.attr("direction"));
g.x = this.x; //parseInt($bpxml.attr("x"));
g.y = this.y; // parseInt($bpxml.attr("y"));
g.width = this.width; //parseInt($bpxml.attr("width"));
g.height = this.height; //parseInt($bpxml.attr("height"));
g.isNew = false;
workflowBase.groups.push(g);
});
return workflowBase;
};
};