Property.js 64 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435
  1. MWF.require("MWF.widget.Common", null, false);
  2. MWF.require("MWF.widget.JsonTemplate", null, false);
  3. MWF.xApplication.query.ViewDesigner.Property = MWF.FVProperty = new Class({
  4. Extends: MWF.widget.Common,
  5. Implements: [Options, Events],
  6. options: {
  7. "style": "default",
  8. "path": "../x_component_query_FormDesigner/property/property.html"
  9. },
  10. initialize: function (module, propertyNode, designer, options) {
  11. this.setOptions(options);
  12. this.module = module;
  13. this.view = module.view;
  14. this.data = module.json;
  15. this.data.vid = this.view.json.id;
  16. this.data.vtype = this.view.json.type;
  17. this.data.pid = this.view.json.id + this.data.id;
  18. this.htmlPath = this.options.path;
  19. this.maplists = {};
  20. this.designer = designer;
  21. this.propertyNode = propertyNode;
  22. },
  23. load: function () {
  24. if (this.fireEvent("queryLoad")) {
  25. MWF.getRequestText(this.htmlPath, function (responseText, responseXML) {
  26. this.htmlString = responseText;
  27. this.fireEvent("postLoad");
  28. }.bind(this));
  29. }
  30. this.propertyNode.addEvent("keydown", function (e) {
  31. e.stopPropagation();
  32. });
  33. },
  34. editProperty: function (td) {
  35. },
  36. getHtmlString: function (callback) {
  37. if (!this.htmlString) {
  38. MWF.getRequestText(this.htmlPath, function (responseText, responseXML) {
  39. this.htmlString = responseText;
  40. if (callback) callback();
  41. }.bind(this));
  42. } else {
  43. if (callback) callback();
  44. }
  45. },
  46. show: function () {
  47. if (!this.propertyContent) {
  48. this.getHtmlString(function () {
  49. if (this.htmlString) {
  50. this.JsonTemplate = new MWF.widget.JsonTemplate(this.data, this.htmlString);
  51. this.propertyContent = new Element("div", {"styles": {"overflow": "hidden"}}).inject(this.propertyNode);
  52. this.propertyContent.set("html", this.JsonTemplate.load());
  53. this.setEditNodeEvent();
  54. this.setEditNodeStyles(this.propertyContent);
  55. this.loadPropertyTab();
  56. this.loadPersonInput();
  57. this.loadPersonSelectInput();
  58. this.loadViewFilter();
  59. this.loadScriptArea();
  60. this.loadColumnExportEditor();
  61. this.loadJSONArea();
  62. this.loadEventsEditor();
  63. this.loadViewStylesArea();
  64. this.loadPagingStylesArea();
  65. this.loadActionStylesArea();
  66. this.loadActionArea();
  67. this.loadStylesList();
  68. this.loadMaplist();
  69. }
  70. }.bind(this));
  71. } else {
  72. this.propertyContent.setStyle("display", "block");
  73. }
  74. },
  75. hide: function () {
  76. //this.JsonTemplate = null;
  77. //this.propertyNode.set("html", "");
  78. if (this.propertyContent) this.propertyContent.setStyle("display", "none");
  79. },
  80. loadJSONArea: function () {
  81. var jsonNode = this.propertyContent.getElement(".MWFJSONArea");
  82. if (jsonNode) {
  83. this.propertyTab.pages.each(function (page) {
  84. if (page.contentNode == jsonNode.parentElement) {
  85. page.setOptions({
  86. "onShow": function () {
  87. jsonNode.empty();
  88. MWF.require("MWF.widget.JsonParse", function () {
  89. this.json = new MWF.widget.JsonParse(this.module.json, jsonNode, null);
  90. this.json.load();
  91. }.bind(this));
  92. }.bind(this)
  93. });
  94. }
  95. }.bind(this));
  96. }
  97. },
  98. loadPropertyTab: function () {
  99. var tabNodes = this.propertyContent.getElements(".MWFTab");
  100. if (tabNodes.length) {
  101. var tmpNode = this.propertyContent.getFirst();
  102. var tabAreaNode = new Element("div", {
  103. "styles": this.view.css.propertyTabNode
  104. }).inject(tmpNode, "before");
  105. MWF.require("MWF.widget.Tab", function () {
  106. var tab = new MWF.widget.Tab(tabAreaNode, {"style": "formPropertyList"});
  107. tab.load();
  108. var tabPages = [];
  109. tabNodes.each(function (node) {
  110. var page = tab.addTab(node, node.get("title"), false);
  111. tabPages.push(page);
  112. this.setScrollBar(page.contentNodeArea, "small", null, null);
  113. }.bind(this));
  114. tabPages[0].showTab();
  115. this.propertyTab = tab;
  116. this.designer.resizeNode();
  117. }.bind(this), false);
  118. }
  119. },
  120. setEditNodeEvent: function () {
  121. var property = this;
  122. // var inputs = this.process.propertyListNode.getElements(".editTableInput");
  123. var inputs = this.propertyContent.getElements("input");
  124. inputs.each(function (input) {
  125. var jsondata = input.get("name");
  126. if (jsondata && jsondata.substr(0, 1) != "_") {
  127. if (this.module) {
  128. var id = this.module.json.id;
  129. input.set("name", id + jsondata);
  130. }
  131. if (jsondata) {
  132. var inputType = input.get("type").toLowerCase();
  133. switch (inputType) {
  134. case "radio":
  135. input.addEvent("change", function (e) {
  136. property.setRadioValue(jsondata, this);
  137. });
  138. input.addEvent("blur", function (e) {
  139. property.setRadioValue(jsondata, this);
  140. });
  141. input.addEvent("keydown", function (e) {
  142. e.stopPropagation();
  143. });
  144. property.setRadioValue(jsondata, input);
  145. break;
  146. case "checkbox":
  147. input.addEvent("change", function (e) {
  148. property.setCheckboxValue(jsondata, this);
  149. });
  150. input.addEvent("click", function (e) {
  151. property.setCheckboxValue(jsondata, this);
  152. });
  153. input.addEvent("keydown", function (e) {
  154. e.stopPropagation();
  155. });
  156. break;
  157. default:
  158. input.addEvent("change", function (e) {
  159. property.setValue(jsondata, this.value, this);
  160. });
  161. input.addEvent("blur", function (e) {
  162. property.setValue(jsondata, this.value, this);
  163. });
  164. input.addEvent("keydown", function (e) {
  165. if (e.code == 13) {
  166. property.setValue(jsondata, this.value, this);
  167. }
  168. e.stopPropagation();
  169. });
  170. if (input.hasClass("editTableInputDate")) {
  171. this.loadCalendar(input, jsondata);
  172. }
  173. }
  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. loadCalendar: function (node, jsondata) {
  204. MWF.require("MWF.widget.Calendar", function () {
  205. this.calendar = new MWF.widget.Calendar(node, {
  206. "style": "xform",
  207. "isTime": false,
  208. "target": this.module.designer.content,
  209. "format": "%Y-%m-%d",
  210. "onComplate": function () {
  211. this.setValue(jsondata, node.value, node);
  212. //this.validationMode();
  213. //this.validation();
  214. //this.fireEvent("complete");
  215. }.bind(this)
  216. });
  217. //this.calendar.show();
  218. }.bind(this));
  219. },
  220. changeStyle: function (name) {
  221. this.module.setPropertiesOrStyles(name);
  222. },
  223. changeData: function (name, input, oldValue) {
  224. var i = name.lastIndexOf("*");
  225. var n = (i != -1) ? name.substr(i + 1, name.length) : name;
  226. this.module._setEditStyle(n, input, oldValue);
  227. },
  228. changeJsonDate: function (key, value) {
  229. if (typeOf(key) != "array") key = [key];
  230. var o = this.data;
  231. var len = key.length - 1;
  232. key.each(function (n, i) {
  233. if (!o[n]) o[n] = {};
  234. if (i < len) o = o[n];
  235. }.bind(this));
  236. o[key[len]] = value;
  237. },
  238. setRadioValue: function (name, input) {
  239. if (input.checked) {
  240. var i = name.indexOf("*");
  241. var names = (i == -1) ? name.split(".") : name.substr(i + 1, name.length).split(".");
  242. var value = input.value;
  243. if (value == "false") value = false;
  244. if (value == "true") value = true;
  245. var oldValue = this.data;
  246. for (var idx = 0; idx < names.length; idx++) {
  247. if (!oldValue[names[idx]]) {
  248. oldValue = null;
  249. break;
  250. } else {
  251. oldValue = oldValue[names[idx]];
  252. }
  253. }
  254. //var oldValue = this.data[name];
  255. this.changeJsonDate(names, value);
  256. this.changeData(name, input, oldValue);
  257. }
  258. },
  259. setCheckboxValue: function (name, input) {
  260. var id = this.module.json.id;
  261. var checkboxList = $$("input[name='" + id + name + "']");
  262. var values = [];
  263. checkboxList.each(function (checkbox) {
  264. if (checkbox.get("checked")) {
  265. values.push(checkbox.value);
  266. }
  267. });
  268. var oldValue = this.data[name];
  269. //this.data[name] = values;
  270. this.changeJsonDate(name, values);
  271. this.changeData(name, input, oldValue);
  272. },
  273. setSelectValue: function (name, select) {
  274. var idx = select.selectedIndex;
  275. var options = select.getElements("option");
  276. var value = "";
  277. if (options[idx]) {
  278. value = options[idx].get("value");
  279. }
  280. var i = name.indexOf("*");
  281. var names = (i == -1) ? name.split(".") : name.substr(i + 1, name.length).split(".");
  282. //var oldValue = this.data[name];
  283. var oldValue = this.data;
  284. for (var idx = 0; idx < names.length; idx++) {
  285. if (!oldValue[names[idx]]) {
  286. oldValue = null;
  287. break;
  288. } else {
  289. oldValue = oldValue[names[idx]];
  290. }
  291. }
  292. //var oldValue = this.data[name];
  293. //this.data[name] = value;
  294. this.changeJsonDate(names, value);
  295. this.changeData(name, select, oldValue);
  296. },
  297. setValue: function (name, value, obj) {
  298. var names = name.split(".");
  299. var oldValue = this.data;
  300. for (var idx = 0; idx < names.length; idx++) {
  301. if (!oldValue[names[idx]]) {
  302. oldValue = null;
  303. break;
  304. } else {
  305. oldValue = oldValue[names[idx]];
  306. }
  307. }
  308. //var oldValue = this.data[name];
  309. //this.data[name] = value;
  310. this.changeJsonDate(names, value);
  311. this.changeData(name, obj, oldValue);
  312. },
  313. setEditNodeStyles: function (node) {
  314. var nodes = node.getChildren();
  315. if (nodes.length) {
  316. nodes.each(function (el) {
  317. var cName = el.get("class");
  318. if (cName) {
  319. if (this.view.css[cName]) el.setStyles(this.view.css[cName]);
  320. }
  321. this.setEditNodeStyles(el);
  322. }.bind(this));
  323. }
  324. },
  325. loadScriptArea: function () {
  326. var scriptAreas = this.propertyContent.getElements(".MWFScriptArea");
  327. var formulaAreas = this.propertyContent.getElements(".MWFFormulaArea");
  328. this.loadScriptEditor(scriptAreas);
  329. this.loadScriptEditor(formulaAreas, "formula");
  330. },
  331. loadScriptEditor: function (scriptAreas, style) {
  332. scriptAreas.each(function (node) {
  333. var title = node.get("title");
  334. var name = node.get("name");
  335. var scriptContent = this.data[name];
  336. MWF.require("MWF.widget.ScriptArea", function () {
  337. var scriptArea = new MWF.widget.ScriptArea(node, {
  338. "title": title,
  339. //"maxObj": this.propertyNode.parentElement.parentElement.parentElement,
  340. "maxObj": this.designer.editContentNode,
  341. "onChange": function () {
  342. this.data[name] = scriptArea.toJson().code;
  343. }.bind(this),
  344. "onSave": function () {
  345. this.designer.saveView();
  346. }.bind(this),
  347. "style": style || "default",
  348. "runtime": "server"
  349. });
  350. scriptArea.load({"code": scriptContent});
  351. }.bind(this));
  352. }.bind(this));
  353. },
  354. loadStatColumnSelect: function () {
  355. },
  356. loadPersonInput: function () {
  357. var identityNodes = this.propertyContent.getElements(".MWFPersonIdentity");
  358. var personUnitNodes = this.propertyContent.getElements(".MWFPersonUnit");
  359. MWF.xDesktop.requireApp("process.ProcessDesigner", "widget.PersonSelector", function () {
  360. identityNodes.each(function (node) {
  361. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.view.designer, {
  362. "type": "identity",
  363. "names": this.data[node.get("name")],
  364. "onChange": function (ids) {
  365. this.savePersonItem(node, ids);
  366. }.bind(this)
  367. });
  368. }.bind(this));
  369. personUnitNodes.each(function (node) {
  370. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.view.designer, {
  371. "type": "unit",
  372. "names": this.data[node.get("name")],
  373. "onChange": function (ids) {
  374. this.savePersonItem(node, ids);
  375. }.bind(this)
  376. });
  377. }.bind(this));
  378. }.bind(this));
  379. },
  380. savePersonItem: function (node, ids) {
  381. var values = [];
  382. ids.each(function (id) {
  383. //values.push({"name": (id.data.distinguishedName || id.data.name), "id": id.data.id});
  384. values.push((id.data.distinguishedName || id.data.id || id.data.name));
  385. }.bind(this));
  386. var name = node.get("name");
  387. key = name.split(".");
  388. var o = this.data;
  389. var len = key.length - 1;
  390. key.each(function (n, i) {
  391. if (!o[n]) o[n] = {};
  392. if (i < len) o = o[n];
  393. }.bind(this));
  394. o[key[len]] = values;
  395. //this.data.data.restrictWhereEntry[node.get("name")] = values;
  396. },
  397. loadPersonSelectInput: function () {
  398. var applicationNodes = this.propertyContent.getElements(".MWFSelectApplication");
  399. var processNodes = this.propertyContent.getElements(".MWFSelectProcess");
  400. // var companyNodes = this.propertyContent.getElements(".MWFSelectCompany");
  401. // var departmentNodes = this.propertyContent.getElements(".MWFSelectDepartment");
  402. var personNodes = this.propertyContent.getElements(".MWFSelectPerson");
  403. var identityNodes = this.propertyContent.getElements(".MWFSelectIdentity");
  404. var personUnitNodes = this.propertyContent.getElements(".MWFSelectUnit");
  405. var cmsapplicationNodes = this.propertyContent.getElements(".MWFSelectCMSApplication");
  406. var cmscategoryNodes = this.propertyContent.getElements(".MWFSelecCMStCategory");
  407. MWF.xDesktop.requireApp("process.ProcessDesigner", "widget.PersonSelector", function () {
  408. applicationNodes.each(function (node) {
  409. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.view.designer, {
  410. "type": "application",
  411. "names": (this.data.data.where) ? this.data.data.where.applicationList : [],
  412. "onChange": function (ids) {
  413. this.savePersonSelectItem(node, ids);
  414. }.bind(this)
  415. });
  416. }.bind(this));
  417. processNodes.each(function (node) {
  418. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.view.designer, {
  419. "type": "process",
  420. "names": (this.data.data.where) ? this.data.data.where.processList : [],
  421. "onChange": function (ids) {
  422. this.savePersonSelectItem(node, ids);
  423. }.bind(this)
  424. });
  425. }.bind(this));
  426. personUnitNodes.each(function (node) {
  427. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.view.designer, {
  428. "type": "unit",
  429. "names": (this.data.data.where) ? this.data.data.where.creatorUnitList : [],
  430. "onChange": function (ids) {
  431. this.savePersonSelectItem(node, ids);
  432. }.bind(this)
  433. });
  434. }.bind(this));
  435. personNodes.each(function (node) {
  436. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.view.designer, {
  437. "type": "person",
  438. "names": (this.data.data.where) ? this.data.data.where.creatorPersonList : [],
  439. "onChange": function (ids) {
  440. this.savePersonSelectItem(node, ids);
  441. }.bind(this)
  442. });
  443. }.bind(this));
  444. identityNodes.each(function (node) {
  445. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.view.designer, {
  446. "type": "identity",
  447. "names": (this.data.data.where) ? this.data.data.where.creatorIdentityList : [],
  448. "onChange": function (ids) {
  449. this.savePersonSelectItem(node, ids);
  450. }.bind(this)
  451. });
  452. }.bind(this));
  453. cmsapplicationNodes.each(function (node) {
  454. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.view.designer, {
  455. "type": "CMSApplication",
  456. "names": (this.data.data.where) ? this.data.data.where.appInfoList : [],
  457. "onChange": function (ids) {
  458. this.savePersonSelectItem(node, ids);
  459. }.bind(this)
  460. });
  461. }.bind(this));
  462. cmscategoryNodes.each(function (node) {
  463. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.view.designer, {
  464. "type": "CMSCategory",
  465. "names": (this.data.data.where) ? this.data.data.where.categoryInfoList : [],
  466. "onChange": function (ids) {
  467. this.savePersonSelectItem(node, ids);
  468. }.bind(this)
  469. });
  470. }.bind(this));
  471. }.bind(this));
  472. },
  473. savePersonSelectItem: function (node, ids) {
  474. //this.initWhereEntryData();
  475. var values = [];
  476. ids.each(function (id) {
  477. values.push({"name": (id.data.distinguishedName || id.data.name), "id": id.data.id});
  478. //values.push((id.data.distinguishedName || id.data.id || id.data.name));
  479. }.bind(this));
  480. var name = node.get("name");
  481. key = name.split(".");
  482. var o = this.data;
  483. var len = key.length - 1;
  484. key.each(function (n, i) {
  485. if (!o[n]) o[n] = {};
  486. if (i < len) o = o[n];
  487. }.bind(this));
  488. o[key[len]] = values;
  489. //this.data.data.restrictWhereEntry[node.get("name")] = values;
  490. },
  491. //loadWorkDataEditor: function(){
  492. // var workDataNodes = this.propertyContent.getElements(".MWFWorkData");
  493. // workDataNodes.each(function(node){
  494. // var select = node.getElement("select");
  495. // for (var i=0; i<select.options.length; i++){
  496. // if (select.options[i].value==this.data.name){
  497. // select.options[i].set("selected", true);
  498. // break;
  499. // }
  500. // }
  501. // if (!this.data.type) this.data.type = "text";
  502. // select.addEvent("change", function(e){
  503. // delete this.data.path;
  504. // this.data.name = select.options[select.selectedIndex].value;
  505. // this.module.listNode.getLast().set("text", this.data.text+"("+this.data.name+")");
  506. // this.setDataType();
  507. // }.bind(this));
  508. //
  509. // this.setDataType();
  510. // }.bind(this));
  511. // var nodes = this.propertyContent.getElements(".MWFWorkDataCheck");
  512. // nodes.each(function(node){
  513. // if (this.data.name) node.set("checked", true);
  514. // }.bind(this));
  515. //},
  516. //setDataType: function(){
  517. // switch (this.data.name){
  518. // case "startTime":case "completedTime":
  519. // this.data.type ="date";
  520. // break;
  521. // case "completed":
  522. // this.data.type ="boolean";
  523. // break;
  524. // default:
  525. // this.data.type ="text";
  526. // }
  527. //},
  528. //loadDataDataEditor: function(){
  529. // var nodes = this.propertyContent.getElements(".MWFDataData");
  530. // nodes.each(function(node){
  531. // var input = node.getElement("input");
  532. // input.set("value", this.data.path);
  533. // input.addEvent("change", function(e){
  534. // delete this.data.name;
  535. // this.data.path = input.get("value");
  536. // this.module.listNode.getLast().set("text", this.data.text+"("+this.data.path+")");
  537. // }.bind(this));
  538. // input.addEvent("blur", function(e){
  539. // delete this.data.name;
  540. // this.data.path = input.get("value");
  541. // this.module.listNode.getLast().set("text", this.data.text+"("+this.data.path+")");
  542. // }.bind(this));
  543. // input.addEvent("keydown", function(e){
  544. // if (e.code==13){
  545. // delete this.data.name;
  546. // this.data.path = input.get("value");
  547. // this.module.listNode.getLast().set("text", this.data.text+"("+this.data.path+")");
  548. // }
  549. // e.stopPropagation();
  550. // }.bind(this));
  551. //
  552. // var select = node.getElement("select");
  553. // for (var i=0; i<select.options.length; i++){
  554. // if (select.options[i].value==this.data.type){
  555. // select.options[i].set("selected", true);
  556. // break;
  557. // }
  558. // }
  559. // if (!this.data.type) this.data.type = "text";
  560. // select.addEvent("change", function(e){
  561. // this.data.type = select.options[select.selectedIndex].value;
  562. // }.bind(this));
  563. //
  564. // }.bind(this));
  565. // var nodes = this.propertyContent.getElements(".MWFDataDataCheck");
  566. // nodes.each(function(node){
  567. // if (this.data.path) node.set("checked", true);
  568. // }.bind(this));
  569. //},
  570. loadColumnExportEditor: function () {
  571. var _self = this;
  572. var nodes = this.propertyContent.getElements(".MWFColumnExport");
  573. nodes.each(function (node) {
  574. //if (!this.data.export) this.data.export = {};
  575. //var sort = this.data.export.sort || "";
  576. //var sortOrder = this.data.export.sortOrder || "1";
  577. var select = node.getElement("select");
  578. var sortList = this.view.data.data.orderList;
  579. sortList.each(function (order) {
  580. if (order.column == this.data.column) {
  581. if (order.orderType == "asc") select.options[1].set("selected", true);
  582. if (order.orderType == "desc") select.options[1].set("selected", false);
  583. }
  584. }.bind(this));
  585. select.addEvent("change", function (e) {
  586. debugger;
  587. var sortList = this.view.data.data.orderList;
  588. var v = select.options[select.selectedIndex].value;
  589. if (v != "none") {
  590. var flag = false;
  591. sortList.each(function (order) {
  592. if (order.column == this.data.column) {
  593. flag = true;
  594. order.orderType = select.options[select.selectedIndex].value;
  595. }
  596. }.bind(this));
  597. if (!flag) sortList.push({
  598. "column": this.data.column,
  599. "orderType": select.options[select.selectedIndex].value
  600. });
  601. var oldOrderList = Array.clone(this.view.data.data.orderList);
  602. this.view.data.data.orderList = [];
  603. this.view.json.data.selectList.each(function (sel) {
  604. oldOrderList.each(function (order) {
  605. if (order.column == sel.column) {
  606. this.view.data.data.orderList.push(order);
  607. }
  608. }.bind(this));
  609. }.bind(this));
  610. } else {
  611. var sortList = this.view.data.data.orderList;
  612. var deleteItem = null;
  613. sortList.each(function (order) {
  614. if (order.column == this.data.column) {
  615. deleteItem = order;
  616. }
  617. }.bind(this));
  618. if (deleteItem) sortList.erase(deleteItem);
  619. }
  620. }.bind(this));
  621. var radios = node.getElements("input[name='" + this.module.json.id + "groupEntry']");
  622. var group = this.view.data.data.group;
  623. if (group.column == this.data.column) radios[0].set("checked", true);
  624. radios.addEvent("click", function (e) {
  625. if (this.checked) {
  626. if (this.value == "true") {
  627. _self.view.data.data.group.column = _self.data.column;
  628. _self.view.items.each(function (col) {
  629. if (col.property) {
  630. var groupRadios = col.property.propertyContent.getElement(".MWFColumnExportGroup").getElements("input");
  631. groupRadios.each(function (r) {
  632. if (r.value == "true") r.set("checked", false);
  633. if (r.value == "false") r.set("checked", true);
  634. });
  635. }
  636. });
  637. (_self.view.data.data.selectList).each(function (s) {
  638. if (s.column !== _self.data.column) s.groupEntry = false;
  639. });
  640. this.set("checked", true);
  641. } else {
  642. if (group.column == _self.data.column) _self.view.data.data.group = {};
  643. }
  644. }
  645. });
  646. }.bind(this));
  647. },
  648. loadViewFilter: function () {
  649. var nodes = this.propertyContent.getElements(".MWFViewFilter");
  650. var filtrData = this.view.data.data.filterList;
  651. var customData = this.view.data.data.customFilterList;
  652. nodes.each(function (node) {
  653. MWF.xDesktop.requireApp("query.ViewDesigner", "widget.ViewFilter", function () {
  654. var _slef = this;
  655. new MWF.xApplication.query.ViewDesigner.widget.ViewFilter(node, this.view.designer, {
  656. "filtrData": filtrData,
  657. "customData": customData
  658. }, {
  659. "onChange": function (ids) {
  660. var data = this.getData();
  661. _slef.changeJsonDate(["data", "filterList"], data.data);
  662. _slef.changeJsonDate(["data", "customFilterList"], data.customData);
  663. }
  664. });
  665. }.bind(this));
  666. }.bind(this));
  667. },
  668. loadColumnFilter: function () {
  669. var nodes = this.propertyContent.getElements(".MWFColumnFilter");
  670. nodes.each(function (node) {
  671. this.module.filterAreaNode = node;
  672. var table = new Element("table", {
  673. "styles": {"width": "100%"},
  674. "border": "0px",
  675. "cellPadding": "0",
  676. "cellSpacing": "0"
  677. }).inject(node);
  678. var tr = new Element("tr", {"styles": this.module.css.filterTableTitle}).inject(table);
  679. var html = "<th style='width:24px;border-right:1px solid #CCC;border-bottom:1px solid #999;'></th>" +
  680. "<th style='border-right:1px solid #CCC;border-left:1px solid #FFF;border-bottom:1px solid #999;'>逻辑</th>" +
  681. "<th style='border-right:1px solid #CCC;border-left:1px solid #FFF;border-bottom:1px solid #999;'>路径</th>" +
  682. "<th style='border-right:1px solid #CCC;border-left:1px solid #FFF;border-bottom:1px solid #999;'>比较</th>" +
  683. "<th style='border-left:1px solid #FFF;border-bottom:1px solid #999;'>值</th>";
  684. tr.set("html", html);
  685. var addActionNode = new Element("div", {"styles": this.module.css.filterAddActionNode}).inject(tr.getFirst("th"));
  686. addActionNode.addEvent("click", function () {
  687. this.addFilter(table);
  688. }.bind(this));
  689. if (this.data.filterList) {
  690. this.data.filterList.each(function (op) {
  691. new MWF.xApplication.query.ViewDesigner.Property.Filter(op, table, this);
  692. }.bind(this));
  693. }
  694. }.bind(this));
  695. },
  696. addFilter: function (table) {
  697. op = {
  698. "logic": "and",
  699. "comparison": "",
  700. "value": ""
  701. }
  702. if (!this.data.filterList) this.data.filterList = [];
  703. this.data.filterList.push(op);
  704. var filter = new MWF.xApplication.query.ViewDesigner.Property.Filter(op, table, this);
  705. filter.editMode();
  706. },
  707. loadViewStylesArea: function () {
  708. var _self = this;
  709. var viewAreas = this.propertyContent.getElements(".MWFViewStylesArea");
  710. viewAreas.each(function (node) {
  711. var name = node.get("name");
  712. var d = this.data;
  713. Array.each(name.split("."), function (n) {
  714. if (d) d = d[n];
  715. });
  716. var viewStyles = d || {};
  717. MWF.require("MWF.widget.Maplist", function () {
  718. var maps = [];
  719. Object.each(viewStyles, function (v, k) {
  720. var mapNode = new Element("div").inject(node);
  721. mapNode.empty();
  722. var maplist = new MWF.widget.Maplist(mapNode, {
  723. "title": k,
  724. "collapse": true,
  725. "onChange": function () {
  726. // var oldData = _self.data[name];
  727. var oldData = this.data;
  728. Array.each(name.split("."), function (n) {
  729. if (oldData) oldData = oldData[n];
  730. });
  731. maps.each(function (o) {
  732. d[o.key] = o.map.toJson();
  733. }.bind(this));
  734. _self.changeData(name, node, oldData);
  735. }
  736. });
  737. maps.push({"key": k, "map": maplist});
  738. maplist.load(v);
  739. }.bind(this));
  740. }.bind(this));
  741. }.bind(this));
  742. },
  743. loadMaplist: function(){
  744. var maplists = this.propertyContent.getElements(".MWFMaplist");
  745. debugger;
  746. maplists.each(function(node){
  747. var title = node.get("title");
  748. var name = node.get("name");
  749. var collapse = node.get("collapse");
  750. var mapObj = this.data[name];
  751. if (!mapObj) mapObj = {};
  752. MWF.require("MWF.widget.Maplist", function(){
  753. node.empty();
  754. var maplist = new MWF.widget.Maplist(node, {
  755. "title": title,
  756. "collapse": (collapse) ? true : false,
  757. "onChange": function(){
  758. //this.data[name] = maplist.toJson();
  759. //
  760. var oldData = this.data[name];
  761. this.changeJsonDate(name, maplist.toJson());
  762. this.changeStyle(name, oldData);
  763. this.changeData(name);
  764. }.bind(this),
  765. "onDelete": function(key){
  766. debugger;
  767. this.module.deletePropertiesOrStyles(name, key);
  768. }.bind(this)
  769. });
  770. maplist.load(mapObj);
  771. this.maplists[name] = maplist;
  772. }.bind(this));
  773. }.bind(this));
  774. },
  775. loadActionStylesArea: function () {
  776. var _self = this;
  777. var actionAreas = this.propertyContent.getElements(".MWFActionStylesArea");
  778. actionAreas.each(function (node) {
  779. var name = node.get("name");
  780. var actionStyles = this.data[name];
  781. MWF.require("MWF.widget.Maplist", function () {
  782. var maps = [];
  783. Object.each(actionStyles, function (v, k) {
  784. var mapNode = new Element("div").inject(node);
  785. mapNode.empty();
  786. var maplist = new MWF.widget.Maplist(mapNode, {
  787. "title": k,
  788. "collapse": true,
  789. "onChange": function () {
  790. var oldData = _self.data[name];
  791. maps.each(function (o) {
  792. _self.data[name][o.key] = o.map.toJson();
  793. }.bind(this));
  794. _self.changeData(name, node, oldData);
  795. }
  796. });
  797. maps.push({"key": k, "map": maplist});
  798. maplist.load(v);
  799. }.bind(this));
  800. }.bind(this));
  801. }.bind(this));
  802. },
  803. loadPagingStylesArea: function () {
  804. var _self = this;
  805. var pagingAreas = this.propertyContent.getElements(".MWFPagingStylesArea");
  806. pagingAreas.each(function (node) {
  807. var name = node.get("name");
  808. var pagingStyles = this.data[name];
  809. MWF.require("MWF.widget.Maplist", function () {
  810. var maps = [];
  811. Object.each(pagingStyles, function (v, k) {
  812. var mapNode = new Element("div").inject(node);
  813. mapNode.empty();
  814. var maplist = new MWF.widget.Maplist(mapNode, {
  815. "title": k,
  816. "collapse": true,
  817. "onChange": function () {
  818. var oldData = _self.data[name];
  819. maps.each(function (o) {
  820. _self.data[name][o.key] = o.map.toJson();
  821. }.bind(this));
  822. _self.changeData(name, node, oldData);
  823. }
  824. });
  825. maps.push({"key": k, "map": maplist});
  826. maplist.load(v);
  827. }.bind(this));
  828. }.bind(this));
  829. }.bind(this));
  830. },
  831. loadEventsEditor: function () {
  832. MWF.xApplication.process = MWF.xApplication.process || {};
  833. MWF.APPFD = MWF.xApplication.process.FormDesigner = MWF.xApplication.process.FormDesigner || {};
  834. MWF.xDesktop.requireApp("process.FormDesigner", "lp." + o2.language, null, false);
  835. var events = this.propertyContent.getElement(".MWFEventsArea");
  836. if (events) {
  837. var name = events.get("name");
  838. var eventsObj = this.data;
  839. Array.each(name.split("."), function (n) {
  840. if (eventsObj) eventsObj = eventsObj[n];
  841. })
  842. MWF.xDesktop.requireApp("process.FormDesigner", "widget.EventsEditor", function () {
  843. var eventsEditor = new MWF.xApplication.process.FormDesigner.widget.EventsEditor(events, this.designer, {
  844. //"maxObj": this.propertyNode.parentElement.parentElement.parentElement,
  845. "maxObj": this.designer.contentNode
  846. });
  847. eventsEditor.load(eventsObj, this.data, name);
  848. }.bind(this));
  849. }
  850. },
  851. loadActionArea: function () {
  852. MWF.xApplication.process = MWF.xApplication.process || {};
  853. MWF.APPFD = MWF.xApplication.process.FormDesigner = MWF.xApplication.process.FormDesigner || {};
  854. MWF.xDesktop.requireApp("process.FormDesigner", "lp." + o2.language, null, false);
  855. var actionAreas = this.propertyContent.getElements(".MWFActionArea");
  856. actionAreas.each(function (node) {
  857. var name = node.get("name");
  858. var actionContent = this.data[name];
  859. MWF.xDesktop.requireApp("process.FormDesigner", "widget.ActionsEditor", function () {
  860. // debugger;
  861. // var actionEditor = new MWF.xApplication.process.FormDesigner.widget.ActionsEditor(node, this.designer, {
  862. // "maxObj": this.propertyNode.parentElement.parentElement.parentElement,
  863. // "noCreate": true,
  864. // "noDelete": true,
  865. // "noCode": true,
  866. // "onChange": function(){
  867. // this.data[name] = actionEditor.data;
  868. // }.bind(this)
  869. // });
  870. // actionEditor.load(this.module.defaultToolBarsData);
  871. var actionEditor = new MWF.xApplication.process.FormDesigner.widget.ActionsEditor(node, this.designer, this.data, {
  872. "maxObj": this.propertyNode.parentElement.parentElement.parentElement,
  873. "noEditShow": true,
  874. "noReadShow": true,
  875. "onChange": function () {
  876. this.data[name] = actionEditor.data;
  877. this.changeData(name);
  878. }.bind(this)
  879. });
  880. actionEditor.load(actionContent);
  881. }.bind(this));
  882. }.bind(this));
  883. var actionAreas = this.propertyContent.getElements(".MWFDefaultActionArea");
  884. actionAreas.each(function (node) {
  885. var name = node.get("name");
  886. var actionContent = this.data[name] || this.module.defaultToolBarsData;
  887. MWF.xDesktop.requireApp("process.FormDesigner", "widget.ActionsEditor", function () {
  888. var actionEditor = new MWF.xApplication.process.FormDesigner.widget.ActionsEditor(node, this.designer, this.data, {
  889. "maxObj": this.propertyNode.parentElement.parentElement.parentElement,
  890. "isSystemTool": true,
  891. "systemToolsAddress": "../x_component_query_ViewDesigner/$View/toolbars.json",
  892. "noCreate": true,
  893. "noDelete": false,
  894. "noCode": true,
  895. "noReadShow": true,
  896. "noEditShow": true,
  897. "onChange": function () {
  898. this.data[name] = actionEditor.data;
  899. this.changeData(name);
  900. }.bind(this)
  901. });
  902. actionEditor.load(actionContent);
  903. // var actionEditor = new MWF.xApplication.process.FormDesigner.widget.ActionsEditor(node, this.designer, {
  904. // "maxObj": this.propertyNode.parentElement.parentElement.parentElement,
  905. // "onChange": function(){
  906. // this.data[name] = actionEditor.data;
  907. // }.bind(this)
  908. // });
  909. // actionEditor.load(actionContent);
  910. }.bind(this));
  911. }.bind(this));
  912. },
  913. loadStylesList: function () {
  914. var styleSelNodes = this.propertyContent.getElements(".MWFViewStyle");
  915. styleSelNodes.each(function (node) {
  916. debugger;
  917. if (this.module.stylesList) {
  918. if (!this.data.data.viewStyleType) this.data.data.viewStyleType = "default";
  919. // var mode = ( this.form.options.mode || "" ).toLowerCase() === "mobile" ? "mobile" : "pc";
  920. Object.each(this.module.stylesList, function (s, key) {
  921. // if( s.mode.contains( mode ) ){
  922. new Element("option", {
  923. "text": s.name,
  924. "value": key,
  925. "selected": ((!this.data.data.viewStyleType && key == "default") || (this.data.data.viewStyleType == key))
  926. }).inject(node)
  927. // }
  928. }.bind(this));
  929. } else {
  930. node.getParent("tr").setStyle("display", "none");
  931. }
  932. }.bind(this));
  933. }
  934. //initWhereEntryData: function(){
  935. // if (!this.data.data.restrictWhereEntry) this.data.data.restrictWhereEntry = {
  936. // "applicationList": [],
  937. // "processList": [],
  938. // "companyList": [],
  939. // "departmentList": [],
  940. // "personList": [],
  941. // "identityList": []
  942. // };
  943. //},
  944. //loadApplicationSelector: function(){
  945. // var nodes = this.propertyContent.getElements(".MWFApplicationSelect");
  946. // if (nodes.length){
  947. // MWF.xDesktop.requireApp("Organization", "Selector.package", function(){
  948. // nodes.each(function(node){
  949. // var title = new Element("div", {"styles": this.view.css.applicationSelectTitle, "text": node.get("title")}).inject(node);
  950. // var content = new Element("div", {"styles": this.view.css.applicationSelectContent}).inject(node);
  951. // var action = new Element("div", {"styles": this.view.css.applicationSelectAction, "text": node.get("title")}).inject(node);
  952. // action.addEvent("click", function(e){
  953. // var values = [];
  954. // if (this.data.data.whereEntry){
  955. // if (this.data.data.whereEntry.applicationList.length){
  956. // this.data.data.whereEntry.applicationList.each(function(item){
  957. // values.push(item.id);
  958. // }.bind(this));
  959. // }
  960. // }
  961. // var options = {
  962. // "type": "application",
  963. // "count": 0,
  964. // "values": values,
  965. // //"title": this.app.lp.monthly.selectSortApplication,
  966. // "onComplete": function(items){
  967. // this.initWhereEntryData();
  968. // this.data.data.whereEntry.applicationList = [];
  969. // content.empty();
  970. // items.each(function(item){
  971. // this.data.data.whereEntry.applicationList.push({
  972. // "id": item.data.id,
  973. // "name": item.data.name
  974. // });
  975. // new Element("div", {
  976. // "styles": this.view.css.applicationSelectItem,
  977. // "text": item.data.name
  978. // }).inject(content);
  979. // }.bind(this));
  980. // }.bind(this)
  981. // };
  982. // var selector = new MWF.OrgSelector(this.view.designer.content, options);
  983. // }.bind(this));
  984. //
  985. // this.initWhereEntryData();
  986. // this.data.data.whereEntry.applicationList.each(function(app){
  987. // new Element("div", {
  988. // "styles": this.view.css.applicationSelectItem,
  989. // "text": app.name
  990. // }).inject(content);
  991. // }.bind(this));
  992. // }.bind(this));
  993. // }.bind(this));
  994. // }
  995. //},
  996. //loadApplicationSelector1: function(){
  997. // var nodes = this.propertyContent.getElements(".MWFApplicationSelect");
  998. // if (nodes.length){
  999. // this._getAppSelector(function(){
  1000. // nodes.each(function(node){
  1001. // var title = new Element("div", {"styles": this.view.css.applicationSelectTitle, "text": node.get("title")}).inject(node);
  1002. // var content = new Element("div", {"styles": this.view.css.applicationSelectContent}).inject(node);
  1003. // var action = new Element("div", {"styles": this.view.css.applicationSelectAction, "text": node.get("title")}).inject(node);
  1004. // action.addEvent("click", function(e){
  1005. // this.appSelector.load(function(apps){
  1006. // if (!this.data.data.select) this.data.data.select = {"applicationRestrictList": [], "processRestrictList": []};
  1007. // this.data.data.select.applicationRestrictList = [];
  1008. // content.empty();
  1009. // if (apps.length){
  1010. // apps.each(function(app){
  1011. // var o = {
  1012. // "name": app.name,
  1013. // "id": app.id,
  1014. // "alias": app.alias
  1015. // }
  1016. // this.data.data.select.applicationRestrictList.push(o);
  1017. //
  1018. // new Element("div", {
  1019. // "styles": this.view.css.applicationSelectItem,
  1020. // "text": app.name
  1021. // }).inject(content);
  1022. //
  1023. // }.bind(this));
  1024. // }
  1025. // }.bind(this));
  1026. // }.bind(this));
  1027. // if (!this.data.data.select) this.data.data.select = {"applicationRestrictList": [], "processRestrictList": []};
  1028. // this.data.data.select.applicationRestrictList.each(function(app){
  1029. // new Element("div", {
  1030. // "styles": this.view.css.applicationSelectItem,
  1031. // "text": app.name
  1032. // }).inject(content);
  1033. // }.bind(this));
  1034. //
  1035. // }.bind(this));
  1036. // }.bind(this));
  1037. // }
  1038. //},
  1039. //
  1040. //_getAppSelector: function(callback){
  1041. // if (!this.appSelector){
  1042. // MWF.xDesktop.requireApp("process.ProcessManager", "widget.ApplicationSelector", function(){
  1043. // this.appSelector = new MWF.xApplication.process.ProcessManager.widget.ApplicationSelector(this.view.designer, {"maskNode": this.view.designer.content});
  1044. // if (callback) callback();
  1045. // }.bind(this));
  1046. // }else{
  1047. // if (callback) callback();
  1048. // }
  1049. //},
  1050. //this.initWhereEntryData();
  1051. //loadProcessSelector: function(){
  1052. // var nodes = this.propertyContent.getElements(".MWFApplicationSelect");
  1053. // if (nodes.length){
  1054. // MWF.xDesktop.requireApp("Organization", "Selector.package", function(){
  1055. // nodes.each(function(node){
  1056. // var title = new Element("div", {"styles": this.view.css.applicationSelectTitle, "text": node.get("title")}).inject(node);
  1057. // var content = new Element("div", {"styles": this.view.css.applicationSelectContent}).inject(node);
  1058. // var action = new Element("div", {"styles": this.view.css.applicationSelectAction, "text": node.get("title")}).inject(node);
  1059. // action.addEvent("click", function(e){
  1060. // var values = [];
  1061. // if (this.data.data.whereEntry){
  1062. // if (this.data.data.whereEntry.processList.length){
  1063. // this.data.data.whereEntry.processList.each(function(item){
  1064. // values.push(item.id);
  1065. // }.bind(this));
  1066. // }
  1067. // }
  1068. // var options = {
  1069. // "type": "process",
  1070. // "count": 0,
  1071. // "values": values,
  1072. // "onComplete": function(items){
  1073. // this.initWhereEntryData();
  1074. // this.data.data.whereEntry.processList = [];
  1075. // content.empty();
  1076. // items.each(function(item){
  1077. // this.data.data.whereEntry.processList.push({
  1078. // "id": item.data.id,
  1079. // "name": item.data.name
  1080. // });
  1081. // new Element("div", {
  1082. // "styles": this.view.css.applicationSelectItem,
  1083. // "text": item.data.name
  1084. // }).inject(content);
  1085. // }.bind(this));
  1086. // }.bind(this)
  1087. // };
  1088. // var selector = new MWF.OrgSelector(this.view.designer.content, options);
  1089. // }.bind(this));
  1090. //
  1091. // this.initWhereEntryData();
  1092. // this.data.data.whereEntry.processList.each(function(app){
  1093. // new Element("div", {
  1094. // "styles": this.view.css.applicationSelectItem,
  1095. // "text": app.name
  1096. // }).inject(content);
  1097. // }.bind(this));
  1098. // }.bind(this));
  1099. // }.bind(this));
  1100. // }
  1101. //}
  1102. //loadProcessSelector1: function(){
  1103. // var nodes = this.propertyContent.getElements(".MWFProcessSelect");
  1104. // if (nodes.length){
  1105. // this._getProcessSelector(function(){
  1106. // nodes.each(function(node){
  1107. // var title = new Element("div", {"styles": this.view.css.applicationSelectTitle, "text": node.get("title")}).inject(node);
  1108. // var content = new Element("div", {"styles": this.view.css.applicationSelectContent}).inject(node);
  1109. // var action = new Element("div", {"styles": this.view.css.applicationSelectAction, "text": node.get("title")}).inject(node);
  1110. // action.addEvent("click", function(e){
  1111. // var ids=[];
  1112. // this.data.data.select.applicationRestrictList.each(function(app){
  1113. // ids.push(app.id);
  1114. // });
  1115. // this.processSelector.load(ids, function(apps){
  1116. // if (!this.data.data.select) this.data.data.select = {"applicationRestrictList": [], "processRestrictList": []};
  1117. // this.data.data.select.processRestrictList = [];
  1118. // content.empty();
  1119. // if (apps.length){
  1120. // apps.each(function(app){
  1121. // var o = {
  1122. // "name": app.name,
  1123. // "id": app.id,
  1124. // "alias": app.alias
  1125. // }
  1126. // this.data.data.select.processRestrictList.push(o);
  1127. //
  1128. // new Element("div", {
  1129. // "styles": this.view.css.applicationSelectItem,
  1130. // "text": app.name
  1131. // }).inject(content);
  1132. //
  1133. // }.bind(this));
  1134. // }
  1135. // }.bind(this));
  1136. // }.bind(this));
  1137. // if (!this.data.data.select) this.data.data.select = {"applicationRestrictList": [], "processRestrictList": []};
  1138. // this.data.data.select.processRestrictList.each(function(app){
  1139. // new Element("div", {
  1140. // "styles": this.view.css.applicationSelectItem,
  1141. // "text": app.name
  1142. // }).inject(content);
  1143. // }.bind(this));
  1144. //
  1145. // }.bind(this));
  1146. // }.bind(this));
  1147. // }
  1148. //},
  1149. //_getProcessSelector: function(callback){
  1150. // if (!this.processSelector){
  1151. // MWF.xDesktop.requireApp("process.ProcessManager", "widget.ProcessSelector", function(){
  1152. // this.processSelector = new MWF.xApplication.process.ProcessManager.widget.ProcessSelector(this.view.designer, {"maskNode": this.view.designer.content});
  1153. // if (callback) callback();
  1154. // }.bind(this));
  1155. // }else{
  1156. // if (callback) callback();
  1157. // }
  1158. //}
  1159. });
  1160. MWF.xApplication.query.ViewDesigner.Property.Filter = new Class({
  1161. Implements: [Events],
  1162. initialize: function (json, table, property) {
  1163. this.property = property;
  1164. this.module = property.module;
  1165. this.table = table;
  1166. this.data = json;
  1167. this.load();
  1168. },
  1169. load: function () {
  1170. this.node = new Element("tr", {"styles": this.module.css.filterTableTd}).inject(this.table);
  1171. var html = "<td style='widtd:24px;border-right:1px solid #CCC;border-bottom:1px solid #999;'></td>" +
  1172. "<td style='padding:3px;border-right:1px solid #CCC;border-bottom:1px solid #999; width:60px'>" + this.data.logic + "</td>" +
  1173. "<td style='padding:3px;border-right:1px solid #CCC;border-bottom:1px solid #999; width:30px'>列值</td>" +
  1174. "<td style='padding:3px;border-right:1px solid #CCC;border-bottom:1px solid #999;'>" + this.data.comparison + "</td>" +
  1175. "<td style='padding:3px;border-bottom:1px solid #999;'>" + this.data.value + "</td>";
  1176. this.node.set("html", html);
  1177. var tds = this.node.getElements("td");
  1178. this.delActionNode = new Element("div", {"styles": this.module.css.filterDelActionNode}).inject(tds[0]);
  1179. this.delActionNode.addEvent("click", function (e) {
  1180. this.delFilter(e);
  1181. e.stopPropagation();
  1182. }.bind(this));
  1183. this.logicNode = tds[1];
  1184. this.comparisonNode = tds[3];
  1185. this.valueNode = tds[4];
  1186. this.node.addEvent("click", function () {
  1187. if (!this.isEditMode) this.editMode();
  1188. }.bind(this));
  1189. this.node.addEvent("blur", function () {
  1190. if (this.isEditMode) this.readMode();
  1191. }.bind(this));
  1192. },
  1193. delFilter: function (e) {
  1194. var _self = this;
  1195. this.property.designer.confirm("warn", e, MWF.APPDVD.LP.notice.deleteFilterTitle, MWF.APPDVD.LP.notice.deleteFilter, 300, 120, function () {
  1196. _self.node.destroy();
  1197. _self.property.data.filterList.erase(_self.data);
  1198. MWF.release(_self);
  1199. this.close();
  1200. }, function () {
  1201. this.close();
  1202. }, null);
  1203. },
  1204. editMode: function () {
  1205. if (this.property.editModeFilter) {
  1206. if (this.property.editModeFilter != this) this.property.editModeFilter.readMode();
  1207. }
  1208. var width = this.logicNode.getSize().x - 9;
  1209. this.logicNode.empty();
  1210. var logicSelect = new Element("select", {"styles": {"width": "90%"}}).inject(this.logicNode);
  1211. var html = "";
  1212. if (this.data.logic == "and") {
  1213. html = "<option value=\"and\" selected>and</option><option value=\"or\">or</option>";
  1214. } else {
  1215. html = "<option value=\"and\">and</option><option value=\"or\" selected>or</option>";
  1216. }
  1217. logicSelect.set("html", html);
  1218. logicSelect.addEvent("change", function () {
  1219. this.data.logic = logicSelect.options[logicSelect.selectedIndex].value;
  1220. }.bind(this));
  1221. width = this.comparisonNode.getSize().x - 9;
  1222. this.comparisonNode.empty();
  1223. var comparisonSelect = new Element("select", {"styles": {"width": "90%"}}).inject(this.comparisonNode);
  1224. html = "";
  1225. switch (this.property.data.type) {
  1226. case "text":
  1227. html += "<option value=''></option><option value='==' " + ((this.data.comparison == "==") ? "selected" : "") + ">等于(==)</option>" +
  1228. "<option value='!=' " + ((this.data.comparison == "!=") ? "selected" : "") + ">不等于(!=)</option>" +
  1229. "<option value='@' " + ((this.data.comparison == "@") ? "selected" : "") + ">包含(@)</option>";
  1230. break;
  1231. case "date":
  1232. html += "<option value=''></option><option value='&gt;' " + ((this.data.comparison == ">") ? "selected" : "") + ">大于(&gt;)</option>" +
  1233. "<option value='&lt;' " + ((this.data.comparison == "<") ? "selected" : "") + ">小于(&lt;)</option>" +
  1234. "<option value='&gt;=' " + ((this.data.comparison == ">=") ? "selected" : "") + ">大于等于(&gt;=)</option>" +
  1235. "<option value='&lt;=' " + ((this.data.comparison == "<=") ? "selected" : "") + ">小于等于(&lt;=)</option>";
  1236. break;
  1237. case "number":
  1238. html += "<option value=''></option><option value='==' " + ((this.data.comparison == "==") ? "selected" : "") + ">等于(==)</option>" +
  1239. "<option value='!=' " + ((this.data.comparison == "!=") ? "selected" : "") + ">不等于(!=)</option>" +
  1240. "<option value='&gt;' " + ((this.data.comparison == ">") ? "selected" : "") + ">大于(&gt;)</option>" +
  1241. "<option value='&lt;' " + ((this.data.comparison == "<") ? "selected" : "") + ">小于(&lt;)</option>" +
  1242. "<option value='&gt;=' " + ((this.data.comparison == ">=") ? "selected" : "") + ">大于等于(&gt;=)</option>" +
  1243. "<option value='&lt;=' " + ((this.data.comparison == "<=") ? "selected" : "") + ">小于等于(&lt;=)</option>";
  1244. break;
  1245. case "boolean":
  1246. html += "<option value=''></option><option value='==' " + ((this.data.comparison == "==") ? "selected" : "") + ">等于(==)</option>" +
  1247. "<option value='!=' " + ((this.data.comparison == "!=") ? "selected" : "") + ">不等于(!=)</option>";
  1248. break;
  1249. }
  1250. comparisonSelect.set("html", html);
  1251. comparisonSelect.addEvent("change", function () {
  1252. this.data.comparison = comparisonSelect.options[comparisonSelect.selectedIndex].value;
  1253. }.bind(this));
  1254. width = this.valueNode.getSize().x - 9;
  1255. this.valueNode.empty();
  1256. var type = "text";
  1257. switch (this.property.data.type) {
  1258. case "date":
  1259. var valueInput = new Element("input", {
  1260. "styles": {"width": "90%"},
  1261. "type": "text",
  1262. "value": this.data.value
  1263. }).inject(this.valueNode);
  1264. MWF.require("MWF.widget.Calendar", function () {
  1265. this.calendar = new MWF.widget.Calendar(valueInput, {
  1266. "style": "xform",
  1267. "isTime": true,
  1268. "secondEnable": true,
  1269. "target": this.property.designer.content,
  1270. "format": "%Y-%m-%d %H:%M:%S"
  1271. });
  1272. //this.calendar.show();
  1273. }.bind(this));
  1274. break;
  1275. case "number":
  1276. var valueInput = new Element("input", {
  1277. "styles": {"width": "90%"},
  1278. "type": "number",
  1279. "value": this.data.value
  1280. }).inject(this.valueNode);
  1281. break;
  1282. case "boolean":
  1283. var valueInput = new Element("select", {
  1284. "styles": {"width": "" + width + "px"},
  1285. "html": "<option value=\"\"></option><option value=\"true\" " + ((this.data.value) ? "selected" : "") + ">true</option><option value=\"false\" " + ((!this.data.value) ? "selected" : "") + ">false</option>"
  1286. }).inject(this.valueNode);
  1287. break;
  1288. default:
  1289. var valueInput = new Element("input", {
  1290. "styles": {"width": "90%"},
  1291. "type": "text",
  1292. "value": this.data.value
  1293. }).inject(this.valueNode);
  1294. }
  1295. if (valueInput.tagName.toLowerCase() == "select") {
  1296. valueInput.addEvent("change", function () {
  1297. var v = valueInput.options[valueInput.selectedIndex].value;
  1298. this.data.value = (v = "true") ? true : false;
  1299. }.bind(this));
  1300. } else {
  1301. valueInput.addEvent("change", function (e) {
  1302. this.data.value = valueInput.get("value");
  1303. }.bind(this));
  1304. valueInput.addEvent("blur", function (e) {
  1305. this.data.value = valueInput.get("value");
  1306. }.bind(this));
  1307. valueInput.addEvent("keydown", function (e) {
  1308. if (e.code == 13) {
  1309. this.data.value = valueInput.get("value");
  1310. this.readMode();
  1311. }
  1312. e.stopPropagation();
  1313. }.bind(this));
  1314. }
  1315. this.isEditMode = true;
  1316. this.property.editModeFilter = this;
  1317. },
  1318. readMode: function () {
  1319. if (this.isEditMode) {
  1320. var logicSelect = this.logicNode.getElement("select");
  1321. this.data.logic = logicSelect.options[logicSelect.selectedIndex].value;
  1322. var comparisonSelect = this.comparisonNode.getElement("select");
  1323. this.data.comparison = comparisonSelect.options[comparisonSelect.selectedIndex].value;
  1324. var valueInput = this.valueNode.getFirst();
  1325. if (valueInput.tagName.toLowerCase() == "select") {
  1326. var v = valueInput.options[valueInput.selectedIndex].value;
  1327. this.data.value = (v = "true") ? true : false;
  1328. } else {
  1329. this.data.value = valueInput.get("value");
  1330. }
  1331. this.logicNode.empty();
  1332. this.comparisonNode.empty();
  1333. this.valueNode.empty();
  1334. this.logicNode.set("text", this.data.logic);
  1335. this.comparisonNode.set("text", this.data.comparison);
  1336. this.valueNode.set("text", this.data.value);
  1337. this.isEditMode = false;
  1338. this.property.editModeFilter = null;
  1339. }
  1340. }
  1341. });