Property.js 66 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469
  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 names = name.split(".");
  336. var scriptContent = this.data;
  337. Array.each(names, function (n) {
  338. if (scriptContent) scriptContent = scriptContent[n];
  339. });
  340. // var scriptContent = this.data[name];
  341. MWF.require("MWF.widget.ScriptArea", function () {
  342. var scriptArea = new MWF.widget.ScriptArea(node, {
  343. "title": title,
  344. //"maxObj": this.propertyNode.parentElement.parentElement.parentElement,
  345. "maxObj": this.designer.editContentNode,
  346. "onChange": function () {
  347. var scriptObj = this.data;
  348. Array.each(names, function (n, idx) {
  349. if( idx === names.length -1 )return;
  350. if (scriptObj) scriptObj = scriptObj[n];
  351. });
  352. scriptObj[names[names.length -1]] = scriptArea.toJson().code;
  353. // this.data[name] = scriptArea.toJson().code;
  354. }.bind(this),
  355. "onSave": function () {
  356. this.designer.saveView();
  357. }.bind(this),
  358. "style": style || "default",
  359. "runtime": "server"
  360. });
  361. scriptArea.load({"code": scriptContent});
  362. }.bind(this));
  363. }.bind(this));
  364. },
  365. loadStatColumnSelect: function () {
  366. },
  367. loadPersonInput: function () {
  368. var identityNodes = this.propertyContent.getElements(".MWFPersonIdentity");
  369. var personUnitNodes = this.propertyContent.getElements(".MWFPersonUnit");
  370. MWF.xDesktop.requireApp("process.ProcessDesigner", "widget.PersonSelector", function () {
  371. identityNodes.each(function (node) {
  372. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.view.designer, {
  373. "type": "identity",
  374. "names": this.data[node.get("name")],
  375. "onChange": function (ids) {
  376. this.savePersonItem(node, ids);
  377. }.bind(this)
  378. });
  379. }.bind(this));
  380. personUnitNodes.each(function (node) {
  381. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.view.designer, {
  382. "type": "unit",
  383. "names": this.data[node.get("name")],
  384. "onChange": function (ids) {
  385. this.savePersonItem(node, ids);
  386. }.bind(this)
  387. });
  388. }.bind(this));
  389. }.bind(this));
  390. },
  391. savePersonItem: function (node, ids) {
  392. var values = [];
  393. ids.each(function (id) {
  394. //values.push({"name": (id.data.distinguishedName || id.data.name), "id": id.data.id});
  395. values.push((id.data.distinguishedName || id.data.id || id.data.name));
  396. }.bind(this));
  397. var name = node.get("name");
  398. key = name.split(".");
  399. var o = this.data;
  400. var len = key.length - 1;
  401. key.each(function (n, i) {
  402. if (!o[n]) o[n] = {};
  403. if (i < len) o = o[n];
  404. }.bind(this));
  405. o[key[len]] = values;
  406. //this.data.data.restrictWhereEntry[node.get("name")] = values;
  407. },
  408. loadPersonSelectInput: function () {
  409. var applicationNodes = this.propertyContent.getElements(".MWFSelectApplication");
  410. var processNodes = this.propertyContent.getElements(".MWFSelectProcess");
  411. // var companyNodes = this.propertyContent.getElements(".MWFSelectCompany");
  412. // var departmentNodes = this.propertyContent.getElements(".MWFSelectDepartment");
  413. var personNodes = this.propertyContent.getElements(".MWFSelectPerson");
  414. var identityNodes = this.propertyContent.getElements(".MWFSelectIdentity");
  415. var personUnitNodes = this.propertyContent.getElements(".MWFSelectUnit");
  416. var cmsapplicationNodes = this.propertyContent.getElements(".MWFSelectCMSApplication");
  417. var cmscategoryNodes = this.propertyContent.getElements(".MWFSelecCMStCategory");
  418. MWF.xDesktop.requireApp("process.ProcessDesigner", "widget.PersonSelector", function () {
  419. applicationNodes.each(function (node) {
  420. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.view.designer, {
  421. "type": "application",
  422. "names": (this.data.data.where) ? this.data.data.where.applicationList : [],
  423. "onChange": function (ids) {
  424. this.savePersonSelectItem(node, ids);
  425. }.bind(this)
  426. });
  427. }.bind(this));
  428. processNodes.each(function (node) {
  429. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.view.designer, {
  430. "type": "process",
  431. "names": (this.data.data.where) ? this.data.data.where.processList : [],
  432. "onChange": function (ids) {
  433. this.savePersonSelectItem(node, ids);
  434. }.bind(this)
  435. });
  436. }.bind(this));
  437. personUnitNodes.each(function (node) {
  438. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.view.designer, {
  439. "type": "unit",
  440. "names": (this.data.data.where) ? this.data.data.where.creatorUnitList : [],
  441. "onChange": function (ids) {
  442. this.savePersonSelectItem(node, ids);
  443. }.bind(this)
  444. });
  445. }.bind(this));
  446. personNodes.each(function (node) {
  447. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.view.designer, {
  448. "type": "person",
  449. "names": (this.data.data.where) ? this.data.data.where.creatorPersonList : [],
  450. "onChange": function (ids) {
  451. this.savePersonSelectItem(node, ids);
  452. }.bind(this)
  453. });
  454. }.bind(this));
  455. identityNodes.each(function (node) {
  456. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.view.designer, {
  457. "type": "identity",
  458. "names": (this.data.data.where) ? this.data.data.where.creatorIdentityList : [],
  459. "onChange": function (ids) {
  460. this.savePersonSelectItem(node, ids);
  461. }.bind(this)
  462. });
  463. }.bind(this));
  464. cmsapplicationNodes.each(function (node) {
  465. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.view.designer, {
  466. "type": "CMSApplication",
  467. "names": (this.data.data.where) ? this.data.data.where.appInfoList : [],
  468. "onChange": function (ids) {
  469. this.savePersonSelectItem(node, ids);
  470. }.bind(this)
  471. });
  472. }.bind(this));
  473. cmscategoryNodes.each(function (node) {
  474. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.view.designer, {
  475. "type": "CMSCategory",
  476. "names": (this.data.data.where) ? this.data.data.where.categoryInfoList : [],
  477. "onChange": function (ids) {
  478. this.savePersonSelectItem(node, ids);
  479. }.bind(this)
  480. });
  481. }.bind(this));
  482. }.bind(this));
  483. },
  484. savePersonSelectItem: function (node, ids) {
  485. //this.initWhereEntryData();
  486. var values = [];
  487. ids.each(function (id) {
  488. values.push({"name": (id.data.distinguishedName || id.data.name), "id": id.data.id});
  489. //values.push((id.data.distinguishedName || id.data.id || id.data.name));
  490. }.bind(this));
  491. var name = node.get("name");
  492. key = name.split(".");
  493. var o = this.data;
  494. var len = key.length - 1;
  495. key.each(function (n, i) {
  496. if (!o[n]) o[n] = {};
  497. if (i < len) o = o[n];
  498. }.bind(this));
  499. o[key[len]] = values;
  500. //this.data.data.restrictWhereEntry[node.get("name")] = values;
  501. },
  502. //loadWorkDataEditor: function(){
  503. // var workDataNodes = this.propertyContent.getElements(".MWFWorkData");
  504. // workDataNodes.each(function(node){
  505. // var select = node.getElement("select");
  506. // for (var i=0; i<select.options.length; i++){
  507. // if (select.options[i].value==this.data.name){
  508. // select.options[i].set("selected", true);
  509. // break;
  510. // }
  511. // }
  512. // if (!this.data.type) this.data.type = "text";
  513. // select.addEvent("change", function(e){
  514. // delete this.data.path;
  515. // this.data.name = select.options[select.selectedIndex].value;
  516. // this.module.listNode.getLast().set("text", this.data.text+"("+this.data.name+")");
  517. // this.setDataType();
  518. // }.bind(this));
  519. //
  520. // this.setDataType();
  521. // }.bind(this));
  522. // var nodes = this.propertyContent.getElements(".MWFWorkDataCheck");
  523. // nodes.each(function(node){
  524. // if (this.data.name) node.set("checked", true);
  525. // }.bind(this));
  526. //},
  527. //setDataType: function(){
  528. // switch (this.data.name){
  529. // case "startTime":case "completedTime":
  530. // this.data.type ="date";
  531. // break;
  532. // case "completed":
  533. // this.data.type ="boolean";
  534. // break;
  535. // default:
  536. // this.data.type ="text";
  537. // }
  538. //},
  539. //loadDataDataEditor: function(){
  540. // var nodes = this.propertyContent.getElements(".MWFDataData");
  541. // nodes.each(function(node){
  542. // var input = node.getElement("input");
  543. // input.set("value", this.data.path);
  544. // input.addEvent("change", function(e){
  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. // }.bind(this));
  549. // input.addEvent("blur", function(e){
  550. // delete this.data.name;
  551. // this.data.path = input.get("value");
  552. // this.module.listNode.getLast().set("text", this.data.text+"("+this.data.path+")");
  553. // }.bind(this));
  554. // input.addEvent("keydown", function(e){
  555. // if (e.code==13){
  556. // delete this.data.name;
  557. // this.data.path = input.get("value");
  558. // this.module.listNode.getLast().set("text", this.data.text+"("+this.data.path+")");
  559. // }
  560. // e.stopPropagation();
  561. // }.bind(this));
  562. //
  563. // var select = node.getElement("select");
  564. // for (var i=0; i<select.options.length; i++){
  565. // if (select.options[i].value==this.data.type){
  566. // select.options[i].set("selected", true);
  567. // break;
  568. // }
  569. // }
  570. // if (!this.data.type) this.data.type = "text";
  571. // select.addEvent("change", function(e){
  572. // this.data.type = select.options[select.selectedIndex].value;
  573. // }.bind(this));
  574. //
  575. // }.bind(this));
  576. // var nodes = this.propertyContent.getElements(".MWFDataDataCheck");
  577. // nodes.each(function(node){
  578. // if (this.data.path) node.set("checked", true);
  579. // }.bind(this));
  580. //},
  581. loadColumnExportEditor: function () {
  582. var _self = this;
  583. var nodes = this.propertyContent.getElements(".MWFColumnExport");
  584. nodes.each(function (node) {
  585. //if (!this.data.export) this.data.export = {};
  586. //var sort = this.data.export.sort || "";
  587. //var sortOrder = this.data.export.sortOrder || "1";
  588. var select = node.getElement("select");
  589. var sortList = this.view.data.data.orderList;
  590. sortList.each(function (order) {
  591. if (order.column == this.data.column) {
  592. if (order.orderType == "asc") select.options[1].set("selected", true);
  593. if (order.orderType == "desc") select.options[1].set("selected", false);
  594. }
  595. }.bind(this));
  596. select.addEvent("change", function (e) {
  597. debugger;
  598. var sortList = this.view.data.data.orderList;
  599. var v = select.options[select.selectedIndex].value;
  600. if (v != "none") {
  601. var flag = false;
  602. sortList.each(function (order) {
  603. if (order.column == this.data.column) {
  604. flag = true;
  605. order.orderType = select.options[select.selectedIndex].value;
  606. }
  607. }.bind(this));
  608. if (!flag) sortList.push({
  609. "column": this.data.column,
  610. "orderType": select.options[select.selectedIndex].value
  611. });
  612. var oldOrderList = Array.clone(this.view.data.data.orderList);
  613. this.view.data.data.orderList = [];
  614. this.view.json.data.selectList.each(function (sel) {
  615. oldOrderList.each(function (order) {
  616. if (order.column == sel.column) {
  617. this.view.data.data.orderList.push(order);
  618. }
  619. }.bind(this));
  620. }.bind(this));
  621. } else {
  622. var sortList = this.view.data.data.orderList;
  623. var deleteItem = null;
  624. sortList.each(function (order) {
  625. if (order.column == this.data.column) {
  626. deleteItem = order;
  627. }
  628. }.bind(this));
  629. if (deleteItem) sortList.erase(deleteItem);
  630. }
  631. }.bind(this));
  632. var radios = node.getElements("input[name='" + this.module.json.id + "groupEntry']");
  633. var group = this.view.data.data.group;
  634. if (group.column == this.data.column) radios[0].set("checked", true);
  635. radios.addEvent("click", function (e) {
  636. if (this.checked) {
  637. if (this.value == "true") {
  638. _self.view.data.data.group.column = _self.data.column;
  639. _self.view.items.each(function (col) {
  640. if (col.property) {
  641. var groupRadios = col.property.propertyContent.getElement(".MWFColumnExportGroup").getElements("input");
  642. groupRadios.each(function (r) {
  643. if (r.value == "true") r.set("checked", false);
  644. if (r.value == "false") r.set("checked", true);
  645. });
  646. }
  647. });
  648. (_self.view.data.data.selectList).each(function (s) {
  649. if (s.column !== _self.data.column) s.groupEntry = false;
  650. });
  651. this.set("checked", true);
  652. } else {
  653. if (group.column == _self.data.column) _self.view.data.data.group = {};
  654. }
  655. }
  656. });
  657. }.bind(this));
  658. },
  659. loadViewFilter: function () {
  660. var nodes = this.propertyContent.getElements(".MWFViewFilter");
  661. var filtrData = this.view.data.data.filterList;
  662. var customData = this.view.data.data.customFilterList;
  663. nodes.each(function (node) {
  664. MWF.xDesktop.requireApp("query.ViewDesigner", "widget.ViewFilter", function () {
  665. var _slef = this;
  666. new MWF.xApplication.query.ViewDesigner.widget.ViewFilter(node, this.view.designer, {
  667. "filtrData": filtrData,
  668. "customData": customData
  669. }, {
  670. "onChange": function (ids) {
  671. var data = this.getData();
  672. _slef.changeJsonDate(["data", "filterList"], data.data);
  673. _slef.changeJsonDate(["data", "customFilterList"], data.customData);
  674. }
  675. });
  676. }.bind(this));
  677. }.bind(this));
  678. },
  679. loadColumnFilter: function () {
  680. var nodes = this.propertyContent.getElements(".MWFColumnFilter");
  681. nodes.each(function (node) {
  682. this.module.filterAreaNode = node;
  683. var table = new Element("table", {
  684. "styles": {"width": "100%"},
  685. "border": "0px",
  686. "cellPadding": "0",
  687. "cellSpacing": "0"
  688. }).inject(node);
  689. var tr = new Element("tr", {"styles": this.module.css.filterTableTitle}).inject(table);
  690. var html = "<th style='width:24px;border-right:1px solid #CCC;border-bottom:1px solid #999;'></th>" +
  691. "<th style='border-right:1px solid #CCC;border-left:1px solid #FFF;border-bottom:1px solid #999;'>逻辑</th>" +
  692. "<th style='border-right:1px solid #CCC;border-left:1px solid #FFF;border-bottom:1px solid #999;'>路径</th>" +
  693. "<th style='border-right:1px solid #CCC;border-left:1px solid #FFF;border-bottom:1px solid #999;'>比较</th>" +
  694. "<th style='border-left:1px solid #FFF;border-bottom:1px solid #999;'>值</th>";
  695. tr.set("html", html);
  696. var addActionNode = new Element("div", {"styles": this.module.css.filterAddActionNode}).inject(tr.getFirst("th"));
  697. addActionNode.addEvent("click", function () {
  698. this.addFilter(table);
  699. }.bind(this));
  700. if (this.data.filterList) {
  701. this.data.filterList.each(function (op) {
  702. new MWF.xApplication.query.ViewDesigner.Property.Filter(op, table, this);
  703. }.bind(this));
  704. }
  705. }.bind(this));
  706. },
  707. addFilter: function (table) {
  708. op = {
  709. "logic": "and",
  710. "comparison": "",
  711. "value": ""
  712. }
  713. if (!this.data.filterList) this.data.filterList = [];
  714. this.data.filterList.push(op);
  715. var filter = new MWF.xApplication.query.ViewDesigner.Property.Filter(op, table, this);
  716. filter.editMode();
  717. },
  718. loadViewStylesArea: function () {
  719. var _self = this;
  720. var viewAreas = this.propertyContent.getElements(".MWFViewStylesArea");
  721. viewAreas.each(function (node) {
  722. var name = node.get("name");
  723. var d = this.data;
  724. Array.each(name.split("."), function (n) {
  725. if (d) d = d[n];
  726. });
  727. var viewStyles = d || {};
  728. MWF.require("MWF.widget.Maplist", function () {
  729. var maps = [];
  730. Object.each(viewStyles, function (v, k) {
  731. var mapNode = new Element("div").inject(node);
  732. mapNode.empty();
  733. var maplist = new MWF.widget.Maplist(mapNode, {
  734. "title": k,
  735. "collapse": true,
  736. "onChange": function () {
  737. // var oldData = _self.data[name];
  738. var oldData = this.data;
  739. Array.each(name.split("."), function (n) {
  740. if (oldData) oldData = oldData[n];
  741. });
  742. maps.each(function (o) {
  743. d[o.key] = o.map.toJson();
  744. }.bind(this));
  745. _self.changeData(name, node, oldData);
  746. }
  747. });
  748. maps.push({"key": k, "map": maplist});
  749. maplist.load(v);
  750. }.bind(this));
  751. }.bind(this));
  752. }.bind(this));
  753. },
  754. loadMaplist: function(){
  755. var maplists = this.propertyContent.getElements(".MWFMaplist");
  756. debugger;
  757. maplists.each(function(node){
  758. var title = node.get("title");
  759. var name = node.get("name");
  760. var collapse = node.get("collapse");
  761. var mapObj = this.data[name];
  762. if (!mapObj) mapObj = {};
  763. MWF.require("MWF.widget.Maplist", function(){
  764. node.empty();
  765. var maplist = new MWF.widget.Maplist(node, {
  766. "title": title,
  767. "collapse": (collapse) ? true : false,
  768. "onChange": function(){
  769. //this.data[name] = maplist.toJson();
  770. //
  771. var oldData = this.data[name];
  772. this.changeJsonDate(name, maplist.toJson());
  773. this.changeStyle(name, oldData);
  774. this.changeData(name);
  775. }.bind(this),
  776. "onDelete": function(key){
  777. debugger;
  778. this.module.deletePropertiesOrStyles(name, key);
  779. }.bind(this)
  780. });
  781. maplist.load(mapObj);
  782. this.maplists[name] = maplist;
  783. }.bind(this));
  784. }.bind(this));
  785. },
  786. loadActionStylesArea: function () {
  787. var _self = this;
  788. var actionAreas = this.propertyContent.getElements(".MWFActionStylesArea");
  789. actionAreas.each(function (node) {
  790. var name = node.get("name");
  791. var actionStyles = this.data[name];
  792. MWF.require("MWF.widget.Maplist", function () {
  793. var maps = [];
  794. Object.each(actionStyles, function (v, k) {
  795. var mapNode = new Element("div").inject(node);
  796. mapNode.empty();
  797. var maplist = new MWF.widget.Maplist(mapNode, {
  798. "title": k,
  799. "collapse": true,
  800. "onChange": function () {
  801. var oldData = _self.data[name];
  802. maps.each(function (o) {
  803. _self.data[name][o.key] = o.map.toJson();
  804. }.bind(this));
  805. _self.changeData(name, node, oldData);
  806. }
  807. });
  808. maps.push({"key": k, "map": maplist});
  809. maplist.load(v);
  810. }.bind(this));
  811. }.bind(this));
  812. }.bind(this));
  813. },
  814. loadPagingStylesArea: function () {
  815. var _self = this;
  816. var pagingAreas = this.propertyContent.getElements(".MWFPagingStylesArea");
  817. pagingAreas.each(function (node) {
  818. var name = node.get("name");
  819. var pagingStyles = this.data[name];
  820. MWF.require("MWF.widget.Maplist", function () {
  821. var maps = [];
  822. Object.each(pagingStyles, function (v, k) {
  823. var mapNode = new Element("div").inject(node);
  824. mapNode.empty();
  825. var maplist = new MWF.widget.Maplist(mapNode, {
  826. "title": k,
  827. "collapse": true,
  828. "onChange": function () {
  829. var oldData = _self.data[name];
  830. maps.each(function (o) {
  831. _self.data[name][o.key] = o.map.toJson();
  832. }.bind(this));
  833. _self.changeData(name, node, oldData);
  834. }
  835. });
  836. maps.push({"key": k, "map": maplist});
  837. maplist.load(v);
  838. }.bind(this));
  839. }.bind(this));
  840. }.bind(this));
  841. },
  842. loadEventsEditor: function () {
  843. MWF.xApplication.process = MWF.xApplication.process || {};
  844. MWF.APPFD = MWF.xApplication.process.FormDesigner = MWF.xApplication.process.FormDesigner || {};
  845. MWF.xDesktop.requireApp("process.FormDesigner", "lp." + o2.language, null, false);
  846. var events = this.propertyContent.getElement(".MWFEventsArea");
  847. if (events) {
  848. var name = events.get("name");
  849. var eventsObj = this.data;
  850. Array.each(name.split("."), function (n) {
  851. if (eventsObj) eventsObj = eventsObj[n];
  852. })
  853. MWF.xDesktop.requireApp("process.FormDesigner", "widget.EventsEditor", function () {
  854. var eventsEditor = new MWF.xApplication.process.FormDesigner.widget.EventsEditor(events, this.designer, {
  855. //"maxObj": this.propertyNode.parentElement.parentElement.parentElement,
  856. "maxObj": this.designer.contentNode
  857. });
  858. eventsEditor.load(eventsObj, this.data, name);
  859. }.bind(this));
  860. }
  861. },
  862. loadActionArea: function () {
  863. debugger;
  864. MWF.xApplication.process = MWF.xApplication.process || {};
  865. MWF.APPFD = MWF.xApplication.process.FormDesigner = MWF.xApplication.process.FormDesigner || {};
  866. MWF.xDesktop.requireApp("process.FormDesigner", "lp." + o2.language, null, false);
  867. var multiActionArea = this.propertyContent.getElements(".MWFMultiActionArea");
  868. multiActionArea.each(function(node){
  869. var name = node.get("name");
  870. var actionContent = this.data[name];
  871. MWF.xDesktop.requireApp("process.FormDesigner", "widget.ActionsEditor", function(){
  872. var actionEditor = new MWF.xApplication.process.FormDesigner.widget.ActionsEditor(node, this.designer, this.data, {
  873. "maxObj": this.propertyNode.parentElement.parentElement.parentElement,
  874. "isSystemTool" : 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(".MWFActionArea");
  884. actionAreas.each(function (node) {
  885. var name = node.get("name");
  886. var actionContent = this.data[name];
  887. MWF.xDesktop.requireApp("process.FormDesigner", "widget.ActionsEditor", function () {
  888. // debugger;
  889. // var actionEditor = new MWF.xApplication.process.FormDesigner.widget.ActionsEditor(node, this.designer, {
  890. // "maxObj": this.propertyNode.parentElement.parentElement.parentElement,
  891. // "noCreate": true,
  892. // "noDelete": true,
  893. // "noCode": true,
  894. // "onChange": function(){
  895. // this.data[name] = actionEditor.data;
  896. // }.bind(this)
  897. // });
  898. // actionEditor.load(this.module.defaultToolBarsData);
  899. var actionEditor = new MWF.xApplication.process.FormDesigner.widget.ActionsEditor(node, this.designer, this.data, {
  900. "maxObj": this.propertyNode.parentElement.parentElement,
  901. "noEditShow": true,
  902. "noReadShow": true,
  903. "onChange": function () {
  904. this.data[name] = actionEditor.data;
  905. this.changeData(name);
  906. }.bind(this)
  907. });
  908. actionEditor.load(actionContent);
  909. }.bind(this));
  910. }.bind(this));
  911. var actionAreas = this.propertyContent.getElements(".MWFDefaultActionArea");
  912. actionAreas.each(function (node) {
  913. var name = node.get("name");
  914. var actionContent = this.data[name] || this.module.defaultToolBarsData;
  915. MWF.xDesktop.requireApp("process.FormDesigner", "widget.ActionsEditor", function () {
  916. var actionEditor = new MWF.xApplication.process.FormDesigner.widget.ActionsEditor(node, this.designer, this.data, {
  917. "maxObj": this.propertyNode.parentElement.parentElement,
  918. "isSystemTool": true,
  919. "systemToolsAddress": "../x_component_query_ViewDesigner/$View/toolbars.json",
  920. "noCreate": true,
  921. "noDelete": false,
  922. "noCode": true,
  923. "noReadShow": true,
  924. "noEditShow": true,
  925. "onChange": function () {
  926. this.data[name] = actionEditor.data;
  927. this.changeData(name);
  928. }.bind(this)
  929. });
  930. actionEditor.load(actionContent);
  931. // var actionEditor = new MWF.xApplication.process.FormDesigner.widget.ActionsEditor(node, this.designer, {
  932. // "maxObj": this.propertyNode.parentElement.parentElement.parentElement,
  933. // "onChange": function(){
  934. // this.data[name] = actionEditor.data;
  935. // }.bind(this)
  936. // });
  937. // actionEditor.load(actionContent);
  938. }.bind(this));
  939. }.bind(this));
  940. },
  941. loadStylesList: function () {
  942. var styleSelNodes = this.propertyContent.getElements(".MWFViewStyle");
  943. styleSelNodes.each(function (node) {
  944. debugger;
  945. if (this.module.stylesList) {
  946. if (!this.data.data.viewStyleType) this.data.data.viewStyleType = "default";
  947. // var mode = ( this.form.options.mode || "" ).toLowerCase() === "mobile" ? "mobile" : "pc";
  948. Object.each(this.module.stylesList, function (s, key) {
  949. // if( s.mode.contains( mode ) ){
  950. new Element("option", {
  951. "text": s.name,
  952. "value": key,
  953. "selected": ((!this.data.data.viewStyleType && key == "default") || (this.data.data.viewStyleType == key))
  954. }).inject(node)
  955. // }
  956. }.bind(this));
  957. } else {
  958. node.getParent("tr").setStyle("display", "none");
  959. }
  960. }.bind(this));
  961. }
  962. //initWhereEntryData: function(){
  963. // if (!this.data.data.restrictWhereEntry) this.data.data.restrictWhereEntry = {
  964. // "applicationList": [],
  965. // "processList": [],
  966. // "companyList": [],
  967. // "departmentList": [],
  968. // "personList": [],
  969. // "identityList": []
  970. // };
  971. //},
  972. //loadApplicationSelector: function(){
  973. // var nodes = this.propertyContent.getElements(".MWFApplicationSelect");
  974. // if (nodes.length){
  975. // MWF.xDesktop.requireApp("Organization", "Selector.package", function(){
  976. // nodes.each(function(node){
  977. // var title = new Element("div", {"styles": this.view.css.applicationSelectTitle, "text": node.get("title")}).inject(node);
  978. // var content = new Element("div", {"styles": this.view.css.applicationSelectContent}).inject(node);
  979. // var action = new Element("div", {"styles": this.view.css.applicationSelectAction, "text": node.get("title")}).inject(node);
  980. // action.addEvent("click", function(e){
  981. // var values = [];
  982. // if (this.data.data.whereEntry){
  983. // if (this.data.data.whereEntry.applicationList.length){
  984. // this.data.data.whereEntry.applicationList.each(function(item){
  985. // values.push(item.id);
  986. // }.bind(this));
  987. // }
  988. // }
  989. // var options = {
  990. // "type": "application",
  991. // "count": 0,
  992. // "values": values,
  993. // //"title": this.app.lp.monthly.selectSortApplication,
  994. // "onComplete": function(items){
  995. // this.initWhereEntryData();
  996. // this.data.data.whereEntry.applicationList = [];
  997. // content.empty();
  998. // items.each(function(item){
  999. // this.data.data.whereEntry.applicationList.push({
  1000. // "id": item.data.id,
  1001. // "name": item.data.name
  1002. // });
  1003. // new Element("div", {
  1004. // "styles": this.view.css.applicationSelectItem,
  1005. // "text": item.data.name
  1006. // }).inject(content);
  1007. // }.bind(this));
  1008. // }.bind(this)
  1009. // };
  1010. // var selector = new MWF.OrgSelector(this.view.designer.content, options);
  1011. // }.bind(this));
  1012. //
  1013. // this.initWhereEntryData();
  1014. // this.data.data.whereEntry.applicationList.each(function(app){
  1015. // new Element("div", {
  1016. // "styles": this.view.css.applicationSelectItem,
  1017. // "text": app.name
  1018. // }).inject(content);
  1019. // }.bind(this));
  1020. // }.bind(this));
  1021. // }.bind(this));
  1022. // }
  1023. //},
  1024. //loadApplicationSelector1: function(){
  1025. // var nodes = this.propertyContent.getElements(".MWFApplicationSelect");
  1026. // if (nodes.length){
  1027. // this._getAppSelector(function(){
  1028. // nodes.each(function(node){
  1029. // var title = new Element("div", {"styles": this.view.css.applicationSelectTitle, "text": node.get("title")}).inject(node);
  1030. // var content = new Element("div", {"styles": this.view.css.applicationSelectContent}).inject(node);
  1031. // var action = new Element("div", {"styles": this.view.css.applicationSelectAction, "text": node.get("title")}).inject(node);
  1032. // action.addEvent("click", function(e){
  1033. // this.appSelector.load(function(apps){
  1034. // if (!this.data.data.select) this.data.data.select = {"applicationRestrictList": [], "processRestrictList": []};
  1035. // this.data.data.select.applicationRestrictList = [];
  1036. // content.empty();
  1037. // if (apps.length){
  1038. // apps.each(function(app){
  1039. // var o = {
  1040. // "name": app.name,
  1041. // "id": app.id,
  1042. // "alias": app.alias
  1043. // }
  1044. // this.data.data.select.applicationRestrictList.push(o);
  1045. //
  1046. // new Element("div", {
  1047. // "styles": this.view.css.applicationSelectItem,
  1048. // "text": app.name
  1049. // }).inject(content);
  1050. //
  1051. // }.bind(this));
  1052. // }
  1053. // }.bind(this));
  1054. // }.bind(this));
  1055. // if (!this.data.data.select) this.data.data.select = {"applicationRestrictList": [], "processRestrictList": []};
  1056. // this.data.data.select.applicationRestrictList.each(function(app){
  1057. // new Element("div", {
  1058. // "styles": this.view.css.applicationSelectItem,
  1059. // "text": app.name
  1060. // }).inject(content);
  1061. // }.bind(this));
  1062. //
  1063. // }.bind(this));
  1064. // }.bind(this));
  1065. // }
  1066. //},
  1067. //
  1068. //_getAppSelector: function(callback){
  1069. // if (!this.appSelector){
  1070. // MWF.xDesktop.requireApp("process.ProcessManager", "widget.ApplicationSelector", function(){
  1071. // this.appSelector = new MWF.xApplication.process.ProcessManager.widget.ApplicationSelector(this.view.designer, {"maskNode": this.view.designer.content});
  1072. // if (callback) callback();
  1073. // }.bind(this));
  1074. // }else{
  1075. // if (callback) callback();
  1076. // }
  1077. //},
  1078. //this.initWhereEntryData();
  1079. //loadProcessSelector: function(){
  1080. // var nodes = this.propertyContent.getElements(".MWFApplicationSelect");
  1081. // if (nodes.length){
  1082. // MWF.xDesktop.requireApp("Organization", "Selector.package", function(){
  1083. // nodes.each(function(node){
  1084. // var title = new Element("div", {"styles": this.view.css.applicationSelectTitle, "text": node.get("title")}).inject(node);
  1085. // var content = new Element("div", {"styles": this.view.css.applicationSelectContent}).inject(node);
  1086. // var action = new Element("div", {"styles": this.view.css.applicationSelectAction, "text": node.get("title")}).inject(node);
  1087. // action.addEvent("click", function(e){
  1088. // var values = [];
  1089. // if (this.data.data.whereEntry){
  1090. // if (this.data.data.whereEntry.processList.length){
  1091. // this.data.data.whereEntry.processList.each(function(item){
  1092. // values.push(item.id);
  1093. // }.bind(this));
  1094. // }
  1095. // }
  1096. // var options = {
  1097. // "type": "process",
  1098. // "count": 0,
  1099. // "values": values,
  1100. // "onComplete": function(items){
  1101. // this.initWhereEntryData();
  1102. // this.data.data.whereEntry.processList = [];
  1103. // content.empty();
  1104. // items.each(function(item){
  1105. // this.data.data.whereEntry.processList.push({
  1106. // "id": item.data.id,
  1107. // "name": item.data.name
  1108. // });
  1109. // new Element("div", {
  1110. // "styles": this.view.css.applicationSelectItem,
  1111. // "text": item.data.name
  1112. // }).inject(content);
  1113. // }.bind(this));
  1114. // }.bind(this)
  1115. // };
  1116. // var selector = new MWF.OrgSelector(this.view.designer.content, options);
  1117. // }.bind(this));
  1118. //
  1119. // this.initWhereEntryData();
  1120. // this.data.data.whereEntry.processList.each(function(app){
  1121. // new Element("div", {
  1122. // "styles": this.view.css.applicationSelectItem,
  1123. // "text": app.name
  1124. // }).inject(content);
  1125. // }.bind(this));
  1126. // }.bind(this));
  1127. // }.bind(this));
  1128. // }
  1129. //}
  1130. //loadProcessSelector1: function(){
  1131. // var nodes = this.propertyContent.getElements(".MWFProcessSelect");
  1132. // if (nodes.length){
  1133. // this._getProcessSelector(function(){
  1134. // nodes.each(function(node){
  1135. // var title = new Element("div", {"styles": this.view.css.applicationSelectTitle, "text": node.get("title")}).inject(node);
  1136. // var content = new Element("div", {"styles": this.view.css.applicationSelectContent}).inject(node);
  1137. // var action = new Element("div", {"styles": this.view.css.applicationSelectAction, "text": node.get("title")}).inject(node);
  1138. // action.addEvent("click", function(e){
  1139. // var ids=[];
  1140. // this.data.data.select.applicationRestrictList.each(function(app){
  1141. // ids.push(app.id);
  1142. // });
  1143. // this.processSelector.load(ids, function(apps){
  1144. // if (!this.data.data.select) this.data.data.select = {"applicationRestrictList": [], "processRestrictList": []};
  1145. // this.data.data.select.processRestrictList = [];
  1146. // content.empty();
  1147. // if (apps.length){
  1148. // apps.each(function(app){
  1149. // var o = {
  1150. // "name": app.name,
  1151. // "id": app.id,
  1152. // "alias": app.alias
  1153. // }
  1154. // this.data.data.select.processRestrictList.push(o);
  1155. //
  1156. // new Element("div", {
  1157. // "styles": this.view.css.applicationSelectItem,
  1158. // "text": app.name
  1159. // }).inject(content);
  1160. //
  1161. // }.bind(this));
  1162. // }
  1163. // }.bind(this));
  1164. // }.bind(this));
  1165. // if (!this.data.data.select) this.data.data.select = {"applicationRestrictList": [], "processRestrictList": []};
  1166. // this.data.data.select.processRestrictList.each(function(app){
  1167. // new Element("div", {
  1168. // "styles": this.view.css.applicationSelectItem,
  1169. // "text": app.name
  1170. // }).inject(content);
  1171. // }.bind(this));
  1172. //
  1173. // }.bind(this));
  1174. // }.bind(this));
  1175. // }
  1176. //},
  1177. //_getProcessSelector: function(callback){
  1178. // if (!this.processSelector){
  1179. // MWF.xDesktop.requireApp("process.ProcessManager", "widget.ProcessSelector", function(){
  1180. // this.processSelector = new MWF.xApplication.process.ProcessManager.widget.ProcessSelector(this.view.designer, {"maskNode": this.view.designer.content});
  1181. // if (callback) callback();
  1182. // }.bind(this));
  1183. // }else{
  1184. // if (callback) callback();
  1185. // }
  1186. //}
  1187. });
  1188. MWF.xApplication.query.ViewDesigner.Property.Filter = new Class({
  1189. Implements: [Events],
  1190. initialize: function (json, table, property) {
  1191. this.property = property;
  1192. this.module = property.module;
  1193. this.table = table;
  1194. this.data = json;
  1195. this.load();
  1196. },
  1197. load: function () {
  1198. this.node = new Element("tr", {"styles": this.module.css.filterTableTd}).inject(this.table);
  1199. var html = "<td style='widtd:24px;border-right:1px solid #CCC;border-bottom:1px solid #999;'></td>" +
  1200. "<td style='padding:3px;border-right:1px solid #CCC;border-bottom:1px solid #999; width:60px'>" + this.data.logic + "</td>" +
  1201. "<td style='padding:3px;border-right:1px solid #CCC;border-bottom:1px solid #999; width:30px'>列值</td>" +
  1202. "<td style='padding:3px;border-right:1px solid #CCC;border-bottom:1px solid #999;'>" + this.data.comparison + "</td>" +
  1203. "<td style='padding:3px;border-bottom:1px solid #999;'>" + this.data.value + "</td>";
  1204. this.node.set("html", html);
  1205. var tds = this.node.getElements("td");
  1206. this.delActionNode = new Element("div", {"styles": this.module.css.filterDelActionNode}).inject(tds[0]);
  1207. this.delActionNode.addEvent("click", function (e) {
  1208. this.delFilter(e);
  1209. e.stopPropagation();
  1210. }.bind(this));
  1211. this.logicNode = tds[1];
  1212. this.comparisonNode = tds[3];
  1213. this.valueNode = tds[4];
  1214. this.node.addEvent("click", function () {
  1215. if (!this.isEditMode) this.editMode();
  1216. }.bind(this));
  1217. this.node.addEvent("blur", function () {
  1218. if (this.isEditMode) this.readMode();
  1219. }.bind(this));
  1220. },
  1221. delFilter: function (e) {
  1222. var _self = this;
  1223. this.property.designer.confirm("warn", e, MWF.APPDVD.LP.notice.deleteFilterTitle, MWF.APPDVD.LP.notice.deleteFilter, 300, 120, function () {
  1224. _self.node.destroy();
  1225. _self.property.data.filterList.erase(_self.data);
  1226. MWF.release(_self);
  1227. this.close();
  1228. }, function () {
  1229. this.close();
  1230. }, null);
  1231. },
  1232. editMode: function () {
  1233. if (this.property.editModeFilter) {
  1234. if (this.property.editModeFilter != this) this.property.editModeFilter.readMode();
  1235. }
  1236. var width = this.logicNode.getSize().x - 9;
  1237. this.logicNode.empty();
  1238. var logicSelect = new Element("select", {"styles": {"width": "90%"}}).inject(this.logicNode);
  1239. var html = "";
  1240. if (this.data.logic == "and") {
  1241. html = "<option value=\"and\" selected>and</option><option value=\"or\">or</option>";
  1242. } else {
  1243. html = "<option value=\"and\">and</option><option value=\"or\" selected>or</option>";
  1244. }
  1245. logicSelect.set("html", html);
  1246. logicSelect.addEvent("change", function () {
  1247. this.data.logic = logicSelect.options[logicSelect.selectedIndex].value;
  1248. }.bind(this));
  1249. width = this.comparisonNode.getSize().x - 9;
  1250. this.comparisonNode.empty();
  1251. var comparisonSelect = new Element("select", {"styles": {"width": "90%"}}).inject(this.comparisonNode);
  1252. html = "";
  1253. switch (this.property.data.type) {
  1254. case "text":
  1255. html += "<option value=''></option><option value='==' " + ((this.data.comparison == "==") ? "selected" : "") + ">等于(==)</option>" +
  1256. "<option value='!=' " + ((this.data.comparison == "!=") ? "selected" : "") + ">不等于(!=)</option>" +
  1257. "<option value='@' " + ((this.data.comparison == "@") ? "selected" : "") + ">包含(@)</option>";
  1258. break;
  1259. case "date":
  1260. html += "<option value=''></option><option value='&gt;' " + ((this.data.comparison == ">") ? "selected" : "") + ">大于(&gt;)</option>" +
  1261. "<option value='&lt;' " + ((this.data.comparison == "<") ? "selected" : "") + ">小于(&lt;)</option>" +
  1262. "<option value='&gt;=' " + ((this.data.comparison == ">=") ? "selected" : "") + ">大于等于(&gt;=)</option>" +
  1263. "<option value='&lt;=' " + ((this.data.comparison == "<=") ? "selected" : "") + ">小于等于(&lt;=)</option>";
  1264. break;
  1265. case "number":
  1266. html += "<option value=''></option><option value='==' " + ((this.data.comparison == "==") ? "selected" : "") + ">等于(==)</option>" +
  1267. "<option value='!=' " + ((this.data.comparison == "!=") ? "selected" : "") + ">不等于(!=)</option>" +
  1268. "<option value='&gt;' " + ((this.data.comparison == ">") ? "selected" : "") + ">大于(&gt;)</option>" +
  1269. "<option value='&lt;' " + ((this.data.comparison == "<") ? "selected" : "") + ">小于(&lt;)</option>" +
  1270. "<option value='&gt;=' " + ((this.data.comparison == ">=") ? "selected" : "") + ">大于等于(&gt;=)</option>" +
  1271. "<option value='&lt;=' " + ((this.data.comparison == "<=") ? "selected" : "") + ">小于等于(&lt;=)</option>";
  1272. break;
  1273. case "boolean":
  1274. html += "<option value=''></option><option value='==' " + ((this.data.comparison == "==") ? "selected" : "") + ">等于(==)</option>" +
  1275. "<option value='!=' " + ((this.data.comparison == "!=") ? "selected" : "") + ">不等于(!=)</option>";
  1276. break;
  1277. }
  1278. comparisonSelect.set("html", html);
  1279. comparisonSelect.addEvent("change", function () {
  1280. this.data.comparison = comparisonSelect.options[comparisonSelect.selectedIndex].value;
  1281. }.bind(this));
  1282. width = this.valueNode.getSize().x - 9;
  1283. this.valueNode.empty();
  1284. var type = "text";
  1285. switch (this.property.data.type) {
  1286. case "date":
  1287. var valueInput = new Element("input", {
  1288. "styles": {"width": "90%"},
  1289. "type": "text",
  1290. "value": this.data.value
  1291. }).inject(this.valueNode);
  1292. MWF.require("MWF.widget.Calendar", function () {
  1293. this.calendar = new MWF.widget.Calendar(valueInput, {
  1294. "style": "xform",
  1295. "isTime": true,
  1296. "secondEnable": true,
  1297. "target": this.property.designer.content,
  1298. "format": "%Y-%m-%d %H:%M:%S"
  1299. });
  1300. //this.calendar.show();
  1301. }.bind(this));
  1302. break;
  1303. case "number":
  1304. var valueInput = new Element("input", {
  1305. "styles": {"width": "90%"},
  1306. "type": "number",
  1307. "value": this.data.value
  1308. }).inject(this.valueNode);
  1309. break;
  1310. case "boolean":
  1311. var valueInput = new Element("select", {
  1312. "styles": {"width": "" + width + "px"},
  1313. "html": "<option value=\"\"></option><option value=\"true\" " + ((this.data.value) ? "selected" : "") + ">true</option><option value=\"false\" " + ((!this.data.value) ? "selected" : "") + ">false</option>"
  1314. }).inject(this.valueNode);
  1315. break;
  1316. default:
  1317. var valueInput = new Element("input", {
  1318. "styles": {"width": "90%"},
  1319. "type": "text",
  1320. "value": this.data.value
  1321. }).inject(this.valueNode);
  1322. }
  1323. if (valueInput.tagName.toLowerCase() == "select") {
  1324. valueInput.addEvent("change", function () {
  1325. var v = valueInput.options[valueInput.selectedIndex].value;
  1326. this.data.value = (v = "true") ? true : false;
  1327. }.bind(this));
  1328. } else {
  1329. valueInput.addEvent("change", function (e) {
  1330. this.data.value = valueInput.get("value");
  1331. }.bind(this));
  1332. valueInput.addEvent("blur", function (e) {
  1333. this.data.value = valueInput.get("value");
  1334. }.bind(this));
  1335. valueInput.addEvent("keydown", function (e) {
  1336. if (e.code == 13) {
  1337. this.data.value = valueInput.get("value");
  1338. this.readMode();
  1339. }
  1340. e.stopPropagation();
  1341. }.bind(this));
  1342. }
  1343. this.isEditMode = true;
  1344. this.property.editModeFilter = this;
  1345. },
  1346. readMode: function () {
  1347. if (this.isEditMode) {
  1348. var logicSelect = this.logicNode.getElement("select");
  1349. this.data.logic = logicSelect.options[logicSelect.selectedIndex].value;
  1350. var comparisonSelect = this.comparisonNode.getElement("select");
  1351. this.data.comparison = comparisonSelect.options[comparisonSelect.selectedIndex].value;
  1352. var valueInput = this.valueNode.getFirst();
  1353. if (valueInput.tagName.toLowerCase() == "select") {
  1354. var v = valueInput.options[valueInput.selectedIndex].value;
  1355. this.data.value = (v = "true") ? true : false;
  1356. } else {
  1357. this.data.value = valueInput.get("value");
  1358. }
  1359. this.logicNode.empty();
  1360. this.comparisonNode.empty();
  1361. this.valueNode.empty();
  1362. this.logicNode.set("text", this.data.logic);
  1363. this.comparisonNode.set("text", this.data.comparison);
  1364. this.valueNode.set("text", this.data.value);
  1365. this.isEditMode = false;
  1366. this.property.editModeFilter = null;
  1367. }
  1368. }
  1369. });