Property.js 63 KB

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