Property.js 60 KB

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