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 checkboxList = $$("input:[name='"+name+"']");
  242. var values = [];
  243. checkboxList.each(function(checkbox){
  244. if (checkbox.get("checked")){
  245. values.push(checkbox.value);
  246. }
  247. });
  248. var oldValue = this.data[name];
  249. //this.data[name] = values;
  250. this.changeJsonDate(name, values);
  251. this.changeData(name, input, oldValue);
  252. },
  253. setSelectValue: function(name, select){
  254. var idx = select.selectedIndex;
  255. var options = select.getElements("option");
  256. var value = "";
  257. if (options[idx]){
  258. value = options[idx].get("value");
  259. }
  260. var oldValue = this.data[name];
  261. //this.data[name] = value;
  262. this.changeJsonDate(name, value);
  263. this.changeData(name, select, oldValue);
  264. },
  265. setValue: function(name, value, obj){
  266. var names = name.split(".");
  267. var oldValue = this.data;
  268. for (var idx = 0; idx<names.length; idx++){
  269. if (!oldValue[names[idx]]){
  270. oldValue = null;
  271. break;
  272. }else{
  273. oldValue = oldValue[names[idx]];
  274. }
  275. }
  276. //var oldValue = this.data[name];
  277. //this.data[name] = value;
  278. this.changeJsonDate(names, value);
  279. this.changeData(name, obj, oldValue);
  280. },
  281. setEditNodeStyles: function(node){
  282. var nodes = node.getChildren();
  283. if (nodes.length){
  284. nodes.each(function(el){
  285. var cName = el.get("class");
  286. if (cName){
  287. if (this.view.css[cName]) el.setStyles(this.view.css[cName]);
  288. }
  289. this.setEditNodeStyles(el);
  290. }.bind(this));
  291. }
  292. },
  293. loadPersonInput: function(){
  294. var applicationNodes = this.propertyContent.getElements(".MWFSelectApplication");
  295. var processNodes = this.propertyContent.getElements(".MWFSelectProcess");
  296. var companyNodes = this.propertyContent.getElements(".MWFSelectCompany");
  297. var departmentNodes = this.propertyContent.getElements(".MWFSelectDepartment");
  298. var personNodes = this.propertyContent.getElements(".MWFSelectPerson");
  299. var identityNodes = this.propertyContent.getElements(".MWFSelectIdentity");
  300. MWF.xDesktop.requireApp("process.ViewDesigner", "widget.PersonSelector", function(){
  301. applicationNodes.each(function(node){
  302. new MWF.xApplication.process.ViewDesigner.widget.PersonSelector(node, this.view.designer, {
  303. "type": "application",
  304. "names": (this.data.data.restrictWhereEntry) ? this.data.data.restrictWhereEntry.applicationList : [],
  305. "onChange": function(ids){this.savePersonItem(node, ids);}.bind(this)
  306. });
  307. }.bind(this));
  308. processNodes.each(function(node){
  309. new MWF.xApplication.process.ViewDesigner.widget.PersonSelector(node, this.view.designer, {
  310. "type": "process",
  311. "names": (this.data.data.restrictWhereEntry) ? this.data.data.restrictWhereEntry.processList : [],
  312. "onChange": function(ids){this.savePersonItem(node, ids);}.bind(this)
  313. });
  314. }.bind(this));
  315. companyNodes.each(function(node){
  316. new MWF.xApplication.process.ViewDesigner.widget.PersonSelector(node, this.view.designer, {
  317. "type": "company",
  318. "names": (this.data.data.restrictWhereEntry) ? this.data.data.restrictWhereEntry.companyList : [],
  319. "onChange": function(ids){this.savePersonItem(node, ids);}.bind(this)
  320. });
  321. }.bind(this));
  322. departmentNodes.each(function(node){
  323. new MWF.xApplication.process.ViewDesigner.widget.PersonSelector(node, this.view.designer, {
  324. "type": "department",
  325. "names": (this.data.data.restrictWhereEntry) ? this.data.data.restrictWhereEntry.departmentList : [],
  326. "onChange": function(ids){this.savePersonItem(node, ids);}.bind(this)
  327. });
  328. }.bind(this));
  329. personNodes.each(function(node){
  330. new MWF.xApplication.process.ViewDesigner.widget.PersonSelector(node, this.view.designer, {
  331. "type": "person",
  332. "names": (this.data.data.restrictWhereEntry) ? this.data.data.restrictWhereEntry.personList : [],
  333. "onChange": function(ids){this.savePersonItem(node, ids);}.bind(this)
  334. });
  335. }.bind(this));
  336. identityNodes.each(function(node){
  337. new MWF.xApplication.process.ViewDesigner.widget.PersonSelector(node, this.view.designer, {
  338. "type": "identity",
  339. "names": (this.data.data.restrictWhereEntry) ? this.data.data.restrictWhereEntry.identityList : [],
  340. "onChange": function(ids){this.savePersonItem(node, ids);}.bind(this)
  341. });
  342. }.bind(this));
  343. }.bind(this));
  344. },
  345. savePersonItem: function(node, ids){
  346. //this.initWhereEntryData();
  347. debugger;
  348. var values = [];
  349. ids.each(function(id){
  350. values.push({"name": id.data.name, "id": id.data.id});
  351. }.bind(this));
  352. var name = node.get("name");
  353. key = name.split(".");
  354. var o = this.data;
  355. var len = key.length-1;
  356. key.each(function(n, i){
  357. if (!o[n]) o[n] = {};
  358. if (i<len) o = o[n];
  359. }.bind(this));
  360. o[key[len]] = values;
  361. //this.data.data.restrictWhereEntry[node.get("name")] = values;
  362. },
  363. //loadWorkDataEditor: function(){
  364. // var workDataNodes = this.propertyContent.getElements(".MWFWorkData");
  365. // workDataNodes.each(function(node){
  366. // var select = node.getElement("select");
  367. // for (var i=0; i<select.options.length; i++){
  368. // if (select.options[i].value==this.data.name){
  369. // select.options[i].set("selected", true);
  370. // break;
  371. // }
  372. // }
  373. // if (!this.data.type) this.data.type = "text";
  374. // select.addEvent("change", function(e){
  375. // delete this.data.path;
  376. // this.data.name = select.options[select.selectedIndex].value;
  377. // this.module.listNode.getLast().set("text", this.data.text+"("+this.data.name+")");
  378. // this.setDataType();
  379. // }.bind(this));
  380. //
  381. // this.setDataType();
  382. // }.bind(this));
  383. // var nodes = this.propertyContent.getElements(".MWFWorkDataCheck");
  384. // nodes.each(function(node){
  385. // if (this.data.name) node.set("checked", true);
  386. // }.bind(this));
  387. //},
  388. //setDataType: function(){
  389. // switch (this.data.name){
  390. // case "startTime":case "completedTime":
  391. // this.data.type ="date";
  392. // break;
  393. // case "completed":
  394. // this.data.type ="boolean";
  395. // break;
  396. // default:
  397. // this.data.type ="text";
  398. // }
  399. //},
  400. //loadDataDataEditor: function(){
  401. // var nodes = this.propertyContent.getElements(".MWFDataData");
  402. // nodes.each(function(node){
  403. // var input = node.getElement("input");
  404. // input.set("value", this.data.path);
  405. // input.addEvent("change", function(e){
  406. // delete this.data.name;
  407. // this.data.path = input.get("value");
  408. // this.module.listNode.getLast().set("text", this.data.text+"("+this.data.path+")");
  409. // }.bind(this));
  410. // input.addEvent("blur", function(e){
  411. // delete this.data.name;
  412. // this.data.path = input.get("value");
  413. // this.module.listNode.getLast().set("text", this.data.text+"("+this.data.path+")");
  414. // }.bind(this));
  415. // input.addEvent("keydown", function(e){
  416. // if (e.code==13){
  417. // delete this.data.name;
  418. // this.data.path = input.get("value");
  419. // this.module.listNode.getLast().set("text", this.data.text+"("+this.data.path+")");
  420. // }
  421. // e.stopPropagation();
  422. // }.bind(this));
  423. //
  424. // var select = node.getElement("select");
  425. // for (var i=0; i<select.options.length; i++){
  426. // if (select.options[i].value==this.data.type){
  427. // select.options[i].set("selected", true);
  428. // break;
  429. // }
  430. // }
  431. // if (!this.data.type) this.data.type = "text";
  432. // select.addEvent("change", function(e){
  433. // this.data.type = select.options[select.selectedIndex].value;
  434. // }.bind(this));
  435. //
  436. // }.bind(this));
  437. // var nodes = this.propertyContent.getElements(".MWFDataDataCheck");
  438. // nodes.each(function(node){
  439. // if (this.data.path) node.set("checked", true);
  440. // }.bind(this));
  441. //},
  442. loadColumnExportEditor: function(){
  443. var _self = this;
  444. var nodes = this.propertyContent.getElements(".MWFColumnExport");
  445. nodes.each(function(node){
  446. //if (!this.data.export) this.data.export = {};
  447. //var sort = this.data.export.sort || "";
  448. //var sortOrder = this.data.export.sortOrder || "1";
  449. var select = node.getElement("select");
  450. var sortList = this.view.data.data.orderEntryList;
  451. sortList.each(function(order){
  452. if (order.column==this.data.column){
  453. if (order.orderType=="asc") select.options[1].set("selected", true);
  454. if (order.orderType=="desc") select.options[1].set("selected", false);
  455. }
  456. }.bind(this));
  457. select.addEvent("change", function(e){
  458. var v = select.options[select.selectedIndex].value;
  459. if (v!="none"){
  460. var flag = false;
  461. sortList.each(function(order){
  462. if (order.column==this.data.column){
  463. flag = true;
  464. order.orderType=select.options[select.selectedIndex].value;
  465. }
  466. }.bind(this));
  467. if (!flag) sortList.push({"column": this.data.column, "orderType": select.options[select.selectedIndex].value});
  468. }else{
  469. var deleteItem = null;
  470. sortList.each(function(order){
  471. if (order.column==this.data.column){
  472. deleteItem = order;
  473. }
  474. }.bind(this));
  475. if (deleteItem) sortList.erase(deleteItem);
  476. }
  477. }.bind(this));
  478. var radios = node.getElements("input");
  479. var group = this.view.data.data.groupEntry;
  480. if (group.column==this.data.column) radios[0].set("checked", true);
  481. radios.addEvent("click", function(e){
  482. if (this.checked){
  483. if (this.value=="true") {
  484. _self.view.data.data.groupEntry.column = _self.data.column;
  485. _self.view.items.each(function(col){
  486. if (col.property){
  487. var groupRadios = col.property.propertyContent.getElement(".MWFColumnExport").getElements("input");
  488. groupRadios.each(function(r){
  489. if (r.value=="true") r.set("checked", false);
  490. if (r.value=="false") r.set("checked", true);
  491. });
  492. }
  493. });
  494. this.set("checked", true);
  495. }else{
  496. if (group.column ==_self.data.column) _self.view.data.data.groupEntry = {};
  497. }
  498. }
  499. });
  500. }.bind(this));
  501. },
  502. loadViewFilter: function(){
  503. var nodes = this.propertyContent.getElements(".MWFViewFilter");
  504. var filtrData = this.view.data.data.restrictFilterEntryList;
  505. nodes.each(function(node){
  506. MWF.xDesktop.requireApp("process.ViewDesigner", "widget.ViewFilter", function(){
  507. var _slef = this;
  508. new MWF.xApplication.process.ViewDesigner.widget.ViewFilter(node, this.view.designer, filtrData, {
  509. "onChange": function(ids){
  510. var data = this.getData();
  511. _slef.changeJsonDate(["data", "restrictFilterEntryList"], data);
  512. }
  513. });
  514. }.bind(this));
  515. }.bind(this));
  516. },
  517. loadColumnFilter: function(){
  518. var nodes = this.propertyContent.getElements(".MWFColumnFilter");
  519. nodes.each(function(node){
  520. this.module.filterAreaNode = node;
  521. var table = new Element("table", {
  522. "styles": {"width": "100%"},
  523. "border": "0px",
  524. "cellPadding": "0",
  525. "cellSpacing": "0"
  526. }).inject(node);
  527. var tr = new Element("tr", {"styles": this.module.css.filterTableTitle}).inject(table);
  528. var html = "<th style='width:24px;border-right:1px solid #CCC;border-bottom:1px solid #999;'></th>" +
  529. "<th style='border-right:1px solid #CCC;border-left:1px solid #FFF;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-left:1px solid #FFF;border-bottom:1px solid #999;'>值</th>";
  533. tr.set("html", html);
  534. var addActionNode = new Element("div", {"styles": this.module.css.filterAddActionNode}).inject(tr.getFirst("th"));
  535. addActionNode.addEvent("click", function(){
  536. this.addFilter(table);
  537. }.bind(this));
  538. if (this.data.filterList) {
  539. this.data.filterList.each(function (op) {
  540. new MWF.xApplication.process.ViewDesigner.Property.Filter(op, table, this);
  541. }.bind(this));
  542. }
  543. }.bind(this));
  544. },
  545. addFilter: function(table){
  546. op = {
  547. "logic": "and",
  548. "comparison": "",
  549. "value": ""
  550. }
  551. if (!this.data.filterList) this.data.filterList = [];
  552. this.data.filterList.push(op);
  553. var filter = new MWF.xApplication.process.ViewDesigner.Property.Filter(op, table, this);
  554. filter.editMode();
  555. }
  556. //initWhereEntryData: function(){
  557. // if (!this.data.data.restrictWhereEntry) this.data.data.restrictWhereEntry = {
  558. // "applicationList": [],
  559. // "processList": [],
  560. // "companyList": [],
  561. // "departmentList": [],
  562. // "personList": [],
  563. // "identityList": []
  564. // };
  565. //},
  566. //loadApplicationSelector: function(){
  567. // var nodes = this.propertyContent.getElements(".MWFApplicationSelect");
  568. // if (nodes.length){
  569. // MWF.xDesktop.requireApp("Organization", "Selector.package", function(){
  570. // nodes.each(function(node){
  571. // var title = new Element("div", {"styles": this.view.css.applicationSelectTitle, "text": node.get("title")}).inject(node);
  572. // var content = new Element("div", {"styles": this.view.css.applicationSelectContent}).inject(node);
  573. // var action = new Element("div", {"styles": this.view.css.applicationSelectAction, "text": node.get("title")}).inject(node);
  574. // action.addEvent("click", function(e){
  575. // var values = [];
  576. // if (this.data.data.whereEntry){
  577. // if (this.data.data.whereEntry.applicationList.length){
  578. // this.data.data.whereEntry.applicationList.each(function(item){
  579. // values.push(item.id);
  580. // }.bind(this));
  581. // }
  582. // }
  583. // var options = {
  584. // "type": "application",
  585. // "count": 0,
  586. // "values": values,
  587. // //"title": this.app.lp.monthly.selectSortApplication,
  588. // "onComplete": function(items){
  589. // this.initWhereEntryData();
  590. // this.data.data.whereEntry.applicationList = [];
  591. // content.empty();
  592. // items.each(function(item){
  593. // this.data.data.whereEntry.applicationList.push({
  594. // "id": item.data.id,
  595. // "name": item.data.name
  596. // });
  597. // new Element("div", {
  598. // "styles": this.view.css.applicationSelectItem,
  599. // "text": item.data.name
  600. // }).inject(content);
  601. // }.bind(this));
  602. // }.bind(this)
  603. // };
  604. // var selector = new MWF.OrgSelector(this.view.designer.content, options);
  605. // }.bind(this));
  606. //
  607. // this.initWhereEntryData();
  608. // this.data.data.whereEntry.applicationList.each(function(app){
  609. // new Element("div", {
  610. // "styles": this.view.css.applicationSelectItem,
  611. // "text": app.name
  612. // }).inject(content);
  613. // }.bind(this));
  614. // }.bind(this));
  615. // }.bind(this));
  616. // }
  617. //},
  618. //loadApplicationSelector1: function(){
  619. // var nodes = this.propertyContent.getElements(".MWFApplicationSelect");
  620. // if (nodes.length){
  621. // this._getAppSelector(function(){
  622. // nodes.each(function(node){
  623. // var title = new Element("div", {"styles": this.view.css.applicationSelectTitle, "text": node.get("title")}).inject(node);
  624. // var content = new Element("div", {"styles": this.view.css.applicationSelectContent}).inject(node);
  625. // var action = new Element("div", {"styles": this.view.css.applicationSelectAction, "text": node.get("title")}).inject(node);
  626. // action.addEvent("click", function(e){
  627. // this.appSelector.load(function(apps){
  628. // if (!this.data.data.select) this.data.data.select = {"applicationRestrictList": [], "processRestrictList": []};
  629. // this.data.data.select.applicationRestrictList = [];
  630. // content.empty();
  631. // if (apps.length){
  632. // apps.each(function(app){
  633. // var o = {
  634. // "name": app.name,
  635. // "id": app.id,
  636. // "alias": app.alias
  637. // }
  638. // this.data.data.select.applicationRestrictList.push(o);
  639. //
  640. // new Element("div", {
  641. // "styles": this.view.css.applicationSelectItem,
  642. // "text": app.name
  643. // }).inject(content);
  644. //
  645. // }.bind(this));
  646. // }
  647. // }.bind(this));
  648. // }.bind(this));
  649. // if (!this.data.data.select) this.data.data.select = {"applicationRestrictList": [], "processRestrictList": []};
  650. // this.data.data.select.applicationRestrictList.each(function(app){
  651. // new Element("div", {
  652. // "styles": this.view.css.applicationSelectItem,
  653. // "text": app.name
  654. // }).inject(content);
  655. // }.bind(this));
  656. //
  657. // }.bind(this));
  658. // }.bind(this));
  659. // }
  660. //},
  661. //
  662. //_getAppSelector: function(callback){
  663. // if (!this.appSelector){
  664. // MWF.xDesktop.requireApp("process.ProcessManager", "widget.ApplicationSelector", function(){
  665. // this.appSelector = new MWF.xApplication.process.ProcessManager.widget.ApplicationSelector(this.view.designer, {"maskNode": this.view.designer.content});
  666. // if (callback) callback();
  667. // }.bind(this));
  668. // }else{
  669. // if (callback) callback();
  670. // }
  671. //},
  672. //this.initWhereEntryData();
  673. //loadProcessSelector: function(){
  674. // var nodes = this.propertyContent.getElements(".MWFApplicationSelect");
  675. // if (nodes.length){
  676. // MWF.xDesktop.requireApp("Organization", "Selector.package", function(){
  677. // nodes.each(function(node){
  678. // var title = new Element("div", {"styles": this.view.css.applicationSelectTitle, "text": node.get("title")}).inject(node);
  679. // var content = new Element("div", {"styles": this.view.css.applicationSelectContent}).inject(node);
  680. // var action = new Element("div", {"styles": this.view.css.applicationSelectAction, "text": node.get("title")}).inject(node);
  681. // action.addEvent("click", function(e){
  682. // var values = [];
  683. // if (this.data.data.whereEntry){
  684. // if (this.data.data.whereEntry.processList.length){
  685. // this.data.data.whereEntry.processList.each(function(item){
  686. // values.push(item.id);
  687. // }.bind(this));
  688. // }
  689. // }
  690. // var options = {
  691. // "type": "process",
  692. // "count": 0,
  693. // "values": values,
  694. // "onComplete": function(items){
  695. // this.initWhereEntryData();
  696. // this.data.data.whereEntry.processList = [];
  697. // content.empty();
  698. // items.each(function(item){
  699. // this.data.data.whereEntry.processList.push({
  700. // "id": item.data.id,
  701. // "name": item.data.name
  702. // });
  703. // new Element("div", {
  704. // "styles": this.view.css.applicationSelectItem,
  705. // "text": item.data.name
  706. // }).inject(content);
  707. // }.bind(this));
  708. // }.bind(this)
  709. // };
  710. // var selector = new MWF.OrgSelector(this.view.designer.content, options);
  711. // }.bind(this));
  712. //
  713. // this.initWhereEntryData();
  714. // this.data.data.whereEntry.processList.each(function(app){
  715. // new Element("div", {
  716. // "styles": this.view.css.applicationSelectItem,
  717. // "text": app.name
  718. // }).inject(content);
  719. // }.bind(this));
  720. // }.bind(this));
  721. // }.bind(this));
  722. // }
  723. //}
  724. //loadProcessSelector1: function(){
  725. // var nodes = this.propertyContent.getElements(".MWFProcessSelect");
  726. // if (nodes.length){
  727. // this._getProcessSelector(function(){
  728. // nodes.each(function(node){
  729. // var title = new Element("div", {"styles": this.view.css.applicationSelectTitle, "text": node.get("title")}).inject(node);
  730. // var content = new Element("div", {"styles": this.view.css.applicationSelectContent}).inject(node);
  731. // var action = new Element("div", {"styles": this.view.css.applicationSelectAction, "text": node.get("title")}).inject(node);
  732. // action.addEvent("click", function(e){
  733. // var ids=[];
  734. // this.data.data.select.applicationRestrictList.each(function(app){
  735. // ids.push(app.id);
  736. // });
  737. // this.processSelector.load(ids, function(apps){
  738. // if (!this.data.data.select) this.data.data.select = {"applicationRestrictList": [], "processRestrictList": []};
  739. // this.data.data.select.processRestrictList = [];
  740. // content.empty();
  741. // if (apps.length){
  742. // apps.each(function(app){
  743. // var o = {
  744. // "name": app.name,
  745. // "id": app.id,
  746. // "alias": app.alias
  747. // }
  748. // this.data.data.select.processRestrictList.push(o);
  749. //
  750. // new Element("div", {
  751. // "styles": this.view.css.applicationSelectItem,
  752. // "text": app.name
  753. // }).inject(content);
  754. //
  755. // }.bind(this));
  756. // }
  757. // }.bind(this));
  758. // }.bind(this));
  759. // if (!this.data.data.select) this.data.data.select = {"applicationRestrictList": [], "processRestrictList": []};
  760. // this.data.data.select.processRestrictList.each(function(app){
  761. // new Element("div", {
  762. // "styles": this.view.css.applicationSelectItem,
  763. // "text": app.name
  764. // }).inject(content);
  765. // }.bind(this));
  766. //
  767. // }.bind(this));
  768. // }.bind(this));
  769. // }
  770. //},
  771. //_getProcessSelector: function(callback){
  772. // if (!this.processSelector){
  773. // MWF.xDesktop.requireApp("process.ProcessManager", "widget.ProcessSelector", function(){
  774. // this.processSelector = new MWF.xApplication.process.ProcessManager.widget.ProcessSelector(this.view.designer, {"maskNode": this.view.designer.content});
  775. // if (callback) callback();
  776. // }.bind(this));
  777. // }else{
  778. // if (callback) callback();
  779. // }
  780. //}
  781. });
  782. MWF.xApplication.process.ViewDesigner.Property.Filter = new Class({
  783. Implements: [Events],
  784. initialize: function(json, table, property){
  785. this.property = property;
  786. this.module = property.module;
  787. this.table = table;
  788. this.data = json;
  789. this.load();
  790. },
  791. load: function(){
  792. this.node = new Element("tr", {"styles": this.module.css.filterTableTd}).inject(this.table);
  793. var html = "<td style='widtd:24px;border-right:1px solid #CCC;border-bottom:1px solid #999;'></td>" +
  794. "<td style='padding:3px;border-right:1px solid #CCC;border-bottom:1px solid #999; width:60px'>"+this.data.logic+"</td>" +
  795. "<td style='padding:3px;border-right:1px solid #CCC;border-bottom:1px solid #999; width:30px'>列值</td>" +
  796. "<td style='padding:3px;border-right:1px solid #CCC;border-bottom:1px solid #999;'>"+this.data.comparison+"</td>" +
  797. "<td style='padding:3px;border-bottom:1px solid #999;'>"+this.data.value+"</td>";
  798. this.node.set("html", html);
  799. var tds = this.node.getElements("td");
  800. this.delActionNode = new Element("div", {"styles": this.module.css.filterDelActionNode}).inject(tds[0]);
  801. this.delActionNode.addEvent("click", function(e){
  802. this.delFilter(e);
  803. e.stopPropagation();
  804. }.bind(this));
  805. this.logicNode = tds[1];
  806. this.comparisonNode = tds[3];
  807. this.valueNode = tds[4];
  808. this.node.addEvent("click", function(){
  809. if (!this.isEditMode) this.editMode();
  810. }.bind(this));
  811. this.node.addEvent("blur", function(){
  812. if (this.isEditMode) this.readMode();
  813. }.bind(this));
  814. },
  815. delFilter: function(e){
  816. var _self = this;
  817. this.property.designer.confirm("warn", e, MWF.APPVD.LP.notice.deleteFilterTitle, MWF.APPVD.LP.notice.deleteFilter, 300, 120, function(){
  818. _self.node.destroy();
  819. _self.property.data.filterList.erase(_self.data);
  820. MWF.release(_self);
  821. this.close();
  822. }, function(){
  823. this.close();
  824. }, null);
  825. },
  826. editMode: function(){
  827. if (this.property.editModeFilter){
  828. if (this.property.editModeFilter!=this) this.property.editModeFilter.readMode();
  829. }
  830. var width = this.logicNode.getSize().x-9;
  831. this.logicNode.empty();
  832. var logicSelect = new Element("select", {"styles": {"width": "90%"}}).inject(this.logicNode);
  833. var html = "";
  834. if (this.data.logic=="and"){
  835. html = "<option value=\"and\" selected>and</option><option value=\"or\">or</option>";
  836. }else{
  837. html = "<option value=\"and\">and</option><option value=\"or\" selected>or</option>";
  838. }
  839. logicSelect.set("html", html);
  840. logicSelect.addEvent("change", function(){
  841. this.data.logic = logicSelect.options[logicSelect.selectedIndex].value;
  842. }.bind(this));
  843. width = this.comparisonNode.getSize().x-9;
  844. this.comparisonNode.empty();
  845. var comparisonSelect = new Element("select", {"styles": {"width": "90%"}}).inject(this.comparisonNode);
  846. html = "";
  847. switch (this.property.data.type){
  848. case "text":
  849. html += "<option value=''></option><option value='==' "+((this.data.comparison=="==") ? "selected": "")+">等于(==)</option>" +
  850. "<option value='!=' "+((this.data.comparison=="!=") ? "selected": "")+">不等于(!=)</option>" +
  851. "<option value='@' "+((this.data.comparison=="@") ? "selected": "")+">包含(@)</option>";
  852. break;
  853. case "date":
  854. html += "<option value=''></option><option value='&gt;' "+((this.data.comparison==">") ? "selected": "")+">大于(&gt;)</option>" +
  855. "<option value='&lt;' "+((this.data.comparison=="<") ? "selected": "")+">小于(&lt;)</option>" +
  856. "<option value='&gt;=' "+((this.data.comparison==">=") ? "selected": "")+">大于等于(&gt;=)</option>" +
  857. "<option value='&lt;=' "+((this.data.comparison=="<=") ? "selected": "")+">小于等于(&lt;=)</option>";
  858. break;
  859. case "number":
  860. html += "<option value=''></option><option value='==' "+((this.data.comparison=="==") ? "selected": "")+">等于(==)</option>" +
  861. "<option value='!=' "+((this.data.comparison=="!=") ? "selected": "")+">不等于(!=)</option>" +
  862. "<option value='&gt;' "+((this.data.comparison==">") ? "selected": "")+">大于(&gt;)</option>" +
  863. "<option value='&lt;' "+((this.data.comparison=="<") ? "selected": "")+">小于(&lt;)</option>" +
  864. "<option value='&gt;=' "+((this.data.comparison==">=") ? "selected": "")+">大于等于(&gt;=)</option>" +
  865. "<option value='&lt;=' "+((this.data.comparison=="<=") ? "selected": "")+">小于等于(&lt;=)</option>";
  866. break;
  867. case "boolean":
  868. html += "<option value=''></option><option value='==' "+((this.data.comparison=="==") ? "selected": "")+">等于(==)</option>" +
  869. "<option value='!=' "+((this.data.comparison=="!=") ? "selected": "")+">不等于(!=)</option>";
  870. break;
  871. }
  872. comparisonSelect.set("html", html);
  873. comparisonSelect.addEvent("change", function(){
  874. this.data.comparison = comparisonSelect.options[comparisonSelect.selectedIndex].value;
  875. }.bind(this));
  876. width = this.valueNode.getSize().x-9;
  877. this.valueNode.empty();
  878. var type = "text";
  879. switch (this.property.data.type){
  880. case "date":
  881. var valueInput = new Element("input", {"styles": {"width": "90%"},
  882. "type": "text",
  883. "value": this.data.value
  884. }).inject(this.valueNode);
  885. MWF.require("MWF.widget.Calendar", function(){
  886. this.calendar = new MWF.widget.Calendar(valueInput, {
  887. "style": "xform",
  888. "isTime": true,
  889. "target": this.property.designer.content,
  890. "format": "%Y-%m-%d %H:%M:%S"
  891. });
  892. //this.calendar.show();
  893. }.bind(this));
  894. break;
  895. case "number":
  896. var valueInput = new Element("input", {"styles": {"width": "90%"},
  897. "type": "number",
  898. "value": this.data.value
  899. }).inject(this.valueNode);
  900. break;
  901. case "boolean":
  902. var valueInput = new Element("select", {"styles": {"width": ""+width+"px"},
  903. "html": "<option value=\"\"></option><option value=\"true\" "+((this.data.value) ? "selected": "")+">true</option><option value=\"false\" "+((!this.data.value) ? "selected": "")+">false</option>"
  904. }).inject(this.valueNode);
  905. break;
  906. default:
  907. var valueInput = new Element("input", {"styles": {"width": "90%"},
  908. "type": "text",
  909. "value": this.data.value
  910. }).inject(this.valueNode);
  911. }
  912. if (valueInput.tagName.toLowerCase()=="select"){
  913. valueInput.addEvent("change", function(){
  914. var v = valueInput.options[valueInput.selectedIndex].value;
  915. this.data.value = (v="true") ? true : false;
  916. }.bind(this));
  917. }else{
  918. valueInput.addEvent("change", function(e){
  919. this.data.value = valueInput.get("value");
  920. }.bind(this));
  921. valueInput.addEvent("blur", function(e){
  922. this.data.value = valueInput.get("value");
  923. }.bind(this));
  924. valueInput.addEvent("keydown", function(e){
  925. if (e.code==13){
  926. this.data.value = valueInput.get("value");
  927. this.readMode();
  928. }
  929. e.stopPropagation();
  930. }.bind(this));
  931. }
  932. this.isEditMode = true;
  933. this.property.editModeFilter = this;
  934. },
  935. readMode: function(){
  936. if (this.isEditMode){
  937. var logicSelect = this.logicNode.getElement("select");
  938. this.data.logic = logicSelect.options[logicSelect.selectedIndex].value;
  939. var comparisonSelect = this.comparisonNode.getElement("select");
  940. this.data.comparison = comparisonSelect.options[comparisonSelect.selectedIndex].value;
  941. var valueInput = this.valueNode.getFirst();
  942. if (valueInput.tagName.toLowerCase()=="select"){
  943. var v = valueInput.options[valueInput.selectedIndex].value;
  944. this.data.value = (v="true") ? true : false;
  945. }else{
  946. this.data.value = valueInput.get("value");
  947. }
  948. this.logicNode.empty();
  949. this.comparisonNode.empty();
  950. this.valueNode.empty();
  951. this.logicNode.set("text", this.data.logic);
  952. this.comparisonNode.set("text", this.data.comparison);
  953. this.valueNode.set("text", this.data.value);
  954. this.isEditMode = false;
  955. this.property.editModeFilter = null;
  956. }
  957. }
  958. });