PrivateConfig.js 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336
  1. MWF.require("MWF.widget.O2Identity", null, false);
  2. MWF.xApplication.Org.PrivateConfig = new Class({
  3. Extends: MWF.widget.Common,
  4. Implements: [Options, Events],
  5. options: {
  6. "style": "default",
  7. "lp": {
  8. }
  9. },
  10. initialize: function(node, actions, options){
  11. this.setOptions(options);
  12. this.restLoadActions = MWF.Actions.load("x_organization_assemble_control");
  13. this.node = $(node);
  14. },
  15. _isActionManager: function(){
  16. return (MWF.AC.isOrganizationManager() || MWF.AC.isPersonManager() || MWF.AC.isUnitManager());
  17. },
  18. _loadLp: function(){
  19. this.options.lp = {
  20. "queryPrivateConfigTitle": this.app.lp.queryPrivateConfigTitle,
  21. "queryPrivateConfigExcludUnit": this.app.lp.queryPrivateConfigExcludUnit,
  22. "queryPrivateConfigExcludPerson": this.app.lp.queryPrivateConfigExcludPerson,
  23. "queryPrivateConfigLimitOuter": this.app.lp.queryPrivateConfigLimitOuter,
  24. "queryPrivateConfigLimitAll": this.app.lp.queryPrivateConfigLimitAll,
  25. "queryPrivateConfigDescribe": this.app.lp.queryPrivateConfigDescribe,
  26. "queryPrivateConfigBtnEdit": this.app.lp.queryPrivateConfigBtnEdit,
  27. "queryPrivateConfigBtnSave": this.app.lp.queryPrivateConfigBtnSave,
  28. "queryPrivateConfigBtnCancel": this.app.lp.queryPrivateConfigBtnCancel
  29. }
  30. },
  31. _loadConfig:function(){
  32. this.ConfigContent = new MWF.xApplication.Org.PrivateConfig.ConfigContent(this);
  33. this.ConfigContent.load();
  34. },
  35. load: function(){
  36. this._loadLp();
  37. this._loadConfig();
  38. }
  39. });
  40. MWF.xApplication.Org.PrivateConfig.ConfigContent = new Class({
  41. initialize: function(content){
  42. debugger;
  43. this.content = content;
  44. this.lp = this.content.options.lp;
  45. this.restLoadActions = MWF.Actions.load("x_organization_assemble_control");
  46. this.data = {};
  47. this.data["id"] = "";
  48. this.data["excludeUnit"]=[];
  49. this.data["excludePerson"]=[];
  50. this.data["limitQueryOuter"]=[];
  51. this.data["limitQueryAll"]=[];
  52. this.data["explain"]="";
  53. this.data["status"]="发布";
  54. this.contentNode = this.content.node;
  55. this.mode = "read";
  56. },
  57. load: function(){
  58. //get data
  59. this.restLoadActions.PermissionSettingAction.list(function( json ){
  60. if (json.data.length){
  61. this.data = json.data[0];
  62. }
  63. }.bind(this),null,false);
  64. debugger;
  65. this.node = new Element("div").inject(this.contentNode);
  66. this.editContentNode = new Element("div").inject(this.node);
  67. this.editContentNode.set("html", this.getContentHtml());
  68. var n = this.editContentNode.getElement(".excludeUnit");
  69. var displaynames =[];
  70. this.data.excludeUnit.each(function(ptv){
  71. displaynames.push(ptv.split("@")[0]);
  72. })
  73. if (n) n.set("text", displaynames.join() || "");
  74. displaynames =[];
  75. this.data.excludePerson.each(function(ptv){
  76. displaynames.push(ptv.split("@")[0]);
  77. })
  78. var n = this.editContentNode.getElement(".excludePerson");
  79. if (n) n.set("text", displaynames.join() || "");
  80. displaynames =[];
  81. this.data.limitQueryOuter.each(function(ptv){
  82. displaynames.push(ptv.split("@")[0]);
  83. })
  84. var n = this.editContentNode.getElement(".limitQueryOuter");
  85. if (n) n.set("text", displaynames.join() || "");
  86. displaynames =[];
  87. this.data.limitQueryAll.each(function(ptv){
  88. displaynames.push(ptv.split("@")[0]);
  89. })
  90. var n = this.editContentNode.getElement(".limitQueryAll");
  91. if (n) n.set("text", displaynames.join() || "");
  92. var n = this.editContentNode.getElement(".explain");
  93. if (n) n.set("text", this.data.explain || "");
  94. var tdContents = this.editContentNode.getElements("td.inforContent");
  95. //if (this.data.excludeUnit) new MWF.widget.O2Unit({"name": this.data.excludeUnit}, tdContents[0], {"style": "xform"});
  96. //if (this.data.excludePerson) new MWF.widget.O2Person({"name": this.data.excludePerson}, tdContents[1], {"style": "xform"});
  97. //if (this.data.limitQueryOuter) new MWF.widget.O2Identity({"name": this.data.limitQueryOuter}, tdContents[2], {"style": "xform"});
  98. //if (this.data.limitQueryAll) new MWF.widget.O2Identity({"name": this.data.limitQueryAll}, tdContents[3], {"style": "xform"});
  99. this.loadAction();
  100. },
  101. getContentHtml: function(){
  102. var html = "<table class='queryPrivateConfigTable'>";
  103. html += "<tr><td class='tabletitle' colspan=2>"+this.lp.queryPrivateConfigTitle+"</td></tr>"
  104. html += "<tr><td class='inforTitle'>"+this.lp.queryPrivateConfigExcludUnit+":</td><td class='inforContent excludeUnit'></td></tr>";
  105. html += "<td class='inforTitle'>"+this.lp.queryPrivateConfigExcludPerson+":</td><td class='inforContent excludePerson'></td></tr>";
  106. html += "<tr><td class='inforTitle'>"+this.lp.queryPrivateConfigLimitOuter+":</td><td class='inforContent limitQueryOuter'></td></tr>" ;
  107. html += "<td class='inforTitle'>"+this.lp.queryPrivateConfigLimitAll+":</td><td class='inforContent limitQueryAll'></td></tr>";
  108. html += "<tr><td class='inforTitle'>"+this.lp.queryPrivateConfigDescribe+":</td><td class='inforContent explain'></td></tr>";
  109. html += "<tr><td colspan='2' class='inforAction'></td></tr>";
  110. //this.baseInforRightNode.set("html", html);
  111. return html;
  112. },
  113. loadAction: function(){
  114. //this.explorer.app.lp.edit
  115. var actionAreas = this.editContentNode.getElements("td");
  116. var actionArea = actionAreas[actionAreas.length-1];
  117. if (MWF.AC.isOrganizationManager() || MWF.AC.isPersonManager() || MWF.AC.isUnitManager()){
  118. this.baseInforEditActionAreaNode = new Element("div", {"class": "queryPrivateConfigBtnNode"}).inject(actionArea);
  119. this.editNode = new Element("div", {"class": "queryPrivateConfigBtnEditNode", "text": this.lp.queryPrivateConfigBtnEdit}).inject(this.baseInforEditActionAreaNode);
  120. this.saveNode = new Element("div", {"class": "queryPrivateConfigBtnSaveNode", "text": this.lp.queryPrivateConfigBtnSave}).inject(this.baseInforEditActionAreaNode);
  121. this.cancelNode = new Element("div", {"class":"queryPrivateConfigBtnCancelNode", "text": this.lp.queryPrivateConfigBtnCancel}).inject(this.baseInforEditActionAreaNode);
  122. this.editNode.setStyle("display", "block");
  123. this.editNode.addEvent("click", this.edit.bind(this));
  124. this.saveNode.addEvent("click", this.save.bind(this));
  125. this.cancelNode.addEvent("click", this.cancel.bind(this));
  126. }else{
  127. }
  128. },
  129. edit: function(){
  130. var tdContents = this.editContentNode.getElements("td.inforContent");
  131. tdContents[0].empty();
  132. this.excludeUnitInputNode = new Element("div", {"class": "inputPersonNode"}).inject(tdContents[0]);
  133. if (this.data.excludeUnit){
  134. this.data.excludeUnit.each(function(perv){
  135. new MWF.widget.O2Unit({"name":perv.split("@")[0]}, this.excludeUnitInputNode, {"style": "xform"});
  136. }.bind(this))
  137. }
  138. this.excludeUnitInputNode.addEvent("click", function(){
  139. MWF.xDesktop.requireApp("Selector", "package", function(){
  140. var options = {
  141. "type": "unit",
  142. "values": this.data.excludeUnit,
  143. "count": 0,
  144. "onComplete": function(items){
  145. var ids= [];
  146. var persons = [];
  147. var displaynames = [];
  148. items.each(function(item){
  149. ids.push(item.data.id);
  150. persons.push(item.data.distinguishedName);
  151. });
  152. this.data.excludeUnit = persons;
  153. this.excludeUnitInputNode.empty();
  154. this.data.excludeUnit.each(function(perv){
  155. new MWF.widget.O2Unit({"name":perv.split("@")[0]}, this.excludeUnitInputNode, {"style": "xform"});
  156. }.bind(this))
  157. }.bind(this)
  158. };
  159. var selector = new MWF.O2Selector(this.contentNode, options);
  160. }.bind(this));
  161. }.bind(this));
  162. tdContents[1].empty();
  163. this.excludePersonInputNode = new Element("div", {"class": "inputPersonNode"}).inject(tdContents[1]);
  164. //this.superiorInputNode.set("value", (this.data.superior));
  165. if (this.data.excludePerson){
  166. this.data.excludePerson.each(function(perv){
  167. new MWF.widget.O2Person({"name":perv.split("@")[0]}, this.excludePersonInputNode, {"style": "xform"});
  168. }.bind(this))
  169. }
  170. this.excludePersonInputNode.addEvent("click", function(){
  171. MWF.xDesktop.requireApp("Selector", "package", function(){
  172. var options = {
  173. "type": "person",
  174. "values": this.data.excludePerson,
  175. "count": 0,
  176. "onComplete": function(items){
  177. var ids= [];
  178. var persons = [];
  179. items.each(function(item){
  180. ids.push(item.data.id);
  181. persons.push(item.data.distinguishedName);
  182. });
  183. this.data.excludePerson = persons;
  184. this.excludePersonInputNode.empty();
  185. this.data.excludePerson.each(function(perv){
  186. new MWF.widget.O2Person({"name":perv.split("@")[0]}, this.excludePersonInputNode, {"style": "xform"});
  187. }.bind(this))
  188. }.bind(this)
  189. };
  190. var selector = new MWF.O2Selector(this.contentNode, options);
  191. }.bind(this));
  192. }.bind(this));
  193. tdContents[2].empty();
  194. this.limitQueryOuterInputNode = new Element("div", {"class": "inputPersonNode"}).inject(tdContents[2]);
  195. //this.superiorInputNode.set("value", (this.data.superior));
  196. if (this.data.limitQueryOuter){
  197. this.data.limitQueryOuter.each(function(perv){
  198. new MWF.widget.O2Person({"name":perv.split("@")[0]}, this.limitQueryOuterInputNode, {"style": "xform"});
  199. }.bind(this))
  200. }
  201. this.limitQueryOuterInputNode.addEvent("click", function(){
  202. MWF.xDesktop.requireApp("Selector", "package", function(){
  203. var options = {
  204. "type": "person",
  205. "values": this.data.limitQueryOuter,
  206. "count": 0,
  207. "onComplete": function(items){
  208. var ids= [];
  209. var persons = [];
  210. items.each(function(item){
  211. ids.push(item.data.id);
  212. persons.push(item.data.distinguishedName);
  213. });
  214. this.data.limitQueryOuter = persons;
  215. this.limitQueryOuterInputNode.empty();
  216. this.data.limitQueryOuter.each(function(perv){
  217. new MWF.widget.O2Person({"name":perv.split("@")[0]}, this.limitQueryOuterInputNode, {"style": "xform"});
  218. }.bind(this))
  219. }.bind(this)
  220. };
  221. var selector = new MWF.O2Selector(this.contentNode, options);
  222. }.bind(this));
  223. }.bind(this));
  224. tdContents[3].empty();
  225. this.limitQueryAllInputNode = new Element("div", {"class": "inputPersonNode"}).inject(tdContents[3]);
  226. //this.superiorInputNode.set("value", (this.data.superior));
  227. if (this.data.limitQueryAll){
  228. this.data.limitQueryAll.each(function(perv){
  229. new MWF.widget.O2Person({"name":perv.split("@")[0]}, this.limitQueryAllInputNode, {"style": "xform"});
  230. }.bind(this))
  231. }
  232. this.limitQueryAllInputNode.addEvent("click", function(){
  233. MWF.xDesktop.requireApp("Selector", "package", function(){
  234. var options = {
  235. "type": "person",
  236. "values": this.data.limitQueryAll,
  237. "count": 0,
  238. "onComplete": function(items){
  239. var ids= [];
  240. var persons = [];
  241. items.each(function(item){
  242. ids.push(item.data.id);
  243. persons.push(item.data.distinguishedName);
  244. });
  245. this.data.limitQueryAll = persons;
  246. this.limitQueryAllInputNode.empty();
  247. this.data.limitQueryAll.each(function(perv){
  248. new MWF.widget.O2Person({"name":perv.split("@")[0]}, this.limitQueryAllInputNode, {"style": "xform"});
  249. }.bind(this))
  250. }.bind(this)
  251. };
  252. var selector = new MWF.O2Selector(this.contentNode, options);
  253. }.bind(this));
  254. }.bind(this));
  255. tdContents[4].empty();
  256. this.explainInputNode = new Element("input", {"class": "inputNode"}).inject(tdContents[4]);
  257. this.explainInputNode.set("value", (this.data.explain));
  258. var _self = this;
  259. /*
  260. this.editContentNode.getElements("input").addEvents({
  261. "focus": function(){if (this.get("type").toLowerCase()==="text"){this.setStyles(_self.style.inputNode_focus);}},
  262. "blur": function(){if (this.get("type").toLowerCase()==="text"){this.setStyles(_self.style.inputNode_blur);}}
  263. });
  264. */
  265. this.mode = "edit";
  266. this.editNode.setStyle("display", "none");
  267. this.saveNode.setStyle("display", "block");
  268. this.cancelNode.setStyle("display", "block");
  269. },
  270. save: function(){
  271. //this.data.genderType = gender;
  272. debugger;
  273. var tdContents = this.editContentNode.getElements("td.inforContent");
  274. this.data["explain"]=tdContents[4].getElements(".inputNode")[0].get("value");
  275. /*
  276. this.content.propertyContentScrollNode.mask({
  277. "style": {
  278. "opacity": 0.7,
  279. "background-color": "#999"
  280. }
  281. });
  282. */
  283. if (this.data.id=="") {
  284. this.restLoadActions.PermissionSettingAction.create(
  285. this.data,
  286. function( json ){
  287. data = json.data;
  288. this.cancel();
  289. //this.content.propertyContentScrollNode.unmask();
  290. }.bind(this),null,false);
  291. }else{
  292. this.restLoadActions.PermissionSettingAction.update(
  293. this.data.id,
  294. this.data,
  295. function( json ){
  296. data = json.data;
  297. this.cancel();
  298. //this.content.propertyContentScrollNode.unmask();
  299. }.bind(this),null,false);
  300. }
  301. debugger;
  302. },
  303. cancel: function(){
  304. this.node.empty();
  305. this.load();
  306. },
  307. destroy: function(){
  308. this.node.empty();
  309. this.node.destroy();
  310. MWF.release(this);
  311. }
  312. });