FindWorker.js 69 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566
  1. var _worker = self;
  2. var _action = {
  3. _checkRequest: function(s,f){
  4. if (this.request.readyState === XMLHttpRequest.DONE) {
  5. if (this.request.status === 200) {
  6. this._doneRequest(s);
  7. } else {
  8. this._errorRequest(f);
  9. }
  10. }
  11. },
  12. _createRequest: function(s, f){
  13. var request = new XMLHttpRequest();
  14. request.addEventListener("readystatechange",function(){
  15. if (this.readyState === XMLHttpRequest.DONE) {
  16. if (this.status === 200) {
  17. var json = JSON.parse(this.responseText);
  18. var xToken = this.getResponseHeader(_worker.findData.tokenName);
  19. if (xToken){
  20. json.xToken = xToken;
  21. }
  22. if (s) s(json);
  23. } else {
  24. if (f) f(this, this.responseText);
  25. }
  26. }
  27. });
  28. return request
  29. },
  30. sendRequest: function(data){
  31. return new Promise(function(s, f){
  32. var request = this._createRequest(s, f);
  33. var method = data.method;
  34. var noCache = !!data.noCache;
  35. var async = !!data.loadAsync;
  36. var withCredentials = !!data.credentials;
  37. var url = data.address;
  38. var body = data.body;
  39. var debug = data.debug;
  40. var token = data.token;
  41. if (noCache) url = url+(((url.indexOf("?")!==-1) ? "&" : "?")+(new Date()).getTime());
  42. request.open(method, url, async);
  43. request.withCredentials = withCredentials;
  44. request.setRequestHeader("Content-Type", "application/json; charset=utf-8");
  45. request.setRequestHeader("Accept", "text/html,application/json,*/*");
  46. if (debug) request.setRequestHeader("x-debugger", "true");
  47. if (token){
  48. request.setRequestHeader(_worker.findData.tokenName, token);
  49. request.setRequestHeader("authorization", token);
  50. }
  51. request.send(body);
  52. }.bind(this));
  53. },
  54. _doneRequest: function(s){
  55. var json = JSON.parse(this.request.responseText);
  56. var xToken = this.request.getResponseHeader(_worker.findData.tokenName);
  57. if (xToken){
  58. json.xToken = xToken;
  59. }
  60. if (s) s(json);
  61. // _worker.postMessage({"type": "done", "data": json});
  62. // _worker.close();
  63. },
  64. _errorRequest: function(f){
  65. if (s) s(this.request, this.request.responseText);
  66. // _worker.postMessage({"type":"error", "data": {"status": this.request.status, "statusText": this.request.statusText, "responseText":this.request.responseText}});
  67. // _worker.close();
  68. }
  69. };
  70. _worker.action = _action;
  71. _worker._receiveMessageReply = function(){
  72. _worker.postMessage({
  73. "type": "receive"
  74. });
  75. };
  76. _worker._readyMessageReply = function(){
  77. _worker.postMessage({
  78. "type": "ready",
  79. "count": this.filterOptionList.length
  80. });
  81. };
  82. _worker._getRequestOption = function(data, par){
  83. if (par){
  84. Object.keys(par).forEach(function(k){
  85. data.url = data.url.replace("{"+k+"}", par[k]);
  86. });
  87. }
  88. return {
  89. "method": data.method||"get",
  90. "noCache": false,
  91. "loadAsync": true,
  92. "credentials": true,
  93. "address": data.url,
  94. "body": data.body || "",
  95. "debug": data.debug || _worker.findData.debug,
  96. "token": data.token || _worker.findData.token
  97. };
  98. };
  99. _worker._createFilterOption = function(moduleType, appId, designerType, desingerId){
  100. var filterOption = JSON.parse(_worker.filterOptionTemplete);
  101. filterOption.moduleList.push({
  102. "moduleType": moduleType,
  103. "moduleAppList": [{"appId": appId, "designerList": [{"designerType": designerType, "designerIdList": [desingerId]}]}]
  104. });
  105. this.filterOptionList.push(filterOption);
  106. return filterOption;
  107. };
  108. _worker._getDesingerModule = function(id, restful, par, moduleType, designerType){
  109. var p = _worker.action.sendRequest(_worker._getRequestOption({"url": restful, "debug": _worker.findData.debug, "token": _worker.findData.token }, par));
  110. return p.then(function(json){
  111. list = json.data;
  112. if (list) list.forEach(function(designer){
  113. _worker._createFilterOption(moduleType, id, designerType, designer.id)
  114. });
  115. }, function(){
  116. return Promise.resolve("");
  117. });
  118. };
  119. _worker._getDesinger_processPlatform = function(id){
  120. var promiseArr = [];
  121. if (_worker.findData.filterOption.designerTypes.indexOf("script")!=-1){ //所有脚本
  122. promiseArr.push(_worker._getDesingerModule(id, _worker.findData.actions.listProcessScript, {"applicationId": id}, "processPlatform", "script"));
  123. }
  124. if (_worker.findData.filterOption.designerTypes.indexOf("form")!=-1){ //所有表单
  125. promiseArr.push(_worker._getDesingerModule(id, _worker.findData.actions.listProcessForm, {"applicationId": id}, "processPlatform", "form"));
  126. }
  127. if (_worker.findData.filterOption.designerTypes.indexOf("process")!=-1){ //所有流程
  128. promiseArr.push(_worker._getDesingerModule(id, _worker.findData.actions.listProcessProcess, {"applicationId": id}, "processPlatform", "process"));
  129. }
  130. return promiseArr;
  131. };
  132. _worker._getDesinger_cms = function(id){
  133. var promiseArr = [];
  134. if (_worker.findData.filterOption.designerTypes.indexOf("script")!=-1){ //所有脚本
  135. promiseArr.push(_worker._getDesingerModule(id, _worker.findData.actions.listCmsScript, {"flag": id}, "cms", "script"));
  136. }
  137. if (_worker.findData.filterOption.designerTypes.indexOf("form")!=-1){ //所有表单
  138. promiseArr.push(_worker._getDesingerModule(id, _worker.findData.actions.listCmsForm, {"appId": id}, "cms", "form"));
  139. }
  140. return promiseArr;
  141. };
  142. _worker._getDesinger_portal = function(id){
  143. var promiseArr = [];
  144. if (_worker.findData.filterOption.designerTypes.indexOf("script")!=-1){ //所有脚本
  145. promiseArr.push(_worker._getDesingerModule(id, _worker.findData.actions.listPortalScript, {"portalId": id}, "portal", "script"));
  146. }
  147. if (_worker.findData.filterOption.designerTypes.indexOf("page")!=-1){ //所有表单
  148. promiseArr.push(_worker._getDesingerModule(id, _worker.findData.actions.listPortalPage, {"portalId": id}, "portal", "page"));
  149. }
  150. if (_worker.findData.filterOption.designerTypes.indexOf("widget")!=-1){ //所有流程
  151. promiseArr.push(_worker._getDesingerModule(id, _worker.findData.actions.listPortalWidget, {"portalId": id}, "portal", "widget"));
  152. }
  153. return promiseArr;
  154. };
  155. _worker._getDesinger_query = function(id){
  156. var promiseArr = [];
  157. if (_worker.findData.filterOption.designerTypes.indexOf("view")!=-1){ //所有脚本
  158. promiseArr.push(_worker._getDesingerModule(id, _worker.findData.actions.listQueryView, {"flag": id}, "query", "view"));
  159. }
  160. if (_worker.findData.filterOption.designerTypes.indexOf("stat")!=-1){ //所有表单
  161. promiseArr.push(_worker._getDesingerModule(id, _worker.findData.actions.listQueryStat, {"flag": id}, "query", "stat"));
  162. }
  163. if (_worker.findData.filterOption.designerTypes.indexOf("statement")!=-1){ //所有流程
  164. promiseArr.push(_worker._getDesingerModule(id, _worker.findData.actions.listQueryStatement, {"flag": id}, "query", "statement"));
  165. }
  166. return promiseArr;
  167. };
  168. _worker._getDesinger_service = function(id){
  169. var promiseArr = [];
  170. if (_worker.findData.filterOption.designerTypes.indexOf("script")!=-1){ //所有脚本
  171. if (id=="invoke") {
  172. promiseArr.push(_worker._getDesingerModule(id, _worker.findData.actions.listInvoke, null, "service", "script"));
  173. }else if (id=="script"){
  174. promiseArr.push(_worker._getDesingerModule(id, _worker.findData.actions.listScript, null, "service", "script"));
  175. }else{
  176. promiseArr.push(_worker._getDesingerModule(id, _worker.findData.actions.listAgent, null, "service", "script"));
  177. }
  178. }
  179. return promiseArr;
  180. };
  181. _worker._listApplication = function(type){
  182. switch (type){
  183. case "processPlatform":
  184. return this.action.sendRequest(_worker._getRequestOption({"url": this.findData.actions.listProcess, "debug": this.findData.debug, "token": this.findData.token }));
  185. case "cms":
  186. return this.action.sendRequest(_worker._getRequestOption({"url": this.findData.actions.listCms, "debug": this.findData.debug, "token": this.findData.token }));
  187. case "portal":
  188. return this.action.sendRequest(_worker._getRequestOption({"url": this.findData.actions.listPortal, "debug": this.findData.debug, "token": this.findData.token }));
  189. case "query":
  190. return this.action.sendRequest(_worker._getRequestOption({"url": this.findData.actions.listQuery, "debug": this.findData.debug, "token": this.findData.token }));
  191. }
  192. };
  193. _worker._parseFindModule = function(moduleList){
  194. var promiseArr = [];
  195. moduleList.forEach(function(module){
  196. if (module.moduleType==="service"){
  197. if (!module.flagList || !module.flagList.length){
  198. var filterOption = JSON.parse(_worker.filterOptionTemplete);
  199. filterOption.moduleList.push({
  200. "moduleType": module.moduleType,
  201. "moduleAppList": [{"appId": "invoke"}]
  202. });
  203. this.filterOptionList.push(filterOption);
  204. filterOption = JSON.parse(_worker.filterOptionTemplete);
  205. filterOption.moduleList.push({
  206. "moduleType": module.moduleType,
  207. "moduleAppList": [{"appId": "agent"}]
  208. });
  209. this.filterOptionList.push(filterOption);
  210. filterOption = JSON.parse(_worker.filterOptionTemplete);
  211. filterOption.moduleList.push({
  212. "moduleType": module.moduleType,
  213. "moduleAppList": [{"appId": "script"}]
  214. });
  215. this.filterOptionList.push(filterOption);
  216. promiseArr.push(Promise.resolve(""));
  217. //promiseArr = promiseArr.concat(_worker["_getDesinger_"+module.moduleType]("invoke"));
  218. //promiseArr = promiseArr.concat(_worker["_getDesinger_"+module.moduleType]("agent"));
  219. }else{
  220. module.flagList.forEach(function(flag){
  221. if (!flag.designerList || !flag.designerList.length){
  222. promiseArr = promiseArr.concat(_worker["_getDesinger_"+module.moduleType](flag.id));
  223. }else{
  224. flag.designerList.forEach(function(designer){
  225. var filterOption = _worker._createFilterOption(module.moduleType, flag.id, designer.designerType, designer.id)
  226. promiseArr = promiseArr.concat(Promise.resolve(filterOption));
  227. });
  228. }
  229. });
  230. }
  231. }else{
  232. if (!module.flagList || !module.flagList.length){
  233. var p = _worker._listApplication(module.moduleType);
  234. promiseArr.push(p.then(function(json){
  235. //按应用进行搜索
  236. if (json && json.data) json.data.forEach(function(app){
  237. var filterOption = JSON.parse(_worker.filterOptionTemplete);
  238. filterOption.moduleList.push({
  239. "moduleType": module.moduleType,
  240. "moduleAppList": [{"appId": app.id}]
  241. });
  242. this.filterOptionList.push(filterOption);
  243. });
  244. return Promise.resolve("");
  245. //按设计元素进行搜索
  246. // var pArr = [];
  247. // json.data.forEach(function(app){
  248. // pArr = pArr.concat(_worker["_getDesinger_"+module.moduleType](app.id));
  249. // });
  250. // return Promise.all(pArr);
  251. }, function(){
  252. return Promise.resolve("");
  253. }));
  254. }else{
  255. module.flagList.forEach(function(flag){
  256. if (!flag.designerList || !flag.designerList.length){
  257. promiseArr = promiseArr.concat(_worker["_getDesinger_"+module.moduleType](flag.id));
  258. }else{
  259. flag.designerList.forEach(function(designer){
  260. var filterOption = _worker._createFilterOption(module.moduleType, flag.id, designer.designerType, designer.id)
  261. promiseArr = promiseArr.concat(Promise.resolve(filterOption));
  262. });
  263. }
  264. });
  265. }
  266. }
  267. }.bind(this));
  268. return promiseArr;
  269. }
  270. _worker._findMessageReply = function(data, option){
  271. //_worker.setTimeout(function(){
  272. _worker.postMessage({
  273. "type": "find",
  274. "data": data,
  275. "option": option
  276. });
  277. //}, 10);
  278. };
  279. _worker._findOptionReply = function(){
  280. _worker.postMessage({
  281. "type": "done"
  282. });
  283. };
  284. _worker._findCompletedReply = function(data, option){
  285. _worker.setTimeout(function(){
  286. _worker.postMessage({
  287. "type": "completed"
  288. });
  289. }, 100);
  290. };
  291. _worker._createFindMessageReplyData = function(module, designer, aliase, pattern){
  292. return {
  293. "module": module,
  294. "appId": designer.appId,
  295. "appName": designer.appName,
  296. "designerId": designer.designerId,
  297. "designerName": designer.designerName,
  298. "designerType": designer.designerType,
  299. "designerAliase": aliase,
  300. "pattern": pattern
  301. };
  302. };
  303. _worker._setFilterOptionRegex = function(){
  304. var keyword = _worker.findData.filterOption.keyword;
  305. keyword = keyword.replace("[", "\\[").replace("]", "\\]").replace("(", "\\(").replace(")", "\\)").replace("{", "\\{").replace("}", "\\}")
  306. .replace("^", "\\^").replace("$", "\\$").replace(".", "\\.").replace("?", "\\?").replace("+", "\\+").replace("*", "\\*").replace("|", "\\|");
  307. if (_worker.findData.filterOption.matchRegExp){
  308. var flag = (_worker.findData.filterOption.caseSensitive) ? "gm" : "gmi";
  309. this.keywordRegexp = new RegExp(keyword, flag);
  310. }else{
  311. var flag = (_worker.findData.filterOption.caseSensitive) ? "gm" : "gmi";
  312. keyword = (_worker.findData.filterOption.matchWholeWord) ? "\\b"+keyword+"\\b" : keyword;
  313. this.keywordRegexp = new RegExp(keyword, flag);
  314. }
  315. };
  316. _worker._findProcessPlatformParse_script = function(designer, option, module){
  317. if (designer.patternList && designer.patternList.length){
  318. // var action = this.findData.actions.getProcessScript;
  319. //
  320. // var p = _worker.action.sendRequest(_worker._getRequestOption({"url": action}, {"id": designer.designerId}));
  321. // p.then(function(json){
  322. designer.patternList.forEach(function(pattern){
  323. if (pattern.property=="text"){
  324. //var scriptLines = json.data.text.split(/\n/);
  325. pattern.lines.forEach(function(line){
  326. var scriptText = line.lineValue;
  327. _worker._findMessageReply(_worker._createFindMessageReplyData(module, designer, "", {
  328. "property": pattern.property,
  329. "value": scriptText,
  330. "line": line.line
  331. }), option);
  332. // var scriptText = scriptLines[line-1];
  333. // while ((arr = this.keywordRegexp.exec(scriptText)) !== null) {
  334. // var col = arr.index;
  335. // var key = arr[0];
  336. // var value = arr.input;
  337. // _worker._findMessageReply(_worker._createFindMessageReplyData("processPlatform", designer, json.data.aliase, {
  338. // "property": pattern.property,
  339. // "value": value,
  340. // "line": line,
  341. // "column": col,
  342. // "key": key
  343. // }), option);
  344. // }
  345. });
  346. }else{
  347. // _worker._findMessageReply(_worker._createFindMessageReplyData(module, designer, "", {
  348. // "property": pattern.property,
  349. // "value": pattern.propertyValue
  350. // }), option);
  351. }
  352. });
  353. //}, function(){});
  354. }
  355. };
  356. _worker.findScriptLineValue = function(result, code, preLine, preIndex, len){
  357. var lineRegexp = /\r\n|\n|\r/g;
  358. var preText = code.substring(preIndex, result.index);
  359. var m = preText.match(lineRegexp);
  360. preLine += (m) ? m.length : 0;
  361. var value = result[0];
  362. var n = result.index-1;
  363. var char = code.charAt(n);
  364. while (!lineRegexp.test(char) && n>=0){
  365. value = char+value;
  366. n--;
  367. char = code.charAt(n);
  368. }
  369. n = this.keywordRegexp.lastIndex;
  370. char = code.charAt(n);
  371. while (!lineRegexp.test(char) && n<len){
  372. value = value+char;
  373. n++;
  374. char = code.charAt(n);
  375. }
  376. preIndex = this.keywordRegexp.lastIndex = n;
  377. return {"value": value, "preLine": preLine, "preIndex": preIndex};
  378. };
  379. _worker.findInDesigner_script = function(formData, key, module, designer, propertyDefinition, option, mode, path){
  380. if (formData[key].hasOwnProperty("code")) path.push("code");
  381. var code = formData[key].code || formData[key];
  382. if (code){
  383. this.keywordRegexp.lastIndex = 0;
  384. var len = code.length;
  385. var preLine = 0;
  386. var preIndex = 0;
  387. var result;
  388. while ((result = this.keywordRegexp.exec(code)) !== null){
  389. var obj = _worker.findScriptLineValue(result, code, preLine, preIndex, len);
  390. preLine = obj.preLine;
  391. preIndex = obj.preIndex;
  392. _worker._findMessageReply(_worker._createFindMessageReplyData(module, designer, "", {
  393. "type": formData.type,
  394. "propertyType": propertyDefinition.type || "text",
  395. "propertyName": propertyDefinition.name,
  396. "name": formData.name || formData.id,
  397. "id": formData.id,
  398. "key": key,
  399. "value": obj.value,
  400. "line": preLine+1,
  401. "mode": mode,
  402. "path": path
  403. }), option);
  404. }
  405. }
  406. };
  407. _worker.findInDesigner_events = function(formData, key, module, designer, propertyDefinition, option, mode, path){
  408. var eventObj = formData[key];
  409. Object.keys(eventObj).forEach(function(evkey){
  410. var code = eventObj[evkey].code;
  411. if (code){
  412. this.keywordRegexp.lastIndex = 0;
  413. var len = code.length;
  414. var preLine = 0;
  415. var preIndex = 0;
  416. var result;
  417. while ((result = this.keywordRegexp.exec(code)) !== null){
  418. var obj = _worker.findScriptLineValue(result, code, preLine, preIndex, len);
  419. preLine = obj.preLine;
  420. preIndex = obj.preIndex;
  421. _worker._findMessageReply(_worker._createFindMessageReplyData(module, designer, "", {
  422. "type": formData.type,
  423. "propertyType": propertyDefinition.type || "text",
  424. "propertyName": propertyDefinition.name,
  425. "name": formData.name || formData.id,
  426. "id": formData.id,
  427. "key": key,
  428. "evkey": evkey,
  429. "value": obj.value,
  430. "line": preLine+1,
  431. "mode": mode,
  432. "path": (path) ? path.concat([evkey, "code"]) : ""
  433. }), option);
  434. }
  435. }
  436. });
  437. };
  438. _worker.findInDesigner_map = function(formData, key, module, designer, propertyDefinition, option, mode, path){
  439. var map = formData[key];
  440. Object.keys(map).forEach(function(evkey) {
  441. this.keywordRegexp.lastIndex = 0;
  442. var text = map[evkey];
  443. if (text){
  444. if ((typeof text)=="string") {
  445. if (this.keywordRegexp.test(text)) {
  446. _worker._findMessageReply(_worker._createFindMessageReplyData(module, designer, "", {
  447. "type": formData.type,
  448. "propertyType": propertyDefinition.type || "text",
  449. "propertyName": propertyDefinition.name,
  450. "name": formData.name || formData.id,
  451. "id": formData.id,
  452. "key": key,
  453. "value": evkey + ": " + text,
  454. "mode": mode,
  455. "path": path
  456. }), option);
  457. }
  458. }else{
  459. Object.keys(text).forEach(function (stylekey){
  460. this.keywordRegexp.lastIndex = 0;
  461. if (this.keywordRegexp.test(text[stylekey])) {
  462. _worker._findMessageReply(_worker._createFindMessageReplyData(module, designer, "", {
  463. "type": formData.type,
  464. "propertyType": propertyDefinition.type || "text",
  465. "propertyName": propertyDefinition.name+"-"+evkey,
  466. "name": formData.name || formData.id,
  467. "id": formData.id,
  468. "key": key,
  469. "value": stylekey + ": " + text[stylekey],
  470. "mode": mode,
  471. "path": path.concat(evkey)
  472. }), option);
  473. }
  474. });
  475. }
  476. }
  477. });
  478. };
  479. _worker.findInDesigner_array = function(formData, key, module, designer, propertyDefinition, option, mode, path){
  480. var arr = formData[key];
  481. arr.forEach(function(v, i) {
  482. this.keywordRegexp.lastIndex = 0;
  483. var text = v.toString();
  484. if (this.keywordRegexp.test(text)){
  485. _worker._findMessageReply(_worker._createFindMessageReplyData(module, designer, "", {
  486. "type": formData.type,
  487. "propertyType": propertyDefinition.type || "text",
  488. "propertyName": propertyDefinition.name,
  489. "name": formData.name || formData.id,
  490. "id": formData.id,
  491. "line": i+1,
  492. "key": key,
  493. "value": text,
  494. "mode": mode,
  495. "path": path
  496. }), option);
  497. }
  498. });
  499. };
  500. _worker.findInDesigner_objectArray = function(formData, key, module, designer, propertyDefinition, option, mode, path){
  501. var arr = formData[key];
  502. arr.forEach(function(map, i) {
  503. var p = path.concat(i);
  504. Object.keys(map).forEach(function(evkey) {
  505. this.keywordRegexp.lastIndex = 0;
  506. var text = map[evkey];
  507. if (this.keywordRegexp.test(text)){
  508. _worker._findMessageReply(_worker._createFindMessageReplyData(module, designer, "", {
  509. "type": formData.type,
  510. "propertyType": propertyDefinition.type || "text",
  511. "propertyName": propertyDefinition.name,
  512. "name": formData.name || formData.id,
  513. "id": formData.id,
  514. "line": i+1,
  515. "key": key,
  516. "value": evkey+": "+text,
  517. "mode": mode,
  518. "path": p.concat(evkey)
  519. }), option);
  520. }
  521. });
  522. });
  523. };
  524. _worker.findInDesigner_duty = function(formData, key, module, designer, propertyDefinition, option, mode, path){
  525. var text = formData[key];
  526. if (text){
  527. var json = JSON.parse(text);
  528. json.forEach(function(duty, i) {
  529. var p = path.concat(i);
  530. this.keywordRegexp.lastIndex = 0;
  531. var text = duty.name;
  532. if (text) if (this.keywordRegexp.test(text)){
  533. _worker._findMessageReply(_worker._createFindMessageReplyData(module, designer, "", {
  534. "type": formData.type,
  535. "propertyType": propertyDefinition.type || "text",
  536. "propertyName": propertyDefinition.name,
  537. "name": formData.name || formData.id,
  538. "id": formData.id,
  539. "key": key,
  540. "line": i+1,
  541. "valueKey": "name",
  542. "value": "name:"+text,
  543. "mode": mode,
  544. "path": p.concat("name")
  545. }), option);
  546. }
  547. var code = duty.code;
  548. if (code){
  549. this.keywordRegexp.lastIndex = 0;
  550. var len = code.length;
  551. var idx = i+1;
  552. var preLine = 0;
  553. var preIndex = 0;
  554. var result;
  555. while ((result = this.keywordRegexp.exec(code)) !== null){
  556. var obj = _worker.findScriptLineValue(result, code, preLine, preIndex, len);
  557. preLine = obj.preLine;
  558. preIndex = obj.preIndex;
  559. _worker._findMessageReply(_worker._createFindMessageReplyData(module, designer, "", {
  560. "type": formData.type,
  561. "propertyType": propertyDefinition.type || "text",
  562. "propertyName": propertyDefinition.name+"(code)&nbsp;"+idx+"."+duty.name,
  563. "name": formData.name || formData.id,
  564. "id": formData.id,
  565. "key": key,
  566. "valueKey": "code",
  567. "idx": i,
  568. "value": obj.value,
  569. "line": preLine+1,
  570. "mode": mode,
  571. "path": p.concat("code")
  572. }), option);
  573. }
  574. }
  575. });
  576. }
  577. };
  578. _worker.findInDesigner_actions = function(formData, key, module, designer, propertyDefinition, option, mode, path){
  579. var arr = formData[key];
  580. arr.forEach(function(action, i) {
  581. var p = path.concat(i);
  582. this.keywordRegexp.lastIndex = 0;
  583. var text = action.text;
  584. if (text) if (this.keywordRegexp.test(text)){
  585. _worker._findMessageReply(_worker._createFindMessageReplyData(module, designer, "", {
  586. "type": formData.type,
  587. "propertyType": propertyDefinition.type || "text",
  588. "propertyName": propertyDefinition.name,
  589. "name": formData.name || formData.id,
  590. "id": formData.id,
  591. "key": key,
  592. "line": i+1,
  593. "value": "text:"+text,
  594. "mode": mode,
  595. "path": p.concat("text")
  596. }), option);
  597. }
  598. var code = action.actionScript;
  599. if (code){
  600. this.keywordRegexp.lastIndex = 0;
  601. var len = code.length;
  602. var idx = i+1;
  603. var preLine = 0;
  604. var preIndex = 0;
  605. var result;
  606. while ((result = this.keywordRegexp.exec(code)) !== null){
  607. var obj = _worker.findScriptLineValue(result, code, preLine, preIndex, len);
  608. preLine = obj.preLine;
  609. preIndex = obj.preIndex;
  610. _worker._findMessageReply(_worker._createFindMessageReplyData(module, designer, "", {
  611. "type": formData.type,
  612. "propertyType": propertyDefinition.type || "text",
  613. "propertyName": propertyDefinition.name+"(actionScript)&nbsp;"+action.text,
  614. "name": formData.name || formData.id,
  615. "id": formData.id,
  616. "key": key,
  617. "value": obj.value,
  618. "line": preLine+1,
  619. "mode": mode,
  620. "path": p.concat("actionScript")
  621. }), option);
  622. }
  623. }
  624. code = action.condition;
  625. if (code){
  626. this.keywordRegexp.lastIndex = 0;
  627. var len = code.length;
  628. var idx = i+1;
  629. var preLine = 0;
  630. var preIndex = 0;
  631. var result;
  632. while ((result = this.keywordRegexp.exec(code)) !== null){
  633. var obj = _worker.findScriptLineValue(result, code, preLine, preIndex, len);
  634. preLine = obj.preLine;
  635. preIndex = obj.preIndex;
  636. _worker._findMessageReply(_worker._createFindMessageReplyData(module, designer, "", {
  637. "type": formData.type,
  638. "propertyType": propertyDefinition.type || "text",
  639. "propertyName": propertyDefinition.name+"(condition)&nbsp;"+action.text,
  640. "name": formData.name || formData.id,
  641. "id": formData.id,
  642. "key": key,
  643. "value": obj.value,
  644. "line": preLine+1,
  645. "mode": mode,
  646. "path": p.concat("condition")
  647. }), option);
  648. }
  649. }
  650. });
  651. };
  652. _worker.findInDesigner_filter = function(formData, key, module, designer, propertyDefinition, option, mode){
  653. var arr = formData[key];
  654. arr.forEach(function(filter, i) {
  655. this.keywordRegexp.lastIndex = 0;
  656. var text = filter.path;
  657. if (text) if (this.keywordRegexp.test(text)){
  658. _worker._findMessageReply(_worker._createFindMessageReplyData(module, designer, "", {
  659. "type": formData.type,
  660. "propertyType": propertyDefinition.type || "text",
  661. "propertyName": propertyDefinition.name,
  662. "name": formData.name || formData.id,
  663. "id": formData.id,
  664. "key": key,
  665. "line": i+1,
  666. "value": "path:"+text,
  667. "mode": mode
  668. }), option);
  669. }
  670. var value = filter.value;
  671. if (value) if (this.keywordRegexp.test(value)){
  672. _worker._findMessageReply(_worker._createFindMessageReplyData(module, designer, "", {
  673. "type": formData.type,
  674. "propertyType": propertyDefinition.type || "text",
  675. "propertyName": propertyDefinition.name,
  676. "name": formData.name || formData.id,
  677. "id": formData.id,
  678. "key": key,
  679. "line": i+1,
  680. "value": "value:"+value,
  681. "mode": mode
  682. }), option);
  683. }
  684. var otherValue = filter.otherValue;
  685. if (otherValue) if (this.keywordRegexp.test(otherValue)){
  686. _worker._findMessageReply(_worker._createFindMessageReplyData(module, designer, "", {
  687. "type": formData.type,
  688. "propertyType": propertyDefinition.type || "text",
  689. "propertyName": propertyDefinition.name,
  690. "name": formData.name || formData.id,
  691. "id": formData.id,
  692. "key": key,
  693. "line": i+1,
  694. "value": "otherValue:"+otherValue,
  695. "mode": mode
  696. }), option);
  697. }
  698. var code = (filter.code) ? filter.code.code: "";
  699. if (code){
  700. this.keywordRegexp.lastIndex = 0;
  701. var len = code.length;
  702. var idx = i+1;
  703. var preLine = 0;
  704. var preIndex = 0;
  705. var result;
  706. while ((result = this.keywordRegexp.exec(code)) !== null){
  707. var obj = _worker.findScriptLineValue(result, code, preLine, preIndex, len);
  708. preLine = obj.preLine;
  709. preIndex = obj.preIndex;
  710. _worker._findMessageReply(_worker._createFindMessageReplyData(module, designer, "", {
  711. "type": formData.type,
  712. "propertyType": propertyDefinition.type || "text",
  713. "propertyName": propertyDefinition.name+"(code)&nbsp;"+filter.path,
  714. "name": formData.name || formData.id,
  715. "id": formData.id,
  716. "key": key,
  717. "value": obj.value,
  718. "line": preLine+1,
  719. "mode": mode
  720. }), option);
  721. }
  722. }
  723. code = (filter.valueScript) ? filter.valueScript.code : "";
  724. if (code){
  725. this.keywordRegexp.lastIndex = 0;
  726. var len = code.length;
  727. var idx = i+1;
  728. var preLine = 0;
  729. var preIndex = 0;
  730. var result;
  731. while ((result = this.keywordRegexp.exec(code)) !== null){
  732. var obj = _worker.findScriptLineValue(result, code, preLine, preIndex, len);
  733. preLine = obj.preLine;
  734. preIndex = obj.preIndex;
  735. _worker._findMessageReply(_worker._createFindMessageReplyData(module, designer, "", {
  736. "type": formData.type,
  737. "propertyType": propertyDefinition.type || "text",
  738. "propertyName": propertyDefinition.name+"(valueScript)&nbsp;"+filter.path,
  739. "name": formData.name || formData.id,
  740. "id": formData.id,
  741. "key": key,
  742. "value": obj.value,
  743. "line": preLine+1,
  744. "mode": mode
  745. }), option);
  746. }
  747. }
  748. });
  749. };
  750. _worker.findInDesigner_serial = function(formData, key, module, designer, propertyDefinition, option, mode){
  751. var text = formData[key];
  752. if (text) {
  753. var json = JSON.parse(text);
  754. json.forEach(function(serial, i) {
  755. this.keywordRegexp.lastIndex = 0;
  756. switch (serial.key){
  757. case "text":
  758. case "unitAttribute":
  759. if (this.keywordRegexp.test(serial.value)){
  760. _worker._findMessageReply(_worker._createFindMessageReplyData(module, designer, "", {
  761. "type": formData.type,
  762. "propertyType": propertyDefinition.type || "text",
  763. "propertyName": propertyDefinition.name+"&nbsp"+serial.key+"&nbsp",
  764. "name": formData.name || formData.id,
  765. "id": formData.id,
  766. "key": key,
  767. "value": serial.value
  768. }), option);
  769. }
  770. break;
  771. case "script":
  772. var code = serial.value;
  773. if (serial.value){
  774. if (code){
  775. this.keywordRegexp.lastIndex = 0;
  776. var len = code.length;
  777. var idx = i+1;
  778. var preLine = 0;
  779. var preIndex = 0;
  780. var result;
  781. while ((result = this.keywordRegexp.exec(code)) !== null){
  782. var obj = _worker.findScriptLineValue(result, code, preLine, preIndex, len);
  783. preLine = obj.preLine;
  784. preIndex = obj.preIndex;
  785. _worker._findMessageReply(_worker._createFindMessageReplyData(module, designer, "", {
  786. "type": formData.type,
  787. "propertyType": propertyDefinition.type || "text",
  788. "propertyName": propertyDefinition.name+"&nbsp"+serial.key+"&nbsp",
  789. "name": formData.name || formData.id,
  790. "id": formData.id,
  791. "key": key,
  792. "value": obj.value,
  793. "line": preLine+1
  794. }), option);
  795. }
  796. }
  797. }
  798. break;
  799. default:
  800. //nothing
  801. }
  802. });
  803. }
  804. };
  805. _worker.findInDesigner_projection = function(formData, key, module, designer, propertyDefinition, option, mode){
  806. var text = formData[key];
  807. if (text) {
  808. var json = JSON.parse(text);
  809. json.forEach(function(projection, i) {
  810. this.keywordRegexp.lastIndex = 0;
  811. var text = projection.path+"->"+projection.name;
  812. if (this.keywordRegexp.test(text)){
  813. _worker._findMessageReply(_worker._createFindMessageReplyData(module, designer, "", {
  814. "type": formData.type,
  815. "propertyType": propertyDefinition.type || "text",
  816. "propertyName": propertyDefinition.name,
  817. "name": formData.name || formData.id,
  818. "id": formData.id,
  819. "key": key,
  820. "value": text,
  821. "line": i
  822. }), option);
  823. }
  824. });
  825. }
  826. };
  827. _worker.findInDesigner_selectConfig_script = function(formData, key, module, designer, propertyDefinition, option, mode, code, propertyName){
  828. if (code){
  829. this.keywordRegexp.lastIndex = 0;
  830. var len = code.length;
  831. var preLine = 0;
  832. var preIndex = 0;
  833. var result;
  834. while ((result = this.keywordRegexp.exec(code)) !== null){
  835. var obj = _worker.findScriptLineValue(result, code, preLine, preIndex, len);
  836. preLine = obj.preLine;
  837. preIndex = obj.preIndex;
  838. _worker._findMessageReply(_worker._createFindMessageReplyData(module, designer, "", {
  839. "type": formData.type,
  840. "propertyType": propertyDefinition.type || "text",
  841. "propertyName": propertyName,
  842. "name": formData.name || formData.id,
  843. "id": formData.id,
  844. "key": key,
  845. "value": obj.value,
  846. "line": preLine+1
  847. }), option);
  848. }
  849. }
  850. };
  851. _worker.findInDesigner_selectConfig_events = function(formData, key, module, designer, propertyDefinition, option, mode, eventObj, propertyName){
  852. Object.keys(eventObj).forEach(function(evkey){
  853. var code = eventObj[evkey].code;
  854. this.keywordRegexp.lastIndex = 0;
  855. var len = code.length;
  856. var preLine = 0;
  857. var preIndex = 0;
  858. var result;
  859. while ((result = this.keywordRegexp.exec(code)) !== null){
  860. var obj = _worker.findScriptLineValue(result, code, preLine, preIndex, len);
  861. preLine = obj.preLine;
  862. preIndex = obj.preIndex;
  863. _worker._findMessageReply(_worker._createFindMessageReplyData(module, designer, "", {
  864. "type": formData.type,
  865. "propertyType": propertyDefinition.type || "text",
  866. "propertyName": propertyName,
  867. "name": formData.name || formData.id,
  868. "id": formData.id,
  869. "key": key,
  870. "evkey": evkey,
  871. "value": obj.value,
  872. "line": preLine+1,
  873. "mode": mode
  874. }), option);
  875. }
  876. });
  877. };
  878. _worker.findInDesigner_selectConfig = function(formData, key, module, designer, propertyDefinition, option, mode){
  879. var text = formData[key];
  880. if (text) {
  881. var json = JSON.parse(text);
  882. json.forEach(function(config, i) {
  883. var idx = i+1;
  884. var propertyName = propertyDefinition.name+"&nbsp"+idx+"-"+config.name+"&nbsp默认值脚本(defaultValue)&nbsp";
  885. _worker.findInDesigner_selectConfig_script(formData, key, module, designer, propertyDefinition, option, mode, config.defaultValue.code, propertyName);
  886. propertyName = propertyDefinition.name+"&nbsp"+idx+"-"+config.name+"&nbsp校验脚本(validation)&nbsp";
  887. _worker.findInDesigner_selectConfig_script(formData, key, module, designer, propertyDefinition, option, mode, config.validation.code, propertyName);
  888. propertyName = propertyDefinition.name+"&nbsp"+idx+"-"+config.name+"&nbsp隐藏脚本(hiddenScript)&nbsp";
  889. _worker.findInDesigner_selectConfig_script(formData, key, module, designer, propertyDefinition, option, mode, config.hiddenScript.code, propertyName);
  890. propertyName = propertyDefinition.name+"&nbsp"+idx+"-"+config.name+"&nbsp身份选择组织范围脚本(identityRangeKey)&nbsp";
  891. _worker.findInDesigner_selectConfig_script(formData, key, module, designer, propertyDefinition, option, mode, config.identityRangeKey.code, propertyName);
  892. propertyName = propertyDefinition.name+"&nbsp"+idx+"-"+config.name+"&nbsp职务范围脚本(rangeDutyKey)&nbsp";
  893. _worker.findInDesigner_selectConfig_script(formData, key, module, designer, propertyDefinition, option, mode, config.rangeDutyKey.code, propertyName);
  894. propertyName = propertyDefinition.name+"&nbsp"+idx+"-"+config.name+"&nbsp身份添加脚本(identityIncludeKey)&nbsp";
  895. _worker.findInDesigner_selectConfig_script(formData, key, module, designer, propertyDefinition, option, mode, config.identityIncludeKey.code, propertyName);
  896. propertyName = propertyDefinition.name+"&nbsp"+idx+"-"+config.name+"&nbsp组织选择组织范围脚本(unitRangeKey)&nbsp";
  897. _worker.findInDesigner_selectConfig_script(formData, key, module, designer, propertyDefinition, option, mode, config.unitRangeKey.code, propertyName);
  898. propertyName = propertyDefinition.name+"&nbsp"+idx+"-"+config.name+"&nbsp排除范围脚本(exclude)&nbsp";
  899. _worker.findInDesigner_selectConfig_script(formData, key, module, designer, propertyDefinition, option, mode, config.exclude.code, propertyName);
  900. var arr = config.rangeDuty;
  901. if (arr && arr.length) arr.forEach(function(v, i) {
  902. this.keywordRegexp.lastIndex = 0;
  903. var text = v.toString();
  904. if (this.keywordRegexp.test(text)){
  905. propertyName = propertyDefinition.name+"&nbsp"+idx+"-"+config.name+"&nbsp职务范围(rangeDuty)&nbsp";
  906. _worker._findMessageReply(_worker._createFindMessageReplyData(module, designer, "", {
  907. "type": formData.type,
  908. "propertyType": propertyDefinition.type || "text",
  909. "propertyName": propertyName,
  910. "name": formData.name || formData.id,
  911. "id": formData.id,
  912. "line": i+1,
  913. "key": key,
  914. "value": text,
  915. "mode": mode
  916. }), option);
  917. }
  918. });
  919. propertyName = propertyDefinition.name+"&nbsp"+idx+"-"+config.name+"&nbsp事件(events)&nbsp";
  920. _worker.findInDesigner_selectConfig_events(formData, key, module, designer, propertyDefinition, option, mode, config.events, propertyName);
  921. });
  922. }
  923. };
  924. _worker.findInDesigner_text = function(formData, key, module, designer, propertyDefinition, option, mode){
  925. this.keywordRegexp.lastIndex = 0;
  926. var text = formData[key];
  927. if (this.keywordRegexp.test(text)){
  928. _worker._findMessageReply(_worker._createFindMessageReplyData(module, designer, "", {
  929. "type": formData.type,
  930. "propertyType": propertyDefinition.type || "text",
  931. "propertyName": propertyDefinition.name,
  932. "name": formData.name || formData.id,
  933. "id": formData.id,
  934. "key": key,
  935. "value": text,
  936. "mode": mode
  937. }), option);
  938. }
  939. };
  940. _worker.findInDesignerProperty = function(key, propertyDefinition, formData, option, module, designer, mode, path){
  941. if (propertyDefinition){
  942. switch (propertyDefinition.type){
  943. case "html":
  944. _worker.findInDesigner_script(formData, key, module, designer, propertyDefinition, option, mode, path);
  945. break;
  946. case "script":
  947. case "css":
  948. case "sql":
  949. _worker.findInDesigner_script(formData, key, module, designer, propertyDefinition, option, mode, path);
  950. break;
  951. case "events":
  952. _worker.findInDesigner_events(formData, key, module, designer, propertyDefinition, option, mode, path);
  953. break;
  954. case "map":
  955. _worker.findInDesigner_map(formData, key, module, designer, propertyDefinition, option, mode, path);
  956. break;
  957. case "array":
  958. _worker.findInDesigner_array(formData, key, module, designer, propertyDefinition, option, mode, path);
  959. break;
  960. case "object-array":
  961. _worker.findInDesigner_objectArray(formData, key, module, designer, propertyDefinition, option, mode, path);
  962. break;
  963. case "duty":
  964. _worker.findInDesigner_duty(formData, key, module, designer, propertyDefinition, option, mode, path);
  965. break;
  966. case "actions":
  967. _worker.findInDesigner_actions(formData, key, module, designer, propertyDefinition, option, mode, path);
  968. break;
  969. case "filter":
  970. _worker.findInDesigner_filter(formData, key, module, designer, propertyDefinition, option, mode, path);
  971. break;
  972. case "serial":
  973. _worker.findInDesigner_serial(formData, key, module, designer, propertyDefinition, option, mode, path);
  974. break;
  975. case "projection":
  976. _worker.findInDesigner_projection(formData, key, module, designer, propertyDefinition, option, mode, path);
  977. break;
  978. case "selectConfig":
  979. _worker.findInDesigner_selectConfig(formData, key, module, designer, propertyDefinition, option, mode, path);
  980. break;
  981. default:
  982. _worker.findInDesigner_text(formData, key, module, designer, propertyDefinition, option, mode, path);
  983. }
  984. }
  985. }
  986. _worker.findInDesigner = function(formData, option, module, designer, mode, path){
  987. Object.keys(formData).forEach(function(key){
  988. var propertyDefinition = this.designerPropertysData.form[key];
  989. _worker.findInDesignerProperty(key, propertyDefinition, formData, option, module, designer, mode, path.concat(key));
  990. });
  991. };
  992. _worker.decodeJsonString = function(str){
  993. var tmp = "[\""+str+"\"]";
  994. var dataObj = (JSON.parse(tmp));
  995. return dataObj[0];
  996. };
  997. _worker._getDesignerData = function(designer, module){
  998. var action = "";
  999. switch (designer.designerType){
  1000. case "form":
  1001. if (module=="processPlatform") action = this.findData.actions.getProcessForm
  1002. else if (module=="cms") action = this.findData.actions.getCmsForm;
  1003. break;
  1004. case "process":
  1005. action = this.findData.actions.getProcessProcess;
  1006. break;
  1007. case "page":
  1008. action = this.findData.actions.getPortalPage;
  1009. break;
  1010. case "widget":
  1011. action = this.findData.actions.getPortalWidget;
  1012. break;
  1013. case "view":
  1014. action = this.findData.actions.getQueryView;
  1015. break;
  1016. case "statement":
  1017. action = this.findData.actions.getQueryStatement;
  1018. break;
  1019. }
  1020. if (action){
  1021. var formPromise = _worker.action.sendRequest(_worker._getRequestOption({"url": action}, {"id": designer.designerId}));
  1022. if (!this.designerPropertysData) this.designerPropertysData = _worker.action.sendRequest(_worker._getRequestOption({"url": "../x_component_FindDesigner/propertys.json"}));
  1023. return Promise.all([formPromise, this.designerPropertysData]);
  1024. }
  1025. };
  1026. _worker._findInDesigner_form = function(formData, designer, option, module, path){
  1027. var mode = formData.json.mode;
  1028. path.push("json");
  1029. _worker.findInDesigner(formData.json, option, module, designer, mode, path);
  1030. path.push("moduleList");
  1031. for (key in formData.json.moduleList){
  1032. if (formData.json.moduleList[key].recoveryStyles) formData.json.moduleList[key].styles = formData.json.moduleList[key].recoveryStyles;
  1033. if (formData.json.moduleList[key].recoveryInputStyles) formData.json.moduleList[key].inputStyles = formData.json.moduleList[key].recoveryInputStyles;
  1034. _worker.findInDesigner(formData.json.moduleList[key], option, module, designer, mode, path.concat(key));
  1035. }
  1036. };
  1037. _worker._findProcessPlatformParse_form = function(designer, option, module){
  1038. if (designer.patternList && designer.patternList.length){
  1039. var p = _worker._getDesignerData(designer, module);
  1040. if (p){
  1041. var patternPropertys = designer.patternList.map(function(a){return a.property;});
  1042. p.then(function(arr){
  1043. var formJson = arr[0];
  1044. this.designerPropertysData = arr[1];
  1045. if (patternPropertys.indexOf("data")!=-1){
  1046. var formData = JSON.parse(_worker.decodeJsonString(formJson.data.data));
  1047. _worker._findInDesigner_form(formData, designer, option, module, ["data"]);
  1048. }
  1049. if (patternPropertys.indexOf("mobileData")!=-1){
  1050. var formData = JSON.parse(_worker.decodeJsonString(formJson.data.mobileData));
  1051. _worker._findInDesigner_form(formData, designer, option, module, ["mobileData"])
  1052. }
  1053. }, function(){});
  1054. }
  1055. }
  1056. };
  1057. _worker._findProcessPlatformParse_view = function(designer, option, module){
  1058. debugger;
  1059. if (designer.patternList && designer.patternList.length){
  1060. if (!this.designerPropertysData) this.designerPropertysData = _worker.action.sendRequest(_worker._getRequestOption({"url": "../x_component_FindDesigner/propertys.json"}));
  1061. var patternPropertys = designer.patternList.map(function(a){return a.property;});
  1062. if (patternPropertys.indexOf("data")!=-1){
  1063. var p = _worker._getDesignerData(designer, module);
  1064. if (p) {
  1065. p.then(function (arr) {
  1066. var viewJson = arr[0].data;
  1067. this.designerPropertysData = arr[1];
  1068. var viewData = JSON.parse(viewJson.data);
  1069. viewData.type = "View";
  1070. viewData.name = viewJson.name;
  1071. Object.keys(viewData).forEach(function(key){
  1072. if (key!=="where" && key!=="selectList" && key!=="actionbarList" && key!=="pagingList" && key!=="type" && key!=="name" ){
  1073. var propertyDefinition = this.designerPropertysData.view[key];
  1074. _worker.findInDesignerProperty(key, propertyDefinition, viewData, option, module, designer, null, ["data", key]);
  1075. }
  1076. });
  1077. if (viewData.where) {
  1078. viewData.where.type = "View";
  1079. viewData.where.name = viewJson.name;
  1080. Object.keys(viewData.where).forEach(function (key) {
  1081. if (key !== "type" && key !== "name") {
  1082. var propertyDefinition = this.designerPropertysData.view[key];
  1083. _worker.findInDesignerProperty(key, propertyDefinition, viewData.where, option, module, designer, null, ["data", "where", key]);
  1084. }
  1085. });
  1086. }
  1087. if (viewData.selectList) {
  1088. viewData.selectList.forEach(function (col, i) {
  1089. col.type = "column";
  1090. col.name = col.displayName;
  1091. Object.keys(col).forEach(function (key) {
  1092. if (key !== "name" && key !== "type") {
  1093. var propertyDefinition = this.designerPropertysData.view[key];
  1094. _worker.findInDesignerProperty(key, propertyDefinition, col, option, module, designer, null, ["data", "selectList", i, key]);
  1095. }
  1096. });
  1097. });
  1098. }
  1099. if (viewData.actionbarList) {
  1100. viewData.actionbarList.forEach(function (item, i) {
  1101. item.type = "actionbar";
  1102. item.name = item.type;
  1103. Object.keys(item).forEach(function (key) {
  1104. if (key !== "name" && key !== "type") {
  1105. var propertyDefinition = this.designerPropertysData.view[key];
  1106. _worker.findInDesignerProperty(key, propertyDefinition, item, option, module, designer, null, ["data", "actionbarList", i, key]);
  1107. }
  1108. });
  1109. });
  1110. }
  1111. if (viewData.pagingList) {
  1112. viewData.pagingList.forEach(function (item, i) {
  1113. item.type = "paging";
  1114. item.name = item.type;
  1115. Object.keys(item).forEach(function (key) {
  1116. if (key !== "name" && key !== "type") {
  1117. var propertyDefinition = this.designerPropertysData.view[key];
  1118. _worker.findInDesignerProperty(key, propertyDefinition, item, option, module, designer, null, ["data", "pagingList", i, key]);
  1119. }
  1120. });
  1121. });
  1122. }
  1123. }, function () {
  1124. });
  1125. }
  1126. }else{
  1127. Promise.resolve(this.designerPropertysData).then(function(data){
  1128. this.designerPropertysData = data;
  1129. designer.patternList.forEach(function(pattern){
  1130. var propertyDefinition = this.designerPropertysData.view[pattern.property];
  1131. if (propertyDefinition){
  1132. _worker._findMessageReply(_worker._createFindMessageReplyData(module, designer, "", {
  1133. "type": "View",
  1134. "propertyType": propertyDefinition.type || "text",
  1135. "propertyName": propertyDefinition.name,
  1136. "name": designer.designerName,
  1137. "key": pattern.property,
  1138. "path": [pattern.property],
  1139. "value": pattern.propertyValue
  1140. }), option);
  1141. }
  1142. });
  1143. }, function(){});
  1144. }
  1145. }
  1146. }
  1147. _worker._findProcessPlatformParse_statement = function(designer, option, module){
  1148. if (designer.patternList && designer.patternList.length){
  1149. if (!this.designerPropertysData) this.designerPropertysData = _worker.action.sendRequest(_worker._getRequestOption({"url": "../x_component_FindDesigner/propertys.json"}));
  1150. // var patternPropertys = designer.patternList.map(function(a){return a.property;});
  1151. // if (patternPropertys.indexOf("view")!=-1){
  1152. debugger;
  1153. var p = _worker._getDesignerData(designer, module);
  1154. if (p) {
  1155. p.then(function (arr) {
  1156. var statementJson = arr[0].data;
  1157. this.designerPropertysData = arr[1];
  1158. designer.patternList.forEach(function(pattern){
  1159. if (pattern.property=="view"){
  1160. if ((typeof statementJson.view)=="string"){
  1161. statementJson.view = JSON.parse(statementJson.view);
  1162. }
  1163. var viewData = statementJson.view.data;
  1164. if (viewData){
  1165. viewData.type = "View";
  1166. viewData.name = statementJson.name;
  1167. Object.keys(viewData).forEach(function(key){
  1168. if (key!=="where" && key!=="selectList" && key!=="actionbarList" && key!=="pagingList" && key!=="type" && key!=="name" ){
  1169. var propertyDefinition = this.designerPropertysData.view[key];
  1170. _worker.findInDesignerProperty(key, propertyDefinition, viewData, option, module, designer, null, ["view", "data", key]);
  1171. }
  1172. });
  1173. if (viewData.where) {
  1174. viewData.where.type = "View";
  1175. viewData.where.name = viewJson.name;
  1176. Object.keys(viewData.where).forEach(function(key){
  1177. if ( key!=="type" && key!=="name"){
  1178. var propertyDefinition = this.designerPropertysData.view[key];
  1179. _worker.findInDesignerProperty(key, propertyDefinition, viewData.where, option, module, designer, null, ["view", "data", "where", key]);
  1180. }
  1181. });
  1182. }
  1183. if (viewData.selectList) {
  1184. viewData.selectList.forEach(function (col, i) {
  1185. col.type = "View-column";
  1186. col.name = col.displayName;
  1187. Object.keys(col).forEach(function (key) {
  1188. if (key !== "name" && key !== "type") {
  1189. var propertyDefinition = this.designerPropertysData.view[key];
  1190. _worker.findInDesignerProperty(key, propertyDefinition, col, option, module, designer, null, ["view", "data", "selectList", i, key]);
  1191. }
  1192. });
  1193. });
  1194. }
  1195. if (viewData.actionbarList) {
  1196. viewData.actionbarList.forEach(function (item, i) {
  1197. item.type = "View-actionbar";
  1198. item.name = item.type;
  1199. Object.keys(item).forEach(function (key) {
  1200. if (key !== "name" && key !== "type") {
  1201. var propertyDefinition = this.designerPropertysData.view[key];
  1202. _worker.findInDesignerProperty(key, propertyDefinition, item, option, module, designer, null, ["view", "data", "actionbarList", i, key]);
  1203. }
  1204. });
  1205. });
  1206. }
  1207. if (viewData.pagingList) {
  1208. viewData.pagingList.forEach(function (item, i) {
  1209. item.type = "View-paging";
  1210. item.name = item.type;
  1211. Object.keys(item).forEach(function (key) {
  1212. if (key !== "name" && key !== "type") {
  1213. var propertyDefinition = this.designerPropertysData.view[key];
  1214. _worker.findInDesignerProperty(key, propertyDefinition, item, option, module, designer, null, ["view", "data", "pagingList", i, key]);
  1215. }
  1216. });
  1217. });
  1218. }
  1219. }
  1220. }else{
  1221. var propertyDefinition = this.designerPropertysData.statement[pattern.property];
  1222. if (propertyDefinition){
  1223. _worker.findInDesignerProperty(pattern.property, propertyDefinition, statementJson, option, module, designer, null, [pattern.property]);
  1224. }
  1225. }
  1226. });
  1227. // if (statementJson.view){
  1228. // var viewJson = JSON.parse(statementJson.view);
  1229. // var viewData = viewJson.data;
  1230. //
  1231. // }
  1232. }, function () {});
  1233. }
  1234. // }else{
  1235. // Promise.resolve(this.designerPropertysData).then(function(data){
  1236. // this.designerPropertysData = data;
  1237. // designer.patternList.forEach(function(pattern){
  1238. // var propertyDefinition = this.designerPropertysData.statement[pattern.property];
  1239. // if (propertyDefinition){
  1240. // _worker._findMessageReply(_worker._createFindMessageReplyData(module, designer, "", {
  1241. // "type": "Statement",
  1242. // "propertyType": propertyDefinition.type || "text",
  1243. // "propertyName": propertyDefinition.name,
  1244. // "name": designer.designerName,
  1245. // "key": pattern.property,
  1246. // "mode": null,
  1247. // "path": [pattern.property],
  1248. // "value": pattern.propertyValue
  1249. // }), option);
  1250. // }
  1251. // });
  1252. // }, function(){});
  1253. // }
  1254. }
  1255. };
  1256. _worker._findProcessPlatformParse_process = function(designer, option, module){
  1257. if (designer.patternList && designer.patternList.length){
  1258. var p = _worker._getDesignerData(designer, module);
  1259. if (p){
  1260. p.then(function(arr){
  1261. var processData = arr[0].data;
  1262. this.designerPropertysData = arr[1];
  1263. designer.patternList.forEach(function(pattern){
  1264. if (pattern.elementType === "process"){
  1265. debugger;
  1266. var propertyDefinition = this.designerPropertysData.process[pattern.property];
  1267. processData.type = pattern.elementType;
  1268. _worker.findInDesignerProperty(pattern.property, propertyDefinition, processData, option, module, designer, null, [pattern.property]);
  1269. }else if (pattern.elementType === "route") {
  1270. for (var i=0; i<processData.routeList.length; i++){
  1271. if (processData.routeList[i].id===pattern.elementId) break;
  1272. }
  1273. Object.keys(processData.routeList[i]).forEach(function(key){
  1274. var propertyDefinition = this.designerPropertysData.process[key];
  1275. processData.routeList[i].type = pattern.elementType;
  1276. _worker.findInDesignerProperty(key, propertyDefinition, processData.routeList[i], option, module, designer, null,["routeList", i, key]);
  1277. }.bind(this));
  1278. }else{
  1279. if (pattern.elementType=="begin" && pattern.elementId===processData.begin.id){
  1280. Object.keys(processData.begin).forEach(function(key){
  1281. var propertyDefinition = this.designerPropertysData.process[key];
  1282. processData.begin.type = pattern.elementType;
  1283. _worker.findInDesignerProperty(key, propertyDefinition, processData.begin, option, module, designer, null,["begin", key]);
  1284. }.bind(this));
  1285. }else{
  1286. var arrKey = pattern.elementType+"List";
  1287. for (var i=0; i<processData[arrKey].length; i++){
  1288. if (processData[arrKey][i].id===pattern.elementId) break;
  1289. }
  1290. Object.keys(processData[arrKey][i]).forEach(function(key){
  1291. var propertyDefinition = this.designerPropertysData.process[key];
  1292. processData[arrKey][i].type = pattern.elementType;
  1293. _worker.findInDesignerProperty(key, propertyDefinition, processData[arrKey][i], option, module, designer, null,[arrKey, i, key]);
  1294. }.bind(this));
  1295. }
  1296. }
  1297. });
  1298. }, function(){});
  1299. }
  1300. }
  1301. };
  1302. _worker._findProcessPlatformParse = function(resultList, option, module){
  1303. resultList.forEach(function(designer){
  1304. switch (designer.designerType){
  1305. case "script":
  1306. _worker._findProcessPlatformParse_script(designer, option, module);
  1307. break;
  1308. case "form":
  1309. case "page":
  1310. case "widget":
  1311. debugger;
  1312. _worker._findProcessPlatformParse_form(designer, option, module);
  1313. break;
  1314. case "process":
  1315. _worker._findProcessPlatformParse_process(designer, option, module);
  1316. break;
  1317. case "view":
  1318. _worker._findProcessPlatformParse_view(designer, option, module);
  1319. break;
  1320. case "statement":
  1321. _worker._findProcessPlatformParse_statement(designer, option, module);
  1322. break;
  1323. }
  1324. });
  1325. };
  1326. _worker._doFindDesigner = function(option, idx){
  1327. var option = this.filterOptionList[idx];
  1328. var res = _worker._getRequestOption({
  1329. "method": "post",
  1330. "url": this.findData.actions.findAction,
  1331. "body": JSON.stringify(option),
  1332. "debug": this.findData.debug,
  1333. "token": this.findData.token
  1334. });
  1335. this.action.sendRequest(res).then(function(json){
  1336. if (json.data.processPlatformList && json.data.processPlatformList.length){
  1337. // var worker = new Worker("../x_component_FindDesigner/PatternWorker.js");
  1338. // worker.onmessage = function(e) {
  1339. // if (e.data) _worker._findMessageReply(e.data, option);
  1340. // }.bind(this);
  1341. // worker.postMessage({
  1342. // "parser": "_findProcessPlatformParse",
  1343. // "actions": _worker.findData.actions,
  1344. // "option": option,
  1345. // "pattern": json.data.processPlatformList
  1346. // });
  1347. _worker._findProcessPlatformParse(json.data.processPlatformList, option, "processPlatform");
  1348. }
  1349. if (json.data.cmsList && json.data.cmsList.length){
  1350. _worker._findProcessPlatformParse(json.data.cmsList, option, "cms");
  1351. }
  1352. if (json.data.portalList && json.data.portalList.length){
  1353. _worker._findProcessPlatformParse(json.data.portalList, option, "portal");
  1354. }
  1355. if (json.data.queryList && json.data.queryList.length){
  1356. _worker._findProcessPlatformParse(json.data.queryList, option, "query");
  1357. }
  1358. if (json.data.serviceList && json.data.serviceList.length){
  1359. _worker._findProcessPlatformParse(json.data.serviceList, option, "service");
  1360. }
  1361. _worker._findOptionReply();
  1362. idx++;
  1363. if (this.filterOptionList.length>idx){
  1364. _worker._doFindDesigner(null, idx);
  1365. }else{
  1366. debugger;
  1367. _worker._findCompletedReply();
  1368. }
  1369. //this.filterOptionList[idx];
  1370. //_worker._findMessageReply(json.data, option);
  1371. }, function(xhr){
  1372. _worker._findOptionReply(null);
  1373. _worker._findMessageReply(null);
  1374. idx++;
  1375. if (this.filterOptionList.length>idx){
  1376. _worker._doFindDesigner(null, idx);
  1377. }else{
  1378. _worker._findCompletedReply();
  1379. }
  1380. });
  1381. },
  1382. _worker._doFindDesignerFromFilterOption = function(){
  1383. var idx = 0;
  1384. //this.filterOptionList.forEach(function(option){
  1385. // _worker._doFindDesigner(option, idx);
  1386. //});
  1387. _worker._doFindDesigner(null, idx);
  1388. },
  1389. onmessage = function(e) {
  1390. this.findData = e.data;
  1391. var moduleList = this.findData.filterOption.moduleList;
  1392. this.findData.filterOption.moduleList = [];
  1393. _worker._setFilterOptionRegex();
  1394. this.filterOptionTemplete = JSON.stringify(this.findData.filterOption);
  1395. this.filterOptionList = [];
  1396. Promise.all(_worker._parseFindModule(moduleList)).then(function(){
  1397. // this.filterOptionList[0].moduleList=[];
  1398. // //_worker._doFindDesigner(this.filterOptionList[0]);
  1399. // this.filterOptionList = [this.filterOptionList[0]];
  1400. _worker._readyMessageReply();
  1401. debugger;
  1402. _worker._doFindDesignerFromFilterOption();
  1403. });
  1404. //"moduleType": "cms", "flagList": [];
  1405. // designerTypes
  1406. // flagList = [{
  1407. // "id": "dddd",
  1408. // "desingerList": [
  1409. // {
  1410. // "desingerType": "脚本(script)表单(form)流程(process)页面(page)部件(widget)视图(view)脚本(statement)统计(stat",
  1411. // "id": ""
  1412. // },
  1413. // {
  1414. // "desingerType": "脚本(script)表单(form)流程(process)页面(page)部件(widget)视图(view)脚本(statement)统计(stat",
  1415. // "id": ""
  1416. // }
  1417. // ]
  1418. // }]
  1419. _worker._receiveMessageReply();
  1420. //_worker.action.sendRequest(e.data);
  1421. }