-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathflow.js
More file actions
204 lines (180 loc) · 5.52 KB
/
flow.js
File metadata and controls
204 lines (180 loc) · 5.52 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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
'use strict';
//time类型
Object.defineProperty(exports, "__esModule", {
value: true
});
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
var _arguments = arguments;
var timeType = {
TABLE_SOURCE: 3000,
NOMAL_SOURCE: 1000,
QUICK_TYPE: 300
};
var funList = {};
//时间列表
//const flowTimeObject= {};
var timeStep = "";
var tnum = 0;
var isflowcheck = true;
//模块错误则不往下执行
var errorType = {};
//模块方法列表
var flowFucList = {};
//已经走过的流程
var flowDoneList = {};
var doPlistObject = {};
var flowImport = function flowImport(_ref) {
var id = _ref.id,
FlowMent = _ref.FlowMent,
doMent = _ref.doMent,
doLists = _ref.doLists,
doid = _ref.doid;
if (errorType[doid] === undefined) {
errorType[doid] = true;
}
var ocomponentWillMount = FlowMent.type.prototype.componentWillMount;
FlowMent.type.prototype.componentWillMount = function () {
funList[doid] = doMent(eval('this'), id);
flowFunc(funList[doid], doLists, id, doid);
doFunListf(doid, id);
if (ocomponentWillMount) {
ocomponentWillMount.apply(eval('this'), _arguments);
}
};
var ocomponentWillUnmount = FlowMent.type.prototype.componentWillUnmount;
FlowMent.type.prototype.componentWillUnmount = function () {
if (id === doid) {
clearFunDetail(doid);
}
if (ocomponentWillUnmount) {
ocomponentWillUnmount.apply(eval('this'), _arguments);
}
};
};
//注销页面注销所有记录
var clearFunDetail = function clearFunDetail(doid) {
delete errorType[doid];
delete funList[doid];
delete flowFucList[doid];
delete doPlistObject[doid];
delete flowDoneList[doid];
clearTimeout(timeStep);
};
var getTimeFunList = function getTimeFunList(doList, doid) {
if (!flowFucList[doid]) {
flowFucList[doid] = getFlist(doList);
}
};
var getFlist = function getFlist(doList, doid) {
var flist = [];
var timeList = [];
var inum = 0;
var _loop = function _loop(key) {
var data = doList[key];
data.map(function (list, i) {
//有默认类型选默认类型时间,如果没有时间定义取 300
var t = list.STEP_TIME ? timeType[list.STEP_TIME] ? timeType[list.STEP_TIME] : list.STEP_TIME : timeType['QUICK_TYPE'];
if (timeList.length >= 1) {
t = parseInt(t) + parseInt(timeList[timeList.length - 1]);
}
list.testKey = key;
list.testTime = t;
list.funNum = inum;
flist.push(list);
timeList.push(t);
inum++;
});
};
for (var key in doList) {
_loop(key);
}
return flist;
};
var doFunListf = function doFunListf(doid, id) {
var doPlist = doPlistObject[doid];
if (!flowDoneList[doid]) {
flowDoneList[doid] = {};
}
var i = 0;
for (var key in doPlist) {
if (i == key && !flowDoneList[doid][key]) {
(function () {
flowDoneList[doid][key] = key;
var funList = doPlist[key].funList;
var list = doPlist[key].list;
var keyTest = list.testKey;
timeStep = setTimeout(function () {
if (errorType[doid] === false || !doPlistObject[doid]) {
clearTimeout(timeStep);
return;
}
funList[list.doMent](list.funKey);
var disc = list.description ? list.description : "";
if (list.checkReactDo) {
var ischeckReactDo = true;
var returndata = funList[list.doMent](list.funKey);
var checkdata = list.checkReactDo;
//判断是否需要验证
if (typeof list.checkReactDo == 'function') {
if (checkdata(returndata) != true) {
ischeckReactDo = false;
}
} else if (_typeof(list.checkReactDo) == 'object') {
checkReactDoIs(returndata, checkdata);
if (isflowcheck == false) {
ischeckReactDo = false;
}
} else {
console.log("%c 【" + keyTest + "】" + list.num + " " + list.doMent + " 格式定义错误", "color:red");
errorType[doid] = false;
return;
}
//验证报错提醒
if (ischeckReactDo == false) {
console.log("%c 【" + keyTest + "】" + list.num + " " + list.doMent + "验证出错", "color:red", returndata);
errorType[doid] = false;
return;
} else {
console.log("%c 【" + keyTest + "】【验证】" + list.num + " " + list.doMent + " " + disc, "color:blue");
}
} else {
console.log("%c 【" + keyTest + "】" + list.num + " " + list.doMent + " " + disc, "color:green");
}
}, list.testTime);
})();
}
i++;
}
};
var flowFunc = function flowFunc(funList, doList, id, doid) {
getTimeFunList(doList, doid);
if (!doPlistObject[doid]) {
doPlistObject[doid] = [];
}
var doPlist = doPlistObject[doid];
flowFucList[doid].map(function (list, inum) {
if (!list.STEP_TIME || !list.doMent || !list.id || !list.funKey || !list.num) {
console.log("%c 【ERROR】doList[" + num + "] 格式错误,STEP_TIME doMent funKey id num字段不可缺少", "color:red");
return;
}
var key = list.testKey;
if (list.doMent && funList[list.doMent] && id == list.id) {
doPlistObject[doid][list.funNum] = { funList: funList, list: list };
}
});
return;
};
var checkReactDoIs = function checkReactDoIs(rdata, cdata) {
for (var key in cdata) {
if (_typeof(cdata[key]) == "object") {
checkReactDoIs(rdata[key], cdata[key]);
} else {
if (cdata[key] != rdata[key]) {
console.log("%c 【error】" + key + " " + cdata[key] + "!=" + rdata[key], "color:red");
isflowcheck = false;
}
}
}
};
exports.flowImport = flowImport;
exports.flowFunc = flowFunc;