Property.js 66 KB

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