Property.js 69 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576
  1. MWF.require("MWF.widget.UUID", null,false);
  2. MWF.require("MWF.widget.JsonTemplate", null, false);
  3. MWF.xApplication.process.ProcessDesigner.Property = new Class({
  4. Implements: [Options, Events],
  5. load: function(){
  6. if (!this.process.options.isView){
  7. if (this.fireEvent("queryLoad")){
  8. MWF.getRequestText(this.htmlPath, function(responseText, responseXML){
  9. this.htmlString = responseText;
  10. this.fireEvent("postLoad");
  11. }.bind(this));
  12. }
  13. this.process.propertyListNode.addEvent("keydown", function(e){e.stopPropagation();});
  14. }
  15. },
  16. editProperty: function(td){
  17. },
  18. getHtmlString: function(callback){
  19. if (!this.htmlString){
  20. MWF.getRequestText(this.htmlPath, function(responseText, responseXML){
  21. this.htmlString = responseText;
  22. if (callback) callback();
  23. }.bind(this));
  24. }else{
  25. if (callback) callback();
  26. }
  27. },
  28. //隐藏高级属性
  29. hideAdvanced: function(){
  30. if (this.process.panel.showAdvanced && !this.process.panel.showAdvanced.checked){
  31. var advs = this.propertyContent.querySelectorAll("*[data-o2-advanced=\"yes\"]");
  32. if (advs && advs.length){
  33. for (var i=0; i<advs.length; i++){
  34. advs[i].hide();
  35. }
  36. }
  37. }
  38. },
  39. show: function(){
  40. if (!this.process.options.isView){
  41. if (!this.propertyContent){
  42. this.getHtmlString(function(){
  43. this.htmlString = o2.bindJson(this.htmlString, {"lp": o2.APPPD.LP.propertyTemplate});
  44. this.propertyContent = new Element("div", {"styles": {"overflow": "hidden"}}).inject(this.process.propertyListNode);
  45. this.process.panel.propertyTabPage.showTabIm();
  46. this.JsonTemplate = new MWF.widget.JsonTemplate(this.data, this.htmlString);
  47. this.propertyContent.set("html", this.JsonTemplate.load());
  48. this.process.panel.data = this.data;
  49. this.setEditNodeEvent();
  50. this.setEditNodeStyles(this.propertyContent);
  51. this.loadPropertyTab();
  52. this.loadFormFieldInput();
  53. this.loadPersonInput();
  54. this.loadCalendarInput();
  55. this.loadScriptInput();
  56. this.loadScriptText();
  57. this.loadConditionInput();
  58. this.loadFormSelect();
  59. this.loadSerial();
  60. this.loadArrayList();
  61. this.loadDataTraceFieldSelect();
  62. this.loadSericalActivitySelect();
  63. this.loadApplicationSelector();
  64. this.loadProcessSelector();
  65. this.loadIconSelect();
  66. this.loadContextRoot();
  67. this.loadProjection();
  68. this.loadMaplist();
  69. this.loadQueryTablePublisher();
  70. this.loadGobackActivityConfig();
  71. this.loadActivityParticipant();
  72. this.hideAdvanced();
  73. }.bind(this));
  74. //this.loadDutySelector();
  75. }else{
  76. this.process.panel.data = this.data;
  77. this.propertyContent.setStyle("display", "block");
  78. this.process.panel.propertyTabPage.showTabIm();
  79. }
  80. // this.process.isFocus = true;
  81. }
  82. },
  83. //hide: function(){
  84. // if (!this.process.options.isView) {
  85. // this.JsonTemplate = null;
  86. //
  87. // this.scriptTexts.each(function(script){
  88. // MWF.release(script);
  89. // }.bind(this));
  90. // this.scriptTexts = null;
  91. //
  92. // this.propertyContent.set("html", "");
  93. // }
  94. //},
  95. hide: function(){
  96. if (!this.process.options.isView) {
  97. if (this.propertyContent) this.propertyContent.setStyle("display", "none");
  98. }
  99. },
  100. loadPropertyTab: function(){
  101. var tabNodes = this.propertyContent.getElements(".MWFTab");
  102. if (tabNodes.length){
  103. var tmpNode = this.propertyContent.getFirst();
  104. var tabAreaNode = new Element("div", {
  105. "styles": this.process.css.propertyTabNode
  106. }).inject(tmpNode, "before");
  107. MWF.require("MWF.widget.Tab", function(){
  108. var tab = new MWF.widget.Tab(tabAreaNode, {"style": "moduleList"});
  109. tab.load();
  110. var tabPages = [];
  111. tabNodes.each(function(node){
  112. var tabPage = tab.addTab(node, node.get("title"), false);
  113. tabPages.push(tabPage);
  114. if (node.hasAttribute("data-o2-advanced") && node.dataset["o2Advanced"]=="yes"){
  115. tabPage.tabNode.setAttribute("data-o2-advanced", "yes");
  116. }
  117. }.bind(this));
  118. tabPages[0].showTab();
  119. }.bind(this));
  120. }
  121. },
  122. setEditNodeEvent: function(){
  123. var property = this;
  124. // var inputs = this.propertyContent.getElements(".editTableInput");
  125. var inputs = this.propertyContent.getElements("input");
  126. inputs.each(function(input){
  127. var jsondata = input.get("name");
  128. var id = this.process.process.id;
  129. if (this.activity) id = this.activity.data.id;
  130. if (this.route) id = this.route.data.id;
  131. if (jsondata){
  132. var inputType = input.get("type").toLowerCase();
  133. switch (inputType){
  134. case "radio":
  135. input.set("name", id+jsondata);
  136. input.addEvent("change", function(e){
  137. property.setRadioValue(jsondata, this);
  138. });
  139. input.addEvent("blur", function(e){
  140. property.setRadioValue(jsondata, this);
  141. });
  142. input.addEvent("keydown", function(e){
  143. e.stopPropagation();
  144. });
  145. property.setRadioValue(jsondata, input);
  146. break;
  147. case "checkbox":
  148. input.set("name", id+jsondata);
  149. input.addEvent("keydown", function(e){
  150. e.stopPropagation();
  151. });
  152. input.addEvent("change", function(e){
  153. property.setCheckboxValue(jsondata, this, id);
  154. });
  155. input.addEvent("blur", function(e){
  156. property.setCheckboxValue(jsondata, this, id);
  157. });
  158. property.setCheckboxValue(jsondata, input, id);
  159. break;
  160. default:
  161. input.addEvent("change", function(e){
  162. property.setValue(jsondata, this.value);
  163. });
  164. input.addEvent("blur", function(e){
  165. property.setValue(jsondata, this.value);
  166. });
  167. input.addEvent("keydown", function(e){
  168. if (e.code===13){
  169. property.setValue(jsondata, this.value);
  170. }
  171. e.stopPropagation();
  172. });
  173. property.setValue(jsondata, input.get("value"));
  174. }
  175. }
  176. }.bind(this));
  177. var selects = this.propertyContent.getElements("select");
  178. selects.each(function(select){
  179. var jsondata = select.get("name");
  180. if (jsondata){
  181. select.addEvent("change", function(e){
  182. property.setSelectValue(jsondata, this);
  183. });
  184. //property.setSelectValue(jsondata, select);
  185. }
  186. });
  187. var textareas = this.propertyContent.getElements("textarea");
  188. textareas.each(function(input){
  189. var jsondata = input.get("name");
  190. if (jsondata){
  191. input.addEvent("change", function(e){
  192. property.setValue(jsondata, this.value);
  193. });
  194. input.addEvent("blur", function(e){
  195. property.setValue(jsondata, this.value);
  196. });
  197. input.addEvent("keydown", function(e){
  198. e.stopPropagation();
  199. });
  200. }
  201. }.bind(this));
  202. },
  203. setSelectValue: function(name, select){
  204. var idx = select.selectedIndex;
  205. var options = select.getElements("option");
  206. var value = "";
  207. if (options[idx]){
  208. value = options[idx].get("value");
  209. }
  210. this.data[name] = value;
  211. },
  212. setCheckboxValue: function(name, input, id){
  213. var nodes = this.propertyContent.querySelectorAll('input[name="'+id+name+'"]');
  214. var value = [];
  215. nodes.forEach(function(node){
  216. if (node.checked){
  217. value.push(node.value);
  218. }
  219. });
  220. var names = name.split(".");
  221. var o = this.data;
  222. while (names.length>1){
  223. var k = names.shift();
  224. if (!o.hasOwnProperty(k)){
  225. o[k] = {};
  226. }
  227. o=o[k];
  228. }
  229. var key = names.shift();
  230. o[key] = value;
  231. },
  232. setRadioValue: function(name, input){
  233. if (input.checked){
  234. // var oldValue = this.data[name];
  235. var value = input.value;
  236. if (value=="false") value = false;
  237. if (value=="true") value = true;
  238. if (input.dataset.valueType && input.dataset.valueType==='number'){
  239. value = parseFloat(value);
  240. }
  241. var names = name.split(".");
  242. var oldValue = null;
  243. var o = this.data;
  244. while (names.length>1){
  245. var k = names.shift();
  246. if (!o.hasOwnProperty(k)){
  247. o[k] = {};
  248. }
  249. o=o[k];
  250. }
  251. var key = names.shift();
  252. oldValue = o[key];
  253. o[key] = value;
  254. // this.data[name] = value;
  255. if (this.route) this.route._setEditProperty(name, input, oldValue);
  256. }
  257. },
  258. setValue: function(name, value){
  259. // var oldValue = this.data[name];
  260. // this.data[name] = value;
  261. var names = name.split(".");
  262. var oldValue = null;
  263. var o = this.data;
  264. while (names.length>1){
  265. var k = names.shift();
  266. if (!o.hasOwnProperty(k)){
  267. o[k] = {};
  268. }
  269. o=o[k];
  270. }
  271. var key = names.shift();
  272. oldValue = o[key];
  273. o[key] = value;
  274. if (name=="name"){
  275. if (!value) this.data[name] = MWF.APPPD.LP.unnamed;
  276. // this.activity.redraw();
  277. }
  278. if (this.route) this.route._setEditProperty(name, input, oldValue);
  279. },
  280. setEditNodeStyles: function(node){
  281. var nodes = node.getChildren();
  282. if (nodes.length){
  283. nodes.each(function(el){
  284. var cName = el.get("class");
  285. if (cName){
  286. if (this.process.css[cName]) el.setStyles(this.process.css[cName]);
  287. }
  288. this.setEditNodeStyles(el);
  289. }.bind(this));
  290. }
  291. },
  292. loadScriptText: function(){
  293. this.scriptTexts = [];
  294. var scriptNodes = this.propertyContent.getElements(".MWFScriptText");
  295. MWF.xDesktop.requireApp("process.ProcessDesigner", "widget.ScriptText", function(){
  296. var _self = this;
  297. scriptNodes.each(function(node){
  298. var api = node.dataset["o2Api"];
  299. var editorType = node.dataset["editorType"];
  300. var loadImmediately = node.dataset["loadImmediately"];
  301. var script = new MWF.xApplication.process.ProcessDesigner.widget.ScriptText(node, this.data[node.get("name")], this.process.designer, {
  302. "api": api,
  303. "forceType": editorType || null,
  304. "maskNode": this.process.designer.content,
  305. "maxObj": this.process.designer.paperNode,
  306. "onChange": function(code){
  307. _self.data[node.get("name")] = code;
  308. },
  309. "type": node.dataset["type"]
  310. });
  311. if( loadImmediately )script.loadEditor();
  312. this.scriptTexts.push(script);
  313. //this.setScriptItems(script, node);
  314. node.store("editor", script);
  315. }.bind(this));
  316. }.bind(this));
  317. },
  318. loadScriptInput: function(){
  319. var scriptNodes = this.propertyContent.getElements(".MWFScript");
  320. MWF.xDesktop.requireApp("process.ProcessDesigner", "widget.ScriptSelector", function(){
  321. var _self = this;
  322. scriptNodes.each(function(node){
  323. var script = new MWF.xApplication.process.ProcessDesigner.widget.ScriptSelector(node, this.data[node.get("name")], this.process.designer, {
  324. "maskNode": this.process.designer.content,
  325. "onSelected": function(scriptData){
  326. _self.data[node.get("name")] = scriptData.name;
  327. },
  328. "onDelete": function(){
  329. _self.data[node.get("name")] = "";
  330. node.empty();
  331. }
  332. //"onPostSave": function(script){
  333. // this.saveScriptItem(node, script);
  334. //}.bind(this),
  335. //"onQueryDelete": function(script){
  336. // this.deleteScriptItem(node, script);
  337. //}.bind(this)
  338. });
  339. //this.setScriptItems(script, node);
  340. node.store("selector", script);
  341. }.bind(this));
  342. }.bind(this));
  343. },
  344. loadScriptArea: function(){
  345. var scriptAreas = this.propertyContent.getElements(".MWFScriptArea");
  346. var formulaAreas = this.propertyContent.getElements(".MWFFormulaArea");
  347. this.loadScriptEditor(scriptAreas);
  348. this.loadScriptEditor(formulaAreas, "formula");
  349. },
  350. loadScriptEditor: function(scriptAreas, style){
  351. scriptAreas.each(function(node){
  352. var title = node.get("title");
  353. var name = node.get("name");
  354. if (!this.data[name]) this.data[name] = {"code": "", "html": ""};
  355. var scriptContent = this.data[name];
  356. MWF.require("MWF.widget.ScriptArea", function(){
  357. var scriptArea = new MWF.widget.ScriptArea(node, {
  358. "title": title,
  359. //"maxObj": this.propertyNode.parentElement.parentElement.parentElement,
  360. "maxObj": this.process.designer.content,
  361. "onChange": function(){
  362. if (!this.data[name]){
  363. this.data[name] = {"code": "", "html": ""};
  364. //if (this.module.form.scriptDesigner) this.module.form.scriptDesigner.addScriptItem(this.data[name], "code", this.data, name);
  365. }
  366. var json = scriptArea.toJson();
  367. this.data[name].code = json.code;
  368. }.bind(this),
  369. //"onSave": function(){
  370. // this.designer.saveForm();
  371. //}.bind(this),
  372. "style": style || "default"
  373. });
  374. scriptArea.load(scriptContent);
  375. }.bind(this));
  376. }.bind(this));
  377. },
  378. loadUnitTypeSelector: function(){
  379. var nodes = this.propertyContent.getElements(".MWFFormUnitTypeSelector");
  380. if (nodes.length){
  381. this.getUnitTypeList(function(){
  382. nodes.each(function(node){
  383. var select = new Element("select").inject(node);
  384. select.addEvent("change", function(e){
  385. this.setValue(e.target.getParent("div").get("name"), e.target.options[e.target.selectedIndex].value);
  386. }.bind(this));
  387. this.setUnitTypeSelectOptions(node, select);
  388. this.setValue(select.getParent("div").get("name"), select.options[select.selectedIndex].value);
  389. // var refreshNode = new Element("div", {"styles": this.form.css.propertyRefreshFormNode}).inject(node);
  390. // refreshNode.addEvent("click", function(e){
  391. // this.getUnitTypeList(function(){
  392. // this.setUnitTypeSelectOptions(node, select);
  393. // }.bind(this), true);
  394. // }.bind(this));
  395. }.bind(this));
  396. }.bind(this));
  397. }
  398. },
  399. setUnitTypeSelectOptions: function(node, select){
  400. var name = node.get("name");
  401. select.empty();
  402. var option = new Element("option", {"value":"all", "text": MWF.xApplication.process.ProcessDesigner.LP.all, "selected": (!this.data[name] || this.data[name]==="all")}).inject(select);
  403. this.unitTypeList.each(function(unitType){
  404. var option = new Element("option", {
  405. "text": unitType,
  406. "value": unitType,
  407. "selected": (this.data[name]===unitType)
  408. }).inject(select);
  409. }.bind(this));
  410. },
  411. getUnitTypeList: function(callback, refresh){
  412. if (!this.unitTypeList || refresh){
  413. //MWF.xDesktop.requireApp("Org", "Actions.RestActions", function(){
  414. // var action = new MWF.xApplication.Org.Actions.RestActions();
  415. var action = MWF.Actions.get("x_organization_assemble_control");
  416. action.listUnitType(function(json){
  417. this.unitTypeList = json.data.valueList;
  418. if (callback) callback();
  419. }.bind(this));
  420. //}.bind(this));
  421. }else{
  422. if (callback) callback();
  423. }
  424. },
  425. loadFormFieldInput: function(){
  426. var fieldNodes = this.propertyContent.getElements(".MWFFormFieldPerson");
  427. MWF.xDesktop.requireApp("process.ProcessDesigner", "widget.PersonSelector", function(){
  428. fieldNodes.each(function(node){
  429. var dataType = node.get("data-o2-type");
  430. var data = this.data[node.get("name")];
  431. if( dataType && dataType === "string" && o2.typeOf(data) === "string")data = data.split(",");
  432. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.process.designer, {
  433. "type": "formField",
  434. "application": this.process.process.application,
  435. "fieldType": "person",
  436. "names": data || [],
  437. "onChange": function(ids){this.savePersonItem(node, ids, dataType);}.bind(this)
  438. });
  439. }.bind(this));
  440. }.bind(this));
  441. },
  442. createCalendar: function(node){
  443. if (!node.retrieve("calendar")){
  444. var calendar = new MWF.widget.Calendar(node, {
  445. "isTime": true,
  446. // "target": node.getParent(),
  447. "style": "xform",
  448. "secondEnable": true,
  449. "format": "db",
  450. "onChange": function(dv, date, t){
  451. this.setValue(node.get("name"), dv)
  452. }.bind(this)
  453. });
  454. node.store("calendar", calendar);
  455. }
  456. },
  457. loadCalendarInput: function(){
  458. var nodes = this.propertyContent.getElements(".MWFDateTime");
  459. MWF.require("MWF.widget.Calendar", function(){
  460. nodes.each(function(node){
  461. var input = node.getFirst();
  462. input.addEvents({
  463. "click": function(){ this.createCalendar(input) }.bind(this),
  464. "focus": function(){ this.createCalendar(input) }.bind(this)
  465. });
  466. }.bind(this));
  467. }.bind(this));
  468. },
  469. loadDataTraceFieldSelect: function(){
  470. var buttonList = this.propertyContent.getElements(".MWFDataTraceFieldSelect");
  471. var lp = this.process.designer.lp.propertyTemplate;
  472. buttonList.each(function(node){
  473. node.addEventListener("click", function(){
  474. var arrayListNode = node.getNext();
  475. var arrayList = arrayListNode.arrayList;
  476. var selectedFields = arrayList.toArray();
  477. var content = new Element('div.o2_vue', {
  478. "styles": this.process.css.selectDataTraceFieldArea
  479. });
  480. const formArea = new Element('div', {"styles": this.process.css.selectDataTraceArea}).inject(content);
  481. new Element('div', {"styles": this.process.css.selectDataTraceAreaTitle, text: lp.selectForm}).inject(formArea);
  482. const formContent = new Element('div', {"styles": this.process.css.selectDataTraceAreaContent}).inject(formArea);
  483. const fieldArea = new Element('div', {"styles": this.process.css.selectDataTraceArea}).inject(content);
  484. new Element('div', {"styles": this.process.css.selectDataTraceAreaTitle, text: lp.selectField}).inject(fieldArea);
  485. const fieldContent = new Element('div', {"styles": this.process.css.selectDataTraceAreaContent}).inject(fieldArea);
  486. const selectedArea = new Element('div', {"styles": this.process.css.selectDataTraceArea}).inject(content);
  487. new Element('div', {"styles": this.process.css.selectDataTraceAreaTitle, text: lp.selectedField}).inject(selectedArea);
  488. const selectedContent = new Element('div', {"styles": this.process.css.selectDataTraceAreaContent}).inject(selectedArea);
  489. if (!selectedContent.selectedFields) selectedContent.selectedFields = {};
  490. selectedFields.forEach(function(name){
  491. this.createSelectedItem(name, selectedContent);
  492. }.bind(this));
  493. content.style.boxSizing = 'border-box!important';
  494. var _self = this;
  495. o2.Actions.load("x_processplatform_assemble_designer").FormAction.listWithApplication(this.process.process.application, function(json){
  496. json.data.forEach(function(form){
  497. var item = new Element("div", {
  498. "text": form.name,
  499. "styles": _self.process.css.selectFormItemNode
  500. }).inject(formContent);
  501. item.store('formId', form.id);
  502. item.addEvents({
  503. "mouseover": function(e){e.target.addClass('lightColor_bg');},
  504. "mouseout": function(e){e.target.removeClass('lightColor_bg');},
  505. "click": function(e){ _self.selectedForm(e.target, fieldContent, selectedContent); }
  506. });
  507. });
  508. });
  509. o2.DL.open({
  510. title: lp.dataTraceFieldNamesSelect,
  511. width: 700,
  512. height: 500,
  513. content: content,
  514. buttonList: [
  515. {
  516. text: "确定",
  517. action: function(){
  518. _self.selectFieldsOk(selectedContent, arrayList);
  519. this.close();
  520. }
  521. },
  522. {
  523. text: "关闭",
  524. type: "cancel",
  525. action: function(){
  526. this.close();
  527. }
  528. }
  529. ]
  530. });
  531. }.bind(this));
  532. }.bind(this));
  533. },
  534. selectFieldsOk: function(selectedContent, arrayList){
  535. var fields = Object.keys(selectedContent.selectedFields);
  536. arrayList.clear();
  537. arrayList.loadContent(fields);
  538. arrayList.fireEvent("change");
  539. },
  540. selectedForm: function(node, fieldContent, selectedContent){
  541. if (fieldContent.formNode){
  542. fieldContent.formNode.removeClass('mainColor_bg');
  543. }
  544. node.addClass('mainColor_bg');
  545. node.removeClass('lightColor_bg');
  546. fieldContent.formNode = node;
  547. var _self = this;
  548. var id = node.retrieve("formId");
  549. o2.Actions.load("x_processplatform_assemble_designer").FormAction.get(id, function(form){
  550. var fields = this.getFormFields(form.data.data);
  551. var mobileFields = this.getFormFields(form.data.mobileData);
  552. fields.forEach(function(name){
  553. _self.createFieldItem(name, fieldContent, selectedContent);
  554. });
  555. mobileFields.forEach(function(name){
  556. if (fields.indexOf(name)===-1){
  557. _self.createFieldItem(name, fieldContent, selectedContent);
  558. }
  559. });
  560. }.bind(this));
  561. },
  562. createFieldItem: function(name, fieldContent, selectedContent){
  563. var item = new Element("label", {
  564. "html": "<input type='checkbox' value='"+name+"'><div>"+name+"</div>",
  565. "styles": this.process.css.selectFieldItemNode
  566. }).inject(fieldContent);
  567. if (selectedContent.selectedFields[name]){
  568. item.getElement('input').checked = true;
  569. }
  570. var _self = this;
  571. item.addEvents({
  572. "mouseover": function(e){if (!item.firstElementChild.checked) item.addClass('lightColor_bg');},
  573. "mouseout": function(e){if (!item.firstElementChild.checked) item.removeClass('lightColor_bg');}
  574. });
  575. item.firstElementChild.addEventListener('click', function(e){ e.stopPropagation(); _self.clickField(e.target, selectedContent); });
  576. },
  577. clickField: function(input, selectedContent){
  578. var checked = input.checked;
  579. var name = input.value;
  580. var node = input.parentElement;
  581. if (checked){
  582. node.addClass('mainColor_bg');
  583. node.removeClass('lightColor_bg');
  584. this.createSelectedItem(name, selectedContent);
  585. }else{
  586. node.removeClass('mainColor_bg');
  587. var item = selectedContent.selectedFields[name];
  588. item.destroy();
  589. selectedContent.selectedFields[name] = null;
  590. }
  591. },
  592. createSelectedItem: function(name, node){
  593. var flag = !node.selectedFields[name];
  594. if (flag){
  595. var item = new Element("div", {
  596. "html": name,
  597. "styles": this.process.css.selectFormItemNode
  598. }).inject(node);
  599. node.selectedFields[name] = item;
  600. }
  601. },
  602. getFormFields: function(data){
  603. if (data){
  604. var fieldTypeList = ["textfield", "textarea", "select", "radio", "personfield",
  605. "orgfield", "org", "number", "currency", "eltime", "elswitch", "elslider", "elselect", "elrate",
  606. "elradio", "elnumber", "elinput", "eldatetime", "eldate", "elcolorpicker", "elcheckbox",
  607. "elcascader", "elautocomplete", "combox", "checkbox", "calendar", "address"];
  608. var formData = JSON.decode(MWF.decodeJsonString(data));
  609. var json = formData.json;
  610. return Object.keys(json.moduleList).filter(function(k){
  611. var m = json.moduleList[k]
  612. return (fieldTypeList.indexOf(m.type.toLowerCase())!==-1 || fieldTypeList.indexOf(m.moduleName)!==-1);
  613. })
  614. // .map(function(k){
  615. // return {
  616. // name: k,
  617. // type: json.moduleList[k].type,
  618. // }
  619. // });
  620. }
  621. return [];
  622. },
  623. saveGobackConfig: function(check, select, defineConfigList){
  624. var activityId = check.value;
  625. var config = defineConfigList.find(function(c){
  626. return c.activity === activityId;
  627. });
  628. if (check.checked){
  629. var way = select.options[select.selectedIndex].value;
  630. if (config){
  631. config.way = way;
  632. }else{
  633. defineConfigList.push({
  634. activity: activityId,
  635. way: way
  636. });
  637. }
  638. }else {
  639. if (config) {
  640. defineConfigList.erase(config);
  641. }
  642. }
  643. },
  644. loadGobackActivityConfig: function(){
  645. var nodes = this.propertyContent.getElements(".gobackActivityConfig");
  646. // this.manuals
  647. nodes.each(function(node){
  648. var keys = Object.keys(this.process.manuals);
  649. if (keys.length){
  650. var html = '<table cellspacing="0" cellpadding="5px" style="width: 100%; border: 1px solid #cccccc; border-collapse: collapse"><tr>' +
  651. // '<th class="grayColor_bg" style="width: 20px; max-width: 20px; border: 1px solid #cccccc;"></th>' +
  652. '<th class="grayColor_bg" style="text-align:left; border: 1px solid #cccccc;">活动</th>' +
  653. '<th class="grayColor_bg" style="text-align:left; border: 1px solid #cccccc;">退回后处理方式</th>' +
  654. '</tr></table>';
  655. node.insertAdjacentHTML('beforeend', html);
  656. var table = node.getElement('table');
  657. if (!this.data.goBackConfig) this.data.goBackConfig = {};
  658. if (!this.data.goBackConfig.defineConfigList) this.data.goBackConfig.defineConfigList = [];
  659. var defineConfigList = this.data.goBackConfig.defineConfigList;
  660. keys.forEach(function(key){
  661. var activity = this.process.manuals[key];
  662. if (activity.data.id !== this.data.id){
  663. var config = defineConfigList.find(function(c){
  664. return c.activity === activity.data.id;
  665. });
  666. var tr = table.insertRow();
  667. var td = tr.insertCell();
  668. td.setStyles({
  669. "border": "1px solid #cccccc"
  670. });
  671. var label = new Element('label').inject(td);
  672. var check = new Element('input',{
  673. type: 'checkbox',
  674. value: activity.data.id,
  675. checked: !!config
  676. }).inject(label);
  677. label.appendChild(document.createTextNode(activity.data.name));
  678. check.addEvent('click', function(e){
  679. var select = e.target.getParent('tr').getElement('select');
  680. this.saveGobackConfig(e.target, select, defineConfigList);
  681. }.bind(this));
  682. td = tr.insertCell();
  683. td.setStyles({
  684. "border": "1px solid #cccccc"
  685. });
  686. var select = new Element('select', {
  687. html: '<option '+(!config || config.way==='default' ? 'selected' : '')+' value="default" select>'+o2.APPPD.LP.propertyTemplate.backWayDefault+'</option>' +
  688. '<option '+(config && config.way==='step' ? 'selected' : '')+' value="step" select>'+o2.APPPD.LP.propertyTemplate.backWayStep+'</option>' +
  689. '<option '+(config && config.way==='jump' ? 'selected' : '')+' value="jump">'+o2.APPPD.LP.propertyTemplate.backWayJump+'</option>' +
  690. '<option '+(config && config.way==='custom' ? 'selected' : '')+' value="custom">'+o2.APPPD.LP.propertyTemplate.backWayCustom+'</option>'
  691. }).inject(td);
  692. select.addEvent('click', function(e){
  693. var check = e.target.getParent('tr').getElement('input');
  694. this.saveGobackConfig(check, e.target, defineConfigList);
  695. }.bind(this));
  696. }
  697. }.bind(this));
  698. }
  699. // var title = node.get("title");
  700. // var name = node.get("name");
  701. // var lName = name.toLowerCase();
  702. // var collapse = node.get("collapse");
  703. // var mapObj = this.data[name] || {};
  704. // //if (!mapObj) mapObj = {};
  705. // MWF.require("MWF.widget.Maplist", function(){
  706. // node.empty();
  707. // var maplist = new MWF.widget.Maplist(node, {
  708. // "title": title,
  709. // "collapse": (collapse) ? true : false,
  710. // "onChange": function(){
  711. // //this.data[name] = maplist.toJson();
  712. // //
  713. // //var oldData = this.data[name];
  714. // this.setValue(name, maplist.toJson());
  715. // // this.changeStyle(name, oldData);
  716. // // this.changeData(name);
  717. // }.bind(this),
  718. // "isProperty": (lName.contains("properties") || lName.contains("property") || lName.contains("attribute"))
  719. // });
  720. // maplist.load(mapObj);
  721. // //this.maplists[name] = maplist;
  722. // }.bind(this));
  723. }.bind(this));
  724. },
  725. loadPersonInput: function(){
  726. var personIdentityNodes = this.propertyContent.getElements(".MWFPersonIdentity");
  727. var personNodes = this.propertyContent.getElements(".MWFPersonPerson");
  728. var personUnitNodes = this.propertyContent.getElements(".MWFPersonUnit");
  729. var personGroupNodes = this.propertyContent.getElements(".MWFPersonGroup");
  730. var dutyNameNodes = this.propertyContent.getElements(".MWFPersonDuty");
  731. // var personDepartmentNodes = this.propertyContent.getElements(".MWFPersonDepartment");
  732. // var personCompanyNodes = this.propertyContent.getElements(".MWFPersonCompany");
  733. var dutyNodes = this.propertyContent.getElements(".MWFDutySelector");
  734. var tableNodes = this.propertyContent.getElements(".MWFTableSelector");
  735. var cmsCategoryNodes = this.propertyContent.getElements(".MWFCMSCategorySelector");
  736. var formFieldString = this.propertyContent.getElements(".MWFFormFieldString");
  737. MWF.xDesktop.requireApp("process.ProcessDesigner", "widget.PersonSelector", function(){
  738. personIdentityNodes.each(function(node){
  739. var count = node.get("count") || 0;
  740. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.process.designer, {
  741. "type": "identity",
  742. "names": this.data[node.get("name")],
  743. "count": count,
  744. "onChange": function(ids){this.savePersonItem(node, ids);}.bind(this)
  745. });
  746. }.bind(this));
  747. personNodes.each(function(node){
  748. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.process.designer, {
  749. "type": "person",
  750. "names": this.data[node.get("name")],
  751. "onChange": function(ids){this.savePersonItem(node, ids);}.bind(this)
  752. });
  753. }.bind(this));
  754. personUnitNodes.each(function(node){
  755. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.process.designer, {
  756. "type": "unit",
  757. "names": this.data[node.get("name")],
  758. "onChange": function(ids){this.savePersonItem(node, ids);}.bind(this)
  759. });
  760. }.bind(this));
  761. personGroupNodes.each(function(node){
  762. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.process.designer, {
  763. "type": "group",
  764. "names": this.data[node.get("name")],
  765. "onChange": function(ids){this.savePersonItem(node, ids);}.bind(this)
  766. });
  767. }.bind(this));
  768. dutyNodes.each(function(node){
  769. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.process.designer, {
  770. "type": "duty",
  771. "names": this.data[node.get("name")],
  772. "onChange": function(ids){this.addDutyItem(node, ids);}.bind(this),
  773. "onRemoveDuty": function(item){this.removeDutyItem(node, item);}.bind(this)
  774. });
  775. }.bind(this));
  776. dutyNameNodes.each(function(node){
  777. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.process.designer, {
  778. "type": "dutyName",
  779. "names": this.data[node.get("name")],
  780. "onChange": function(ids){this.savePersonItem(node, ids);}.bind(this)
  781. });
  782. }.bind(this));
  783. tableNodes.each(function(node){
  784. var resultKey = node.get("data-result-key");
  785. var selector = new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.process.designer, {
  786. "type": "queryTable",
  787. "count": node.get("count") || 0,
  788. "names": this.data[node.get("name")],
  789. "onChange": function(ids){this.savePersonItem(node, ids, null, resultKey);}.bind(this)
  790. });
  791. node.store("selector", selector);
  792. }.bind(this));
  793. cmsCategoryNodes.each(function(node){
  794. var resultKey = node.get("data-result-key");
  795. var data;
  796. if( resultKey ){
  797. var d = this.data[node.get("name")] || [];
  798. data = ( o2.typeOf( d ) === "array" ? d : [d] ).map(function(i){
  799. var obj = {};
  800. obj[ resultKey ] = i;
  801. return obj;
  802. });
  803. }else{
  804. data = this.data[node.get("name")] || [];
  805. }
  806. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.process.designer, {
  807. "type": "CMSCategory",
  808. "count": node.get("count") || 0,
  809. "names": data,
  810. "onChange": function(ids){this.savePersonItem(node, ids, null, resultKey);}.bind(this)
  811. });
  812. }.bind(this));
  813. formFieldString.each(function(node){
  814. var count = node.get("count") || 0;
  815. var dataType = node.get("data-o2-type");
  816. var data = this.data[node.get("name")];
  817. if( dataType && dataType === "string" && o2.typeOf(data) === "string")data = data.split(",");
  818. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.process.designer, {
  819. "type": "formField",
  820. "count": count,
  821. "application": this.process.process.application,
  822. "fieldType": "string",
  823. "names": data || [],
  824. "onChange": function(ids){this.savePersonItem(node, ids, dataType);}.bind(this)
  825. });
  826. }.bind(this));
  827. // personDepartmentNodes.each(function(node){
  828. // new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.process.designer, {
  829. // "type": "department",
  830. // "names": this.data[node.get("name")],
  831. // "onChange": function(ids){this.savePersonItem(node, ids);}.bind(this)
  832. // });
  833. // }.bind(this));
  834. // personCompanyNodes.each(function(node){
  835. // new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.process.designer, {
  836. // "type": "company",
  837. // "names": this.data[node.get("name")],
  838. // "onChange": function(ids){this.savePersonItem(node, ids);}.bind(this)
  839. // });
  840. // }.bind(this));
  841. // dutyNodes.each(function(node){
  842. // new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.process.designer, {
  843. // "type": "duty",
  844. // "names": this.data[node.get("name")],
  845. // "onChange": function(ids){this.addDutyItem(node, ids);}.bind(this),
  846. // "onRemoveDuty": function(item){this.removeDutyItem(node, item);}.bind(this)
  847. // });
  848. // }.bind(this));
  849. }.bind(this));
  850. },
  851. removeDutyItem: function(node, item){
  852. if (item.data.id){
  853. var values = JSON.decode(this.data[node.get("name")]) || [];
  854. var value = values.filter(function(v){
  855. return v.id == item.data.id;
  856. });
  857. value.each(function(v) {
  858. values = values.erase(v);
  859. });
  860. this.data[node.get("name")] = JSON.encode(values);
  861. }
  862. item.node.destroy();
  863. MWF.release(item);
  864. delete item;
  865. },
  866. addDutyItem: function(node, ids){
  867. var value = this.data[node.get("name")] || "";
  868. if (!value) value = "[]";
  869. var values = JSON.decode(value);
  870. ids.each(function(id){
  871. if (id.data.dutyId){
  872. for (var i=0; i<values.length; i++){
  873. if (values[i].dutyId===id.data.dutyId){
  874. values[i].name = id.data.name;
  875. values[i].code = id.data.code;
  876. break;
  877. }
  878. }
  879. }else{
  880. id.data.dutyId = new MWF.widget.UUID().toString();
  881. values.push({"name": id.data.name, "id": id.data.id, "dutyId": id.data.dutyId, "code": id.data.code});
  882. }
  883. }.bind(this));
  884. this.data[node.get("name")] = JSON.encode(values);
  885. },
  886. savePersonItem: function(node, ids, dataType, resultKey){
  887. var count = node.get("count") || 0;
  888. var values = [];
  889. ids.each(function(id){
  890. if( resultKey ){
  891. values.push( id.data[resultKey] );
  892. }else{
  893. values.push(id.data.distinguishedName || id.data.id);
  894. }
  895. }.bind(this));
  896. var data;
  897. if( count && count.toInt()==1 ){
  898. data = values[0]
  899. }else if( dataType === "string" ){
  900. data = values.join(",");
  901. }else{
  902. data = values;
  903. }
  904. this.data[node.get("name")] = data;
  905. },
  906. savePersonObjectItem: function(node, ids){
  907. var values = [];
  908. ids.each(function(id){
  909. values.push(id.data);
  910. }.bind(this));
  911. this.data[node.get("name")] = values;
  912. },
  913. loadConditionInput: function(){
  914. var conditionNodes = this.propertyContent.getElements(".MWFCondition");
  915. conditionNodes.each(function(node){
  916. MWF.xDesktop.requireApp("process.ProcessDesigner", "widget.ConditionEditor", function(){
  917. var script = new MWF.xApplication.process.ProcessDesigner.widget.ConditionEditor(node, {
  918. "onPostSave": function(script){
  919. this.saveScriptItem(node, script);
  920. }.bind(this),
  921. "onQueryDelete": function(script){
  922. this.deleteScriptItem(node, script);
  923. }.bind(this)
  924. });
  925. this.setScriptItems(script, node);
  926. }.bind(this));
  927. }.bind(this));
  928. },
  929. loadFormSelect: function(){
  930. var formNodes = this.propertyContent.getElements(".MWFFormSelect");
  931. if (formNodes.length){
  932. this.getFormList(function(){
  933. formNodes.each(function(node){
  934. var select = new Element("select").inject(node);
  935. var option = new Element("option", {"text": "none"}).inject(select);
  936. select.addEvent("change", function(e){
  937. this.setValue(e.target.getParent("div").get("name"), e.target.options[e.target.selectedIndex].value);
  938. }.bind(this));
  939. this.setFormSelectOptions(node, select);
  940. var refreshNode = new Element("div", {"styles": this.process.css.propertyRefreshFormNode}).inject(node);
  941. refreshNode.addEvent("click", function(e){
  942. this.getFormList(function(){
  943. this.setFormSelectOptions(node, select);
  944. }.bind(this), true);
  945. }.bind(this));
  946. var openNode = new Element("div", {"styles": this.process.css.propertyOpenFormNode}).inject(node);
  947. openNode.addEvent("click", function(e){
  948. var name = node.get("name");
  949. var formId = this.data[name];
  950. if( formId && formId !== "none" ){
  951. o2.Actions.load("x_processplatform_assemble_designer").FormAction.get(formId, function () {
  952. var options = {
  953. "style": layout.desktop.formDesignerStyle || "default",
  954. "appId": "process.FormDesigner"+formId,
  955. "id": formId
  956. };
  957. layout.openApplication(null, "process.FormDesigner", options);
  958. }.bind(this), function () {
  959. return true;
  960. })
  961. }
  962. }.bind(this));
  963. }.bind(this));
  964. }.bind(this));
  965. }
  966. },
  967. setFormSelectOptions: function(node, select){
  968. var name = node.get("name");
  969. select.empty();
  970. var option = new Element("option", {"text": "none"}).inject(select);
  971. this.forms.each(function(form){
  972. var option = new Element("option", {
  973. "text": form.name,
  974. "value": form.id,
  975. "selected": (this.data[name]==form.id)
  976. }).inject(select);
  977. }.bind(this));
  978. },
  979. getFormList: function(callback, refresh){
  980. if (!this.forms || refresh){
  981. this.process.designer.actions.listForm(this.process.designer.application.id, function(json){
  982. this.forms = json.data;
  983. if (callback) callback();
  984. }.bind(this));
  985. }else{
  986. if (callback) callback();
  987. }
  988. },
  989. loadArrayList: function(){
  990. var arrays = this.propertyContent.getElements(".MWFArraylist");
  991. arrays.each(function(node){
  992. var title = node.get("title");
  993. var name = node.get("name");
  994. var arr = this.data[name];
  995. if (!arr) arr = [];
  996. MWF.require("MWF.widget.Arraylist", function(){
  997. var arraylist = new MWF.widget.Arraylist(node, {
  998. "title": title,
  999. "onChange": function(){
  1000. var oldValue = this.data[name];
  1001. this.data[name] = arraylist.toArray();
  1002. }.bind(this)
  1003. });
  1004. arraylist.load(arr);
  1005. node.arrayList = arraylist;
  1006. }.bind(this));
  1007. node.addEvent("keydown", function(e){e.stopPropagation();});
  1008. }.bind(this));
  1009. },
  1010. loadMaplist: function(){
  1011. var maplists = this.propertyContent.getElements(".MWFMaplist");
  1012. maplists.each(function(node){
  1013. var title = node.get("title");
  1014. var name = node.get("name");
  1015. var lName = name.toLowerCase();
  1016. var collapse = node.get("collapse");
  1017. var mapObj = this.data[name] || {};
  1018. //if (!mapObj) mapObj = {};
  1019. MWF.require("MWF.widget.Maplist", function(){
  1020. node.empty();
  1021. var maplist = new MWF.widget.Maplist(node, {
  1022. "title": title,
  1023. "collapse": (collapse) ? true : false,
  1024. "onChange": function(){
  1025. this.setValue(name, maplist.toJson());
  1026. }.bind(this),
  1027. "isProperty": (lName.contains("properties") || lName.contains("property") || lName.contains("attribute"))
  1028. });
  1029. maplist.load(mapObj);
  1030. }.bind(this));
  1031. }.bind(this));
  1032. },
  1033. loadSerial: function(){
  1034. var serialNodes = this.propertyContent.getElements(".MWFSerial");
  1035. if (serialNodes.length){
  1036. // this.getSerialRule(function(){
  1037. MWF.xDesktop.requireApp("process.ProcessDesigner", "widget.SerialEditor", function(){
  1038. serialNodes.each(function(node){
  1039. var serialEditor = new MWF.xApplication.process.ProcessDesigner.widget.SerialEditor(node, this.data[node.get("name")]);
  1040. serialEditor.addEvent("change", function(e){
  1041. this.setValue(node.get("name"), JSON.encode(serialEditor.getData()));
  1042. }.bind(this));
  1043. serialEditor.process = this.process;
  1044. serialEditor.load();
  1045. }.bind(this));
  1046. }.bind(this));
  1047. // }.bind(this));
  1048. }
  1049. },
  1050. loadSericalActivitySelect: function(){
  1051. var serialNodes = this.propertyContent.getElements(".MWFSericalActivitySelect");
  1052. if (serialNodes.length){
  1053. serialNodes.each(function(node){
  1054. var select = new Element("select").inject(node);
  1055. select.addEvent("change", function(e){
  1056. this.setValue(e.target.getParent("div").get("name"), e.target.options[e.target.selectedIndex].value);
  1057. }.bind(this));
  1058. this.listSericalActivityOptions(node, select);
  1059. var refreshNode = new Element("div", {"styles": this.process.css.propertyRefreshFormNode}).inject(node);
  1060. refreshNode.addEvent("click", function(e){
  1061. this.listSericalActivityOptions(node, select);
  1062. }.bind(this));
  1063. }.bind(this));
  1064. }
  1065. },
  1066. listSericalActivityOptions: function(node, select){
  1067. var name = node.get("name");
  1068. select.empty();
  1069. var option = new Element("option", {"text": "none"}).inject(select);
  1070. var option = new Element("option", {
  1071. "text": this.process.process.begin.name,
  1072. "value": this.process.process.begin.id,
  1073. "selected": (this.data[name]===this.process.process.begin.id)
  1074. }).inject(select);
  1075. this.listSericalActivitys("endList", name, select);
  1076. this.listSericalActivitys("cancelList", name, select);
  1077. this.listSericalActivitys("manualList", name, select);
  1078. this.listSericalActivitys("conditionList", name, select);
  1079. this.listSericalActivitys("choiceList", name, select);
  1080. this.listSericalActivitys("splitList", name, select);
  1081. this.listSericalActivitys("parallelList", name, select);
  1082. this.listSericalActivitys("mergeList", name, select);
  1083. this.listSericalActivitys("embedList", name, select);
  1084. this.listSericalActivitys("publishList", name, select);
  1085. this.listSericalActivitys("delayList", name, select);
  1086. this.listSericalActivitys("invokeList", name, select);
  1087. this.listSericalActivitys("serviceList", name, select);
  1088. this.listSericalActivitys("agentList", name, select);
  1089. this.listSericalActivitys("messageList", name, select);
  1090. },
  1091. listSericalActivitys: function(p, name, select){
  1092. var datas = this.process.process[p];
  1093. if (datas){
  1094. var count = datas.length;
  1095. if (count){
  1096. datas.each(function(data){
  1097. var option = new Element("option", {
  1098. "text": data.name,
  1099. "value": data.id,
  1100. "selected": (this.data[name]===data.id)
  1101. }).inject(select);
  1102. }.bind(this));
  1103. }
  1104. }
  1105. },
  1106. loadApplicationSelector: function(){
  1107. var nodes = this.propertyContent.getElements(".MWFApplicationSelect");
  1108. if (nodes.length){
  1109. this._getAppSelector(function(){
  1110. nodes.each(function(node){
  1111. var title = new Element("div", {"styles": this.process.css.applicationSelectTitle, "text": node.get("title")}).inject(node);
  1112. var action = new Element("div", {"styles": this.process.css.applicationSelectAction, "text": node.get("title")}).inject(node);
  1113. var content = new Element("div", {"styles": this.process.css.applicationSelectContent}).inject(node);
  1114. action.addEvent("click", function(e){
  1115. this.appSelector.load(function(apps){
  1116. content.empty();
  1117. if (apps.length){
  1118. this.data.targetApplication = apps[0].id;
  1119. this.data.targetApplicationName = apps[0].name;
  1120. this.data.targetApplicationAlias = apps[0].alias;
  1121. new Element("div", {
  1122. "styles": this.process.css.applicationSelectItem,
  1123. "text": apps[0].name
  1124. }).inject(content);
  1125. }else{
  1126. this.data.targetApplication = "";
  1127. this.data.targetApplicationName = "";
  1128. this.data.targetApplicationAlias = "";
  1129. }
  1130. var processNodes = this.propertyContent.getElements(".MWFProcessSelect");
  1131. processNodes.each(function(n){
  1132. this.data.targetProcess = "";
  1133. this.data.targetProcessName = "";
  1134. this.data.targetProcessAlias = "";
  1135. var processContent = n.getLast();
  1136. processContent.empty();
  1137. }.bind(this));
  1138. }.bind(this));
  1139. }.bind(this));
  1140. if (this.data.targetApplication){
  1141. new Element("div", {
  1142. "styles": this.process.css.applicationSelectItem,
  1143. "text": this.data.targetApplicationName
  1144. }).inject(content);
  1145. }
  1146. }.bind(this));
  1147. }.bind(this));
  1148. }
  1149. },
  1150. _getAppSelector: function(callback){
  1151. if (!this.appSelector){
  1152. MWF.xDesktop.requireApp("process.ProcessManager", "widget.ApplicationSelector", function(){
  1153. this.appSelector = new MWF.xApplication.process.ProcessManager.widget.ApplicationSelector(this.process.designer, {"maskNode": this.process.designer.content, "multi": false});
  1154. if (callback) callback();
  1155. }.bind(this));
  1156. }else{
  1157. if (callback) callback();
  1158. }
  1159. },
  1160. loadProcessSelector: function(){
  1161. var nodes = this.propertyContent.getElements(".MWFProcessSelect");
  1162. if (nodes.length){
  1163. nodes.each(function(node){
  1164. var title = new Element("div", {"styles": this.process.css.applicationSelectTitle, "text": node.get("title")}).inject(node);
  1165. var action = new Element("div", {"styles": this.process.css.applicationSelectAction, "text": node.get("title")}).inject(node);
  1166. var content = new Element("div", {"styles": this.process.css.applicationSelectContent}).inject(node);
  1167. action.addEvent("click", function(e){
  1168. new o2.O2Selector(this.process.designer.content, {
  1169. "count": 1,
  1170. "type": "process",
  1171. "onComplete": function(items){
  1172. if (items.length){
  1173. content.empty();
  1174. this.data.targetApplication = items[0].data.application;
  1175. this.data.targetApplicationName = items[0].data.applicationName;
  1176. this.data.targetApplicationAlias = "";
  1177. this.data.targetProcess = items[0].data.id;
  1178. this.data.targetProcessName = items[0].data.name;
  1179. this.data.targetProcessAlias = items[0].data.alias;
  1180. new Element("div", {
  1181. "styles": this.process.css.applicationSelectItem,
  1182. "text": this.data.targetProcessName
  1183. }).inject(content);
  1184. }else{
  1185. this.data.targetApplication = "";
  1186. this.data.targetApplicationName = "";
  1187. this.data.targetApplicationAlias = "";
  1188. this.data.targetProcess = "";
  1189. this.data.targetProcessName = "";
  1190. this.data.targetProcessAlias = "";
  1191. content.empty();
  1192. }
  1193. }.bind(this)
  1194. });
  1195. }.bind(this));
  1196. if (this.data.targetProcess){
  1197. new Element("div", {
  1198. "styles": this.process.css.applicationSelectItem,
  1199. "text": this.data.targetProcessName
  1200. }).inject(content);
  1201. }
  1202. }.bind(this));
  1203. // this._getProcessSelector(function(){
  1204. // nodes.each(function(node){
  1205. // var title = new Element("div", {"styles": this.process.css.applicationSelectTitle, "text": node.get("title")}).inject(node);
  1206. // var action = new Element("div", {"styles": this.process.css.applicationSelectAction, "text": node.get("title")}).inject(node);
  1207. // var content = new Element("div", {"styles": this.process.css.applicationSelectContent}).inject(node);
  1208. // action.addEvent("click", function(e){
  1209. // var id = this.data.targetApplication;
  1210. // this.processSelector.load([id], function(pros){
  1211. // content.empty();
  1212. // if (pros.length){
  1213. // this.data.targetProcess = pros[0].id;
  1214. // this.data.targetProcessName = pros[0].name;
  1215. // this.data.targetProcessAlias = pros[0].alias;
  1216. //
  1217. // new Element("div", {
  1218. // "styles": this.process.css.applicationSelectItem,
  1219. // "text": pros[0].name
  1220. // }).inject(content);
  1221. // }else{
  1222. // this.data.targetProcess = "";
  1223. // this.data.targetProcessName = "";
  1224. // this.data.targetProcessAlias = "";
  1225. // }
  1226. // }.bind(this));
  1227. // }.bind(this));
  1228. //
  1229. // if (this.data.targetProcess){
  1230. // new Element("div", {
  1231. // "styles": this.process.css.applicationSelectItem,
  1232. // "text": this.data.targetProcessName
  1233. // }).inject(content);
  1234. // }
  1235. // }.bind(this));
  1236. // }.bind(this));
  1237. }
  1238. },
  1239. _getProcessSelector: function(callback){
  1240. if (!this.processSelector){
  1241. MWF.xDesktop.requireApp("process.ProcessManager", "widget.ProcessSelector", function(){
  1242. this.processSelector = new MWF.xApplication.process.ProcessManager.widget.ProcessSelector(this.process.designer, {"maskNode": this.process.designer.content, "multi": false});
  1243. if (callback) callback();
  1244. }.bind(this));
  1245. }else{
  1246. if (callback) callback();
  1247. }
  1248. },
  1249. loadIconSelect: function(){
  1250. var nodes = this.propertyContent.getElements(".MWFIcon");
  1251. if (nodes.length){
  1252. nodes.each(function(node){
  1253. var id = node.get("name");
  1254. var icon = this.data[id];
  1255. var iconNode = new Element("div", {"styles": this.process.css.processIconNode}).inject(node);
  1256. if (icon) iconNode.setStyles({"background": "url("+icon+") center center no-repeat"});
  1257. var selectNode = new Element("div", {"styles": this.process.css.processIconSelectNode, "text": this.process.designer.lp.selectIcon}).inject(node);
  1258. selectNode.addEvent("click", function(){
  1259. this.selectIcon(node);
  1260. }.bind(this));
  1261. }.bind(this));
  1262. }
  1263. },
  1264. loadContextRoot: function(){
  1265. var nodes = this.propertyContent.getElements(".MWFContextRoot");
  1266. if (nodes){
  1267. nodes.each(function(node){
  1268. var name = node.get("name");
  1269. var value = this.data[name];
  1270. var select = new Element("select").inject(node);
  1271. Object.each(layout.serviceAddressList, function(v, key){
  1272. var option = new Element("option", {"value": key, "text": v.name, "selected": (value==key)}).inject(select);
  1273. }.bind(this));
  1274. var option = new Element("option", {"value": "x_program_center", "text": this.process.designer.lp.centerServer, "selected": (value=="x_program_center")}).inject(select);
  1275. select.addEvent("change", function(){
  1276. var data = select.options[select.selectedIndex].value;
  1277. // this.changeJsonDate(name, data);
  1278. // this.changeData(name, node, value);
  1279. this.setValue(name, data);
  1280. }.bind(this));
  1281. }.bind(this));
  1282. }
  1283. },
  1284. loadProjection: function(){
  1285. var nodes = this.propertyContent.getElements(".MWFProjection");
  1286. if (nodes){
  1287. nodes.each(function(node){
  1288. var name = node.get("name");
  1289. var value = this.data[name];
  1290. MWF.xDesktop.requireApp("process.ProcessDesigner", "widget.ProjectionEditor", function(){
  1291. var projection = new MWF.xApplication.process.ProcessDesigner.widget.ProjectionEditor(node, value, {
  1292. "onChange": function(){
  1293. this.setValue(node.get("name"), JSON.encode(projection.getData()));
  1294. }.bind(this),
  1295. "process": this.process.process.id
  1296. });
  1297. projection.load();
  1298. }.bind(this));
  1299. // var select = new Element("select").inject(node);
  1300. // Object.each(layout.desktop.serviceAddressList, function(v, key){
  1301. // var option = new Element("option", {"value": key, "text": v.name, "selected": (value==key)}).inject(select);
  1302. // }.bind(this));
  1303. // select.addEvent("change", function(){
  1304. // var data = select.options[select.selectedIndex].value;
  1305. // // this.changeJsonDate(name, data);
  1306. // // this.changeData(name, node, value);
  1307. // this.setValue(name, data);
  1308. // }.bind(this));
  1309. }.bind(this));
  1310. }
  1311. },
  1312. selectIcon: function(node){
  1313. if (!node.iconMenu){
  1314. var tr = node.getParent("tr");
  1315. var p = tr.getPosition(this.process.designer.paperInNode.getNext());
  1316. var iconSelectMenu = new MWF.widget.Menu(node, {"left": p.x-330, "top": p.y, "event": "click", "style": "processIcon"});
  1317. iconSelectMenu.load();
  1318. node.iconMenu = iconSelectMenu;
  1319. var _self = this;
  1320. for (var i=0; i<=48; i++){
  1321. var icon = "../x_component_process_ProcessManager/$Explorer/default/processIcon/process_icon_"+i+".png";
  1322. var item = iconSelectMenu.addMenuItem("", "click", function(){
  1323. var id = node.get("name");
  1324. var src = this.item.getElement("img").get("src");
  1325. _self.data[id] = src;
  1326. node.getFirst("div").setStyle("background-image", "url("+src+")");
  1327. }, icon);
  1328. item.iconName = icon;
  1329. }
  1330. }
  1331. },
  1332. deleteScriptItem: function(node, script){
  1333. var jsondata = node.get("name");
  1334. this.data[jsondata].erase(script.data.id);
  1335. this.process.scripts[script.data.id] = null;
  1336. delete this.process.scripts[script.data.id];
  1337. this.process.process.scriptList.erase(script.data);
  1338. },
  1339. saveScriptItem: function(node, script){
  1340. var jsondata = node.get("name");
  1341. var scriptList = this.data[jsondata];
  1342. var data = script.data;
  1343. var scriptData = this.process.scripts[script.data.id];
  1344. if (!scriptData){
  1345. this.process.process.scriptList.push(data);
  1346. this.process.scripts[script.data.id] = data;
  1347. }
  1348. if (scriptList.indexOf(data.id) == -1){
  1349. this.data[jsondata].push(data.id);
  1350. }
  1351. },
  1352. setScriptItems: function(script, node){
  1353. var jsondata = node.get("name");
  1354. var scriptList = this.data[jsondata];
  1355. if (scriptList){
  1356. scriptList.each(function(id){
  1357. if (id){
  1358. var data = this.process.scripts[id];
  1359. if (data) script.setScriptItem(data);
  1360. }
  1361. }.bind(this));
  1362. }
  1363. },
  1364. showMultiActivity: function(activitys){
  1365. this.hide();
  1366. var multiActivityTable = new HtmlTable({
  1367. "properties": this.process.css.activityListTable
  1368. }).inject(this.propertyContent);
  1369. activitys.each(function(activity){
  1370. this.row = multiActivityTable.push([
  1371. {
  1372. "content": " ",
  1373. "properties": {
  1374. "styles": activity.style.listIcon
  1375. }
  1376. },
  1377. {
  1378. "content": activity.data.name,
  1379. "properties": {
  1380. "width": "80px",
  1381. "styles": this.process.css.list.listText
  1382. }
  1383. },
  1384. {
  1385. "content": " "+activity.data.description,
  1386. "properties": {
  1387. "styles": this.process.css.list.listTextDescription
  1388. }
  1389. }
  1390. ]);
  1391. }.bind(this));
  1392. },
  1393. loadOrgEditor: function(){
  1394. var orgNodes = this.propertyContent.getElements(".MWFOrgEditor");
  1395. if(orgNodes.length){
  1396. orgNodes.each(function(node){
  1397. MWF.xDesktop.requireApp("process.ProcessDesigner", "widget.OrgEditor", function(){
  1398. var editor = new MWF.xApplication.process.ProcessDesigner.widget.OrgEditor(node, this.route, this.data.selectConfig, {
  1399. "onPostSave": function(script){
  1400. //this.saveScriptItem(node, script);
  1401. }.bind(this),
  1402. "onQueryDelete": function(script){
  1403. //this.deleteScriptItem(node, script);
  1404. }.bind(this)
  1405. });
  1406. editor.load();
  1407. //this.setScriptItems(script, node);
  1408. }.bind(this));
  1409. }.bind(this));
  1410. }
  1411. },
  1412. loadQueryTablePublisher: function(){
  1413. var tableNodes = this.propertyContent.getElements(".MWFQueryTablePublisher");
  1414. if(tableNodes.length){
  1415. tableNodes.each(function(node){
  1416. var name = node.get("name");
  1417. var value = this.data[name];
  1418. MWF.xDesktop.requireApp("process.ProcessDesigner", "widget.QueryTablePublisher", function(){
  1419. var publisher = new MWF.xApplication.process.ProcessDesigner.widget.QueryTablePublisher(node, value, {
  1420. "onChange": function(){
  1421. this.setValue(node.get("name"), publisher.getData());
  1422. }.bind(this)
  1423. }, this);
  1424. publisher.load();
  1425. }.bind(this));
  1426. }.bind(this));
  1427. }
  1428. },
  1429. loadActivityParticipant: function(){
  1430. var nodes = this.propertyContent.getElements(".MWFActivityParticipant");
  1431. if(nodes.length){
  1432. var id = this.process.process.id;
  1433. if (this.activity) id = this.activity.data.id;
  1434. if (this.route) id = this.route.data.id;
  1435. var property = this;
  1436. if (!this.data.taskParticipant) this.data.taskParticipant = {type: "", data:""}
  1437. // var ids = (this.data.taskParticipant && this.data.taskParticipant.data) ? JSON.parse(this.data.taskParticipant.data) : [];
  1438. var ids = this.data.taskParticipant.data || [];
  1439. nodes.each(function(node){
  1440. var jsondata = "taskParticipant.data";
  1441. // var vdata = property.data.taskParticipant.data;
  1442. // var acts = (vdata) ? JSON.parse(vdata) : [];
  1443. var acts = property.data.taskParticipant.data || [];
  1444. Object.keys(this.process.manuals).forEach(function(k){
  1445. var a = this.process.manuals[k];
  1446. var label = new Element('label', {
  1447. html: "<input name='"+id+jsondata+"' type='checkbox' value='"+a.data.id+"'>"+a.data.name
  1448. });
  1449. const input = label.firstChild;
  1450. if (acts.indexOf(a.data.id)!==-1) input.checked = true;
  1451. input.addEvent("keydown", function(e){
  1452. e.stopPropagation();
  1453. });
  1454. input.addEvent("change", function(e){
  1455. var v = property.getCheckboxValue(id+jsondata);
  1456. // property.data.taskParticipant.data = JSON.stringify(v);
  1457. property.data.taskParticipant.data = v;
  1458. });
  1459. input.addEvent("blur", function(e){
  1460. var v = property.getCheckboxValue(id+jsondata);
  1461. // property.data.taskParticipant.data = JSON.stringify(v);
  1462. property.data.taskParticipant.data = v;
  1463. });
  1464. label.inject(node);
  1465. }.bind(this));
  1466. }.bind(this));
  1467. }
  1468. },
  1469. getCheckboxValue: function (name){
  1470. var nodes = this.propertyContent.querySelectorAll('input[name="'+name+'"]');
  1471. var value = [];
  1472. nodes.forEach(function(node){
  1473. if (node.checked){
  1474. value.push(node.value);
  1475. }
  1476. });
  1477. return value
  1478. }
  1479. });