Property.js 45 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020
  1. MWF.require("MWF.widget.Common", null, false);
  2. MWF.require("MWF.widget.JsonTemplate", null, false);
  3. MWF.xApplication.process.ViewDesigner.Property = MWF.FVProperty = new Class({
  4. Extends: MWF.widget.Common,
  5. Implements: [Options, Events],
  6. options: {
  7. "style": "default",
  8. "path": "/x_component_process_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.htmlPath = this.options.path;
  16. this.designer = designer;
  17. this.propertyNode = propertyNode;
  18. },
  19. load: function(){
  20. if (this.fireEvent("queryLoad")){
  21. MWF.getRequestText(this.htmlPath, function(responseText, responseXML){
  22. this.htmlString = responseText;
  23. this.fireEvent("postLoad");
  24. }.bind(this));
  25. }
  26. this.propertyNode.addEvent("keydown", function(e){e.stopPropagation();});
  27. },
  28. editProperty: function(td){
  29. },
  30. getHtmlString: function(callback){
  31. if (!this.htmlString){
  32. MWF.getRequestText(this.htmlPath, function(responseText, responseXML){
  33. this.htmlString = responseText;
  34. if (callback) callback();
  35. }.bind(this));
  36. }else{
  37. if (callback) callback();
  38. }
  39. },
  40. show: function(){
  41. if (!this.propertyContent){
  42. this.getHtmlString(function(){
  43. if (this.htmlString){
  44. this.JsonTemplate = new MWF.widget.JsonTemplate(this.data, this.htmlString);
  45. this.propertyContent = new Element("div", {"styles": {"overflow": "hidden"}}).inject(this.propertyNode);
  46. this.propertyContent.set("html", this.JsonTemplate.load());
  47. this.setEditNodeEvent();
  48. this.setEditNodeStyles(this.propertyContent);
  49. this.loadPropertyTab();
  50. this.loadPersonInput();
  51. this.loadViewFilter();
  52. this.loadColumnExportEditor();
  53. this.loadJSONArea();
  54. }
  55. }.bind(this));
  56. }else{
  57. this.propertyContent.setStyle("display", "block");
  58. }
  59. },
  60. hide: function(){
  61. //this.JsonTemplate = null;
  62. //this.propertyNode.set("html", "");
  63. if (this.propertyContent) this.propertyContent.setStyle("display", "none");
  64. },
  65. loadJSONArea: function(){
  66. var jsonNode = this.propertyContent.getElement(".MWFJSONArea");
  67. if (jsonNode){
  68. this.propertyTab.pages.each(function(page){
  69. if (page.contentNode == jsonNode.parentElement){
  70. page.setOptions({
  71. "onShow": function(){
  72. jsonNode.empty();
  73. MWF.require("MWF.widget.JsonParse", function(){
  74. this.json = new MWF.widget.JsonParse(this.module.json, jsonNode, null);
  75. this.json.load();
  76. }.bind(this));
  77. }.bind(this)
  78. });
  79. }
  80. }.bind(this));
  81. }
  82. },
  83. loadPropertyTab: function(){
  84. var tabNodes = this.propertyContent.getElements(".MWFTab");
  85. if (tabNodes.length){
  86. var tmpNode = this.propertyContent.getFirst();
  87. var tabAreaNode = new Element("div", {
  88. "styles": this.view.css.propertyTabNode
  89. }).inject(tmpNode, "before");
  90. MWF.require("MWF.widget.Tab", function(){
  91. var tab = new MWF.widget.Tab(tabAreaNode, {"style": "formPropertyList"});
  92. tab.load();
  93. var tabPages = [];
  94. tabNodes.each(function(node){
  95. var page = tab.addTab(node, node.get("title"), false);
  96. tabPages.push(page);
  97. this.setScrollBar(page.contentNodeArea, "small", null, null);
  98. }.bind(this));
  99. tabPages[0].showTab();
  100. this.propertyTab = tab;
  101. this.designer.resizeNode();
  102. }.bind(this), false);
  103. }
  104. },
  105. setEditNodeEvent: function(){
  106. var property = this;
  107. // var inputs = this.process.propertyListNode.getElements(".editTableInput");
  108. var inputs = this.propertyContent.getElements("input");
  109. inputs.each(function(input){
  110. var jsondata = input.get("name");
  111. if (jsondata && jsondata.substr(0,1)!="_"){
  112. if (this.module){
  113. var id = this.module.json.id;
  114. input.set("name", id+jsondata);
  115. }
  116. if (jsondata){
  117. var inputType = input.get("type").toLowerCase();
  118. switch (inputType){
  119. case "radio":
  120. input.addEvent("change", function(e){
  121. property.setRadioValue(jsondata, this);
  122. });
  123. input.addEvent("blur", function(e){
  124. property.setRadioValue(jsondata, this);
  125. });
  126. input.addEvent("keydown", function(e){
  127. e.stopPropagation();
  128. });
  129. property.setRadioValue(jsondata, input);
  130. break;
  131. case "checkbox":
  132. input.addEvent("change", function(e){
  133. property.setCheckboxValue(jsondata, this);
  134. });
  135. input.addEvent("click", function(e){
  136. property.setCheckboxValue(jsondata, this);
  137. });
  138. input.addEvent("keydown", function(e){
  139. e.stopPropagation();
  140. });
  141. break;
  142. default:
  143. input.addEvent("change", function(e){
  144. property.setValue(jsondata, this.value, this);
  145. });
  146. input.addEvent("blur", function(e){
  147. property.setValue(jsondata, this.value, this);
  148. });
  149. input.addEvent("keydown", function(e){
  150. if (e.code==13){
  151. property.setValue(jsondata, this.value, this);
  152. }
  153. e.stopPropagation();
  154. });
  155. if (input.hasClass("editTableInputDate")){
  156. this.loadCalendar(input);
  157. }
  158. }
  159. }
  160. }
  161. }.bind(this));
  162. var selects = this.propertyContent.getElements("select");
  163. selects.each(function(select){
  164. var jsondata = select.get("name");
  165. if (jsondata){
  166. select.addEvent("change", function(e){
  167. property.setSelectValue(jsondata, this);
  168. });
  169. }
  170. });
  171. var textareas = this.propertyContent.getElements("textarea");
  172. textareas.each(function(input){
  173. var jsondata = input.get("name");
  174. if (jsondata){
  175. input.addEvent("change", function(e){
  176. property.setValue(jsondata, this.value);
  177. });
  178. input.addEvent("blur", function(e){
  179. property.setValue(jsondata, this.value);
  180. });
  181. input.addEvent("keydown", function(e){
  182. e.stopPropagation();
  183. });
  184. }
  185. }.bind(this));
  186. },
  187. loadCalendar: function(node){
  188. MWF.require("MWF.widget.Calendar", function(){
  189. this.calendar = new MWF.widget.Calendar(node, {
  190. "style": "xform",
  191. "isTime": false,
  192. "target": this.module.designer.content,
  193. "format": "%Y-%m-%d",
  194. "onComplate": function(){
  195. //this.validationMode();
  196. //this.validation();
  197. //this.fireEvent("complete");
  198. }.bind(this)
  199. });
  200. //this.calendar.show();
  201. }.bind(this));
  202. },
  203. changeStyle: function(name){
  204. this.module.setPropertiesOrStyles(name);
  205. },
  206. changeData: function(name, input, oldValue){
  207. this.module._setEditStyle(name, input, oldValue);
  208. },
  209. changeJsonDate: function(key, value){
  210. if (typeOf(key)!="array") key = [key];
  211. var o = this.data;
  212. var len = key.length-1;
  213. key.each(function(n, i){
  214. if (!o[n]) o[n] = {};
  215. if (i<len) o = o[n];
  216. }.bind(this));
  217. o[key[len]] = value;
  218. },
  219. setRadioValue: function(name, input){
  220. if (input.checked){
  221. var i = name.indexOf("*");
  222. var names = (i==-1) ? name.split(".") : name.substr(i+1, name.length).split(".");
  223. var value = input.value;
  224. if (value=="false") value = false;
  225. if (value=="true") value = true;
  226. var oldValue = this.data;
  227. for (var idx = 0; idx<names.length; idx++){
  228. if (!oldValue[names[idx]]){
  229. oldValue = null;
  230. break;
  231. }else{
  232. oldValue = oldValue[names[idx]];
  233. }
  234. }
  235. //var oldValue = this.data[name];
  236. this.changeJsonDate(names, value);
  237. this.changeData(name, input, oldValue);
  238. }
  239. },
  240. setCheckboxValue: function(name, input){
  241. var id = this.module.json.id;
  242. var checkboxList = $$("input[name='"+id+name+"']");
  243. var values = [];
  244. checkboxList.each(function(checkbox){
  245. if (checkbox.get("checked")){
  246. values.push(checkbox.value);
  247. }
  248. });
  249. var oldValue = this.data[name];
  250. //this.data[name] = values;
  251. this.changeJsonDate(name, values);
  252. this.changeData(name, input, oldValue);
  253. },
  254. setSelectValue: function(name, select){
  255. var idx = select.selectedIndex;
  256. var options = select.getElements("option");
  257. var value = "";
  258. if (options[idx]){
  259. value = options[idx].get("value");
  260. }
  261. var oldValue = this.data[name];
  262. //this.data[name] = value;
  263. this.changeJsonDate(name, value);
  264. this.changeData(name, select, oldValue);
  265. },
  266. setValue: function(name, value, obj){
  267. var names = name.split(".");
  268. var oldValue = this.data;
  269. for (var idx = 0; idx<names.length; idx++){
  270. if (!oldValue[names[idx]]){
  271. oldValue = null;
  272. break;
  273. }else{
  274. oldValue = oldValue[names[idx]];
  275. }
  276. }
  277. //var oldValue = this.data[name];
  278. //this.data[name] = value;
  279. this.changeJsonDate(names, value);
  280. this.changeData(name, obj, oldValue);
  281. },
  282. setEditNodeStyles: function(node){
  283. var nodes = node.getChildren();
  284. if (nodes.length){
  285. nodes.each(function(el){
  286. var cName = el.get("class");
  287. if (cName){
  288. if (this.view.css[cName]) el.setStyles(this.view.css[cName]);
  289. }
  290. this.setEditNodeStyles(el);
  291. }.bind(this));
  292. }
  293. },
  294. loadPersonInput: function(){
  295. var applicationNodes = this.propertyContent.getElements(".MWFSelectApplication");
  296. var processNodes = this.propertyContent.getElements(".MWFSelectProcess");
  297. var companyNodes = this.propertyContent.getElements(".MWFSelectCompany");
  298. var departmentNodes = this.propertyContent.getElements(".MWFSelectDepartment");
  299. var personNodes = this.propertyContent.getElements(".MWFSelectPerson");
  300. var identityNodes = this.propertyContent.getElements(".MWFSelectIdentity");
  301. MWF.xDesktop.requireApp("process.ViewDesigner", "widget.PersonSelector", function(){
  302. applicationNodes.each(function(node){
  303. new MWF.xApplication.process.ViewDesigner.widget.PersonSelector(node, this.view.designer, {
  304. "type": "application",
  305. "names": (this.data.data.restrictWhereEntry) ? this.data.data.restrictWhereEntry.applicationList : [],
  306. "onChange": function(ids){this.savePersonItem(node, ids);}.bind(this)
  307. });
  308. }.bind(this));
  309. processNodes.each(function(node){
  310. new MWF.xApplication.process.ViewDesigner.widget.PersonSelector(node, this.view.designer, {
  311. "type": "process",
  312. "names": (this.data.data.restrictWhereEntry) ? this.data.data.restrictWhereEntry.processList : [],
  313. "onChange": function(ids){this.savePersonItem(node, ids);}.bind(this)
  314. });
  315. }.bind(this));
  316. companyNodes.each(function(node){
  317. new MWF.xApplication.process.ViewDesigner.widget.PersonSelector(node, this.view.designer, {
  318. "type": "company",
  319. "names": (this.data.data.restrictWhereEntry) ? this.data.data.restrictWhereEntry.companyList : [],
  320. "onChange": function(ids){this.savePersonItem(node, ids);}.bind(this)
  321. });
  322. }.bind(this));
  323. departmentNodes.each(function(node){
  324. new MWF.xApplication.process.ViewDesigner.widget.PersonSelector(node, this.view.designer, {
  325. "type": "department",
  326. "names": (this.data.data.restrictWhereEntry) ? this.data.data.restrictWhereEntry.departmentList : [],
  327. "onChange": function(ids){this.savePersonItem(node, ids);}.bind(this)
  328. });
  329. }.bind(this));
  330. personNodes.each(function(node){
  331. new MWF.xApplication.process.ViewDesigner.widget.PersonSelector(node, this.view.designer, {
  332. "type": "person",
  333. "names": (this.data.data.restrictWhereEntry) ? this.data.data.restrictWhereEntry.personList : [],
  334. "onChange": function(ids){this.savePersonItem(node, ids);}.bind(this)
  335. });
  336. }.bind(this));
  337. identityNodes.each(function(node){
  338. new MWF.xApplication.process.ViewDesigner.widget.PersonSelector(node, this.view.designer, {
  339. "type": "identity",
  340. "names": (this.data.data.restrictWhereEntry) ? this.data.data.restrictWhereEntry.identityList : [],
  341. "onChange": function(ids){this.savePersonItem(node, ids);}.bind(this)
  342. });
  343. }.bind(this));
  344. }.bind(this));
  345. },
  346. savePersonItem: function(node, ids){
  347. //this.initWhereEntryData();
  348. debugger;
  349. var values = [];
  350. ids.each(function(id){
  351. values.push({"name": id.data.name, "id": id.data.id});
  352. }.bind(this));
  353. var name = node.get("name");
  354. key = name.split(".");
  355. var o = this.data;
  356. var len = key.length-1;
  357. key.each(function(n, i){
  358. if (!o[n]) o[n] = {};
  359. if (i<len) o = o[n];
  360. }.bind(this));
  361. o[key[len]] = values;
  362. //this.data.data.restrictWhereEntry[node.get("name")] = values;
  363. },
  364. //loadWorkDataEditor: function(){
  365. // var workDataNodes = this.propertyContent.getElements(".MWFWorkData");
  366. // workDataNodes.each(function(node){
  367. // var select = node.getElement("select");
  368. // for (var i=0; i<select.options.length; i++){
  369. // if (select.options[i].value==this.data.name){
  370. // select.options[i].set("selected", true);
  371. // break;
  372. // }
  373. // }
  374. // if (!this.data.type) this.data.type = "text";
  375. // select.addEvent("change", function(e){
  376. // delete this.data.path;
  377. // this.data.name = select.options[select.selectedIndex].value;
  378. // this.module.listNode.getLast().set("text", this.data.text+"("+this.data.name+")");
  379. // this.setDataType();
  380. // }.bind(this));
  381. //
  382. // this.setDataType();
  383. // }.bind(this));
  384. // var nodes = this.propertyContent.getElements(".MWFWorkDataCheck");
  385. // nodes.each(function(node){
  386. // if (this.data.name) node.set("checked", true);
  387. // }.bind(this));
  388. //},
  389. //setDataType: function(){
  390. // switch (this.data.name){
  391. // case "startTime":case "completedTime":
  392. // this.data.type ="date";
  393. // break;
  394. // case "completed":
  395. // this.data.type ="boolean";
  396. // break;
  397. // default:
  398. // this.data.type ="text";
  399. // }
  400. //},
  401. //loadDataDataEditor: function(){
  402. // var nodes = this.propertyContent.getElements(".MWFDataData");
  403. // nodes.each(function(node){
  404. // var input = node.getElement("input");
  405. // input.set("value", this.data.path);
  406. // input.addEvent("change", function(e){
  407. // delete this.data.name;
  408. // this.data.path = input.get("value");
  409. // this.module.listNode.getLast().set("text", this.data.text+"("+this.data.path+")");
  410. // }.bind(this));
  411. // input.addEvent("blur", function(e){
  412. // delete this.data.name;
  413. // this.data.path = input.get("value");
  414. // this.module.listNode.getLast().set("text", this.data.text+"("+this.data.path+")");
  415. // }.bind(this));
  416. // input.addEvent("keydown", function(e){
  417. // if (e.code==13){
  418. // delete this.data.name;
  419. // this.data.path = input.get("value");
  420. // this.module.listNode.getLast().set("text", this.data.text+"("+this.data.path+")");
  421. // }
  422. // e.stopPropagation();
  423. // }.bind(this));
  424. //
  425. // var select = node.getElement("select");
  426. // for (var i=0; i<select.options.length; i++){
  427. // if (select.options[i].value==this.data.type){
  428. // select.options[i].set("selected", true);
  429. // break;
  430. // }
  431. // }
  432. // if (!this.data.type) this.data.type = "text";
  433. // select.addEvent("change", function(e){
  434. // this.data.type = select.options[select.selectedIndex].value;
  435. // }.bind(this));
  436. //
  437. // }.bind(this));
  438. // var nodes = this.propertyContent.getElements(".MWFDataDataCheck");
  439. // nodes.each(function(node){
  440. // if (this.data.path) node.set("checked", true);
  441. // }.bind(this));
  442. //},
  443. loadColumnExportEditor: function(){
  444. var _self = this;
  445. var nodes = this.propertyContent.getElements(".MWFColumnExport");
  446. nodes.each(function(node){
  447. //if (!this.data.export) this.data.export = {};
  448. //var sort = this.data.export.sort || "";
  449. //var sortOrder = this.data.export.sortOrder || "1";
  450. var select = node.getElement("select");
  451. var sortList = this.view.data.data.orderEntryList;
  452. sortList.each(function(order){
  453. if (order.column==this.data.column){
  454. if (order.orderType=="asc") select.options[1].set("selected", true);
  455. if (order.orderType=="desc") select.options[1].set("selected", false);
  456. }
  457. }.bind(this));
  458. select.addEvent("change", function(e){
  459. var v = select.options[select.selectedIndex].value;
  460. if (v!="none"){
  461. var flag = false;
  462. sortList.each(function(order){
  463. if (order.column==this.data.column){
  464. flag = true;
  465. order.orderType=select.options[select.selectedIndex].value;
  466. }
  467. }.bind(this));
  468. if (!flag) sortList.push({"column": this.data.column, "orderType": select.options[select.selectedIndex].value});
  469. }else{
  470. var deleteItem = null;
  471. sortList.each(function(order){
  472. if (order.column==this.data.column){
  473. deleteItem = order;
  474. }
  475. }.bind(this));
  476. if (deleteItem) sortList.erase(deleteItem);
  477. }
  478. }.bind(this));
  479. var radios = node.getElements("input");
  480. var group = this.view.data.data.groupEntry;
  481. if (group.column==this.data.column) radios[0].set("checked", true);
  482. radios.addEvent("click", function(e){
  483. if (this.checked){
  484. if (this.value=="true") {
  485. _self.view.data.data.groupEntry.column = _self.data.column;
  486. _self.view.items.each(function(col){
  487. if (col.property){
  488. var groupRadios = col.property.propertyContent.getElement(".MWFColumnExport").getElements("input");
  489. groupRadios.each(function(r){
  490. if (r.value=="true") r.set("checked", false);
  491. if (r.value=="false") r.set("checked", true);
  492. });
  493. }
  494. });
  495. this.set("checked", true);
  496. }else{
  497. if (group.column ==_self.data.column) _self.view.data.data.groupEntry = {};
  498. }
  499. }
  500. });
  501. }.bind(this));
  502. },
  503. loadViewFilter: function(){
  504. var nodes = this.propertyContent.getElements(".MWFViewFilter");
  505. var filtrData = this.view.data.data.restrictFilterEntryList;
  506. nodes.each(function(node){
  507. MWF.xDesktop.requireApp("process.ViewDesigner", "widget.ViewFilter", function(){
  508. var _slef = this;
  509. new MWF.xApplication.process.ViewDesigner.widget.ViewFilter(node, this.view.designer, filtrData, {
  510. "onChange": function(ids){
  511. var data = this.getData();
  512. _slef.changeJsonDate(["data", "restrictFilterEntryList"], data);
  513. }
  514. });
  515. }.bind(this));
  516. }.bind(this));
  517. },
  518. loadColumnFilter: function(){
  519. var nodes = this.propertyContent.getElements(".MWFColumnFilter");
  520. nodes.each(function(node){
  521. this.module.filterAreaNode = node;
  522. var table = new Element("table", {
  523. "styles": {"width": "100%"},
  524. "border": "0px",
  525. "cellPadding": "0",
  526. "cellSpacing": "0"
  527. }).inject(node);
  528. var tr = new Element("tr", {"styles": this.module.css.filterTableTitle}).inject(table);
  529. var html = "<th style='width:24px;border-right:1px solid #CCC;border-bottom:1px solid #999;'></th>" +
  530. "<th style='border-right:1px solid #CCC;border-left:1px solid #FFF;border-bottom:1px solid #999;'>逻辑</th>" +
  531. "<th style='border-right:1px solid #CCC;border-left:1px solid #FFF;border-bottom:1px solid #999;'>路径</th>" +
  532. "<th style='border-right:1px solid #CCC;border-left:1px solid #FFF;border-bottom:1px solid #999;'>比较</th>" +
  533. "<th style='border-left:1px solid #FFF;border-bottom:1px solid #999;'>值</th>";
  534. tr.set("html", html);
  535. var addActionNode = new Element("div", {"styles": this.module.css.filterAddActionNode}).inject(tr.getFirst("th"));
  536. addActionNode.addEvent("click", function(){
  537. this.addFilter(table);
  538. }.bind(this));
  539. if (this.data.filterList) {
  540. this.data.filterList.each(function (op) {
  541. new MWF.xApplication.process.ViewDesigner.Property.Filter(op, table, this);
  542. }.bind(this));
  543. }
  544. }.bind(this));
  545. },
  546. addFilter: function(table){
  547. op = {
  548. "logic": "and",
  549. "comparison": "",
  550. "value": ""
  551. }
  552. if (!this.data.filterList) this.data.filterList = [];
  553. this.data.filterList.push(op);
  554. var filter = new MWF.xApplication.process.ViewDesigner.Property.Filter(op, table, this);
  555. filter.editMode();
  556. }
  557. //initWhereEntryData: function(){
  558. // if (!this.data.data.restrictWhereEntry) this.data.data.restrictWhereEntry = {
  559. // "applicationList": [],
  560. // "processList": [],
  561. // "companyList": [],
  562. // "departmentList": [],
  563. // "personList": [],
  564. // "identityList": []
  565. // };
  566. //},
  567. //loadApplicationSelector: function(){
  568. // var nodes = this.propertyContent.getElements(".MWFApplicationSelect");
  569. // if (nodes.length){
  570. // MWF.xDesktop.requireApp("Organization", "Selector.package", function(){
  571. // nodes.each(function(node){
  572. // var title = new Element("div", {"styles": this.view.css.applicationSelectTitle, "text": node.get("title")}).inject(node);
  573. // var content = new Element("div", {"styles": this.view.css.applicationSelectContent}).inject(node);
  574. // var action = new Element("div", {"styles": this.view.css.applicationSelectAction, "text": node.get("title")}).inject(node);
  575. // action.addEvent("click", function(e){
  576. // var values = [];
  577. // if (this.data.data.whereEntry){
  578. // if (this.data.data.whereEntry.applicationList.length){
  579. // this.data.data.whereEntry.applicationList.each(function(item){
  580. // values.push(item.id);
  581. // }.bind(this));
  582. // }
  583. // }
  584. // var options = {
  585. // "type": "application",
  586. // "count": 0,
  587. // "values": values,
  588. // //"title": this.app.lp.monthly.selectSortApplication,
  589. // "onComplete": function(items){
  590. // this.initWhereEntryData();
  591. // this.data.data.whereEntry.applicationList = [];
  592. // content.empty();
  593. // items.each(function(item){
  594. // this.data.data.whereEntry.applicationList.push({
  595. // "id": item.data.id,
  596. // "name": item.data.name
  597. // });
  598. // new Element("div", {
  599. // "styles": this.view.css.applicationSelectItem,
  600. // "text": item.data.name
  601. // }).inject(content);
  602. // }.bind(this));
  603. // }.bind(this)
  604. // };
  605. // var selector = new MWF.OrgSelector(this.view.designer.content, options);
  606. // }.bind(this));
  607. //
  608. // this.initWhereEntryData();
  609. // this.data.data.whereEntry.applicationList.each(function(app){
  610. // new Element("div", {
  611. // "styles": this.view.css.applicationSelectItem,
  612. // "text": app.name
  613. // }).inject(content);
  614. // }.bind(this));
  615. // }.bind(this));
  616. // }.bind(this));
  617. // }
  618. //},
  619. //loadApplicationSelector1: function(){
  620. // var nodes = this.propertyContent.getElements(".MWFApplicationSelect");
  621. // if (nodes.length){
  622. // this._getAppSelector(function(){
  623. // nodes.each(function(node){
  624. // var title = new Element("div", {"styles": this.view.css.applicationSelectTitle, "text": node.get("title")}).inject(node);
  625. // var content = new Element("div", {"styles": this.view.css.applicationSelectContent}).inject(node);
  626. // var action = new Element("div", {"styles": this.view.css.applicationSelectAction, "text": node.get("title")}).inject(node);
  627. // action.addEvent("click", function(e){
  628. // this.appSelector.load(function(apps){
  629. // if (!this.data.data.select) this.data.data.select = {"applicationRestrictList": [], "processRestrictList": []};
  630. // this.data.data.select.applicationRestrictList = [];
  631. // content.empty();
  632. // if (apps.length){
  633. // apps.each(function(app){
  634. // var o = {
  635. // "name": app.name,
  636. // "id": app.id,
  637. // "alias": app.alias
  638. // }
  639. // this.data.data.select.applicationRestrictList.push(o);
  640. //
  641. // new Element("div", {
  642. // "styles": this.view.css.applicationSelectItem,
  643. // "text": app.name
  644. // }).inject(content);
  645. //
  646. // }.bind(this));
  647. // }
  648. // }.bind(this));
  649. // }.bind(this));
  650. // if (!this.data.data.select) this.data.data.select = {"applicationRestrictList": [], "processRestrictList": []};
  651. // this.data.data.select.applicationRestrictList.each(function(app){
  652. // new Element("div", {
  653. // "styles": this.view.css.applicationSelectItem,
  654. // "text": app.name
  655. // }).inject(content);
  656. // }.bind(this));
  657. //
  658. // }.bind(this));
  659. // }.bind(this));
  660. // }
  661. //},
  662. //
  663. //_getAppSelector: function(callback){
  664. // if (!this.appSelector){
  665. // MWF.xDesktop.requireApp("process.ProcessManager", "widget.ApplicationSelector", function(){
  666. // this.appSelector = new MWF.xApplication.process.ProcessManager.widget.ApplicationSelector(this.view.designer, {"maskNode": this.view.designer.content});
  667. // if (callback) callback();
  668. // }.bind(this));
  669. // }else{
  670. // if (callback) callback();
  671. // }
  672. //},
  673. //this.initWhereEntryData();
  674. //loadProcessSelector: function(){
  675. // var nodes = this.propertyContent.getElements(".MWFApplicationSelect");
  676. // if (nodes.length){
  677. // MWF.xDesktop.requireApp("Organization", "Selector.package", function(){
  678. // nodes.each(function(node){
  679. // var title = new Element("div", {"styles": this.view.css.applicationSelectTitle, "text": node.get("title")}).inject(node);
  680. // var content = new Element("div", {"styles": this.view.css.applicationSelectContent}).inject(node);
  681. // var action = new Element("div", {"styles": this.view.css.applicationSelectAction, "text": node.get("title")}).inject(node);
  682. // action.addEvent("click", function(e){
  683. // var values = [];
  684. // if (this.data.data.whereEntry){
  685. // if (this.data.data.whereEntry.processList.length){
  686. // this.data.data.whereEntry.processList.each(function(item){
  687. // values.push(item.id);
  688. // }.bind(this));
  689. // }
  690. // }
  691. // var options = {
  692. // "type": "process",
  693. // "count": 0,
  694. // "values": values,
  695. // "onComplete": function(items){
  696. // this.initWhereEntryData();
  697. // this.data.data.whereEntry.processList = [];
  698. // content.empty();
  699. // items.each(function(item){
  700. // this.data.data.whereEntry.processList.push({
  701. // "id": item.data.id,
  702. // "name": item.data.name
  703. // });
  704. // new Element("div", {
  705. // "styles": this.view.css.applicationSelectItem,
  706. // "text": item.data.name
  707. // }).inject(content);
  708. // }.bind(this));
  709. // }.bind(this)
  710. // };
  711. // var selector = new MWF.OrgSelector(this.view.designer.content, options);
  712. // }.bind(this));
  713. //
  714. // this.initWhereEntryData();
  715. // this.data.data.whereEntry.processList.each(function(app){
  716. // new Element("div", {
  717. // "styles": this.view.css.applicationSelectItem,
  718. // "text": app.name
  719. // }).inject(content);
  720. // }.bind(this));
  721. // }.bind(this));
  722. // }.bind(this));
  723. // }
  724. //}
  725. //loadProcessSelector1: function(){
  726. // var nodes = this.propertyContent.getElements(".MWFProcessSelect");
  727. // if (nodes.length){
  728. // this._getProcessSelector(function(){
  729. // nodes.each(function(node){
  730. // var title = new Element("div", {"styles": this.view.css.applicationSelectTitle, "text": node.get("title")}).inject(node);
  731. // var content = new Element("div", {"styles": this.view.css.applicationSelectContent}).inject(node);
  732. // var action = new Element("div", {"styles": this.view.css.applicationSelectAction, "text": node.get("title")}).inject(node);
  733. // action.addEvent("click", function(e){
  734. // var ids=[];
  735. // this.data.data.select.applicationRestrictList.each(function(app){
  736. // ids.push(app.id);
  737. // });
  738. // this.processSelector.load(ids, function(apps){
  739. // if (!this.data.data.select) this.data.data.select = {"applicationRestrictList": [], "processRestrictList": []};
  740. // this.data.data.select.processRestrictList = [];
  741. // content.empty();
  742. // if (apps.length){
  743. // apps.each(function(app){
  744. // var o = {
  745. // "name": app.name,
  746. // "id": app.id,
  747. // "alias": app.alias
  748. // }
  749. // this.data.data.select.processRestrictList.push(o);
  750. //
  751. // new Element("div", {
  752. // "styles": this.view.css.applicationSelectItem,
  753. // "text": app.name
  754. // }).inject(content);
  755. //
  756. // }.bind(this));
  757. // }
  758. // }.bind(this));
  759. // }.bind(this));
  760. // if (!this.data.data.select) this.data.data.select = {"applicationRestrictList": [], "processRestrictList": []};
  761. // this.data.data.select.processRestrictList.each(function(app){
  762. // new Element("div", {
  763. // "styles": this.view.css.applicationSelectItem,
  764. // "text": app.name
  765. // }).inject(content);
  766. // }.bind(this));
  767. //
  768. // }.bind(this));
  769. // }.bind(this));
  770. // }
  771. //},
  772. //_getProcessSelector: function(callback){
  773. // if (!this.processSelector){
  774. // MWF.xDesktop.requireApp("process.ProcessManager", "widget.ProcessSelector", function(){
  775. // this.processSelector = new MWF.xApplication.process.ProcessManager.widget.ProcessSelector(this.view.designer, {"maskNode": this.view.designer.content});
  776. // if (callback) callback();
  777. // }.bind(this));
  778. // }else{
  779. // if (callback) callback();
  780. // }
  781. //}
  782. });
  783. MWF.xApplication.process.ViewDesigner.Property.Filter = new Class({
  784. Implements: [Events],
  785. initialize: function(json, table, property){
  786. this.property = property;
  787. this.module = property.module;
  788. this.table = table;
  789. this.data = json;
  790. this.load();
  791. },
  792. load: function(){
  793. this.node = new Element("tr", {"styles": this.module.css.filterTableTd}).inject(this.table);
  794. var html = "<td style='widtd:24px;border-right:1px solid #CCC;border-bottom:1px solid #999;'></td>" +
  795. "<td style='padding:3px;border-right:1px solid #CCC;border-bottom:1px solid #999; width:60px'>"+this.data.logic+"</td>" +
  796. "<td style='padding:3px;border-right:1px solid #CCC;border-bottom:1px solid #999; width:30px'>列值</td>" +
  797. "<td style='padding:3px;border-right:1px solid #CCC;border-bottom:1px solid #999;'>"+this.data.comparison+"</td>" +
  798. "<td style='padding:3px;border-bottom:1px solid #999;'>"+this.data.value+"</td>";
  799. this.node.set("html", html);
  800. var tds = this.node.getElements("td");
  801. this.delActionNode = new Element("div", {"styles": this.module.css.filterDelActionNode}).inject(tds[0]);
  802. this.delActionNode.addEvent("click", function(e){
  803. this.delFilter(e);
  804. e.stopPropagation();
  805. }.bind(this));
  806. this.logicNode = tds[1];
  807. this.comparisonNode = tds[3];
  808. this.valueNode = tds[4];
  809. this.node.addEvent("click", function(){
  810. if (!this.isEditMode) this.editMode();
  811. }.bind(this));
  812. this.node.addEvent("blur", function(){
  813. if (this.isEditMode) this.readMode();
  814. }.bind(this));
  815. },
  816. delFilter: function(e){
  817. var _self = this;
  818. this.property.designer.confirm("warn", e, MWF.APPVD.LP.notice.deleteFilterTitle, MWF.APPVD.LP.notice.deleteFilter, 300, 120, function(){
  819. _self.node.destroy();
  820. _self.property.data.filterList.erase(_self.data);
  821. MWF.release(_self);
  822. this.close();
  823. }, function(){
  824. this.close();
  825. }, null);
  826. },
  827. editMode: function(){
  828. if (this.property.editModeFilter){
  829. if (this.property.editModeFilter!=this) this.property.editModeFilter.readMode();
  830. }
  831. var width = this.logicNode.getSize().x-9;
  832. this.logicNode.empty();
  833. var logicSelect = new Element("select", {"styles": {"width": "90%"}}).inject(this.logicNode);
  834. var html = "";
  835. if (this.data.logic=="and"){
  836. html = "<option value=\"and\" selected>and</option><option value=\"or\">or</option>";
  837. }else{
  838. html = "<option value=\"and\">and</option><option value=\"or\" selected>or</option>";
  839. }
  840. logicSelect.set("html", html);
  841. logicSelect.addEvent("change", function(){
  842. this.data.logic = logicSelect.options[logicSelect.selectedIndex].value;
  843. }.bind(this));
  844. width = this.comparisonNode.getSize().x-9;
  845. this.comparisonNode.empty();
  846. var comparisonSelect = new Element("select", {"styles": {"width": "90%"}}).inject(this.comparisonNode);
  847. html = "";
  848. switch (this.property.data.type){
  849. case "text":
  850. html += "<option value=''></option><option value='==' "+((this.data.comparison=="==") ? "selected": "")+">等于(==)</option>" +
  851. "<option value='!=' "+((this.data.comparison=="!=") ? "selected": "")+">不等于(!=)</option>" +
  852. "<option value='@' "+((this.data.comparison=="@") ? "selected": "")+">包含(@)</option>";
  853. break;
  854. case "date":
  855. html += "<option value=''></option><option value='&gt;' "+((this.data.comparison==">") ? "selected": "")+">大于(&gt;)</option>" +
  856. "<option value='&lt;' "+((this.data.comparison=="<") ? "selected": "")+">小于(&lt;)</option>" +
  857. "<option value='&gt;=' "+((this.data.comparison==">=") ? "selected": "")+">大于等于(&gt;=)</option>" +
  858. "<option value='&lt;=' "+((this.data.comparison=="<=") ? "selected": "")+">小于等于(&lt;=)</option>";
  859. break;
  860. case "number":
  861. html += "<option value=''></option><option value='==' "+((this.data.comparison=="==") ? "selected": "")+">等于(==)</option>" +
  862. "<option value='!=' "+((this.data.comparison=="!=") ? "selected": "")+">不等于(!=)</option>" +
  863. "<option value='&gt;' "+((this.data.comparison==">") ? "selected": "")+">大于(&gt;)</option>" +
  864. "<option value='&lt;' "+((this.data.comparison=="<") ? "selected": "")+">小于(&lt;)</option>" +
  865. "<option value='&gt;=' "+((this.data.comparison==">=") ? "selected": "")+">大于等于(&gt;=)</option>" +
  866. "<option value='&lt;=' "+((this.data.comparison=="<=") ? "selected": "")+">小于等于(&lt;=)</option>";
  867. break;
  868. case "boolean":
  869. html += "<option value=''></option><option value='==' "+((this.data.comparison=="==") ? "selected": "")+">等于(==)</option>" +
  870. "<option value='!=' "+((this.data.comparison=="!=") ? "selected": "")+">不等于(!=)</option>";
  871. break;
  872. }
  873. comparisonSelect.set("html", html);
  874. comparisonSelect.addEvent("change", function(){
  875. this.data.comparison = comparisonSelect.options[comparisonSelect.selectedIndex].value;
  876. }.bind(this));
  877. width = this.valueNode.getSize().x-9;
  878. this.valueNode.empty();
  879. var type = "text";
  880. switch (this.property.data.type){
  881. case "date":
  882. var valueInput = new Element("input", {"styles": {"width": "90%"},
  883. "type": "text",
  884. "value": this.data.value
  885. }).inject(this.valueNode);
  886. MWF.require("MWF.widget.Calendar", function(){
  887. this.calendar = new MWF.widget.Calendar(valueInput, {
  888. "style": "xform",
  889. "isTime": true,
  890. "target": this.property.designer.content,
  891. "format": "%Y-%m-%d %H:%M:%S"
  892. });
  893. //this.calendar.show();
  894. }.bind(this));
  895. break;
  896. case "number":
  897. var valueInput = new Element("input", {"styles": {"width": "90%"},
  898. "type": "number",
  899. "value": this.data.value
  900. }).inject(this.valueNode);
  901. break;
  902. case "boolean":
  903. var valueInput = new Element("select", {"styles": {"width": ""+width+"px"},
  904. "html": "<option value=\"\"></option><option value=\"true\" "+((this.data.value) ? "selected": "")+">true</option><option value=\"false\" "+((!this.data.value) ? "selected": "")+">false</option>"
  905. }).inject(this.valueNode);
  906. break;
  907. default:
  908. var valueInput = new Element("input", {"styles": {"width": "90%"},
  909. "type": "text",
  910. "value": this.data.value
  911. }).inject(this.valueNode);
  912. }
  913. if (valueInput.tagName.toLowerCase()=="select"){
  914. valueInput.addEvent("change", function(){
  915. var v = valueInput.options[valueInput.selectedIndex].value;
  916. this.data.value = (v="true") ? true : false;
  917. }.bind(this));
  918. }else{
  919. valueInput.addEvent("change", function(e){
  920. this.data.value = valueInput.get("value");
  921. }.bind(this));
  922. valueInput.addEvent("blur", function(e){
  923. this.data.value = valueInput.get("value");
  924. }.bind(this));
  925. valueInput.addEvent("keydown", function(e){
  926. if (e.code==13){
  927. this.data.value = valueInput.get("value");
  928. this.readMode();
  929. }
  930. e.stopPropagation();
  931. }.bind(this));
  932. }
  933. this.isEditMode = true;
  934. this.property.editModeFilter = this;
  935. },
  936. readMode: function(){
  937. if (this.isEditMode){
  938. var logicSelect = this.logicNode.getElement("select");
  939. this.data.logic = logicSelect.options[logicSelect.selectedIndex].value;
  940. var comparisonSelect = this.comparisonNode.getElement("select");
  941. this.data.comparison = comparisonSelect.options[comparisonSelect.selectedIndex].value;
  942. var valueInput = this.valueNode.getFirst();
  943. if (valueInput.tagName.toLowerCase()=="select"){
  944. var v = valueInput.options[valueInput.selectedIndex].value;
  945. this.data.value = (v="true") ? true : false;
  946. }else{
  947. this.data.value = valueInput.get("value");
  948. }
  949. this.logicNode.empty();
  950. this.comparisonNode.empty();
  951. this.valueNode.empty();
  952. this.logicNode.set("text", this.data.logic);
  953. this.comparisonNode.set("text", this.data.comparison);
  954. this.valueNode.set("text", this.data.value);
  955. this.isEditMode = false;
  956. this.property.editModeFilter = null;
  957. }
  958. }
  959. });