Property.js 50 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115
  1. MWF.require("MWF.widget.Common", null, false);
  2. MWF.require("MWF.widget.JsonTemplate", null, false);
  3. MWF.xApplication.process.ViewDesigner.Property = MWF.FVProperty = new Class({
  4. Extends: MWF.widget.Common,
  5. Implements: [Options, Events],
  6. options: {
  7. "style": "default",
  8. "path": "../x_component_process_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.pid = this.view.json.id + this.data.id;
  16. this.htmlPath = this.options.path;
  17. this.designer = designer;
  18. this.propertyNode = propertyNode;
  19. },
  20. load: function () {
  21. if (this.fireEvent("queryLoad")) {
  22. MWF.getRequestText(this.htmlPath, function (responseText, responseXML) {
  23. this.htmlString = responseText;
  24. this.fireEvent("postLoad");
  25. }.bind(this));
  26. }
  27. this.propertyNode.addEvent("keydown", function (e) {
  28. e.stopPropagation();
  29. });
  30. },
  31. editProperty: function (td) {
  32. },
  33. getHtmlString: function (callback) {
  34. if (!this.htmlString) {
  35. MWF.getRequestText(this.htmlPath, function (responseText, responseXML) {
  36. this.htmlString = responseText;
  37. if (callback) callback();
  38. }.bind(this));
  39. } else {
  40. if (callback) callback();
  41. }
  42. },
  43. show: function () {
  44. if (!this.propertyContent) {
  45. this.getHtmlString(function () {
  46. if (this.htmlString) {
  47. this.JsonTemplate = new MWF.widget.JsonTemplate(this.data, this.htmlString);
  48. this.propertyContent = new Element("div", {"styles": {"overflow": "hidden"}}).inject(this.propertyNode);
  49. this.propertyContent.set("html", this.JsonTemplate.load());
  50. this.setEditNodeEvent();
  51. this.setEditNodeStyles(this.propertyContent);
  52. this.loadPropertyTab();
  53. this.loadPersonInput();
  54. this.loadPersonSelectInput();
  55. this.loadViewFilter();
  56. this.loadScriptArea();
  57. this.loadColumnExportEditor();
  58. this.loadJSONArea();
  59. }
  60. }.bind(this));
  61. } else {
  62. this.propertyContent.setStyle("display", "block");
  63. }
  64. },
  65. hide: function () {
  66. //this.JsonTemplate = null;
  67. //this.propertyNode.set("html", "");
  68. if (this.propertyContent) this.propertyContent.setStyle("display", "none");
  69. },
  70. loadJSONArea: function () {
  71. var jsonNode = this.propertyContent.getElement(".MWFJSONArea");
  72. if (jsonNode) {
  73. this.propertyTab.pages.each(function (page) {
  74. if (page.contentNode == jsonNode.parentElement) {
  75. page.setOptions({
  76. "onShow": function () {
  77. jsonNode.empty();
  78. MWF.require("MWF.widget.JsonParse", function () {
  79. this.json = new MWF.widget.JsonParse(this.module.json, jsonNode, null);
  80. this.json.load();
  81. }.bind(this));
  82. }.bind(this)
  83. });
  84. }
  85. }.bind(this));
  86. }
  87. },
  88. loadPropertyTab: function () {
  89. var tabNodes = this.propertyContent.getElements(".MWFTab");
  90. if (tabNodes.length) {
  91. var tmpNode = this.propertyContent.getFirst();
  92. var tabAreaNode = new Element("div", {
  93. "styles": this.view.css.propertyTabNode
  94. }).inject(tmpNode, "before");
  95. MWF.require("MWF.widget.Tab", function () {
  96. var tab = new MWF.widget.Tab(tabAreaNode, {"style": "formPropertyList"});
  97. tab.load();
  98. var tabPages = [];
  99. tabNodes.each(function (node) {
  100. var page = tab.addTab(node, node.get("title"), false);
  101. tabPages.push(page);
  102. this.setScrollBar(page.contentNodeArea, "small", null, null);
  103. }.bind(this));
  104. tabPages[0].showTab();
  105. this.propertyTab = tab;
  106. this.designer.resizeNode();
  107. }.bind(this), false);
  108. }
  109. },
  110. setEditNodeEvent: function () {
  111. var property = this;
  112. // var inputs = this.process.propertyListNode.getElements(".editTableInput");
  113. var inputs = this.propertyContent.getElements("input");
  114. inputs.each(function (input) {
  115. var jsondata = input.get("name");
  116. if (jsondata && jsondata.substr(0, 1) != "_") {
  117. if (this.module) {
  118. var id = this.module.json.id;
  119. input.set("name", id + jsondata);
  120. }
  121. if (jsondata) {
  122. var inputType = input.get("type").toLowerCase();
  123. switch (inputType) {
  124. case "radio":
  125. input.addEvent("change", function (e) {
  126. property.setRadioValue(jsondata, this);
  127. });
  128. input.addEvent("blur", function (e) {
  129. property.setRadioValue(jsondata, this);
  130. });
  131. input.addEvent("keydown", function (e) {
  132. e.stopPropagation();
  133. });
  134. property.setRadioValue(jsondata, input);
  135. break;
  136. case "checkbox":
  137. input.addEvent("change", function (e) {
  138. property.setCheckboxValue(jsondata, this);
  139. });
  140. input.addEvent("click", function (e) {
  141. property.setCheckboxValue(jsondata, this);
  142. });
  143. input.addEvent("keydown", function (e) {
  144. e.stopPropagation();
  145. });
  146. break;
  147. default:
  148. input.addEvent("change", function (e) {
  149. property.setValue(jsondata, this.value, this);
  150. });
  151. input.addEvent("blur", function (e) {
  152. property.setValue(jsondata, this.value, this);
  153. });
  154. input.addEvent("keydown", function (e) {
  155. if (e.code == 13) {
  156. property.setValue(jsondata, this.value, this);
  157. }
  158. e.stopPropagation();
  159. });
  160. if (input.hasClass("editTableInputDate")) {
  161. this.loadCalendar(input);
  162. }
  163. }
  164. }
  165. }
  166. }.bind(this));
  167. var selects = this.propertyContent.getElements("select");
  168. selects.each(function (select) {
  169. var jsondata = select.get("name");
  170. if (jsondata) {
  171. select.addEvent("change", function (e) {
  172. property.setSelectValue(jsondata, this);
  173. });
  174. //property.setSelectValue(jsondata, select);
  175. }
  176. });
  177. var textareas = this.propertyContent.getElements("textarea");
  178. textareas.each(function (input) {
  179. var jsondata = input.get("name");
  180. if (jsondata) {
  181. input.addEvent("change", function (e) {
  182. property.setValue(jsondata, this.value);
  183. });
  184. input.addEvent("blur", function (e) {
  185. property.setValue(jsondata, this.value);
  186. });
  187. input.addEvent("keydown", function (e) {
  188. e.stopPropagation();
  189. });
  190. }
  191. }.bind(this));
  192. },
  193. loadCalendar: function (node) {
  194. MWF.require("MWF.widget.Calendar", function () {
  195. this.calendar = new MWF.widget.Calendar(node, {
  196. "style": "xform",
  197. "isTime": false,
  198. "target": this.module.designer.content,
  199. "format": "%Y-%m-%d",
  200. "onComplate": function () {
  201. //this.validationMode();
  202. //this.validation();
  203. //this.fireEvent("complete");
  204. }.bind(this)
  205. });
  206. //this.calendar.show();
  207. }.bind(this));
  208. },
  209. changeStyle: function (name) {
  210. this.module.setPropertiesOrStyles(name);
  211. },
  212. changeData: function (name, input, oldValue) {
  213. this.module._setEditStyle(name, input, oldValue);
  214. },
  215. changeJsonDate: function (key, value) {
  216. if (typeOf(key) != "array") key = [key];
  217. var o = this.data;
  218. var len = key.length - 1;
  219. key.each(function (n, i) {
  220. if (!o[n]) o[n] = {};
  221. if (i < len) o = o[n];
  222. }.bind(this));
  223. o[key[len]] = value;
  224. },
  225. setRadioValue: function (name, input) {
  226. if (input.checked) {
  227. var i = name.indexOf("*");
  228. var names = (i == -1) ? name.split(".") : name.substr(i + 1, name.length).split(".");
  229. var value = input.value;
  230. if (value == "false") value = false;
  231. if (value == "true") value = true;
  232. var oldValue = this.data;
  233. for (var idx = 0; idx < names.length; idx++) {
  234. if (!oldValue[names[idx]]) {
  235. oldValue = null;
  236. break;
  237. } else {
  238. oldValue = oldValue[names[idx]];
  239. }
  240. }
  241. //var oldValue = this.data[name];
  242. this.changeJsonDate(names, value);
  243. this.changeData(name, input, oldValue);
  244. }
  245. },
  246. setCheckboxValue: function (name, input) {
  247. var id = this.module.json.id;
  248. var checkboxList = $$("input[name='" + id + name + "']");
  249. var values = [];
  250. checkboxList.each(function (checkbox) {
  251. if (checkbox.get("checked")) {
  252. values.push(checkbox.value);
  253. }
  254. });
  255. var oldValue = this.data[name];
  256. //this.data[name] = values;
  257. this.changeJsonDate(name, values);
  258. this.changeData(name, input, oldValue);
  259. },
  260. setSelectValue: function (name, select) {
  261. var idx = select.selectedIndex;
  262. var options = select.getElements("option");
  263. var value = "";
  264. if (options[idx]) {
  265. value = options[idx].get("value");
  266. }
  267. var oldValue = this.data[name];
  268. //this.data[name] = value;
  269. this.changeJsonDate(name, value);
  270. this.changeData(name, select, oldValue);
  271. },
  272. setValue: function (name, value, obj) {
  273. var names = name.split(".");
  274. var oldValue = this.data;
  275. for (var idx = 0; idx < names.length; idx++) {
  276. if (!oldValue[names[idx]]) {
  277. oldValue = null;
  278. break;
  279. } else {
  280. oldValue = oldValue[names[idx]];
  281. }
  282. }
  283. //var oldValue = this.data[name];
  284. //this.data[name] = value;
  285. this.changeJsonDate(names, value);
  286. this.changeData(name, obj, oldValue);
  287. },
  288. setEditNodeStyles: function (node) {
  289. var nodes = node.getChildren();
  290. if (nodes.length) {
  291. nodes.each(function (el) {
  292. var cName = el.get("class");
  293. if (cName) {
  294. if (this.view.css[cName]) el.setStyles(this.view.css[cName]);
  295. }
  296. this.setEditNodeStyles(el);
  297. }.bind(this));
  298. }
  299. },
  300. loadScriptArea: function () {
  301. var scriptAreas = this.propertyContent.getElements(".MWFScriptArea");
  302. var formulaAreas = this.propertyContent.getElements(".MWFFormulaArea");
  303. this.loadScriptEditor(scriptAreas);
  304. this.loadScriptEditor(formulaAreas, "formula");
  305. },
  306. loadScriptEditor: function (scriptAreas, style) {
  307. scriptAreas.each(function (node) {
  308. var title = node.get("title");
  309. var name = node.get("name");
  310. var scriptContent = this.data[name];
  311. MWF.require("MWF.widget.ScriptArea", function () {
  312. var scriptArea = new MWF.widget.ScriptArea(node, {
  313. "title": title,
  314. //"maxObj": this.propertyNode.parentElement.parentElement.parentElement,
  315. "maxObj": this.designer.editContentNode,
  316. "onChange": function () {
  317. this.data[name] = scriptArea.toJson().code;
  318. }.bind(this),
  319. "onSave": function () {
  320. this.designer.saveView();
  321. }.bind(this),
  322. "style": style || "default"
  323. });
  324. scriptArea.load({"code": scriptContent});
  325. }.bind(this));
  326. }.bind(this));
  327. },
  328. loadPersonInput: function () {
  329. var identityNodes = this.propertyContent.getElements(".MWFPersonIdentity");
  330. var personUnitNodes = this.propertyContent.getElements(".MWFPersonUnit");
  331. MWF.xDesktop.requireApp("process.ProcessDesigner", "widget.PersonSelector", function () {
  332. identityNodes.each(function (node) {
  333. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.view.designer, {
  334. "type": "identity",
  335. "names": this.data[node.get("name")],
  336. "onChange": function (ids) {
  337. this.savePersonItem(node, ids);
  338. }.bind(this)
  339. });
  340. }.bind(this));
  341. personUnitNodes.each(function (node) {
  342. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.view.designer, {
  343. "type": "unit",
  344. "names": this.data[node.get("name")],
  345. "onChange": function (ids) {
  346. this.savePersonItem(node, ids);
  347. }.bind(this)
  348. });
  349. }.bind(this));
  350. }.bind(this));
  351. },
  352. savePersonItem: function (node, ids) {
  353. var values = [];
  354. ids.each(function (id) {
  355. //values.push({"name": (id.data.distinguishedName || id.data.name), "id": id.data.id});
  356. values.push((id.data.distinguishedName || id.data.id || id.data.name));
  357. }.bind(this));
  358. var name = node.get("name");
  359. key = name.split(".");
  360. var o = this.data;
  361. var len = key.length - 1;
  362. key.each(function (n, i) {
  363. if (!o[n]) o[n] = {};
  364. if (i < len) o = o[n];
  365. }.bind(this));
  366. o[key[len]] = values;
  367. //this.data.data.restrictWhereEntry[node.get("name")] = values;
  368. },
  369. loadPersonSelectInput: function () {
  370. var applicationNodes = this.propertyContent.getElements(".MWFSelectApplication");
  371. var processNodes = this.propertyContent.getElements(".MWFSelectProcess");
  372. // var companyNodes = this.propertyContent.getElements(".MWFSelectCompany");
  373. // var departmentNodes = this.propertyContent.getElements(".MWFSelectDepartment");
  374. var personNodes = this.propertyContent.getElements(".MWFSelectPerson");
  375. var identityNodes = this.propertyContent.getElements(".MWFSelectIdentity");
  376. var personUnitNodes = this.propertyContent.getElements(".MWFSelectUnit");
  377. MWF.xDesktop.requireApp("process.ProcessDesigner", "widget.PersonSelector", function () {
  378. applicationNodes.each(function (node) {
  379. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.view.designer, {
  380. "type": "application",
  381. "names": (this.data.data.restrictWhereEntry) ? this.data.data.restrictWhereEntry.applicationList : [],
  382. "onChange": function (ids) {
  383. this.savePersonSelectItem(node, ids);
  384. }.bind(this)
  385. });
  386. }.bind(this));
  387. processNodes.each(function (node) {
  388. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.view.designer, {
  389. "type": "process",
  390. "names": (this.data.data.restrictWhereEntry) ? this.data.data.restrictWhereEntry.processList : [],
  391. "onChange": function (ids) {
  392. this.savePersonSelectItem(node, ids);
  393. }.bind(this)
  394. });
  395. }.bind(this));
  396. personUnitNodes.each(function (node) {
  397. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.view.designer, {
  398. "type": "unit",
  399. "names": (this.data.data.restrictWhereEntry) ? this.data.data.restrictWhereEntry.unitList : [],
  400. "onChange": function (ids) {
  401. this.savePersonSelectItem(node, ids);
  402. }.bind(this)
  403. });
  404. }.bind(this));
  405. personNodes.each(function (node) {
  406. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.view.designer, {
  407. "type": "person",
  408. "names": (this.data.data.restrictWhereEntry) ? this.data.data.restrictWhereEntry.personList : [],
  409. "onChange": function (ids) {
  410. this.savePersonSelectItem(node, ids);
  411. }.bind(this)
  412. });
  413. }.bind(this));
  414. identityNodes.each(function (node) {
  415. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.view.designer, {
  416. "type": "identity",
  417. "names": (this.data.data.restrictWhereEntry) ? this.data.data.restrictWhereEntry.identityList : [],
  418. "onChange": function (ids) {
  419. this.savePersonSelectItem(node, ids);
  420. }.bind(this)
  421. });
  422. }.bind(this));
  423. }.bind(this));
  424. },
  425. savePersonSelectItem: function (node, ids) {
  426. //this.initWhereEntryData();
  427. var values = [];
  428. ids.each(function (id) {
  429. values.push({"name": (id.data.distinguishedName || id.data.name), "id": id.data.id});
  430. //values.push((id.data.distinguishedName || id.data.id || id.data.name));
  431. }.bind(this));
  432. var name = node.get("name");
  433. key = name.split(".");
  434. var o = this.data;
  435. var len = key.length - 1;
  436. key.each(function (n, i) {
  437. if (!o[n]) o[n] = {};
  438. if (i < len) o = o[n];
  439. }.bind(this));
  440. o[key[len]] = values;
  441. //this.data.data.restrictWhereEntry[node.get("name")] = values;
  442. },
  443. //loadWorkDataEditor: function(){
  444. // var workDataNodes = this.propertyContent.getElements(".MWFWorkData");
  445. // workDataNodes.each(function(node){
  446. // var select = node.getElement("select");
  447. // for (var i=0; i<select.options.length; i++){
  448. // if (select.options[i].value==this.data.name){
  449. // select.options[i].set("selected", true);
  450. // break;
  451. // }
  452. // }
  453. // if (!this.data.type) this.data.type = "text";
  454. // select.addEvent("change", function(e){
  455. // delete this.data.path;
  456. // this.data.name = select.options[select.selectedIndex].value;
  457. // this.module.listNode.getLast().set("text", this.data.text+"("+this.data.name+")");
  458. // this.setDataType();
  459. // }.bind(this));
  460. //
  461. // this.setDataType();
  462. // }.bind(this));
  463. // var nodes = this.propertyContent.getElements(".MWFWorkDataCheck");
  464. // nodes.each(function(node){
  465. // if (this.data.name) node.set("checked", true);
  466. // }.bind(this));
  467. //},
  468. //setDataType: function(){
  469. // switch (this.data.name){
  470. // case "startTime":case "completedTime":
  471. // this.data.type ="date";
  472. // break;
  473. // case "completed":
  474. // this.data.type ="boolean";
  475. // break;
  476. // default:
  477. // this.data.type ="text";
  478. // }
  479. //},
  480. //loadDataDataEditor: function(){
  481. // var nodes = this.propertyContent.getElements(".MWFDataData");
  482. // nodes.each(function(node){
  483. // var input = node.getElement("input");
  484. // input.set("value", this.data.path);
  485. // input.addEvent("change", function(e){
  486. // delete this.data.name;
  487. // this.data.path = input.get("value");
  488. // this.module.listNode.getLast().set("text", this.data.text+"("+this.data.path+")");
  489. // }.bind(this));
  490. // input.addEvent("blur", function(e){
  491. // delete this.data.name;
  492. // this.data.path = input.get("value");
  493. // this.module.listNode.getLast().set("text", this.data.text+"("+this.data.path+")");
  494. // }.bind(this));
  495. // input.addEvent("keydown", function(e){
  496. // if (e.code==13){
  497. // delete this.data.name;
  498. // this.data.path = input.get("value");
  499. // this.module.listNode.getLast().set("text", this.data.text+"("+this.data.path+")");
  500. // }
  501. // e.stopPropagation();
  502. // }.bind(this));
  503. //
  504. // var select = node.getElement("select");
  505. // for (var i=0; i<select.options.length; i++){
  506. // if (select.options[i].value==this.data.type){
  507. // select.options[i].set("selected", true);
  508. // break;
  509. // }
  510. // }
  511. // if (!this.data.type) this.data.type = "text";
  512. // select.addEvent("change", function(e){
  513. // this.data.type = select.options[select.selectedIndex].value;
  514. // }.bind(this));
  515. //
  516. // }.bind(this));
  517. // var nodes = this.propertyContent.getElements(".MWFDataDataCheck");
  518. // nodes.each(function(node){
  519. // if (this.data.path) node.set("checked", true);
  520. // }.bind(this));
  521. //},
  522. loadColumnExportEditor: function () {
  523. var _self = this;
  524. var nodes = this.propertyContent.getElements(".MWFColumnExport");
  525. nodes.each(function (node) {
  526. //if (!this.data.export) this.data.export = {};
  527. //var sort = this.data.export.sort || "";
  528. //var sortOrder = this.data.export.sortOrder || "1";
  529. var select = node.getElement("select");
  530. var sortList = this.view.data.data.orderEntryList;
  531. sortList.each(function (order) {
  532. if (order.column == this.data.column) {
  533. if (order.orderType == "asc") select.options[1].set("selected", true);
  534. if (order.orderType == "desc") select.options[1].set("selected", false);
  535. }
  536. }.bind(this));
  537. select.addEvent("change", function (e) {
  538. var v = select.options[select.selectedIndex].value;
  539. if (v != "none") {
  540. var flag = false;
  541. sortList.each(function (order) {
  542. if (order.column == this.data.column) {
  543. flag = true;
  544. order.orderType = select.options[select.selectedIndex].value;
  545. }
  546. }.bind(this));
  547. if (!flag) sortList.push({
  548. "column": this.data.column,
  549. "orderType": select.options[select.selectedIndex].value
  550. });
  551. } else {
  552. var deleteItem = null;
  553. sortList.each(function (order) {
  554. if (order.column == this.data.column) {
  555. deleteItem = order;
  556. }
  557. }.bind(this));
  558. if (deleteItem) sortList.erase(deleteItem);
  559. }
  560. }.bind(this));
  561. var radios = node.getElements("input");
  562. var group = this.view.data.data.group;
  563. if (group.column == this.data.column) radios[0].set("checked", true);
  564. radios.addEvent("click", function (e) {
  565. if (this.checked) {
  566. if (this.value == "true") {
  567. _self.view.data.data.group.column = _self.data.column;
  568. _self.view.items.each(function (col) {
  569. if (col.property) {
  570. var groupRadios = col.property.propertyContent.getElement(".MWFColumnExportGroup").getElements("input");
  571. groupRadios.each(function (r) {
  572. if (r.value == "true") r.set("checked", false);
  573. if (r.value == "false") r.set("checked", true);
  574. });
  575. }
  576. });
  577. this.set("checked", true);
  578. } else {
  579. if (group.column == _self.data.column) _self.view.data.data.group = {};
  580. }
  581. }
  582. });
  583. }.bind(this));
  584. },
  585. loadViewFilter: function () {
  586. var nodes = this.propertyContent.getElements(".MWFViewFilter");
  587. var filtrData = this.view.data.data.restrictFilterEntryList;
  588. var customData = this.view.data.data.customFilterEntryList;
  589. nodes.each(function (node) {
  590. MWF.xDesktop.requireApp("process.ViewDesigner", "widget.ViewFilter", function () {
  591. var _slef = this;
  592. new MWF.xApplication.process.ViewDesigner.widget.ViewFilter(node, this.view.designer, {
  593. "filtrData": filtrData,
  594. "customData": customData
  595. }, {
  596. "onChange": function (ids) {
  597. var data = this.getData();
  598. _slef.changeJsonDate(["data", "restrictFilterEntryList"], data.data);
  599. _slef.changeJsonDate(["data", "customFilterEntryList"], data.customData);
  600. }
  601. });
  602. }.bind(this));
  603. }.bind(this));
  604. },
  605. loadColumnFilter: function () {
  606. var nodes = this.propertyContent.getElements(".MWFColumnFilter");
  607. nodes.each(function (node) {
  608. this.module.filterAreaNode = node;
  609. var table = new Element("table", {
  610. "styles": {"width": "100%"},
  611. "border": "0px",
  612. "cellPadding": "0",
  613. "cellSpacing": "0"
  614. }).inject(node);
  615. var tr = new Element("tr", {"styles": this.module.css.filterTableTitle}).inject(table);
  616. var html = "<th style='width:24px;border-right:1px solid #CCC;border-bottom:1px solid #999;'></th>" +
  617. "<th style='border-right:1px solid #CCC;border-left:1px solid #FFF;border-bottom:1px solid #999;'>逻辑</th>" +
  618. "<th style='border-right:1px solid #CCC;border-left:1px solid #FFF;border-bottom:1px solid #999;'>路径</th>" +
  619. "<th style='border-right:1px solid #CCC;border-left:1px solid #FFF;border-bottom:1px solid #999;'>比较</th>" +
  620. "<th style='border-left:1px solid #FFF;border-bottom:1px solid #999;'>值</th>";
  621. tr.set("html", html);
  622. var addActionNode = new Element("div", {"styles": this.module.css.filterAddActionNode}).inject(tr.getFirst("th"));
  623. addActionNode.addEvent("click", function () {
  624. this.addFilter(table);
  625. }.bind(this));
  626. if (this.data.filterList) {
  627. this.data.filterList.each(function (op) {
  628. new MWF.xApplication.process.ViewDesigner.Property.Filter(op, table, this);
  629. }.bind(this));
  630. }
  631. }.bind(this));
  632. },
  633. addFilter: function (table) {
  634. op = {
  635. "logic": "and",
  636. "comparison": "",
  637. "value": ""
  638. }
  639. if (!this.data.filterList) this.data.filterList = [];
  640. this.data.filterList.push(op);
  641. var filter = new MWF.xApplication.process.ViewDesigner.Property.Filter(op, table, this);
  642. filter.editMode();
  643. }
  644. //initWhereEntryData: function(){
  645. // if (!this.data.data.restrictWhereEntry) this.data.data.restrictWhereEntry = {
  646. // "applicationList": [],
  647. // "processList": [],
  648. // "companyList": [],
  649. // "departmentList": [],
  650. // "personList": [],
  651. // "identityList": []
  652. // };
  653. //},
  654. //loadApplicationSelector: function(){
  655. // var nodes = this.propertyContent.getElements(".MWFApplicationSelect");
  656. // if (nodes.length){
  657. // MWF.xDesktop.requireApp("Organization", "Selector.package", function(){
  658. // nodes.each(function(node){
  659. // var title = new Element("div", {"styles": this.view.css.applicationSelectTitle, "text": node.get("title")}).inject(node);
  660. // var content = new Element("div", {"styles": this.view.css.applicationSelectContent}).inject(node);
  661. // var action = new Element("div", {"styles": this.view.css.applicationSelectAction, "text": node.get("title")}).inject(node);
  662. // action.addEvent("click", function(e){
  663. // var values = [];
  664. // if (this.data.data.whereEntry){
  665. // if (this.data.data.whereEntry.applicationList.length){
  666. // this.data.data.whereEntry.applicationList.each(function(item){
  667. // values.push(item.id);
  668. // }.bind(this));
  669. // }
  670. // }
  671. // var options = {
  672. // "type": "application",
  673. // "count": 0,
  674. // "values": values,
  675. // //"title": this.app.lp.monthly.selectSortApplication,
  676. // "onComplete": function(items){
  677. // this.initWhereEntryData();
  678. // this.data.data.whereEntry.applicationList = [];
  679. // content.empty();
  680. // items.each(function(item){
  681. // this.data.data.whereEntry.applicationList.push({
  682. // "id": item.data.id,
  683. // "name": item.data.name
  684. // });
  685. // new Element("div", {
  686. // "styles": this.view.css.applicationSelectItem,
  687. // "text": item.data.name
  688. // }).inject(content);
  689. // }.bind(this));
  690. // }.bind(this)
  691. // };
  692. // var selector = new MWF.OrgSelector(this.view.designer.content, options);
  693. // }.bind(this));
  694. //
  695. // this.initWhereEntryData();
  696. // this.data.data.whereEntry.applicationList.each(function(app){
  697. // new Element("div", {
  698. // "styles": this.view.css.applicationSelectItem,
  699. // "text": app.name
  700. // }).inject(content);
  701. // }.bind(this));
  702. // }.bind(this));
  703. // }.bind(this));
  704. // }
  705. //},
  706. //loadApplicationSelector1: function(){
  707. // var nodes = this.propertyContent.getElements(".MWFApplicationSelect");
  708. // if (nodes.length){
  709. // this._getAppSelector(function(){
  710. // nodes.each(function(node){
  711. // var title = new Element("div", {"styles": this.view.css.applicationSelectTitle, "text": node.get("title")}).inject(node);
  712. // var content = new Element("div", {"styles": this.view.css.applicationSelectContent}).inject(node);
  713. // var action = new Element("div", {"styles": this.view.css.applicationSelectAction, "text": node.get("title")}).inject(node);
  714. // action.addEvent("click", function(e){
  715. // this.appSelector.load(function(apps){
  716. // if (!this.data.data.select) this.data.data.select = {"applicationRestrictList": [], "processRestrictList": []};
  717. // this.data.data.select.applicationRestrictList = [];
  718. // content.empty();
  719. // if (apps.length){
  720. // apps.each(function(app){
  721. // var o = {
  722. // "name": app.name,
  723. // "id": app.id,
  724. // "alias": app.alias
  725. // }
  726. // this.data.data.select.applicationRestrictList.push(o);
  727. //
  728. // new Element("div", {
  729. // "styles": this.view.css.applicationSelectItem,
  730. // "text": app.name
  731. // }).inject(content);
  732. //
  733. // }.bind(this));
  734. // }
  735. // }.bind(this));
  736. // }.bind(this));
  737. // if (!this.data.data.select) this.data.data.select = {"applicationRestrictList": [], "processRestrictList": []};
  738. // this.data.data.select.applicationRestrictList.each(function(app){
  739. // new Element("div", {
  740. // "styles": this.view.css.applicationSelectItem,
  741. // "text": app.name
  742. // }).inject(content);
  743. // }.bind(this));
  744. //
  745. // }.bind(this));
  746. // }.bind(this));
  747. // }
  748. //},
  749. //
  750. //_getAppSelector: function(callback){
  751. // if (!this.appSelector){
  752. // MWF.xDesktop.requireApp("process.ProcessManager", "widget.ApplicationSelector", function(){
  753. // this.appSelector = new MWF.xApplication.process.ProcessManager.widget.ApplicationSelector(this.view.designer, {"maskNode": this.view.designer.content});
  754. // if (callback) callback();
  755. // }.bind(this));
  756. // }else{
  757. // if (callback) callback();
  758. // }
  759. //},
  760. //this.initWhereEntryData();
  761. //loadProcessSelector: function(){
  762. // var nodes = this.propertyContent.getElements(".MWFApplicationSelect");
  763. // if (nodes.length){
  764. // MWF.xDesktop.requireApp("Organization", "Selector.package", function(){
  765. // nodes.each(function(node){
  766. // var title = new Element("div", {"styles": this.view.css.applicationSelectTitle, "text": node.get("title")}).inject(node);
  767. // var content = new Element("div", {"styles": this.view.css.applicationSelectContent}).inject(node);
  768. // var action = new Element("div", {"styles": this.view.css.applicationSelectAction, "text": node.get("title")}).inject(node);
  769. // action.addEvent("click", function(e){
  770. // var values = [];
  771. // if (this.data.data.whereEntry){
  772. // if (this.data.data.whereEntry.processList.length){
  773. // this.data.data.whereEntry.processList.each(function(item){
  774. // values.push(item.id);
  775. // }.bind(this));
  776. // }
  777. // }
  778. // var options = {
  779. // "type": "process",
  780. // "count": 0,
  781. // "values": values,
  782. // "onComplete": function(items){
  783. // this.initWhereEntryData();
  784. // this.data.data.whereEntry.processList = [];
  785. // content.empty();
  786. // items.each(function(item){
  787. // this.data.data.whereEntry.processList.push({
  788. // "id": item.data.id,
  789. // "name": item.data.name
  790. // });
  791. // new Element("div", {
  792. // "styles": this.view.css.applicationSelectItem,
  793. // "text": item.data.name
  794. // }).inject(content);
  795. // }.bind(this));
  796. // }.bind(this)
  797. // };
  798. // var selector = new MWF.OrgSelector(this.view.designer.content, options);
  799. // }.bind(this));
  800. //
  801. // this.initWhereEntryData();
  802. // this.data.data.whereEntry.processList.each(function(app){
  803. // new Element("div", {
  804. // "styles": this.view.css.applicationSelectItem,
  805. // "text": app.name
  806. // }).inject(content);
  807. // }.bind(this));
  808. // }.bind(this));
  809. // }.bind(this));
  810. // }
  811. //}
  812. //loadProcessSelector1: function(){
  813. // var nodes = this.propertyContent.getElements(".MWFProcessSelect");
  814. // if (nodes.length){
  815. // this._getProcessSelector(function(){
  816. // nodes.each(function(node){
  817. // var title = new Element("div", {"styles": this.view.css.applicationSelectTitle, "text": node.get("title")}).inject(node);
  818. // var content = new Element("div", {"styles": this.view.css.applicationSelectContent}).inject(node);
  819. // var action = new Element("div", {"styles": this.view.css.applicationSelectAction, "text": node.get("title")}).inject(node);
  820. // action.addEvent("click", function(e){
  821. // var ids=[];
  822. // this.data.data.select.applicationRestrictList.each(function(app){
  823. // ids.push(app.id);
  824. // });
  825. // this.processSelector.load(ids, function(apps){
  826. // if (!this.data.data.select) this.data.data.select = {"applicationRestrictList": [], "processRestrictList": []};
  827. // this.data.data.select.processRestrictList = [];
  828. // content.empty();
  829. // if (apps.length){
  830. // apps.each(function(app){
  831. // var o = {
  832. // "name": app.name,
  833. // "id": app.id,
  834. // "alias": app.alias
  835. // }
  836. // this.data.data.select.processRestrictList.push(o);
  837. //
  838. // new Element("div", {
  839. // "styles": this.view.css.applicationSelectItem,
  840. // "text": app.name
  841. // }).inject(content);
  842. //
  843. // }.bind(this));
  844. // }
  845. // }.bind(this));
  846. // }.bind(this));
  847. // if (!this.data.data.select) this.data.data.select = {"applicationRestrictList": [], "processRestrictList": []};
  848. // this.data.data.select.processRestrictList.each(function(app){
  849. // new Element("div", {
  850. // "styles": this.view.css.applicationSelectItem,
  851. // "text": app.name
  852. // }).inject(content);
  853. // }.bind(this));
  854. //
  855. // }.bind(this));
  856. // }.bind(this));
  857. // }
  858. //},
  859. //_getProcessSelector: function(callback){
  860. // if (!this.processSelector){
  861. // MWF.xDesktop.requireApp("process.ProcessManager", "widget.ProcessSelector", function(){
  862. // this.processSelector = new MWF.xApplication.process.ProcessManager.widget.ProcessSelector(this.view.designer, {"maskNode": this.view.designer.content});
  863. // if (callback) callback();
  864. // }.bind(this));
  865. // }else{
  866. // if (callback) callback();
  867. // }
  868. //}
  869. });
  870. MWF.xApplication.process.ViewDesigner.Property.Filter = new Class({
  871. Implements: [Events],
  872. initialize: function (json, table, property) {
  873. this.property = property;
  874. this.module = property.module;
  875. this.table = table;
  876. this.data = json;
  877. this.load();
  878. },
  879. load: function () {
  880. this.node = new Element("tr", {"styles": this.module.css.filterTableTd}).inject(this.table);
  881. var html = "<td style='widtd:24px;border-right:1px solid #CCC;border-bottom:1px solid #999;'></td>" +
  882. "<td style='padding:3px;border-right:1px solid #CCC;border-bottom:1px solid #999; width:60px'>" + this.data.logic + "</td>" +
  883. "<td style='padding:3px;border-right:1px solid #CCC;border-bottom:1px solid #999; width:30px'>列值</td>" +
  884. "<td style='padding:3px;border-right:1px solid #CCC;border-bottom:1px solid #999;'>" + this.data.comparison + "</td>" +
  885. "<td style='padding:3px;border-bottom:1px solid #999;'>" + this.data.value + "</td>";
  886. this.node.set("html", html);
  887. var tds = this.node.getElements("td");
  888. this.delActionNode = new Element("div", {"styles": this.module.css.filterDelActionNode}).inject(tds[0]);
  889. this.delActionNode.addEvent("click", function (e) {
  890. this.delFilter(e);
  891. e.stopPropagation();
  892. }.bind(this));
  893. this.logicNode = tds[1];
  894. this.comparisonNode = tds[3];
  895. this.valueNode = tds[4];
  896. this.node.addEvent("click", function () {
  897. if (!this.isEditMode) this.editMode();
  898. }.bind(this));
  899. this.node.addEvent("blur", function () {
  900. if (this.isEditMode) this.readMode();
  901. }.bind(this));
  902. },
  903. delFilter: function (e) {
  904. var _self = this;
  905. this.property.designer.confirm("warn", e, MWF.APPVD.LP.notice.deleteFilterTitle, MWF.APPVD.LP.notice.deleteFilter, 300, 120, function () {
  906. _self.node.destroy();
  907. _self.property.data.filterList.erase(_self.data);
  908. MWF.release(_self);
  909. this.close();
  910. }, function () {
  911. this.close();
  912. }, null);
  913. },
  914. editMode: function () {
  915. if (this.property.editModeFilter) {
  916. if (this.property.editModeFilter != this) this.property.editModeFilter.readMode();
  917. }
  918. var width = this.logicNode.getSize().x - 9;
  919. this.logicNode.empty();
  920. var logicSelect = new Element("select", {"styles": {"width": "90%"}}).inject(this.logicNode);
  921. var html = "";
  922. if (this.data.logic == "and") {
  923. html = "<option value=\"and\" selected>and</option><option value=\"or\">or</option>";
  924. } else {
  925. html = "<option value=\"and\">and</option><option value=\"or\" selected>or</option>";
  926. }
  927. logicSelect.set("html", html);
  928. logicSelect.addEvent("change", function () {
  929. this.data.logic = logicSelect.options[logicSelect.selectedIndex].value;
  930. }.bind(this));
  931. width = this.comparisonNode.getSize().x - 9;
  932. this.comparisonNode.empty();
  933. var comparisonSelect = new Element("select", {"styles": {"width": "90%"}}).inject(this.comparisonNode);
  934. html = "";
  935. switch (this.property.data.type) {
  936. case "text":
  937. html += "<option value=''></option><option value='==' " + ((this.data.comparison == "==") ? "selected" : "") + ">等于(==)</option>" +
  938. "<option value='!=' " + ((this.data.comparison == "!=") ? "selected" : "") + ">不等于(!=)</option>" +
  939. "<option value='@' " + ((this.data.comparison == "@") ? "selected" : "") + ">包含(@)</option>";
  940. break;
  941. case "date":
  942. html += "<option value=''></option><option value='&gt;' " + ((this.data.comparison == ">") ? "selected" : "") + ">大于(&gt;)</option>" +
  943. "<option value='&lt;' " + ((this.data.comparison == "<") ? "selected" : "") + ">小于(&lt;)</option>" +
  944. "<option value='&gt;=' " + ((this.data.comparison == ">=") ? "selected" : "") + ">大于等于(&gt;=)</option>" +
  945. "<option value='&lt;=' " + ((this.data.comparison == "<=") ? "selected" : "") + ">小于等于(&lt;=)</option>";
  946. break;
  947. case "number":
  948. html += "<option value=''></option><option value='==' " + ((this.data.comparison == "==") ? "selected" : "") + ">等于(==)</option>" +
  949. "<option value='!=' " + ((this.data.comparison == "!=") ? "selected" : "") + ">不等于(!=)</option>" +
  950. "<option value='&gt;' " + ((this.data.comparison == ">") ? "selected" : "") + ">大于(&gt;)</option>" +
  951. "<option value='&lt;' " + ((this.data.comparison == "<") ? "selected" : "") + ">小于(&lt;)</option>" +
  952. "<option value='&gt;=' " + ((this.data.comparison == ">=") ? "selected" : "") + ">大于等于(&gt;=)</option>" +
  953. "<option value='&lt;=' " + ((this.data.comparison == "<=") ? "selected" : "") + ">小于等于(&lt;=)</option>";
  954. break;
  955. case "boolean":
  956. html += "<option value=''></option><option value='==' " + ((this.data.comparison == "==") ? "selected" : "") + ">等于(==)</option>" +
  957. "<option value='!=' " + ((this.data.comparison == "!=") ? "selected" : "") + ">不等于(!=)</option>";
  958. break;
  959. }
  960. comparisonSelect.set("html", html);
  961. comparisonSelect.addEvent("change", function () {
  962. this.data.comparison = comparisonSelect.options[comparisonSelect.selectedIndex].value;
  963. }.bind(this));
  964. width = this.valueNode.getSize().x - 9;
  965. this.valueNode.empty();
  966. var type = "text";
  967. switch (this.property.data.type) {
  968. case "date":
  969. var valueInput = new Element("input", {
  970. "styles": {"width": "90%"},
  971. "type": "text",
  972. "value": this.data.value
  973. }).inject(this.valueNode);
  974. MWF.require("MWF.widget.Calendar", function () {
  975. this.calendar = new MWF.widget.Calendar(valueInput, {
  976. "style": "xform",
  977. "isTime": true,
  978. "secondEnable": true,
  979. "target": this.property.designer.content,
  980. "format": "%Y-%m-%d %H:%M:%S"
  981. });
  982. //this.calendar.show();
  983. }.bind(this));
  984. break;
  985. case "number":
  986. var valueInput = new Element("input", {
  987. "styles": {"width": "90%"},
  988. "type": "number",
  989. "value": this.data.value
  990. }).inject(this.valueNode);
  991. break;
  992. case "boolean":
  993. var valueInput = new Element("select", {
  994. "styles": {"width": "" + width + "px"},
  995. "html": "<option value=\"\"></option><option value=\"true\" " + ((this.data.value) ? "selected" : "") + ">true</option><option value=\"false\" " + ((!this.data.value) ? "selected" : "") + ">false</option>"
  996. }).inject(this.valueNode);
  997. break;
  998. default:
  999. var valueInput = new Element("input", {
  1000. "styles": {"width": "90%"},
  1001. "type": "text",
  1002. "value": this.data.value
  1003. }).inject(this.valueNode);
  1004. }
  1005. if (valueInput.tagName.toLowerCase() == "select") {
  1006. valueInput.addEvent("change", function () {
  1007. var v = valueInput.options[valueInput.selectedIndex].value;
  1008. this.data.value = (v = "true") ? true : false;
  1009. }.bind(this));
  1010. } else {
  1011. valueInput.addEvent("change", function (e) {
  1012. this.data.value = valueInput.get("value");
  1013. }.bind(this));
  1014. valueInput.addEvent("blur", function (e) {
  1015. this.data.value = valueInput.get("value");
  1016. }.bind(this));
  1017. valueInput.addEvent("keydown", function (e) {
  1018. if (e.code == 13) {
  1019. this.data.value = valueInput.get("value");
  1020. this.readMode();
  1021. }
  1022. e.stopPropagation();
  1023. }.bind(this));
  1024. }
  1025. this.isEditMode = true;
  1026. this.property.editModeFilter = this;
  1027. },
  1028. readMode: function () {
  1029. if (this.isEditMode) {
  1030. var logicSelect = this.logicNode.getElement("select");
  1031. this.data.logic = logicSelect.options[logicSelect.selectedIndex].value;
  1032. var comparisonSelect = this.comparisonNode.getElement("select");
  1033. this.data.comparison = comparisonSelect.options[comparisonSelect.selectedIndex].value;
  1034. var valueInput = this.valueNode.getFirst();
  1035. if (valueInput.tagName.toLowerCase() == "select") {
  1036. var v = valueInput.options[valueInput.selectedIndex].value;
  1037. this.data.value = (v = "true") ? true : false;
  1038. } else {
  1039. this.data.value = valueInput.get("value");
  1040. }
  1041. this.logicNode.empty();
  1042. this.comparisonNode.empty();
  1043. this.valueNode.empty();
  1044. this.logicNode.set("text", this.data.logic);
  1045. this.comparisonNode.set("text", this.data.comparison);
  1046. this.valueNode.set("text", this.data.value);
  1047. this.isEditMode = false;
  1048. this.property.editModeFilter = null;
  1049. }
  1050. }
  1051. });