Property.js 65 KB

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