Property.js 60 KB

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