Duty.js 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  1. MWF.xApplication.Organization.Selector = MWF.xApplication.Organization.Selector || {};
  2. MWF.xDesktop.requireApp("Organization", "Actions.RestActions", null, false);
  3. MWF.xDesktop.requireApp("Organization", "Selector.Identity", null, false);
  4. MWF.xApplication.Organization.Selector.Duty = new Class({
  5. Extends: MWF.xApplication.Organization.Selector.Identity,
  6. options: {
  7. "style": "default",
  8. "count": 0,
  9. "title": "Select Duty",
  10. "companys": [],
  11. "departments": [],
  12. "values": [],
  13. "names": [],
  14. "expand": false
  15. },
  16. initialize: function(container, options){
  17. this.setOptions(options);
  18. this.options.groups = [];
  19. this.options.roles = [];
  20. this.path = "/x_component_Organization/Selector/$Selector/";
  21. this.cssPath = "/x_component_Organization/Selector/$Selector/"+this.options.style+"/css.wcss";
  22. this._loadCss();
  23. this.container = $(container);
  24. this.action = new MWF.xApplication.Organization.Actions.RestActions();
  25. this.lastPeople = "";
  26. this.pageCount = "13";
  27. this.selectedItems = [];
  28. this.items = [];
  29. },
  30. loadSelectItems: function(addToNext){
  31. this.comapnyCategory = this._newItemCategory("Category", {
  32. "name": "公司职务",
  33. "id": "company"
  34. }, this, this.itemAreaNode);
  35. this.comapnyCategory = this._newItemCategory("Category", {
  36. "name": "部门职务",
  37. "id": "department"
  38. }, this, this.itemAreaNode);
  39. //this.action.listTopCompany(function(json){
  40. // json.data.each(function(data){
  41. // var category = this._newItemCategory("ItemCompanyCategory", data, this, this.itemAreaNode);
  42. // }.bind(this));
  43. //}.bind(this));
  44. },
  45. _scrollEvent: function(y){
  46. return true;
  47. },
  48. _getChildrenItemIds: function(){
  49. return null;
  50. },
  51. _newItemCategory: function(type, data, selector, item, level){
  52. return new MWF.xApplication.Organization.Selector.Duty[type](data, selector, item, level)
  53. },
  54. _listItemByKey: function(callback, failure, key){
  55. this.action.listDepartmentByKey(function(json){
  56. if (callback) callback.apply(this, [json]);
  57. }.bind(this), failure, key);
  58. },
  59. _getItem: function(callback, failure, id, async){
  60. this.action.getDepartment(function(json){
  61. if (callback) callback.apply(this, [json]);
  62. }.bind(this), failure, id, async);
  63. },
  64. _newItemSelected: function(data, selector, item){
  65. return new MWF.xApplication.Organization.Selector.Duty.ItemSelected(data, selector, item)
  66. },
  67. _listItemByPinyin: function(callback, failure, key){
  68. this.action.listDepartmentByKey(function(json){
  69. if (callback) callback.apply(this, [json]);
  70. }.bind(this), failure, key);
  71. },
  72. _newItem: function(data, selector, container, level){
  73. return new MWF.xApplication.Organization.Selector.Duty.Item(data, selector, container, level);
  74. }
  75. });
  76. MWF.xApplication.Organization.Selector.Duty.Item = new Class({
  77. Extends: MWF.xApplication.Organization.Selector.Person.Item,
  78. _getShowName: function(){
  79. return this.data.name;
  80. },
  81. _setIcon: function(){
  82. this.iconNode.setStyle("background-image", "url("+"/x_component_Organization/Selector/$Selector/default/icon/duty.png)");
  83. }
  84. //selected: function(){
  85. // if ((this.selector.options.count==0) || (this.selector.selectedItems.length+1)<=this.selector.options.count){
  86. // this.isSelected = true;
  87. // this.node.setStyles(this.selector.css.selectorItem_selected);
  88. // this.textNode.setStyles(this.selector.css.selectorItemTextNode_selected);
  89. //
  90. // this.createInputDialog();
  91. //
  92. // //this.actionNode.setStyles(this.selector.css.selectorItemActionNode_selected);
  93. // //
  94. // //this.selectedItem = this.selector._newItemSelected(this.data, this.selector, this);
  95. // //this.selectedItem.check();
  96. // //this.selector.selectedItems.push(this.selectedItem);
  97. // }else{
  98. // MWF.xDesktop.notice("error", {x: "right", y:"top"}, "最多可选择"+this.selector.options.count+"个选项", this.selector.node);
  99. // }
  100. //},
  101. //unSelected: function(){
  102. // //if (this.isSelected){
  103. // // this.node.addEvent("click", function(){
  104. // // this.clickItem();
  105. // // }.bind(this));
  106. // //}
  107. // this.isSelected = false;
  108. // this.node.setStyles(this.selector.css.selectorItem);
  109. // this.textNode.setStyles(this.selector.css.selectorItemTextNode);
  110. // this.actionNode.setStyles(this.selector.css.selectorItemActionNode);
  111. //
  112. // if (this.selectedItem){
  113. // this.selector.selectedItems.erase(this.selectedItem);
  114. //
  115. // this.selectedItem.items.each(function(item){
  116. // if (item != this){
  117. // item.isSelected = false;
  118. // item.node.setStyles(this.selector.css.selectorItem);
  119. // item.textNode.setStyles(this.selector.css.selectorItemTextNode);
  120. // item.actionNode.setStyles(this.selector.css.selectorItemActionNode);
  121. // }
  122. // }.bind(this));
  123. //
  124. // this.selectedItem.destroy();
  125. // this.selectedItem = null;
  126. // }
  127. //
  128. // if (this.inputDialog){
  129. // this.inputDialog.destroy();
  130. // this.inputDialog = null;
  131. // this.inputNode = null;
  132. // }
  133. //},
  134. //createInputDialog: function(){
  135. // var levelSize = this.levelNode.getSize();
  136. // var iconSize = this.iconNode.getSize();
  137. // var height = levelSize.y*3;
  138. //
  139. // this.node.set("tween", {"duration": 100});
  140. // this.node.tween("height", ""+height+"px");
  141. // this.inputDialog = new Element("div", {"styles": this.selector.css.dutyInputDialog}).inject(this.node);
  142. // this.inputNode = new Element("input", {"styles": this.selector.css.dutyInputNode}).inject(this.inputDialog);
  143. //
  144. // this.node.removeEvents("click");
  145. //
  146. //
  147. // MWF.xDesktop.requireApp("process.ProcessDesigner", "widget.ScriptText", function(){
  148. // var script = new MWF.xApplication.process.ProcessDesigner.widget.ScriptText(node, this.data[node.get("name")], this.process.designer, {
  149. // "maskNode": this.process.designer.content,
  150. // "maxObj": this.process.designer.paperNode,
  151. // "onChange": function(code){
  152. // _self.data[node.get("name")] = code;
  153. // }
  154. // });
  155. // }.bind(this));
  156. //
  157. //
  158. // //if (!this.inputDialog){
  159. // // //this.inputDialog = new Element("div", {"styles": this.selector.css.dutyInputDialog}).inject(this.selector.node);
  160. // // //this.inputDialog.position({
  161. // // // relativeTo: this.node,
  162. // // // position: "top",
  163. // // // edge: "top"
  164. // // //});
  165. // //}
  166. //
  167. //}
  168. });
  169. MWF.xApplication.Organization.Selector.Duty.ItemSelected = new Class({
  170. Extends: MWF.xApplication.Organization.Selector.Person.ItemSelected,
  171. _getShowName: function(){
  172. return this.data.name;
  173. },
  174. _setIcon: function(){
  175. this.iconNode.setStyle("background-image", "url("+"/x_component_Organization/Selector/$Selector/default/icon/duty.png)");
  176. }
  177. });
  178. MWF.xApplication.Organization.Selector.Duty.Category = new Class({
  179. Extends: MWF.xApplication.Organization.Selector.Identity.ItemCompanyCategory,
  180. _getShowName: function(){
  181. return this.data.name;
  182. },
  183. _setIcon: function(){
  184. this.iconNode.setStyle("background-image", "url("+"/x_component_Organization/Selector/$Selector/default/icon/dutyCategory.png)");
  185. },
  186. loadSub: function(callback){
  187. if (!this.loaded){
  188. if (this.data.id=="company"){
  189. this.selector.action.listCompanyDutyName(function(json){
  190. json.data.valueList.each(function(value){
  191. this.selector._newItem({"name": value}, this.selector, this.children, this.level+1);
  192. }.bind(this));
  193. }.bind(this));
  194. }
  195. if (this.data.id=="department"){
  196. this.selector.action.listDepartmentDutyName(function(json){
  197. json.data.valueList.each(function(value){
  198. this.selector._newItem({"name": value}, this.selector, this.children, this.level+1);
  199. }.bind(this));
  200. }.bind(this));
  201. }
  202. this.loaded = true;
  203. if (callback) callback();
  204. //this.selector.action.listSubComplexDirect(function(subJson){
  205. // subJson.data.companyList.each(function(subData){
  206. // var category = this.selector._newItemCategory("ItemCompanyCategory", subData, this.selector, this.children, this.level+1);
  207. // }.bind(this));
  208. // subJson.data.departmentList.each(function(subData){
  209. // var category = this.selector._newItem(subData, this.selector, this.children, this.level+1);
  210. // }.bind(this));
  211. //
  212. // this.loaded = true;
  213. // if (callback) callback();
  214. //
  215. //}.bind(this), null, this.data.id);
  216. }else{
  217. if (callback) callback();
  218. }
  219. },
  220. _hasChild: function(){
  221. return true;
  222. }
  223. });