| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246 |
- MWF.xApplication.Selector = MWF.xApplication.Selector || {};
- MWF.xDesktop.requireApp("Selector", "Actions.RestActions", null, false);
- MWF.xDesktop.requireApp("Selector", "Person", null, false);
- MWF.xApplication.Selector.Identity = new Class({
- Extends: MWF.xApplication.Selector.Person,
- options: {
- "style": "default",
- "count": 0,
- "title": "Select Identity",
- "companys": [],
- "departments": [],
- "values": [],
- "names": [],
- "expand": false
- },
- initialize: function(container, options){
- this.setOptions(options);
- this.options.groups = [];
- this.options.roles = [];
- this.path = "/x_component_Selector/$Selector/";
- this.cssPath = "/x_component_Selector/$Selector/"+this.options.style+"/css.wcss";
- this._loadCss();
- this.container = $(container);
- this.action = new MWF.xApplication.Selector.Actions.RestActions();
- this.lastPeople = "";
- this.pageCount = "13";
- this.selectedItems = [];
- this.items = [];
- },
- //loadCompanylevel: function(parent){
- //
- // this.action.listSubComplexDirect(function(subJson){
- // subJson.data.companyList.each(function(subData){
- // var category = this._newItemCategory("ItemCompanyCategory", subData, this, parent.children, parent.level+1);
- // this.loadCompanylevel(category);
- // }.bind(this));
- // subJson.data.departmentList.each(function(subData){
- // var category = this._newItemCategory("ItemDepartmentCategory", subData, this, parent.children, parent.level+1);
- // this.loadDepartmentlevel(category);
- // }.bind(this));
- // }.bind(this), null, parent.data.id);
- //},
- //loadDepartmentlevel: function(parent){
- // this.action.listSubDepartment(function(subJson){
- // subJson.data.each(function(subData){
- // var category = this._newItemCategory("ItemDepartmentCategory", subData, this, parent.children, parent.level+1);
- // this.loadDepartmentlevel(category);
- // }.bind(this));
- // }.bind(this), null, parent.data.id);
- //},
- loadSelectItems: function(addToNext){
- if (this.options.companys.length || this.options.departments.length){
- this.options.companys.each(function(comp){
- this.action.listCompanyByKey(function(json){
- if (json.data.length){
- json.data.each(function(data){
- var category = this._newItemCategory("ItemCompanyCategory", data, this, this.itemAreaNode);
- }.bind(this));
- }
- }.bind(this), null, comp);
- }.bind(this));
- this.options.departments.each(function(depart){
- this.action.listDepartmentByKey(function(json){
- if (json.data.length){
- json.data.each(function(data){
- var category = this._newItemCategory("ItemDepartmentCategory", data, this, this.itemAreaNode);
- }.bind(this));
- }
- }.bind(this), null, depart);
- }.bind(this));
- }else{
- this.action.listTopCompany(function(json){
- json.data.each(function(data){
- var category = this._newItemCategory("ItemCompanyCategory", data, this, this.itemAreaNode);
- }.bind(this));
- }.bind(this));
- }
- },
- _scrollEvent: function(y){
- return true;
- },
- _getChildrenItemIds: function(){
- return null;
- },
- _newItemCategory: function(type, data, selector, item, level){
- return new MWF.xApplication.Selector.Identity[type](data, selector, item, level)
- },
- _listItemByKey: function(callback, failure, key){
- this.action.listIdentityByKey(function(json){
- if (callback) callback.apply(this, [json]);
- }.bind(this), failure, key);
- },
- _getItem: function(callback, failure, id, async){
- this.action.getIdentity(function(json){
- if (callback) callback.apply(this, [json]);
- }.bind(this), failure, id, async);
- },
- _newItemSelected: function(data, selector, item){
- return new MWF.xApplication.Selector.Identity.ItemSelected(data, selector, item)
- },
- _listItemByPinyin: function(callback, failure, key){
- this.action.listIdentityByPinyin(function(json){
- if (callback) callback.apply(this, [json]);
- }.bind(this), failure, key);
- },
- _newItem: function(data, selector, container, level){
- return new MWF.xApplication.Selector.Identity.Item(data, selector, container, level);
- }
- //_listItemNext: function(last, count, callback){
- // this.action.listRoleNext(last, count, function(json){
- // if (callback) callback.apply(this, [json]);
- // }.bind(this));
- //}
- });
- MWF.xApplication.Selector.Identity.Item = new Class({
- Extends: MWF.xApplication.Selector.Person.Item,
- _getShowName: function(){
- return this.data.name;
- },
- _setIcon: function(){
- this.iconNode.setStyle("background-image", "url("+"/x_component_Selector/$Selector/default/icon/personicon.png)");
- }
- });
- MWF.xApplication.Selector.Identity.ItemSelected = new Class({
- Extends: MWF.xApplication.Selector.Person.ItemSelected,
- _getShowName: function(){
- return this.data.name;
- },
- _setIcon: function(){
- this.iconNode.setStyle("background-image", "url("+"/x_component_Selector/$Selector/default/icon/personicon.png)");
- }
- });
- MWF.xApplication.Selector.Identity.ItemCompanyCategory = new Class({
- Extends: MWF.xApplication.Selector.Person.ItemCategory,
- _getShowName: function(){
- return this.data.name;
- },
- _setIcon: function(){
- this.iconNode.setStyle("background-image", "url("+"/x_component_Selector/$Selector/default/icon/companyicon.png)");
- },
- clickItem: function(){
- if (this._hasChild()){
- this.loadSub(function(){
- var display = this.children.getStyle("display");
- if (display == "none"){
- this.children.setStyles({"display": "block", "height": "auto"});
- this.actionNode.setStyles(this.selector.css.selectorItemCategoryActionNode_expand);
- }else{
- this.children.setStyles({"display": "none", "height": "0px"});
- this.actionNode.setStyles(this.selector.css.selectorItemCategoryActionNode_collapse);
- }
- }.bind(this));
- }
- },
- loadSub: function(callback){
- if (!this.loaded){
- this.selector.action.listSubComplexDirect(function(subJson){
- subJson.data.companyList.each(function(subData){
- var category = this.selector._newItemCategory("ItemCompanyCategory", subData, this.selector, this.children, this.level+1);
- }.bind(this));
- subJson.data.departmentList.each(function(subData){
- var category = this.selector._newItemCategory("ItemDepartmentCategory", subData, this.selector, this.children, this.level+1);
- }.bind(this));
- this.loaded = true;
- if (callback) callback();
- }.bind(this), null, this.data.name);
- }else{
- if (callback) callback();
- }
- },
- _hasChild: function(){
- var cCount = (this.data.companySubDirectCount) ? this.data.companySubDirectCount : 0;
- var dCount = (this.data.departmentSubDirectCount) ? this.data.departmentSubDirectCount : 0;
- var count = cCount + dCount;
- if (count) return true;
- return true;
- }
- });
- MWF.xApplication.Selector.Identity.ItemDepartmentCategory = new Class({
- Extends: MWF.xApplication.Selector.Identity.ItemCompanyCategory,
- createNode: function(){
- this.node = new Element("div", {
- "styles": this.selector.css.selectorItemCategory_department
- }).inject(this.container);
- },
- loadSub: function(callback){
- if (!this.loaded){
- // if (this.data.departmentSubDirectCount){
- this.selector.action.listSubDepartment(function(subJson){
- subJson.data.each(function(subData){
- var category = this.selector._newItemCategory("ItemDepartmentCategory", subData, this.selector, this.children, this.level+1);
- }.bind(this));
- }.bind(this), null, this.data.name);
- // }
- // if (this.data.identitySubDirectCount){
- this.selector.action.listIdentity(function(subJson){
- subJson.data.each(function(subData){
- var item = this.selector._newItem(subData, this.selector, this.children, this.level+1);
- this.selector.items.push(item);
- }.bind(this));
- }.bind(this), null, this.data.name);
- // }
- this.loaded = true;
- if (callback) callback();
- }else{
- if (callback) callback();
- }
- },
- _hasChild: function(){
- var cCount = (this.data.companySubDirectCount) ? this.data.companySubDirectCount : 0;
- var dCount = (this.data.departmentSubDirectCount) ? this.data.departmentSubDirectCount : 0;
- var iCount = (this.data.identitySubDirectCount) ? this.data.identitySubDirectCount : 0;
- var count = cCount + dCount + iCount;
- if (count) return true;
- return true;
- },
- _getShowName: function(){
- return this.data.name;
- },
- _setIcon: function(){
- this.iconNode.setStyle("background-image", "url("+"/x_component_Selector/$Selector/default/icon/departmenticon.png)");
- }
- });
|